12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559 |
- /*!
- * bpmn-js - bpmn-modeler v0.11.0
- * Copyright 2014, 2015 camunda Services GmbH and other contributors
- *
- * Released under the bpmn.io license
- * http://bpmn.io/license
- *
- * Source Code: https://github.com/bpmn-io/bpmn-js
- *
- * Date: 2015-08-06
- */
- !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){
- 'use strict';
- var inherits = _dereq_(207);
- var IdSupport = _dereq_(53),
- Ids = _dereq_(205);
- var Viewer = _dereq_(2);
- var initialDiagram =
- '<?xml version="1.0" encoding="UTF-8"?>' +
- '<bpmn:definitions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ' +
- 'xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" ' +
- 'xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" ' +
- 'xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" ' +
- 'targetNamespace="http://bpmn.io/schema/bpmn" ' +
- 'id="Definitions_1">' +
- '<bpmn:process id="Process_1" isExecutable="false">' +
- '<bpmn:startEvent id="StartEvent_1"/>' +
- '</bpmn:process>' +
- '<bpmndi:BPMNDiagram id="BPMNDiagram_1">' +
- '<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1">' +
- '<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">' +
- '<dc:Bounds height="36.0" width="36.0" x="173.0" y="102.0"/>' +
- '</bpmndi:BPMNShape>' +
- '</bpmndi:BPMNPlane>' +
- '</bpmndi:BPMNDiagram>' +
- '</bpmn:definitions>';
- /**
- * A modeler for BPMN 2.0 diagrams.
- *
- *
- * ## Extending the Modeler
- *
- * In order to extend the viewer pass extension modules to bootstrap via the
- * `additionalModules` option. An extension module is an object that exposes
- * named services.
- *
- * The following example depicts the integration of a simple
- * logging component that integrates with interaction events:
- *
- *
- * ```javascript
- *
- * // logging component
- * function InteractionLogger(eventBus) {
- * eventBus.on('element.hover', function(event) {
- * console.log()
- * })
- * }
- *
- * InteractionLogger.$inject = [ 'eventBus' ]; // minification save
- *
- * // extension module
- * var extensionModule = {
- * __init__: [ 'interactionLogger' ],
- * interactionLogger: [ 'type', InteractionLogger ]
- * };
- *
- * // extend the viewer
- * var bpmnModeler = new Modeler({ additionalModules: [ extensionModule ] });
- * bpmnModeler.importXML(...);
- * ```
- *
- *
- * ## Customizing / Replacing Components
- *
- * You can replace individual diagram components by redefining them in override modules.
- * This works for all components, including those defined in the core.
- *
- * Pass in override modules via the `options.additionalModules` flag like this:
- *
- * ```javascript
- * function CustomContextPadProvider(contextPad) {
- *
- * contextPad.registerProvider(this);
- *
- * this.getContextPadEntries = function(element) {
- * // no entries, effectively disable the context pad
- * return {};
- * };
- * }
- *
- * CustomContextPadProvider.$inject = [ 'contextPad' ];
- *
- * var overrideModule = {
- * contextPadProvider: [ 'type', CustomContextPadProvider ]
- * };
- *
- * var bpmnModeler = new Modeler({ additionalModules: [ overrideModule ]});
- * ```
- *
- * @param {Object} [options] configuration options to pass to the viewer
- * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
- * @param {String|Number} [options.width] the width of the viewer
- * @param {String|Number} [options.height] the height of the viewer
- * @param {Object} [options.moddleExtensions] extension packages to provide
- * @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
- * @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
- */
- function Modeler(options) {
- Viewer.call(this, options);
- }
- inherits(Modeler, Viewer);
- Modeler.prototype.createDiagram = function(done) {
- return this.importXML(initialDiagram, done);
- };
- Modeler.prototype.createModdle = function() {
- var moddle = Viewer.prototype.createModdle.call(this);
- IdSupport.extend(moddle, new Ids([ 32, 36, 1 ]));
- return moddle;
- };
- Modeler.prototype._interactionModules = [
- // non-modeling components
- _dereq_(14),
- _dereq_(182),
- _dereq_(178),
- _dereq_(179)
- ];
- Modeler.prototype._modelingModules = [
- // modeling components
- _dereq_(139),
- _dereq_(96),
- _dereq_(152),
- _dereq_(166),
- _dereq_(114),
- _dereq_(10),
- _dereq_(42),
- _dereq_(32),
- _dereq_(8),
- _dereq_(36)
- ];
- // modules the modeler is composed of
- //
- // - viewer modules
- // - interaction modules
- // - modeling modules
- Modeler.prototype._modules = [].concat(
- Modeler.prototype._modules,
- Modeler.prototype._interactionModules,
- Modeler.prototype._modelingModules);
- module.exports = Modeler;
- },{"10":10,"114":114,"139":139,"14":14,"152":152,"166":166,"178":178,"179":179,"182":182,"2":2,"205":205,"207":207,"32":32,"36":36,"42":42,"53":53,"8":8,"96":96}],2:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- omit = _dereq_(343),
- isString = _dereq_(336),
- isNumber = _dereq_(333);
- var domify = _dereq_(356),
- domQuery = _dereq_(359),
- domRemove = _dereq_(360);
- var Diagram = _dereq_(76),
- BpmnModdle = _dereq_(51);
- var Importer = _dereq_(45);
- function initListeners(diagram, listeners) {
- var events = diagram.get('eventBus');
- listeners.forEach(function(l) {
- events.on(l.event, l.handler);
- });
- }
- function checkValidationError(err) {
- // check if we can help the user by indicating wrong BPMN 2.0 xml
- // (in case he or the exporting tool did not get that right)
- var pattern = /unparsable content <([^>]+)> detected([\s\S]*)$/;
- var match = pattern.exec(err.message);
- if (match) {
- err.message =
- 'unparsable content <' + match[1] + '> detected; ' +
- 'this may indicate an invalid BPMN 2.0 diagram file' + match[2];
- }
- return err;
- }
- var DEFAULT_OPTIONS = {
- width: '100%',
- height: '100%',
- position: 'relative',
- container: 'body'
- };
- /**
- * Ensure the passed argument is a proper unit (defaulting to px)
- */
- function ensureUnit(val) {
- return val + (isNumber(val) ? 'px' : '');
- }
- /**
- * A viewer for BPMN 2.0 diagrams.
- *
- * Have a look at {@link NavigatedViewer} or {@link Modeler} for bundles that include
- * additional features.
- *
- *
- * ## Extending the Viewer
- *
- * In order to extend the viewer pass extension modules to bootstrap via the
- * `additionalModules` option. An extension module is an object that exposes
- * named services.
- *
- * The following example depicts the integration of a simple
- * logging component that integrates with interaction events:
- *
- *
- * ```javascript
- *
- * // logging component
- * function InteractionLogger(eventBus) {
- * eventBus.on('element.hover', function(event) {
- * console.log()
- * })
- * }
- *
- * InteractionLogger.$inject = [ 'eventBus' ]; // minification save
- *
- * // extension module
- * var extensionModule = {
- * __init__: [ 'interactionLogger' ],
- * interactionLogger: [ 'type', InteractionLogger ]
- * };
- *
- * // extend the viewer
- * var bpmnViewer = new Viewer({ additionalModules: [ extensionModule ] });
- * bpmnViewer.importXML(...);
- * ```
- *
- * @param {Object} [options] configuration options to pass to the viewer
- * @param {DOMElement} [options.container] the container to render the viewer in, defaults to body.
- * @param {String|Number} [options.width] the width of the viewer
- * @param {String|Number} [options.height] the height of the viewer
- * @param {Object} [options.moddleExtensions] extension packages to provide
- * @param {Array<didi.Module>} [options.modules] a list of modules to override the default modules
- * @param {Array<didi.Module>} [options.additionalModules] a list of modules to use with the default modules
- */
- function Viewer(options) {
- this.options = options = assign({}, DEFAULT_OPTIONS, options || {});
- var parent = options.container;
- // support jquery element
- // unwrap it if passed
- if (parent.get) {
- parent = parent.get(0);
- }
- // support selector
- if (isString(parent)) {
- parent = domQuery(parent);
- }
- var container = this.container = domify('<div class="bjs-container"></div>');
- parent.appendChild(container);
- assign(container.style, {
- width: ensureUnit(options.width),
- height: ensureUnit(options.height),
- position: options.position
- });
- /**
- * The code in the <project-logo></project-logo> area
- * must not be changed, see http://bpmn.io/license for more information
- *
- * <project-logo>
- */
- /* jshint -W101 */
- // inlined ../resources/bpmnjs.png
- var logoData = 'iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADBQTFRFiMte9PrwldFwfcZPqtqN0+zEyOe1XLgjvuKncsJAZ70y6fXh3vDT////UrQV////G2zN+AAAABB0Uk5T////////////////////AOAjXRkAAAHDSURBVHjavJZJkoUgDEBJmAX8979tM8u3E6x20VlYJfFFMoL4vBDxATxZcakIOJTWSmxvKWVIkJ8jHvlRv1F2LFrVISCZI+tCtQx+XfewgVTfyY3plPiQEAzI3zWy+kR6NBhFBYeBuscJLOUuA2WVLpCjVIaFzrNQZArxAZKUQm6gsj37L9Cb7dnIBUKxENaaMJQqMpDXvSL+ktxdGRm2IsKgJGGPg7atwUG5CcFUEuSv+CwQqizTrvDTNXdMU2bMiDWZd8d7QIySWVRsb2vBBioxOFt4OinPBapL+neAb5KL5IJ8szOza2/DYoipUCx+CjO0Bpsv0V6mktNZ+k8rlABlWG0FrOpKYVo8DT3dBeLEjUBAj7moDogVii7nSS9QzZnFcOVBp1g2PyBQ3Vr5aIapN91VJy33HTJLC1iX2FY6F8gRdaAeIEfVONgtFCzZTmoLEdOjBDfsIOA6128gw3eu1shAajdZNAORxuQDJN5A5PbEG6gNIu24QJD5iNyRMZIr6bsHbCtCU/OaOaSvgkUyDMdDa1BXGf5HJ1To+/Ym6mCKT02Y+/Sa126ZKyd3jxhzpc1r8zVL6YM1Qy/kR4ABAFJ6iQUnivhAAAAAAElFTkSuQmCC';
- /* jshint +W101 */
- var linkMarkup =
- '<a href="http://bpmn.io" ' +
- 'target="_blank" ' +
- 'class="bjs-powered-by" ' +
- 'title="Powered by bpmn.io" ' +
- 'style="position: absolute; bottom: 15px; right: 15px; z-index: 100">' +
- '<img src="data:image/png;base64,' + logoData + '">' +
- '</a>';
- container.appendChild(domify(linkMarkup));
- /* </project-logo> */
- }
- Viewer.prototype.importXML = function(xml, done) {
- var self = this;
- this.moddle = this.createModdle();
- this.moddle.fromXML(xml, 'bpmn:Definitions', function(err, definitions, context) {
- if (err) {
- err = checkValidationError(err);
- return done(err);
- }
- var parseWarnings = context.warnings;
- self.importDefinitions(definitions, function(err, importWarnings) {
- if (err) {
- return done(err);
- }
- done(null, parseWarnings.concat(importWarnings || []));
- });
- });
- };
- Viewer.prototype.saveXML = function(options, done) {
- if (!done) {
- done = options;
- options = {};
- }
- var definitions = this.definitions;
- if (!definitions) {
- return done(new Error('no definitions loaded'));
- }
- this.moddle.toXML(definitions, options, done);
- };
- Viewer.prototype.createModdle = function() {
- return new BpmnModdle(this.options.moddleExtensions);
- };
- Viewer.prototype.saveSVG = function(options, done) {
- if (!done) {
- done = options;
- options = {};
- }
- var canvas = this.get('canvas');
- var contentNode = canvas.getDefaultLayer(),
- defsNode = canvas._svg.select('defs');
- var contents = contentNode.innerSVG(),
- defs = (defsNode && defsNode.outerSVG()) || '';
- var bbox = contentNode.getBBox();
- var svg =
- '<?xml version="1.0" encoding="utf-8"?>\n' +
- '<!-- created with bpmn-js / http://bpmn.io -->\n' +
- '<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
- '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" ' +
- 'width="' + bbox.width + '" height="' + bbox.height + '" ' +
- 'viewBox="' + bbox.x + ' ' + bbox.y + ' ' + bbox.width + ' ' + bbox.height + '" version="1.1">' +
- defs + contents +
- '</svg>';
- done(null, svg);
- };
- Viewer.prototype.get = function(name) {
- if (!this.diagram) {
- throw new Error('no diagram loaded');
- }
- return this.diagram.get(name);
- };
- Viewer.prototype.invoke = function(fn) {
- if (!this.diagram) {
- throw new Error('no diagram loaded');
- }
- return this.diagram.invoke(fn);
- };
- Viewer.prototype.importDefinitions = function(definitions, done) {
- // use try/catch to not swallow synchronous exceptions
- // that may be raised during model parsing
- try {
- if (this.diagram) {
- this.clear();
- }
- this.definitions = definitions;
- var diagram = this.diagram = this._createDiagram(this.options);
- this._init(diagram);
- Importer.importBpmnDiagram(diagram, definitions, done);
- } catch (e) {
- done(e);
- }
- };
- Viewer.prototype._init = function(diagram) {
- initListeners(diagram, this.__listeners || []);
- };
- Viewer.prototype._createDiagram = function(options) {
- var modules = [].concat(options.modules || this.getModules(), options.additionalModules || []);
- // add self as an available service
- modules.unshift({
- bpmnjs: [ 'value', this ],
- moddle: [ 'value', this.moddle ]
- });
- options = omit(options, 'additionalModules');
- options = assign(options, {
- canvas: { container: this.container },
- modules: modules
- });
- return new Diagram(options);
- };
- Viewer.prototype.getModules = function() {
- return this._modules;
- };
- /**
- * Remove all drawn elements from the viewer.
- *
- * After calling this method the viewer can still
- * be reused for opening another diagram.
- */
- Viewer.prototype.clear = function() {
- var diagram = this.diagram;
- if (diagram) {
- diagram.destroy();
- }
- };
- /**
- * Destroy the viewer instance and remove all its remainders
- * from the document tree.
- */
- Viewer.prototype.destroy = function() {
- // clear underlying diagram
- this.clear();
- // remove container
- domRemove(this.container);
- };
- /**
- * Register an event listener on the viewer
- *
- * @param {String} event
- * @param {Function} handler
- */
- Viewer.prototype.on = function(event, handler) {
- var diagram = this.diagram,
- listeners = this.__listeners = this.__listeners || [];
- listeners.push({ event: event, handler: handler });
- if (diagram) {
- diagram.get('eventBus').on(event, handler);
- }
- };
- // modules the viewer is composed of
- Viewer.prototype._modules = [
- _dereq_(3),
- _dereq_(159),
- _dereq_(143)
- ];
- module.exports = Viewer;
- },{"143":143,"159":159,"3":3,"333":333,"336":336,"339":339,"343":343,"356":356,"359":359,"360":360,"45":45,"51":51,"76":76}],3:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(6),
- _dereq_(47)
- ]
- };
- },{"47":47,"6":6}],4:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207),
- isArray = _dereq_(330),
- isObject = _dereq_(334),
- assign = _dereq_(339),
- forEach = _dereq_(218),
- every = _dereq_(215),
- includes = _dereq_(220),
- some = _dereq_(224);
- var DefaultRenderer = _dereq_(87),
- TextUtil = _dereq_(196),
- DiUtil = _dereq_(48);
- var createLine = DefaultRenderer.createLine;
- function BpmnRenderer(events, styles, pathMap) {
- DefaultRenderer.call(this, styles);
- var TASK_BORDER_RADIUS = 10;
- var INNER_OUTER_DIST = 3;
- var LABEL_STYLE = {
- fontFamily: 'Arial, sans-serif',
- fontSize: '12px'
- };
- var textUtil = new TextUtil({
- style: LABEL_STYLE,
- size: { width: 100 }
- });
- var markers = {};
- function addMarker(id, element) {
- markers[id] = element;
- }
- function marker(id) {
- return markers[id];
- }
- function initMarkers(svg) {
- function createMarker(id, options) {
- var attrs = assign({
- fill: 'black',
- strokeWidth: 1,
- strokeLinecap: 'round',
- strokeDasharray: 'none'
- }, options.attrs);
- var ref = options.ref || { x: 0, y: 0 };
- var scale = options.scale || 1;
- // fix for safari / chrome / firefox bug not correctly
- // resetting stroke dash array
- if (attrs.strokeDasharray === 'none') {
- attrs.strokeDasharray = [10000, 1];
- }
- var marker = options.element
- .attr(attrs)
- .marker(0, 0, 20, 20, ref.x, ref.y)
- .attr({
- markerWidth: 20 * scale,
- markerHeight: 20 * scale
- });
- return addMarker(id, marker);
- }
- createMarker('sequenceflow-end', {
- element: svg.path('M 1 5 L 11 10 L 1 15 Z'),
- ref: { x: 11, y: 10 },
- scale: 0.5
- });
- createMarker('messageflow-start', {
- element: svg.circle(6, 6, 3.5),
- attrs: {
- fill: 'white',
- stroke: 'black'
- },
- ref: { x: 6, y: 6 }
- });
- createMarker('messageflow-end', {
- element: svg.path('m 1 5 l 0 -3 l 7 3 l -7 3 z'),
- attrs: {
- fill: 'white',
- stroke: 'black',
- strokeLinecap: 'butt'
- },
- ref: { x: 8.5, y: 5 }
- });
- createMarker('data-association-end', {
- element: svg.path('M 1 5 L 11 10 L 1 15'),
- attrs: {
- fill: 'white',
- stroke: 'black'
- },
- ref: { x: 11, y: 10 },
- scale: 0.5
- });
- createMarker('conditional-flow-marker', {
- element: svg.path('M 0 10 L 8 6 L 16 10 L 8 14 Z'),
- attrs: {
- fill: 'white',
- stroke: 'black'
- },
- ref: { x: -1, y: 10 },
- scale: 0.5
- });
- createMarker('conditional-default-flow-marker', {
- element: svg.path('M 1 4 L 5 16'),
- attrs: {
- stroke: 'black'
- },
- ref: { x: -5, y: 10 },
- scale: 0.5
- });
- }
- function computeStyle(custom, traits, defaultStyles) {
- if (!isArray(traits)) {
- defaultStyles = traits;
- traits = [];
- }
- return styles.style(traits || [], assign(defaultStyles, custom || {}));
- }
- function drawCircle(p, width, height, offset, attrs) {
- if (isObject(offset)) {
- attrs = offset;
- offset = 0;
- }
- offset = offset || 0;
- attrs = computeStyle(attrs, {
- stroke: 'black',
- strokeWidth: 2,
- fill: 'white'
- });
- var cx = width / 2,
- cy = height / 2;
- return p.circle(cx, cy, Math.round((width + height) / 4 - offset)).attr(attrs);
- }
- function drawRect(p, width, height, r, offset, attrs) {
- if (isObject(offset)) {
- attrs = offset;
- offset = 0;
- }
- offset = offset || 0;
- attrs = computeStyle(attrs, {
- stroke: 'black',
- strokeWidth: 2,
- fill: 'white'
- });
- return p.rect(offset, offset, width - offset * 2, height - offset * 2, r).attr(attrs);
- }
- function drawDiamond(p, width, height, attrs) {
- var x_2 = width / 2;
- var y_2 = height / 2;
- var points = [x_2, 0, width, y_2, x_2, height, 0, y_2 ];
- attrs = computeStyle(attrs, {
- stroke: 'black',
- strokeWidth: 2,
- fill: 'white'
- });
- return p.polygon(points).attr(attrs);
- }
- function drawLine(p, waypoints, attrs) {
- attrs = computeStyle(attrs, [ 'no-fill' ], {
- stroke: 'black',
- strokeWidth: 2,
- fill: 'none'
- });
- return createLine(waypoints, attrs).appendTo(p);
- }
- function drawPath(p, d, attrs) {
- attrs = computeStyle(attrs, [ 'no-fill' ], {
- strokeWidth: 2,
- stroke: 'black'
- });
- return p.path(d).attr(attrs);
- }
- function as(type) {
- return function(p, element) {
- return handlers[type](p, element);
- };
- }
- function renderer(type) {
- return handlers[type];
- }
- function renderEventContent(element, p) {
- var event = getSemantic(element);
- var isThrowing = isThrowEvent(event);
- if (isTypedEvent(event, 'bpmn:MessageEventDefinition')) {
- return renderer('bpmn:MessageEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:TimerEventDefinition')) {
- return renderer('bpmn:TimerEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:ConditionalEventDefinition')) {
- return renderer('bpmn:ConditionalEventDefinition')(p, element);
- }
- if (isTypedEvent(event, 'bpmn:SignalEventDefinition')) {
- return renderer('bpmn:SignalEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
- isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: false })) {
- return renderer('bpmn:MultipleEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition') &&
- isTypedEvent(event, 'bpmn:TerminateEventDefinition', { parallelMultiple: true })) {
- return renderer('bpmn:ParallelMultipleEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:EscalationEventDefinition')) {
- return renderer('bpmn:EscalationEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:LinkEventDefinition')) {
- return renderer('bpmn:LinkEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:ErrorEventDefinition')) {
- return renderer('bpmn:ErrorEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:CancelEventDefinition')) {
- return renderer('bpmn:CancelEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:CompensateEventDefinition')) {
- return renderer('bpmn:CompensateEventDefinition')(p, element, isThrowing);
- }
- if (isTypedEvent(event, 'bpmn:TerminateEventDefinition')) {
- return renderer('bpmn:TerminateEventDefinition')(p, element, isThrowing);
- }
- return null;
- }
- function renderLabel(p, label, options) {
- return textUtil.createText(p, label || '', options).addClass('djs-label');
- }
- function renderEmbeddedLabel(p, element, align) {
- var semantic = getSemantic(element);
- return renderLabel(p, semantic.name, { box: element, align: align, padding: 5 });
- }
- function renderExternalLabel(p, element, align) {
- var semantic = getSemantic(element);
- if (!semantic.name) {
- element.hidden = true;
- }
- return renderLabel(p, semantic.name, { box: element, align: align, style: { fontSize: '11px' } });
- }
- function renderLaneLabel(p, text, element) {
- var textBox = renderLabel(p, text, {
- box: { height: 30, width: element.height },
- align: 'center-middle'
- });
- var top = -1 * element.height;
- textBox.transform(
- 'rotate(270) ' +
- 'translate(' + top + ',' + 0 + ')'
- );
- }
- function createPathFromConnection(connection) {
- var waypoints = connection.waypoints;
- var pathData = 'm ' + waypoints[0].x + ',' + waypoints[0].y;
- for (var i = 1; i < waypoints.length; i++) {
- pathData += 'L' + waypoints[i].x + ',' + waypoints[i].y + ' ';
- }
- return pathData;
- }
- var handlers = {
- 'bpmn:Event': function(p, element, attrs) {
- return drawCircle(p, element.width, element.height, attrs);
- },
- 'bpmn:StartEvent': function(p, element) {
- var attrs = {};
- var semantic = getSemantic(element);
- if (!semantic.isInterrupting) {
- attrs = {
- strokeDasharray: '6',
- strokeLinecap: 'round'
- };
- }
- var circle = renderer('bpmn:Event')(p, element, attrs);
- renderEventContent(element, p);
- return circle;
- },
- 'bpmn:MessageEventDefinition': function(p, element, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_MESSAGE', {
- xScaleFactor: 0.9,
- yScaleFactor: 0.9,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.235,
- my: 0.315
- }
- });
- var fill = isThrowing ? 'black' : 'white';
- var stroke = isThrowing ? 'white' : 'black';
- var messagePath = drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill,
- stroke: stroke
- });
- return messagePath;
- },
- 'bpmn:TimerEventDefinition': function(p, element) {
- var circle = drawCircle(p, element.width, element.height, 0.2 * element.height, {
- strokeWidth: 2
- });
- var pathData = pathMap.getScaledPath('EVENT_TIMER_WH', {
- xScaleFactor: 0.75,
- yScaleFactor: 0.75,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.5,
- my: 0.5
- }
- });
- drawPath(p, pathData, {
- strokeWidth: 2,
- strokeLinecap: 'square'
- });
- for(var i = 0;i < 12;i++) {
- var linePathData = pathMap.getScaledPath('EVENT_TIMER_LINE', {
- xScaleFactor: 0.75,
- yScaleFactor: 0.75,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.5,
- my: 0.5
- }
- });
- var width = element.width / 2;
- var height = element.height / 2;
- drawPath(p, linePathData, {
- strokeWidth: 1,
- strokeLinecap: 'square',
- transform: 'rotate(' + (i * 30) + ',' + height + ',' + width + ')'
- });
- }
- return circle;
- },
- 'bpmn:EscalationEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_ESCALATION', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.5,
- my: 0.555
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:ConditionalEventDefinition': function(p, event) {
- var pathData = pathMap.getScaledPath('EVENT_CONDITIONAL', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.5,
- my: 0.222
- }
- });
- return drawPath(p, pathData, {
- strokeWidth: 1
- });
- },
- 'bpmn:LinkEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_LINK', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.57,
- my: 0.263
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:ErrorEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_ERROR', {
- xScaleFactor: 1.1,
- yScaleFactor: 1.1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.2,
- my: 0.722
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:CancelEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_CANCEL_45', {
- xScaleFactor: 1.0,
- yScaleFactor: 1.0,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.638,
- my: -0.055
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- }).transform('rotate(45)');
- },
- 'bpmn:CompensateEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_COMPENSATION', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.201,
- my: 0.472
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:SignalEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_SIGNAL', {
- xScaleFactor: 0.9,
- yScaleFactor: 0.9,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.5,
- my: 0.2
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:MultipleEventDefinition': function(p, event, isThrowing) {
- var pathData = pathMap.getScaledPath('EVENT_MULTIPLE', {
- xScaleFactor: 1.1,
- yScaleFactor: 1.1,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.222,
- my: 0.36
- }
- });
- var fill = isThrowing ? 'black' : 'none';
- return drawPath(p, pathData, {
- strokeWidth: 1,
- fill: fill
- });
- },
- 'bpmn:ParallelMultipleEventDefinition': function(p, event) {
- var pathData = pathMap.getScaledPath('EVENT_PARALLEL_MULTIPLE', {
- xScaleFactor: 1.2,
- yScaleFactor: 1.2,
- containerWidth: event.width,
- containerHeight: event.height,
- position: {
- mx: 0.458,
- my: 0.194
- }
- });
- return drawPath(p, pathData, {
- strokeWidth: 1
- });
- },
- 'bpmn:EndEvent': function(p, element) {
- var circle = renderer('bpmn:Event')(p, element, {
- strokeWidth: 4
- });
- renderEventContent(element, p, true);
- return circle;
- },
- 'bpmn:TerminateEventDefinition': function(p, element) {
- var circle = drawCircle(p, element.width, element.height, 8, {
- strokeWidth: 4,
- fill: 'black'
- });
- return circle;
- },
- 'bpmn:IntermediateEvent': function(p, element) {
- var outer = renderer('bpmn:Event')(p, element, { strokeWidth: 1 });
- /* inner */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, { strokeWidth: 1, fill: 'none' });
- renderEventContent(element, p);
- return outer;
- },
- 'bpmn:IntermediateCatchEvent': as('bpmn:IntermediateEvent'),
- 'bpmn:IntermediateThrowEvent': as('bpmn:IntermediateEvent'),
- 'bpmn:Activity': function(p, element, attrs) {
- return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, attrs);
- },
- 'bpmn:Task': function(p, element, attrs) {
- var rect = renderer('bpmn:Activity')(p, element, attrs);
- renderEmbeddedLabel(p, element, 'center-middle');
- attachTaskMarkers(p, element);
- return rect;
- },
- 'bpmn:ServiceTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var pathDataBG = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
- abspos: {
- x: 12,
- y: 18
- }
- });
- /* service bg */ drawPath(p, pathDataBG, {
- strokeWidth: 1,
- fill: 'none'
- });
- var fillPathData = pathMap.getScaledPath('TASK_TYPE_SERVICE_FILL', {
- abspos: {
- x: 17.2,
- y: 18
- }
- });
- /* service fill */ drawPath(p, fillPathData, {
- strokeWidth: 0,
- stroke: 'none',
- fill: 'white'
- });
- var pathData = pathMap.getScaledPath('TASK_TYPE_SERVICE', {
- abspos: {
- x: 17,
- y: 22
- }
- });
- /* service */ drawPath(p, pathData, {
- strokeWidth: 1,
- fill: 'white'
- });
- return task;
- },
- 'bpmn:UserTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var x = 15;
- var y = 12;
- var pathData = pathMap.getScaledPath('TASK_TYPE_USER_1', {
- abspos: {
- x: x,
- y: y
- }
- });
- /* user path */ drawPath(p, pathData, {
- strokeWidth: 0.5,
- fill: 'none'
- });
- var pathData2 = pathMap.getScaledPath('TASK_TYPE_USER_2', {
- abspos: {
- x: x,
- y: y
- }
- });
- /* user2 path */ drawPath(p, pathData2, {
- strokeWidth: 0.5,
- fill: 'none'
- });
- var pathData3 = pathMap.getScaledPath('TASK_TYPE_USER_3', {
- abspos: {
- x: x,
- y: y
- }
- });
- /* user3 path */ drawPath(p, pathData3, {
- strokeWidth: 0.5,
- fill: 'black'
- });
- return task;
- },
- 'bpmn:ManualTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var pathData = pathMap.getScaledPath('TASK_TYPE_MANUAL', {
- abspos: {
- x: 17,
- y: 15
- }
- });
- /* manual path */ drawPath(p, pathData, {
- strokeWidth: 0.25,
- fill: 'white',
- stroke: 'black'
- });
- return task;
- },
- 'bpmn:SendTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: 21,
- containerHeight: 14,
- position: {
- mx: 0.285,
- my: 0.357
- }
- });
- /* send path */ drawPath(p, pathData, {
- strokeWidth: 1,
- fill: 'black',
- stroke: 'white'
- });
- return task;
- },
- 'bpmn:ReceiveTask' : function(p, element) {
- var semantic = getSemantic(element);
- var task = renderer('bpmn:Task')(p, element);
- var pathData;
- if (semantic.instantiate) {
- drawCircle(p, 28, 28, 20 * 0.22, { strokeWidth: 1 });
- pathData = pathMap.getScaledPath('TASK_TYPE_INSTANTIATING_SEND', {
- abspos: {
- x: 7.77,
- y: 9.52
- }
- });
- } else {
- pathData = pathMap.getScaledPath('TASK_TYPE_SEND', {
- xScaleFactor: 0.9,
- yScaleFactor: 0.9,
- containerWidth: 21,
- containerHeight: 14,
- position: {
- mx: 0.3,
- my: 0.4
- }
- });
- }
- /* receive path */ drawPath(p, pathData, {
- strokeWidth: 1
- });
- return task;
- },
- 'bpmn:ScriptTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var pathData = pathMap.getScaledPath('TASK_TYPE_SCRIPT', {
- abspos: {
- x: 15,
- y: 20
- }
- });
- /* script path */ drawPath(p, pathData, {
- strokeWidth: 1
- });
- return task;
- },
- 'bpmn:BusinessRuleTask': function(p, element) {
- var task = renderer('bpmn:Task')(p, element);
- var headerPathData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_HEADER', {
- abspos: {
- x: 8,
- y: 8
- }
- });
- var businessHeaderPath = drawPath(p, headerPathData);
- businessHeaderPath.attr({
- strokeWidth: 1,
- fill: 'AAA'
- });
- var headerData = pathMap.getScaledPath('TASK_TYPE_BUSINESS_RULE_MAIN', {
- abspos: {
- x: 8,
- y: 8
- }
- });
- var businessPath = drawPath(p, headerData);
- businessPath.attr({
- strokeWidth: 1
- });
- return task;
- },
- 'bpmn:SubProcess': function(p, element, attrs) {
- var rect = renderer('bpmn:Activity')(p, element, attrs);
- var semantic = getSemantic(element);
- var expanded = DiUtil.isExpanded(semantic);
- var isEventSubProcess = !!semantic.triggeredByEvent;
- if (isEventSubProcess) {
- rect.attr({
- strokeDasharray: '1,2'
- });
- }
- renderEmbeddedLabel(p, element, expanded ? 'center-top' : 'center-middle');
- if (expanded) {
- attachTaskMarkers(p, element);
- } else {
- attachTaskMarkers(p, element, ['SubProcessMarker']);
- }
- return rect;
- },
- 'bpmn:AdHocSubProcess': function(p, element) {
- return renderer('bpmn:SubProcess')(p, element);
- },
- 'bpmn:Transaction': function(p, element) {
- var outer = renderer('bpmn:SubProcess')(p, element);
- var innerAttrs = styles.style([ 'no-fill', 'no-events' ]);
- /* inner path */ drawRect(p, element.width, element.height, TASK_BORDER_RADIUS - 2, INNER_OUTER_DIST, innerAttrs);
- return outer;
- },
- 'bpmn:CallActivity': function(p, element) {
- return renderer('bpmn:Task')(p, element, {
- strokeWidth: 5
- });
- },
- 'bpmn:Participant': function(p, element) {
- var lane = renderer('bpmn:Lane')(p, element, {
- fill: 'White'
- });
- var expandedPool = DiUtil.isExpanded(element);
- if (expandedPool) {
- drawLine(p, [
- { x: 30, y: 0 },
- { x: 30, y: element.height }
- ]);
- var text = getSemantic(element).name;
- renderLaneLabel(p, text, element);
- } else {
- // Collapsed pool draw text inline
- var text2 = getSemantic(element).name;
- renderLabel(p, text2, { box: element, align: 'center-middle' });
- }
- var participantMultiplicity = !!(getSemantic(element).participantMultiplicity);
- if(participantMultiplicity) {
- renderer('ParticipantMultiplicityMarker')(p, element);
- }
- return lane;
- },
- 'bpmn:Lane': function(p, element, attrs) {
- var rect = drawRect(p, element.width, element.height, 0, attrs || {
- fill: 'none'
- });
- var semantic = getSemantic(element);
- if (semantic.$type === 'bpmn:Lane') {
- var text = semantic.name;
- renderLaneLabel(p, text, element);
- }
- return rect;
- },
- 'bpmn:InclusiveGateway': function(p, element) {
- var diamond = drawDiamond(p, element.width, element.height);
- /* circle path */
- drawCircle(p, element.width, element.height, element.height * 0.24, {
- strokeWidth: 2.5,
- fill: 'none'
- });
- return diamond;
- },
- 'bpmn:ExclusiveGateway': function(p, element) {
- var diamond = drawDiamond(p, element.width, element.height);
- var pathData = pathMap.getScaledPath('GATEWAY_EXCLUSIVE', {
- xScaleFactor: 0.4,
- yScaleFactor: 0.4,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.32,
- my: 0.3
- }
- });
- if (!!(getDi(element).isMarkerVisible)) {
- drawPath(p, pathData, {
- strokeWidth: 1,
- fill: 'black'
- });
- }
- return diamond;
- },
- 'bpmn:ComplexGateway': function(p, element) {
- var diamond = drawDiamond(p, element.width, element.height);
- var pathData = pathMap.getScaledPath('GATEWAY_COMPLEX', {
- xScaleFactor: 0.5,
- yScaleFactor:0.5,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.46,
- my: 0.26
- }
- });
- /* complex path */ drawPath(p, pathData, {
- strokeWidth: 1,
- fill: 'black'
- });
- return diamond;
- },
- 'bpmn:ParallelGateway': function(p, element) {
- var diamond = drawDiamond(p, element.width, element.height);
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
- xScaleFactor: 0.6,
- yScaleFactor:0.6,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.46,
- my: 0.2
- }
- });
- /* parallel path */ drawPath(p, pathData, {
- strokeWidth: 1,
- fill: 'black'
- });
- return diamond;
- },
- 'bpmn:EventBasedGateway': function(p, element) {
- var semantic = getSemantic(element);
- var diamond = drawDiamond(p, element.width, element.height);
- /* outer circle path */ drawCircle(p, element.width, element.height, element.height * 0.20, {
- strokeWidth: 1,
- fill: 'none'
- });
- var type = semantic.eventGatewayType;
- var instantiate = !!semantic.instantiate;
- function drawEvent() {
- var pathData = pathMap.getScaledPath('GATEWAY_EVENT_BASED', {
- xScaleFactor: 0.18,
- yScaleFactor: 0.18,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.36,
- my: 0.44
- }
- });
- /* event path */ drawPath(p, pathData, {
- strokeWidth: 2,
- fill: 'none'
- });
- }
- if (type === 'Parallel') {
- var pathData = pathMap.getScaledPath('GATEWAY_PARALLEL', {
- xScaleFactor: 0.4,
- yScaleFactor:0.4,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.474,
- my: 0.296
- }
- });
- var parallelPath = drawPath(p, pathData);
- parallelPath.attr({
- strokeWidth: 1,
- fill: 'none'
- });
- } else if (type === 'Exclusive') {
- if (!instantiate) {
- var innerCircle = drawCircle(p, element.width, element.height, element.height * 0.26);
- innerCircle.attr({
- strokeWidth: 1,
- fill: 'none'
- });
- }
- drawEvent();
- }
- return diamond;
- },
- 'bpmn:Gateway': function(p, element) {
- return drawDiamond(p, element.width, element.height);
- },
- 'bpmn:SequenceFlow': function(p, element) {
- var pathData = createPathFromConnection(element);
- var path = drawPath(p, pathData, {
- strokeLinejoin: 'round',
- markerEnd: marker('sequenceflow-end')
- });
- var sequenceFlow = getSemantic(element);
- var source = element.source.businessObject;
- // conditional flow marker
- if (sequenceFlow.conditionExpression && source.$instanceOf('bpmn:Task')) {
- path.attr({
- markerStart: marker('conditional-flow-marker')
- });
- }
- // default marker
- if (source.default && source.$instanceOf('bpmn:Gateway') && source.default === sequenceFlow) {
- path.attr({
- markerStart: marker('conditional-default-flow-marker')
- });
- }
- return path;
- },
- 'bpmn:Association': function(p, element, attrs) {
- attrs = assign({
- strokeDasharray: '1,6',
- strokeLinecap: 'round',
- strokeLinejoin: 'round'
- }, attrs || {});
- // TODO(nre): style according to directed state
- return drawLine(p, element.waypoints, attrs);
- },
- 'bpmn:DataInputAssociation': function(p, element) {
- return renderer('bpmn:Association')(p, element, {
- markerEnd: marker('data-association-end')
- });
- },
- 'bpmn:DataOutputAssociation': function(p, element) {
- return renderer('bpmn:Association')(p, element, {
- markerEnd: marker('data-association-end')
- });
- },
- 'bpmn:MessageFlow': function(p, element) {
- var semantic = getSemantic(element),
- di = getDi(element);
- var pathData = createPathFromConnection(element);
- var path = drawPath(p, pathData, {
- markerEnd: marker('messageflow-end'),
- markerStart: marker('messageflow-start'),
- strokeDasharray: '10, 12',
- strokeLinecap: 'round',
- strokeLinejoin: 'round',
- strokeWidth: '1.5px'
- });
- if (semantic.messageRef) {
- var midPoint = path.getPointAtLength(path.getTotalLength() / 2);
- var markerPathData = pathMap.getScaledPath('MESSAGE_FLOW_MARKER', {
- abspos: {
- x: midPoint.x,
- y: midPoint.y
- }
- });
- var messageAttrs = { strokeWidth: 1 };
- if (di.messageVisibleKind === 'initiating') {
- messageAttrs.fill = 'white';
- messageAttrs.stroke = 'black';
- } else {
- messageAttrs.fill = '#888';
- messageAttrs.stroke = 'white';
- }
- drawPath(p, markerPathData, messageAttrs);
- }
- return path;
- },
- 'bpmn:DataObject': function(p, element) {
- var pathData = pathMap.getScaledPath('DATA_OBJECT_PATH', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.474,
- my: 0.296
- }
- });
- var elementObject = drawPath(p, pathData, { fill: 'white' });
- var semantic = getSemantic(element);
- if (isCollection(semantic)) {
- renderDataItemCollection(p, element);
- }
- return elementObject;
- },
- 'bpmn:DataObjectReference': as('bpmn:DataObject'),
- 'bpmn:DataInput': function(p, element) {
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
- // page
- var elementObject = renderer('bpmn:DataObject')(p, element);
- /* input arrow path */ drawPath(p, arrowPathData, { strokeWidth: 1 });
- return elementObject;
- },
- 'bpmn:DataOutput': function(p, element) {
- var arrowPathData = pathMap.getRawPath('DATA_ARROW');
- // page
- var elementObject = renderer('bpmn:DataObject')(p, element);
- /* output arrow path */ drawPath(p, arrowPathData, {
- strokeWidth: 1,
- fill: 'black'
- });
- return elementObject;
- },
- 'bpmn:DataStoreReference': function(p, element) {
- var DATA_STORE_PATH = pathMap.getScaledPath('DATA_STORE', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0,
- my: 0.133
- }
- });
- var elementStore = drawPath(p, DATA_STORE_PATH, {
- strokeWidth: 2,
- fill: 'white'
- });
- return elementStore;
- },
- 'bpmn:BoundaryEvent': function(p, element) {
- var semantic = getSemantic(element),
- cancel = semantic.cancelActivity;
- var attrs = {
- strokeWidth: 1
- };
- if (!cancel) {
- attrs.strokeDasharray = '6';
- attrs.strokeLinecap = 'round';
- }
- var outer = renderer('bpmn:Event')(p, element, attrs);
- /* inner path */ drawCircle(p, element.width, element.height, INNER_OUTER_DIST, assign(attrs, { fill: 'none' }));
- renderEventContent(element, p);
- return outer;
- },
- 'bpmn:Group': function(p, element) {
- return drawRect(p, element.width, element.height, TASK_BORDER_RADIUS, {
- strokeWidth: 1,
- strokeDasharray: '8,3,1,3',
- fill: 'none',
- pointerEvents: 'none'
- });
- },
- 'label': function(p, element) {
- return renderExternalLabel(p, element, '');
- },
- 'bpmn:TextAnnotation': function(p, element) {
- var style = {
- 'fill': 'none',
- 'stroke': 'none'
- };
- var textElement = drawRect(p, element.width, element.height, 0, 0, style);
- var textPathData = pathMap.getScaledPath('TEXT_ANNOTATION', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.0,
- my: 0.0
- }
- });
- drawPath(p, textPathData);
- var text = getSemantic(element).text || '';
- renderLabel(p, text, { box: element, align: 'left-middle', padding: 5 });
- return textElement;
- },
- 'ParticipantMultiplicityMarker': function(p, element) {
- var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2) / element.width),
- my: (element.height - 15) / element.height
- }
- });
- drawPath(p, subProcessPath);
- },
- 'SubProcessMarker': function(p, element) {
- var markerRect = drawRect(p, 14, 14, 0, {
- strokeWidth: 1
- });
- // Process marker is placed in the middle of the box
- // therefore fixed values can be used here
- markerRect.transform('translate(' + (element.width / 2 - 7.5) + ',' + (element.height - 20) + ')');
- var subProcessPath = pathMap.getScaledPath('MARKER_SUB_PROCESS', {
- xScaleFactor: 1.5,
- yScaleFactor: 1.5,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: (element.width / 2 - 7.5) / element.width,
- my: (element.height - 20) / element.height
- }
- });
- drawPath(p, subProcessPath);
- },
- 'ParallelMarker': function(p, element, position) {
- var subProcessPath = pathMap.getScaledPath('MARKER_PARALLEL', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2 + position.parallel) / element.width),
- my: (element.height - 20) / element.height
- }
- });
- drawPath(p, subProcessPath);
- },
- 'SequentialMarker': function(p, element, position) {
- var sequentialPath = pathMap.getScaledPath('MARKER_SEQUENTIAL', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2 + position.seq) / element.width),
- my: (element.height - 19) / element.height
- }
- });
- drawPath(p, sequentialPath);
- },
- 'CompensationMarker': function(p, element, position) {
- var compensationPath = pathMap.getScaledPath('MARKER_COMPENSATION', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2 + position.compensation) / element.width),
- my: (element.height - 13) / element.height
- }
- });
- drawPath(p, compensationPath, { strokeWidth: 1 });
- },
- 'LoopMarker': function(p, element, position) {
- var loopPath = pathMap.getScaledPath('MARKER_LOOP', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2 + position.loop) / element.width),
- my: (element.height - 7) / element.height
- }
- });
- drawPath(p, loopPath, {
- strokeWidth: 1,
- fill: 'none',
- strokeLinecap: 'round',
- strokeMiterlimit: 0.5
- });
- },
- 'AdhocMarker': function(p, element, position) {
- var loopPath = pathMap.getScaledPath('MARKER_ADHOC', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: ((element.width / 2 + position.adhoc) / element.width),
- my: (element.height - 15) / element.height
- }
- });
- drawPath(p, loopPath, {
- strokeWidth: 1,
- fill: 'black'
- });
- }
- };
- function attachTaskMarkers(p, element, taskMarkers) {
- var obj = getSemantic(element);
- var subprocess = includes(taskMarkers, 'SubProcessMarker');
- var position;
- if (subprocess) {
- position = {
- seq: -21,
- parallel: -22,
- compensation: -42,
- loop: -18,
- adhoc: 10
- };
- } else {
- position = {
- seq: -3,
- parallel: -6,
- compensation: -27,
- loop: 0,
- adhoc: 10
- };
- }
- forEach(taskMarkers, function(marker) {
- renderer(marker)(p, element, position);
- });
- if (obj.$type === 'bpmn:AdHocSubProcess') {
- renderer('AdhocMarker')(p, element, position);
- }
- if (obj.loopCharacteristics && obj.loopCharacteristics.isSequential === undefined) {
- renderer('LoopMarker')(p, element, position);
- return;
- }
- if (obj.loopCharacteristics &&
- obj.loopCharacteristics.isSequential !== undefined &&
- !obj.loopCharacteristics.isSequential) {
- renderer('ParallelMarker')(p, element, position);
- }
- if (obj.loopCharacteristics && !!obj.loopCharacteristics.isSequential) {
- renderer('SequentialMarker')(p, element, position);
- }
- if (!!obj.isForCompensation) {
- renderer('CompensationMarker')(p, element, position);
- }
- }
- function drawShape(parent, element) {
- var type = element.type;
- var h = handlers[type];
- /* jshint -W040 */
- if (!h) {
- return DefaultRenderer.prototype.drawShape.apply(this, [ parent, element ]);
- } else {
- return h(parent, element);
- }
- }
- function drawConnection(parent, element) {
- var type = element.type;
- var h = handlers[type];
- /* jshint -W040 */
- if (!h) {
- return DefaultRenderer.prototype.drawConnection.apply(this, [ parent, element ]);
- } else {
- return h(parent, element);
- }
- }
- function renderDataItemCollection(p, element) {
- var yPosition = (element.height - 16) / element.height;
- var pathData = pathMap.getScaledPath('DATA_OBJECT_COLLECTION_PATH', {
- xScaleFactor: 1,
- yScaleFactor: 1,
- containerWidth: element.width,
- containerHeight: element.height,
- position: {
- mx: 0.451,
- my: yPosition
- }
- });
- /* collection path */ drawPath(p, pathData, {
- strokeWidth: 2
- });
- }
- function isCollection(element, filter) {
- return element.isCollection ||
- (element.elementObjectRef && element.elementObjectRef.isCollection);
- }
- function getDi(element) {
- return element.businessObject.di;
- }
- function getSemantic(element) {
- return element.businessObject;
- }
- /**
- * Checks if eventDefinition of the given element matches with semantic type.
- *
- * @return {boolean} true if element is of the given semantic type
- */
- function isTypedEvent(event, eventDefinitionType, filter) {
- function matches(definition, filter) {
- return every(filter, function(val, key) {
- // we want a == conversion here, to be able to catch
- // undefined == false and friends
- /* jshint -W116 */
- return definition[key] == val;
- });
- }
- return some(event.eventDefinitions, function(definition) {
- return definition.$type === eventDefinitionType && matches(event, filter);
- });
- }
- function isThrowEvent(event) {
- return (event.$type === 'bpmn:IntermediateThrowEvent') || (event.$type === 'bpmn:EndEvent');
- }
- /////// cropping path customizations /////////////////////////
- function componentsToPath(elements) {
- return elements.join(',').replace(/,?([A-z]),?/g, '$1');
- }
- function getCirclePath(shape) {
- var cx = shape.x + shape.width / 2,
- cy = shape.y + shape.height / 2,
- radius = shape.width / 2;
- var circlePath = [
- ['M', cx, cy],
- ['m', 0, -radius],
- ['a', radius, radius, 0, 1, 1, 0, 2 * radius],
- ['a', radius, radius, 0, 1, 1, 0, -2 * radius],
- ['z']
- ];
- return componentsToPath(circlePath);
- }
- function getRoundRectPath(shape) {
- var radius = TASK_BORDER_RADIUS,
- x = shape.x,
- y = shape.y,
- width = shape.width,
- height = shape.height;
- var roundRectPath = [
- ['M', x + radius, y],
- ['l', width - radius * 2, 0],
- ['a', radius, radius, 0, 0, 1, radius, radius],
- ['l', 0, height - radius * 2],
- ['a', radius, radius, 0, 0, 1, -radius, radius],
- ['l', radius * 2 - width, 0],
- ['a', radius, radius, 0, 0, 1, -radius, -radius],
- ['l', 0, radius * 2 - height],
- ['a', radius, radius, 0, 0, 1, radius, -radius],
- ['z']
- ];
- return componentsToPath(roundRectPath);
- }
- function getDiamondPath(shape) {
- var width = shape.width,
- height = shape.height,
- x = shape.x,
- y = shape.y,
- halfWidth = width / 2,
- halfHeight = height / 2;
- var diamondPath = [
- ['M', x + halfWidth, y],
- ['l', halfWidth, halfHeight],
- ['l', -halfWidth, halfHeight],
- ['l', -halfWidth, -halfHeight],
- ['z']
- ];
- return componentsToPath(diamondPath);
- }
- function getRectPath(shape) {
- var x = shape.x,
- y = shape.y,
- width = shape.width,
- height = shape.height;
- var rectPath = [
- ['M', x, y],
- ['l', width, 0],
- ['l', 0, height],
- ['l', -width, 0],
- ['z']
- ];
- return componentsToPath(rectPath);
- }
- function getShapePath(element) {
- var obj = getSemantic(element);
- if (obj.$instanceOf('bpmn:Event')) {
- return getCirclePath(element);
- }
- if (obj.$instanceOf('bpmn:Activity')) {
- return getRoundRectPath(element);
- }
- if (obj.$instanceOf('bpmn:Gateway')) {
- return getDiamondPath(element);
- }
- return getRectPath(element);
- }
- // hook onto canvas init event to initialize
- // connection start/end markers on svg
- events.on('canvas.init', function(event) {
- initMarkers(event.svg);
- });
- this.drawShape = drawShape;
- this.drawConnection = drawConnection;
- this.getShapePath = getShapePath;
- }
- inherits(BpmnRenderer, DefaultRenderer);
- BpmnRenderer.$inject = [ 'eventBus', 'styles', 'pathMap' ];
- module.exports = BpmnRenderer;
- },{"196":196,"207":207,"215":215,"218":218,"220":220,"224":224,"330":330,"334":334,"339":339,"48":48,"87":87}],5:[function(_dereq_,module,exports){
- 'use strict';
- var Snap = _dereq_(200);
- /**
- * Map containing SVG paths needed by BpmnRenderer.
- */
- function PathMap() {
- /**
- * Contains a map of path elements
- *
- * <h1>Path definition</h1>
- * A parameterized path is defined like this:
- * <pre>
- * 'GATEWAY_PARALLEL': {
- * d: 'm {mx},{my} {e.x0},0 0,{e.x1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
- '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
- * height: 17.5,
- * width: 17.5,
- * heightElements: [2.5, 7.5],
- * widthElements: [2.5, 7.5]
- * }
- * </pre>
- * <p>It's important to specify a correct <b>height and width</b> for the path as the scaling
- * is based on the ratio between the specified height and width in this object and the
- * height and width that is set as scale target (Note x,y coordinates will be scaled with
- * individual ratios).</p>
- * <p>The '<b>heightElements</b>' and '<b>widthElements</b>' array must contain the values that will be scaled.
- * The scaling is based on the computed ratios.
- * Coordinates on the y axis should be in the <b>heightElement</b>'s array, they will be scaled using
- * the computed ratio coefficient.
- * In the parameterized path the scaled values can be accessed through the 'e' object in {} brackets.
- * <ul>
- * <li>The values for the y axis can be accessed in the path string using {e.y0}, {e.y1}, ....</li>
- * <li>The values for the x axis can be accessed in the path string using {e.x0}, {e.x1}, ....</li>
- * </ul>
- * The numbers x0, x1 respectively y0, y1, ... map to the corresponding array index.
- * </p>
- */
- this.pathMap = {
- 'EVENT_MESSAGE': {
- 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}',
- height: 36,
- width: 36,
- heightElements: [6, 14],
- widthElements: [10.5, 21]
- },
- 'EVENT_SIGNAL': {
- d: 'M {mx},{my} l {e.x0},{e.y0} l -{e.x1},0 Z',
- height: 36,
- width: 36,
- heightElements: [18],
- widthElements: [10, 20]
- },
- 'EVENT_ESCALATION': {
- 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} ' +
- '{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',
- height: 36,
- width: 36,
- heightElements: [2.382, 4.764, 4.926, 6.589333, 7.146, 13.178667, 19.768],
- widthElements: [2.463, 2.808, 4.926, 5.616, 7.389, 8.424]
- },
- 'EVENT_CONDITIONAL': {
- d: 'M {e.x0},{e.y0} l {e.x1},0 l 0,{e.y2} l -{e.x1},0 Z ' +
- 'M {e.x2},{e.y3} l {e.x0},0 ' +
- 'M {e.x2},{e.y4} l {e.x0},0 ' +
- 'M {e.x2},{e.y5} l {e.x0},0 ' +
- 'M {e.x2},{e.y6} l {e.x0},0 ' +
- 'M {e.x2},{e.y7} l {e.x0},0 ' +
- 'M {e.x2},{e.y8} l {e.x0},0 ',
- height: 36,
- width: 36,
- heightElements: [8.5, 14.5, 18, 11.5, 14.5, 17.5, 20.5, 23.5, 26.5],
- widthElements: [10.5, 14.5, 12.5]
- },
- 'EVENT_LINK': {
- 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',
- height: 36,
- width: 36,
- heightElements: [4.4375, 6.75, 7.8125],
- widthElements: [9.84375, 13.5]
- },
- 'EVENT_ERROR': {
- 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',
- height: 36,
- width: 36,
- heightElements: [0.023, 8.737, 8.151, 16.564, 10.591, 8.714],
- widthElements: [0.085, 6.672, 6.97, 4.273, 5.337, 6.636]
- },
- 'EVENT_CANCEL_45': {
- d: 'm {mx},{my} -{e.x1},0 0,{e.x0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
- '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
- height: 36,
- width: 36,
- heightElements: [4.75, 8.5],
- widthElements: [4.75, 8.5]
- },
- 'EVENT_COMPENSATION': {
- d: 'm {mx},{my} {e.x0},-{e.y0} 0,{e.y1} z m {e.x0},0 {e.x0},-{e.y0} 0,{e.y1} z',
- height: 36,
- width: 36,
- heightElements: [5, 10],
- widthElements: [10]
- },
- 'EVENT_TIMER_WH': {
- d: 'M {mx},{my} l {e.x0},-{e.y0} m -{e.x0},{e.y0} l {e.x1},{e.y1} ',
- height: 36,
- width: 36,
- heightElements: [10, 2],
- widthElements: [3, 7]
- },
- 'EVENT_TIMER_LINE': {
- d: 'M {mx},{my} ' +
- 'm {e.x0},{e.y0} l -{e.x1},{e.y1} ',
- height: 36,
- width: 36,
- heightElements: [10, 3],
- widthElements: [0, 0]
- },
- 'EVENT_MULTIPLE': {
- d:'m {mx},{my} {e.x1},-{e.y0} {e.x1},{e.y0} -{e.x0},{e.y1} -{e.x2},0 z',
- height: 36,
- width: 36,
- heightElements: [6.28099, 12.56199],
- widthElements: [3.1405, 9.42149, 12.56198]
- },
- 'EVENT_PARALLEL_MULTIPLE': {
- d:'m {mx},{my} {e.x0},0 0,{e.y1} {e.x1},0 0,{e.y0} -{e.x1},0 0,{e.y1} ' +
- '-{e.x0},0 0,-{e.y1} -{e.x1},0 0,-{e.y0} {e.x1},0 z',
- height: 36,
- width: 36,
- heightElements: [2.56228, 7.68683],
- widthElements: [2.56228, 7.68683]
- },
- 'GATEWAY_EXCLUSIVE': {
- d:'m {mx},{my} {e.x0},{e.y0} {e.x1},{e.y0} {e.x2},0 {e.x4},{e.y2} ' +
- '{e.x4},{e.y1} {e.x2},0 {e.x1},{e.y3} {e.x0},{e.y3} ' +
- '{e.x3},0 {e.x5},{e.y1} {e.x5},{e.y2} {e.x3},0 z',
- height: 17.5,
- width: 17.5,
- heightElements: [8.5, 6.5312, -6.5312, -8.5],
- widthElements: [6.5, -6.5, 3, -3, 5, -5]
- },
- 'GATEWAY_PARALLEL': {
- d:'m {mx},{my} 0,{e.y1} -{e.x1},0 0,{e.y0} {e.x1},0 0,{e.y1} {e.x0},0 ' +
- '0,-{e.y1} {e.x1},0 0,-{e.y0} -{e.x1},0 0,-{e.y1} -{e.x0},0 z',
- height: 30,
- width: 30,
- heightElements: [5, 12.5],
- widthElements: [5, 12.5]
- },
- 'GATEWAY_EVENT_BASED': {
- d:'m {mx},{my} {e.x0},{e.y0} {e.x0},{e.y1} {e.x1},{e.y2} {e.x2},0 z',
- height: 11,
- width: 11,
- heightElements: [-6, 6, 12, -12],
- widthElements: [9, -3, -12]
- },
- 'GATEWAY_COMPLEX': {
- 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} ' +
- '{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} ' +
- '{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} ' +
- '-{e.x0},{e.y1} 0,-{e.y0} -{e.x3},0 z',
- height: 17.125,
- width: 17.125,
- heightElements: [4.875, 3.4375, 2.125, 3],
- widthElements: [3.4375, 2.125, 4.875, 3]
- },
- 'DATA_OBJECT_PATH': {
- 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',
- height: 61,
- width: 51,
- heightElements: [10, 50, 60],
- widthElements: [10, 40, 50, 60]
- },
- 'DATA_OBJECT_COLLECTION_PATH': {
- d:'m {mx}, {my} ' +
- 'm 0 15 l 0 -15 ' +
- 'm 4 15 l 0 -15 ' +
- 'm 4 15 l 0 -15 ',
- height: 61,
- width: 51,
- heightElements: [12],
- widthElements: [1, 6, 12, 15]
- },
- 'DATA_ARROW': {
- d:'m 5,9 9,0 0,-3 5,5 -5,5 0,-3 -9,0 z',
- height: 61,
- width: 51,
- heightElements: [],
- widthElements: []
- },
- 'DATA_STORE': {
- d:'m {mx},{my} ' +
- 'l 0,{e.y2} ' +
- 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
- 'l 0,-{e.y2} ' +
- 'c -{e.x0},-{e.y1} -{e.x1},-{e.y1} -{e.x2},0' +
- 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0 ' +
- 'm -{e.x2},{e.y0}' +
- 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0' +
- 'm -{e.x2},{e.y0}' +
- 'c {e.x0},{e.y1} {e.x1},{e.y1} {e.x2},0',
- height: 61,
- width: 61,
- heightElements: [7, 10, 45],
- widthElements: [2, 58, 60]
- },
- 'TEXT_ANNOTATION': {
- d: 'm {mx}, {my} m 10,0 l -10,0 l 0,{e.y0} l 10,0',
- height: 30,
- width: 10,
- heightElements: [30],
- widthElements: [10]
- },
- 'MARKER_SUB_PROCESS': {
- d: 'm{mx},{my} m 7,2 l 0,10 m -5,-5 l 10,0',
- height: 10,
- width: 10,
- heightElements: [],
- widthElements: []
- },
- 'MARKER_PARALLEL': {
- d: 'm{mx},{my} m 3,2 l 0,10 m 3,-10 l 0,10 m 3,-10 l 0,10',
- height: 10,
- width: 10,
- heightElements: [],
- widthElements: []
- },
- 'MARKER_SEQUENTIAL': {
- d: 'm{mx},{my} m 0,3 l 10,0 m -10,3 l 10,0 m -10,3 l 10,0',
- height: 10,
- width: 10,
- heightElements: [],
- widthElements: []
- },
- 'MARKER_COMPENSATION': {
- d: 'm {mx},{my} 8,-5 0,10 z m 9,0 8,-5 0,10 z',
- height: 10,
- width: 21,
- heightElements: [],
- widthElements: []
- },
- 'MARKER_LOOP': {
- d: 'm {mx},{my} c 3.526979,0 6.386161,-2.829858 6.386161,-6.320661 0,-3.490806 -2.859182,-6.320661 ' +
- '-6.386161,-6.320661 -3.526978,0 -6.38616,2.829855 -6.38616,6.320661 0,1.745402 ' +
- '0.714797,3.325567 1.870463,4.469381 0.577834,0.571908 1.265885,1.034728 2.029916,1.35457 ' +
- 'l -0.718163,-3.909793 m 0.718163,3.909793 -3.885211,0.802902',
- height: 13.9,
- width: 13.7,
- heightElements: [],
- widthElements: []
- },
- 'MARKER_ADHOC': {
- 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 ' +
- '3.85579,1.15803 5.76082,1.79107 1.06385,0.34139996 2.24454,0.1438 3.18759,-0.43767 0.61743,-0.33642 ' +
- '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 ' +
- '-3.6918,1.66181996 -1.24459,0.0927 -2.46671,-0.2491 -3.59505,-0.74812 -1.35789,-0.55965 ' +
- '-2.75133,-1.33436996 -4.27027,-1.18121996 -1.37741,0.14601 -2.41842,1.13685996 -3.44288,1.96782996 z',
- height: 4,
- width: 15,
- heightElements: [],
- widthElements: []
- },
- 'TASK_TYPE_SEND': {
- 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}',
- height: 14,
- width: 21,
- heightElements: [6, 14],
- widthElements: [10.5, 21]
- },
- 'TASK_TYPE_SCRIPT': {
- d: 'm {mx},{my} c 9.966553,-6.27276 -8.000926,-7.91932 2.968968,-14.938 l -8.802728,0 ' +
- 'c -10.969894,7.01868 6.997585,8.66524 -2.968967,14.938 z ' +
- 'm -7,-12 l 5,0 ' +
- 'm -4.5,3 l 4.5,0 ' +
- 'm -3,3 l 5,0' +
- 'm -4,3 l 5,0',
- height: 15,
- width: 12.6,
- heightElements: [6, 14],
- widthElements: [10.5, 21]
- },
- 'TASK_TYPE_USER_1': {
- d: 'm {mx},{my} c 0.909,-0.845 1.594,-2.049 1.594,-3.385 0,-2.554 -1.805,-4.62199999 ' +
- '-4.357,-4.62199999 -2.55199998,0 -4.28799998,2.06799999 -4.28799998,4.62199999 0,1.348 ' +
- '0.974,2.562 1.89599998,3.405 -0.52899998,0.187 -5.669,2.097 -5.794,4.7560005 v 6.718 ' +
- 'h 17 v -6.718 c 0,-2.2980005 -5.5279996,-4.5950005 -6.0509996,-4.7760005 z' +
- 'm -8,6 l 0,5.5 m 11,0 l 0,-5'
- },
- 'TASK_TYPE_USER_2': {
- d: 'm {mx},{my} m 2.162,1.009 c 0,2.4470005 -2.158,4.4310005 -4.821,4.4310005 ' +
- '-2.66499998,0 -4.822,-1.981 -4.822,-4.4310005 '
- },
- 'TASK_TYPE_USER_3': {
- 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 ' +
- '4.124,0.965 -0.098,-0.57 -0.117,-3.79099999 -4.191,-4.13599999 -3.57499998,0.001 ' +
- '-4.20799998,3.36699999 -4.20699998,4.34799999 z'
- },
- 'TASK_TYPE_MANUAL': {
- 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 ' +
- '-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 ' +
- '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 ' +
- '-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 ' +
- '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 ' +
- '-10.86,-0.003 -11.0829995,-0.003 -0.022,-0.047 -0.045,-0.094 -0.069,-0.139 0.3939995,-0.319 ' +
- '2.0409995,-1.626 2.4149995,-2.017 0.469,-0.4870005 0.519,-1.1650005 0.162,-1.6040005 -0.414,-0.511 ' +
- '-0.973,-0.5 -1.48,-0.236 -1.4609995,0.764 -6.5999995,3.6430005 -7.7329995,4.2710005 -0.9,0.499 ' +
- '-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 ' +
- '-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 ' +
- '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 ' +
- '-5.824,-0.004 -6.04,-0.004 10e-4,-0.084 0.003,-0.586 10e-4,-0.67 z'
- },
- 'TASK_TYPE_INSTANTIATING_SEND': {
- 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'
- },
- 'TASK_TYPE_SERVICE': {
- d: 'm {mx},{my} v -1.71335 c 0.352326,-0.0705 0.703932,-0.17838 1.047628,-0.32133 ' +
- '0.344416,-0.14465 0.665822,-0.32133 0.966377,-0.52145 l 1.19431,1.18005 1.567487,-1.57688 ' +
- '-1.195028,-1.18014 c 0.403376,-0.61394 0.683079,-1.29908 0.825447,-2.01824 l 1.622133,-0.01 ' +
- 'v -2.2196 l -1.636514,0.01 c -0.07333,-0.35153 -0.178319,-0.70024 -0.323564,-1.04372 ' +
- '-0.145244,-0.34406 -0.321407,-0.6644 -0.522735,-0.96217 l 1.131035,-1.13631 -1.583305,-1.56293 ' +
- '-1.129598,1.13589 c -0.614052,-0.40108 -1.302883,-0.68093 -2.022633,-0.82247 l 0.0093,-1.61852 ' +
- '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 ' +
- '-0.665102,0.32092 -0.9635006,0.52046 l -1.1698628,-1.15823 -1.5667691,1.5792 1.1684265,1.15669 ' +
- 'c -0.4026573,0.61283 -0.68308,1.29797 -0.8247287,2.01713 l -1.6588041,0.003 v 2.22174 ' +
- 'l 1.6724648,-0.006 c 0.073327,0.35077 0.1797598,0.70243 0.3242851,1.04472 0.1452428,0.34448 ' +
- '0.3214064,0.6644 0.5227339,0.96066 l -1.1993431,1.19723 1.5840256,1.56011 1.1964668,-1.19348 ' +
- 'c 0.6140517,0.40346 1.3028827,0.68232 2.0233517,0.82331 l 7.19e-4,1.69892 h 2.226848 z ' +
- 'm 0.221462,-3.9957 c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
- '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
- '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
- },
- 'TASK_TYPE_SERVICE_FILL': {
- d: 'm {mx},{my} c -1.788948,0.7502 -3.8576,-0.0928 -4.6097055,-1.87438 -0.7521065,-1.78321 ' +
- '0.090598,-3.84627 1.8802645,-4.59604 1.78823,-0.74936 3.856881,0.0929 4.608987,1.87437 ' +
- '0.752106,1.78165 -0.0906,3.84612 -1.879546,4.59605 z'
- },
- 'TASK_TYPE_BUSINESS_RULE_HEADER': {
- d: 'm {mx},{my} 0,4 20,0 0,-4 z'
- },
- 'TASK_TYPE_BUSINESS_RULE_MAIN': {
- d: 'm {mx},{my} 0,12 20,0 0,-12 z' +
- 'm 0,8 l 20,0 ' +
- 'm -13,-4 l 0,8'
- },
- 'MESSAGE_FLOW_MARKER': {
- 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'
- }
- };
- this.getRawPath = function getRawPath(pathId) {
- return this.pathMap[pathId].d;
- };
- /**
- * Scales the path to the given height and width.
- * <h1>Use case</h1>
- * <p>Use case is to scale the content of elements (event, gateways) based
- * on the element bounding box's size.
- * </p>
- * <h1>Why not transform</h1>
- * <p>Scaling a path with transform() will also scale the stroke and IE does not support
- * the option 'non-scaling-stroke' to prevent this.
- * Also there are use cases where only some parts of a path should be
- * scaled.</p>
- *
- * @param {String} pathId The ID of the path.
- * @param {Object} param <p>
- * Example param object scales the path to 60% size of the container (data.width, data.height).
- * <pre>
- * {
- * xScaleFactor: 0.6,
- * yScaleFactor:0.6,
- * containerWidth: data.width,
- * containerHeight: data.height,
- * position: {
- * mx: 0.46,
- * my: 0.2,
- * }
- * }
- * </pre>
- * <ul>
- * <li>targetpathwidth = xScaleFactor * containerWidth</li>
- * <li>targetpathheight = yScaleFactor * containerHeight</li>
- * <li>Position is used to set the starting coordinate of the path. M is computed:
- * <ul>
- * <li>position.x * containerWidth</li>
- * <li>position.y * containerHeight</li>
- * </ul>
- * Center of the container <pre> position: {
- * mx: 0.5,
- * my: 0.5,
- * }</pre>
- * Upper left corner of the container
- * <pre> position: {
- * mx: 0.0,
- * my: 0.0,
- * }</pre>
- * </li>
- * </ul>
- * </p>
- *
- */
- this.getScaledPath = function getScaledPath(pathId, param) {
- var rawPath = this.pathMap[pathId];
- // positioning
- // compute the start point of the path
- var mx, my;
- if(!!param.abspos) {
- mx = param.abspos.x;
- my = param.abspos.y;
- } else {
- mx = param.containerWidth * param.position.mx;
- my = param.containerHeight * param.position.my;
- }
- var coordinates = {}; //map for the scaled coordinates
- if(param.position) {
- // path
- var heightRatio = (param.containerHeight / rawPath.height) * param.yScaleFactor;
- var widthRatio = (param.containerWidth / rawPath.width) * param.xScaleFactor;
- //Apply height ratio
- for (var heightIndex = 0; heightIndex < rawPath.heightElements.length; heightIndex++) {
- coordinates['y' + heightIndex] = rawPath.heightElements[heightIndex] * heightRatio;
- }
- //Apply width ratio
- for (var widthIndex = 0; widthIndex < rawPath.widthElements.length; widthIndex++) {
- coordinates['x' + widthIndex] = rawPath.widthElements[widthIndex] * widthRatio;
- }
- }
- //Apply value to raw path
- var path = Snap.format(
- rawPath.d, {
- mx: mx,
- my: my,
- e: coordinates
- }
- );
- return path;
- };
- }
- module.exports = PathMap;
- },{"200":200}],6:[function(_dereq_,module,exports){
- module.exports = {
- renderer: [ 'type', _dereq_(4) ],
- pathMap: [ 'type', _dereq_(5) ]
- };
- },{"4":4,"5":5}],7:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- forEach = _dereq_(218),
- is = _dereq_(50).is;
- /**
- * A provider for BPMN 2.0 elements context pad
- */
- function ContextPadProvider(contextPad, modeling, elementFactory,
- connect, create, bpmnReplace,
- canvas) {
- contextPad.registerProvider(this);
- this._contextPad = contextPad;
- this._modeling = modeling;
- this._elementFactory = elementFactory;
- this._connect = connect;
- this._create = create;
- this._bpmnReplace = bpmnReplace;
- this._canvas = canvas;
- }
- ContextPadProvider.$inject = [
- 'contextPad',
- 'modeling',
- 'elementFactory',
- 'connect',
- 'create',
- 'bpmnReplace',
- 'canvas'
- ];
- ContextPadProvider.prototype.getContextPadEntries = function(element) {
- var contextPad = this._contextPad,
- modeling = this._modeling,
- elementFactory = this._elementFactory,
- connect = this._connect,
- create = this._create,
- bpmnReplace = this._bpmnReplace,
- canvas = this._canvas;
- var actions = {};
- if (element.type === 'label') {
- return actions;
- }
- var bpmnElement = element.businessObject;
- function startConnect(event, element, autoActivate) {
- connect.start(event, element, autoActivate);
- }
- function removeElement(e) {
- if (element.waypoints) {
- modeling.removeConnection(element);
- } else {
- modeling.removeShape(element);
- }
- }
- function getReplaceMenuPosition(element) {
- var Y_OFFSET = 5;
- var diagramContainer = canvas.getContainer(),
- pad = contextPad.getPad(element).html;
- var diagramRect = diagramContainer.getBoundingClientRect(),
- padRect = pad.getBoundingClientRect();
- var top = padRect.top - diagramRect.top;
- var left = padRect.left - diagramRect.left;
- var pos = {
- x: left,
- y: top + padRect.height + Y_OFFSET
- };
- return pos;
- }
- function appendAction(type, className, options) {
- function appendListener(event, element) {
- var shape = elementFactory.createShape(assign({ type: type }, options));
- create.start(event, shape, element);
- }
- var shortType = type.replace(/^bpmn\:/, '');
- return {
- group: 'model',
- className: className,
- title: 'Append ' + shortType,
- action: {
- dragstart: appendListener,
- click: appendListener
- }
- };
- }
- if (is(bpmnElement, 'bpmn:FlowNode')) {
- if (!is(bpmnElement, 'bpmn:EndEvent') &&
- !is(bpmnElement, 'bpmn:EventBasedGateway') &&
- !isEventType(bpmnElement, 'bpmn:IntermediateThrowEvent', 'bpmn:LinkEventDefinition')) {
- assign(actions, {
- 'append.end-event': appendAction('bpmn:EndEvent', 'icon-end-event-none'),
- 'append.gateway': appendAction('bpmn:ExclusiveGateway', 'icon-gateway-xor'),
- 'append.append-task': appendAction('bpmn:Task', 'icon-task'),
- 'append.intermediate-event': appendAction('bpmn:IntermediateThrowEvent',
- 'icon-intermediate-event-none')
- });
- }
- if (is(bpmnElement, 'bpmn:EventBasedGateway')) {
- assign(actions, {
- 'append.receive-task': appendAction('bpmn:ReceiveTask', 'icon-receive-task'),
- 'append.message-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
- 'icon-intermediate-event-catch-message',
- { _eventDefinitionType: 'bpmn:MessageEventDefinition'}),
- 'append.timer-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
- 'icon-intermediate-event-catch-timer',
- { _eventDefinitionType: 'bpmn:TimerEventDefinition'}),
- 'append.condtion-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
- 'icon-intermediate-event-catch-condition',
- { _eventDefinitionType: 'bpmn:ConditionalEventDefinition'}),
- 'append.signal-intermediate-event': appendAction('bpmn:IntermediateCatchEvent',
- 'icon-intermediate-event-catch-signal',
- { _eventDefinitionType: 'bpmn:SignalEventDefinition'})
- });
- }
- // Replace menu entry
- assign(actions, {
- 'replace': {
- group: 'edit',
- className: 'icon-screw-wrench',
- title: 'Change type',
- action: {
- click: function(event, element) {
- bpmnReplace.openChooser(getReplaceMenuPosition(element), element);
- }
- }
- }
- });
- }
- if (is(bpmnElement, 'bpmn:FlowNode') ||
- is(bpmnElement, 'bpmn:InteractionNode')) {
- assign(actions, {
- 'append.text-annotation': appendAction('bpmn:TextAnnotation', 'icon-text-annotation'),
- 'connect': {
- group: 'connect',
- className: 'icon-connection-multi',
- title: 'Connect using Sequence/MessageFlow',
- action: {
- click: startConnect,
- dragstart: startConnect
- }
- }
- });
- }
- // Delete Element Entry
- assign(actions, {
- 'delete': {
- group: 'edit',
- className: 'icon-trash',
- title: 'Remove',
- action: {
- click: removeElement,
- dragstart: removeElement
- }
- }
- });
- return actions;
- };
- function isEventType(eventBo, type, definition) {
- var isType = eventBo.$instanceOf(type);
- var isDefinition = false;
- var definitions = eventBo.eventDefinitions || [];
- forEach(definitions, function(def) {
- if (def.$type === definition) {
- isDefinition = true;
- }
- });
- return isType && isDefinition;
- }
- module.exports = ContextPadProvider;
- },{"218":218,"339":339,"50":50}],8:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(73),
- _dereq_(102),
- _dereq_(159),
- _dereq_(100),
- _dereq_(104),
- _dereq_(39)
- ],
- __init__: [ 'contextPadProvider' ],
- contextPadProvider: [ 'type', _dereq_(7) ]
- };
- },{"100":100,"102":102,"104":104,"159":159,"39":39,"7":7,"73":73}],9:[function(_dereq_,module,exports){
- 'use strict';
- function BpmnKeyBindings(
- keyboard, spaceTool, lassoTool,
- directEditing, selection, canvas,
- elementRegistry) {
- keyboard.addListener(function(key, modifiers) {
- // ctrl + a -> select all elements
- if (key === 65 && keyboard.isCmd(modifiers)) {
- // select all elements except for the invisible
- // root element
- var rootElement = canvas.getRootElement();
- var elements = elementRegistry.filter(function(element) {
- return element != rootElement;
- });
- selection.select(elements);
- return true;
- }
- if (keyboard.hasModifier(modifiers)) {
- return;
- }
- // s -> activate space tool
- if (key === 83) {
- spaceTool.activateSelection();
- return true;
- }
- // l -> activate lasso tool
- if (key === 76) {
- lassoTool.activateSelection();
- return true;
- }
- var currentSelection = selection.get();
- // e -> activate direct editing
- if (key === 69) {
- if (currentSelection.length) {
- directEditing.activate(currentSelection[0]);
- }
- return true;
- }
- });
- }
- BpmnKeyBindings.$inject = [
- 'keyboard',
- 'spaceTool',
- 'lassoTool',
- 'directEditing',
- 'selection',
- 'canvas',
- 'elementRegistry'
- ];
- module.exports = BpmnKeyBindings;
- },{}],10:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(110)
- ],
- __init__: [ 'bpmnKeyBindings' ],
- bpmnKeyBindings: [ 'type', _dereq_(9) ]
- };
- },{"110":110,"9":9}],11:[function(_dereq_,module,exports){
- 'use strict';
- var UpdateLabelHandler = _dereq_(13);
- var LabelUtil = _dereq_(12);
- var is = _dereq_(50).is,
- isExpanded = _dereq_(48).isExpanded;
- var MIN_BOUNDS = {
- width: 150,
- height: 50
- };
- function LabelEditingProvider(eventBus, canvas, directEditing, commandStack, injector) {
- directEditing.registerProvider(this);
- commandStack.registerHandler('element.updateLabel', UpdateLabelHandler);
- // listen to dblclick on non-root elements
- eventBus.on('element.dblclick', function(event) {
- directEditing.activate(event.element);
- });
- // complete on followup canvas operation
- eventBus.on([ 'element.mousedown', 'drag.activate', 'canvas.viewbox.changed' ], function(event) {
- directEditing.complete();
- });
- // cancel on command stack changes
- eventBus.on([ 'commandStack.changed' ], function() {
- directEditing.cancel();
- });
- // activate direct editing for activities and text annotations
- if ('ontouchstart' in document.documentElement) {
- // we deactivate automatic label editing on mobile devices
- // as it breaks the user interaction workflow
- // TODO(nre): we should temporarily focus the edited element here
- // and release the focused viewport after the direct edit operation is finished
- } else {
- eventBus.on('create.end', 500, function(e) {
- var element = e.shape,
- canExecute = e.context.canExecute;
- if (!canExecute) {
- return;
- }
- if (is(element, 'bpmn:Task') || is(element, 'bpmn:TextAnnotation') ||
- (is(element, 'bpmn:SubProcess') && !isExpanded(element))) {
- directEditing.activate(element);
- }
- });
- }
- this._canvas = canvas;
- this._commandStack = commandStack;
- }
- LabelEditingProvider.$inject = [ 'eventBus', 'canvas', 'directEditing', 'commandStack', 'injector' ];
- module.exports = LabelEditingProvider;
- LabelEditingProvider.prototype.activate = function(element) {
- var text = LabelUtil.getLabel(element);
- if (text === undefined) {
- return;
- }
- var bbox = this.getEditingBBox(element);
- // adjust for expanded pools AND lanes
- if ((is(element, 'bpmn:Participant') && isExpanded(element)) || is(element, 'bpmn:Lane')) {
- bbox.width = MIN_BOUNDS.width;
- bbox.height = MIN_BOUNDS.height;
- bbox.x = bbox.x + 10 - bbox.width / 2;
- bbox.y = bbox.mid.y - bbox.height / 2;
- }
- // adjust for expanded sub processes
- if (is(element, 'bpmn:SubProcess') && isExpanded(element)) {
- bbox.height = MIN_BOUNDS.height;
- bbox.x = bbox.mid.x - bbox.width / 2;
- bbox.y = bbox.y + 10 - bbox.height / 2;
- }
- return { bounds: bbox, text: text };
- };
- LabelEditingProvider.prototype.getEditingBBox = function(element, maxBounds) {
- var target = element.label || element;
- var bbox = this._canvas.getAbsoluteBBox(target);
- var mid = {
- x: bbox.x + bbox.width / 2,
- y: bbox.y + bbox.height / 2
- };
- // external label
- if (target.labelTarget) {
- bbox.width = Math.max(bbox.width, MIN_BOUNDS.width);
- bbox.height = Math.max(bbox.height, MIN_BOUNDS.height);
- bbox.x = mid.x - bbox.width / 2;
- }
- bbox.mid = mid;
- return bbox;
- };
- LabelEditingProvider.prototype.update = function(element, newLabel) {
- this._commandStack.execute('element.updateLabel', {
- element: element,
- newLabel: newLabel
- });
- };
- },{"12":12,"13":13,"48":48,"50":50}],12:[function(_dereq_,module,exports){
- 'use strict';
- function getLabelAttr(semantic) {
- if (semantic.$instanceOf('bpmn:FlowElement') ||
- semantic.$instanceOf('bpmn:Participant') ||
- semantic.$instanceOf('bpmn:Lane') ||
- semantic.$instanceOf('bpmn:SequenceFlow') ||
- semantic.$instanceOf('bpmn:MessageFlow')) {
- return 'name';
- }
- if (semantic.$instanceOf('bpmn:TextAnnotation')) {
- return 'text';
- }
- }
- module.exports.getLabel = function(element) {
- var semantic = element.businessObject,
- attr = getLabelAttr(semantic);
- if (attr) {
- return semantic[attr] || '';
- }
- };
- module.exports.setLabel = function(element, text) {
- var semantic = element.businessObject,
- attr = getLabelAttr(semantic);
- if (attr) {
- semantic[attr] = text;
- }
- var label = element.label || element;
- // show label
- label.hidden = false;
- return label;
- };
- },{}],13:[function(_dereq_,module,exports){
- 'use strict';
- var LabelUtil = _dereq_(12);
- /**
- * A handler that updates the text of a BPMN element.
- *
- * @param {EventBus} eventBus
- */
- function UpdateTextHandler(eventBus) {
- function setText(element, text) {
- var label = LabelUtil.setLabel(element, text);
- eventBus.fire('element.changed', { element: label });
- }
- function execute(ctx) {
- ctx.oldLabel = LabelUtil.getLabel(ctx.element);
- return setText(ctx.element, ctx.newLabel);
- }
- function revert(ctx) {
- return setText(ctx.element, ctx.oldLabel);
- }
- function canExecute(ctx) {
- return true;
- }
- // API
- this.execute = execute;
- this.revert = revert;
- this.canExecute = canExecute;
- }
- UpdateTextHandler.$inject = [ 'eventBus' ];
- module.exports = UpdateTextHandler;
- },{"12":12}],14:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(80),
- _dereq_(98),
- _dereq_(73)
- ],
- __init__: [ 'labelEditingProvider' ],
- labelEditingProvider: [ 'type', _dereq_(11) ]
- };
- },{"11":11,"73":73,"80":80,"98":98}],15:[function(_dereq_,module,exports){
- 'use strict';
- var map = _dereq_(221),
- assign = _dereq_(339),
- pick = _dereq_(345);
- function BpmnFactory(moddle) {
- this._model = moddle;
- }
- BpmnFactory.$inject = [ 'moddle' ];
- BpmnFactory.prototype._needsId = function(element) {
- return element.$instanceOf('bpmn:RootElement') ||
- element.$instanceOf('bpmn:FlowElement') ||
- element.$instanceOf('bpmn:MessageFlow') ||
- element.$instanceOf('bpmn:Artifact') ||
- element.$instanceOf('bpmn:Participant') ||
- element.$instanceOf('bpmn:Process') ||
- element.$instanceOf('bpmn:Collaboration') ||
- element.$instanceOf('bpmndi:BPMNShape') ||
- element.$instanceOf('bpmndi:BPMNEdge') ||
- element.$instanceOf('bpmndi:BPMNDiagram') ||
- element.$instanceOf('bpmndi:BPMNPlane');
- };
- BpmnFactory.prototype._ensureId = function(element) {
- // generate semantic ids for elements
- // bpmn:SequenceFlow -> SequenceFlow_ID
- var prefix = (element.$type || '').replace(/^[^:]*:/g, '') + '_';
- if (!element.id && this._needsId(element)) {
- element.id = this._model.ids.nextPrefixed(prefix, element);
- }
- };
- BpmnFactory.prototype.create = function(type, attrs) {
- var element = this._model.create(type, attrs || {});
- this._ensureId(element);
- return element;
- };
- BpmnFactory.prototype.createDiLabel = function() {
- return this.create('bpmndi:BPMNLabel', {
- bounds: this.createDiBounds()
- });
- };
- BpmnFactory.prototype.createDiShape = function(semantic, bounds, attrs) {
- return this.create('bpmndi:BPMNShape', assign({
- bpmnElement: semantic,
- bounds: this.createDiBounds(bounds)
- }, attrs));
- };
- BpmnFactory.prototype.createDiBounds = function(bounds) {
- return this.create('dc:Bounds', bounds);
- };
- BpmnFactory.prototype.createDiWaypoints = function(waypoints) {
- return map(waypoints, function(pos) {
- return this.createDiWaypoint(pos);
- }, this);
- };
- BpmnFactory.prototype.createDiWaypoint = function(point) {
- return this.create('dc:Point', pick(point, [ 'x', 'y' ]));
- };
- BpmnFactory.prototype.createDiEdge = function(semantic, waypoints, attrs) {
- return this.create('bpmndi:BPMNEdge', assign({
- bpmnElement: semantic
- }, attrs));
- };
- BpmnFactory.prototype.createDiPlane = function(semantic) {
- return this.create('bpmndi:BPMNPlane', {
- bpmnElement: semantic
- });
- };
- module.exports = BpmnFactory;
- },{"221":221,"339":339,"345":345}],16:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- inherits = _dereq_(207);
- var LabelUtil = _dereq_(49);
- var hasExternalLabel = LabelUtil.hasExternalLabel,
- getExternalLabelMid = LabelUtil.getExternalLabelMid;
- var CommandInterceptor = _dereq_(78);
- function LabelSupport(eventBus, modeling, bpmnFactory) {
- CommandInterceptor.call(this, eventBus);
- // create external labels on shape creation
- this.postExecute([ 'shape.create', 'connection.create' ], function(e) {
- var context = e.context;
- var element = context.shape || context.connection,
- businessObject = element.businessObject;
- var position;
- if (hasExternalLabel(businessObject)) {
- position = getExternalLabelMid(element);
- modeling.createLabel(element, position, {
- id: businessObject.id + '_label',
- businessObject: businessObject
- });
- }
- });
- // update di information on label movement and creation
- this.executed([ 'label.create', 'shape.moved' ], function(e) {
- var element = e.context.shape,
- businessObject = element.businessObject,
- di = businessObject.di;
- // we want to trigger on real labels only
- if (!element.labelTarget) {
- return;
- }
- if (!di.label) {
- di.label = bpmnFactory.create('bpmndi:BPMNLabel', {
- bounds: bpmnFactory.create('dc:Bounds')
- });
- }
- assign(di.label.bounds, {
- x: element.x,
- y: element.y,
- width: element.width,
- height: element.height
- });
- });
- }
- inherits(LabelSupport, CommandInterceptor);
- LabelSupport.$inject = [ 'eventBus', 'modeling', 'bpmnFactory' ];
- module.exports = LabelSupport;
- },{"207":207,"339":339,"49":49,"78":78}],17:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var assign = _dereq_(339);
- var BaseLayouter = _dereq_(172),
- ManhattanLayout = _dereq_(175);
- var LayoutUtil = _dereq_(174);
- var getMid = LayoutUtil.getMid,
- getOrientation = LayoutUtil.getOrientation;
- var is = _dereq_(50).is;
- function BpmnLayouter() {}
- inherits(BpmnLayouter, BaseLayouter);
- module.exports = BpmnLayouter;
- BpmnLayouter.prototype.layoutConnection = function(connection, layoutHints) {
- var source = connection.source,
- target = connection.target,
- waypoints = connection.waypoints,
- start,
- end;
- var manhattanOptions,
- updatedWaypoints;
- start = getConnectionDocking(waypoints, 0, source);
- end = getConnectionDocking(waypoints, waypoints && waypoints.length - 1, target);
- // TODO (nre): support vertical modeling
- // and invert preferredLayouts accordingly
- // manhattan layout sequence / message flows
- if (is(connection, 'bpmn:MessageFlow')) {
- manhattanOptions = {
- preferredLayouts: [ 'straight', 'v:v' ]
- };
- } else
- // layout all connection between flow elements h:h,
- //
- // except for
- //
- // (1) outgoing of BoundaryEvents -> layout h:v or v:h based on attach orientation
- // (2) incoming / outgoing of Gateway -> v:h (outgoing), h:v (incoming)
- //
- if (is(connection, 'bpmn:SequenceFlow')) {
- // make sure boundary event connections do
- // not look ugly =:>
- if (is(source, 'bpmn:BoundaryEvent')) {
- var orientation = getAttachOrientation(source);
- if (/left|right/.test(orientation)) {
- manhattanOptions = {
- preferredLayouts: [ 'h:v' ]
- };
- } else
- if (/top|bottom/.test(orientation)) {
- manhattanOptions = {
- preferredLayouts: [ 'v:h' ]
- };
- }
- } else
- if (is(source, 'bpmn:Gateway')) {
- manhattanOptions = {
- preferredLayouts: [ 'v:h' ]
- };
- } else
- if (is(target, 'bpmn:Gateway')) {
- manhattanOptions = {
- preferredLayouts: [ 'h:v' ]
- };
- }
- // apply horizontal love <3
- else {
- manhattanOptions = {
- preferredLayouts: [ 'h:h' ]
- };
- }
- }
- if (manhattanOptions) {
- manhattanOptions = assign(manhattanOptions, layoutHints);
- updatedWaypoints =
- ManhattanLayout.repairConnection(
- source, target,
- start, end,
- waypoints,
- manhattanOptions);
- }
- return updatedWaypoints || [ start, end ];
- };
- function getAttachOrientation(attachedElement) {
- var hostElement = attachedElement.host,
- padding = -10;
- return getOrientation(getMid(attachedElement), hostElement, padding);
- }
- function getConnectionDocking(waypoints, idx, shape) {
- var point = waypoints && waypoints[idx];
- return point ? (point.original || point) : getMid(shape);
- }
- },{"172":172,"174":174,"175":175,"207":207,"339":339,"50":50}],18:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- forEach = _dereq_(218),
- inherits = _dereq_(207);
- var Collections = _dereq_(184),
- Model = _dereq_(176);
- var getBusinessObject = _dereq_(50).getBusinessObject,
- is = _dereq_(50).is;
- var CommandInterceptor = _dereq_(78);
- /**
- * A handler responsible for updating the underlying BPMN 2.0 XML + DI
- * once changes on the diagram happen
- */
- function BpmnUpdater(eventBus, bpmnFactory, connectionDocking) {
- CommandInterceptor.call(this, eventBus);
- this._bpmnFactory = bpmnFactory;
- var self = this;
- ////// connection cropping /////////////////////////
- // crop connection ends during create/update
- function cropConnection(e) {
- var context = e.context,
- connection;
- if (!context.cropped) {
- connection = context.connection;
- connection.waypoints = connectionDocking.getCroppedWaypoints(connection);
- context.cropped = true;
- }
- }
- this.executed([
- 'connection.layout',
- 'connection.create',
- 'connection.reconnectEnd',
- 'connection.reconnectStart'
- ], cropConnection);
- this.reverted([ 'connection.layout' ], function(e) {
- delete e.context.cropped;
- });
- ////// BPMN + DI update /////////////////////////
- // update parent
- function updateParent(e) {
- self.updateParent(e.context.shape || e.context.connection);
- }
- this.executed([ 'shape.move',
- 'shape.create',
- 'shape.delete',
- 'connection.create',
- 'connection.move',
- 'connection.delete' ], updateParent);
- this.reverted([ 'shape.move',
- 'shape.create',
- 'shape.delete',
- 'connection.create',
- 'connection.move',
- 'connection.delete' ], updateParent);
- /*
- * ## Updating Parent
- *
- * When morphing a Process into a Collaboration or vice-versa,
- * make sure that both the *semantic* and *di* parent of each element
- * is updated.
- *
- */
- function updateRoot(event) {
- var context = event.context,
- oldRoot = context.oldRoot,
- children = oldRoot.children;
- forEach(children, function(child) {
- self.updateParent(child);
- });
- }
- this.executed([ 'canvas.updateRoot' ], updateRoot);
- this.reverted([ 'canvas.updateRoot' ], updateRoot);
- // update bounds
- function updateBounds(e) {
- self.updateBounds(e.context.shape);
- }
- this.executed([ 'shape.move', 'shape.create', 'shape.resize' ], updateBounds);
- this.reverted([ 'shape.move', 'shape.create', 'shape.resize' ], updateBounds);
- // attach / detach connection
- function updateConnection(e) {
- self.updateConnection(e.context.connection);
- }
- this.executed([
- 'connection.create',
- 'connection.move',
- 'connection.delete',
- 'connection.reconnectEnd',
- 'connection.reconnectStart'
- ], updateConnection);
- this.reverted([
- 'connection.create',
- 'connection.move',
- 'connection.delete',
- 'connection.reconnectEnd',
- 'connection.reconnectStart'
- ], updateConnection);
- // update waypoints
- function updateConnectionWaypoints(e) {
- self.updateConnectionWaypoints(e.context.connection);
- }
- this.executed([
- 'connection.layout',
- 'connection.move',
- 'connection.updateWaypoints',
- 'connection.reconnectEnd',
- 'connection.reconnectStart'
- ], updateConnectionWaypoints);
- this.reverted([
- 'connection.layout',
- 'connection.move',
- 'connection.updateWaypoints',
- 'connection.reconnectEnd',
- 'connection.reconnectStart'
- ], updateConnectionWaypoints);
- // update attachments
- function updateAttachment(e) {
- self.updateAttachment(e.context);
- }
- this.executed([ 'shape.attach' ], updateAttachment);
- this.reverted([ 'shape.attach' ], updateAttachment);
- }
- inherits(BpmnUpdater, CommandInterceptor);
- module.exports = BpmnUpdater;
- BpmnUpdater.$inject = [ 'eventBus', 'bpmnFactory', 'connectionDocking'];
- /////// implementation //////////////////////////////////
- BpmnUpdater.prototype.updateAttachment = function(context) {
- var shape = context.shape,
- businessObject = shape.businessObject,
- host = shape.host;
- businessObject.attachedToRef = host && host.businessObject;
- };
- BpmnUpdater.prototype.updateParent = function(element) {
- // do not update BPMN 2.0 label parent
- if (element instanceof Model.Label) {
- return;
- }
- var parentShape = element.parent;
- var businessObject = element.businessObject,
- parentBusinessObject = parentShape && parentShape.businessObject,
- parentDi = parentBusinessObject && parentBusinessObject.di;
- this.updateSemanticParent(businessObject, parentBusinessObject);
- this.updateDiParent(businessObject.di, parentDi);
- };
- BpmnUpdater.prototype.updateBounds = function(shape) {
- var di = shape.businessObject.di;
- var bounds = (shape instanceof Model.Label) ? this._getLabel(di).bounds : di.bounds;
- assign(bounds, {
- x: shape.x,
- y: shape.y,
- width: shape.width,
- height: shape.height
- });
- };
- BpmnUpdater.prototype.updateDiParent = function(di, parentDi) {
- if (parentDi && !is(parentDi, 'bpmndi:BPMNPlane')) {
- parentDi = parentDi.$parent;
- }
- if (di.$parent === parentDi) {
- return;
- }
- var planeElements = (parentDi || di.$parent).get('planeElement');
- if (parentDi) {
- planeElements.push(di);
- di.$parent = parentDi;
- } else {
- Collections.remove(planeElements, di);
- di.$parent = null;
- }
- };
- function getDefinitions(element) {
- while (element && !is(element, 'bpmn:Definitions')) {
- element = element.$parent;
- }
- return element;
- }
- BpmnUpdater.prototype.updateSemanticParent = function(businessObject, newParent) {
- var containment;
- if (businessObject.$parent === newParent) {
- return;
- }
- if (is(businessObject, 'bpmn:FlowElement')) {
- if (newParent && is(newParent, 'bpmn:Participant')) {
- newParent = newParent.processRef;
- }
- containment = 'flowElements';
- } else
- if (is(businessObject, 'bpmn:Artifact')) {
- while (newParent &&
- !is(newParent, 'bpmn:Process') &&
- !is(newParent, 'bpmn:SubProcess') &&
- !is(newParent, 'bpmn:Collaboration')) {
- if (is(newParent, 'bpmn:Participant')) {
- newParent = newParent.processRef;
- break;
- } else {
- newParent = newParent.$parent;
- }
- }
- containment = 'artifacts';
- } else
- if (is(businessObject, 'bpmn:MessageFlow')) {
- containment = 'messageFlows';
- } else
- if (is(businessObject, 'bpmn:Participant')) {
- containment = 'participants';
- // make sure the participants process is properly attached / detached
- // from the XML document
- var process = businessObject.processRef,
- definitions;
- if (process) {
- definitions = getDefinitions(businessObject.$parent || newParent);
- if (businessObject.$parent) {
- Collections.remove(definitions.get('rootElements'), process);
- process.$parent = null;
- }
- if (newParent) {
- Collections.add(definitions.get('rootElements'), process);
- process.$parent = definitions;
- }
- }
- }
- if (!containment) {
- throw new Error('no parent for ', businessObject, newParent);
- }
- var children;
- if (businessObject.$parent) {
- // remove from old parent
- children = businessObject.$parent.get(containment);
- Collections.remove(children, businessObject);
- }
- if (!newParent) {
- businessObject.$parent = null;
- } else {
- // add to new parent
- children = newParent.get(containment);
- children.push(businessObject);
- businessObject.$parent = newParent;
- }
- };
- BpmnUpdater.prototype.updateConnectionWaypoints = function(connection) {
- connection.businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
- };
- BpmnUpdater.prototype.updateConnection = function(connection) {
- var businessObject = getBusinessObject(connection),
- newSource = getBusinessObject(connection.source),
- newTarget = getBusinessObject(connection.target);
- var inverseSet = is(businessObject, 'bpmn:SequenceFlow');
- if (businessObject.sourceRef !== newSource) {
- if (inverseSet) {
- Collections.remove(businessObject.sourceRef && businessObject.sourceRef.get('outgoing'), businessObject);
- if (newSource && newSource.get('outgoing')) {
- newSource.get('outgoing').push(businessObject);
- }
- }
- businessObject.sourceRef = newSource;
- }
- if (businessObject.targetRef !== newTarget) {
- if (inverseSet) {
- Collections.remove(businessObject.targetRef && businessObject.targetRef.get('incoming'), businessObject);
- if (newTarget && newTarget.get('incoming')) {
- newTarget.get('incoming').push(businessObject);
- }
- }
- businessObject.targetRef = newTarget;
- }
- businessObject.di.set('waypoint', this._bpmnFactory.createDiWaypoints(connection.waypoints));
- };
- /////// helpers /////////////////////////////////////////
- BpmnUpdater.prototype._getLabel = function(di) {
- if (!di.label) {
- di.label = this._bpmnFactory.createDiLabel();
- }
- return di.label;
- };
- },{"176":176,"184":184,"207":207,"218":218,"339":339,"50":50,"78":78}],19:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- inherits = _dereq_(207);
- var BaseElementFactory = _dereq_(82),
- LabelUtil = _dereq_(49);
- /**
- * A bpmn-aware factory for diagram-js shapes
- */
- function ElementFactory(bpmnFactory, moddle) {
- BaseElementFactory.call(this);
- this._bpmnFactory = bpmnFactory;
- this._moddle = moddle;
- }
- inherits(ElementFactory, BaseElementFactory);
- ElementFactory.$inject = [ 'bpmnFactory', 'moddle' ];
- module.exports = ElementFactory;
- ElementFactory.prototype.baseCreate = BaseElementFactory.prototype.create;
- ElementFactory.prototype.create = function(elementType, attrs) {
- // no special magic for labels,
- // we assume their businessObjects have already been created
- // and wired via attrs
- if (elementType === 'label') {
- return this.baseCreate(elementType, assign({ type: 'label' }, LabelUtil.DEFAULT_LABEL_SIZE, attrs));
- }
- attrs = attrs || {};
- var businessObject = attrs.businessObject,
- size;
- if (!businessObject) {
- if (!attrs.type) {
- throw new Error('no shape type specified');
- }
- businessObject = this._bpmnFactory.create(attrs.type);
- }
- if (!businessObject.di) {
- if (elementType === 'root') {
- businessObject.di = this._bpmnFactory.createDiPlane(businessObject, [], {
- id: businessObject.id + '_di'
- });
- } else
- if (elementType === 'connection') {
- businessObject.di = this._bpmnFactory.createDiEdge(businessObject, [], {
- id: businessObject.id + '_di'
- });
- } else {
- businessObject.di = this._bpmnFactory.createDiShape(businessObject, {}, {
- id: businessObject.id + '_di'
- });
- }
- }
- if (!!attrs.isExpanded) {
- businessObject.di.isExpanded = attrs.isExpanded;
- }
- if (businessObject.$instanceOf('bpmn:ExclusiveGateway')) {
- businessObject.di.isMarkerVisible = true;
- }
- if (attrs._eventDefinitionType) {
- var eventDefinitions = businessObject.get('eventDefinitions') || [],
- newEventDefinition = this._moddle.create(attrs._eventDefinitionType);
- eventDefinitions.push(newEventDefinition);
- businessObject.eventDefinitions = eventDefinitions;
- }
- size = this._getDefaultSize(businessObject);
- attrs = assign({
- businessObject: businessObject,
- id: businessObject.id
- }, size, attrs);
- return this.baseCreate(elementType, attrs);
- };
- ElementFactory.prototype._getDefaultSize = function(semantic) {
- if (semantic.$instanceOf('bpmn:SubProcess')) {
- var isExpanded = semantic.di.isExpanded === true;
- if (isExpanded) {
- return { width: 350, height: 200 };
- } else {
- return { width: 100, height: 80 };
- }
- }
- if (semantic.$instanceOf('bpmn:Task')) {
- return { width: 100, height: 80 };
- }
- if (semantic.$instanceOf('bpmn:Gateway')) {
- return { width: 50, height: 50 };
- }
- if (semantic.$instanceOf('bpmn:Event')) {
- return { width: 36, height: 36 };
- }
- if (semantic.$instanceOf('bpmn:Participant')) {
- return { width: 600, height: 250 };
- }
- return { width: 100, height: 80 };
- };
- ElementFactory.prototype.createParticipantShape = function(collapsed) {
- var participantShape = this.createShape({ type: 'bpmn:Participant' });
- if (!collapsed) {
- participantShape.businessObject.processRef = this._bpmnFactory.create('bpmn:Process');
- }
- return participantShape;
- };
- },{"207":207,"339":339,"49":49,"82":82}],20:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var BaseModeling = _dereq_(115);
- var UpdatePropertiesHandler = _dereq_(31),
- UpdateCanvasRootHandler = _dereq_(30);
- /**
- * BPMN 2.0 modeling features activator
- *
- * @param {EventBus} eventBus
- * @param {ElementFactory} elementFactory
- * @param {CommandStack} commandStack
- * @param {BpmnRules} bpmnRules
- */
- function Modeling(eventBus, elementFactory, commandStack, bpmnRules) {
- BaseModeling.call(this, eventBus, elementFactory, commandStack);
- this._bpmnRules = bpmnRules;
- }
- inherits(Modeling, BaseModeling);
- Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack', 'bpmnRules' ];
- module.exports = Modeling;
- Modeling.prototype.getHandlers = function() {
- var handlers = BaseModeling.prototype.getHandlers.call(this);
- handlers['element.updateProperties'] = UpdatePropertiesHandler;
- handlers['canvas.updateRoot'] = UpdateCanvasRootHandler;
- return handlers;
- };
- Modeling.prototype.updateLabel = function(element, newLabel) {
- this._commandStack.execute('element.updateLabel', {
- element: element,
- newLabel: newLabel
- });
- };
- var getSharedParent = _dereq_(21).getSharedParent;
- Modeling.prototype.connect = function(source, target, attrs) {
- var bpmnRules = this._bpmnRules;
- if (!attrs) {
- if (bpmnRules.canConnectMessageFlow(source, target)) {
- attrs = {
- type: 'bpmn:MessageFlow'
- };
- } else
- if (bpmnRules.canConnectSequenceFlow(source, target)) {
- attrs = {
- type: 'bpmn:SequenceFlow'
- };
- } else {
- attrs = {
- type: 'bpmn:Association'
- };
- }
- }
- return this.createConnection(source, target, attrs, getSharedParent(source, target));
- };
- Modeling.prototype.updateProperties = function(element, properties) {
- this._commandStack.execute('element.updateProperties', {
- element: element,
- properties: properties
- });
- };
- /**
- * Transform the current diagram into a collaboration.
- *
- * @return {djs.model.Root} the new root element
- */
- Modeling.prototype.makeCollaboration = function() {
- var collaborationElement = this._create('root', {
- type: 'bpmn:Collaboration'
- });
- var context = {
- newRoot: collaborationElement
- };
- this._commandStack.execute('canvas.updateRoot', context);
- return collaborationElement;
- };
- /**
- * Transform the current diagram into a process.
- *
- * @return {djs.model.Root} the new root element
- */
- Modeling.prototype.makeProcess = function() {
- var processElement = this._create('root', {
- type: 'bpmn:Process'
- });
- var context = {
- newRoot: processElement
- };
- this._commandStack.execute('canvas.updateRoot', context);
- };
- },{"115":115,"207":207,"21":21,"30":30,"31":31}],21:[function(_dereq_,module,exports){
- 'use strict';
- var find = _dereq_(217);
- function getParents(element) {
- var parents = [];
- while (element) {
- element = element.parent;
- if (element) {
- parents.push(element);
- }
- }
- return parents;
- }
- module.exports.getParents = getParents;
- function getSharedParent(a, b) {
- var parentsA = getParents(a),
- parentsB = getParents(b);
- return find(parentsA, function(parent) {
- return parentsB.indexOf(parent) !== -1;
- });
- }
- module.exports.getSharedParent = getSharedParent;
- },{"217":217}],22:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var is = _dereq_(50).is;
- var CommandInterceptor = _dereq_(78);
- function AppendBehavior(eventBus, elementFactory, bpmnRules) {
- CommandInterceptor.call(this, eventBus);
- // assign correct shape position unless already set
- this.preExecute('shape.append', function(context) {
- var source = context.source,
- shape = context.shape;
- if (!context.position) {
- if (is(shape, 'bpmn:TextAnnotation')) {
- context.position = {
- x: source.x + source.width / 2 + 75,
- y: source.y - (50) - shape.height / 2
- };
- } else {
- context.position = {
- x: source.x + source.width + 80 + shape.width / 2,
- y: source.y + source.height / 2
- };
- }
- }
- }, true);
- }
- AppendBehavior.$inject = [ 'eventBus', 'elementFactory', 'bpmnRules' ];
- inherits(AppendBehavior, CommandInterceptor);
- module.exports = AppendBehavior;
- },{"207":207,"50":50,"78":78}],23:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var CommandInterceptor = _dereq_(78);
- var is = _dereq_(50).is;
- /**
- * BPMN specific create boundary event behavior
- */
- function CreateBoundaryEventBehavior(eventBus, modeling, elementFactory, bpmnFactory) {
- CommandInterceptor.call(this, eventBus);
- /**
- * replace intermediate event with boundary event when
- * attaching it to a shape
- */
- this.preExecute('shape.create', function(context) {
- var shape = context.shape,
- host = context.host,
- businessObject,
- boundaryEvent;
- var attrs = {
- cancelActivity: true
- };
- if (host && is(shape, 'bpmn:IntermediateThrowEvent')) {
- attrs.attachedToRef = host.businessObject;
- businessObject = bpmnFactory.create('bpmn:BoundaryEvent', attrs);
- boundaryEvent = {
- type: 'bpmn:BoundaryEvent',
- businessObject: businessObject
- };
- context.shape = elementFactory.createShape(boundaryEvent);
- }
- }, true);
- }
- CreateBoundaryEventBehavior.$inject = [ 'eventBus', 'modeling', 'elementFactory', 'bpmnFactory' ];
- inherits(CreateBoundaryEventBehavior, CommandInterceptor);
- module.exports = CreateBoundaryEventBehavior;
- },{"207":207,"50":50,"78":78}],24:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var assign = _dereq_(339);
- var CommandInterceptor = _dereq_(78);
- var getApproxIntersection = _dereq_(191).getApproxIntersection;
- function copy(obj) {
- return assign({}, obj);
- }
- function CreateOnFlowBehavior(eventBus, bpmnRules, modeling) {
- CommandInterceptor.call(this, eventBus);
- /**
- * Reconnect start / end of a connection after
- * dropping an element on a flow.
- */
- this.preExecute('shape.create', function(context) {
- var parent = context.parent,
- shape = context.shape;
- if (bpmnRules.canInsert(shape, parent)) {
- context.targetFlow = parent;
- context.parent = parent.parent;
- }
- }, true);
- this.postExecute('shape.create', function(context) {
- var shape = context.shape,
- targetFlow = context.targetFlow,
- position = context.position,
- source,
- target,
- reconnected,
- intersection,
- waypoints,
- waypointsBefore,
- waypointsAfter,
- dockingPoint;
- if (targetFlow) {
- waypoints = targetFlow.waypoints;
- intersection = getApproxIntersection(waypoints, position);
- if (intersection) {
- waypointsBefore = waypoints.slice(0, intersection.index);
- waypointsAfter = waypoints.slice(intersection.index + (intersection.bendpoint ? 1 : 0));
- dockingPoint = intersection.bendpoint ? waypoints[intersection.index] : position;
- waypointsBefore.push(copy(dockingPoint));
- waypointsAfter.unshift(copy(dockingPoint));
- }
- source = targetFlow.source;
- target = targetFlow.target;
- if (bpmnRules.canConnect(source, shape, targetFlow)) {
- // reconnect source -> inserted shape
- modeling.reconnectEnd(targetFlow, shape, waypointsBefore || copy(position));
- reconnected = true;
- }
- if (bpmnRules.canConnect(shape, target, targetFlow)) {
- if (!reconnected) {
- // reconnect inserted shape -> end
- modeling.reconnectStart(targetFlow, shape, waypointsAfter || copy(position));
- } else {
- modeling.connect(shape, target, { type: targetFlow.type, waypoints: waypointsAfter });
- }
- }
- }
- }, true);
- }
- inherits(CreateOnFlowBehavior, CommandInterceptor);
- CreateOnFlowBehavior.$inject = [ 'eventBus', 'bpmnRules', 'modeling' ];
- module.exports = CreateOnFlowBehavior;
- },{"191":191,"207":207,"339":339,"78":78}],25:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var CommandInterceptor = _dereq_(78);
- var is = _dereq_(50).is;
- /**
- * BPMN specific create participant behavior
- */
- function CreateParticipantBehavior(eventBus, modeling, elementFactory, bpmnFactory) {
- CommandInterceptor.call(this, eventBus);
- /**
- * morph process into collaboration before adding
- * participant onto collaboration
- */
- this.preExecute('shape.create', function(context) {
- var parent = context.parent,
- shape = context.shape,
- position = context.position;
- if (is(parent, 'bpmn:Process') && is(shape, 'bpmn:Participant')) {
- // this is going to detach the process root
- // and set the returned collaboration element
- // as the new root element
- var collaborationElement = modeling.makeCollaboration();
- // monkey patch the create context
- // so that the participant is being dropped
- // onto the new collaboration root instead
- context.position = position;
- context.parent = collaborationElement;
- context.processRoot = parent;
- }
- }, true);
- this.execute('shape.create', function(context) {
- var processRoot = context.processRoot,
- shape = context.shape;
- if (processRoot) {
- context.oldProcessRef = shape.businessObject.processRef;
- // assign the participant processRef
- shape.businessObject.processRef = processRoot.businessObject;
- }
- }, true);
- this.revert('shape.create', function(context) {
- var processRoot = context.processRoot,
- shape = context.shape;
- if (processRoot) {
- // assign the participant processRef
- shape.businessObject.processRef = context.oldProcessRef;
- }
- }, true);
- this.postExecute('shape.create', function(context) {
- var processRoot = context.processRoot,
- shape = context.shape;
- if (processRoot) {
- // process root is already detached at this point
- var processChildren = processRoot.children.slice();
- modeling.moveShapes(processChildren, { x: 0, y: 0 }, shape);
- }
- }, true);
- }
- CreateParticipantBehavior.$inject = [ 'eventBus', 'modeling', 'elementFactory', 'bpmnFactory' ];
- inherits(CreateParticipantBehavior, CommandInterceptor);
- module.exports = CreateParticipantBehavior;
- },{"207":207,"50":50,"78":78}],26:[function(_dereq_,module,exports){
- 'use strict';
- var is = _dereq_(50).is;
- function ModelingFeedback(eventBus, tooltips) {
- function showError(position, message) {
- tooltips.add({
- position: {
- x: position.x + 5,
- y: position.y + 5
- },
- type: 'error',
- timeout: 2000,
- html: '<div>' + message + '</div>'
- });
- }
- eventBus.on([ 'shape.move.rejected', 'create.rejected' ], function(event) {
- var context = event.context,
- shape = context.shape,
- target = context.target;
- if (is(target, 'bpmn:Collaboration') && is(shape, 'bpmn:FlowNode')) {
- showError(event, 'flow elements must be children of pools/participants');
- }
- });
- }
- ModelingFeedback.$inject = [ 'eventBus', 'tooltips' ];
- module.exports = ModelingFeedback;
- },{"50":50}],27:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var CommandInterceptor = _dereq_(78);
- var is = _dereq_(50).is;
- /**
- * BPMN specific remove behavior
- */
- function RemoveBehavior(eventBus, modeling) {
- CommandInterceptor.call(this, eventBus);
- /**
- * morph collaboration diagram into process diagram
- * after the last participant has been removed
- */
- this.preExecute('shape.delete', function(context) {
- var shape = context.shape,
- parent = shape.parent;
- // activate the behavior if the shape to be removed
- // is a participant
- if (is(shape, 'bpmn:Participant')) {
- context.collaborationRoot = parent;
- }
- }, true);
- this.postExecute('shape.delete', function(context) {
- var collaborationRoot = context.collaborationRoot;
- if (collaborationRoot && !collaborationRoot.businessObject.participants.length) {
- // replace empty collaboration with process diagram
- modeling.makeProcess();
- }
- }, true);
- }
- RemoveBehavior.$inject = [ 'eventBus', 'modeling' ];
- inherits(RemoveBehavior, CommandInterceptor);
- module.exports = RemoveBehavior;
- },{"207":207,"50":50,"78":78}],28:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- inherits = _dereq_(207);
- var CommandInterceptor = _dereq_(78);
- var is = _dereq_(50).is,
- getSharedParent = _dereq_(21).getSharedParent;
- function ReplaceConnectionBehavior(eventBus, modeling, bpmnRules) {
- CommandInterceptor.call(this, eventBus);
- function replaceConnection(connection) {
- var source = connection.source,
- target = connection.target;
- var replacementType,
- remove;
- /**
- * Check if incoming or outgoing connections
- * can stay or could be substituted with an
- * appropriate replacement.
- *
- * This holds true for SequenceFlow <> MessageFlow.
- */
- if (is(connection, 'bpmn:SequenceFlow')) {
- if (!bpmnRules.canConnectSequenceFlow(source, target)) {
- remove = true;
- }
- if (bpmnRules.canConnectMessageFlow(source, target)) {
- replacementType = 'bpmn:MessageFlow';
- }
- }
- // transform message flows into sequence flows, if possible
- if (is(connection, 'bpmn:MessageFlow')) {
- if (!bpmnRules.canConnectMessageFlow(source, target)) {
- remove = true;
- }
- if (bpmnRules.canConnectSequenceFlow(source, target)) {
- replacementType = 'bpmn:SequenceFlow';
- }
- }
- if (is(connection, 'bpmn:Association') && !bpmnRules.canConnectAssociation(source, target)) {
- remove = true;
- }
- // remove invalid connection
- if (remove) {
- modeling.removeConnection(connection);
- }
- // replace SequenceFlow <> MessageFlow
- if (replacementType) {
- modeling.createConnection(source, target, {
- type: replacementType,
- waypoints: connection.waypoints.slice()
- }, getSharedParent(source, target));
- }
- }
- this.postExecuted('shapes.move', function(context) {
- var closure = context.closure,
- allConnections = closure.allConnections;
- forEach(allConnections, replaceConnection);
- }, true);
- this.postExecuted([
- 'connection.reconnectStart',
- 'connection.reconnectEnd'
- ], function(event){
- var connection = event.context.connection;
- replaceConnection(connection);
- });
- }
- inherits(ReplaceConnectionBehavior, CommandInterceptor);
- ReplaceConnectionBehavior.$inject = [ 'eventBus', 'modeling', 'bpmnRules' ];
- module.exports = ReplaceConnectionBehavior;
- },{"207":207,"21":21,"218":218,"50":50,"78":78}],29:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [
- 'appendBehavior',
- 'createParticipantBehavior',
- 'createBoundaryEventBehavior',
- 'createOnFlowBehavior',
- 'replaceConnectionBehavior',
- 'removeBehavior',
- 'modelingFeedback'
- ],
- appendBehavior: [ 'type', _dereq_(22) ],
- createParticipantBehavior: [ 'type', _dereq_(25) ],
- createBoundaryEventBehavior: [ 'type', _dereq_(23) ],
- createOnFlowBehavior: [ 'type', _dereq_(24) ],
- replaceConnectionBehavior: [ 'type', _dereq_(28) ],
- removeBehavior: [ 'type', _dereq_(27) ],
- modelingFeedback: [ 'type', _dereq_(26) ]
- };
- },{"22":22,"23":23,"24":24,"25":25,"26":26,"27":27,"28":28}],30:[function(_dereq_,module,exports){
- 'use strict';
- var Collections = _dereq_(184);
- function UpdateCanvasRootHandler(canvas, modeling) {
- this._canvas = canvas;
- this._modeling = modeling;
- }
- UpdateCanvasRootHandler.$inject = [ 'canvas', 'modeling' ];
- module.exports = UpdateCanvasRootHandler;
- UpdateCanvasRootHandler.prototype.execute = function(context) {
- var canvas = this._canvas;
- var newRoot = context.newRoot,
- newRootBusinessObject = newRoot.businessObject,
- oldRoot = canvas.getRootElement(),
- oldRootBusinessObject = oldRoot.businessObject,
- bpmnDefinitions = oldRootBusinessObject.$parent,
- diPlane = oldRootBusinessObject.di;
- // (1) replace process old <> new root
- canvas.setRootElement(newRoot, true);
- // (2) update root elements
- Collections.add(bpmnDefinitions.rootElements, newRootBusinessObject);
- newRootBusinessObject.$parent = bpmnDefinitions;
- Collections.remove(bpmnDefinitions.rootElements, oldRootBusinessObject);
- oldRootBusinessObject.$parent = null;
- // (3) wire di
- oldRootBusinessObject.di = null;
- diPlane.bpmnElement = newRootBusinessObject;
- newRootBusinessObject.di = diPlane;
- context.oldRoot = oldRoot;
- };
- UpdateCanvasRootHandler.prototype.revert = function(context) {
- var canvas = this._canvas;
- var newRoot = context.newRoot,
- newRootBusinessObject = newRoot.businessObject,
- oldRoot = context.oldRoot,
- oldRootBusinessObject = oldRoot.businessObject,
- bpmnDefinitions = newRootBusinessObject.$parent,
- diPlane = newRootBusinessObject.di;
- // (1) replace process old <> new root
- canvas.setRootElement(oldRoot, true);
- // (2) update root elements
- Collections.remove(bpmnDefinitions.rootElements, newRootBusinessObject);
- newRootBusinessObject.$parent = null;
- Collections.add(bpmnDefinitions.rootElements, oldRootBusinessObject);
- oldRootBusinessObject.$parent = bpmnDefinitions;
- // (3) wire di
- newRootBusinessObject.di = null;
- diPlane.bpmnElement = oldRootBusinessObject;
- oldRootBusinessObject.di = diPlane;
- };
- },{"184":184}],31:[function(_dereq_,module,exports){
- 'use strict';
- var reduce = _dereq_(346),
- keys = _dereq_(340),
- forEach = _dereq_(218);
- var DEFAULT_FLOW = 'default',
- NAME = 'name',
- ID = 'id';
- /**
- * A handler that implements a BPMN 2.0 property update.
- *
- * This should be used to set simple properties on elements with
- * an underlying BPMN business object.
- *
- * Use respective diagram-js provided handlers if you would
- * like to perform automated modeling.
- */
- function UpdatePropertiesHandler(elementRegistry) {
- this._elementRegistry = elementRegistry;
- }
- UpdatePropertiesHandler.$inject = [ 'elementRegistry' ];
- module.exports = UpdatePropertiesHandler;
- function getProperties(businessObject, propertyNames) {
- return reduce(propertyNames, function(result, key) {
- result[key] = businessObject.get(key);
- return result;
- }, {});
- }
- function setProperties(businessObject, properties) {
- forEach(properties, function(value, key) {
- businessObject.set(key, value);
- });
- }
- ////// api /////////////////////////////////////////////
- /**
- * Updates a BPMN element with a list of new properties
- *
- * @param {Object} context
- * @param {djs.model.Base} context.element the element to update
- * @param {Object} context.properties a list of properties to set on the element's
- * businessObject (the BPMN model element)
- *
- * @return {Array<djs.mode.Base>} the updated element
- */
- UpdatePropertiesHandler.prototype.execute = function(context) {
- var element = context.element,
- changed = [ element ];
- if (!element) {
- throw new Error('element required');
- }
- var elementRegistry = this._elementRegistry;
- var businessObject = element.businessObject,
- properties = context.properties,
- oldProperties = context.oldProperties || getProperties(businessObject, keys(properties));
- if (ID in properties) {
- elementRegistry.updateId(element, properties[ID]);
- }
- // correctly indicate visual changes on default flow updates
- if (DEFAULT_FLOW in properties) {
- if (properties[DEFAULT_FLOW]) {
- changed.push(elementRegistry.get(properties[DEFAULT_FLOW].id));
- }
- if (businessObject[DEFAULT_FLOW]) {
- changed.push(elementRegistry.get(businessObject[DEFAULT_FLOW].id));
- }
- }
- if (NAME in properties && element.label) {
- changed.push(element.label);
- }
- // update properties
- setProperties(businessObject, properties);
- // store old values
- context.oldProperties = oldProperties;
- context.changed = changed;
- // indicate changed on objects affected by the update
- return changed;
- };
- /**
- * Reverts the update on a BPMN elements properties.
- *
- * @param {Object} context
- *
- * @return {djs.mode.Base} the updated element
- */
- UpdatePropertiesHandler.prototype.revert = function(context) {
- var element = context.element,
- oldProperties = context.oldProperties,
- businessObject = element.businessObject,
- elementRegistry = this._elementRegistry;
- // update properties
- setProperties(businessObject, oldProperties);
- if (ID in oldProperties) {
- elementRegistry.updateId(element, oldProperties[ID]);
- }
- return context.changed;
- };
- },{"218":218,"340":340,"346":346}],32:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'modeling', 'bpmnUpdater', 'bpmnLabelSupport' ],
- __depends__: [
- _dereq_(14),
- _dereq_(34),
- _dereq_(29),
- _dereq_(80),
- _dereq_(168),
- _dereq_(112),
- _dereq_(91),
- _dereq_(159),
- _dereq_(98)
- ],
- bpmnFactory: [ 'type', _dereq_(15) ],
- bpmnUpdater: [ 'type', _dereq_(18) ],
- elementFactory: [ 'type', _dereq_(19) ],
- modeling: [ 'type', _dereq_(20) ],
- bpmnLabelSupport: [ 'type', _dereq_(16) ],
- layouter: [ 'type', _dereq_(17) ],
- connectionDocking: [ 'type', _dereq_(173) ]
- };
- },{"112":112,"14":14,"15":15,"159":159,"16":16,"168":168,"17":17,"173":173,"18":18,"19":19,"20":20,"29":29,"34":34,"80":80,"91":91,"98":98}],33:[function(_dereq_,module,exports){
- 'use strict';
- var groupBy = _dereq_(219),
- size = _dereq_(223),
- find = _dereq_(217),
- any = _dereq_(214),
- inherits = _dereq_(207);
- var getParents = _dereq_(21).getParents,
- is = _dereq_(50).is,
- getBusinessObject = _dereq_(50).getBusinessObject,
- isExpanded = _dereq_(48).isExpanded;
- var RuleProvider = _dereq_(153);
- var isBoundaryAttachment = _dereq_(41).getBoundaryAttachment;
- /**
- * BPMN specific modeling rule
- */
- function BpmnRules(eventBus) {
- RuleProvider.call(this, eventBus);
- }
- inherits(BpmnRules, RuleProvider);
- BpmnRules.$inject = [ 'eventBus' ];
- module.exports = BpmnRules;
- BpmnRules.prototype.init = function() {
- this.addRule('connection.create', function(context) {
- var source = context.source,
- target = context.target;
- return canConnect(source, target);
- });
- this.addRule('connection.reconnectStart', function(context) {
- var connection = context.connection,
- source = context.hover || context.source,
- target = connection.target;
- return canConnect(source, target, connection);
- });
- this.addRule('connection.reconnectEnd', function(context) {
- var connection = context.connection,
- source = connection.source,
- target = context.hover || context.target;
- return canConnect(source, target, connection);
- });
- this.addRule('connection.updateWaypoints', function(context) {
- // OK! but visually ignore
- return null;
- });
- this.addRule('shape.resize', function(context) {
- var shape = context.shape,
- newBounds = context.newBounds;
- return canResize(shape, newBounds);
- });
- this.addRule('shapes.move', function(context) {
- var target = context.target,
- shapes = context.shapes,
- position = context.position;
- return canAttach(shapes, target, null, position) || canMove(shapes, target, position);
- });
- this.addRule([ 'shape.create', 'shape.append' ], function(context) {
- var target = context.target,
- shape = context.shape,
- source = context.source,
- position = context.position;
- return canAttach([ shape ], target, source, position) || canCreate(shape, target, source, position);
- });
- };
- BpmnRules.prototype.canConnectMessageFlow = canConnectMessageFlow;
- BpmnRules.prototype.canConnectSequenceFlow = canConnectSequenceFlow;
- BpmnRules.prototype.canConnectAssociation = canConnectAssociation;
- BpmnRules.prototype.canMove = canMove;
- BpmnRules.prototype.canAttach = canAttach;
- BpmnRules.prototype.canDrop = canDrop;
- BpmnRules.prototype.canInsert = canInsert;
- BpmnRules.prototype.canCreate = canCreate;
- BpmnRules.prototype.canConnect = canConnect;
- BpmnRules.prototype.canResize = canResize;
- /**
- * Utility functions for rule checking
- */
- function nonExistantOrLabel(element) {
- return !element || isLabel(element);
- }
- function isSame(a, b) {
- return a === b;
- }
- function getOrganizationalParent(element) {
- var bo = getBusinessObject(element);
- while (bo && !is(bo, 'bpmn:Process')) {
- if (is(bo, 'bpmn:Participant')) {
- return bo.processRef || bo;
- }
- bo = bo.$parent;
- }
- return bo;
- }
- function isSameOrganization(a, b) {
- var parentA = getOrganizationalParent(a),
- parentB = getOrganizationalParent(b);
- return parentA === parentB;
- }
- function isMessageFlowSource(element) {
- return is(element, 'bpmn:InteractionNode') && (
- !is(element, 'bpmn:Event') || (
- is(element, 'bpmn:ThrowEvent') &&
- hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
- )
- );
- }
- function isMessageFlowTarget(element) {
- return is(element, 'bpmn:InteractionNode') && (
- !is(element, 'bpmn:Event') || (
- is(element, 'bpmn:CatchEvent') &&
- hasEventDefinitionOrNone(element, 'bpmn:MessageEventDefinition')
- )
- );
- }
- function getScopeParent(element) {
- var bo = getBusinessObject(element);
- if (is(bo, 'bpmn:Participant')) {
- return null;
- }
- while (bo) {
- bo = bo.$parent;
- if (is(bo, 'bpmn:FlowElementsContainer')) {
- return bo;
- }
- }
- return bo;
- }
- function isSameScope(a, b) {
- var scopeParentA = getScopeParent(a),
- scopeParentB = getScopeParent(b);
- return scopeParentA && (scopeParentA === scopeParentB);
- }
- function hasEventDefinition(element, eventDefinition) {
- var bo = getBusinessObject(element);
- return !!find(bo.eventDefinitions || [], function(definition) {
- return is(definition, eventDefinition);
- });
- }
- function hasEventDefinitionOrNone(element, eventDefinition) {
- var bo = getBusinessObject(element);
- return (bo.eventDefinitions || []).every(function(definition) {
- return is(definition, eventDefinition);
- });
- }
- function isSequenceFlowSource(element) {
- return is(element, 'bpmn:FlowNode') && !is(element, 'bpmn:EndEvent') &&
- !(is(element, 'bpmn:IntermediateThrowEvent') &&
- hasEventDefinition(element, 'bpmn:LinkEventDefinition')
- );
- }
- function isSequenceFlowTarget(element) {
- return is(element, 'bpmn:FlowNode') &&
- !is(element, 'bpmn:StartEvent') &&
- !is(element, 'bpmn:BoundaryEvent') &&
- !(is(element, 'bpmn:IntermediateCatchEvent') &&
- hasEventDefinition(element, 'bpmn:LinkEventDefinition'));
- }
- function isEventBasedTarget(element) {
- return is(element, 'bpmn:ReceiveTask') || (
- is(element, 'bpmn:IntermediateCatchEvent') && (
- hasEventDefinition(element, 'bpmn:MessageEventDefinition') ||
- hasEventDefinition(element, 'bpmn:TimerEventDefinition') ||
- hasEventDefinition(element, 'bpmn:ConditionalEventDefinition') ||
- hasEventDefinition(element, 'bpmn:SignalEventDefinition')
- )
- );
- }
- function isLabel(element) {
- return element.labelTarget;
- }
- function isConnection(element) {
- return element.waypoints;
- }
- function isParent(possibleParent, element) {
- var allParents = getParents(element);
- return allParents.indexOf(possibleParent) !== -1;
- }
- function canConnect(source, target, connection) {
- if (nonExistantOrLabel(source) || nonExistantOrLabel(target)) {
- return null;
- }
- // See https://github.com/bpmn-io/bpmn-js/issues/178
- // as a workround we disallow connections with same
- // target and source element.
- // This rule must be removed if a auto layout for this
- // connections is implemented.
- if (isSame(source, target)) {
- return false;
- }
- if (canConnectMessageFlow(source, target) ||
- canConnectSequenceFlow(source, target)) {
- return true;
- }
- if (is(connection, 'bpmn:Association')) {
- return canConnectAssociation(source, target);
- }
- return false;
- }
- /**
- * Can an element be dropped into the target element
- *
- * @return {Boolean}
- */
- function canDrop(element, target) {
- // can move labels everywhere
- if (isLabel(element) && !isConnection(target)) {
- return true;
- }
- // allow to create new participants on
- // on existing collaboration and process diagrams
- if (is(element, 'bpmn:Participant')) {
- return is(target, 'bpmn:Process') || is(target, 'bpmn:Collaboration');
- }
- if (is(element, 'bpmn:BoundaryEvent')) {
- return false;
- }
- // drop flow elements onto flow element containers
- // and participants
- if (is(element, 'bpmn:FlowElement')) {
- if (is(target, 'bpmn:FlowElementsContainer')) {
- return isExpanded(target) !== false;
- }
- return is(target, 'bpmn:Participant');
- }
- if (is(element, 'bpmn:Artifact')) {
- return is(target, 'bpmn:Collaboration') ||
- is(target, 'bpmn:Participant') ||
- is(target, 'bpmn:Process');
- }
- if (is(element, 'bpmn:MessageFlow')) {
- return is(target, 'bpmn:Collaboration');
- }
- return false;
- }
- function isBoundaryEvent(element) {
- return !isLabel(element) && is(element, 'bpmn:BoundaryEvent');
- }
- /**
- * We treat IntermediateThrowEvents as boundary events during create,
- * this must be reflected in the rules.
- */
- function isBoundaryCandidate(element) {
- return isBoundaryEvent(element) ||
- (is(element, 'bpmn:IntermediateThrowEvent') && !element.parent);
- }
- function canAttach(elements, target, source, position) {
- // disallow appending as boundary event
- if (source) {
- return false;
- }
- // only (re-)attach one element at a time
- if (elements.length !== 1) {
- return false;
- }
- var element = elements[0];
- // do not attach labels
- if (isLabel(element)) {
- return false;
- }
- // only handle boundary events
- if (!isBoundaryCandidate(element)) {
- return false;
- }
- // allow default move operation
- if (!target) {
- return true;
- }
- // only allow drop on activities
- if (!is(target, 'bpmn:Activity')) {
- return false;
- }
- // only attach to subprocess border
- if (position && !isBoundaryAttachment(position, target)) {
- return false;
- }
- return 'attach';
- }
- function canMove(elements, target) {
- // only move if they have the same parent
- if (!haveSameParent(elements)) {
- return false;
- }
- // do not move selection containing boundary events
- if (any(elements, isBoundaryEvent)) {
- return false;
- }
- // allow default move check to start move operation
- if (!target) {
- return true;
- }
- return elements.every(function(element) {
- return canDrop(element, target);
- });
- }
- function canCreate(shape, target, source, position) {
- if (!target) {
- return false;
- }
- if (isLabel(target)) {
- return null;
- }
- if (isSame(source, target)) {
- return false;
- }
- // ensure we do not drop the element
- // into source
- if (source && isParent(source, target)) {
- return false;
- }
- return canDrop(shape, target, position) || canInsert(shape, target, position);
- }
- function canResize(shape, newBounds) {
- if (is(shape, 'bpmn:SubProcess')) {
- return (!!isExpanded(shape)) && (
- !newBounds || (newBounds.width >= 100 && newBounds.height >= 80)
- );
- }
- if (is(shape, 'bpmn:Participant')) {
- return !newBounds || (newBounds.width >= 100 && newBounds.height >= 80);
- }
- if (is(shape, 'bpmn:TextAnnotation')) {
- return true;
- }
- return false;
- }
- function canConnectAssociation(source, target) {
- // do not connect connections
- if (isConnection(source) || isConnection(target)) {
- return false;
- }
- // connect if different parent
- return !isParent(target, source) &&
- !isParent(source, target);
- }
- function canConnectMessageFlow(source, target) {
- return isMessageFlowSource(source) &&
- isMessageFlowTarget(target) &&
- !isSameOrganization(source, target);
- }
- function canConnectSequenceFlow(source, target) {
- return isSequenceFlowSource(source) &&
- isSequenceFlowTarget(target) &&
- isSameScope(source, target) &&
- !(is(source, 'bpmn:EventBasedGateway') && !isEventBasedTarget(target));
- }
- function canInsert(shape, flow, position) {
- // return true if we can drop on the
- // underlying flow parent
- //
- // at this point we are not really able to talk
- // about connection rules (yet)
- return (
- is(flow, 'bpmn:SequenceFlow') ||
- is(flow, 'bpmn:MessageFlow')
- ) && is(shape, 'bpmn:FlowNode') && !is(shape, 'bpmn:BoundaryEvent') &&
- canDrop(shape, flow.parent, position);
- }
- function haveSameParent(elements) {
- return size(groupBy(elements, function(e) { return e.parent && e.parent.id; })) === 1;
- }
- },{"153":153,"207":207,"21":21,"214":214,"217":217,"219":219,"223":223,"41":41,"48":48,"50":50}],34:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(155)
- ],
- __init__: [ 'bpmnRules' ],
- bpmnRules: [ 'type', _dereq_(33) ]
- };
- },{"155":155,"33":33}],35:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- /**
- * A palette provider for BPMN 2.0 elements.
- */
- function PaletteProvider(palette, create, elementFactory, spaceTool, lassoTool) {
- this._create = create;
- this._elementFactory = elementFactory;
- this._spaceTool = spaceTool;
- this._lassoTool = lassoTool;
- palette.registerProvider(this);
- }
- module.exports = PaletteProvider;
- PaletteProvider.$inject = [ 'palette', 'create', 'elementFactory', 'spaceTool', 'lassoTool' ];
- PaletteProvider.prototype.getPaletteEntries = function(element) {
- var actions = {},
- create = this._create,
- elementFactory = this._elementFactory,
- spaceTool = this._spaceTool,
- lassoTool = this._lassoTool;
- function createAction(type, group, className, title, options) {
- function createListener(event) {
- var shape = elementFactory.createShape(assign({ type: type }, options));
- if (options) {
- shape.businessObject.di.isExpanded = options.isExpanded;
- }
- create.start(event, shape);
- }
- var shortType = type.replace(/^bpmn\:/, '');
- return {
- group: group,
- className: className,
- title: title || 'Create ' + shortType,
- action: {
- dragstart: createListener,
- click: createListener
- }
- };
- }
- function createParticipant(event, collapsed) {
- create.start(event, elementFactory.createParticipantShape(collapsed));
- }
- assign(actions, {
- 'lasso-tool': {
- group: 'tools',
- className: 'icon-lasso-tool',
- title: 'Activate the lasso tool',
- action: {
- click: function(event) {
- lassoTool.activateSelection(event);
- }
- }
- },
- 'space-tool': {
- group: 'tools',
- className: 'icon-space-tool',
- title: 'Activate the create/remove space tool',
- action: {
- click: function(event) {
- spaceTool.activateSelection(event);
- }
- }
- },
- 'tool-separator': {
- group: 'tools',
- separator: true
- },
- 'create.start-event': createAction(
- 'bpmn:StartEvent', 'event', 'icon-start-event-none'
- ),
- 'create.intermediate-event': createAction(
- 'bpmn:IntermediateThrowEvent', 'event', 'icon-intermediate-event-none'
- ),
- 'create.end-event': createAction(
- 'bpmn:EndEvent', 'event', 'icon-end-event-none'
- ),
- 'create.exclusive-gateway': createAction(
- 'bpmn:ExclusiveGateway', 'gateway', 'icon-gateway-xor'
- ),
- 'create.task': createAction(
- 'bpmn:Task', 'activity', 'icon-task'
- ),
- 'create.subprocess-expanded': createAction(
- 'bpmn:SubProcess', 'activity', 'icon-subprocess-expanded', 'Create expanded SubProcess',
- { isExpanded: true }
- ),
- 'create.participant-expanded': {
- group: 'collaboration',
- className: 'icon-participant',
- title: 'Create Pool/Participant',
- action: {
- dragstart: createParticipant,
- click: createParticipant
- }
- }
- });
- return actions;
- };
- },{"339":339}],36:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(145),
- _dereq_(104),
- _dereq_(166),
- _dereq_(114)
- ],
- __init__: [ 'paletteProvider' ],
- paletteProvider: [ 'type', _dereq_(35) ]
- };
- },{"104":104,"114":114,"145":145,"166":166,"35":35}],37:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- filter = _dereq_(216),
- pick = _dereq_(345),
- assign = _dereq_(339);
- var REPLACE_OPTIONS = _dereq_(38);
- var startEventReplace = REPLACE_OPTIONS.START_EVENT,
- intermediateEventReplace = REPLACE_OPTIONS.INTERMEDIATE_EVENT,
- endEventReplace = REPLACE_OPTIONS.END_EVENT,
- gatewayReplace = REPLACE_OPTIONS.GATEWAY,
- taskReplace = REPLACE_OPTIONS.TASK,
- subProcessExpandedReplace = REPLACE_OPTIONS.SUBPROCESS_EXPANDED,
- transactionReplace = REPLACE_OPTIONS.TRANSACTION,
- boundaryEventReplace = REPLACE_OPTIONS.BOUNDARY_EVENT;
- var is = _dereq_(50).is,
- getBusinessObject = _dereq_(50).getBusinessObject,
- isExpanded = _dereq_(48).isExpanded;
- var CUSTOM_PROPERTIES = [
- 'cancelActivity',
- 'instantiate',
- 'eventGatewayType'
- ];
- /**
- * A replace menu provider that gives users the controls to choose
- * and replace BPMN elements with each other.
- *
- * @param {BpmnFactory} bpmnFactory
- * @param {Moddle} moddle
- * @param {PopupMenu} popupMenu
- * @param {Replace} replace
- */
- function BpmnReplace(bpmnFactory, moddle, popupMenu, replace, selection, modeling, eventBus) {
- var self = this,
- currentElement;
- /**
- * Prepares a new business object for the replacement element
- * and triggers the replace operation.
- *
- * @param {djs.model.Base} element
- * @param {Object} target
- * @return {djs.model.Base} the newly created element
- */
- function replaceElement(element, target) {
- var type = target.type,
- oldBusinessObject = element.businessObject,
- businessObject = bpmnFactory.create(type);
- var newElement = {
- type: type,
- businessObject: businessObject
- };
- // initialize custom BPMN extensions
- if (target.eventDefinition) {
- var eventDefinitions = businessObject.get('eventDefinitions'),
- eventDefinition = moddle.create(target.eventDefinition);
- eventDefinitions.push(eventDefinition);
- }
- // initialize special properties defined in target definition
- assign(businessObject, pick(target, CUSTOM_PROPERTIES));
- // copy size (for activities only)
- if (is(oldBusinessObject, 'bpmn:Activity')) {
- // TODO: need also to respect min/max Size
- newElement.width = element.width;
- newElement.height = element.height;
- }
- if (is(oldBusinessObject, 'bpmn:SubProcess')) {
- newElement.isExpanded = isExpanded(oldBusinessObject);
- }
- // TODO: copy other elligable properties from old business object
- businessObject.name = oldBusinessObject.name;
- businessObject.loopCharacteristics = oldBusinessObject.loopCharacteristics;
- newElement = replace.replaceElement(element, newElement);
- selection.select(newElement);
- return newElement;
- }
- function toggleLoopEntry(event, entry) {
- var loopEntries = self.getLoopEntries(currentElement);
- var loopCharacteristics;
- if (entry.active) {
- loopCharacteristics = undefined;
- } else {
- forEach(loopEntries, function(action) {
- var options = action.options;
- if (entry.id === action.id) {
- loopCharacteristics = moddle.create(options.loopCharacteristics);
- if (options.isSequential) {
- loopCharacteristics.isSequential = options.isSequential;
- }
- }
- });
- }
- modeling.updateProperties(currentElement, { loopCharacteristics: loopCharacteristics });
- }
- function getLoopEntries(element) {
- currentElement = element;
- var businessObject = getBusinessObject(element),
- loopCharacteristics = businessObject.loopCharacteristics;
- var isSequential,
- isLoop,
- isParallel;
- if (loopCharacteristics) {
- isSequential = loopCharacteristics.isSequential;
- isLoop = loopCharacteristics.isSequential === undefined;
- isParallel = loopCharacteristics.isSequential !== undefined && !loopCharacteristics.isSequential;
- }
- var loopEntries = [
- {
- id: 'toggle-parallel-mi',
- className: 'icon-parallel-mi-marker',
- active: isParallel,
- action: toggleLoopEntry,
- options: {
- loopCharacteristics: 'bpmn:MultiInstanceLoopCharacteristics',
- isSequential: false
- }
- },
- {
- id: 'toggle-sequential-mi',
- className: 'icon-sequential-mi-marker',
- active: isSequential,
- action: toggleLoopEntry,
- options: {
- loopCharacteristics: 'bpmn:MultiInstanceLoopCharacteristics',
- isSequential: true
- }
- },
- {
- id: 'toggle-loop',
- className: 'icon-loop-marker',
- active: isLoop,
- action: toggleLoopEntry,
- options: {
- loopCharacteristics: 'bpmn:StandardLoopCharacteristics'
- }
- }
- ];
- return loopEntries;
- }
- function getAdHocEntry(element) {
- var businessObject = getBusinessObject(element);
- var isAdHoc = is(businessObject, 'bpmn:AdHocSubProcess');
- var adHocEntry = {
- id: 'toggle-adhoc',
- className: 'icon-ad-hoc-marker',
- active: isAdHoc,
- action: function(event, entry) {
- if (isAdHoc) {
- return replaceElement(element, { type: 'bpmn:SubProcess' });
- } else {
- return replaceElement(element, { type: 'bpmn:AdHocSubProcess' });
- }
- }
- };
- return adHocEntry;
- }
- function getReplaceOptions(element) {
- var menuEntries = [];
- var businessObject = element.businessObject;
- if (is(businessObject, 'bpmn:StartEvent')) {
- addEntries(startEventReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:IntermediateCatchEvent') ||
- is(businessObject, 'bpmn:IntermediateThrowEvent')) {
- addEntries(intermediateEventReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:EndEvent')) {
- addEntries(endEventReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:Gateway')) {
- addEntries(gatewayReplace, function(entry) {
- return entry.target.type !== businessObject.$type;
- });
- } else
- if (is(businessObject, 'bpmn:Transaction')) {
- addEntries(transactionReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:SubProcess') && isExpanded(businessObject)) {
- addEntries(subProcessExpandedReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:AdHocSubProcess') && !isExpanded(businessObject)) {
- addEntries(taskReplace, function(entry) {
- return entry.target.type !== 'bpmn:SubProcess';
- });
- } else
- if (is(businessObject, 'bpmn:BoundaryEvent')) {
- addEntries(boundaryEventReplace, filterEvents);
- } else
- if (is(businessObject, 'bpmn:FlowNode')) {
- addEntries(taskReplace, function(entry) {
- return entry.target.type !== businessObject.$type;
- });
- }
- function filterEvents(entry) {
- var target = entry.target;
- var eventDefinition = businessObject.eventDefinitions && businessObject.eventDefinitions[0].$type,
- cancelActivity;
- if (businessObject.$type === 'bpmn:BoundaryEvent') {
- cancelActivity = target.cancelActivity !== false;
- }
- var isEventDefinitionEqual = target.eventDefinition == eventDefinition,
- isEventTypeEqual = businessObject.$type == target.type,
- isInterruptingEqual = businessObject.cancelActivity == cancelActivity;
- return ((!isEventDefinitionEqual && isEventTypeEqual) ||
- !isEventTypeEqual) ||
- !(isEventDefinitionEqual && isEventTypeEqual && isInterruptingEqual);
- }
- function addEntries(entries, filterFun) {
- // Filter selected type from the array
- var filteredEntries = filter(entries, filterFun);
- // Add entries to replace menu
- forEach(filteredEntries, function(definition) {
- var entry = addMenuEntry(definition);
- menuEntries.push(entry);
- });
- }
- function addMenuEntry(definition) {
- return {
- label: definition.label,
- className: definition.className,
- id: definition.actionName,
- action: function() {
- return replaceElement(element, definition.target);
- }
- };
- }
- return menuEntries;
- }
- /**
- * [function description]
- * @param {Object} position
- * @param {Object} element
- */
- this.openChooser = function(position, element) {
- var entries = this.getReplaceOptions(element),
- headerEntries = [];
- if (is(element, 'bpmn:Activity')) {
- headerEntries = headerEntries.concat(this.getLoopEntries(element));
- }
- if (is(element, 'bpmn:SubProcess') && !is(element, 'bpmn:Transaction')) {
- headerEntries.push(this.getAdHocEntry(element));
- }
- popupMenu.open({
- className: 'replace-menu',
- element: element,
- position: position,
- headerEntries: headerEntries,
- entries: entries
- });
- };
- this.getReplaceOptions = getReplaceOptions;
- this.getLoopEntries = getLoopEntries;
- this.getAdHocEntry = getAdHocEntry;
- this.replaceElement = replaceElement;
- }
- BpmnReplace.$inject = [ 'bpmnFactory', 'moddle', 'popupMenu', 'replace', 'selection', 'modeling', 'eventBus' ];
- module.exports = BpmnReplace;
- },{"216":216,"218":218,"339":339,"345":345,"38":38,"48":48,"50":50}],38:[function(_dereq_,module,exports){
- 'use strict';
- module.exports.START_EVENT = [
- {
- label: 'Start Event',
- actionName: 'replace-with-none-start',
- className: 'icon-start-event-none',
- target: {
- type: 'bpmn:StartEvent'
- }
- },
- {
- label: 'Intermediate Throw Event',
- actionName: 'replace-with-none-intermediate-throwing',
- className: 'icon-intermediate-event-none',
- target: {
- type: 'bpmn:IntermediateThrowEvent'
- }
- },
- {
- label: 'End Event',
- actionName: 'replace-with-none-end',
- className: 'icon-end-event-none',
- target: {
- type: 'bpmn:EndEvent'
- }
- },
- {
- label: 'Message Start Event',
- actionName: 'replace-with-message-start',
- className: 'icon-start-event-message',
- target: {
- type: 'bpmn:StartEvent',
- eventDefinition: 'bpmn:MessageEventDefinition'
- }
- },
- {
- label: 'Timer Start Event',
- actionName: 'replace-with-timer-start',
- className: 'icon-start-event-timer',
- target: {
- type: 'bpmn:StartEvent',
- eventDefinition: 'bpmn:TimerEventDefinition'
- }
- },
- {
- label: 'Conditional Start Event',
- actionName: 'replace-with-conditional-start',
- className: 'icon-start-event-condition',
- target: {
- type: 'bpmn:StartEvent',
- eventDefinition: 'bpmn:ConditionalEventDefinition'
- }
- },
- {
- label: 'Signal Start Event',
- actionName: 'replace-with-signal-start',
- className: 'icon-start-event-signal',
- target: {
- type: 'bpmn:StartEvent',
- eventDefinition: 'bpmn:SignalEventDefinition'
- }
- }
- ];
- module.exports.INTERMEDIATE_EVENT = [
- {
- label: 'Start Event',
- actionName: 'replace-with-none-start',
- className: 'icon-start-event-none',
- target: {
- type: 'bpmn:StartEvent'
- }
- },
- {
- label: 'Intermediate Throw Event',
- actionName: 'replace-with-none-intermediate-throw',
- className: 'icon-intermediate-event-none',
- target: {
- type: 'bpmn:IntermediateThrowEvent'
- }
- },
- {
- label: 'End Event',
- actionName: 'replace-with-none-end',
- className: 'icon-end-event-none',
- target: {
- type: 'bpmn:EndEvent'
- }
- },
- {
- label: 'Message Intermediate Catch Event',
- actionName: 'replace-with-message-intermediate-catch',
- className: 'icon-intermediate-event-catch-message',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:MessageEventDefinition'
- }
- },
- {
- label: 'Message Intermediate Throw Event',
- actionName: 'replace-with-message-intermediate-throw',
- className: 'icon-intermediate-event-throw-message',
- target: {
- type: 'bpmn:IntermediateThrowEvent',
- eventDefinition: 'bpmn:MessageEventDefinition'
- }
- },
- {
- label: 'Timer Intermediate Catch Event',
- actionName: 'replace-with-timer-intermediate-catch',
- className: 'icon-intermediate-event-catch-timer',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:TimerEventDefinition'
- }
- },
- {
- label: 'Escalation Intermediate Catch Event',
- actionName: 'replace-with-escalation-intermediate-catch',
- className: 'icon-intermediate-event-catch-escalation',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:EscalationEventDefinition'
- }
- },
- {
- label: 'Conditional Intermediate Catch Event',
- actionName: 'replace-with-conditional-intermediate-catch',
- className: 'icon-intermediate-event-catch-condition',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:ConditionalEventDefinition'
- }
- },
- {
- label: 'Link Intermediate Catch Event',
- actionName: 'replace-with-link-intermediate-catch',
- className: 'icon-intermediate-event-catch-link',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:LinkEventDefinition'
- }
- },
- {
- label: 'Link Intermediate Throw Event',
- actionName: 'replace-with-link-intermediate-throw',
- className: 'icon-intermediate-event-throw-link',
- target: {
- type: 'bpmn:IntermediateThrowEvent',
- eventDefinition: 'bpmn:LinkEventDefinition'
- }
- },
- {
- label: 'Compensation Intermediate Throw Event',
- actionName: 'replace-with-compensation-intermediate-throw',
- className: 'icon-intermediate-event-throw-compensation',
- target: {
- type: 'bpmn:IntermediateThrowEvent',
- eventDefinition: 'bpmn:CompensateEventDefinition'
- }
- },
- {
- label: 'Signal Intermediate Catch Event',
- actionName: 'replace-with-signal-intermediate-catch',
- className: 'icon-intermediate-event-catch-signal',
- target: {
- type: 'bpmn:IntermediateCatchEvent',
- eventDefinition: 'bpmn:SignalEventDefinition'
- }
- },
- {
- label: 'Signal Intermediate Throw Event',
- actionName: 'replace-with-signal-intermediate-throw',
- className: 'icon-intermediate-event-throw-signal',
- target: {
- type: 'bpmn:IntermediateThrowEvent',
- eventDefinition: 'bpmn:SignalEventDefinition'
- }
- }
- ];
- module.exports.END_EVENT = [
- {
- label: 'Start Event',
- actionName: 'replace-with-none-start',
- className: 'icon-start-event-none',
- target: {
- type: 'bpmn:StartEvent'
- }
- },
- {
- label: 'Intermediate Throw Event',
- actionName: 'replace-with-none-intermediate-throw',
- className: 'icon-intermediate-event-none',
- target: {
- type: 'bpmn:IntermediateThrowEvent'
- }
- },
- {
- label: 'End Event',
- actionName: 'replace-with-none-end',
- className: 'icon-end-event-none',
- target: {
- type: 'bpmn:EndEvent'
- }
- },
- {
- label: 'Message End Event',
- actionName: 'replace-with-message-end',
- className: 'icon-end-event-message',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:MessageEventDefinition'
- }
- },
- {
- label: 'Escalation End Event',
- actionName: 'replace-with-escalation-end',
- className: 'icon-end-event-escalation',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:EscalationEventDefinition'
- }
- },
- {
- label: 'Error End Event',
- actionName: 'replace-with-error-end',
- className: 'icon-end-event-error',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:ErrorEventDefinition'
- }
- },
- {
- label: 'Cancel End Event',
- actionName: 'replace-with-cancel-end',
- className: 'icon-end-event-cancel',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:CancelEventDefinition'
- }
- },
- {
- label: 'Compensation End Event',
- actionName: 'replace-with-compensation-end',
- className: 'icon-end-event-compensation',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:CompensateEventDefinition'
- }
- },
- {
- label: 'Signal End Event',
- actionName: 'replace-with-signal-end',
- className: 'icon-end-event-signal',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:SignalEventDefinition'
- }
- },
- {
- label: 'Terminate End Event',
- actionName: 'replace-with-terminate-end',
- className: 'icon-end-event-terminate',
- target: {
- type: 'bpmn:EndEvent',
- eventDefinition: 'bpmn:TerminateEventDefinition'
- }
- }
- ];
- module.exports.GATEWAY = [
- {
- label: 'Exclusive Gateway',
- actionName: 'replace-with-exclusive-gateway',
- className: 'icon-gateway-xor',
- target: {
- type: 'bpmn:ExclusiveGateway'
- }
- },
- {
- label: 'Parallel Gateway',
- actionName: 'replace-with-parallel-gateway',
- className: 'icon-gateway-parallel',
- target: {
- type: 'bpmn:ParallelGateway'
- }
- },
- {
- label: 'Inclusive Gateway',
- actionName: 'replace-with-inclusive-gateway',
- className: 'icon-gateway-or',
- target: {
- type: 'bpmn:InclusiveGateway'
- }
- },
- {
- label: 'Complex Gateway',
- actionName: 'replace-with-complex-gateway',
- className: 'icon-gateway-complex',
- target: {
- type: 'bpmn:ComplexGateway'
- }
- },
- {
- label: 'Event based Gateway',
- actionName: 'replace-with-event-based-gateway',
- className: 'icon-gateway-eventbased',
- target: {
- type: 'bpmn:EventBasedGateway',
- instantiate: false,
- eventGatewayType: 'Exclusive'
- }
- }
- // Gateways deactivated until https://github.com/bpmn-io/bpmn-js/issues/194
- // {
- // label: 'Event based instantiating Gateway',
- // actionName: 'replace-with-exclusive-event-based-gateway',
- // className: 'icon-exclusive-event-based',
- // target: {
- // type: 'bpmn:EventBasedGateway'
- // },
- // options: {
- // businessObject: { instantiate: true, eventGatewayType: 'Exclusive' }
- // }
- // },
- // {
- // label: 'Parallel Event based instantiating Gateway',
- // actionName: 'replace-with-parallel-event-based-instantiate-gateway',
- // className: 'icon-parallel-event-based-instantiate-gateway',
- // target: {
- // type: 'bpmn:EventBasedGateway'
- // },
- // options: {
- // businessObject: { instantiate: true, eventGatewayType: 'Parallel' }
- // }
- // }
- ];
- module.exports.SUBPROCESS_EXPANDED = [
- {
- label: 'Transaction',
- actionName: 'replace-with-transaction',
- className: 'icon-transaction',
- target: {
- type: 'bpmn:Transaction',
- isExpanded: true
- }
- }
- ];
- module.exports.TRANSACTION = [
- {
- label: 'Sub Process',
- actionName: 'replace-with-subprocess',
- className: 'icon-subprocess-expanded',
- target: {
- type: 'bpmn:SubProcess'
- }
- }
- ];
- module.exports.TASK = [
- {
- label: 'Task',
- actionName: 'replace-with-task',
- className: 'icon-task',
- target: {
- type: 'bpmn:Task'
- }
- },
- {
- label: 'Send Task',
- actionName: 'replace-with-send-task',
- className: 'icon-send',
- target: {
- type: 'bpmn:SendTask'
- }
- },
- {
- label: 'Receive Task',
- actionName: 'replace-with-receive-task',
- className: 'icon-receive',
- target: {
- type: 'bpmn:ReceiveTask'
- }
- },
- {
- label: 'User Task',
- actionName: 'replace-with-user-task',
- className: 'icon-user',
- target: {
- type: 'bpmn:UserTask'
- }
- },
- {
- label: 'Manual Task',
- actionName: 'replace-with-manual-task',
- className: 'icon-manual',
- target: {
- type: 'bpmn:ManualTask'
- }
- },
- {
- label: 'Business Rule Task',
- actionName: 'replace-with-rule-task',
- className: 'icon-business-rule',
- target: {
- type: 'bpmn:BusinessRuleTask'
- }
- },
- {
- label: 'Service Task',
- actionName: 'replace-with-service-task',
- className: 'icon-service',
- target: {
- type: 'bpmn:ServiceTask'
- }
- },
- {
- label: 'Script Task',
- actionName: 'replace-with-script-task',
- className: 'icon-script',
- target: {
- type: 'bpmn:ScriptTask'
- }
- },
- {
- label: 'Call Activity',
- actionName: 'replace-with-call-activity',
- className: 'icon-call-activity',
- target: {
- type: 'bpmn:CallActivity'
- }
- },
- {
- label: 'Sub Process (collapsed)',
- actionName: 'replace-with-collapsed-subprocess',
- className: 'icon-subprocess-collapsed',
- target: {
- type: 'bpmn:SubProcess',
- isExpanded: false
- }
- }
- ];
- module.exports.BOUNDARY_EVENT = [
- {
- label: 'Message Boundary Event',
- actionName: 'replace-with-message-boundary',
- className: 'icon-intermediate-event-catch-message',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:MessageEventDefinition'
- }
- },
- {
- label: 'Timer Boundary Event',
- actionName: 'replace-with-timer-boundary',
- className: 'icon-intermediate-event-catch-timer',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:TimerEventDefinition'
- }
- },
- {
- label: 'Escalation Boundary Event',
- actionName: 'replace-with-escalation-boundary',
- className: 'icon-intermediate-event-catch-escalation',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:EscalationEventDefinition'
- }
- },
- {
- label: 'Conditional Boundary Event',
- actionName: 'replace-with-conditional-boundary',
- className: 'icon-intermediate-event-catch-condition',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:ConditionalEventDefinition'
- }
- },
- {
- label: 'Error Boundary Event',
- actionName: 'replace-with-error-boundary',
- className: 'icon-intermediate-event-catch-error',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:ErrorEventDefinition'
- }
- },
- {
- label: 'Signal Boundary Event',
- actionName: 'replace-with-signal-boundary',
- className: 'icon-intermediate-event-catch-signal',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:SignalEventDefinition'
- }
- },
- {
- label: 'Message Boundary Event (non-interrupting)',
- actionName: 'replace-with-non-interrupting-message-boundary',
- className: 'icon-intermediate-event-catch-non-interrupting-message',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:MessageEventDefinition',
- cancelActivity: false
- }
- },
- {
- label: 'Timer Boundary Event (non-interrupting)',
- actionName: 'replace-with-non-interrupting-timer-boundary',
- className: 'icon-intermediate-event-catch-non-interrupting-timer',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:TimerEventDefinition',
- cancelActivity: false
- }
- },
- {
- label: 'Escalation Boundary Event (non-interrupting)',
- actionName: 'replace-with-non-interrupting-escalation-boundary',
- className: 'icon-intermediate-event-catch-non-interrupting-escalation',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:EscalationEventDefinition',
- cancelActivity: false
- }
- },
- {
- label: 'Conditional Boundary Event (non-interrupting)',
- actionName: 'replace-with-non-interrupting-conditional-boundary',
- className: 'icon-intermediate-event-catch-non-interrupting-condition',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:ConditionalEventDefinition',
- cancelActivity: false
- }
- },
- {
- label: 'Signal Boundary Event (non-interrupting)',
- actionName: 'replace-with-non-interrupting-signal-boundary',
- className: 'icon-intermediate-event-catch-non-interrupting-signal',
- target: {
- type: 'bpmn:BoundaryEvent',
- eventDefinition: 'bpmn:SignalEventDefinition',
- cancelActivity: false
- }
- },
- ];
- },{}],39:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(147),
- _dereq_(149),
- _dereq_(159)
- ],
- bpmnReplace: [ 'type', _dereq_(37) ]
- };
- },{"147":147,"149":149,"159":159,"37":37}],40:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var forEach = _dereq_(218);
- var getBoundingBox = _dereq_(186).getBBox;
- var is = _dereq_(21).is,
- isExpanded = _dereq_(48).isExpanded;
- var Snapping = _dereq_(162),
- SnapUtil = _dereq_(161);
- var is = _dereq_(50).is;
- var round = Math.round;
- var mid = SnapUtil.mid,
- topLeft = SnapUtil.topLeft,
- bottomRight = SnapUtil.bottomRight,
- isSnapped = SnapUtil.isSnapped,
- setSnapped = SnapUtil.setSnapped,
- getBoundaryAttachment = _dereq_(41).getBoundaryAttachment;
- /**
- * BPMN specific snapping functionality
- *
- * * snap on process elements if a pool is created inside a
- * process diagram
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- */
- function BpmnSnapping(eventBus, canvas, bpmnRules) {
- // instantiate super
- Snapping.call(this, eventBus, canvas);
- /**
- * Drop participant on process <> process elements snapping
- */
- eventBus.on('create.start', function(event) {
- var context = event.context,
- shape = context.shape,
- rootElement = canvas.getRootElement();
- // snap participant around existing elements (if any)
- if (is(shape, 'bpmn:Participant') && is(rootElement, 'bpmn:Process')) {
- initParticipantSnapping(context, shape, rootElement.children);
- }
- });
- eventBus.on([ 'create.move', 'create.end' ], 1500, function(event) {
- var context = event.context,
- shape = context.shape,
- participantSnapBox = context.participantSnapBox;
- if (!isSnapped(event) && participantSnapBox) {
- snapParticipant(participantSnapBox, shape, event);
- }
- });
- eventBus.on('shape.move.start', function(event) {
- var context = event.context,
- shape = context.shape,
- rootElement = canvas.getRootElement();
- // snap participant around existing elements (if any)
- if (is(shape, 'bpmn:Participant') && is(rootElement, 'bpmn:Process')) {
- initParticipantSnapping(context, shape, rootElement.children);
- }
- });
- function canAttach(shape, target, position) {
- return bpmnRules.canAttach([ shape ], target, null, position) === 'attach';
- }
- /**
- * Snap boundary events to elements border
- */
- eventBus.on([ 'create.move', 'create.end' ], 1500, function(event) {
- var context = event.context,
- target = context.target,
- shape = context.shape;
- if (target && !isSnapped(event) && canAttach(shape, target, event)) {
- snapBoundaryEvent(event, shape, target);
- }
- });
- eventBus.on([ 'shape.move.move', 'shape.move.end' ], 1500, function(event) {
- var context = event.context,
- target = context.target,
- shape = context.shape;
- if (target && !isSnapped(event) && canAttach(shape, target, event)) {
- snapBoundaryEvent(event, shape, target);
- }
- });
- eventBus.on('resize.start', 1500, function(event) {
- var context = event.context,
- shape = context.shape;
- if (is(shape, 'bpmn:SubProcess') && isExpanded(shape)) {
- context.minDimensions = { width: 140, height: 120 };
- }
- if (is(shape, 'bpmn:Participant')) {
- context.minDimensions = { width: 300, height: 150 };
- context.childrenBoxPadding = {
- left: 50,
- right: 35
- };
- }
- if (is(shape, 'bpmn:TextAnnotation')) {
- context.minDimensions = { width: 50, height: 50 };
- }
- });
- }
- inherits(BpmnSnapping, Snapping);
- BpmnSnapping.$inject = [ 'eventBus', 'canvas', 'bpmnRules' ];
- module.exports = BpmnSnapping;
- BpmnSnapping.prototype.initSnap = function(event) {
- var context = event.context,
- shape = event.shape,
- shapeMid,
- shapeBounds,
- shapeTopLeft,
- shapeBottomRight,
- snapContext;
- snapContext = Snapping.prototype.initSnap.call(this, event);
- if (is(shape, 'bpmn:Participant')) {
- // assign higher priority for outer snaps on participants
- snapContext.setSnapLocations([ 'top-left', 'bottom-right', 'mid' ]);
- }
- if (shape) {
- shapeMid = mid(shape, event);
- shapeBounds = {
- width: shape.width,
- height: shape.height,
- x: isNaN(shape.x) ? round(shapeMid.x - shape.width / 2) : shape.x,
- y: isNaN(shape.y) ? round(shapeMid.y - shape.height / 2) : shape.y,
- };
- shapeTopLeft = topLeft(shapeBounds);
- shapeBottomRight = bottomRight(shapeBounds);
- snapContext.setSnapOrigin('top-left', {
- x: shapeTopLeft.x - event.x,
- y: shapeTopLeft.y - event.y
- });
- snapContext.setSnapOrigin('bottom-right', {
- x: shapeBottomRight.x - event.x,
- y: shapeBottomRight.y - event.y
- });
- forEach(shape.outgoing, function(c) {
- var docking = c.waypoints[0];
- docking = docking.original || docking;
- snapContext.setSnapOrigin(c.id + '-docking', {
- x: docking.x - event.x,
- y: docking.y - event.y
- });
- });
- forEach(shape.incoming, function(c) {
- var docking = c.waypoints[c.waypoints.length - 1];
- docking = docking.original || docking;
- snapContext.setSnapOrigin(c.id + '-docking', {
- x: docking.x - event.x,
- y: docking.y - event.y
- });
- });
- }
- var source = context.source;
- if (source) {
- snapContext.addDefaultSnap('mid', mid(source));
- }
- };
- BpmnSnapping.prototype.addTargetSnaps = function(snapPoints, shape, target) {
- // use target parent as snap target
- if (is(shape, 'bpmn:BoundaryEvent')) {
- target = target.parent;
- }
- // add sequence flow parents as snap targets
- if (is(target, 'bpmn:SequenceFlow')) {
- this.addTargetSnaps(snapPoints, shape, target.parent);
- }
- var siblings = this.getSiblings(shape, target) || [];
- forEach(siblings, function(s) {
- snapPoints.add('mid', mid(s));
- if (is(s, 'bpmn:Participant')) {
- snapPoints.add('top-left', topLeft(s));
- snapPoints.add('bottom-right', bottomRight(s));
- }
- });
- forEach(shape.incoming, function(c) {
- if (siblings.indexOf(c.source) === -1) {
- snapPoints.add('mid', mid(c.source));
- }
- var docking = c.waypoints[0];
- snapPoints.add(c.id + '-docking', docking.original || docking);
- });
- forEach(shape.outgoing, function(c) {
- if (siblings.indexOf(c.target) === -1) {
- snapPoints.add('mid', mid(c.target));
- }
- var docking = c.waypoints[c.waypoints.length - 1];
- snapPoints.add(c.id + '-docking', docking.original || docking);
- });
- };
- /////// participant snapping //////////////////
- function initParticipantSnapping(context, shape, elements) {
- if (!elements.length) {
- return;
- }
- var snapBox = getBoundingBox(elements.filter(function(e) {
- return !e.labelTarget && !e.waypoints;
- }));
- snapBox.x -= 50;
- snapBox.y -= 20;
- snapBox.width += 70;
- snapBox.height += 40;
- // adjust shape height to include bounding box
- shape.width = Math.max(shape.width, snapBox.width);
- shape.height = Math.max(shape.height, snapBox.height);
- context.participantSnapBox = snapBox;
- }
- function snapParticipant(snapBox, shape, event, offset) {
- offset = offset || 0;
- var shapeHalfWidth = shape.width / 2 - offset,
- shapeHalfHeight = shape.height / 2;
- var currentTopLeft = {
- x: event.x - shapeHalfWidth - offset,
- y: event.y - shapeHalfHeight
- };
- var currentBottomRight = {
- x: event.x + shapeHalfWidth + offset,
- y: event.y + shapeHalfHeight
- };
- var snapTopLeft = snapBox,
- snapBottomRight = bottomRight(snapBox);
- if (currentTopLeft.x >= snapTopLeft.x) {
- setSnapped(event, 'x', snapTopLeft.x + offset + shapeHalfWidth);
- } else
- if (currentBottomRight.x <= snapBottomRight.x) {
- setSnapped(event, 'x', snapBottomRight.x - offset - shapeHalfWidth);
- }
- if (currentTopLeft.y >= snapTopLeft.y) {
- setSnapped(event, 'y', snapTopLeft.y + shapeHalfHeight);
- } else
- if (currentBottomRight.y <= snapBottomRight.y) {
- setSnapped(event, 'y', snapBottomRight.y - shapeHalfHeight);
- }
- }
- /////// boundary event snapping /////////////////////////
- var LayoutUtil = _dereq_(174);
- function snapBoundaryEvent(event, shape, target) {
- var targetTRBL = LayoutUtil.asTRBL(target);
- var direction = getBoundaryAttachment(event, target);
- if (/top/.test(direction)) {
- setSnapped(event, 'y', targetTRBL.top);
- } else
- if (/bottom/.test(direction)) {
- setSnapped(event, 'y', targetTRBL.bottom);
- }
- if (/left/.test(direction)) {
- setSnapped(event, 'x', targetTRBL.left);
- } else
- if (/right/.test(direction)) {
- setSnapped(event, 'x', targetTRBL.right);
- }
- }
- },{"161":161,"162":162,"174":174,"186":186,"207":207,"21":21,"218":218,"41":41,"48":48,"50":50}],41:[function(_dereq_,module,exports){
- 'use strict';
- var getOrientation = _dereq_(174).getOrientation;
- module.exports.getBoundaryAttachment = function(position, targetBounds) {
- var orientation = getOrientation(position, targetBounds, -15);
- if (orientation !== 'intersect') {
- return orientation;
- } else {
- return null;
- }
- };
- },{"174":174}],42:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'snapping' ],
- snapping: [ 'type', _dereq_(40) ]
- };
- },{"40":40}],43:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- map = _dereq_(221);
- var LabelUtil = _dereq_(49);
- var is = _dereq_(50).is;
- var hasExternalLabel = LabelUtil.hasExternalLabel,
- getExternalLabelBounds = LabelUtil.getExternalLabelBounds,
- isExpanded = _dereq_(48).isExpanded,
- elementToString = _dereq_(46).elementToString;
- function elementData(semantic, attrs) {
- return assign({
- id: semantic.id,
- type: semantic.$type,
- businessObject: semantic
- }, attrs);
- }
- function collectWaypoints(waypoints) {
- return map(waypoints, function(p) {
- return { x: p.x, y: p.y };
- });
- }
- function notYetDrawn(semantic, refSemantic, property) {
- return new Error(
- 'element ' + elementToString(refSemantic) + ' referenced by ' +
- elementToString(semantic) + '#' + property + ' not yet drawn');
- }
- /**
- * An importer that adds bpmn elements to the canvas
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- * @param {ElementFactory} elementFactory
- * @param {ElementRegistry} elementRegistry
- */
- function BpmnImporter(eventBus, canvas, elementFactory, elementRegistry) {
- this._eventBus = eventBus;
- this._canvas = canvas;
- this._elementFactory = elementFactory;
- this._elementRegistry = elementRegistry;
- }
- BpmnImporter.$inject = [ 'eventBus', 'canvas', 'elementFactory', 'elementRegistry' ];
- module.exports = BpmnImporter;
- /**
- * Add bpmn element (semantic) to the canvas onto the
- * specified parent shape.
- */
- BpmnImporter.prototype.add = function(semantic, parentElement) {
- var di = semantic.di,
- element;
- // ROOT ELEMENT
- // handle the special case that we deal with a
- // invisible root element (process or collaboration)
- if (di.$instanceOf('bpmndi:BPMNPlane')) {
- // add a virtual element (not being drawn)
- element = this._elementFactory.createRoot(elementData(semantic));
- this._canvas.setRootElement(element);
- }
- // SHAPE
- else if (di.$instanceOf('bpmndi:BPMNShape')) {
- var collapsed = !isExpanded(semantic);
- var hidden = parentElement && (parentElement.hidden || parentElement.collapsed);
- var bounds = semantic.di.bounds;
- element = this._elementFactory.createShape(elementData(semantic, {
- collapsed: collapsed,
- hidden: hidden,
- x: Math.round(bounds.x),
- y: Math.round(bounds.y),
- width: Math.round(bounds.width),
- height: Math.round(bounds.height)
- }));
- if (is(semantic, 'bpmn:BoundaryEvent')) {
- this._attachBoundary(semantic, element);
- }
- this._canvas.addShape(element, parentElement);
- }
- // CONNECTION
- else if (di.$instanceOf('bpmndi:BPMNEdge')) {
- var source = this._getSource(semantic),
- target = this._getTarget(semantic);
- element = this._elementFactory.createConnection(elementData(semantic, {
- source: source,
- target: target,
- waypoints: collectWaypoints(semantic.di.waypoint)
- }));
- this._canvas.addConnection(element, parentElement);
- } else {
- throw new Error('unknown di ' + elementToString(di) + ' for element ' + elementToString(semantic));
- }
- // (optional) LABEL
- if (hasExternalLabel(semantic)) {
- this.addLabel(semantic, element);
- }
- this._eventBus.fire('bpmnElement.added', { element: element });
- return element;
- };
- /**
- * Attach the boundary element to the given host
- *
- * @param {ModdleElement} boundarySemantic
- * @param {djs.model.Base} boundaryElement
- */
- BpmnImporter.prototype._attachBoundary = function(boundarySemantic, boundaryElement) {
- var hostSemantic = boundarySemantic.attachedToRef;
- if (!hostSemantic) {
- throw new Error('missing ' + elementToString(boundarySemantic) + '#attachedToRef');
- }
- var host = this._elementRegistry.get(hostSemantic.id),
- attachers = host && host.attachers;
- if (!host) {
- throw notYetDrawn(boundarySemantic, hostSemantic, 'attachedToRef');
- }
- // wire element.host <> host.attachers
- boundaryElement.host = host;
- if (!attachers) {
- host.attachers = attachers = [];
- }
- if (attachers.indexOf(boundaryElement) === -1) {
- attachers.push(boundaryElement);
- }
- };
- /**
- * add label for an element
- */
- BpmnImporter.prototype.addLabel = function(semantic, element) {
- var bounds = getExternalLabelBounds(semantic, element);
- var label = this._elementFactory.createLabel(elementData(semantic, {
- id: semantic.id + '_label',
- labelTarget: element,
- type: 'label',
- hidden: element.hidden,
- x: Math.round(bounds.x),
- y: Math.round(bounds.y),
- width: Math.round(bounds.width),
- height: Math.round(bounds.height)
- }));
- return this._canvas.addShape(label, element.parent);
- };
- /**
- * Return the drawn connection end based on the given side.
- *
- * @throws {Error} if the end is not yet drawn
- */
- BpmnImporter.prototype._getEnd = function(semantic, side) {
- var element,
- refSemantic,
- type = semantic.$type;
- refSemantic = semantic[side + 'Ref'];
- // handle mysterious isMany DataAssociation#sourceRef
- if (side === 'source' && type === 'bpmn:DataInputAssociation') {
- refSemantic = refSemantic && refSemantic[0];
- }
- // fix source / target for DataInputAssociation / DataOutputAssociation
- if (side === 'source' && type === 'bpmn:DataOutputAssociation' ||
- side === 'target' && type === 'bpmn:DataInputAssociation') {
- refSemantic = semantic.$parent;
- }
- element = refSemantic && this._getElement(refSemantic);
- if (element) {
- return element;
- }
- if (refSemantic) {
- throw notYetDrawn(semantic, refSemantic, side + 'Ref');
- } else {
- throw new Error(elementToString(semantic) + '#' + side + 'Ref not specified');
- }
- };
- BpmnImporter.prototype._getSource = function(semantic) {
- return this._getEnd(semantic, 'source');
- };
- BpmnImporter.prototype._getTarget = function(semantic) {
- return this._getEnd(semantic, 'target');
- };
- BpmnImporter.prototype._getElement = function(semantic) {
- return this._elementRegistry.get(semantic.id);
- };
- },{"221":221,"339":339,"46":46,"48":48,"49":49,"50":50}],44:[function(_dereq_,module,exports){
- 'use strict';
- var filter = _dereq_(216),
- find = _dereq_(217),
- forEach = _dereq_(218);
- var Refs = _dereq_(369);
- var elementToString = _dereq_(46).elementToString;
- var diRefs = new Refs({ name: 'bpmnElement', enumerable: true }, { name: 'di' });
- /**
- * Returns true if an element has the given meta-model type
- *
- * @param {ModdleElement} element
- * @param {String} type
- *
- * @return {Boolean}
- */
- function is(element, type) {
- return element.$instanceOf(type);
- }
- /**
- * Find a suitable display candidate for definitions where the DI does not
- * correctly specify one.
- */
- function findDisplayCandidate(definitions) {
- return find(definitions.rootElements, function(e) {
- return is(e, 'bpmn:Process') || is(e, 'bpmn:Collaboration');
- });
- }
- function BpmnTreeWalker(handler) {
- // list of containers already walked
- var handledProcesses = [];
- // list of elements to handle deferred to ensure
- // prerequisites are drawn
- var deferred = [];
- ///// Helpers /////////////////////////////////
- function contextual(fn, ctx) {
- return function(e) {
- fn(e, ctx);
- };
- }
- function visit(element, ctx) {
- var gfx = element.gfx;
- // avoid multiple rendering of elements
- if (gfx) {
- throw new Error('already rendered ' + elementToString(element));
- }
- // call handler
- return handler.element(element, ctx);
- }
- function visitRoot(element, diagram) {
- return handler.root(element, diagram);
- }
- function visitIfDi(element, ctx) {
- try {
- return element.di && visit(element, ctx);
- } catch (e) {
- logError(e.message, { element: element, error: e });
- console.error('failed to import ' + elementToString(element));
- console.error(e);
- }
- }
- function logError(message, context) {
- handler.error(message, context);
- }
- ////// DI handling ////////////////////////////
- function registerDi(di) {
- var bpmnElement = di.bpmnElement;
- if (bpmnElement) {
- if (bpmnElement.di) {
- logError('multiple DI elements defined for ' + elementToString(bpmnElement), { element: bpmnElement });
- } else {
- diRefs.bind(bpmnElement, 'di');
- bpmnElement.di = di;
- }
- } else {
- logError('no bpmnElement referenced in ' + elementToString(di), { element: di });
- }
- }
- function handleDiagram(diagram) {
- handlePlane(diagram.plane);
- }
- function handlePlane(plane) {
- registerDi(plane);
- forEach(plane.planeElement, handlePlaneElement);
- }
- function handlePlaneElement(planeElement) {
- registerDi(planeElement);
- }
- ////// Semantic handling //////////////////////
- function handleDefinitions(definitions, diagram) {
- // make sure we walk the correct bpmnElement
- var diagrams = definitions.diagrams;
- if (diagram && diagrams.indexOf(diagram) === -1) {
- throw new Error('diagram not part of bpmn:Definitions');
- }
- if (!diagram && diagrams && diagrams.length) {
- diagram = diagrams[0];
- }
- // no diagram -> nothing to import
- if (!diagram) {
- return;
- }
- // load DI from selected diagram only
- handleDiagram(diagram);
- var plane = diagram.plane;
- if (!plane) {
- throw new Error('no plane for ' + elementToString(diagram));
- }
- var rootElement = plane.bpmnElement;
- // ensure we default to a suitable display candidate (process or collaboration),
- // even if non is specified in DI
- if (!rootElement) {
- rootElement = findDisplayCandidate(definitions);
- if (!rootElement) {
- return logError('no process or collaboration present to display');
- } else {
- logError('correcting missing bpmnElement on ' + elementToString(plane) + ' to ' + elementToString(rootElement));
- // correct DI on the fly
- plane.bpmnElement = rootElement;
- registerDi(plane);
- }
- }
- var ctx = visitRoot(rootElement, plane);
- if (is(rootElement, 'bpmn:Process')) {
- handleProcess(rootElement, ctx);
- } else if (is(rootElement, 'bpmn:Collaboration')) {
- handleCollaboration(rootElement, ctx);
- // force drawing of everything not yet drawn that is part of the target DI
- handleUnhandledProcesses(definitions.rootElements, ctx);
- } else {
- throw new Error('unsupported bpmnElement for ' + elementToString(plane) + ' : ' + elementToString(rootElement));
- }
- // handle all deferred elements
- handleDeferred(deferred);
- }
- function handleDeferred(deferred) {
- forEach(deferred, function(d) { d(); });
- }
- function handleProcess(process, context) {
- handleFlowElementsContainer(process, context);
- handleIoSpecification(process.ioSpecification, context);
- handleArtifacts(process.artifacts, context);
- // log process handled
- handledProcesses.push(process);
- }
- function handleUnhandledProcesses(rootElements) {
- // walk through all processes that have not yet been drawn and draw them
- // if they contain lanes with DI information.
- // we do this to pass the free-floating lane test cases in the MIWG test suite
- var processes = filter(rootElements, function(e) {
- return is(e, 'bpmn:Process') && e.laneSets && handledProcesses.indexOf(e) === -1;
- });
- processes.forEach(contextual(handleProcess));
- }
- function handleMessageFlow(messageFlow, context) {
- visitIfDi(messageFlow, context);
- }
- function handleMessageFlows(messageFlows, context) {
- forEach(messageFlows, contextual(handleMessageFlow, context));
- }
- function handleDataAssociation(association, context) {
- visitIfDi(association, context);
- }
- function handleDataInput(dataInput, context) {
- visitIfDi(dataInput, context);
- }
- function handleDataOutput(dataOutput, context) {
- visitIfDi(dataOutput, context);
- }
- function handleArtifact(artifact, context) {
- // bpmn:TextAnnotation
- // bpmn:Group
- // bpmn:Association
- visitIfDi(artifact, context);
- }
- function handleArtifacts(artifacts, context) {
- forEach(artifacts, function(e) {
- if (is(e, 'bpmn:Association')) {
- deferred.push(function() {
- handleArtifact(e, context);
- });
- } else {
- handleArtifact(e, context);
- }
- });
- }
- function handleIoSpecification(ioSpecification, context) {
- if (!ioSpecification) {
- return;
- }
- forEach(ioSpecification.dataInputs, contextual(handleDataInput, context));
- forEach(ioSpecification.dataOutputs, contextual(handleDataOutput, context));
- }
- function handleSubProcess(subProcess, context) {
- handleFlowElementsContainer(subProcess, context);
- handleArtifacts(subProcess.artifacts, context);
- }
- function handleFlowNode(flowNode, context) {
- var childCtx = visitIfDi(flowNode, context);
- if (is(flowNode, 'bpmn:SubProcess')) {
- handleSubProcess(flowNode, childCtx || context);
- }
- }
- function handleSequenceFlow(sequenceFlow, context) {
- visitIfDi(sequenceFlow, context);
- }
- function handleDataElement(dataObject, context) {
- visitIfDi(dataObject, context);
- }
- function handleBoundaryEvent(dataObject, context) {
- visitIfDi(dataObject, context);
- }
- function handleLane(lane, context) {
- var newContext = visitIfDi(lane, context);
- if (lane.childLaneSet) {
- handleLaneSet(lane.childLaneSet, newContext || context);
- } else {
- var filterList = filter(lane.flowNodeRef, function(e) {
- return e.$type !== 'bpmn:BoundaryEvent';
- });
- handleFlowElements(filterList, newContext || context);
- }
- }
- function handleLaneSet(laneSet, context) {
- forEach(laneSet.lanes, contextual(handleLane, context));
- }
- function handleLaneSets(laneSets, context) {
- forEach(laneSets, contextual(handleLaneSet, context));
- }
- function handleFlowElementsContainer(container, context) {
- if (container.laneSets) {
- handleLaneSets(container.laneSets, context);
- handleNonFlowNodes(container.flowElements);
- } else {
- handleFlowElements(container.flowElements, context);
- }
- }
- function handleNonFlowNodes(flowElements, context) {
- forEach(flowElements, function(e) {
- if (is(e, 'bpmn:SequenceFlow')) {
- deferred.push(function() {
- handleSequenceFlow(e, context);
- });
- } else if (is(e, 'bpmn:BoundaryEvent')) {
- deferred.unshift(function() {
- handleBoundaryEvent(e, context);
- });
- } else if (is(e, 'bpmn:DataObject')) {
- // SKIP (assume correct referencing via DataObjectReference)
- } else if (is(e, 'bpmn:DataStoreReference')) {
- handleDataElement(e, context);
- } else if (is(e, 'bpmn:DataObjectReference')) {
- handleDataElement(e, context);
- }
- });
- }
- function handleFlowElements(flowElements, context) {
- forEach(flowElements, function(e) {
- if (is(e, 'bpmn:SequenceFlow')) {
- deferred.push(function() {
- handleSequenceFlow(e, context);
- });
- } else if (is(e, 'bpmn:BoundaryEvent')) {
- deferred.unshift(function() {
- handleBoundaryEvent(e, context);
- });
- } else if (is(e, 'bpmn:FlowNode')) {
- handleFlowNode(e, context);
- if (is(e, 'bpmn:Activity')) {
- handleIoSpecification(e.ioSpecification, context);
- // defer handling of associations
- deferred.push(function() {
- forEach(e.dataInputAssociations, contextual(handleDataAssociation, context));
- forEach(e.dataOutputAssociations, contextual(handleDataAssociation, context));
- });
- }
- } else if (is(e, 'bpmn:DataObject')) {
- // SKIP (assume correct referencing via DataObjectReference)
- } else if (is(e, 'bpmn:DataStoreReference')) {
- handleDataElement(e, context);
- } else if (is(e, 'bpmn:DataObjectReference')) {
- handleDataElement(e, context);
- } else {
- logError(
- 'unrecognized flowElement ' + elementToString(e) + ' in context ' +
- (context ? elementToString(context.businessObject) : null),
- { element: e, context: context });
- }
- });
- }
- function handleParticipant(participant, context) {
- var newCtx = visitIfDi(participant, context);
- var process = participant.processRef;
- if (process) {
- handleProcess(process, newCtx || context);
- }
- }
- function handleCollaboration(collaboration) {
- forEach(collaboration.participants, contextual(handleParticipant));
- handleArtifacts(collaboration.artifacts);
- // handle message flows latest in the process
- deferred.push(function() {
- handleMessageFlows(collaboration.messageFlows);
- });
- }
- ///// API ////////////////////////////////
- return {
- handleDefinitions: handleDefinitions
- };
- }
- module.exports = BpmnTreeWalker;
- },{"216":216,"217":217,"218":218,"369":369,"46":46}],45:[function(_dereq_,module,exports){
- 'use strict';
- var BpmnTreeWalker = _dereq_(44);
- /**
- * Import the definitions into a diagram.
- *
- * Errors and warnings are reported through the specified callback.
- *
- * @param {Diagram} diagram
- * @param {ModdleElement} definitions
- * @param {Function} done the callback, invoked with (err, [ warning ]) once the import is done
- */
- function importBpmnDiagram(diagram, definitions, done) {
- var importer = diagram.get('bpmnImporter'),
- eventBus = diagram.get('eventBus');
- var error,
- warnings = [];
- function parse(definitions) {
- var visitor = {
- root: function(element) {
- return importer.add(element);
- },
- element: function(element, parentShape) {
- return importer.add(element, parentShape);
- },
- error: function(message, context) {
- warnings.push({ message: message, context: context });
- }
- };
- var walker = new BpmnTreeWalker(visitor);
- // import
- walker.handleDefinitions(definitions);
- }
- eventBus.fire('import.start');
- try {
- parse(definitions);
- } catch (e) {
- error = e;
- }
- eventBus.fire(error ? 'import.error' : 'import.success', { error: error, warnings: warnings });
- done(error, warnings);
- }
- module.exports.importBpmnDiagram = importBpmnDiagram;
- },{"44":44}],46:[function(_dereq_,module,exports){
- 'use strict';
- module.exports.elementToString = function(e) {
- if (!e) {
- return '<null>';
- }
- return '<' + e.$type + (e.id ? ' id="' + e.id : '') + '" />';
- };
- },{}],47:[function(_dereq_,module,exports){
- module.exports = {
- bpmnImporter: [ 'type', _dereq_(43) ]
- };
- },{"43":43}],48:[function(_dereq_,module,exports){
- 'use strict';
- var is = _dereq_(50).is,
- getBusinessObject = _dereq_(50).getBusinessObject;
- module.exports.isExpanded = function(element) {
- if (is(element, 'bpmn:CallActivity')) {
- return false;
- }
- if (is(element, 'bpmn:SubProcess')) {
- return getBusinessObject(element).di.isExpanded;
- }
- if (is(element, 'bpmn:Participant')) {
- return !!getBusinessObject(element).processRef;
- }
- return true;
- };
- },{"50":50}],49:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- var DEFAULT_LABEL_SIZE = module.exports.DEFAULT_LABEL_SIZE = {
- width: 90,
- height: 20
- };
- /**
- * Returns true if the given semantic has an external label
- *
- * @param {BpmnElement} semantic
- * @return {Boolean} true if has label
- */
- module.exports.hasExternalLabel = function(semantic) {
- return semantic.$instanceOf('bpmn:Event') ||
- semantic.$instanceOf('bpmn:Gateway') ||
- semantic.$instanceOf('bpmn:DataStoreReference') ||
- semantic.$instanceOf('bpmn:DataObjectReference') ||
- semantic.$instanceOf('bpmn:SequenceFlow') ||
- semantic.$instanceOf('bpmn:MessageFlow');
- };
- /**
- * Get the middle of a number of waypoints
- *
- * @param {Array<Point>} waypoints
- * @return {Point} the mid point
- */
- var getWaypointsMid = module.exports.getWaypointsMid = function(waypoints) {
- var mid = waypoints.length / 2 - 1;
- var first = waypoints[Math.floor(mid)];
- var second = waypoints[Math.ceil(mid + 0.01)];
- return {
- x: first.x + (second.x - first.x) / 2,
- y: first.y + (second.y - first.y) / 2
- };
- };
- var getExternalLabelMid = module.exports.getExternalLabelMid = function(element) {
- if (element.waypoints) {
- return getWaypointsMid(element.waypoints);
- } else {
- return {
- x: element.x + element.width / 2,
- y: element.y + element.height + DEFAULT_LABEL_SIZE.height / 2
- };
- }
- };
- /**
- * Returns the bounds of an elements label, parsed from the elements DI or
- * generated from its bounds.
- *
- * @param {BpmnElement} semantic
- * @param {djs.model.Base} element
- */
- module.exports.getExternalLabelBounds = function(semantic, element) {
- var mid,
- size,
- bounds,
- di = semantic.di,
- label = di.label;
- if (label && label.bounds) {
- bounds = label.bounds;
- size = {
- width: Math.max(DEFAULT_LABEL_SIZE.width, bounds.width),
- height: bounds.height
- };
- mid = {
- x: bounds.x + bounds.width / 2,
- y: bounds.y + bounds.height / 2
- };
- } else {
- mid = getExternalLabelMid(element);
- size = DEFAULT_LABEL_SIZE;
- }
- return assign({
- x: mid.x - size.width / 2,
- y: mid.y - size.height / 2
- }, size);
- };
- },{"339":339}],50:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Is an element of the given BPMN type?
- *
- * @param {djs.model.Base|ModdleElement} element
- * @param {String} type
- *
- * @return {Boolean}
- */
- function is(element, type) {
- var bo = getBusinessObject(element);
- return bo && bo.$instanceOf(type);
- }
- module.exports.is = is;
- /**
- * Return the business object for a given element.
- *
- * @param {djs.model.Base|ModdleElement} element
- *
- * @return {ModdleElement}
- */
- function getBusinessObject(element) {
- return (element && element.businessObject) || element;
- }
- module.exports.getBusinessObject = getBusinessObject;
- },{}],51:[function(_dereq_,module,exports){
- module.exports = _dereq_(54);
- },{"54":54}],52:[function(_dereq_,module,exports){
- 'use strict';
- var isString = _dereq_(336),
- isFunction = _dereq_(331),
- assign = _dereq_(339);
- var Moddle = _dereq_(60),
- XmlReader = _dereq_(56),
- XmlWriter = _dereq_(57);
- /**
- * A sub class of {@link Moddle} with support for import and export of BPMN 2.0 xml files.
- *
- * @class BpmnModdle
- * @extends Moddle
- *
- * @param {Object|Array} packages to use for instantiating the model
- * @param {Object} [options] additional options to pass over
- */
- function BpmnModdle(packages, options) {
- Moddle.call(this, packages, options);
- }
- BpmnModdle.prototype = Object.create(Moddle.prototype);
- module.exports = BpmnModdle;
- /**
- * Instantiates a BPMN model tree from a given xml string.
- *
- * @param {String} xmlStr
- * @param {String} [typeName='bpmn:Definitions'] name of the root element
- * @param {Object} [options] options to pass to the underlying reader
- * @param {Function} done callback that is invoked with (err, result, parseContext)
- * once the import completes
- */
- BpmnModdle.prototype.fromXML = function(xmlStr, typeName, options, done) {
- if (!isString(typeName)) {
- done = options;
- options = typeName;
- typeName = 'bpmn:Definitions';
- }
- if (isFunction(options)) {
- done = options;
- options = {};
- }
- var reader = new XmlReader(assign({ model: this, lax: true }, options));
- var rootHandler = reader.handler(typeName);
- reader.fromXML(xmlStr, rootHandler, done);
- };
- /**
- * Serializes a BPMN 2.0 object tree to XML.
- *
- * @param {String} element the root element, typically an instance of `bpmn:Definitions`
- * @param {Object} [options] to pass to the underlying writer
- * @param {Function} done callback invoked with (err, xmlStr) once the import completes
- */
- BpmnModdle.prototype.toXML = function(element, options, done) {
- if (isFunction(options)) {
- done = options;
- options = {};
- }
- var writer = new XmlWriter(options);
- try {
- var result = writer.toXML(element);
- done(null, result);
- } catch (e) {
- done(e);
- }
- };
- },{"331":331,"336":336,"339":339,"56":56,"57":57,"60":60}],53:[function(_dereq_,module,exports){
- 'use strict';
- var ID_PATTERN = /^(.*:)?id$/;
- /**
- * Extends the bpmn instance with id support.
- *
- * @example
- *
- * var moddle, ids;
- *
- * require('id-support').extend(moddle, ids);
- *
- * moddle.ids.next(); // create a next id
- * moddle.ids; // ids instance
- *
- * // claims id as used
- * moddle.create('foo:Bar', { id: 'fooobar1' });
- *
- *
- * @param {Moddle} model
- * @param {Ids} ids
- *
- * @return {Moddle} the extended moddle instance
- */
- module.exports.extend = function(model, ids) {
- var set = model.properties.set;
- // do not reinitialize setter
- // unless it is already initialized
- if (!model.ids) {
- model.properties.set = function(target, property, value) {
- // ensure we log used ids once they are assigned
- // to model elements
- if (ID_PATTERN.test(property)) {
- var assigned = model.ids.assigned(value);
- if (assigned && assigned !== target) {
- throw new Error('id <' + value + '> already used');
- }
- model.ids.claim(value, target);
- }
- set.call(this, target, property, value);
- };
- }
- model.ids = ids;
- return model;
- };
- },{}],54:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- var BpmnModdle = _dereq_(52);
- var packages = {
- bpmn: _dereq_(69),
- bpmndi: _dereq_(70),
- dc: _dereq_(71),
- di: _dereq_(72)
- };
- module.exports = function(additionalPackages, options) {
- return new BpmnModdle(assign({}, packages, additionalPackages), options);
- };
- },{"339":339,"52":52,"69":69,"70":70,"71":71,"72":72}],55:[function(_dereq_,module,exports){
- 'use strict';
- function capitalize(string) {
- return string.charAt(0).toUpperCase() + string.slice(1);
- }
- function lower(string) {
- return string.charAt(0).toLowerCase() + string.slice(1);
- }
- function hasLowerCaseAlias(pkg) {
- return pkg.xml && pkg.xml.tagAlias === 'lowerCase';
- }
- module.exports.aliasToName = function(alias, pkg) {
- if (hasLowerCaseAlias(pkg)) {
- return capitalize(alias);
- } else {
- return alias;
- }
- };
- module.exports.nameToAlias = function(name, pkg) {
- if (hasLowerCaseAlias(pkg)) {
- return lower(name);
- } else {
- return name;
- }
- };
- module.exports.DEFAULT_NS_MAP = {
- 'xsi': 'http://www.w3.org/2001/XMLSchema-instance'
- };
- var XSI_TYPE = module.exports.XSI_TYPE = 'xsi:type';
- function serializeFormat(element) {
- return element.xml && element.xml.serialize;
- }
- module.exports.serializeAsType = function(element) {
- return serializeFormat(element) === XSI_TYPE;
- };
- module.exports.serializeAsProperty = function(element) {
- return serializeFormat(element) === 'property';
- };
- },{}],56:[function(_dereq_,module,exports){
- 'use strict';
- var reduce = _dereq_(222),
- forEach = _dereq_(218),
- find = _dereq_(217),
- assign = _dereq_(339),
- defer = _dereq_(229);
- var Stack = _dereq_(59),
- SaxParser = _dereq_(58).parser,
- Moddle = _dereq_(60),
- parseNameNs = _dereq_(65).parseName,
- Types = _dereq_(68),
- coerceType = Types.coerceType,
- isSimpleType = Types.isSimple,
- common = _dereq_(55),
- XSI_TYPE = common.XSI_TYPE,
- XSI_URI = common.DEFAULT_NS_MAP.xsi,
- serializeAsType = common.serializeAsType,
- aliasToName = common.aliasToName;
- function parseNodeAttributes(node) {
- var nodeAttrs = node.attributes;
- return reduce(nodeAttrs, function(result, v, k) {
- var name, ns;
- if (!v.local) {
- name = v.prefix;
- } else {
- ns = parseNameNs(v.name, v.prefix);
- name = ns.name;
- }
- result[name] = v.value;
- return result;
- }, {});
- }
- function normalizeType(node, attr, model) {
- var nameNs = parseNameNs(attr.value);
- var uri = node.ns[nameNs.prefix || ''],
- localName = nameNs.localName,
- pkg = uri && model.getPackage(uri),
- typePrefix;
- if (pkg) {
- typePrefix = pkg.xml && pkg.xml.typePrefix;
- if (typePrefix && localName.indexOf(typePrefix) === 0) {
- localName = localName.slice(typePrefix.length);
- }
- attr.value = pkg.prefix + ':' + localName;
- }
- }
- /**
- * Normalizes namespaces for a node given an optional default namespace and a
- * number of mappings from uris to default prefixes.
- *
- * @param {XmlNode} node
- * @param {Model} model the model containing all registered namespaces
- * @param {Uri} defaultNsUri
- */
- function normalizeNamespaces(node, model, defaultNsUri) {
- var uri, prefix;
- uri = node.uri || defaultNsUri;
- if (uri) {
- var pkg = model.getPackage(uri);
- if (pkg) {
- prefix = pkg.prefix;
- } else {
- prefix = node.prefix;
- }
- node.prefix = prefix;
- node.uri = uri;
- }
- forEach(node.attributes, function(attr) {
- // normalize xsi:type attributes because the
- // assigned type may or may not be namespace prefixed
- if (attr.uri === XSI_URI && attr.local === 'type') {
- normalizeType(node, attr, model);
- }
- normalizeNamespaces(attr, model, null);
- });
- }
- /**
- * A parse context.
- *
- * @class
- *
- * @param {Object} options
- * @param {ElementHandler} options.parseRoot the root handler for parsing a document
- * @param {boolean} [options.lax=false] whether or not to ignore invalid elements
- */
- function Context(options) {
- /**
- * @property {ElementHandler} parseRoot
- */
- /**
- * @property {Boolean} lax
- */
- assign(this, options);
- var elementsById = this.elementsById = {};
- var references = this.references = [];
- var warnings = this.warnings = [];
- this.addReference = function(reference) {
- references.push(reference);
- };
- this.addElement = function(id, element) {
- if (!id || !element) {
- throw new Error('[xml-reader] id or ctx must not be null');
- }
- elementsById[id] = element;
- };
- this.addWarning = function (w) {
- warnings.push(w);
- };
- }
- function BaseHandler() {}
- BaseHandler.prototype.handleEnd = function() {};
- BaseHandler.prototype.handleText = function() {};
- BaseHandler.prototype.handleNode = function() {};
- /**
- * A simple pass through handler that does nothing except for
- * ignoring all input it receives.
- *
- * This is used to ignore unknown elements and
- * attributes.
- */
- function NoopHandler() { }
- NoopHandler.prototype = new BaseHandler();
- NoopHandler.prototype.handleNode = function() {
- return this;
- };
- function BodyHandler() {}
- BodyHandler.prototype = new BaseHandler();
- BodyHandler.prototype.handleText = function(text) {
- this.body = (this.body || '') + text;
- };
- function ReferenceHandler(property, context) {
- this.property = property;
- this.context = context;
- }
- ReferenceHandler.prototype = new BodyHandler();
- ReferenceHandler.prototype.handleNode = function(node) {
- if (this.element) {
- throw new Error('expected no sub nodes');
- } else {
- this.element = this.createReference(node);
- }
- return this;
- };
- ReferenceHandler.prototype.handleEnd = function() {
- this.element.id = this.body;
- };
- ReferenceHandler.prototype.createReference = function() {
- return {
- property: this.property.ns.name,
- id: ''
- };
- };
- function ValueHandler(propertyDesc, element) {
- this.element = element;
- this.propertyDesc = propertyDesc;
- }
- ValueHandler.prototype = new BodyHandler();
- ValueHandler.prototype.handleEnd = function() {
- var value = this.body,
- element = this.element,
- propertyDesc = this.propertyDesc;
- value = coerceType(propertyDesc.type, value);
- if (propertyDesc.isMany) {
- element.get(propertyDesc.name).push(value);
- } else {
- element.set(propertyDesc.name, value);
- }
- };
- function BaseElementHandler() {}
- BaseElementHandler.prototype = Object.create(BodyHandler.prototype);
- BaseElementHandler.prototype.handleNode = function(node) {
- var parser = this,
- element = this.element,
- id;
- if (!element) {
- element = this.element = this.createElement(node);
- id = element.id;
- if (id) {
- this.context.addElement(id, element);
- }
- } else {
- parser = this.handleChild(node);
- }
- return parser;
- };
- /**
- * @class XMLReader.ElementHandler
- *
- */
- function ElementHandler(model, type, context) {
- this.model = model;
- this.type = model.getType(type);
- this.context = context;
- }
- ElementHandler.prototype = new BaseElementHandler();
- ElementHandler.prototype.addReference = function(reference) {
- this.context.addReference(reference);
- };
- ElementHandler.prototype.handleEnd = function() {
- var value = this.body,
- element = this.element,
- descriptor = element.$descriptor,
- bodyProperty = descriptor.bodyProperty;
- if (bodyProperty && value !== undefined) {
- value = coerceType(bodyProperty.type, value);
- element.set(bodyProperty.name, value);
- }
- };
- /**
- * Create an instance of the model from the given node.
- *
- * @param {Element} node the xml node
- */
- ElementHandler.prototype.createElement = function(node) {
- var attributes = parseNodeAttributes(node),
- Type = this.type,
- descriptor = Type.$descriptor,
- context = this.context,
- instance = new Type({});
- forEach(attributes, function(value, name) {
- var prop = descriptor.propertiesByName[name];
- if (prop && prop.isReference) {
- context.addReference({
- element: instance,
- property: prop.ns.name,
- id: value
- });
- } else {
- if (prop) {
- value = coerceType(prop.type, value);
- }
- instance.set(name, value);
- }
- });
- return instance;
- };
- ElementHandler.prototype.getPropertyForNode = function(node) {
- var nameNs = parseNameNs(node.local, node.prefix);
- var type = this.type,
- model = this.model,
- descriptor = type.$descriptor;
- var propertyName = nameNs.name,
- property = descriptor.propertiesByName[propertyName],
- elementTypeName,
- elementType,
- typeAnnotation;
- // search for properties by name first
- if (property) {
- if (serializeAsType(property)) {
- typeAnnotation = node.attributes[XSI_TYPE];
- // xsi type is optional, if it does not exists the
- // default type is assumed
- if (typeAnnotation) {
- elementTypeName = typeAnnotation.value;
- // TODO: extract real name from attribute
- elementType = model.getType(elementTypeName);
- return assign({}, property, { effectiveType: elementType.$descriptor.name });
- }
- }
- // search for properties by name first
- return property;
- }
- var pkg = model.getPackage(nameNs.prefix);
- if (pkg) {
- elementTypeName = nameNs.prefix + ':' + aliasToName(nameNs.localName, descriptor.$pkg);
- elementType = model.getType(elementTypeName);
- // search for collection members later
- property = find(descriptor.properties, function(p) {
- return !p.isVirtual && !p.isReference && !p.isAttribute && elementType.hasType(p.type);
- });
- if (property) {
- return assign({}, property, { effectiveType: elementType.$descriptor.name });
- }
- } else {
- // parse unknown element (maybe extension)
- property = find(descriptor.properties, function(p) {
- return !p.isReference && !p.isAttribute && p.type === 'Element';
- });
- if (property) {
- return property;
- }
- }
- throw new Error('unrecognized element <' + nameNs.name + '>');
- };
- ElementHandler.prototype.toString = function() {
- return 'ElementDescriptor[' + this.type.$descriptor.name + ']';
- };
- ElementHandler.prototype.valueHandler = function(propertyDesc, element) {
- return new ValueHandler(propertyDesc, element);
- };
- ElementHandler.prototype.referenceHandler = function(propertyDesc) {
- return new ReferenceHandler(propertyDesc, this.context);
- };
- ElementHandler.prototype.handler = function(type) {
- if (type === 'Element') {
- return new GenericElementHandler(this.model, type, this.context);
- } else {
- return new ElementHandler(this.model, type, this.context);
- }
- };
- /**
- * Handle the child element parsing
- *
- * @param {Element} node the xml node
- */
- ElementHandler.prototype.handleChild = function(node) {
- var propertyDesc, type, element, childHandler;
- propertyDesc = this.getPropertyForNode(node);
- element = this.element;
- type = propertyDesc.effectiveType || propertyDesc.type;
- if (isSimpleType(type)) {
- return this.valueHandler(propertyDesc, element);
- }
- if (propertyDesc.isReference) {
- childHandler = this.referenceHandler(propertyDesc).handleNode(node);
- } else {
- childHandler = this.handler(type).handleNode(node);
- }
- var newElement = childHandler.element;
- // child handles may decide to skip elements
- // by not returning anything
- if (newElement !== undefined) {
- if (propertyDesc.isMany) {
- element.get(propertyDesc.name).push(newElement);
- } else {
- element.set(propertyDesc.name, newElement);
- }
- if (propertyDesc.isReference) {
- assign(newElement, {
- element: element
- });
- this.context.addReference(newElement);
- } else {
- // establish child -> parent relationship
- newElement.$parent = element;
- }
- }
- return childHandler;
- };
- function GenericElementHandler(model, type, context) {
- this.model = model;
- this.context = context;
- }
- GenericElementHandler.prototype = Object.create(BaseElementHandler.prototype);
- GenericElementHandler.prototype.createElement = function(node) {
- var name = node.name,
- prefix = node.prefix,
- uri = node.ns[prefix],
- attributes = node.attributes;
- return this.model.createAny(name, uri, attributes);
- };
- GenericElementHandler.prototype.handleChild = function(node) {
- var handler = new GenericElementHandler(this.model, 'Element', this.context).handleNode(node),
- element = this.element;
- var newElement = handler.element,
- children;
- if (newElement !== undefined) {
- children = element.$children = element.$children || [];
- children.push(newElement);
- // establish child -> parent relationship
- newElement.$parent = element;
- }
- return handler;
- };
- GenericElementHandler.prototype.handleText = function(text) {
- this.body = this.body || '' + text;
- };
- GenericElementHandler.prototype.handleEnd = function() {
- if (this.body) {
- this.element.$body = this.body;
- }
- };
- /**
- * A reader for a meta-model
- *
- * @param {Object} options
- * @param {Model} options.model used to read xml files
- * @param {Boolean} options.lax whether to make parse errors warnings
- */
- function XMLReader(options) {
- if (options instanceof Moddle) {
- options = {
- model: options
- };
- }
- assign(this, { lax: false }, options);
- }
- XMLReader.prototype.fromXML = function(xml, rootHandler, done) {
- var model = this.model,
- lax = this.lax,
- context = new Context({
- parseRoot: rootHandler
- });
- var parser = new SaxParser(true, { xmlns: true, trim: true }),
- stack = new Stack();
- rootHandler.context = context;
- // push root handler
- stack.push(rootHandler);
- function resolveReferences() {
- var elementsById = context.elementsById;
- var references = context.references;
- var i, r;
- for (i = 0; !!(r = references[i]); i++) {
- var element = r.element;
- var reference = elementsById[r.id];
- var property = element.$descriptor.propertiesByName[r.property];
- if (!reference) {
- context.addWarning({
- message: 'unresolved reference <' + r.id + '>',
- element: r.element,
- property: r.property,
- value: r.id
- });
- }
- if (property.isMany) {
- var collection = element.get(property.name),
- idx = collection.indexOf(r);
- if (!reference) {
- // remove unresolvable reference
- collection.splice(idx, 1);
- } else {
- // update reference
- collection[idx] = reference;
- }
- } else {
- element.set(property.name, reference);
- }
- }
- }
- function handleClose(tagName) {
- stack.pop().handleEnd();
- }
- function handleOpen(node) {
- var handler = stack.peek();
- normalizeNamespaces(node, model);
- try {
- stack.push(handler.handleNode(node));
- } catch (e) {
- var line = this.line,
- column = this.column;
- var message =
- 'unparsable content <' + node.name + '> detected\n\t' +
- 'line: ' + line + '\n\t' +
- 'column: ' + column + '\n\t' +
- 'nested error: ' + e.message;
- if (lax) {
- context.addWarning({
- message: message,
- error: e
- });
- console.warn('could not parse node');
- console.warn(e);
- stack.push(new NoopHandler());
- } else {
- console.error('could not parse document');
- console.error(e);
- throw new Error(message);
- }
- }
- }
- function handleText(text) {
- stack.peek().handleText(text);
- }
- parser.onopentag = handleOpen;
- parser.oncdata = parser.ontext = handleText;
- parser.onclosetag = handleClose;
- parser.onend = resolveReferences;
- // deferred parse XML to make loading really ascnchronous
- // this ensures the execution environment (node or browser)
- // is kept responsive and that certain optimization strategies
- // can kick in
- defer(function() {
- var error;
- try {
- parser.write(xml).close();
- } catch (e) {
- error = e;
- }
- done(error, error ? undefined : rootHandler.element, context);
- });
- };
- XMLReader.prototype.handler = function(name) {
- return new ElementHandler(this.model, name);
- };
- module.exports = XMLReader;
- module.exports.ElementHandler = ElementHandler;
- },{"217":217,"218":218,"222":222,"229":229,"339":339,"55":55,"58":58,"59":59,"60":60,"65":65,"68":68}],57:[function(_dereq_,module,exports){
- 'use strict';
- var map = _dereq_(221),
- forEach = _dereq_(218),
- isString = _dereq_(336),
- filter = _dereq_(216),
- assign = _dereq_(339);
- var Types = _dereq_(68),
- parseNameNs = _dereq_(65).parseName,
- common = _dereq_(55),
- nameToAlias = common.nameToAlias,
- serializeAsType = common.serializeAsType,
- serializeAsProperty = common.serializeAsProperty;
- var XML_PREAMBLE = '<?xml version="1.0" encoding="UTF-8"?>\n',
- ESCAPE_CHARS = /(<|>|'|"|&|\n\r|\n)/g,
- DEFAULT_NS_MAP = common.DEFAULT_NS_MAP,
- XSI_TYPE = common.XSI_TYPE;
- function nsName(ns) {
- if (isString(ns)) {
- return ns;
- } else {
- return (ns.prefix ? ns.prefix + ':' : '') + ns.localName;
- }
- }
- function getElementNs(ns, descriptor) {
- if (descriptor.isGeneric) {
- return descriptor.name;
- } else {
- return assign({ localName: nameToAlias(descriptor.ns.localName, descriptor.$pkg) }, ns);
- }
- }
- function getPropertyNs(ns, descriptor) {
- return assign({ localName: descriptor.ns.localName }, ns);
- }
- function getSerializableProperties(element) {
- var descriptor = element.$descriptor;
- return filter(descriptor.properties, function(p) {
- var name = p.name;
- // do not serialize defaults
- if (!element.hasOwnProperty(name)) {
- return false;
- }
- var value = element[name];
- // do not serialize default equals
- if (value === p.default) {
- return false;
- }
- return p.isMany ? value.length : true;
- });
- }
- var ESCAPE_MAP = {
- '\n': '10',
- '\n\r': '10',
- '"': '34',
- '\'': '39',
- '<': '60',
- '>': '62',
- '&': '38'
- };
- /**
- * Escape a string attribute to not contain any bad values (line breaks, '"', ...)
- *
- * @param {String} str the string to escape
- * @return {String} the escaped string
- */
- function escapeAttr(str) {
- // ensure we are handling strings here
- str = isString(str) ? str : '' + str;
- return str.replace(ESCAPE_CHARS, function(str) {
- return '&#' + ESCAPE_MAP[str] + ';';
- });
- }
- function filterAttributes(props) {
- return filter(props, function(p) { return p.isAttr; });
- }
- function filterContained(props) {
- return filter(props, function(p) { return !p.isAttr; });
- }
- function ReferenceSerializer(parent, ns) {
- this.ns = ns;
- }
- ReferenceSerializer.prototype.build = function(element) {
- this.element = element;
- return this;
- };
- ReferenceSerializer.prototype.serializeTo = function(writer) {
- writer
- .appendIndent()
- .append('<' + nsName(this.ns) + '>' + this.element.id + '</' + nsName(this.ns) + '>')
- .appendNewLine();
- };
- function BodySerializer() {}
- BodySerializer.prototype.serializeValue = BodySerializer.prototype.serializeTo = function(writer) {
- var escape = this.escape;
- if (escape) {
- writer.append('<![CDATA[');
- }
- writer.append(this.value);
- if (escape) {
- writer.append(']]>');
- }
- };
- BodySerializer.prototype.build = function(prop, value) {
- this.value = value;
- if (prop.type === 'String' && ESCAPE_CHARS.test(value)) {
- this.escape = true;
- }
- return this;
- };
- function ValueSerializer(ns) {
- this.ns = ns;
- }
- ValueSerializer.prototype = new BodySerializer();
- ValueSerializer.prototype.serializeTo = function(writer) {
- writer
- .appendIndent()
- .append('<' + nsName(this.ns) + '>');
- this.serializeValue(writer);
- writer
- .append( '</' + nsName(this.ns) + '>')
- .appendNewLine();
- };
- function ElementSerializer(parent, ns) {
- this.body = [];
- this.attrs = [];
- this.parent = parent;
- this.ns = ns;
- }
- ElementSerializer.prototype.build = function(element) {
- this.element = element;
- var otherAttrs = this.parseNsAttributes(element);
- if (!this.ns) {
- this.ns = this.nsTagName(element.$descriptor);
- }
- if (element.$descriptor.isGeneric) {
- this.parseGeneric(element);
- } else {
- var properties = getSerializableProperties(element);
- this.parseAttributes(filterAttributes(properties));
- this.parseContainments(filterContained(properties));
- this.parseGenericAttributes(element, otherAttrs);
- }
- return this;
- };
- ElementSerializer.prototype.nsTagName = function(descriptor) {
- var effectiveNs = this.logNamespaceUsed(descriptor.ns);
- return getElementNs(effectiveNs, descriptor);
- };
- ElementSerializer.prototype.nsPropertyTagName = function(descriptor) {
- var effectiveNs = this.logNamespaceUsed(descriptor.ns);
- return getPropertyNs(effectiveNs, descriptor);
- };
- ElementSerializer.prototype.isLocalNs = function(ns) {
- return ns.uri === this.ns.uri;
- };
- ElementSerializer.prototype.nsAttributeName = function(element) {
- var ns;
- if (isString(element)) {
- ns = parseNameNs(element);
- } else
- if (element.ns) {
- ns = element.ns;
- }
- var effectiveNs = this.logNamespaceUsed(ns);
- // strip prefix if same namespace like parent
- if (this.isLocalNs(effectiveNs)) {
- return { localName: ns.localName };
- } else {
- return assign({ localName: ns.localName }, effectiveNs);
- }
- };
- ElementSerializer.prototype.parseGeneric = function(element) {
- var self = this,
- body = this.body,
- attrs = this.attrs;
- forEach(element, function(val, key) {
- if (key === '$body') {
- body.push(new BodySerializer().build({ type: 'String' }, val));
- } else
- if (key === '$children') {
- forEach(val, function(child) {
- body.push(new ElementSerializer(self).build(child));
- });
- } else
- if (key.indexOf('$') !== 0) {
- attrs.push({ name: key, value: escapeAttr(val) });
- }
- });
- };
- /**
- * Parse namespaces and return a list of left over generic attributes
- *
- * @param {Object} element
- * @return {Array<Object>}
- */
- ElementSerializer.prototype.parseNsAttributes = function(element) {
- var self = this;
- var genericAttrs = element.$attrs;
- var attributes = [];
- // parse namespace attributes first
- // and log them. push non namespace attributes to a list
- // and process them later
- forEach(genericAttrs, function(value, name) {
- var nameNs = parseNameNs(name);
- if (nameNs.prefix === 'xmlns') {
- self.logNamespace({ prefix: nameNs.localName, uri: value });
- } else
- if (!nameNs.prefix && nameNs.localName === 'xmlns') {
- self.logNamespace({ uri: value });
- } else {
- attributes.push({ name: name, value: value });
- }
- });
- return attributes;
- };
- ElementSerializer.prototype.parseGenericAttributes = function(element, attributes) {
- var self = this;
- forEach(attributes, function(attr) {
- // do not serialize xsi:type attribute
- // it is set manually based on the actual implementation type
- if (attr.name === XSI_TYPE) {
- return;
- }
- try {
- self.addAttribute(self.nsAttributeName(attr.name), attr.value);
- } catch (e) {
- console.warn('[writer] missing namespace information for ', attr.name, '=', attr.value, 'on', element, e);
- }
- });
- };
- ElementSerializer.prototype.parseContainments = function(properties) {
- var self = this,
- body = this.body,
- element = this.element;
- forEach(properties, function(p) {
- var value = element.get(p.name),
- isReference = p.isReference,
- isMany = p.isMany;
- var ns = self.nsPropertyTagName(p);
- if (!isMany) {
- value = [ value ];
- }
- if (p.isBody) {
- body.push(new BodySerializer().build(p, value[0]));
- } else
- if (Types.isSimple(p.type)) {
- forEach(value, function(v) {
- body.push(new ValueSerializer(ns).build(p, v));
- });
- } else
- if (isReference) {
- forEach(value, function(v) {
- body.push(new ReferenceSerializer(self, ns).build(v));
- });
- } else {
- // allow serialization via type
- // rather than element name
- var asType = serializeAsType(p),
- asProperty = serializeAsProperty(p);
- forEach(value, function(v) {
- var serializer;
- if (asType) {
- serializer = new TypeSerializer(self, ns);
- } else
- if (asProperty) {
- serializer = new ElementSerializer(self, ns);
- } else {
- serializer = new ElementSerializer(self);
- }
- body.push(serializer.build(v));
- });
- }
- });
- };
- ElementSerializer.prototype.getNamespaces = function() {
- if (!this.parent) {
- if (!this.namespaces) {
- this.namespaces = {
- prefixMap: {},
- uriMap: {},
- used: {}
- };
- }
- } else {
- this.namespaces = this.parent.getNamespaces();
- }
- return this.namespaces;
- };
- ElementSerializer.prototype.logNamespace = function(ns) {
- var namespaces = this.getNamespaces();
- var existing = namespaces.uriMap[ns.uri];
- if (!existing) {
- namespaces.uriMap[ns.uri] = ns;
- }
- namespaces.prefixMap[ns.prefix] = ns.uri;
- return ns;
- };
- ElementSerializer.prototype.logNamespaceUsed = function(ns) {
- var element = this.element,
- model = element.$model,
- namespaces = this.getNamespaces();
- // ns may be
- //
- // * prefix only
- // * prefix:uri
- var prefix = ns.prefix;
- var uri = ns.uri || DEFAULT_NS_MAP[prefix] ||
- namespaces.prefixMap[prefix] || (model ? (model.getPackage(prefix) || {}).uri : null);
- if (!uri) {
- throw new Error('no namespace uri given for prefix <' + ns.prefix + '>');
- }
- ns = namespaces.uriMap[uri];
- if (!ns) {
- ns = this.logNamespace({ prefix: prefix, uri: uri });
- }
- if (!namespaces.used[ns.uri]) {
- namespaces.used[ns.uri] = ns;
- }
- return ns;
- };
- ElementSerializer.prototype.parseAttributes = function(properties) {
- var self = this,
- element = this.element;
- forEach(properties, function(p) {
- self.logNamespaceUsed(p.ns);
- var value = element.get(p.name);
- if (p.isReference) {
- value = value.id;
- }
- self.addAttribute(self.nsAttributeName(p), value);
- });
- };
- ElementSerializer.prototype.addAttribute = function(name, value) {
- var attrs = this.attrs;
- if (isString(value)) {
- value = escapeAttr(value);
- }
- attrs.push({ name: name, value: value });
- };
- ElementSerializer.prototype.serializeAttributes = function(writer) {
- var attrs = this.attrs,
- root = !this.parent,
- namespaces = this.namespaces;
- function collectNsAttrs() {
- return map(namespaces.used, function(ns) {
- var name = 'xmlns' + (ns.prefix ? ':' + ns.prefix : '');
- return { name: name, value: ns.uri };
- });
- }
- if (root) {
- attrs = collectNsAttrs().concat(attrs);
- }
- forEach(attrs, function(a) {
- writer
- .append(' ')
- .append(nsName(a.name)).append('="').append(a.value).append('"');
- });
- };
- ElementSerializer.prototype.serializeTo = function(writer) {
- var hasBody = this.body.length,
- indent = !(this.body.length === 1 && this.body[0] instanceof BodySerializer);
- writer
- .appendIndent()
- .append('<' + nsName(this.ns));
- this.serializeAttributes(writer);
- writer.append(hasBody ? '>' : ' />');
- if (hasBody) {
- if (indent) {
- writer
- .appendNewLine()
- .indent();
- }
- forEach(this.body, function(b) {
- b.serializeTo(writer);
- });
- if (indent) {
- writer
- .unindent()
- .appendIndent();
- }
- writer.append('</' + nsName(this.ns) + '>');
- }
- writer.appendNewLine();
- };
- /**
- * A serializer for types that handles serialization of data types
- */
- function TypeSerializer(parent, ns) {
- ElementSerializer.call(this, parent, ns);
- }
- TypeSerializer.prototype = new ElementSerializer();
- TypeSerializer.prototype.build = function(element) {
- var descriptor = element.$descriptor;
- this.element = element;
- this.typeNs = this.nsTagName(descriptor);
- // add xsi:type attribute to represent the elements
- // actual type
- var typeNs = this.typeNs,
- pkg = element.$model.getPackage(typeNs.uri),
- typePrefix = (pkg.xml && pkg.xml.typePrefix) || '';
- this.addAttribute(this.nsAttributeName(XSI_TYPE),
- (typeNs.prefix ? typeNs.prefix + ':' : '') +
- typePrefix + descriptor.ns.localName);
- // do the usual stuff
- return ElementSerializer.prototype.build.call(this, element);
- };
- TypeSerializer.prototype.isLocalNs = function(ns) {
- return ns.uri === this.typeNs.uri;
- };
- function SavingWriter() {
- this.value = '';
- this.write = function(str) {
- this.value += str;
- };
- }
- function FormatingWriter(out, format) {
- var indent = [''];
- this.append = function(str) {
- out.write(str);
- return this;
- };
- this.appendNewLine = function() {
- if (format) {
- out.write('\n');
- }
- return this;
- };
- this.appendIndent = function() {
- if (format) {
- out.write(indent.join(' '));
- }
- return this;
- };
- this.indent = function() {
- indent.push('');
- return this;
- };
- this.unindent = function() {
- indent.pop();
- return this;
- };
- }
- /**
- * A writer for meta-model backed document trees
- *
- * @param {Object} options output options to pass into the writer
- */
- function XMLWriter(options) {
- options = assign({ format: false, preamble: true }, options || {});
- function toXML(tree, writer) {
- var internalWriter = writer || new SavingWriter();
- var formatingWriter = new FormatingWriter(internalWriter, options.format);
- if (options.preamble) {
- formatingWriter.append(XML_PREAMBLE);
- }
- new ElementSerializer().build(tree).serializeTo(formatingWriter);
- if (!writer) {
- return internalWriter.value;
- }
- }
- return {
- toXML: toXML
- };
- }
- module.exports = XMLWriter;
- },{"216":216,"218":218,"221":221,"336":336,"339":339,"55":55,"65":65,"68":68}],58:[function(_dereq_,module,exports){
- (function (Buffer){
- // wrapper for non-node envs
- ;(function (sax) {
- sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
- sax.SAXParser = SAXParser
- sax.SAXStream = SAXStream
- sax.createStream = createStream
- // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
- // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
- // since that's the earliest that a buffer overrun could occur. This way, checks are
- // as rare as required, but as often as necessary to ensure never crossing this bound.
- // Furthermore, buffers are only tested at most once per write(), so passing a very
- // large string into write() might have undesirable effects, but this is manageable by
- // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
- // edge case, result in creating at most one complete copy of the string passed in.
- // Set to Infinity to have unlimited buffers.
- sax.MAX_BUFFER_LENGTH = 64 * 1024
- var buffers = [
- "comment", "sgmlDecl", "textNode", "tagName", "doctype",
- "procInstName", "procInstBody", "entity", "attribName",
- "attribValue", "cdata", "script"
- ]
- sax.EVENTS = // for discoverability.
- [ "text"
- , "processinginstruction"
- , "sgmldeclaration"
- , "doctype"
- , "comment"
- , "attribute"
- , "opentag"
- , "closetag"
- , "opencdata"
- , "cdata"
- , "closecdata"
- , "error"
- , "end"
- , "ready"
- , "script"
- , "opennamespace"
- , "closenamespace"
- ]
- function SAXParser (strict, opt) {
- if (!(this instanceof SAXParser)) return new SAXParser(strict, opt)
- var parser = this
- clearBuffers(parser)
- parser.q = parser.c = ""
- parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
- parser.opt = opt || {}
- parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
- parser.looseCase = parser.opt.lowercase ? "toLowerCase" : "toUpperCase"
- parser.tags = []
- parser.closed = parser.closedRoot = parser.sawRoot = false
- parser.tag = parser.error = null
- parser.strict = !!strict
- parser.noscript = !!(strict || parser.opt.noscript)
- parser.state = S.BEGIN
- parser.ENTITIES = Object.create(sax.ENTITIES)
- parser.attribList = []
- // namespaces form a prototype chain.
- // it always points at the current tag,
- // which protos to its parent tag.
- if (parser.opt.xmlns) parser.ns = Object.create(rootNS)
- // mostly just for error reporting
- parser.trackPosition = parser.opt.position !== false
- if (parser.trackPosition) {
- parser.position = parser.line = parser.column = 0
- }
- emit(parser, "onready")
- }
- if (!Object.create) Object.create = function (o) {
- function f () { this.__proto__ = o }
- f.prototype = o
- return new f
- }
- if (!Object.getPrototypeOf) Object.getPrototypeOf = function (o) {
- return o.__proto__
- }
- if (!Object.keys) Object.keys = function (o) {
- var a = []
- for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
- return a
- }
- function checkBufferLength (parser) {
- var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
- , maxActual = 0
- for (var i = 0, l = buffers.length; i < l; i ++) {
- var len = parser[buffers[i]].length
- if (len > maxAllowed) {
- // Text/cdata nodes can get big, and since they're buffered,
- // we can get here under normal conditions.
- // Avoid issues by emitting the text node now,
- // so at least it won't get any bigger.
- switch (buffers[i]) {
- case "textNode":
- closeText(parser)
- break
- case "cdata":
- emitNode(parser, "oncdata", parser.cdata)
- parser.cdata = ""
- break
- case "script":
- emitNode(parser, "onscript", parser.script)
- parser.script = ""
- break
- default:
- error(parser, "Max buffer length exceeded: "+buffers[i])
- }
- }
- maxActual = Math.max(maxActual, len)
- }
- // schedule the next check for the earliest possible buffer overrun.
- parser.bufferCheckPosition = (sax.MAX_BUFFER_LENGTH - maxActual)
- + parser.position
- }
- function clearBuffers (parser) {
- for (var i = 0, l = buffers.length; i < l; i ++) {
- parser[buffers[i]] = ""
- }
- }
- function flushBuffers (parser) {
- closeText(parser)
- if (parser.cdata !== "") {
- emitNode(parser, "oncdata", parser.cdata)
- parser.cdata = ""
- }
- if (parser.script !== "") {
- emitNode(parser, "onscript", parser.script)
- parser.script = ""
- }
- }
- SAXParser.prototype =
- { end: function () { end(this) }
- , write: write
- , resume: function () { this.error = null; return this }
- , close: function () { return this.write(null) }
- , flush: function () { flushBuffers(this) }
- }
- try {
- var Stream = _dereq_("stream").Stream
- } catch (ex) {
- var Stream = function () {}
- }
- var streamWraps = sax.EVENTS.filter(function (ev) {
- return ev !== "error" && ev !== "end"
- })
- function createStream (strict, opt) {
- return new SAXStream(strict, opt)
- }
- function SAXStream (strict, opt) {
- if (!(this instanceof SAXStream)) return new SAXStream(strict, opt)
- Stream.apply(this)
- this._parser = new SAXParser(strict, opt)
- this.writable = true
- this.readable = true
- var me = this
- this._parser.onend = function () {
- me.emit("end")
- }
- this._parser.onerror = function (er) {
- me.emit("error", er)
- // if didn't throw, then means error was handled.
- // go ahead and clear error, so we can write again.
- me._parser.error = null
- }
- this._decoder = null;
- streamWraps.forEach(function (ev) {
- Object.defineProperty(me, "on" + ev, {
- get: function () { return me._parser["on" + ev] },
- set: function (h) {
- if (!h) {
- me.removeAllListeners(ev)
- return me._parser["on"+ev] = h
- }
- me.on(ev, h)
- },
- enumerable: true,
- configurable: false
- })
- })
- }
- SAXStream.prototype = Object.create(Stream.prototype,
- { constructor: { value: SAXStream } })
- SAXStream.prototype.write = function (data) {
- if (typeof Buffer === 'function' &&
- typeof Buffer.isBuffer === 'function' &&
- Buffer.isBuffer(data)) {
- if (!this._decoder) {
- var SD = _dereq_('string_decoder').StringDecoder
- this._decoder = new SD('utf8')
- }
- data = this._decoder.write(data);
- }
- this._parser.write(data.toString())
- this.emit("data", data)
- return true
- }
- SAXStream.prototype.end = function (chunk) {
- if (chunk && chunk.length) this.write(chunk)
- this._parser.end()
- return true
- }
- SAXStream.prototype.on = function (ev, handler) {
- var me = this
- if (!me._parser["on"+ev] && streamWraps.indexOf(ev) !== -1) {
- me._parser["on"+ev] = function () {
- var args = arguments.length === 1 ? [arguments[0]]
- : Array.apply(null, arguments)
- args.splice(0, 0, ev)
- me.emit.apply(me, args)
- }
- }
- return Stream.prototype.on.call(me, ev, handler)
- }
- // character classes and tokens
- var whitespace = "\r\n\t "
- // this really needs to be replaced with character classes.
- // XML allows all manner of ridiculous numbers and digits.
- , number = "0124356789"
- , letter = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
- // (Letter | "_" | ":")
- , quote = "'\""
- , entity = number+letter+"#"
- , attribEnd = whitespace + ">"
- , CDATA = "[CDATA["
- , DOCTYPE = "DOCTYPE"
- , XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
- , XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
- , rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
- // turn all the string character sets into character class objects.
- whitespace = charClass(whitespace)
- number = charClass(number)
- letter = charClass(letter)
- // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
- // This implementation works on strings, a single character at a time
- // as such, it cannot ever support astral-plane characters (10000-EFFFF)
- // without a significant breaking change to either this parser, or the
- // JavaScript language. Implementation of an emoji-capable xml parser
- // is left as an exercise for the reader.
- 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]/
- 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-]/
- quote = charClass(quote)
- entity = charClass(entity)
- attribEnd = charClass(attribEnd)
- function charClass (str) {
- return str.split("").reduce(function (s, c) {
- s[c] = true
- return s
- }, {})
- }
- function isRegExp (c) {
- return Object.prototype.toString.call(c) === '[object RegExp]'
- }
- function is (charclass, c) {
- return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
- }
- function not (charclass, c) {
- return !is(charclass, c)
- }
- var S = 0
- sax.STATE =
- { BEGIN : S++
- , TEXT : S++ // general stuff
- , TEXT_ENTITY : S++ // & and such.
- , OPEN_WAKA : S++ // <
- , SGML_DECL : S++ // <!BLARG
- , SGML_DECL_QUOTED : S++ // <!BLARG foo "bar
- , DOCTYPE : S++ // <!DOCTYPE
- , DOCTYPE_QUOTED : S++ // <!DOCTYPE "//blah
- , DOCTYPE_DTD : S++ // <!DOCTYPE "//blah" [ ...
- , DOCTYPE_DTD_QUOTED : S++ // <!DOCTYPE "//blah" [ "foo
- , COMMENT_STARTING : S++ // <!-
- , COMMENT : S++ // <!--
- , COMMENT_ENDING : S++ // <!-- blah -
- , COMMENT_ENDED : S++ // <!-- blah --
- , CDATA : S++ // <![CDATA[ something
- , CDATA_ENDING : S++ // ]
- , CDATA_ENDING_2 : S++ // ]]
- , PROC_INST : S++ // <?hi
- , PROC_INST_BODY : S++ // <?hi there
- , PROC_INST_ENDING : S++ // <?hi "there" ?
- , OPEN_TAG : S++ // <strong
- , OPEN_TAG_SLASH : S++ // <strong /
- , ATTRIB : S++ // <a
- , ATTRIB_NAME : S++ // <a foo
- , ATTRIB_NAME_SAW_WHITE : S++ // <a foo _
- , ATTRIB_VALUE : S++ // <a foo=
- , ATTRIB_VALUE_QUOTED : S++ // <a foo="bar
- , ATTRIB_VALUE_CLOSED : S++ // <a foo="bar"
- , ATTRIB_VALUE_UNQUOTED : S++ // <a foo=bar
- , ATTRIB_VALUE_ENTITY_Q : S++ // <foo bar="""
- , ATTRIB_VALUE_ENTITY_U : S++ // <foo bar="
- , CLOSE_TAG : S++ // </a
- , CLOSE_TAG_SAW_WHITE : S++ // </a >
- , SCRIPT : S++ // <script> ...
- , SCRIPT_ENDING : S++ // <script> ... <
- }
- sax.ENTITIES =
- { "amp" : "&"
- , "gt" : ">"
- , "lt" : "<"
- , "quot" : "\""
- , "apos" : "'"
- , "AElig" : 198
- , "Aacute" : 193
- , "Acirc" : 194
- , "Agrave" : 192
- , "Aring" : 197
- , "Atilde" : 195
- , "Auml" : 196
- , "Ccedil" : 199
- , "ETH" : 208
- , "Eacute" : 201
- , "Ecirc" : 202
- , "Egrave" : 200
- , "Euml" : 203
- , "Iacute" : 205
- , "Icirc" : 206
- , "Igrave" : 204
- , "Iuml" : 207
- , "Ntilde" : 209
- , "Oacute" : 211
- , "Ocirc" : 212
- , "Ograve" : 210
- , "Oslash" : 216
- , "Otilde" : 213
- , "Ouml" : 214
- , "THORN" : 222
- , "Uacute" : 218
- , "Ucirc" : 219
- , "Ugrave" : 217
- , "Uuml" : 220
- , "Yacute" : 221
- , "aacute" : 225
- , "acirc" : 226
- , "aelig" : 230
- , "agrave" : 224
- , "aring" : 229
- , "atilde" : 227
- , "auml" : 228
- , "ccedil" : 231
- , "eacute" : 233
- , "ecirc" : 234
- , "egrave" : 232
- , "eth" : 240
- , "euml" : 235
- , "iacute" : 237
- , "icirc" : 238
- , "igrave" : 236
- , "iuml" : 239
- , "ntilde" : 241
- , "oacute" : 243
- , "ocirc" : 244
- , "ograve" : 242
- , "oslash" : 248
- , "otilde" : 245
- , "ouml" : 246
- , "szlig" : 223
- , "thorn" : 254
- , "uacute" : 250
- , "ucirc" : 251
- , "ugrave" : 249
- , "uuml" : 252
- , "yacute" : 253
- , "yuml" : 255
- , "copy" : 169
- , "reg" : 174
- , "nbsp" : 160
- , "iexcl" : 161
- , "cent" : 162
- , "pound" : 163
- , "curren" : 164
- , "yen" : 165
- , "brvbar" : 166
- , "sect" : 167
- , "uml" : 168
- , "ordf" : 170
- , "laquo" : 171
- , "not" : 172
- , "shy" : 173
- , "macr" : 175
- , "deg" : 176
- , "plusmn" : 177
- , "sup1" : 185
- , "sup2" : 178
- , "sup3" : 179
- , "acute" : 180
- , "micro" : 181
- , "para" : 182
- , "middot" : 183
- , "cedil" : 184
- , "ordm" : 186
- , "raquo" : 187
- , "frac14" : 188
- , "frac12" : 189
- , "frac34" : 190
- , "iquest" : 191
- , "times" : 215
- , "divide" : 247
- , "OElig" : 338
- , "oelig" : 339
- , "Scaron" : 352
- , "scaron" : 353
- , "Yuml" : 376
- , "fnof" : 402
- , "circ" : 710
- , "tilde" : 732
- , "Alpha" : 913
- , "Beta" : 914
- , "Gamma" : 915
- , "Delta" : 916
- , "Epsilon" : 917
- , "Zeta" : 918
- , "Eta" : 919
- , "Theta" : 920
- , "Iota" : 921
- , "Kappa" : 922
- , "Lambda" : 923
- , "Mu" : 924
- , "Nu" : 925
- , "Xi" : 926
- , "Omicron" : 927
- , "Pi" : 928
- , "Rho" : 929
- , "Sigma" : 931
- , "Tau" : 932
- , "Upsilon" : 933
- , "Phi" : 934
- , "Chi" : 935
- , "Psi" : 936
- , "Omega" : 937
- , "alpha" : 945
- , "beta" : 946
- , "gamma" : 947
- , "delta" : 948
- , "epsilon" : 949
- , "zeta" : 950
- , "eta" : 951
- , "theta" : 952
- , "iota" : 953
- , "kappa" : 954
- , "lambda" : 955
- , "mu" : 956
- , "nu" : 957
- , "xi" : 958
- , "omicron" : 959
- , "pi" : 960
- , "rho" : 961
- , "sigmaf" : 962
- , "sigma" : 963
- , "tau" : 964
- , "upsilon" : 965
- , "phi" : 966
- , "chi" : 967
- , "psi" : 968
- , "omega" : 969
- , "thetasym" : 977
- , "upsih" : 978
- , "piv" : 982
- , "ensp" : 8194
- , "emsp" : 8195
- , "thinsp" : 8201
- , "zwnj" : 8204
- , "zwj" : 8205
- , "lrm" : 8206
- , "rlm" : 8207
- , "ndash" : 8211
- , "mdash" : 8212
- , "lsquo" : 8216
- , "rsquo" : 8217
- , "sbquo" : 8218
- , "ldquo" : 8220
- , "rdquo" : 8221
- , "bdquo" : 8222
- , "dagger" : 8224
- , "Dagger" : 8225
- , "bull" : 8226
- , "hellip" : 8230
- , "permil" : 8240
- , "prime" : 8242
- , "Prime" : 8243
- , "lsaquo" : 8249
- , "rsaquo" : 8250
- , "oline" : 8254
- , "frasl" : 8260
- , "euro" : 8364
- , "image" : 8465
- , "weierp" : 8472
- , "real" : 8476
- , "trade" : 8482
- , "alefsym" : 8501
- , "larr" : 8592
- , "uarr" : 8593
- , "rarr" : 8594
- , "darr" : 8595
- , "harr" : 8596
- , "crarr" : 8629
- , "lArr" : 8656
- , "uArr" : 8657
- , "rArr" : 8658
- , "dArr" : 8659
- , "hArr" : 8660
- , "forall" : 8704
- , "part" : 8706
- , "exist" : 8707
- , "empty" : 8709
- , "nabla" : 8711
- , "isin" : 8712
- , "notin" : 8713
- , "ni" : 8715
- , "prod" : 8719
- , "sum" : 8721
- , "minus" : 8722
- , "lowast" : 8727
- , "radic" : 8730
- , "prop" : 8733
- , "infin" : 8734
- , "ang" : 8736
- , "and" : 8743
- , "or" : 8744
- , "cap" : 8745
- , "cup" : 8746
- , "int" : 8747
- , "there4" : 8756
- , "sim" : 8764
- , "cong" : 8773
- , "asymp" : 8776
- , "ne" : 8800
- , "equiv" : 8801
- , "le" : 8804
- , "ge" : 8805
- , "sub" : 8834
- , "sup" : 8835
- , "nsub" : 8836
- , "sube" : 8838
- , "supe" : 8839
- , "oplus" : 8853
- , "otimes" : 8855
- , "perp" : 8869
- , "sdot" : 8901
- , "lceil" : 8968
- , "rceil" : 8969
- , "lfloor" : 8970
- , "rfloor" : 8971
- , "lang" : 9001
- , "rang" : 9002
- , "loz" : 9674
- , "spades" : 9824
- , "clubs" : 9827
- , "hearts" : 9829
- , "diams" : 9830
- }
- Object.keys(sax.ENTITIES).forEach(function (key) {
- var e = sax.ENTITIES[key]
- var s = typeof e === 'number' ? String.fromCharCode(e) : e
- sax.ENTITIES[key] = s
- })
- for (var S in sax.STATE) sax.STATE[sax.STATE[S]] = S
- // shorthand
- S = sax.STATE
- function emit (parser, event, data) {
- parser[event] && parser[event](data)
- }
- function emitNode (parser, nodeType, data) {
- if (parser.textNode) closeText(parser)
- emit(parser, nodeType, data)
- }
- function closeText (parser) {
- parser.textNode = textopts(parser.opt, parser.textNode)
- if (parser.textNode) emit(parser, "ontext", parser.textNode)
- parser.textNode = ""
- }
- function textopts (opt, text) {
- if (opt.trim) text = text.trim()
- if (opt.normalize) text = text.replace(/\s+/g, " ")
- return text
- }
- function error (parser, er) {
- closeText(parser)
- if (parser.trackPosition) {
- er += "\nLine: "+parser.line+
- "\nColumn: "+parser.column+
- "\nChar: "+parser.c
- }
- er = new Error(er)
- parser.error = er
- emit(parser, "onerror", er)
- return parser
- }
- function end (parser) {
- if (!parser.closedRoot) strictFail(parser, "Unclosed root tag")
- if ((parser.state !== S.BEGIN) && (parser.state !== S.TEXT)) error(parser, "Unexpected end")
- closeText(parser)
- parser.c = ""
- parser.closed = true
- emit(parser, "onend")
- SAXParser.call(parser, parser.strict, parser.opt)
- return parser
- }
- function strictFail (parser, message) {
- if (typeof parser !== 'object' || !(parser instanceof SAXParser))
- throw new Error('bad call to strictFail');
- if (parser.strict) error(parser, message)
- }
- function newTag (parser) {
- if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
- var parent = parser.tags[parser.tags.length - 1] || parser
- , tag = parser.tag = { name : parser.tagName, attributes : {} }
- // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
- if (parser.opt.xmlns) tag.ns = parent.ns
- parser.attribList.length = 0
- }
- function qname (name, attribute) {
- var i = name.indexOf(":")
- , qualName = i < 0 ? [ "", name ] : name.split(":")
- , prefix = qualName[0]
- , local = qualName[1]
- // <x "xmlns"="http://foo">
- if (attribute && name === "xmlns") {
- prefix = "xmlns"
- local = ""
- }
- return { prefix: prefix, local: local }
- }
- function attrib (parser) {
- if (!parser.strict) parser.attribName = parser.attribName[parser.looseCase]()
- if (parser.attribList.indexOf(parser.attribName) !== -1 ||
- parser.tag.attributes.hasOwnProperty(parser.attribName)) {
- return parser.attribName = parser.attribValue = ""
- }
- if (parser.opt.xmlns) {
- var qn = qname(parser.attribName, true)
- , prefix = qn.prefix
- , local = qn.local
- if (prefix === "xmlns") {
- // namespace binding attribute; push the binding into scope
- if (local === "xml" && parser.attribValue !== XML_NAMESPACE) {
- strictFail( parser
- , "xml: prefix must be bound to " + XML_NAMESPACE + "\n"
- + "Actual: " + parser.attribValue )
- } else if (local === "xmlns" && parser.attribValue !== XMLNS_NAMESPACE) {
- strictFail( parser
- , "xmlns: prefix must be bound to " + XMLNS_NAMESPACE + "\n"
- + "Actual: " + parser.attribValue )
- } else {
- var tag = parser.tag
- , parent = parser.tags[parser.tags.length - 1] || parser
- if (tag.ns === parent.ns) {
- tag.ns = Object.create(parent.ns)
- }
- tag.ns[local] = parser.attribValue
- }
- }
- // defer onattribute events until all attributes have been seen
- // so any new bindings can take effect; preserve attribute order
- // so deferred events can be emitted in document order
- parser.attribList.push([parser.attribName, parser.attribValue])
- } else {
- // in non-xmlns mode, we can emit the event right away
- parser.tag.attributes[parser.attribName] = parser.attribValue
- emitNode( parser
- , "onattribute"
- , { name: parser.attribName
- , value: parser.attribValue } )
- }
- parser.attribName = parser.attribValue = ""
- }
- function openTag (parser, selfClosing) {
- if (parser.opt.xmlns) {
- // emit namespace binding events
- var tag = parser.tag
- // add namespace info to tag
- var qn = qname(parser.tagName)
- tag.prefix = qn.prefix
- tag.local = qn.local
- tag.uri = tag.ns[qn.prefix] || ""
- if (tag.prefix && !tag.uri) {
- strictFail(parser, "Unbound namespace prefix: "
- + JSON.stringify(parser.tagName))
- tag.uri = qn.prefix
- }
- var parent = parser.tags[parser.tags.length - 1] || parser
- if (tag.ns && parent.ns !== tag.ns) {
- Object.keys(tag.ns).forEach(function (p) {
- emitNode( parser
- , "onopennamespace"
- , { prefix: p , uri: tag.ns[p] } )
- })
- }
- // handle deferred onattribute events
- // Note: do not apply default ns to attributes:
- // http://www.w3.org/TR/REC-xml-names/#defaulting
- for (var i = 0, l = parser.attribList.length; i < l; i ++) {
- var nv = parser.attribList[i]
- var name = nv[0]
- , value = nv[1]
- , qualName = qname(name, true)
- , prefix = qualName.prefix
- , local = qualName.local
- , uri = prefix == "" ? "" : (tag.ns[prefix] || "")
- , a = { name: name
- , value: value
- , prefix: prefix
- , local: local
- , uri: uri
- }
- // if there's any attributes with an undefined namespace,
- // then fail on them now.
- if (prefix && prefix != "xmlns" && !uri) {
- strictFail(parser, "Unbound namespace prefix: "
- + JSON.stringify(prefix))
- a.uri = prefix
- }
- parser.tag.attributes[name] = a
- emitNode(parser, "onattribute", a)
- }
- parser.attribList.length = 0
- }
- parser.tag.isSelfClosing = !!selfClosing
- // process the tag
- parser.sawRoot = true
- parser.tags.push(parser.tag)
- emitNode(parser, "onopentag", parser.tag)
- if (!selfClosing) {
- // special case for <script> in non-strict mode.
- if (!parser.noscript && parser.tagName.toLowerCase() === "script") {
- parser.state = S.SCRIPT
- } else {
- parser.state = S.TEXT
- }
- parser.tag = null
- parser.tagName = ""
- }
- parser.attribName = parser.attribValue = ""
- parser.attribList.length = 0
- }
- function closeTag (parser) {
- if (!parser.tagName) {
- strictFail(parser, "Weird empty close tag.")
- parser.textNode += "</>"
- parser.state = S.TEXT
- return
- }
- if (parser.script) {
- if (parser.tagName !== "script") {
- parser.script += "</" + parser.tagName + ">"
- parser.tagName = ""
- parser.state = S.SCRIPT
- return
- }
- emitNode(parser, "onscript", parser.script)
- parser.script = ""
- }
- // first make sure that the closing tag actually exists.
- // <a><b></c></b></a> will close everything, otherwise.
- var t = parser.tags.length
- var tagName = parser.tagName
- if (!parser.strict) tagName = tagName[parser.looseCase]()
- var closeTo = tagName
- while (t --) {
- var close = parser.tags[t]
- if (close.name !== closeTo) {
- // fail the first time in strict mode
- strictFail(parser, "Unexpected close tag")
- } else break
- }
- // didn't find it. we already failed for strict, so just abort.
- if (t < 0) {
- strictFail(parser, "Unmatched closing tag: "+parser.tagName)
- parser.textNode += "</" + parser.tagName + ">"
- parser.state = S.TEXT
- return
- }
- parser.tagName = tagName
- var s = parser.tags.length
- while (s --> t) {
- var tag = parser.tag = parser.tags.pop()
- parser.tagName = parser.tag.name
- emitNode(parser, "onclosetag", parser.tagName)
- var x = {}
- for (var i in tag.ns) x[i] = tag.ns[i]
- var parent = parser.tags[parser.tags.length - 1] || parser
- if (parser.opt.xmlns && tag.ns !== parent.ns) {
- // remove namespace bindings introduced by tag
- Object.keys(tag.ns).forEach(function (p) {
- var n = tag.ns[p]
- emitNode(parser, "onclosenamespace", { prefix: p, uri: n })
- })
- }
- }
- if (t === 0) parser.closedRoot = true
- parser.tagName = parser.attribValue = parser.attribName = ""
- parser.attribList.length = 0
- parser.state = S.TEXT
- }
- function parseEntity (parser) {
- var entity = parser.entity
- , entityLC = entity.toLowerCase()
- , num
- , numStr = ""
- if (parser.ENTITIES[entity])
- return parser.ENTITIES[entity]
- if (parser.ENTITIES[entityLC])
- return parser.ENTITIES[entityLC]
- entity = entityLC
- if (entity.charAt(0) === "#") {
- if (entity.charAt(1) === "x") {
- entity = entity.slice(2)
- num = parseInt(entity, 16)
- numStr = num.toString(16)
- } else {
- entity = entity.slice(1)
- num = parseInt(entity, 10)
- numStr = num.toString(10)
- }
- }
- entity = entity.replace(/^0+/, "")
- if (numStr.toLowerCase() !== entity) {
- strictFail(parser, "Invalid character entity")
- return "&"+parser.entity + ";"
- }
- return String.fromCodePoint(num)
- }
- function write (chunk) {
- var parser = this
- if (this.error) throw this.error
- if (parser.closed) return error(parser,
- "Cannot write after close. Assign an onready handler.")
- if (chunk === null) return end(parser)
- var i = 0, c = ""
- while (parser.c = c = chunk.charAt(i++)) {
- if (parser.trackPosition) {
- parser.position ++
- if (c === "\n") {
- parser.line ++
- parser.column = 0
- } else parser.column ++
- }
- switch (parser.state) {
- case S.BEGIN:
- if (c === "<") {
- parser.state = S.OPEN_WAKA
- parser.startTagPosition = parser.position
- } else if (not(whitespace,c)) {
- // have to process this as a text node.
- // weird, but happens.
- strictFail(parser, "Non-whitespace before first tag.")
- parser.textNode = c
- parser.state = S.TEXT
- }
- continue
- case S.TEXT:
- if (parser.sawRoot && !parser.closedRoot) {
- var starti = i-1
- while (c && c!=="<" && c!=="&") {
- c = chunk.charAt(i++)
- if (c && parser.trackPosition) {
- parser.position ++
- if (c === "\n") {
- parser.line ++
- parser.column = 0
- } else parser.column ++
- }
- }
- parser.textNode += chunk.substring(starti, i-1)
- }
- if (c === "<") {
- parser.state = S.OPEN_WAKA
- parser.startTagPosition = parser.position
- } else {
- if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot))
- strictFail(parser, "Text data outside of root node.")
- if (c === "&") parser.state = S.TEXT_ENTITY
- else parser.textNode += c
- }
- continue
- case S.SCRIPT:
- // only non-strict
- if (c === "<") {
- parser.state = S.SCRIPT_ENDING
- } else parser.script += c
- continue
- case S.SCRIPT_ENDING:
- if (c === "/") {
- parser.state = S.CLOSE_TAG
- } else {
- parser.script += "<" + c
- parser.state = S.SCRIPT
- }
- continue
- case S.OPEN_WAKA:
- // either a /, ?, !, or text is coming next.
- if (c === "!") {
- parser.state = S.SGML_DECL
- parser.sgmlDecl = ""
- } else if (is(whitespace, c)) {
- // wait for it...
- } else if (is(nameStart,c)) {
- parser.state = S.OPEN_TAG
- parser.tagName = c
- } else if (c === "/") {
- parser.state = S.CLOSE_TAG
- parser.tagName = ""
- } else if (c === "?") {
- parser.state = S.PROC_INST
- parser.procInstName = parser.procInstBody = ""
- } else {
- strictFail(parser, "Unencoded <")
- // if there was some whitespace, then add that in.
- if (parser.startTagPosition + 1 < parser.position) {
- var pad = parser.position - parser.startTagPosition
- c = new Array(pad).join(" ") + c
- }
- parser.textNode += "<" + c
- parser.state = S.TEXT
- }
- continue
- case S.SGML_DECL:
- if ((parser.sgmlDecl+c).toUpperCase() === CDATA) {
- emitNode(parser, "onopencdata")
- parser.state = S.CDATA
- parser.sgmlDecl = ""
- parser.cdata = ""
- } else if (parser.sgmlDecl+c === "--") {
- parser.state = S.COMMENT
- parser.comment = ""
- parser.sgmlDecl = ""
- } else if ((parser.sgmlDecl+c).toUpperCase() === DOCTYPE) {
- parser.state = S.DOCTYPE
- if (parser.doctype || parser.sawRoot) strictFail(parser,
- "Inappropriately located doctype declaration")
- parser.doctype = ""
- parser.sgmlDecl = ""
- } else if (c === ">") {
- emitNode(parser, "onsgmldeclaration", parser.sgmlDecl)
- parser.sgmlDecl = ""
- parser.state = S.TEXT
- } else if (is(quote, c)) {
- parser.state = S.SGML_DECL_QUOTED
- parser.sgmlDecl += c
- } else parser.sgmlDecl += c
- continue
- case S.SGML_DECL_QUOTED:
- if (c === parser.q) {
- parser.state = S.SGML_DECL
- parser.q = ""
- }
- parser.sgmlDecl += c
- continue
- case S.DOCTYPE:
- if (c === ">") {
- parser.state = S.TEXT
- emitNode(parser, "ondoctype", parser.doctype)
- parser.doctype = true // just remember that we saw it.
- } else {
- parser.doctype += c
- if (c === "[") parser.state = S.DOCTYPE_DTD
- else if (is(quote, c)) {
- parser.state = S.DOCTYPE_QUOTED
- parser.q = c
- }
- }
- continue
- case S.DOCTYPE_QUOTED:
- parser.doctype += c
- if (c === parser.q) {
- parser.q = ""
- parser.state = S.DOCTYPE
- }
- continue
- case S.DOCTYPE_DTD:
- parser.doctype += c
- if (c === "]") parser.state = S.DOCTYPE
- else if (is(quote,c)) {
- parser.state = S.DOCTYPE_DTD_QUOTED
- parser.q = c
- }
- continue
- case S.DOCTYPE_DTD_QUOTED:
- parser.doctype += c
- if (c === parser.q) {
- parser.state = S.DOCTYPE_DTD
- parser.q = ""
- }
- continue
- case S.COMMENT:
- if (c === "-") parser.state = S.COMMENT_ENDING
- else parser.comment += c
- continue
- case S.COMMENT_ENDING:
- if (c === "-") {
- parser.state = S.COMMENT_ENDED
- parser.comment = textopts(parser.opt, parser.comment)
- if (parser.comment) emitNode(parser, "oncomment", parser.comment)
- parser.comment = ""
- } else {
- parser.comment += "-" + c
- parser.state = S.COMMENT
- }
- continue
- case S.COMMENT_ENDED:
- if (c !== ">") {
- strictFail(parser, "Malformed comment")
- // allow <!-- blah -- bloo --> in non-strict mode,
- // which is a comment of " blah -- bloo "
- parser.comment += "--" + c
- parser.state = S.COMMENT
- } else parser.state = S.TEXT
- continue
- case S.CDATA:
- if (c === "]") parser.state = S.CDATA_ENDING
- else parser.cdata += c
- continue
- case S.CDATA_ENDING:
- if (c === "]") parser.state = S.CDATA_ENDING_2
- else {
- parser.cdata += "]" + c
- parser.state = S.CDATA
- }
- continue
- case S.CDATA_ENDING_2:
- if (c === ">") {
- if (parser.cdata) emitNode(parser, "oncdata", parser.cdata)
- emitNode(parser, "onclosecdata")
- parser.cdata = ""
- parser.state = S.TEXT
- } else if (c === "]") {
- parser.cdata += "]"
- } else {
- parser.cdata += "]]" + c
- parser.state = S.CDATA
- }
- continue
- case S.PROC_INST:
- if (c === "?") parser.state = S.PROC_INST_ENDING
- else if (is(whitespace, c)) parser.state = S.PROC_INST_BODY
- else parser.procInstName += c
- continue
- case S.PROC_INST_BODY:
- if (!parser.procInstBody && is(whitespace, c)) continue
- else if (c === "?") parser.state = S.PROC_INST_ENDING
- else parser.procInstBody += c
- continue
- case S.PROC_INST_ENDING:
- if (c === ">") {
- emitNode(parser, "onprocessinginstruction", {
- name : parser.procInstName,
- body : parser.procInstBody
- })
- parser.procInstName = parser.procInstBody = ""
- parser.state = S.TEXT
- } else {
- parser.procInstBody += "?" + c
- parser.state = S.PROC_INST_BODY
- }
- continue
- case S.OPEN_TAG:
- if (is(nameBody, c)) parser.tagName += c
- else {
- newTag(parser)
- if (c === ">") openTag(parser)
- else if (c === "/") parser.state = S.OPEN_TAG_SLASH
- else {
- if (not(whitespace, c)) strictFail(
- parser, "Invalid character in tag name")
- parser.state = S.ATTRIB
- }
- }
- continue
- case S.OPEN_TAG_SLASH:
- if (c === ">") {
- openTag(parser, true)
- closeTag(parser)
- } else {
- strictFail(parser, "Forward-slash in opening tag not followed by >")
- parser.state = S.ATTRIB
- }
- continue
- case S.ATTRIB:
- // haven't read the attribute name yet.
- if (is(whitespace, c)) continue
- else if (c === ">") openTag(parser)
- else if (c === "/") parser.state = S.OPEN_TAG_SLASH
- else if (is(nameStart, c)) {
- parser.attribName = c
- parser.attribValue = ""
- parser.state = S.ATTRIB_NAME
- } else strictFail(parser, "Invalid attribute name")
- continue
- case S.ATTRIB_NAME:
- if (c === "=") parser.state = S.ATTRIB_VALUE
- else if (c === ">") {
- strictFail(parser, "Attribute without value")
- parser.attribValue = parser.attribName
- attrib(parser)
- openTag(parser)
- }
- else if (is(whitespace, c)) parser.state = S.ATTRIB_NAME_SAW_WHITE
- else if (is(nameBody, c)) parser.attribName += c
- else strictFail(parser, "Invalid attribute name")
- continue
- case S.ATTRIB_NAME_SAW_WHITE:
- if (c === "=") parser.state = S.ATTRIB_VALUE
- else if (is(whitespace, c)) continue
- else {
- strictFail(parser, "Attribute without value")
- parser.tag.attributes[parser.attribName] = ""
- parser.attribValue = ""
- emitNode(parser, "onattribute",
- { name : parser.attribName, value : "" })
- parser.attribName = ""
- if (c === ">") openTag(parser)
- else if (is(nameStart, c)) {
- parser.attribName = c
- parser.state = S.ATTRIB_NAME
- } else {
- strictFail(parser, "Invalid attribute name")
- parser.state = S.ATTRIB
- }
- }
- continue
- case S.ATTRIB_VALUE:
- if (is(whitespace, c)) continue
- else if (is(quote, c)) {
- parser.q = c
- parser.state = S.ATTRIB_VALUE_QUOTED
- } else {
- strictFail(parser, "Unquoted attribute value")
- parser.state = S.ATTRIB_VALUE_UNQUOTED
- parser.attribValue = c
- }
- continue
- case S.ATTRIB_VALUE_QUOTED:
- if (c !== parser.q) {
- if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_Q
- else parser.attribValue += c
- continue
- }
- attrib(parser)
- parser.q = ""
- parser.state = S.ATTRIB_VALUE_CLOSED
- continue
- case S.ATTRIB_VALUE_CLOSED:
- if (is(whitespace, c)) {
- parser.state = S.ATTRIB
- } else if (c === ">") openTag(parser)
- else if (c === "/") parser.state = S.OPEN_TAG_SLASH
- else if (is(nameStart, c)) {
- strictFail(parser, "No whitespace between attributes")
- parser.attribName = c
- parser.attribValue = ""
- parser.state = S.ATTRIB_NAME
- } else strictFail(parser, "Invalid attribute name")
- continue
- case S.ATTRIB_VALUE_UNQUOTED:
- if (not(attribEnd,c)) {
- if (c === "&") parser.state = S.ATTRIB_VALUE_ENTITY_U
- else parser.attribValue += c
- continue
- }
- attrib(parser)
- if (c === ">") openTag(parser)
- else parser.state = S.ATTRIB
- continue
- case S.CLOSE_TAG:
- if (!parser.tagName) {
- if (is(whitespace, c)) continue
- else if (not(nameStart, c)) {
- if (parser.script) {
- parser.script += "</" + c
- parser.state = S.SCRIPT
- } else {
- strictFail(parser, "Invalid tagname in closing tag.")
- }
- } else parser.tagName = c
- }
- else if (c === ">") closeTag(parser)
- else if (is(nameBody, c)) parser.tagName += c
- else if (parser.script) {
- parser.script += "</" + parser.tagName
- parser.tagName = ""
- parser.state = S.SCRIPT
- } else {
- if (not(whitespace, c)) strictFail(parser,
- "Invalid tagname in closing tag")
- parser.state = S.CLOSE_TAG_SAW_WHITE
- }
- continue
- case S.CLOSE_TAG_SAW_WHITE:
- if (is(whitespace, c)) continue
- if (c === ">") closeTag(parser)
- else strictFail(parser, "Invalid characters in closing tag")
- continue
- case S.TEXT_ENTITY:
- case S.ATTRIB_VALUE_ENTITY_Q:
- case S.ATTRIB_VALUE_ENTITY_U:
- switch(parser.state) {
- case S.TEXT_ENTITY:
- var returnState = S.TEXT, buffer = "textNode"
- break
- case S.ATTRIB_VALUE_ENTITY_Q:
- var returnState = S.ATTRIB_VALUE_QUOTED, buffer = "attribValue"
- break
- case S.ATTRIB_VALUE_ENTITY_U:
- var returnState = S.ATTRIB_VALUE_UNQUOTED, buffer = "attribValue"
- break
- }
- if (c === ";") {
- parser[buffer] += parseEntity(parser)
- parser.entity = ""
- parser.state = returnState
- }
- else if (is(entity, c)) parser.entity += c
- else {
- strictFail(parser, "Invalid character entity")
- parser[buffer] += "&" + parser.entity + c
- parser.entity = ""
- parser.state = returnState
- }
- continue
- default:
- throw new Error(parser, "Unknown state: " + parser.state)
- }
- } // while
- // cdata blocks can get very big under normal conditions. emit and move on.
- // if (parser.state === S.CDATA && parser.cdata) {
- // emitNode(parser, "oncdata", parser.cdata)
- // parser.cdata = ""
- // }
- if (parser.position >= parser.bufferCheckPosition) checkBufferLength(parser)
- return parser
- }
- /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
- if (!String.fromCodePoint) {
- (function() {
- var stringFromCharCode = String.fromCharCode;
- var floor = Math.floor;
- var fromCodePoint = function() {
- var MAX_SIZE = 0x4000;
- var codeUnits = [];
- var highSurrogate;
- var lowSurrogate;
- var index = -1;
- var length = arguments.length;
- if (!length) {
- return '';
- }
- var result = '';
- while (++index < length) {
- var codePoint = Number(arguments[index]);
- if (
- !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
- codePoint < 0 || // not a valid Unicode code point
- codePoint > 0x10FFFF || // not a valid Unicode code point
- floor(codePoint) != codePoint // not an integer
- ) {
- throw RangeError('Invalid code point: ' + codePoint);
- }
- if (codePoint <= 0xFFFF) { // BMP code point
- codeUnits.push(codePoint);
- } else { // Astral code point; split in surrogate halves
- // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
- codePoint -= 0x10000;
- highSurrogate = (codePoint >> 10) + 0xD800;
- lowSurrogate = (codePoint % 0x400) + 0xDC00;
- codeUnits.push(highSurrogate, lowSurrogate);
- }
- if (index + 1 == length || codeUnits.length > MAX_SIZE) {
- result += stringFromCharCode.apply(null, codeUnits);
- codeUnits.length = 0;
- }
- }
- return result;
- };
- if (Object.defineProperty) {
- Object.defineProperty(String, 'fromCodePoint', {
- 'value': fromCodePoint,
- 'configurable': true,
- 'writable': true
- });
- } else {
- String.fromCodePoint = fromCodePoint;
- }
- }());
- }
- })(typeof exports === "undefined" ? sax = {} : exports);
- }).call(this,undefined)
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9icG1uLW1vZGRsZS9ub2RlX21vZHVsZXMvbW9kZGxlLXhtbC9ub2RlX21vZHVsZXMvc2F4L2xpYi9zYXguanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyIvLyB3cmFwcGVyIGZvciBub24tbm9kZSBlbnZzXG47KGZ1bmN0aW9uIChzYXgpIHtcblxuc2F4LnBhcnNlciA9IGZ1bmN0aW9uIChzdHJpY3QsIG9wdCkgeyByZXR1cm4gbmV3IFNBWFBhcnNlcihzdHJpY3QsIG9wdCkgfVxuc2F4LlNBWFBhcnNlciA9IFNBWFBhcnNlclxuc2F4LlNBWFN0cmVhbSA9IFNBWFN0cmVhbVxuc2F4LmNyZWF0ZVN0cmVhbSA9IGNyZWF0ZVN0cmVhbVxuXG4vLyBXaGVuIHdlIHBhc3MgdGhlIE1BWF9CVUZGRVJfTEVOR1RIIHBvc2l0aW9uLCBzdGFydCBjaGVja2luZyBmb3IgYnVmZmVyIG92ZXJydW5zLlxuLy8gV2hlbiB3ZSBjaGVjaywgc2NoZWR1bGUgdGhlIG5leHQgY2hlY2sgZm9yIE1BWF9CVUZGRVJfTEVOR1RIIC0gKG1heChidWZmZXIgbGVuZ3RocykpLFxuLy8gc2luY2UgdGhhdCdzIHRoZSBlYXJsaWVzdCB0aGF0IGEgYnVmZmVyIG92ZXJydW4gY291bGQgb2NjdXIuICBUaGlzIHdheSwgY2hlY2tzIGFyZVxuLy8gYXMgcmFyZSBhcyByZXF1aXJlZCwgYnV0IGFzIG9mdGVuIGFzIG5lY2Vzc2FyeSB0byBlbnN1cmUgbmV2ZXIgY3Jvc3NpbmcgdGhpcyBib3VuZC5cbi8vIEZ1cnRoZXJtb3JlLCBidWZmZXJzIGFyZSBvbmx5IHRlc3RlZCBhdCBtb3N0IG9uY2UgcGVyIHdyaXRlKCksIHNvIHBhc3NpbmcgYSB2ZXJ5XG4vLyBsYXJnZSBzdHJpbmcgaW50byB3cml0ZSgpIG1pZ2h0IGhhdmUgdW5kZXNpcmFibGUgZWZmZWN0cywgYnV0IHRoaXMgaXMgbWFuYWdlYWJsZSBieVxuLy8gdGhlIGNhbGxlciwgc28gaXQgaXMgYXNzdW1lZCB0byBiZSBzYWZlLiAgVGh1cywgYSBjYWxsIHRvIHdyaXRlKCkgbWF5LCBpbiB0aGUgZXh0cmVtZVxuLy8gZWRnZSBjYXNlLCByZXN1bHQgaW4gY3JlYXRpbmcgYXQgbW9zdCBvbmUgY29tcGxldGUgY29weSBvZiB0aGUgc3RyaW5nIHBhc3NlZCBpbi5cbi8vIFNldCB0byBJbmZpbml0eSB0byBoYXZlIHVubGltaXRlZCBidWZmZXJzLlxuc2F4Lk1BWF9CVUZGRVJfTEVOR1RIID0gNjQgKiAxMDI0XG5cbnZhciBidWZmZXJzID0gW1xuICBcImNvbW1lbnRcIiwgXCJzZ21sRGVjbFwiLCBcInRleHROb2RlXCIsIFwidGFnTmFtZVwiLCBcImRvY3R5cGVcIixcbiAgXCJwcm9jSW5zdE5hbWVcIiwgXCJwcm9jSW5zdEJvZHlcIiwgXCJlbnRpdHlcIiwgXCJhdHRyaWJOYW1lXCIsXG4gIFwiYXR0cmliVmFsdWVcIiwgXCJjZGF0YVwiLCBcInNjcmlwdFwiXG5dXG5cbnNheC5FVkVOVFMgPSAvLyBmb3IgZGlzY292ZXJhYmlsaXR5LlxuICBbIFwidGV4dFwiXG4gICwgXCJwcm9jZXNzaW5naW5zdHJ1Y3Rpb25cIlxuICAsIFwic2dtbGRlY2xhcmF0aW9uXCJcbiAgLCBcImRvY3R5cGVcIlxuICAsIFwiY29tbWVudFwiXG4gICwgXCJhdHRyaWJ1dGVcIlxuICAsIFwib3BlbnRhZ1wiXG4gICwgXCJjbG9zZXRhZ1wiXG4gICwgXCJvcGVuY2RhdGFcIlxuICAsIFwiY2RhdGFcIlxuICAsIFwiY2xvc2VjZGF0YVwiXG4gICwgXCJlcnJvclwiXG4gICwgXCJlbmRcIlxuICAsIFwicmVhZHlcIlxuICAsIFwic2NyaXB0XCJcbiAgLCBcIm9wZW5uYW1lc3BhY2VcIlxuICAsIFwiY2xvc2VuYW1lc3BhY2VcIlxuICBdXG5cbmZ1bmN0aW9uIFNBWFBhcnNlciAoc3RyaWN0LCBvcHQpIHtcbiAgaWYgKCEodGhpcyBpbnN0YW5jZW9mIFNBWFBhcnNlcikpIHJldHVybiBuZXcgU0FYUGFyc2VyKHN0cmljdCwgb3B0KVxuXG4gIHZhciBwYXJzZXIgPSB0aGlzXG4gIGNsZWFyQnVmZmVycyhwYXJzZXIpXG4gIHBhcnNlci5xID0gcGFyc2VyLmMgPSBcIlwiXG4gIHBhcnNlci5idWZmZXJDaGVja1Bvc2l0aW9uID0gc2F4Lk1BWF9CVUZGRVJfTEVOR1RIXG4gIHBhcnNlci5vcHQgPSBvcHQgfHwge31cbiAgcGFyc2VyLm9wdC5sb3dlcmNhc2UgPSBwYXJzZXIub3B0Lmxvd2VyY2FzZSB8fCBwYXJzZXIub3B0Lmxvd2VyY2FzZXRhZ3NcbiAgcGFyc2VyLmxvb3NlQ2FzZSA9IHBhcnNlci5vcHQubG93ZXJjYXNlID8gXCJ0b0xvd2VyQ2FzZVwiIDogXCJ0b1VwcGVyQ2FzZVwiXG4gIHBhcnNlci50YWdzID0gW11cbiAgcGFyc2VyLmNsb3NlZCA9IHBhcnNlci5jbG9zZWRSb290ID0gcGFyc2VyLnNhd1Jvb3QgPSBmYWxzZVxuICBwYXJzZXIudGFnID0gcGFyc2VyLmVycm9yID0gbnVsbFxuICBwYXJzZXIuc3RyaWN0ID0gISFzdHJpY3RcbiAgcGFyc2VyLm5vc2NyaXB0ID0gISEoc3RyaWN0IHx8IHBhcnNlci5vcHQubm9zY3JpcHQpXG4gIHBhcnNlci5zdGF0ZSA9IFMuQkVHSU5cbiAgcGFyc2VyLkVOVElUSUVTID0gT2JqZWN0LmNyZWF0ZShzYXguRU5USVRJRVMpXG4gIHBhcnNlci5hdHRyaWJMaXN0ID0gW11cblxuICAvLyBuYW1lc3BhY2VzIGZvcm0gYSBwcm90b3R5cGUgY2hhaW4uXG4gIC8vIGl0IGFsd2F5cyBwb2ludHMgYXQgdGhlIGN1cnJlbnQgdGFnLFxuICAvLyB3aGljaCBwcm90b3MgdG8gaXRzIHBhcmVudCB0YWcuXG4gIGlmIChwYXJzZXIub3B0LnhtbG5zKSBwYXJzZXIubnMgPSBPYmplY3QuY3JlYXRlKHJvb3ROUylcblxuICAvLyBtb3N0bHkganVzdCBmb3IgZXJyb3IgcmVwb3J0aW5nXG4gIHBhcnNlci50cmFja1Bvc2l0aW9uID0gcGFyc2VyLm9wdC5wb3NpdGlvbiAhPT0gZmFsc2VcbiAgaWYgKHBhcnNlci50cmFja1Bvc2l0aW9uKSB7XG4gICAgcGFyc2VyLnBvc2l0aW9uID0gcGFyc2VyLmxpbmUgPSBwYXJzZXIuY29sdW1uID0gMFxuICB9XG4gIGVtaXQocGFyc2VyLCBcIm9ucmVhZHlcIilcbn1cblxuaWYgKCFPYmplY3QuY3JlYXRlKSBPYmplY3QuY3JlYXRlID0gZnVuY3Rpb24gKG8pIHtcbiAgZnVuY3Rpb24gZiAoKSB7IHRoaXMuX19wcm90b19fID0gbyB9XG4gIGYucHJvdG90eXBlID0gb1xuICByZXR1cm4gbmV3IGZcbn1cblxuaWYgKCFPYmplY3QuZ2V0UHJvdG90eXBlT2YpIE9iamVjdC5nZXRQcm90b3R5cGVPZiA9IGZ1bmN0aW9uIChvKSB7XG4gIHJldHVybiBvLl9fcHJvdG9fX1xufVxuXG5pZiAoIU9iamVjdC5rZXlzKSBPYmplY3Qua2V5cyA9IGZ1bmN0aW9uIChvKSB7XG4gIHZhciBhID0gW11cbiAgZm9yICh2YXIgaSBpbiBvKSBpZiAoby5oYXNPd25Qcm9wZXJ0eShpKSkgYS5wdXNoKGkpXG4gIHJldHVybiBhXG59XG5cbmZ1bmN0aW9uIGNoZWNrQnVmZmVyTGVuZ3RoIChwYXJzZXIpIHtcbiAgdmFyIG1heEFsbG93ZWQgPSBNYXRoLm1heChzYXguTUFYX0JVRkZFUl9MRU5HVEgsIDEwKVxuICAgICwgbWF4QWN0dWFsID0gMFxuICBmb3IgKHZhciBpID0gMCwgbCA9IGJ1ZmZlcnMubGVuZ3RoOyBpIDwgbDsgaSArKykge1xuICAgIHZhciBsZW4gPSBwYXJzZXJbYnVmZmVyc1tpXV0ubGVuZ3RoXG4gICAgaWYgKGxlbiA+IG1heEFsbG93ZWQpIHtcbiAgICAgIC8vIFRleHQvY2RhdGEgbm9kZXMgY2FuIGdldCBiaWcsIGFuZCBzaW5jZSB0aGV5J3JlIGJ1ZmZlcmVkLFxuICAgICAgLy8gd2UgY2FuIGdldCBoZXJlIHVuZGVyIG5vcm1hbCBjb25kaXRpb25zLlxuICAgICAgLy8gQXZvaWQgaXNzdWVzIGJ5IGVtaXR0aW5nIHRoZSB0ZXh0IG5vZGUgbm93LFxuICAgICAgLy8gc28gYXQgbGVhc3QgaXQgd29uJ3QgZ2V0IGFueSBiaWdnZXIuXG4gICAgICBzd2l0Y2ggKGJ1ZmZlcnNbaV0pIHtcbiAgICAgICAgY2FzZSBcInRleHROb2RlXCI6XG4gICAgICAgICAgY2xvc2VUZXh0KHBhcnNlcilcbiAgICAgICAgYnJlYWtcblxuICAgICAgICBjYXNlIFwiY2RhdGFcIjpcbiAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25jZGF0YVwiLCBwYXJzZXIuY2RhdGEpXG4gICAgICAgICAgcGFyc2VyLmNkYXRhID0gXCJcIlxuICAgICAgICBicmVha1xuXG4gICAgICAgIGNhc2UgXCJzY3JpcHRcIjpcbiAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25zY3JpcHRcIiwgcGFyc2VyLnNjcmlwdClcbiAgICAgICAgICBwYXJzZXIuc2NyaXB0ID0gXCJcIlxuICAgICAgICBicmVha1xuXG4gICAgICAgIGRlZmF1bHQ6XG4gICAgICAgICAgZXJyb3IocGFyc2VyLCBcIk1heCBidWZmZXIgbGVuZ3RoIGV4Y2VlZGVkOiBcIitidWZmZXJzW2ldKVxuICAgICAgfVxuICAgIH1cbiAgICBtYXhBY3R1YWwgPSBNYXRoLm1heChtYXhBY3R1YWwsIGxlbilcbiAgfVxuICAvLyBzY2hlZHVsZSB0aGUgbmV4dCBjaGVjayBmb3IgdGhlIGVhcmxpZXN0IHBvc3NpYmxlIGJ1ZmZlciBvdmVycnVuLlxuICBwYXJzZXIuYnVmZmVyQ2hlY2tQb3NpdGlvbiA9IChzYXguTUFYX0JVRkZFUl9MRU5HVEggLSBtYXhBY3R1YWwpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgcGFyc2VyLnBvc2l0aW9uXG59XG5cbmZ1bmN0aW9uIGNsZWFyQnVmZmVycyAocGFyc2VyKSB7XG4gIGZvciAodmFyIGkgPSAwLCBsID0gYnVmZmVycy5sZW5ndGg7IGkgPCBsOyBpICsrKSB7XG4gICAgcGFyc2VyW2J1ZmZlcnNbaV1dID0gXCJcIlxuICB9XG59XG5cbmZ1bmN0aW9uIGZsdXNoQnVmZmVycyAocGFyc2VyKSB7XG4gIGNsb3NlVGV4dChwYXJzZXIpXG4gIGlmIChwYXJzZXIuY2RhdGEgIT09IFwiXCIpIHtcbiAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25jZGF0YVwiLCBwYXJzZXIuY2RhdGEpXG4gICAgcGFyc2VyLmNkYXRhID0gXCJcIlxuICB9XG4gIGlmIChwYXJzZXIuc2NyaXB0ICE9PSBcIlwiKSB7XG4gICAgZW1pdE5vZGUocGFyc2VyLCBcIm9uc2NyaXB0XCIsIHBhcnNlci5zY3JpcHQpXG4gICAgcGFyc2VyLnNjcmlwdCA9IFwiXCJcbiAgfVxufVxuXG5TQVhQYXJzZXIucHJvdG90eXBlID1cbiAgeyBlbmQ6IGZ1bmN0aW9uICgpIHsgZW5kKHRoaXMpIH1cbiAgLCB3cml0ZTogd3JpdGVcbiAgLCByZXN1bWU6IGZ1bmN0aW9uICgpIHsgdGhpcy5lcnJvciA9IG51bGw7IHJldHVybiB0aGlzIH1cbiAgLCBjbG9zZTogZnVuY3Rpb24gKCkgeyByZXR1cm4gdGhpcy53cml0ZShudWxsKSB9XG4gICwgZmx1c2g6IGZ1bmN0aW9uICgpIHsgZmx1c2hCdWZmZXJzKHRoaXMpIH1cbiAgfVxuXG50cnkge1xuICB2YXIgU3RyZWFtID0gcmVxdWlyZShcInN0cmVhbVwiKS5TdHJlYW1cbn0gY2F0Y2ggKGV4KSB7XG4gIHZhciBTdHJlYW0gPSBmdW5jdGlvbiAoKSB7fVxufVxuXG5cbnZhciBzdHJlYW1XcmFwcyA9IHNheC5FVkVOVFMuZmlsdGVyKGZ1bmN0aW9uIChldikge1xuICByZXR1cm4gZXYgIT09IFwiZXJyb3JcIiAmJiBldiAhPT0gXCJlbmRcIlxufSlcblxuZnVuY3Rpb24gY3JlYXRlU3RyZWFtIChzdHJpY3QsIG9wdCkge1xuICByZXR1cm4gbmV3IFNBWFN0cmVhbShzdHJpY3QsIG9wdClcbn1cblxuZnVuY3Rpb24gU0FYU3RyZWFtIChzdHJpY3QsIG9wdCkge1xuICBpZiAoISh0aGlzIGluc3RhbmNlb2YgU0FYU3RyZWFtKSkgcmV0dXJuIG5ldyBTQVhTdHJlYW0oc3RyaWN0LCBvcHQpXG5cbiAgU3RyZWFtLmFwcGx5KHRoaXMpXG5cbiAgdGhpcy5fcGFyc2VyID0gbmV3IFNBWFBhcnNlcihzdHJpY3QsIG9wdClcbiAgdGhpcy53cml0YWJsZSA9IHRydWVcbiAgdGhpcy5yZWFkYWJsZSA9IHRydWVcblxuXG4gIHZhciBtZSA9IHRoaXNcblxuICB0aGlzLl9wYXJzZXIub25lbmQgPSBmdW5jdGlvbiAoKSB7XG4gICAgbWUuZW1pdChcImVuZFwiKVxuICB9XG5cbiAgdGhpcy5fcGFyc2VyLm9uZXJyb3IgPSBmdW5jdGlvbiAoZXIpIHtcbiAgICBtZS5lbWl0KFwiZXJyb3JcIiwgZXIpXG5cbiAgICAvLyBpZiBkaWRuJ3QgdGhyb3csIHRoZW4gbWVhbnMgZXJyb3Igd2FzIGhhbmRsZWQuXG4gICAgLy8gZ28gYWhlYWQgYW5kIGNsZWFyIGVycm9yLCBzbyB3ZSBjYW4gd3JpdGUgYWdhaW4uXG4gICAgbWUuX3BhcnNlci5lcnJvciA9IG51bGxcbiAgfVxuXG4gIHRoaXMuX2RlY29kZXIgPSBudWxsO1xuXG4gIHN0cmVhbVdyYXBzLmZvckVhY2goZnVuY3Rpb24gKGV2KSB7XG4gICAgT2JqZWN0LmRlZmluZVByb3BlcnR5KG1lLCBcIm9uXCIgKyBldiwge1xuICAgICAgZ2V0OiBmdW5jdGlvbiAoKSB7IHJldHVybiBtZS5fcGFyc2VyW1wib25cIiArIGV2XSB9LFxuICAgICAgc2V0OiBmdW5jdGlvbiAoaCkge1xuICAgICAgICBpZiAoIWgpIHtcbiAgICAgICAgICBtZS5yZW1vdmVBbGxMaXN0ZW5lcnMoZXYpXG4gICAgICAgICAgcmV0dXJuIG1lLl9wYXJzZXJbXCJvblwiK2V2XSA9IGhcbiAgICAgICAgfVxuICAgICAgICBtZS5vbihldiwgaClcbiAgICAgIH0sXG4gICAgICBlbnVtZXJhYmxlOiB0cnVlLFxuICAgICAgY29uZmlndXJhYmxlOiBmYWxzZVxuICAgIH0pXG4gIH0pXG59XG5cblNBWFN0cmVhbS5wcm90b3R5cGUgPSBPYmplY3QuY3JlYXRlKFN0cmVhbS5wcm90b3R5cGUsXG4gIHsgY29uc3RydWN0b3I6IHsgdmFsdWU6IFNBWFN0cmVhbSB9IH0pXG5cblNBWFN0cmVhbS5wcm90b3R5cGUud3JpdGUgPSBmdW5jdGlvbiAoZGF0YSkge1xuICBpZiAodHlwZW9mIEJ1ZmZlciA9PT0gJ2Z1bmN0aW9uJyAmJlxuICAgICAgdHlwZW9mIEJ1ZmZlci5pc0J1ZmZlciA9PT0gJ2Z1bmN0aW9uJyAmJlxuICAgICAgQnVmZmVyLmlzQnVmZmVyKGRhdGEpKSB7XG4gICAgaWYgKCF0aGlzLl9kZWNvZGVyKSB7XG4gICAgICB2YXIgU0QgPSByZXF1aXJlKCdzdHJpbmdfZGVjb2RlcicpLlN0cmluZ0RlY29kZXJcbiAgICAgIHRoaXMuX2RlY29kZXIgPSBuZXcgU0QoJ3V0ZjgnKVxuICAgIH1cbiAgICBkYXRhID0gdGhpcy5fZGVjb2Rlci53cml0ZShkYXRhKTtcbiAgfVxuXG4gIHRoaXMuX3BhcnNlci53cml0ZShkYXRhLnRvU3RyaW5nKCkpXG4gIHRoaXMuZW1pdChcImRhdGFcIiwgZGF0YSlcbiAgcmV0dXJuIHRydWVcbn1cblxuU0FYU3RyZWFtLnByb3RvdHlwZS5lbmQgPSBmdW5jdGlvbiAoY2h1bmspIHtcbiAgaWYgKGNodW5rICYmIGNodW5rLmxlbmd0aCkgdGhpcy53cml0ZShjaHVuaylcbiAgdGhpcy5fcGFyc2VyLmVuZCgpXG4gIHJldHVybiB0cnVlXG59XG5cblNBWFN0cmVhbS5wcm90b3R5cGUub24gPSBmdW5jdGlvbiAoZXYsIGhhbmRsZXIpIHtcbiAgdmFyIG1lID0gdGhpc1xuICBpZiAoIW1lLl9wYXJzZXJbXCJvblwiK2V2XSAmJiBzdHJlYW1XcmFwcy5pbmRleE9mKGV2KSAhPT0gLTEpIHtcbiAgICBtZS5fcGFyc2VyW1wib25cIitldl0gPSBmdW5jdGlvbiAoKSB7XG4gICAgICB2YXIgYXJncyA9IGFyZ3VtZW50cy5sZW5ndGggPT09IDEgPyBbYXJndW1lbnRzWzBdXVxuICAgICAgICAgICAgICAgOiBBcnJheS5hcHBseShudWxsLCBhcmd1bWVudHMpXG4gICAgICBhcmdzLnNwbGljZSgwLCAwLCBldilcbiAgICAgIG1lLmVtaXQuYXBwbHkobWUsIGFyZ3MpXG4gICAgfVxuICB9XG5cbiAgcmV0dXJuIFN0cmVhbS5wcm90b3R5cGUub24uY2FsbChtZSwgZXYsIGhhbmRsZXIpXG59XG5cblxuXG4vLyBjaGFyYWN0ZXIgY2xhc3NlcyBhbmQgdG9rZW5zXG52YXIgd2hpdGVzcGFjZSA9IFwiXFxyXFxuXFx0IFwiXG4gIC8vIHRoaXMgcmVhbGx5IG5lZWRzIHRvIGJlIHJlcGxhY2VkIHdpdGggY2hhcmFjdGVyIGNsYXNzZXMuXG4gIC8vIFhNTCBhbGxvd3MgYWxsIG1hbm5lciBvZiByaWRpY3Vsb3VzIG51bWJlcnMgYW5kIGRpZ2l0cy5cbiAgLCBudW1iZXIgPSBcIjAxMjQzNTY3ODlcIlxuICAsIGxldHRlciA9IFwiYWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4eXpBQkNERUZHSElKS0xNTk9QUVJTVFVWV1hZWlwiXG4gIC8vIChMZXR0ZXIgfCBcIl9cIiB8IFwiOlwiKVxuICAsIHF1b3RlID0gXCInXFxcIlwiXG4gICwgZW50aXR5ID0gbnVtYmVyK2xldHRlcitcIiNcIlxuICAsIGF0dHJpYkVuZCA9IHdoaXRlc3BhY2UgKyBcIj5cIlxuICAsIENEQVRBID0gXCJbQ0RBVEFbXCJcbiAgLCBET0NUWVBFID0gXCJET0NUWVBFXCJcbiAgLCBYTUxfTkFNRVNQQUNFID0gXCJodHRwOi8vd3d3LnczLm9yZy9YTUwvMTk5OC9uYW1lc3BhY2VcIlxuICAsIFhNTE5TX05BTUVTUEFDRSA9IFwiaHR0cDovL3d3dy53My5vcmcvMjAwMC94bWxucy9cIlxuICAsIHJvb3ROUyA9IHsgeG1sOiBYTUxfTkFNRVNQQUNFLCB4bWxuczogWE1MTlNfTkFNRVNQQUNFIH1cblxuLy8gdHVybiBhbGwgdGhlIHN0cmluZyBjaGFyYWN0ZXIgc2V0cyBpbnRvIGNoYXJhY3RlciBjbGFzcyBvYmplY3RzLlxud2hpdGVzcGFjZSA9IGNoYXJDbGFzcyh3aGl0ZXNwYWNlKVxubnVtYmVyID0gY2hhckNsYXNzKG51bWJlcilcbmxldHRlciA9IGNoYXJDbGFzcyhsZXR0ZXIpXG5cbi8vIGh0dHA6Ly93d3cudzMub3JnL1RSL1JFQy14bWwvI05ULU5hbWVTdGFydENoYXJcbi8vIFRoaXMgaW1wbGVtZW50YXRpb24gd29ya3Mgb24gc3RyaW5ncywgYSBzaW5nbGUgY2hhcmFjdGVyIGF0IGEgdGltZVxuLy8gYXMgc3VjaCwgaXQgY2Fubm90IGV2ZXIgc3VwcG9ydCBhc3RyYWwtcGxhbmUgY2hhcmFjdGVycyAoMTAwMDAtRUZGRkYpXG4vLyB3aXRob3V0IGEgc2lnbmlmaWNhbnQgYnJlYWtpbmcgY2hhbmdlIHRvIGVpdGhlciB0aGlzICBwYXJzZXIsIG9yIHRoZVxuLy8gSmF2YVNjcmlwdCBsYW5ndWFnZS4gIEltcGxlbWVudGF0aW9uIG9mIGFuIGVtb2ppLWNhcGFibGUgeG1sIHBhcnNlclxuLy8gaXMgbGVmdCBhcyBhbiBleGVyY2lzZSBmb3IgdGhlIHJlYWRlci5cbnZhciBuYW1lU3RhcnQgPSAvWzpfQS1aYS16XFx1MDBDMC1cXHUwMEQ2XFx1MDBEOC1cXHUwMEY2XFx1MDBGOC1cXHUwMkZGXFx1MDM3MC1cXHUwMzdEXFx1MDM3Ri1cXHUxRkZGXFx1MjAwQy1cXHUyMDBEXFx1MjA3MC1cXHUyMThGXFx1MkMwMC1cXHUyRkVGXFx1MzAwMS1cXHVEN0ZGXFx1RjkwMC1cXHVGRENGXFx1RkRGMC1cXHVGRkZEXS9cblxudmFyIG5hbWVCb2R5ID0gL1s6X0EtWmEtelxcdTAwQzAtXFx1MDBENlxcdTAwRDgtXFx1MDBGNlxcdTAwRjgtXFx1MDJGRlxcdTAzNzAtXFx1MDM3RFxcdTAzN0YtXFx1MUZGRlxcdTIwMEMtXFx1MjAwRFxcdTIwNzAtXFx1MjE4RlxcdTJDMDAtXFx1MkZFRlxcdTMwMDEtXFx1RDdGRlxcdUY5MDAtXFx1RkRDRlxcdUZERjAtXFx1RkZGRFxcdTAwQjdcXHUwMzAwLVxcdTAzNkZcXHUyMDNGLVxcdTIwNDBcXC5cXGQtXS9cblxucXVvdGUgPSBjaGFyQ2xhc3MocXVvdGUpXG5lbnRpdHkgPSBjaGFyQ2xhc3MoZW50aXR5KVxuYXR0cmliRW5kID0gY2hhckNsYXNzKGF0dHJpYkVuZClcblxuZnVuY3Rpb24gY2hhckNsYXNzIChzdHIpIHtcbiAgcmV0dXJuIHN0ci5zcGxpdChcIlwiKS5yZWR1Y2UoZnVuY3Rpb24gKHMsIGMpIHtcbiAgICBzW2NdID0gdHJ1ZVxuICAgIHJldHVybiBzXG4gIH0sIHt9KVxufVxuXG5mdW5jdGlvbiBpc1JlZ0V4cCAoYykge1xuICByZXR1cm4gT2JqZWN0LnByb3RvdHlwZS50b1N0cmluZy5jYWxsKGMpID09PSAnW29iamVjdCBSZWdFeHBdJ1xufVxuXG5mdW5jdGlvbiBpcyAoY2hhcmNsYXNzLCBjKSB7XG4gIHJldHVybiBpc1JlZ0V4cChjaGFyY2xhc3MpID8gISFjLm1hdGNoKGNoYXJjbGFzcykgOiBjaGFyY2xhc3NbY11cbn1cblxuZnVuY3Rpb24gbm90IChjaGFyY2xhc3MsIGMpIHtcbiAgcmV0dXJuICFpcyhjaGFyY2xhc3MsIGMpXG59XG5cbnZhciBTID0gMFxuc2F4LlNUQVRFID1cbnsgQkVHSU4gICAgICAgICAgICAgICAgICAgICA6IFMrK1xuLCBURVhUICAgICAgICAgICAgICAgICAgICAgIDogUysrIC8vIGdlbmVyYWwgc3R1ZmZcbiwgVEVYVF9FTlRJVFkgICAgICAgICAgICAgICA6IFMrKyAvLyAmYW1wIGFuZCBzdWNoLlxuLCBPUEVOX1dBS0EgICAgICAgICAgICAgICAgIDogUysrIC8vIDxcbiwgU0dNTF9ERUNMICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IUJMQVJHXG4sIFNHTUxfREVDTF9RVU9URUQgICAgICAgICAgOiBTKysgLy8gPCFCTEFSRyBmb28gXCJiYXJcbiwgRE9DVFlQRSAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEVcbiwgRE9DVFlQRV9RVU9URUQgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcbiwgRE9DVFlQRV9EVEQgICAgICAgICAgICAgICA6IFMrKyAvLyA8IURPQ1RZUEUgXCIvL2JsYWhcIiBbIC4uLlxuLCBET0NUWVBFX0RURF9RVU9URUQgICAgICAgIDogUysrIC8vIDwhRE9DVFlQRSBcIi8vYmxhaFwiIFsgXCJmb29cbiwgQ09NTUVOVF9TVEFSVElORyAgICAgICAgICA6IFMrKyAvLyA8IS1cbiwgQ09NTUVOVCAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tXG4sIENPTU1FTlRfRU5ESU5HICAgICAgICAgICAgOiBTKysgLy8gPCEtLSBibGFoIC1cbiwgQ09NTUVOVF9FTkRFRCAgICAgICAgICAgICA6IFMrKyAvLyA8IS0tIGJsYWggLS1cbiwgQ0RBVEEgICAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8IVtDREFUQVsgc29tZXRoaW5nXG4sIENEQVRBX0VORElORyAgICAgICAgICAgICAgOiBTKysgLy8gXVxuLCBDREFUQV9FTkRJTkdfMiAgICAgICAgICAgIDogUysrIC8vIF1dXG4sIFBST0NfSU5TVCAgICAgICAgICAgICAgICAgOiBTKysgLy8gPD9oaVxuLCBQUk9DX0lOU1RfQk9EWSAgICAgICAgICAgIDogUysrIC8vIDw/aGkgdGhlcmVcbiwgUFJPQ19JTlNUX0VORElORyAgICAgICAgICA6IFMrKyAvLyA8P2hpIFwidGhlcmVcIiA/XG4sIE9QRU5fVEFHICAgICAgICAgICAgICAgICAgOiBTKysgLy8gPHN0cm9uZ1xuLCBPUEVOX1RBR19TTEFTSCAgICAgICAgICAgIDogUysrIC8vIDxzdHJvbmcgL1xuLCBBVFRSSUIgICAgICAgICAgICAgICAgICAgIDogUysrIC8vIDxhXG4sIEFUVFJJQl9OQU1FICAgICAgICAgICAgICAgOiBTKysgLy8gPGEgZm9vXG4sIEFUVFJJQl9OQU1FX1NBV19XSElURSAgICAgOiBTKysgLy8gPGEgZm9vIF9cbiwgQVRUUklCX1ZBTFVFICAgICAgICAgICAgICA6IFMrKyAvLyA8YSBmb289XG4sIEFUVFJJQl9WQUxVRV9RVU9URUQgICAgICAgOiBTKysgLy8gPGEgZm9vPVwiYmFyXG4sIEFUVFJJQl9WQUxVRV9DTE9TRUQgICAgICAgOiBTKysgLy8gPGEgZm9vPVwiYmFyXCJcbiwgQVRUUklCX1ZBTFVFX1VOUVVPVEVEICAgICA6IFMrKyAvLyA8YSBmb289YmFyXG4sIEFUVFJJQl9WQUxVRV9FTlRJVFlfUSAgICAgOiBTKysgLy8gPGZvbyBiYXI9XCImcXVvdDtcIlxuLCBBVFRSSUJfVkFMVUVfRU5USVRZX1UgICAgIDogUysrIC8vIDxmb28gYmFyPSZxdW90O1xuLCBDTE9TRV9UQUcgICAgICAgICAgICAgICAgIDogUysrIC8vIDwvYVxuLCBDTE9TRV9UQUdfU0FXX1dISVRFICAgICAgIDogUysrIC8vIDwvYSAgID5cbiwgU0NSSVBUICAgICAgICAgICAgICAgICAgICA6IFMrKyAvLyA8c2NyaXB0PiAuLi5cbiwgU0NSSVBUX0VORElORyAgICAgICAgICAgICA6IFMrKyAvLyA8c2NyaXB0PiAuLi4gPFxufVxuXG5zYXguRU5USVRJRVMgPVxueyBcImFtcFwiIDogXCImXCJcbiwgXCJndFwiIDogXCI+XCJcbiwgXCJsdFwiIDogXCI8XCJcbiwgXCJxdW90XCIgOiBcIlxcXCJcIlxuLCBcImFwb3NcIiA6IFwiJ1wiXG4sIFwiQUVsaWdcIiA6IDE5OFxuLCBcIkFhY3V0ZVwiIDogMTkzXG4sIFwiQWNpcmNcIiA6IDE5NFxuLCBcIkFncmF2ZVwiIDogMTkyXG4sIFwiQXJpbmdcIiA6IDE5N1xuLCBcIkF0aWxkZVwiIDogMTk1XG4sIFwiQXVtbFwiIDogMTk2XG4sIFwiQ2NlZGlsXCIgOiAxOTlcbiwgXCJFVEhcIiA6IDIwOFxuLCBcIkVhY3V0ZVwiIDogMjAxXG4sIFwiRWNpcmNcIiA6IDIwMlxuLCBcIkVncmF2ZVwiIDogMjAwXG4sIFwiRXVtbFwiIDogMjAzXG4sIFwiSWFjdXRlXCIgOiAyMDVcbiwgXCJJY2lyY1wiIDogMjA2XG4sIFwiSWdyYXZlXCIgOiAyMDRcbiwgXCJJdW1sXCIgOiAyMDdcbiwgXCJOdGlsZGVcIiA6IDIwOVxuLCBcIk9hY3V0ZVwiIDogMjExXG4sIFwiT2NpcmNcIiA6IDIxMlxuLCBcIk9ncmF2ZVwiIDogMjEwXG4sIFwiT3NsYXNoXCIgOiAyMTZcbiwgXCJPdGlsZGVcIiA6IDIxM1xuLCBcIk91bWxcIiA6IDIxNFxuLCBcIlRIT1JOXCIgOiAyMjJcbiwgXCJVYWN1dGVcIiA6IDIxOFxuLCBcIlVjaXJjXCIgOiAyMTlcbiwgXCJVZ3JhdmVcIiA6IDIxN1xuLCBcIlV1bWxcIiA6IDIyMFxuLCBcIllhY3V0ZVwiIDogMjIxXG4sIFwiYWFjdXRlXCIgOiAyMjVcbiwgXCJhY2lyY1wiIDogMjI2XG4sIFwiYWVsaWdcIiA6IDIzMFxuLCBcImFncmF2ZVwiIDogMjI0XG4sIFwiYXJpbmdcIiA6IDIyOVxuLCBcImF0aWxkZVwiIDogMjI3XG4sIFwiYXVtbFwiIDogMjI4XG4sIFwiY2NlZGlsXCIgOiAyMzFcbiwgXCJlYWN1dGVcIiA6IDIzM1xuLCBcImVjaXJjXCIgOiAyMzRcbiwgXCJlZ3JhdmVcIiA6IDIzMlxuLCBcImV0aFwiIDogMjQwXG4sIFwiZXVtbFwiIDogMjM1XG4sIFwiaWFjdXRlXCIgOiAyMzdcbiwgXCJpY2lyY1wiIDogMjM4XG4sIFwiaWdyYXZlXCIgOiAyMzZcbiwgXCJpdW1sXCIgOiAyMzlcbiwgXCJudGlsZGVcIiA6IDI0MVxuLCBcIm9hY3V0ZVwiIDogMjQzXG4sIFwib2NpcmNcIiA6IDI0NFxuLCBcIm9ncmF2ZVwiIDogMjQyXG4sIFwib3NsYXNoXCIgOiAyNDhcbiwgXCJvdGlsZGVcIiA6IDI0NVxuLCBcIm91bWxcIiA6IDI0NlxuLCBcInN6bGlnXCIgOiAyMjNcbiwgXCJ0aG9yblwiIDogMjU0XG4sIFwidWFjdXRlXCIgOiAyNTBcbiwgXCJ1Y2lyY1wiIDogMjUxXG4sIFwidWdyYXZlXCIgOiAyNDlcbiwgXCJ1dW1sXCIgOiAyNTJcbiwgXCJ5YWN1dGVcIiA6IDI1M1xuLCBcInl1bWxcIiA6IDI1NVxuLCBcImNvcHlcIiA6IDE2OVxuLCBcInJlZ1wiIDogMTc0XG4sIFwibmJzcFwiIDogMTYwXG4sIFwiaWV4Y2xcIiA6IDE2MVxuLCBcImNlbnRcIiA6IDE2MlxuLCBcInBvdW5kXCIgOiAxNjNcbiwgXCJjdXJyZW5cIiA6IDE2NFxuLCBcInllblwiIDogMTY1XG4sIFwiYnJ2YmFyXCIgOiAxNjZcbiwgXCJzZWN0XCIgOiAxNjdcbiwgXCJ1bWxcIiA6IDE2OFxuLCBcIm9yZGZcIiA6IDE3MFxuLCBcImxhcXVvXCIgOiAxNzFcbiwgXCJub3RcIiA6IDE3MlxuLCBcInNoeVwiIDogMTczXG4sIFwibWFjclwiIDogMTc1XG4sIFwiZGVnXCIgOiAxNzZcbiwgXCJwbHVzbW5cIiA6IDE3N1xuLCBcInN1cDFcIiA6IDE4NVxuLCBcInN1cDJcIiA6IDE3OFxuLCBcInN1cDNcIiA6IDE3OVxuLCBcImFjdXRlXCIgOiAxODBcbiwgXCJtaWNyb1wiIDogMTgxXG4sIFwicGFyYVwiIDogMTgyXG4sIFwibWlkZG90XCIgOiAxODNcbiwgXCJjZWRpbFwiIDogMTg0XG4sIFwib3JkbVwiIDogMTg2XG4sIFwicmFxdW9cIiA6IDE4N1xuLCBcImZyYWMxNFwiIDogMTg4XG4sIFwiZnJhYzEyXCIgOiAxODlcbiwgXCJmcmFjMzRcIiA6IDE5MFxuLCBcImlxdWVzdFwiIDogMTkxXG4sIFwidGltZXNcIiA6IDIxNVxuLCBcImRpdmlkZVwiIDogMjQ3XG4sIFwiT0VsaWdcIiA6IDMzOFxuLCBcIm9lbGlnXCIgOiAzMzlcbiwgXCJTY2Fyb25cIiA6IDM1MlxuLCBcInNjYXJvblwiIDogMzUzXG4sIFwiWXVtbFwiIDogMzc2XG4sIFwiZm5vZlwiIDogNDAyXG4sIFwiY2lyY1wiIDogNzEwXG4sIFwidGlsZGVcIiA6IDczMlxuLCBcIkFscGhhXCIgOiA5MTNcbiwgXCJCZXRhXCIgOiA5MTRcbiwgXCJHYW1tYVwiIDogOTE1XG4sIFwiRGVsdGFcIiA6IDkxNlxuLCBcIkVwc2lsb25cIiA6IDkxN1xuLCBcIlpldGFcIiA6IDkxOFxuLCBcIkV0YVwiIDogOTE5XG4sIFwiVGhldGFcIiA6IDkyMFxuLCBcIklvdGFcIiA6IDkyMVxuLCBcIkthcHBhXCIgOiA5MjJcbiwgXCJMYW1iZGFcIiA6IDkyM1xuLCBcIk11XCIgOiA5MjRcbiwgXCJOdVwiIDogOTI1XG4sIFwiWGlcIiA6IDkyNlxuLCBcIk9taWNyb25cIiA6IDkyN1xuLCBcIlBpXCIgOiA5MjhcbiwgXCJSaG9cIiA6IDkyOVxuLCBcIlNpZ21hXCIgOiA5MzFcbiwgXCJUYXVcIiA6IDkzMlxuLCBcIlVwc2lsb25cIiA6IDkzM1xuLCBcIlBoaVwiIDogOTM0XG4sIFwiQ2hpXCIgOiA5MzVcbiwgXCJQc2lcIiA6IDkzNlxuLCBcIk9tZWdhXCIgOiA5MzdcbiwgXCJhbHBoYVwiIDogOTQ1XG4sIFwiYmV0YVwiIDogOTQ2XG4sIFwiZ2FtbWFcIiA6IDk0N1xuLCBcImRlbHRhXCIgOiA5NDhcbiwgXCJlcHNpbG9uXCIgOiA5NDlcbiwgXCJ6ZXRhXCIgOiA5NTBcbiwgXCJldGFcIiA6IDk1MVxuLCBcInRoZXRhXCIgOiA5NTJcbiwgXCJpb3RhXCIgOiA5NTNcbiwgXCJrYXBwYVwiIDogOTU0XG4sIFwibGFtYmRhXCIgOiA5NTVcbiwgXCJtdVwiIDogOTU2XG4sIFwibnVcIiA6IDk1N1xuLCBcInhpXCIgOiA5NThcbiwgXCJvbWljcm9uXCIgOiA5NTlcbiwgXCJwaVwiIDogOTYwXG4sIFwicmhvXCIgOiA5NjFcbiwgXCJzaWdtYWZcIiA6IDk2MlxuLCBcInNpZ21hXCIgOiA5NjNcbiwgXCJ0YXVcIiA6IDk2NFxuLCBcInVwc2lsb25cIiA6IDk2NVxuLCBcInBoaVwiIDogOTY2XG4sIFwiY2hpXCIgOiA5NjdcbiwgXCJwc2lcIiA6IDk2OFxuLCBcIm9tZWdhXCIgOiA5NjlcbiwgXCJ0aGV0YXN5bVwiIDogOTc3XG4sIFwidXBzaWhcIiA6IDk3OFxuLCBcInBpdlwiIDogOTgyXG4sIFwiZW5zcFwiIDogODE5NFxuLCBcImVtc3BcIiA6IDgxOTVcbiwgXCJ0aGluc3BcIiA6IDgyMDFcbiwgXCJ6d25qXCIgOiA4MjA0XG4sIFwiendqXCIgOiA4MjA1XG4sIFwibHJtXCIgOiA4MjA2XG4sIFwicmxtXCIgOiA4MjA3XG4sIFwibmRhc2hcIiA6IDgyMTFcbiwgXCJtZGFzaFwiIDogODIxMlxuLCBcImxzcXVvXCIgOiA4MjE2XG4sIFwicnNxdW9cIiA6IDgyMTdcbiwgXCJzYnF1b1wiIDogODIxOFxuLCBcImxkcXVvXCIgOiA4MjIwXG4sIFwicmRxdW9cIiA6IDgyMjFcbiwgXCJiZHF1b1wiIDogODIyMlxuLCBcImRhZ2dlclwiIDogODIyNFxuLCBcIkRhZ2dlclwiIDogODIyNVxuLCBcImJ1bGxcIiA6IDgyMjZcbiwgXCJoZWxsaXBcIiA6IDgyMzBcbiwgXCJwZXJtaWxcIiA6IDgyNDBcbiwgXCJwcmltZVwiIDogODI0MlxuLCBcIlByaW1lXCIgOiA4MjQzXG4sIFwibHNhcXVvXCIgOiA4MjQ5XG4sIFwicnNhcXVvXCIgOiA4MjUwXG4sIFwib2xpbmVcIiA6IDgyNTRcbiwgXCJmcmFzbFwiIDogODI2MFxuLCBcImV1cm9cIiA6IDgzNjRcbiwgXCJpbWFnZVwiIDogODQ2NVxuLCBcIndlaWVycFwiIDogODQ3MlxuLCBcInJlYWxcIiA6IDg0NzZcbiwgXCJ0cmFkZVwiIDogODQ4MlxuLCBcImFsZWZzeW1cIiA6IDg1MDFcbiwgXCJsYXJyXCIgOiA4NTkyXG4sIFwidWFyclwiIDogODU5M1xuLCBcInJhcnJcIiA6IDg1OTRcbiwgXCJkYXJyXCIgOiA4NTk1XG4sIFwiaGFyclwiIDogODU5NlxuLCBcImNyYXJyXCIgOiA4NjI5XG4sIFwibEFyclwiIDogODY1NlxuLCBcInVBcnJcIiA6IDg2NTdcbiwgXCJyQXJyXCIgOiA4NjU4XG4sIFwiZEFyclwiIDogODY1OVxuLCBcImhBcnJcIiA6IDg2NjBcbiwgXCJmb3JhbGxcIiA6IDg3MDRcbiwgXCJwYXJ0XCIgOiA4NzA2XG4sIFwiZXhpc3RcIiA6IDg3MDdcbiwgXCJlbXB0eVwiIDogODcwOVxuLCBcIm5hYmxhXCIgOiA4NzExXG4sIFwiaXNpblwiIDogODcxMlxuLCBcIm5vdGluXCIgOiA4NzEzXG4sIFwibmlcIiA6IDg3MTVcbiwgXCJwcm9kXCIgOiA4NzE5XG4sIFwic3VtXCIgOiA4NzIxXG4sIFwibWludXNcIiA6IDg3MjJcbiwgXCJsb3dhc3RcIiA6IDg3MjdcbiwgXCJyYWRpY1wiIDogODczMFxuLCBcInByb3BcIiA6IDg3MzNcbiwgXCJpbmZpblwiIDogODczNFxuLCBcImFuZ1wiIDogODczNlxuLCBcImFuZFwiIDogODc0M1xuLCBcIm9yXCIgOiA4NzQ0XG4sIFwiY2FwXCIgOiA4NzQ1XG4sIFwiY3VwXCIgOiA4NzQ2XG4sIFwiaW50XCIgOiA4NzQ3XG4sIFwidGhlcmU0XCIgOiA4NzU2XG4sIFwic2ltXCIgOiA4NzY0XG4sIFwiY29uZ1wiIDogODc3M1xuLCBcImFzeW1wXCIgOiA4Nzc2XG4sIFwibmVcIiA6IDg4MDBcbiwgXCJlcXVpdlwiIDogODgwMVxuLCBcImxlXCIgOiA4ODA0XG4sIFwiZ2VcIiA6IDg4MDVcbiwgXCJzdWJcIiA6IDg4MzRcbiwgXCJzdXBcIiA6IDg4MzVcbiwgXCJuc3ViXCIgOiA4ODM2XG4sIFwic3ViZVwiIDogODgzOFxuLCBcInN1cGVcIiA6IDg4MzlcbiwgXCJvcGx1c1wiIDogODg1M1xuLCBcIm90aW1lc1wiIDogODg1NVxuLCBcInBlcnBcIiA6IDg4NjlcbiwgXCJzZG90XCIgOiA4OTAxXG4sIFwibGNlaWxcIiA6IDg5NjhcbiwgXCJyY2VpbFwiIDogODk2OVxuLCBcImxmbG9vclwiIDogODk3MFxuLCBcInJmbG9vclwiIDogODk3MVxuLCBcImxhbmdcIiA6IDkwMDFcbiwgXCJyYW5nXCIgOiA5MDAyXG4sIFwibG96XCIgOiA5Njc0XG4sIFwic3BhZGVzXCIgOiA5ODI0XG4sIFwiY2x1YnNcIiA6IDk4MjdcbiwgXCJoZWFydHNcIiA6IDk4MjlcbiwgXCJkaWFtc1wiIDogOTgzMFxufVxuXG5PYmplY3Qua2V5cyhzYXguRU5USVRJRVMpLmZvckVhY2goZnVuY3Rpb24gKGtleSkge1xuICAgIHZhciBlID0gc2F4LkVOVElUSUVTW2tleV1cbiAgICB2YXIgcyA9IHR5cGVvZiBlID09PSAnbnVtYmVyJyA/IFN0cmluZy5mcm9tQ2hhckNvZGUoZSkgOiBlXG4gICAgc2F4LkVOVElUSUVTW2tleV0gPSBzXG59KVxuXG5mb3IgKHZhciBTIGluIHNheC5TVEFURSkgc2F4LlNUQVRFW3NheC5TVEFURVtTXV0gPSBTXG5cbi8vIHNob3J0aGFuZFxuUyA9IHNheC5TVEFURVxuXG5mdW5jdGlvbiBlbWl0IChwYXJzZXIsIGV2ZW50LCBkYXRhKSB7XG4gIHBhcnNlcltldmVudF0gJiYgcGFyc2VyW2V2ZW50XShkYXRhKVxufVxuXG5mdW5jdGlvbiBlbWl0Tm9kZSAocGFyc2VyLCBub2RlVHlwZSwgZGF0YSkge1xuICBpZiAocGFyc2VyLnRleHROb2RlKSBjbG9zZVRleHQocGFyc2VyKVxuICBlbWl0KHBhcnNlciwgbm9kZVR5cGUsIGRhdGEpXG59XG5cbmZ1bmN0aW9uIGNsb3NlVGV4dCAocGFyc2VyKSB7XG4gIHBhcnNlci50ZXh0Tm9kZSA9IHRleHRvcHRzKHBhcnNlci5vcHQsIHBhcnNlci50ZXh0Tm9kZSlcbiAgaWYgKHBhcnNlci50ZXh0Tm9kZSkgZW1pdChwYXJzZXIsIFwib250ZXh0XCIsIHBhcnNlci50ZXh0Tm9kZSlcbiAgcGFyc2VyLnRleHROb2RlID0gXCJcIlxufVxuXG5mdW5jdGlvbiB0ZXh0b3B0cyAob3B0LCB0ZXh0KSB7XG4gIGlmIChvcHQudHJpbSkgdGV4dCA9IHRleHQudHJpbSgpXG4gIGlmIChvcHQubm9ybWFsaXplKSB0ZXh0ID0gdGV4dC5yZXBsYWNlKC9cXHMrL2csIFwiIFwiKVxuICByZXR1cm4gdGV4dFxufVxuXG5mdW5jdGlvbiBlcnJvciAocGFyc2VyLCBlcikge1xuICBjbG9zZVRleHQocGFyc2VyKVxuICBpZiAocGFyc2VyLnRyYWNrUG9zaXRpb24pIHtcbiAgICBlciArPSBcIlxcbkxpbmU6IFwiK3BhcnNlci5saW5lK1xuICAgICAgICAgIFwiXFxuQ29sdW1uOiBcIitwYXJzZXIuY29sdW1uK1xuICAgICAgICAgIFwiXFxuQ2hhcjogXCIrcGFyc2VyLmNcbiAgfVxuICBlciA9IG5ldyBFcnJvcihlcilcbiAgcGFyc2VyLmVycm9yID0gZXJcbiAgZW1pdChwYXJzZXIsIFwib25lcnJvclwiLCBlcilcbiAgcmV0dXJuIHBhcnNlclxufVxuXG5mdW5jdGlvbiBlbmQgKHBhcnNlcikge1xuICBpZiAoIXBhcnNlci5jbG9zZWRSb290KSBzdHJpY3RGYWlsKHBhcnNlciwgXCJVbmNsb3NlZCByb290IHRhZ1wiKVxuICBpZiAoKHBhcnNlci5zdGF0ZSAhPT0gUy5CRUdJTikgJiYgKHBhcnNlci5zdGF0ZSAhPT0gUy5URVhUKSkgZXJyb3IocGFyc2VyLCBcIlVuZXhwZWN0ZWQgZW5kXCIpXG4gIGNsb3NlVGV4dChwYXJzZXIpXG4gIHBhcnNlci5jID0gXCJcIlxuICBwYXJzZXIuY2xvc2VkID0gdHJ1ZVxuICBlbWl0KHBhcnNlciwgXCJvbmVuZFwiKVxuICBTQVhQYXJzZXIuY2FsbChwYXJzZXIsIHBhcnNlci5zdHJpY3QsIHBhcnNlci5vcHQpXG4gIHJldHVybiBwYXJzZXJcbn1cblxuZnVuY3Rpb24gc3RyaWN0RmFpbCAocGFyc2VyLCBtZXNzYWdlKSB7XG4gIGlmICh0eXBlb2YgcGFyc2VyICE9PSAnb2JqZWN0JyB8fCAhKHBhcnNlciBpbnN0YW5jZW9mIFNBWFBhcnNlcikpXG4gICAgdGhyb3cgbmV3IEVycm9yKCdiYWQgY2FsbCB0byBzdHJpY3RGYWlsJyk7XG4gIGlmIChwYXJzZXIuc3RyaWN0KSBlcnJvcihwYXJzZXIsIG1lc3NhZ2UpXG59XG5cbmZ1bmN0aW9uIG5ld1RhZyAocGFyc2VyKSB7XG4gIGlmICghcGFyc2VyLnN0cmljdCkgcGFyc2VyLnRhZ05hbWUgPSBwYXJzZXIudGFnTmFtZVtwYXJzZXIubG9vc2VDYXNlXSgpXG4gIHZhciBwYXJlbnQgPSBwYXJzZXIudGFnc1twYXJzZXIudGFncy5sZW5ndGggLSAxXSB8fCBwYXJzZXJcbiAgICAsIHRhZyA9IHBhcnNlci50YWcgPSB7IG5hbWUgOiBwYXJzZXIudGFnTmFtZSwgYXR0cmlidXRlcyA6IHt9IH1cblxuICAvLyB3aWxsIGJlIG92ZXJyaWRkZW4gaWYgdGFnIGNvbnRhaWxzIGFuIHhtbG5zPVwiZm9vXCIgb3IgeG1sbnM6Zm9vPVwiYmFyXCJcbiAgaWYgKHBhcnNlci5vcHQueG1sbnMpIHRhZy5ucyA9IHBhcmVudC5uc1xuICBwYXJzZXIuYXR0cmliTGlzdC5sZW5ndGggPSAwXG59XG5cbmZ1bmN0aW9uIHFuYW1lIChuYW1lLCBhdHRyaWJ1dGUpIHtcbiAgdmFyIGkgPSBuYW1lLmluZGV4T2YoXCI6XCIpXG4gICAgLCBxdWFsTmFtZSA9IGkgPCAwID8gWyBcIlwiLCBuYW1lIF0gOiBuYW1lLnNwbGl0KFwiOlwiKVxuICAgICwgcHJlZml4ID0gcXVhbE5hbWVbMF1cbiAgICAsIGxvY2FsID0gcXVhbE5hbWVbMV1cblxuICAvLyA8eCBcInhtbG5zXCI9XCJodHRwOi8vZm9vXCI+XG4gIGlmIChhdHRyaWJ1dGUgJiYgbmFtZSA9PT0gXCJ4bWxuc1wiKSB7XG4gICAgcHJlZml4ID0gXCJ4bWxuc1wiXG4gICAgbG9jYWwgPSBcIlwiXG4gIH1cblxuICByZXR1cm4geyBwcmVmaXg6IHByZWZpeCwgbG9jYWw6IGxvY2FsIH1cbn1cblxuZnVuY3Rpb24gYXR0cmliIChwYXJzZXIpIHtcbiAgaWYgKCFwYXJzZXIuc3RyaWN0KSBwYXJzZXIuYXR0cmliTmFtZSA9IHBhcnNlci5hdHRyaWJOYW1lW3BhcnNlci5sb29zZUNhc2VdKClcblxuICBpZiAocGFyc2VyLmF0dHJpYkxpc3QuaW5kZXhPZihwYXJzZXIuYXR0cmliTmFtZSkgIT09IC0xIHx8XG4gICAgICBwYXJzZXIudGFnLmF0dHJpYnV0ZXMuaGFzT3duUHJvcGVydHkocGFyc2VyLmF0dHJpYk5hbWUpKSB7XG4gICAgcmV0dXJuIHBhcnNlci5hdHRyaWJOYW1lID0gcGFyc2VyLmF0dHJpYlZhbHVlID0gXCJcIlxuICB9XG5cbiAgaWYgKHBhcnNlci5vcHQueG1sbnMpIHtcbiAgICB2YXIgcW4gPSBxbmFtZShwYXJzZXIuYXR0cmliTmFtZSwgdHJ1ZSlcbiAgICAgICwgcHJlZml4ID0gcW4ucHJlZml4XG4gICAgICAsIGxvY2FsID0gcW4ubG9jYWxcblxuICAgIGlmIChwcmVmaXggPT09IFwieG1sbnNcIikge1xuICAgICAgLy8gbmFtZXNwYWNlIGJpbmRpbmcgYXR0cmlidXRlOyBwdXNoIHRoZSBiaW5kaW5nIGludG8gc2NvcGVcbiAgICAgIGlmIChsb2NhbCA9PT0gXCJ4bWxcIiAmJiBwYXJzZXIuYXR0cmliVmFsdWUgIT09IFhNTF9OQU1FU1BBQ0UpIHtcbiAgICAgICAgc3RyaWN0RmFpbCggcGFyc2VyXG4gICAgICAgICAgICAgICAgICAsIFwieG1sOiBwcmVmaXggbXVzdCBiZSBib3VuZCB0byBcIiArIFhNTF9OQU1FU1BBQ0UgKyBcIlxcblwiXG4gICAgICAgICAgICAgICAgICArIFwiQWN0dWFsOiBcIiArIHBhcnNlci5hdHRyaWJWYWx1ZSApXG4gICAgICB9IGVsc2UgaWYgKGxvY2FsID09PSBcInhtbG5zXCIgJiYgcGFyc2VyLmF0dHJpYlZhbHVlICE9PSBYTUxOU19OQU1FU1BBQ0UpIHtcbiAgICAgICAgc3RyaWN0RmFpbCggcGFyc2VyXG4gICAgICAgICAgICAgICAgICAsIFwieG1sbnM6IHByZWZpeCBtdXN0IGJlIGJvdW5kIHRvIFwiICsgWE1MTlNfTkFNRVNQQUNFICsgXCJcXG5cIlxuICAgICAgICAgICAgICAgICAgKyBcIkFjdHVhbDogXCIgKyBwYXJzZXIuYXR0cmliVmFsdWUgKVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgdmFyIHRhZyA9IHBhcnNlci50YWdcbiAgICAgICAgICAsIHBhcmVudCA9IHBhcnNlci50YWdzW3BhcnNlci50YWdzLmxlbmd0aCAtIDFdIHx8IHBhcnNlclxuICAgICAgICBpZiAodGFnLm5zID09PSBwYXJlbnQubnMpIHtcbiAgICAgICAgICB0YWcubnMgPSBPYmplY3QuY3JlYXRlKHBhcmVudC5ucylcbiAgICAgICAgfVxuICAgICAgICB0YWcubnNbbG9jYWxdID0gcGFyc2VyLmF0dHJpYlZhbHVlXG4gICAgICB9XG4gICAgfVxuXG4gICAgLy8gZGVmZXIgb25hdHRyaWJ1dGUgZXZlbnRzIHVudGlsIGFsbCBhdHRyaWJ1dGVzIGhhdmUgYmVlbiBzZWVuXG4gICAgLy8gc28gYW55IG5ldyBiaW5kaW5ncyBjYW4gdGFrZSBlZmZlY3Q7IHByZXNlcnZlIGF0dHJpYnV0ZSBvcmRlclxuICAgIC8vIHNvIGRlZmVycmVkIGV2ZW50cyBjYW4gYmUgZW1pdHRlZCBpbiBkb2N1bWVudCBvcmRlclxuICAgIHBhcnNlci5hdHRyaWJMaXN0LnB1c2goW3BhcnNlci5hdHRyaWJOYW1lLCBwYXJzZXIuYXR0cmliVmFsdWVdKVxuICB9IGVsc2Uge1xuICAgIC8vIGluIG5vbi14bWxucyBtb2RlLCB3ZSBjYW4gZW1pdCB0aGUgZXZlbnQgcmlnaHQgYXdheVxuICAgIHBhcnNlci50YWcuYXR0cmlidXRlc1twYXJzZXIuYXR0cmliTmFtZV0gPSBwYXJzZXIuYXR0cmliVmFsdWVcbiAgICBlbWl0Tm9kZSggcGFyc2VyXG4gICAgICAgICAgICAsIFwib25hdHRyaWJ1dGVcIlxuICAgICAgICAgICAgLCB7IG5hbWU6IHBhcnNlci5hdHRyaWJOYW1lXG4gICAgICAgICAgICAgICwgdmFsdWU6IHBhcnNlci5hdHRyaWJWYWx1ZSB9IClcbiAgfVxuXG4gIHBhcnNlci5hdHRyaWJOYW1lID0gcGFyc2VyLmF0dHJpYlZhbHVlID0gXCJcIlxufVxuXG5mdW5jdGlvbiBvcGVuVGFnIChwYXJzZXIsIHNlbGZDbG9zaW5nKSB7XG4gIGlmIChwYXJzZXIub3B0LnhtbG5zKSB7XG4gICAgLy8gZW1pdCBuYW1lc3BhY2UgYmluZGluZyBldmVudHNcbiAgICB2YXIgdGFnID0gcGFyc2VyLnRhZ1xuXG4gICAgLy8gYWRkIG5hbWVzcGFjZSBpbmZvIHRvIHRhZ1xuICAgIHZhciBxbiA9IHFuYW1lKHBhcnNlci50YWdOYW1lKVxuICAgIHRhZy5wcmVmaXggPSBxbi5wcmVmaXhcbiAgICB0YWcubG9jYWwgPSBxbi5sb2NhbFxuICAgIHRhZy51cmkgPSB0YWcubnNbcW4ucHJlZml4XSB8fCBcIlwiXG5cbiAgICBpZiAodGFnLnByZWZpeCAmJiAhdGFnLnVyaSkge1xuICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiVW5ib3VuZCBuYW1lc3BhY2UgcHJlZml4OiBcIlxuICAgICAgICAgICAgICAgICAgICAgICArIEpTT04uc3RyaW5naWZ5KHBhcnNlci50YWdOYW1lKSlcbiAgICAgIHRhZy51cmkgPSBxbi5wcmVmaXhcbiAgICB9XG5cbiAgICB2YXIgcGFyZW50ID0gcGFyc2VyLnRhZ3NbcGFyc2VyLnRhZ3MubGVuZ3RoIC0gMV0gfHwgcGFyc2VyXG4gICAgaWYgKHRhZy5ucyAmJiBwYXJlbnQubnMgIT09IHRhZy5ucykge1xuICAgICAgT2JqZWN0LmtleXModGFnLm5zKS5mb3JFYWNoKGZ1bmN0aW9uIChwKSB7XG4gICAgICAgIGVtaXROb2RlKCBwYXJzZXJcbiAgICAgICAgICAgICAgICAsIFwib25vcGVubmFtZXNwYWNlXCJcbiAgICAgICAgICAgICAgICAsIHsgcHJlZml4OiBwICwgdXJpOiB0YWcubnNbcF0gfSApXG4gICAgICB9KVxuICAgIH1cblxuICAgIC8vIGhhbmRsZSBkZWZlcnJlZCBvbmF0dHJpYnV0ZSBldmVudHNcbiAgICAvLyBOb3RlOiBkbyBub3QgYXBwbHkgZGVmYXVsdCBucyB0byBhdHRyaWJ1dGVzOlxuICAgIC8vICAgaHR0cDovL3d3dy53My5vcmcvVFIvUkVDLXhtbC1uYW1lcy8jZGVmYXVsdGluZ1xuICAgIGZvciAodmFyIGkgPSAwLCBsID0gcGFyc2VyLmF0dHJpYkxpc3QubGVuZ3RoOyBpIDwgbDsgaSArKykge1xuICAgICAgdmFyIG52ID0gcGFyc2VyLmF0dHJpYkxpc3RbaV1cbiAgICAgIHZhciBuYW1lID0gbnZbMF1cbiAgICAgICAgLCB2YWx1ZSA9IG52WzFdXG4gICAgICAgICwgcXVhbE5hbWUgPSBxbmFtZShuYW1lLCB0cnVlKVxuICAgICAgICAsIHByZWZpeCA9IHF1YWxOYW1lLnByZWZpeFxuICAgICAgICAsIGxvY2FsID0gcXVhbE5hbWUubG9jYWxcbiAgICAgICAgLCB1cmkgPSBwcmVmaXggPT0gXCJcIiA/IFwiXCIgOiAodGFnLm5zW3ByZWZpeF0gfHwgXCJcIilcbiAgICAgICAgLCBhID0geyBuYW1lOiBuYW1lXG4gICAgICAgICAgICAgICwgdmFsdWU6IHZhbHVlXG4gICAgICAgICAgICAgICwgcHJlZml4OiBwcmVmaXhcbiAgICAgICAgICAgICAgLCBsb2NhbDogbG9jYWxcbiAgICAgICAgICAgICAgLCB1cmk6IHVyaVxuICAgICAgICAgICAgICB9XG5cbiAgICAgIC8vIGlmIHRoZXJlJ3MgYW55IGF0dHJpYnV0ZXMgd2l0aCBhbiB1bmRlZmluZWQgbmFtZXNwYWNlLFxuICAgICAgLy8gdGhlbiBmYWlsIG9uIHRoZW0gbm93LlxuICAgICAgaWYgKHByZWZpeCAmJiBwcmVmaXggIT0gXCJ4bWxuc1wiICYmICF1cmkpIHtcbiAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiVW5ib3VuZCBuYW1lc3BhY2UgcHJlZml4OiBcIlxuICAgICAgICAgICAgICAgICAgICAgICAgICsgSlNPTi5zdHJpbmdpZnkocHJlZml4KSlcbiAgICAgICAgYS51cmkgPSBwcmVmaXhcbiAgICAgIH1cbiAgICAgIHBhcnNlci50YWcuYXR0cmlidXRlc1tuYW1lXSA9IGFcbiAgICAgIGVtaXROb2RlKHBhcnNlciwgXCJvbmF0dHJpYnV0ZVwiLCBhKVxuICAgIH1cbiAgICBwYXJzZXIuYXR0cmliTGlzdC5sZW5ndGggPSAwXG4gIH1cblxuICBwYXJzZXIudGFnLmlzU2VsZkNsb3NpbmcgPSAhIXNlbGZDbG9zaW5nXG5cbiAgLy8gcHJvY2VzcyB0aGUgdGFnXG4gIHBhcnNlci5zYXdSb290ID0gdHJ1ZVxuICBwYXJzZXIudGFncy5wdXNoKHBhcnNlci50YWcpXG4gIGVtaXROb2RlKHBhcnNlciwgXCJvbm9wZW50YWdcIiwgcGFyc2VyLnRhZylcbiAgaWYgKCFzZWxmQ2xvc2luZykge1xuICAgIC8vIHNwZWNpYWwgY2FzZSBmb3IgPHNjcmlwdD4gaW4gbm9uLXN0cmljdCBtb2RlLlxuICAgIGlmICghcGFyc2VyLm5vc2NyaXB0ICYmIHBhcnNlci50YWdOYW1lLnRvTG93ZXJDYXNlKCkgPT09IFwic2NyaXB0XCIpIHtcbiAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0NSSVBUXG4gICAgfSBlbHNlIHtcbiAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgIH1cbiAgICBwYXJzZXIudGFnID0gbnVsbFxuICAgIHBhcnNlci50YWdOYW1lID0gXCJcIlxuICB9XG4gIHBhcnNlci5hdHRyaWJOYW1lID0gcGFyc2VyLmF0dHJpYlZhbHVlID0gXCJcIlxuICBwYXJzZXIuYXR0cmliTGlzdC5sZW5ndGggPSAwXG59XG5cbmZ1bmN0aW9uIGNsb3NlVGFnIChwYXJzZXIpIHtcbiAgaWYgKCFwYXJzZXIudGFnTmFtZSkge1xuICAgIHN0cmljdEZhaWwocGFyc2VyLCBcIldlaXJkIGVtcHR5IGNsb3NlIHRhZy5cIilcbiAgICBwYXJzZXIudGV4dE5vZGUgKz0gXCI8Lz5cIlxuICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgIHJldHVyblxuICB9XG5cbiAgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICBpZiAocGFyc2VyLnRhZ05hbWUgIT09IFwic2NyaXB0XCIpIHtcbiAgICAgIHBhcnNlci5zY3JpcHQgKz0gXCI8L1wiICsgcGFyc2VyLnRhZ05hbWUgKyBcIj5cIlxuICAgICAgcGFyc2VyLnRhZ05hbWUgPSBcIlwiXG4gICAgICBwYXJzZXIuc3RhdGUgPSBTLlNDUklQVFxuICAgICAgcmV0dXJuXG4gICAgfVxuICAgIGVtaXROb2RlKHBhcnNlciwgXCJvbnNjcmlwdFwiLCBwYXJzZXIuc2NyaXB0KVxuICAgIHBhcnNlci5zY3JpcHQgPSBcIlwiXG4gIH1cblxuICAvLyBmaXJzdCBtYWtlIHN1cmUgdGhhdCB0aGUgY2xvc2luZyB0YWcgYWN0dWFsbHkgZXhpc3RzLlxuICAvLyA8YT48Yj48L2M+PC9iPjwvYT4gd2lsbCBjbG9zZSBldmVyeXRoaW5nLCBvdGhlcndpc2UuXG4gIHZhciB0ID0gcGFyc2VyLnRhZ3MubGVuZ3RoXG4gIHZhciB0YWdOYW1lID0gcGFyc2VyLnRhZ05hbWVcbiAgaWYgKCFwYXJzZXIuc3RyaWN0KSB0YWdOYW1lID0gdGFnTmFtZVtwYXJzZXIubG9vc2VDYXNlXSgpXG4gIHZhciBjbG9zZVRvID0gdGFnTmFtZVxuICB3aGlsZSAodCAtLSkge1xuICAgIHZhciBjbG9zZSA9IHBhcnNlci50YWdzW3RdXG4gICAgaWYgKGNsb3NlLm5hbWUgIT09IGNsb3NlVG8pIHtcbiAgICAgIC8vIGZhaWwgdGhlIGZpcnN0IHRpbWUgaW4gc3RyaWN0IG1vZGVcbiAgICAgIHN0cmljdEZhaWwocGFyc2VyLCBcIlVuZXhwZWN0ZWQgY2xvc2UgdGFnXCIpXG4gICAgfSBlbHNlIGJyZWFrXG4gIH1cblxuICAvLyBkaWRuJ3QgZmluZCBpdC4gIHdlIGFscmVhZHkgZmFpbGVkIGZvciBzdHJpY3QsIHNvIGp1c3QgYWJvcnQuXG4gIGlmICh0IDwgMCkge1xuICAgIHN0cmljdEZhaWwocGFyc2VyLCBcIlVubWF0Y2hlZCBjbG9zaW5nIHRhZzogXCIrcGFyc2VyLnRhZ05hbWUpXG4gICAgcGFyc2VyLnRleHROb2RlICs9IFwiPC9cIiArIHBhcnNlci50YWdOYW1lICsgXCI+XCJcbiAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICByZXR1cm5cbiAgfVxuICBwYXJzZXIudGFnTmFtZSA9IHRhZ05hbWVcbiAgdmFyIHMgPSBwYXJzZXIudGFncy5sZW5ndGhcbiAgd2hpbGUgKHMgLS0+IHQpIHtcbiAgICB2YXIgdGFnID0gcGFyc2VyLnRhZyA9IHBhcnNlci50YWdzLnBvcCgpXG4gICAgcGFyc2VyLnRhZ05hbWUgPSBwYXJzZXIudGFnLm5hbWVcbiAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25jbG9zZXRhZ1wiLCBwYXJzZXIudGFnTmFtZSlcblxuICAgIHZhciB4ID0ge31cbiAgICBmb3IgKHZhciBpIGluIHRhZy5ucykgeFtpXSA9IHRhZy5uc1tpXVxuXG4gICAgdmFyIHBhcmVudCA9IHBhcnNlci50YWdzW3BhcnNlci50YWdzLmxlbmd0aCAtIDFdIHx8IHBhcnNlclxuICAgIGlmIChwYXJzZXIub3B0LnhtbG5zICYmIHRhZy5ucyAhPT0gcGFyZW50Lm5zKSB7XG4gICAgICAvLyByZW1vdmUgbmFtZXNwYWNlIGJpbmRpbmdzIGludHJvZHVjZWQgYnkgdGFnXG4gICAgICBPYmplY3Qua2V5cyh0YWcubnMpLmZvckVhY2goZnVuY3Rpb24gKHApIHtcbiAgICAgICAgdmFyIG4gPSB0YWcubnNbcF1cbiAgICAgICAgZW1pdE5vZGUocGFyc2VyLCBcIm9uY2xvc2VuYW1lc3BhY2VcIiwgeyBwcmVmaXg6IHAsIHVyaTogbiB9KVxuICAgICAgfSlcbiAgICB9XG4gIH1cbiAgaWYgKHQgPT09IDApIHBhcnNlci5jbG9zZWRSb290ID0gdHJ1ZVxuICBwYXJzZXIudGFnTmFtZSA9IHBhcnNlci5hdHRyaWJWYWx1ZSA9IHBhcnNlci5hdHRyaWJOYW1lID0gXCJcIlxuICBwYXJzZXIuYXR0cmliTGlzdC5sZW5ndGggPSAwXG4gIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxufVxuXG5mdW5jdGlvbiBwYXJzZUVudGl0eSAocGFyc2VyKSB7XG4gIHZhciBlbnRpdHkgPSBwYXJzZXIuZW50aXR5XG4gICAgLCBlbnRpdHlMQyA9IGVudGl0eS50b0xvd2VyQ2FzZSgpXG4gICAgLCBudW1cbiAgICAsIG51bVN0ciA9IFwiXCJcbiAgaWYgKHBhcnNlci5FTlRJVElFU1tlbnRpdHldKVxuICAgIHJldHVybiBwYXJzZXIuRU5USVRJRVNbZW50aXR5XVxuICBpZiAocGFyc2VyLkVOVElUSUVTW2VudGl0eUxDXSlcbiAgICByZXR1cm4gcGFyc2VyLkVOVElUSUVTW2VudGl0eUxDXVxuICBlbnRpdHkgPSBlbnRpdHlMQ1xuICBpZiAoZW50aXR5LmNoYXJBdCgwKSA9PT0gXCIjXCIpIHtcbiAgICBpZiAoZW50aXR5LmNoYXJBdCgxKSA9PT0gXCJ4XCIpIHtcbiAgICAgIGVudGl0eSA9IGVudGl0eS5zbGljZSgyKVxuICAgICAgbnVtID0gcGFyc2VJbnQoZW50aXR5LCAxNilcbiAgICAgIG51bVN0ciA9IG51bS50b1N0cmluZygxNilcbiAgICB9IGVsc2Uge1xuICAgICAgZW50aXR5ID0gZW50aXR5LnNsaWNlKDEpXG4gICAgICBudW0gPSBwYXJzZUludChlbnRpdHksIDEwKVxuICAgICAgbnVtU3RyID0gbnVtLnRvU3RyaW5nKDEwKVxuICAgIH1cbiAgfVxuICBlbnRpdHkgPSBlbnRpdHkucmVwbGFjZSgvXjArLywgXCJcIilcbiAgaWYgKG51bVN0ci50b0xvd2VyQ2FzZSgpICE9PSBlbnRpdHkpIHtcbiAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJJbnZhbGlkIGNoYXJhY3RlciBlbnRpdHlcIilcbiAgICByZXR1cm4gXCImXCIrcGFyc2VyLmVudGl0eSArIFwiO1wiXG4gIH1cblxuICByZXR1cm4gU3RyaW5nLmZyb21Db2RlUG9pbnQobnVtKVxufVxuXG5mdW5jdGlvbiB3cml0ZSAoY2h1bmspIHtcbiAgdmFyIHBhcnNlciA9IHRoaXNcbiAgaWYgKHRoaXMuZXJyb3IpIHRocm93IHRoaXMuZXJyb3JcbiAgaWYgKHBhcnNlci5jbG9zZWQpIHJldHVybiBlcnJvcihwYXJzZXIsXG4gICAgXCJDYW5ub3Qgd3JpdGUgYWZ0ZXIgY2xvc2UuIEFzc2lnbiBhbiBvbnJlYWR5IGhhbmRsZXIuXCIpXG4gIGlmIChjaHVuayA9PT0gbnVsbCkgcmV0dXJuIGVuZChwYXJzZXIpXG4gIHZhciBpID0gMCwgYyA9IFwiXCJcbiAgd2hpbGUgKHBhcnNlci5jID0gYyA9IGNodW5rLmNoYXJBdChpKyspKSB7XG4gICAgaWYgKHBhcnNlci50cmFja1Bvc2l0aW9uKSB7XG4gICAgICBwYXJzZXIucG9zaXRpb24gKytcbiAgICAgIGlmIChjID09PSBcIlxcblwiKSB7XG4gICAgICAgIHBhcnNlci5saW5lICsrXG4gICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICB9IGVsc2UgcGFyc2VyLmNvbHVtbiArK1xuICAgIH1cbiAgICBzd2l0Y2ggKHBhcnNlci5zdGF0ZSkge1xuXG4gICAgICBjYXNlIFMuQkVHSU46XG4gICAgICAgIGlmIChjID09PSBcIjxcIikge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9XQUtBXG4gICAgICAgICAgcGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gPSBwYXJzZXIucG9zaXRpb25cbiAgICAgICAgfSBlbHNlIGlmIChub3Qod2hpdGVzcGFjZSxjKSkge1xuICAgICAgICAgIC8vIGhhdmUgdG8gcHJvY2VzcyB0aGlzIGFzIGEgdGV4dCBub2RlLlxuICAgICAgICAgIC8vIHdlaXJkLCBidXQgaGFwcGVucy5cbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJOb24td2hpdGVzcGFjZSBiZWZvcmUgZmlyc3QgdGFnLlwiKVxuICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSA9IGNcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLlRFWFQ6XG4gICAgICAgIGlmIChwYXJzZXIuc2F3Um9vdCAmJiAhcGFyc2VyLmNsb3NlZFJvb3QpIHtcbiAgICAgICAgICB2YXIgc3RhcnRpID0gaS0xXG4gICAgICAgICAgd2hpbGUgKGMgJiYgYyE9PVwiPFwiICYmIGMhPT1cIiZcIikge1xuICAgICAgICAgICAgYyA9IGNodW5rLmNoYXJBdChpKyspXG4gICAgICAgICAgICBpZiAoYyAmJiBwYXJzZXIudHJhY2tQb3NpdGlvbikge1xuICAgICAgICAgICAgICBwYXJzZXIucG9zaXRpb24gKytcbiAgICAgICAgICAgICAgaWYgKGMgPT09IFwiXFxuXCIpIHtcbiAgICAgICAgICAgICAgICBwYXJzZXIubGluZSArK1xuICAgICAgICAgICAgICAgIHBhcnNlci5jb2x1bW4gPSAwXG4gICAgICAgICAgICAgIH0gZWxzZSBwYXJzZXIuY29sdW1uICsrXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICAgIHBhcnNlci50ZXh0Tm9kZSArPSBjaHVuay5zdWJzdHJpbmcoc3RhcnRpLCBpLTEpXG4gICAgICAgIH1cbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1dBS0FcbiAgICAgICAgICBwYXJzZXIuc3RhcnRUYWdQb3NpdGlvbiA9IHBhcnNlci5wb3NpdGlvblxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGlmIChub3Qod2hpdGVzcGFjZSwgYykgJiYgKCFwYXJzZXIuc2F3Um9vdCB8fCBwYXJzZXIuY2xvc2VkUm9vdCkpXG4gICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJUZXh0IGRhdGEgb3V0c2lkZSBvZiByb290IG5vZGUuXCIpXG4gICAgICAgICAgaWYgKGMgPT09IFwiJlwiKSBwYXJzZXIuc3RhdGUgPSBTLlRFWFRfRU5USVRZXG4gICAgICAgICAgZWxzZSBwYXJzZXIudGV4dE5vZGUgKz0gY1xuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuU0NSSVBUOlxuICAgICAgICAvLyBvbmx5IG5vbi1zdHJpY3RcbiAgICAgICAgaWYgKGMgPT09IFwiPFwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRfRU5ESU5HXG4gICAgICAgIH0gZWxzZSBwYXJzZXIuc2NyaXB0ICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5TQ1JJUFRfRU5ESU5HOlxuICAgICAgICBpZiAoYyA9PT0gXCIvXCIpIHtcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNMT1NFX1RBR1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBhcnNlci5zY3JpcHQgKz0gXCI8XCIgKyBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TQ1JJUFRcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLk9QRU5fV0FLQTpcbiAgICAgICAgLy8gZWl0aGVyIGEgLywgPywgISwgb3IgdGV4dCBpcyBjb21pbmcgbmV4dC5cbiAgICAgICAgaWYgKGMgPT09IFwiIVwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5TR01MX0RFQ0xcbiAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSBcIlwiXG4gICAgICAgIH0gZWxzZSBpZiAoaXMod2hpdGVzcGFjZSwgYykpIHtcbiAgICAgICAgICAvLyB3YWl0IGZvciBpdC4uLlxuICAgICAgICB9IGVsc2UgaWYgKGlzKG5hbWVTdGFydCxjKSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9UQUdcbiAgICAgICAgICBwYXJzZXIudGFnTmFtZSA9IGNcbiAgICAgICAgfSBlbHNlIGlmIChjID09PSBcIi9cIikge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0xPU0VfVEFHXG4gICAgICAgICAgcGFyc2VyLnRhZ05hbWUgPSBcIlwiXG4gICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gXCI/XCIpIHtcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVFxuICAgICAgICAgIHBhcnNlci5wcm9jSW5zdE5hbWUgPSBwYXJzZXIucHJvY0luc3RCb2R5ID0gXCJcIlxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHN0cmljdEZhaWwocGFyc2VyLCBcIlVuZW5jb2RlZCA8XCIpXG4gICAgICAgICAgLy8gaWYgdGhlcmUgd2FzIHNvbWUgd2hpdGVzcGFjZSwgdGhlbiBhZGQgdGhhdCBpbi5cbiAgICAgICAgICBpZiAocGFyc2VyLnN0YXJ0VGFnUG9zaXRpb24gKyAxIDwgcGFyc2VyLnBvc2l0aW9uKSB7XG4gICAgICAgICAgICB2YXIgcGFkID0gcGFyc2VyLnBvc2l0aW9uIC0gcGFyc2VyLnN0YXJ0VGFnUG9zaXRpb25cbiAgICAgICAgICAgIGMgPSBuZXcgQXJyYXkocGFkKS5qb2luKFwiIFwiKSArIGNcbiAgICAgICAgICB9XG4gICAgICAgICAgcGFyc2VyLnRleHROb2RlICs9IFwiPFwiICsgY1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuU0dNTF9ERUNMOlxuICAgICAgICBpZiAoKHBhcnNlci5zZ21sRGVjbCtjKS50b1VwcGVyQ2FzZSgpID09PSBDREFUQSkge1xuICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgXCJvbm9wZW5jZGF0YVwiKVxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFcbiAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSBcIlwiXG4gICAgICAgICAgcGFyc2VyLmNkYXRhID0gXCJcIlxuICAgICAgICB9IGVsc2UgaWYgKHBhcnNlci5zZ21sRGVjbCtjID09PSBcIi0tXCIpIHtcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRcbiAgICAgICAgICBwYXJzZXIuY29tbWVudCA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc2dtbERlY2wgPSBcIlwiXG4gICAgICAgIH0gZWxzZSBpZiAoKHBhcnNlci5zZ21sRGVjbCtjKS50b1VwcGVyQ2FzZSgpID09PSBET0NUWVBFKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5ET0NUWVBFXG4gICAgICAgICAgaWYgKHBhcnNlci5kb2N0eXBlIHx8IHBhcnNlci5zYXdSb290KSBzdHJpY3RGYWlsKHBhcnNlcixcbiAgICAgICAgICAgIFwiSW5hcHByb3ByaWF0ZWx5IGxvY2F0ZWQgZG9jdHlwZSBkZWNsYXJhdGlvblwiKVxuICAgICAgICAgIHBhcnNlci5kb2N0eXBlID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCA9IFwiXCJcbiAgICAgICAgfSBlbHNlIGlmIChjID09PSBcIj5cIikge1xuICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgXCJvbnNnbWxkZWNsYXJhdGlvblwiLCBwYXJzZXIuc2dtbERlY2wpXG4gICAgICAgICAgcGFyc2VyLnNnbWxEZWNsID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICB9IGVsc2UgaWYgKGlzKHF1b3RlLCBjKSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0dNTF9ERUNMX1FVT1RFRFxuICAgICAgICAgIHBhcnNlci5zZ21sRGVjbCArPSBjXG4gICAgICAgIH0gZWxzZSBwYXJzZXIuc2dtbERlY2wgKz0gY1xuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLlNHTUxfREVDTF9RVU9URUQ6XG4gICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0dNTF9ERUNMXG4gICAgICAgICAgcGFyc2VyLnEgPSBcIlwiXG4gICAgICAgIH1cbiAgICAgICAgcGFyc2VyLnNnbWxEZWNsICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5ET0NUWVBFOlxuICAgICAgICBpZiAoYyA9PT0gXCI+XCIpIHtcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25kb2N0eXBlXCIsIHBhcnNlci5kb2N0eXBlKVxuICAgICAgICAgIHBhcnNlci5kb2N0eXBlID0gdHJ1ZSAvLyBqdXN0IHJlbWVtYmVyIHRoYXQgd2Ugc2F3IGl0LlxuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgICBpZiAoYyA9PT0gXCJbXCIpIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERcbiAgICAgICAgICBlbHNlIGlmIChpcyhxdW90ZSwgYykpIHtcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9RVU9URURcbiAgICAgICAgICAgIHBhcnNlci5xID0gY1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkRPQ1RZUEVfUVVPVEVEOlxuICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgIHBhcnNlci5xID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRVxuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuRE9DVFlQRV9EVEQ6XG4gICAgICAgIHBhcnNlci5kb2N0eXBlICs9IGNcbiAgICAgICAgaWYgKGMgPT09IFwiXVwiKSBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVcbiAgICAgICAgZWxzZSBpZiAoaXMocXVvdGUsYykpIHtcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkRPQ1RZUEVfRFREX1FVT1RFRFxuICAgICAgICAgIHBhcnNlci5xID0gY1xuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuRE9DVFlQRV9EVERfUVVPVEVEOlxuICAgICAgICBwYXJzZXIuZG9jdHlwZSArPSBjXG4gICAgICAgIGlmIChjID09PSBwYXJzZXIucSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuRE9DVFlQRV9EVERcbiAgICAgICAgICBwYXJzZXIucSA9IFwiXCJcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkNPTU1FTlQ6XG4gICAgICAgIGlmIChjID09PSBcIi1cIikgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VORElOR1xuICAgICAgICBlbHNlIHBhcnNlci5jb21tZW50ICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VORElORzpcbiAgICAgICAgaWYgKGMgPT09IFwiLVwiKSB7XG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UX0VOREVEXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSB0ZXh0b3B0cyhwYXJzZXIub3B0LCBwYXJzZXIuY29tbWVudClcbiAgICAgICAgICBpZiAocGFyc2VyLmNvbW1lbnQpIGVtaXROb2RlKHBhcnNlciwgXCJvbmNvbW1lbnRcIiwgcGFyc2VyLmNvbW1lbnQpXG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgPSBcIlwiXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFyc2VyLmNvbW1lbnQgKz0gXCItXCIgKyBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DT01NRU5UXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DT01NRU5UX0VOREVEOlxuICAgICAgICBpZiAoYyAhPT0gXCI+XCIpIHtcbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJNYWxmb3JtZWQgY29tbWVudFwiKVxuICAgICAgICAgIC8vIGFsbG93IDwhLS0gYmxhaCAtLSBibG9vIC0tPiBpbiBub24tc3RyaWN0IG1vZGUsXG4gICAgICAgICAgLy8gd2hpY2ggaXMgYSBjb21tZW50IG9mIFwiIGJsYWggLS0gYmxvbyBcIlxuICAgICAgICAgIHBhcnNlci5jb21tZW50ICs9IFwiLS1cIiArIGNcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNPTU1FTlRcbiAgICAgICAgfSBlbHNlIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkNEQVRBOlxuICAgICAgICBpZiAoYyA9PT0gXCJdXCIpIHBhcnNlci5zdGF0ZSA9IFMuQ0RBVEFfRU5ESU5HXG4gICAgICAgIGVsc2UgcGFyc2VyLmNkYXRhICs9IGNcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5DREFUQV9FTkRJTkc6XG4gICAgICAgIGlmIChjID09PSBcIl1cIikgcGFyc2VyLnN0YXRlID0gUy5DREFUQV9FTkRJTkdfMlxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICBwYXJzZXIuY2RhdGEgKz0gXCJdXCIgKyBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5DREFUQVxuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuQ0RBVEFfRU5ESU5HXzI6XG4gICAgICAgIGlmIChjID09PSBcIj5cIikge1xuICAgICAgICAgIGlmIChwYXJzZXIuY2RhdGEpIGVtaXROb2RlKHBhcnNlciwgXCJvbmNkYXRhXCIsIHBhcnNlci5jZGF0YSlcbiAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25jbG9zZWNkYXRhXCIpXG4gICAgICAgICAgcGFyc2VyLmNkYXRhID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuVEVYVFxuICAgICAgICB9IGVsc2UgaWYgKGMgPT09IFwiXVwiKSB7XG4gICAgICAgICAgcGFyc2VyLmNkYXRhICs9IFwiXVwiXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgcGFyc2VyLmNkYXRhICs9IFwiXV1cIiArIGNcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkNEQVRBXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5QUk9DX0lOU1Q6XG4gICAgICAgIGlmIChjID09PSBcIj9cIikgcGFyc2VyLnN0YXRlID0gUy5QUk9DX0lOU1RfRU5ESU5HXG4gICAgICAgIGVsc2UgaWYgKGlzKHdoaXRlc3BhY2UsIGMpKSBwYXJzZXIuc3RhdGUgPSBTLlBST0NfSU5TVF9CT0RZXG4gICAgICAgIGVsc2UgcGFyc2VyLnByb2NJbnN0TmFtZSArPSBjXG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuUFJPQ19JTlNUX0JPRFk6XG4gICAgICAgIGlmICghcGFyc2VyLnByb2NJbnN0Qm9keSAmJiBpcyh3aGl0ZXNwYWNlLCBjKSkgY29udGludWVcbiAgICAgICAgZWxzZSBpZiAoYyA9PT0gXCI/XCIpIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0VORElOR1xuICAgICAgICBlbHNlIHBhcnNlci5wcm9jSW5zdEJvZHkgKz0gY1xuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLlBST0NfSU5TVF9FTkRJTkc6XG4gICAgICAgIGlmIChjID09PSBcIj5cIikge1xuICAgICAgICAgIGVtaXROb2RlKHBhcnNlciwgXCJvbnByb2Nlc3NpbmdpbnN0cnVjdGlvblwiLCB7XG4gICAgICAgICAgICBuYW1lIDogcGFyc2VyLnByb2NJbnN0TmFtZSxcbiAgICAgICAgICAgIGJvZHkgOiBwYXJzZXIucHJvY0luc3RCb2R5XG4gICAgICAgICAgfSlcbiAgICAgICAgICBwYXJzZXIucHJvY0luc3ROYW1lID0gcGFyc2VyLnByb2NJbnN0Qm9keSA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLlRFWFRcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBwYXJzZXIucHJvY0luc3RCb2R5ICs9IFwiP1wiICsgY1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuUFJPQ19JTlNUX0JPRFlcbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLk9QRU5fVEFHOlxuICAgICAgICBpZiAoaXMobmFtZUJvZHksIGMpKSBwYXJzZXIudGFnTmFtZSArPSBjXG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgIG5ld1RhZyhwYXJzZXIpXG4gICAgICAgICAgaWYgKGMgPT09IFwiPlwiKSBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICBlbHNlIGlmIChjID09PSBcIi9cIikgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgaWYgKG5vdCh3aGl0ZXNwYWNlLCBjKSkgc3RyaWN0RmFpbChcbiAgICAgICAgICAgICAgcGFyc2VyLCBcIkludmFsaWQgY2hhcmFjdGVyIGluIHRhZyBuYW1lXCIpXG4gICAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLk9QRU5fVEFHX1NMQVNIOlxuICAgICAgICBpZiAoYyA9PT0gXCI+XCIpIHtcbiAgICAgICAgICBvcGVuVGFnKHBhcnNlciwgdHJ1ZSlcbiAgICAgICAgICBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiRm9yd2FyZC1zbGFzaCBpbiBvcGVuaW5nIHRhZyBub3QgZm9sbG93ZWQgYnkgPlwiKVxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5BVFRSSUI6XG4gICAgICAgIC8vIGhhdmVuJ3QgcmVhZCB0aGUgYXR0cmlidXRlIG5hbWUgeWV0LlxuICAgICAgICBpZiAoaXMod2hpdGVzcGFjZSwgYykpIGNvbnRpbnVlXG4gICAgICAgIGVsc2UgaWYgKGMgPT09IFwiPlwiKSBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgZWxzZSBpZiAoYyA9PT0gXCIvXCIpIHBhcnNlci5zdGF0ZSA9IFMuT1BFTl9UQUdfU0xBU0hcbiAgICAgICAgZWxzZSBpZiAoaXMobmFtZVN0YXJ0LCBjKSkge1xuICAgICAgICAgIHBhcnNlci5hdHRyaWJOYW1lID0gY1xuICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9OQU1FXG4gICAgICAgIH0gZWxzZSBzdHJpY3RGYWlsKHBhcnNlciwgXCJJbnZhbGlkIGF0dHJpYnV0ZSBuYW1lXCIpXG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuQVRUUklCX05BTUU6XG4gICAgICAgIGlmIChjID09PSBcIj1cIikgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVcbiAgICAgICAgZWxzZSBpZiAoYyA9PT0gXCI+XCIpIHtcbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJBdHRyaWJ1dGUgd2l0aG91dCB2YWx1ZVwiKVxuICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9IHBhcnNlci5hdHRyaWJOYW1lXG4gICAgICAgICAgYXR0cmliKHBhcnNlcilcbiAgICAgICAgICBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChpcyh3aGl0ZXNwYWNlLCBjKSkgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRV9TQVdfV0hJVEVcbiAgICAgICAgZWxzZSBpZiAoaXMobmFtZUJvZHksIGMpKSBwYXJzZXIuYXR0cmliTmFtZSArPSBjXG4gICAgICAgIGVsc2Ugc3RyaWN0RmFpbChwYXJzZXIsIFwiSW52YWxpZCBhdHRyaWJ1dGUgbmFtZVwiKVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkFUVFJJQl9OQU1FX1NBV19XSElURTpcbiAgICAgICAgaWYgKGMgPT09IFwiPVwiKSBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQl9WQUxVRVxuICAgICAgICBlbHNlIGlmIChpcyh3aGl0ZXNwYWNlLCBjKSkgY29udGludWVcbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiQXR0cmlidXRlIHdpdGhvdXQgdmFsdWVcIilcbiAgICAgICAgICBwYXJzZXIudGFnLmF0dHJpYnV0ZXNbcGFyc2VyLmF0dHJpYk5hbWVdID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5hdHRyaWJWYWx1ZSA9IFwiXCJcbiAgICAgICAgICBlbWl0Tm9kZShwYXJzZXIsIFwib25hdHRyaWJ1dGVcIixcbiAgICAgICAgICAgICAgICAgICB7IG5hbWUgOiBwYXJzZXIuYXR0cmliTmFtZSwgdmFsdWUgOiBcIlwiIH0pXG4gICAgICAgICAgcGFyc2VyLmF0dHJpYk5hbWUgPSBcIlwiXG4gICAgICAgICAgaWYgKGMgPT09IFwiPlwiKSBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgICBlbHNlIGlmIChpcyhuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSA9IGNcbiAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX05BTUVcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiSW52YWxpZCBhdHRyaWJ1dGUgbmFtZVwiKVxuICAgICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUU6XG4gICAgICAgIGlmIChpcyh3aGl0ZXNwYWNlLCBjKSkgY29udGludWVcbiAgICAgICAgZWxzZSBpZiAoaXMocXVvdGUsIGMpKSB7XG4gICAgICAgICAgcGFyc2VyLnEgPSBjXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfUVVPVEVEXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiVW5xdW90ZWQgYXR0cmlidXRlIHZhbHVlXCIpXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfVkFMVUVfVU5RVU9URURcbiAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgPSBjXG4gICAgICAgIH1cbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfUVVPVEVEOlxuICAgICAgICBpZiAoYyAhPT0gcGFyc2VyLnEpIHtcbiAgICAgICAgICBpZiAoYyA9PT0gXCImXCIpIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX0VOVElUWV9RXG4gICAgICAgICAgZWxzZSBwYXJzZXIuYXR0cmliVmFsdWUgKz0gY1xuICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgIH1cbiAgICAgICAgYXR0cmliKHBhcnNlcilcbiAgICAgICAgcGFyc2VyLnEgPSBcIlwiXG4gICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX0NMT1NFRFxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9DTE9TRUQ6XG4gICAgICAgIGlmIChpcyh3aGl0ZXNwYWNlLCBjKSkge1xuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCXG4gICAgICAgIH0gZWxzZSBpZiAoYyA9PT0gXCI+XCIpIG9wZW5UYWcocGFyc2VyKVxuICAgICAgICBlbHNlIGlmIChjID09PSBcIi9cIikgcGFyc2VyLnN0YXRlID0gUy5PUEVOX1RBR19TTEFTSFxuICAgICAgICBlbHNlIGlmIChpcyhuYW1lU3RhcnQsIGMpKSB7XG4gICAgICAgICAgc3RyaWN0RmFpbChwYXJzZXIsIFwiTm8gd2hpdGVzcGFjZSBiZXR3ZWVuIGF0dHJpYnV0ZXNcIilcbiAgICAgICAgICBwYXJzZXIuYXR0cmliTmFtZSA9IGNcbiAgICAgICAgICBwYXJzZXIuYXR0cmliVmFsdWUgPSBcIlwiXG4gICAgICAgICAgcGFyc2VyLnN0YXRlID0gUy5BVFRSSUJfTkFNRVxuICAgICAgICB9IGVsc2Ugc3RyaWN0RmFpbChwYXJzZXIsIFwiSW52YWxpZCBhdHRyaWJ1dGUgbmFtZVwiKVxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9VTlFVT1RFRDpcbiAgICAgICAgaWYgKG5vdChhdHRyaWJFbmQsYykpIHtcbiAgICAgICAgICBpZiAoYyA9PT0gXCImXCIpIHBhcnNlci5zdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX0VOVElUWV9VXG4gICAgICAgICAgZWxzZSBwYXJzZXIuYXR0cmliVmFsdWUgKz0gY1xuICAgICAgICAgIGNvbnRpbnVlXG4gICAgICAgIH1cbiAgICAgICAgYXR0cmliKHBhcnNlcilcbiAgICAgICAgaWYgKGMgPT09IFwiPlwiKSBvcGVuVGFnKHBhcnNlcilcbiAgICAgICAgZWxzZSBwYXJzZXIuc3RhdGUgPSBTLkFUVFJJQlxuICAgICAgY29udGludWVcblxuICAgICAgY2FzZSBTLkNMT1NFX1RBRzpcbiAgICAgICAgaWYgKCFwYXJzZXIudGFnTmFtZSkge1xuICAgICAgICAgIGlmIChpcyh3aGl0ZXNwYWNlLCBjKSkgY29udGludWVcbiAgICAgICAgICBlbHNlIGlmIChub3QobmFtZVN0YXJ0LCBjKSkge1xuICAgICAgICAgICAgaWYgKHBhcnNlci5zY3JpcHQpIHtcbiAgICAgICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSBcIjwvXCIgKyBjXG4gICAgICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0NSSVBUXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJJbnZhbGlkIHRhZ25hbWUgaW4gY2xvc2luZyB0YWcuXCIpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIHBhcnNlci50YWdOYW1lID0gY1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGMgPT09IFwiPlwiKSBjbG9zZVRhZyhwYXJzZXIpXG4gICAgICAgIGVsc2UgaWYgKGlzKG5hbWVCb2R5LCBjKSkgcGFyc2VyLnRhZ05hbWUgKz0gY1xuICAgICAgICBlbHNlIGlmIChwYXJzZXIuc2NyaXB0KSB7XG4gICAgICAgICAgcGFyc2VyLnNjcmlwdCArPSBcIjwvXCIgKyBwYXJzZXIudGFnTmFtZVxuICAgICAgICAgIHBhcnNlci50YWdOYW1lID0gXCJcIlxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuU0NSSVBUXG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgaWYgKG5vdCh3aGl0ZXNwYWNlLCBjKSkgc3RyaWN0RmFpbChwYXJzZXIsXG4gICAgICAgICAgICBcIkludmFsaWQgdGFnbmFtZSBpbiBjbG9zaW5nIHRhZ1wiKVxuICAgICAgICAgIHBhcnNlci5zdGF0ZSA9IFMuQ0xPU0VfVEFHX1NBV19XSElURVxuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBjYXNlIFMuQ0xPU0VfVEFHX1NBV19XSElURTpcbiAgICAgICAgaWYgKGlzKHdoaXRlc3BhY2UsIGMpKSBjb250aW51ZVxuICAgICAgICBpZiAoYyA9PT0gXCI+XCIpIGNsb3NlVGFnKHBhcnNlcilcbiAgICAgICAgZWxzZSBzdHJpY3RGYWlsKHBhcnNlciwgXCJJbnZhbGlkIGNoYXJhY3RlcnMgaW4gY2xvc2luZyB0YWdcIilcbiAgICAgIGNvbnRpbnVlXG5cbiAgICAgIGNhc2UgUy5URVhUX0VOVElUWTpcbiAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1E6XG4gICAgICBjYXNlIFMuQVRUUklCX1ZBTFVFX0VOVElUWV9VOlxuICAgICAgICBzd2l0Y2gocGFyc2VyLnN0YXRlKSB7XG4gICAgICAgICAgY2FzZSBTLlRFWFRfRU5USVRZOlxuICAgICAgICAgICAgdmFyIHJldHVyblN0YXRlID0gUy5URVhULCBidWZmZXIgPSBcInRleHROb2RlXCJcbiAgICAgICAgICBicmVha1xuXG4gICAgICAgICAgY2FzZSBTLkFUVFJJQl9WQUxVRV9FTlRJVFlfUTpcbiAgICAgICAgICAgIHZhciByZXR1cm5TdGF0ZSA9IFMuQVRUUklCX1ZBTFVFX1FVT1RFRCwgYnVmZmVyID0gXCJhdHRyaWJWYWx1ZVwiXG4gICAgICAgICAgYnJlYWtcblxuICAgICAgICAgIGNhc2UgUy5BVFRSSUJfVkFMVUVfRU5USVRZX1U6XG4gICAgICAgICAgICB2YXIgcmV0dXJuU3RhdGUgPSBTLkFUVFJJQl9WQUxVRV9VTlFVT1RFRCwgYnVmZmVyID0gXCJhdHRyaWJWYWx1ZVwiXG4gICAgICAgICAgYnJlYWtcbiAgICAgICAgfVxuICAgICAgICBpZiAoYyA9PT0gXCI7XCIpIHtcbiAgICAgICAgICBwYXJzZXJbYnVmZmVyXSArPSBwYXJzZUVudGl0eShwYXJzZXIpXG4gICAgICAgICAgcGFyc2VyLmVudGl0eSA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSByZXR1cm5TdGF0ZVxuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGlzKGVudGl0eSwgYykpIHBhcnNlci5lbnRpdHkgKz0gY1xuICAgICAgICBlbHNlIHtcbiAgICAgICAgICBzdHJpY3RGYWlsKHBhcnNlciwgXCJJbnZhbGlkIGNoYXJhY3RlciBlbnRpdHlcIilcbiAgICAgICAgICBwYXJzZXJbYnVmZmVyXSArPSBcIiZcIiArIHBhcnNlci5lbnRpdHkgKyBjXG4gICAgICAgICAgcGFyc2VyLmVudGl0eSA9IFwiXCJcbiAgICAgICAgICBwYXJzZXIuc3RhdGUgPSByZXR1cm5TdGF0ZVxuICAgICAgICB9XG4gICAgICBjb250aW51ZVxuXG4gICAgICBkZWZhdWx0OlxuICAgICAgICB0aHJvdyBuZXcgRXJyb3IocGFyc2VyLCBcIlVua25vd24gc3RhdGU6IFwiICsgcGFyc2VyLnN0YXRlKVxuICAgIH1cbiAgfSAvLyB3aGlsZVxuICAvLyBjZGF0YSBibG9ja3MgY2FuIGdldCB2ZXJ5IGJpZyB1bmRlciBub3JtYWwgY29uZGl0aW9ucy4gZW1pdCBhbmQgbW92ZSBvbi5cbiAgLy8gaWYgKHBhcnNlci5zdGF0ZSA9PT0gUy5DREFUQSAmJiBwYXJzZXIuY2RhdGEpIHtcbiAgLy8gICBlbWl0Tm9kZShwYXJzZXIsIFwib25jZGF0YVwiLCBwYXJzZXIuY2RhdGEpXG4gIC8vICAgcGFyc2VyLmNkYXRhID0gXCJcIlxuICAvLyB9XG4gIGlmIChwYXJzZXIucG9zaXRpb24gPj0gcGFyc2VyLmJ1ZmZlckNoZWNrUG9zaXRpb24pIGNoZWNrQnVmZmVyTGVuZ3RoKHBhcnNlcilcbiAgcmV0dXJuIHBhcnNlclxufVxuXG4vKiEgaHR0cDovL210aHMuYmUvZnJvbWNvZGVwb2ludCB2MC4xLjAgYnkgQG1hdGhpYXMgKi9cbmlmICghU3RyaW5nLmZyb21Db2RlUG9pbnQpIHtcbiAgICAgICAgKGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHZhciBzdHJpbmdGcm9tQ2hhckNvZGUgPSBTdHJpbmcuZnJvbUNoYXJDb2RlO1xuICAgICAgICAgICAgICAgIHZhciBmbG9vciA9IE1hdGguZmxvb3I7XG4gICAgICAgICAgICAgICAgdmFyIGZyb21Db2RlUG9pbnQgPSBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBNQVhfU0laRSA9IDB4NDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjb2RlVW5pdHMgPSBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBoaWdoU3Vycm9nYXRlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxvd1N1cnJvZ2F0ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBpbmRleCA9IC0xO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGxlbmd0aCA9IGFyZ3VtZW50cy5sZW5ndGg7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0ID0gJyc7XG4gICAgICAgICAgICAgICAgICAgICAgICB3aGlsZSAoKytpbmRleCA8IGxlbmd0aCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgY29kZVBvaW50ID0gTnVtYmVyKGFyZ3VtZW50c1tpbmRleF0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIWlzRmluaXRlKGNvZGVQb2ludCkgfHwgLy8gYE5hTmAsIGArSW5maW5pdHlgLCBvciBgLUluZmluaXR5YFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVQb2ludCA8IDAgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29kZVBvaW50ID4gMHgxMEZGRkYgfHwgLy8gbm90IGEgdmFsaWQgVW5pY29kZSBjb2RlIHBvaW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZmxvb3IoY29kZVBvaW50KSAhPSBjb2RlUG9pbnQgLy8gbm90IGFuIGludGVnZXJcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhyb3cgUmFuZ2VFcnJvcignSW52YWxpZCBjb2RlIHBvaW50OiAnICsgY29kZVBvaW50KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoY29kZVBvaW50IDw9IDB4RkZGRikgeyAvLyBCTVAgY29kZSBwb2ludFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvZGVVbml0cy5wdXNoKGNvZGVQb2ludCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7IC8vIEFzdHJhbCBjb2RlIHBvaW50OyBzcGxpdCBpbiBzdXJyb2dhdGUgaGFsdmVzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaHR0cDovL21hdGhpYXNieW5lbnMuYmUvbm90ZXMvamF2YXNjcmlwdC1lbmNvZGluZyNzdXJyb2dhdGUtZm9ybXVsYWVcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlUG9pbnQgLT0gMHgxMDAwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBoaWdoU3Vycm9nYXRlID0gKGNvZGVQb2ludCA+PiAxMCkgKyAweEQ4MDA7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbG93U3Vycm9nYXRlID0gKGNvZGVQb2ludCAlIDB4NDAwKSArIDB4REMwMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMucHVzaChoaWdoU3Vycm9nYXRlLCBsb3dTdXJyb2dhdGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbmRleCArIDEgPT0gbGVuZ3RoIHx8IGNvZGVVbml0cy5sZW5ndGggPiBNQVhfU0laRSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdCArPSBzdHJpbmdGcm9tQ2hhckNvZGUuYXBwbHkobnVsbCwgY29kZVVuaXRzKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb2RlVW5pdHMubGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGlmIChPYmplY3QuZGVmaW5lUHJvcGVydHkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShTdHJpbmcsICdmcm9tQ29kZVBvaW50Jywge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAndmFsdWUnOiBmcm9tQ29kZVBvaW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAnY29uZmlndXJhYmxlJzogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJ3dyaXRhYmxlJzogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIFN0cmluZy5mcm9tQ29kZVBvaW50ID0gZnJvbUNvZGVQb2ludDtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgIH0oKSk7XG59XG5cbn0pKHR5cGVvZiBleHBvcnRzID09PSBcInVuZGVmaW5lZFwiID8gc2F4ID0ge30gOiBleHBvcnRzKTtcbiJdfQ==
- },{"undefined":undefined}],59:[function(_dereq_,module,exports){
- /**
- * Tiny stack for browser or server
- *
- * @author Jason Mulligan <jason.mulligan@avoidwork.com>
- * @copyright 2014 Jason Mulligan
- * @license BSD-3 <https://raw.github.com/avoidwork/tiny-stack/master/LICENSE>
- * @link http://avoidwork.github.io/tiny-stack
- * @module tiny-stack
- * @version 0.1.0
- */
- ( function ( global ) {
- "use strict";
- /**
- * TinyStack
- *
- * @constructor
- */
- function TinyStack () {
- this.data = [null];
- this.top = 0;
- }
- /**
- * Clears the stack
- *
- * @method clear
- * @memberOf TinyStack
- * @return {Object} {@link TinyStack}
- */
- TinyStack.prototype.clear = function clear () {
- this.data = [null];
- this.top = 0;
- return this;
- };
- /**
- * Gets the size of the stack
- *
- * @method length
- * @memberOf TinyStack
- * @return {Number} Size of stack
- */
- TinyStack.prototype.length = function length () {
- return this.top;
- };
- /**
- * Gets the item at the top of the stack
- *
- * @method peek
- * @memberOf TinyStack
- * @return {Mixed} Item at the top of the stack
- */
- TinyStack.prototype.peek = function peek () {
- return this.data[this.top];
- };
- /**
- * Gets & removes the item at the top of the stack
- *
- * @method pop
- * @memberOf TinyStack
- * @return {Mixed} Item at the top of the stack
- */
- TinyStack.prototype.pop = function pop () {
- if ( this.top > 0 ) {
- this.top--;
- return this.data.pop();
- }
- else {
- return undefined;
- }
- };
- /**
- * Pushes an item onto the stack
- *
- * @method push
- * @memberOf TinyStack
- * @return {Object} {@link TinyStack}
- */
- TinyStack.prototype.push = function push ( arg ) {
- this.data[++this.top] = arg;
- return this;
- };
- /**
- * TinyStack factory
- *
- * @method factory
- * @return {Object} {@link TinyStack}
- */
- function factory () {
- return new TinyStack();
- }
- // Node, AMD & window supported
- if ( typeof exports != "undefined" ) {
- module.exports = factory;
- }
- else if ( typeof define == "function" ) {
- define( function () {
- return factory;
- } );
- }
- else {
- global.stack = factory;
- }
- } )( this );
- },{}],60:[function(_dereq_,module,exports){
- module.exports = _dereq_(64);
- },{"64":64}],61:[function(_dereq_,module,exports){
- 'use strict';
- function Base() { }
- Base.prototype.get = function(name) {
- return this.$model.properties.get(this, name);
- };
- Base.prototype.set = function(name, value) {
- this.$model.properties.set(this, name, value);
- };
- module.exports = Base;
- },{}],62:[function(_dereq_,module,exports){
- 'use strict';
- var pick = _dereq_(345),
- assign = _dereq_(339),
- forEach = _dereq_(218);
- var parseNameNs = _dereq_(65).parseName;
- function DescriptorBuilder(nameNs) {
- this.ns = nameNs;
- this.name = nameNs.name;
- this.allTypes = [];
- this.properties = [];
- this.propertiesByName = {};
- }
- module.exports = DescriptorBuilder;
- DescriptorBuilder.prototype.build = function() {
- return pick(this, [ 'ns', 'name', 'allTypes', 'properties', 'propertiesByName', 'bodyProperty' ]);
- };
- DescriptorBuilder.prototype.addProperty = function(p, idx) {
- this.addNamedProperty(p, true);
- var properties = this.properties;
- if (idx !== undefined) {
- properties.splice(idx, 0, p);
- } else {
- properties.push(p);
- }
- };
- DescriptorBuilder.prototype.replaceProperty = function(oldProperty, newProperty) {
- var oldNameNs = oldProperty.ns;
- var props = this.properties,
- propertiesByName = this.propertiesByName,
- rename = oldProperty.name !== newProperty.name;
- if (oldProperty.isBody) {
- if (!newProperty.isBody) {
- throw new Error(
- 'property <' + newProperty.ns.name + '> must be body property ' +
- 'to refine <' + oldProperty.ns.name + '>');
- }
- // TODO: Check compatibility
- this.setBodyProperty(newProperty, false);
- }
- // replacing the named property is intentional
- // thus, validate only if this is a "rename" operation
- this.addNamedProperty(newProperty, rename);
- // replace old property at index with new one
- var idx = props.indexOf(oldProperty);
- if (idx === -1) {
- throw new Error('property <' + oldNameNs.name + '> not found in property list');
- }
- props[idx] = newProperty;
- // replace propertiesByName entry with new property
- propertiesByName[oldNameNs.name] = propertiesByName[oldNameNs.localName] = newProperty;
- };
- DescriptorBuilder.prototype.redefineProperty = function(p) {
- var nsPrefix = p.ns.prefix;
- var parts = p.redefines.split('#');
- var name = parseNameNs(parts[0], nsPrefix);
- var attrName = parseNameNs(parts[1], name.prefix).name;
- var redefinedProperty = this.propertiesByName[attrName];
- if (!redefinedProperty) {
- throw new Error('refined property <' + attrName + '> not found');
- } else {
- this.replaceProperty(redefinedProperty, p);
- }
- delete p.redefines;
- };
- DescriptorBuilder.prototype.addNamedProperty = function(p, validate) {
- var ns = p.ns,
- propsByName = this.propertiesByName;
- if (validate) {
- this.assertNotDefined(p, ns.name);
- this.assertNotDefined(p, ns.localName);
- }
- propsByName[ns.name] = propsByName[ns.localName] = p;
- };
- DescriptorBuilder.prototype.removeNamedProperty = function(p) {
- var ns = p.ns,
- propsByName = this.propertiesByName;
- delete propsByName[ns.name];
- delete propsByName[ns.localName];
- };
- DescriptorBuilder.prototype.setBodyProperty = function(p, validate) {
- if (validate && this.bodyProperty) {
- throw new Error(
- 'body property defined multiple times ' +
- '(<' + this.bodyProperty.ns.name + '>, <' + p.ns.name + '>)');
- }
- this.bodyProperty = p;
- };
- DescriptorBuilder.prototype.addIdProperty = function(name) {
- var nameNs = parseNameNs(name, this.ns.prefix);
- var p = {
- name: nameNs.localName,
- type: 'String',
- isAttr: true,
- ns: nameNs
- };
- // ensure that id is always the first attribute (if present)
- this.addProperty(p, 0);
- };
- DescriptorBuilder.prototype.assertNotDefined = function(p, name) {
- var propertyName = p.name,
- definedProperty = this.propertiesByName[propertyName];
- if (definedProperty) {
- throw new Error(
- 'property <' + propertyName + '> already defined; ' +
- 'override of <' + definedProperty.definedBy.ns.name + '#' + definedProperty.ns.name + '> by ' +
- '<' + p.definedBy.ns.name + '#' + p.ns.name + '> not allowed without redefines');
- }
- };
- DescriptorBuilder.prototype.hasProperty = function(name) {
- return this.propertiesByName[name];
- };
- DescriptorBuilder.prototype.addTrait = function(t) {
- var allTypes = this.allTypes;
- if (allTypes.indexOf(t) !== -1) {
- return;
- }
- forEach(t.properties, function(p) {
- // clone property to allow extensions
- p = assign({}, p, {
- name: p.ns.localName
- });
- Object.defineProperty(p, 'definedBy', {
- value: t
- });
- // add redefine support
- if (p.redefines) {
- this.redefineProperty(p);
- } else {
- if (p.isBody) {
- this.setBodyProperty(p);
- }
- this.addProperty(p);
- }
- }, this);
- allTypes.push(t);
- };
- },{"218":218,"339":339,"345":345,"65":65}],63:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var Base = _dereq_(61);
- function Factory(model, properties) {
- this.model = model;
- this.properties = properties;
- }
- module.exports = Factory;
- Factory.prototype.createType = function(descriptor) {
- var model = this.model;
- var props = this.properties,
- prototype = Object.create(Base.prototype);
- // initialize default values
- forEach(descriptor.properties, function(p) {
- if (!p.isMany && p.default !== undefined) {
- prototype[p.name] = p.default;
- }
- });
- props.defineModel(prototype, model);
- props.defineDescriptor(prototype, descriptor);
- var name = descriptor.ns.name;
- /**
- * The new type constructor
- */
- function ModdleElement(attrs) {
- props.define(this, '$type', { value: name, enumerable: true });
- props.define(this, '$attrs', { value: {} });
- props.define(this, '$parent', { writable: true });
- forEach(attrs, function(val, key) {
- this.set(key, val);
- }, this);
- }
- ModdleElement.prototype = prototype;
- ModdleElement.hasType = prototype.$instanceOf = this.model.hasType;
- // static links
- props.defineModel(ModdleElement, model);
- props.defineDescriptor(ModdleElement, descriptor);
- return ModdleElement;
- };
- },{"218":218,"61":61}],64:[function(_dereq_,module,exports){
- 'use strict';
- var isString = _dereq_(336),
- isObject = _dereq_(334),
- forEach = _dereq_(218),
- find = _dereq_(217);
- var Factory = _dereq_(63),
- Registry = _dereq_(67),
- Properties = _dereq_(66);
- var parseNameNs = _dereq_(65).parseName;
- //// Moddle implementation /////////////////////////////////////////////////
- /**
- * @class Moddle
- *
- * A model that can be used to create elements of a specific type.
- *
- * @example
- *
- * var Moddle = require('moddle');
- *
- * var pkg = {
- * name: 'mypackage',
- * prefix: 'my',
- * types: [
- * { name: 'Root' }
- * ]
- * };
- *
- * var moddle = new Moddle([pkg]);
- *
- * @param {Array<Package>} packages the packages to contain
- * @param {Object} options additional options to pass to the model
- */
- function Moddle(packages, options) {
- options = options || {};
- this.properties = new Properties(this);
- this.factory = new Factory(this, this.properties);
- this.registry = new Registry(packages, this.properties, options);
- this.typeCache = {};
- }
- module.exports = Moddle;
- /**
- * Create an instance of the specified type.
- *
- * @method Moddle#create
- *
- * @example
- *
- * var foo = moddle.create('my:Foo');
- * var bar = moddle.create('my:Bar', { id: 'BAR_1' });
- *
- * @param {String|Object} descriptor the type descriptor or name know to the model
- * @param {Object} attrs a number of attributes to initialize the model instance with
- * @return {Object} model instance
- */
- Moddle.prototype.create = function(descriptor, attrs) {
- var Type = this.getType(descriptor);
- if (!Type) {
- throw new Error('unknown type <' + descriptor + '>');
- }
- return new Type(attrs);
- };
- /**
- * Returns the type representing a given descriptor
- *
- * @method Moddle#getType
- *
- * @example
- *
- * var Foo = moddle.getType('my:Foo');
- * var foo = new Foo({ 'id' : 'FOO_1' });
- *
- * @param {String|Object} descriptor the type descriptor or name know to the model
- * @return {Object} the type representing the descriptor
- */
- Moddle.prototype.getType = function(descriptor) {
- var cache = this.typeCache;
- var name = isString(descriptor) ? descriptor : descriptor.ns.name;
- var type = cache[name];
- if (!type) {
- descriptor = this.registry.getEffectiveDescriptor(name);
- type = cache[name] = this.factory.createType(descriptor);
- }
- return type;
- };
- /**
- * Creates an any-element type to be used within model instances.
- *
- * This can be used to create custom elements that lie outside the meta-model.
- * The created element contains all the meta-data required to serialize it
- * as part of meta-model elements.
- *
- * @method Moddle#createAny
- *
- * @example
- *
- * var foo = moddle.createAny('vendor:Foo', 'http://vendor', {
- * value: 'bar'
- * });
- *
- * var container = moddle.create('my:Container', 'http://my', {
- * any: [ foo ]
- * });
- *
- * // go ahead and serialize the stuff
- *
- *
- * @param {String} name the name of the element
- * @param {String} nsUri the namespace uri of the element
- * @param {Object} [properties] a map of properties to initialize the instance with
- * @return {Object} the any type instance
- */
- Moddle.prototype.createAny = function(name, nsUri, properties) {
- var nameNs = parseNameNs(name);
- var element = {
- $type: name
- };
- var descriptor = {
- name: name,
- isGeneric: true,
- ns: {
- prefix: nameNs.prefix,
- localName: nameNs.localName,
- uri: nsUri
- }
- };
- this.properties.defineDescriptor(element, descriptor);
- this.properties.defineModel(element, this);
- this.properties.define(element, '$parent', { enumerable: false, writable: true });
- forEach(properties, function(a, key) {
- if (isObject(a) && a.value !== undefined) {
- element[a.name] = a.value;
- } else {
- element[key] = a;
- }
- });
- return element;
- };
- /**
- * Returns a registered package by uri or prefix
- *
- * @return {Object} the package
- */
- Moddle.prototype.getPackage = function(uriOrPrefix) {
- return this.registry.getPackage(uriOrPrefix);
- };
- /**
- * Returns a snapshot of all known packages
- *
- * @return {Object} the package
- */
- Moddle.prototype.getPackages = function() {
- return this.registry.getPackages();
- };
- /**
- * Returns the descriptor for an element
- */
- Moddle.prototype.getElementDescriptor = function(element) {
- return element.$descriptor;
- };
- /**
- * Returns true if the given descriptor or instance
- * represents the given type.
- *
- * May be applied to this, if element is omitted.
- */
- Moddle.prototype.hasType = function(element, type) {
- if (type === undefined) {
- type = element;
- element = this;
- }
- var descriptor = element.$model.getElementDescriptor(element);
- return !!find(descriptor.allTypes, function(t) {
- return t.name === type;
- });
- };
- /**
- * Returns the descriptor of an elements named property
- */
- Moddle.prototype.getPropertyDescriptor = function(element, property) {
- return this.getElementDescriptor(element).propertiesByName[property];
- };
- },{"217":217,"218":218,"334":334,"336":336,"63":63,"65":65,"66":66,"67":67}],65:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Parses a namespaced attribute name of the form (ns:)localName to an object,
- * given a default prefix to assume in case no explicit namespace is given.
- *
- * @param {String} name
- * @param {String} [defaultPrefix] the default prefix to take, if none is present.
- *
- * @return {Object} the parsed name
- */
- module.exports.parseName = function(name, defaultPrefix) {
- var parts = name.split(/:/),
- localName, prefix;
- // no prefix (i.e. only local name)
- if (parts.length === 1) {
- localName = name;
- prefix = defaultPrefix;
- } else
- // prefix + local name
- if (parts.length === 2) {
- localName = parts[1];
- prefix = parts[0];
- } else {
- throw new Error('expected <prefix:localName> or <localName>, got ' + name);
- }
- name = (prefix ? prefix + ':' : '') + localName;
- return {
- name: name,
- prefix: prefix,
- localName: localName
- };
- };
- },{}],66:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * A utility that gets and sets properties of model elements.
- *
- * @param {Model} model
- */
- function Properties(model) {
- this.model = model;
- }
- module.exports = Properties;
- /**
- * Sets a named property on the target element
- *
- * @param {Object} target
- * @param {String} name
- * @param {Object} value
- */
- Properties.prototype.set = function(target, name, value) {
- var property = this.model.getPropertyDescriptor(target, name);
- if (!property) {
- target.$attrs[name] = value;
- } else {
- Object.defineProperty(target, property.name, {
- enumerable: !property.isReference,
- writable: true,
- value: value
- });
- }
- };
- /**
- * Returns the named property of the given element
- *
- * @param {Object} target
- * @param {String} name
- *
- * @return {Object}
- */
- Properties.prototype.get = function(target, name) {
- var property = this.model.getPropertyDescriptor(target, name);
- if (!property) {
- return target.$attrs[name];
- }
- var propertyName = property.name;
- // check if access to collection property and lazily initialize it
- if (!target[propertyName] && property.isMany) {
- Object.defineProperty(target, propertyName, {
- enumerable: !property.isReference,
- writable: true,
- value: []
- });
- }
- return target[propertyName];
- };
- /**
- * Define a property on the target element
- *
- * @param {Object} target
- * @param {String} name
- * @param {Object} options
- */
- Properties.prototype.define = function(target, name, options) {
- Object.defineProperty(target, name, options);
- };
- /**
- * Define the descriptor for an element
- */
- Properties.prototype.defineDescriptor = function(target, descriptor) {
- this.define(target, '$descriptor', { value: descriptor });
- };
- /**
- * Define the model for an element
- */
- Properties.prototype.defineModel = function(target, model) {
- this.define(target, '$model', { value: model });
- };
- },{}],67:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- forEach = _dereq_(218);
- var Types = _dereq_(68),
- DescriptorBuilder = _dereq_(62);
- var parseNameNs = _dereq_(65).parseName,
- isBuiltInType = Types.isBuiltIn;
- function Registry(packages, properties, options) {
- this.options = assign({ generateId: 'id' }, options || {});
- this.packageMap = {};
- this.typeMap = {};
- this.packages = [];
- this.properties = properties;
- forEach(packages, this.registerPackage, this);
- }
- module.exports = Registry;
- Registry.prototype.getPackage = function(uriOrPrefix) {
- return this.packageMap[uriOrPrefix];
- };
- Registry.prototype.getPackages = function() {
- return this.packages;
- };
- Registry.prototype.registerPackage = function(pkg) {
- // copy package
- pkg = assign({}, pkg);
- // register types
- forEach(pkg.types, function(descriptor) {
- this.registerType(descriptor, pkg);
- }, this);
- this.packageMap[pkg.uri] = this.packageMap[pkg.prefix] = pkg;
- this.packages.push(pkg);
- };
- /**
- * Register a type from a specific package with us
- */
- Registry.prototype.registerType = function(type, pkg) {
- type = assign({}, type, {
- superClass: (type.superClass || []).slice(),
- extends: (type.extends || []).slice(),
- properties: (type.properties || []).slice()
- });
- var ns = parseNameNs(type.name, pkg.prefix),
- name = ns.name,
- propertiesByName = {};
- // parse properties
- forEach(type.properties, function(p) {
- // namespace property names
- var propertyNs = parseNameNs(p.name, ns.prefix),
- propertyName = propertyNs.name;
- // namespace property types
- if (!isBuiltInType(p.type)) {
- p.type = parseNameNs(p.type, propertyNs.prefix).name;
- }
- assign(p, {
- ns: propertyNs,
- name: propertyName
- });
- propertiesByName[propertyName] = p;
- });
- // update ns + name
- assign(type, {
- ns: ns,
- name: name,
- propertiesByName: propertiesByName
- });
- forEach(type.extends, function(extendsName) {
- var extended = this.typeMap[extendsName];
- extended.traits = extended.traits || [];
- extended.traits.push(name);
- }, this);
- // link to package
- this.definePackage(type, pkg);
- // register
- this.typeMap[name] = type;
- };
- /**
- * Traverse the type hierarchy from bottom to top.
- */
- Registry.prototype.mapTypes = function(nsName, iterator) {
- var type = isBuiltInType(nsName.name) ? { name: nsName.name } : this.typeMap[nsName.name];
- var self = this;
- /**
- * Traverse the selected super type or trait
- *
- * @param {String} cls
- */
- function traverseSuper(cls) {
- var parentNs = parseNameNs(cls, isBuiltInType(cls) ? '' : nsName.prefix);
- self.mapTypes(parentNs, iterator);
- }
- if (!type) {
- throw new Error('unknown type <' + nsName.name + '>');
- }
- forEach(type.superClass, traverseSuper);
- iterator(type);
- forEach(type.traits, traverseSuper);
- };
- /**
- * Returns the effective descriptor for a type.
- *
- * @param {String} type the namespaced name (ns:localName) of the type
- *
- * @return {Descriptor} the resulting effective descriptor
- */
- Registry.prototype.getEffectiveDescriptor = function(name) {
- var nsName = parseNameNs(name);
- var builder = new DescriptorBuilder(nsName);
- this.mapTypes(nsName, function(type) {
- builder.addTrait(type);
- });
- // check we have an id assigned
- var id = this.options.generateId;
- if (id && !builder.hasProperty(id)) {
- builder.addIdProperty(id);
- }
- var descriptor = builder.build();
- // define package link
- this.definePackage(descriptor, descriptor.allTypes[descriptor.allTypes.length - 1].$pkg);
- return descriptor;
- };
- Registry.prototype.definePackage = function(target, pkg) {
- this.properties.define(target, '$pkg', { value: pkg });
- };
- },{"218":218,"339":339,"62":62,"65":65,"68":68}],68:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Built-in moddle types
- */
- var BUILTINS = {
- String: true,
- Boolean: true,
- Integer: true,
- Real: true,
- Element: true
- };
- /**
- * Converters for built in types from string representations
- */
- var TYPE_CONVERTERS = {
- String: function(s) { return s; },
- Boolean: function(s) { return s === 'true'; },
- Integer: function(s) { return parseInt(s, 10); },
- Real: function(s) { return parseFloat(s, 10); }
- };
- /**
- * Convert a type to its real representation
- */
- module.exports.coerceType = function(type, value) {
- var converter = TYPE_CONVERTERS[type];
- if (converter) {
- return converter(value);
- } else {
- return value;
- }
- };
- /**
- * Return whether the given type is built-in
- */
- module.exports.isBuiltIn = function(type) {
- return !!BUILTINS[type];
- };
- /**
- * Return whether the given type is simple
- */
- module.exports.isSimple = function(type) {
- return !!TYPE_CONVERTERS[type];
- };
- },{}],69:[function(_dereq_,module,exports){
- module.exports={
- "name": "BPMN20",
- "uri": "http://www.omg.org/spec/BPMN/20100524/MODEL",
- "associations": [],
- "types": [
- {
- "name": "Interface",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "operations",
- "type": "Operation",
- "isMany": true
- },
- {
- "name": "implementationRef",
- "type": "String",
- "isAttr": true
- }
- ]
- },
- {
- "name": "Operation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "inMessageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "outMessageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "errorRefs",
- "type": "Error",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "implementationRef",
- "type": "String",
- "isAttr": true
- }
- ]
- },
- {
- "name": "EndPoint",
- "superClass": [
- "RootElement"
- ]
- },
- {
- "name": "Auditing",
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "GlobalTask",
- "superClass": [
- "CallableElement"
- ],
- "properties": [
- {
- "name": "resources",
- "type": "ResourceRole",
- "isMany": true
- }
- ]
- },
- {
- "name": "Monitoring",
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "Performer",
- "superClass": [
- "ResourceRole"
- ]
- },
- {
- "name": "Process",
- "superClass": [
- "FlowElementsContainer",
- "CallableElement"
- ],
- "properties": [
- {
- "name": "processType",
- "type": "ProcessType",
- "isAttr": true
- },
- {
- "name": "isClosed",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "auditing",
- "type": "Auditing"
- },
- {
- "name": "monitoring",
- "type": "Monitoring"
- },
- {
- "name": "properties",
- "type": "Property",
- "isMany": true
- },
- {
- "name": "artifacts",
- "type": "Artifact",
- "isMany": true
- },
- {
- "name": "resources",
- "type": "ResourceRole",
- "isMany": true
- },
- {
- "name": "correlationSubscriptions",
- "type": "CorrelationSubscription",
- "isMany": true
- },
- {
- "name": "supports",
- "type": "Process",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "definitionalCollaborationRef",
- "type": "Collaboration",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "isExecutable",
- "isAttr": true,
- "type": "Boolean"
- }
- ]
- },
- {
- "name": "LaneSet",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "lanes",
- "type": "Lane",
- "isMany": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Lane",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "childLaneSet",
- "type": "LaneSet",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "partitionElementRef",
- "type": "BaseElement",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "flowNodeRef",
- "type": "FlowNode",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "partitionElement",
- "type": "BaseElement"
- }
- ]
- },
- {
- "name": "GlobalManualTask",
- "superClass": [
- "GlobalTask"
- ]
- },
- {
- "name": "ManualTask",
- "superClass": [
- "Task"
- ]
- },
- {
- "name": "UserTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "renderings",
- "type": "Rendering",
- "isMany": true
- },
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Rendering",
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "HumanPerformer",
- "superClass": [
- "Performer"
- ]
- },
- {
- "name": "PotentialOwner",
- "superClass": [
- "HumanPerformer"
- ]
- },
- {
- "name": "GlobalUserTask",
- "superClass": [
- "GlobalTask"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "renderings",
- "type": "Rendering",
- "isMany": true
- }
- ]
- },
- {
- "name": "Gateway",
- "isAbstract": true,
- "superClass": [
- "FlowNode"
- ],
- "properties": [
- {
- "name": "gatewayDirection",
- "type": "GatewayDirection",
- "default": "Unspecified",
- "isAttr": true
- }
- ]
- },
- {
- "name": "EventBasedGateway",
- "superClass": [
- "Gateway"
- ],
- "properties": [
- {
- "name": "instantiate",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "eventGatewayType",
- "type": "EventBasedGatewayType",
- "isAttr": true,
- "default": "Exclusive"
- }
- ]
- },
- {
- "name": "ComplexGateway",
- "superClass": [
- "Gateway"
- ],
- "properties": [
- {
- "name": "activationCondition",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "default",
- "type": "SequenceFlow",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ExclusiveGateway",
- "superClass": [
- "Gateway"
- ],
- "properties": [
- {
- "name": "default",
- "type": "SequenceFlow",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "InclusiveGateway",
- "superClass": [
- "Gateway"
- ],
- "properties": [
- {
- "name": "default",
- "type": "SequenceFlow",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ParallelGateway",
- "superClass": [
- "Gateway"
- ]
- },
- {
- "name": "RootElement",
- "isAbstract": true,
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "Relationship",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "type",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "direction",
- "type": "RelationshipDirection",
- "isAttr": true
- },
- {
- "name": "source",
- "isMany": true,
- "isReference": true,
- "type": "Element"
- },
- {
- "name": "target",
- "isMany": true,
- "isReference": true,
- "type": "Element"
- }
- ]
- },
- {
- "name": "BaseElement",
- "isAbstract": true,
- "properties": [
- {
- "name": "id",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "documentation",
- "type": "Documentation",
- "isMany": true
- },
- {
- "name": "extensionDefinitions",
- "type": "ExtensionDefinition",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "extensionElements",
- "type": "ExtensionElements"
- }
- ]
- },
- {
- "name": "Extension",
- "properties": [
- {
- "name": "mustUnderstand",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "definition",
- "type": "ExtensionDefinition"
- }
- ]
- },
- {
- "name": "ExtensionDefinition",
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "extensionAttributeDefinitions",
- "type": "ExtensionAttributeDefinition",
- "isMany": true
- }
- ]
- },
- {
- "name": "ExtensionAttributeDefinition",
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "type",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "isReference",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "extensionDefinition",
- "type": "ExtensionDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ExtensionElements",
- "properties": [
- {
- "name": "valueRef",
- "isAttr": true,
- "isReference": true,
- "type": "Element"
- },
- {
- "name": "values",
- "type": "Element",
- "isMany": true
- },
- {
- "name": "extensionAttributeDefinition",
- "type": "ExtensionAttributeDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Documentation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "text",
- "type": "String",
- "isBody": true
- },
- {
- "name": "textFormat",
- "default": "text/plain",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Event",
- "isAbstract": true,
- "superClass": [
- "FlowNode",
- "InteractionNode"
- ],
- "properties": [
- {
- "name": "properties",
- "type": "Property",
- "isMany": true
- }
- ]
- },
- {
- "name": "IntermediateCatchEvent",
- "superClass": [
- "CatchEvent"
- ]
- },
- {
- "name": "IntermediateThrowEvent",
- "superClass": [
- "ThrowEvent"
- ]
- },
- {
- "name": "EndEvent",
- "superClass": [
- "ThrowEvent"
- ]
- },
- {
- "name": "StartEvent",
- "superClass": [
- "CatchEvent"
- ],
- "properties": [
- {
- "name": "isInterrupting",
- "default": true,
- "isAttr": true,
- "type": "Boolean"
- }
- ]
- },
- {
- "name": "ThrowEvent",
- "isAbstract": true,
- "superClass": [
- "Event"
- ],
- "properties": [
- {
- "name": "inputSet",
- "type": "InputSet"
- },
- {
- "name": "eventDefinitionRefs",
- "type": "EventDefinition",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "dataInputAssociation",
- "type": "DataInputAssociation",
- "isMany": true
- },
- {
- "name": "dataInputs",
- "type": "DataInput",
- "isMany": true
- },
- {
- "name": "eventDefinitions",
- "type": "EventDefinition",
- "isMany": true
- }
- ]
- },
- {
- "name": "CatchEvent",
- "isAbstract": true,
- "superClass": [
- "Event"
- ],
- "properties": [
- {
- "name": "parallelMultiple",
- "isAttr": true,
- "type": "Boolean",
- "default": false
- },
- {
- "name": "outputSet",
- "type": "OutputSet"
- },
- {
- "name": "eventDefinitionRefs",
- "type": "EventDefinition",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "dataOutputAssociation",
- "type": "DataOutputAssociation",
- "isMany": true
- },
- {
- "name": "dataOutputs",
- "type": "DataOutput",
- "isMany": true
- },
- {
- "name": "eventDefinitions",
- "type": "EventDefinition",
- "isMany": true
- }
- ]
- },
- {
- "name": "BoundaryEvent",
- "superClass": [
- "CatchEvent"
- ],
- "properties": [
- {
- "name": "cancelActivity",
- "default": true,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "attachedToRef",
- "type": "Activity",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "EventDefinition",
- "isAbstract": true,
- "superClass": [
- "RootElement"
- ]
- },
- {
- "name": "CancelEventDefinition",
- "superClass": [
- "EventDefinition"
- ]
- },
- {
- "name": "ErrorEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "errorRef",
- "type": "Error",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "TerminateEventDefinition",
- "superClass": [
- "EventDefinition"
- ]
- },
- {
- "name": "EscalationEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "escalationRef",
- "type": "Escalation",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Escalation",
- "properties": [
- {
- "name": "structureRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "escalationCode",
- "isAttr": true,
- "type": "String"
- }
- ],
- "superClass": [
- "RootElement"
- ]
- },
- {
- "name": "CompensateEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "waitForCompletion",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "activityRef",
- "type": "Activity",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "TimerEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "timeDate",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "timeCycle",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "timeDuration",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "LinkEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "target",
- "type": "LinkEventDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "source",
- "type": "LinkEventDefinition",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "MessageEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "messageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "operationRef",
- "type": "Operation",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ConditionalEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "condition",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "SignalEventDefinition",
- "superClass": [
- "EventDefinition"
- ],
- "properties": [
- {
- "name": "signalRef",
- "type": "Signal",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Signal",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "structureRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "ImplicitThrowEvent",
- "superClass": [
- "ThrowEvent"
- ]
- },
- {
- "name": "DataState",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "ItemAwareElement",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "itemSubjectRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "dataState",
- "type": "DataState"
- }
- ]
- },
- {
- "name": "DataAssociation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "transformation",
- "type": "FormalExpression"
- },
- {
- "name": "assignment",
- "type": "Assignment",
- "isMany": true
- },
- {
- "name": "sourceRef",
- "type": "ItemAwareElement",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "targetRef",
- "type": "ItemAwareElement",
- "isReference": true
- }
- ]
- },
- {
- "name": "DataInput",
- "superClass": [
- "ItemAwareElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "isCollection",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "inputSetRefs",
- "type": "InputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "inputSetWithOptional",
- "type": "InputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "inputSetWithWhileExecuting",
- "type": "InputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "DataOutput",
- "superClass": [
- "ItemAwareElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "isCollection",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "outputSetRefs",
- "type": "OutputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "outputSetWithOptional",
- "type": "OutputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "outputSetWithWhileExecuting",
- "type": "OutputSet",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "InputSet",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "dataInputRefs",
- "type": "DataInput",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "optionalInputRefs",
- "type": "DataInput",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "whileExecutingInputRefs",
- "type": "DataInput",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "outputSetRefs",
- "type": "OutputSet",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "OutputSet",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "dataOutputRefs",
- "type": "DataOutput",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "inputSetRefs",
- "type": "InputSet",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "optionalOutputRefs",
- "type": "DataOutput",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "whileExecutingOutputRefs",
- "type": "DataOutput",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Property",
- "superClass": [
- "ItemAwareElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "DataInputAssociation",
- "superClass": [
- "DataAssociation"
- ]
- },
- {
- "name": "DataOutputAssociation",
- "superClass": [
- "DataAssociation"
- ]
- },
- {
- "name": "InputOutputSpecification",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "dataInputs",
- "type": "DataInput",
- "isMany": true
- },
- {
- "name": "dataOutputs",
- "type": "DataOutput",
- "isMany": true
- },
- {
- "name": "inputSets",
- "type": "InputSet",
- "isMany": true
- },
- {
- "name": "outputSets",
- "type": "OutputSet",
- "isMany": true
- }
- ]
- },
- {
- "name": "DataObject",
- "superClass": [
- "FlowElement",
- "ItemAwareElement"
- ],
- "properties": [
- {
- "name": "isCollection",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- }
- ]
- },
- {
- "name": "InputOutputBinding",
- "properties": [
- {
- "name": "inputDataRef",
- "type": "InputSet",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "outputDataRef",
- "type": "OutputSet",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "operationRef",
- "type": "Operation",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Assignment",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "from",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "to",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "DataStore",
- "superClass": [
- "RootElement",
- "ItemAwareElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "capacity",
- "isAttr": true,
- "type": "Integer"
- },
- {
- "name": "isUnlimited",
- "default": true,
- "isAttr": true,
- "type": "Boolean"
- }
- ]
- },
- {
- "name": "DataStoreReference",
- "superClass": [
- "ItemAwareElement",
- "FlowElement"
- ],
- "properties": [
- {
- "name": "dataStoreRef",
- "type": "DataStore",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "DataObjectReference",
- "superClass": [
- "ItemAwareElement",
- "FlowElement"
- ],
- "properties": [
- {
- "name": "dataObjectRef",
- "type": "DataObject",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ConversationLink",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "sourceRef",
- "type": "InteractionNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "targetRef",
- "type": "InteractionNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "ConversationAssociation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "innerConversationNodeRef",
- "type": "ConversationNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "outerConversationNodeRef",
- "type": "ConversationNode",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "CallConversation",
- "superClass": [
- "ConversationNode"
- ],
- "properties": [
- {
- "name": "calledCollaborationRef",
- "type": "Collaboration",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "participantAssociations",
- "type": "ParticipantAssociation",
- "isMany": true
- }
- ]
- },
- {
- "name": "Conversation",
- "superClass": [
- "ConversationNode"
- ]
- },
- {
- "name": "SubConversation",
- "superClass": [
- "ConversationNode"
- ],
- "properties": [
- {
- "name": "conversationNodes",
- "type": "ConversationNode",
- "isMany": true
- }
- ]
- },
- {
- "name": "ConversationNode",
- "isAbstract": true,
- "superClass": [
- "InteractionNode",
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "participantRefs",
- "type": "Participant",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "messageFlowRefs",
- "type": "MessageFlow",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "correlationKeys",
- "type": "CorrelationKey",
- "isMany": true
- }
- ]
- },
- {
- "name": "GlobalConversation",
- "superClass": [
- "Collaboration"
- ]
- },
- {
- "name": "PartnerEntity",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "participantRef",
- "type": "Participant",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "PartnerRole",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "participantRef",
- "type": "Participant",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "CorrelationProperty",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "correlationPropertyRetrievalExpression",
- "type": "CorrelationPropertyRetrievalExpression",
- "isMany": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "type",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Error",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "structureRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "errorCode",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "CorrelationKey",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "correlationPropertyRef",
- "type": "CorrelationProperty",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Expression",
- "superClass": [
- "BaseElement"
- ],
- "isAbstract": true
- },
- {
- "name": "FormalExpression",
- "superClass": [
- "Expression"
- ],
- "properties": [
- {
- "name": "language",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "body",
- "type": "String",
- "isBody": true
- },
- {
- "name": "evaluatesToTypeRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Message",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "itemRef",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ItemDefinition",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "itemKind",
- "type": "ItemKind",
- "isAttr": true
- },
- {
- "name": "structureRef",
- "type": "String",
- "isAttr": true
- },
- {
- "name": "isCollection",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "import",
- "type": "Import",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "FlowElement",
- "isAbstract": true,
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "auditing",
- "type": "Auditing"
- },
- {
- "name": "monitoring",
- "type": "Monitoring"
- },
- {
- "name": "categoryValueRef",
- "type": "CategoryValue",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "SequenceFlow",
- "superClass": [
- "FlowElement"
- ],
- "properties": [
- {
- "name": "isImmediate",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "conditionExpression",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "sourceRef",
- "type": "FlowNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "targetRef",
- "type": "FlowNode",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "FlowElementsContainer",
- "isAbstract": true,
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "laneSets",
- "type": "LaneSet",
- "isMany": true
- },
- {
- "name": "flowElements",
- "type": "FlowElement",
- "isMany": true
- }
- ]
- },
- {
- "name": "CallableElement",
- "isAbstract": true,
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "ioSpecification",
- "type": "InputOutputSpecification",
- "xml": {
- "serialize": "property"
- }
- },
- {
- "name": "supportedInterfaceRefs",
- "type": "Interface",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "ioBinding",
- "type": "InputOutputBinding",
- "isMany": true,
- "xml": {
- "serialize": "property"
- }
- }
- ]
- },
- {
- "name": "FlowNode",
- "isAbstract": true,
- "superClass": [
- "FlowElement"
- ],
- "properties": [
- {
- "name": "incoming",
- "type": "SequenceFlow",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "outgoing",
- "type": "SequenceFlow",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "lanes",
- "type": "Lane",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "CorrelationPropertyRetrievalExpression",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "messagePath",
- "type": "FormalExpression"
- },
- {
- "name": "messageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "CorrelationPropertyBinding",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "dataPath",
- "type": "FormalExpression"
- },
- {
- "name": "correlationPropertyRef",
- "type": "CorrelationProperty",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Resource",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "resourceParameters",
- "type": "ResourceParameter",
- "isMany": true
- }
- ]
- },
- {
- "name": "ResourceParameter",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "isRequired",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "type",
- "type": "ItemDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "CorrelationSubscription",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "correlationKeyRef",
- "type": "CorrelationKey",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "correlationPropertyBinding",
- "type": "CorrelationPropertyBinding",
- "isMany": true
- }
- ]
- },
- {
- "name": "MessageFlow",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "sourceRef",
- "type": "InteractionNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "targetRef",
- "type": "InteractionNode",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "messageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "MessageFlowAssociation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "innerMessageFlowRef",
- "type": "MessageFlow",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "outerMessageFlowRef",
- "type": "MessageFlow",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "InteractionNode",
- "isAbstract": true,
- "properties": [
- {
- "name": "incomingConversationLinks",
- "type": "ConversationLink",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "outgoingConversationLinks",
- "type": "ConversationLink",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Participant",
- "superClass": [
- "InteractionNode",
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "interfaceRefs",
- "type": "Interface",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "participantMultiplicity",
- "type": "ParticipantMultiplicity"
- },
- {
- "name": "endPointRefs",
- "type": "EndPoint",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "processRef",
- "type": "Process",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ParticipantAssociation",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "innerParticipantRef",
- "type": "Participant",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "outerParticipantRef",
- "type": "Participant",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ParticipantMultiplicity",
- "properties": [
- {
- "name": "minimum",
- "default": 0,
- "isAttr": true,
- "type": "Integer"
- },
- {
- "name": "maximum",
- "default": 1,
- "isAttr": true,
- "type": "Integer"
- }
- ]
- },
- {
- "name": "Collaboration",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "isClosed",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "choreographyRef",
- "type": "Choreography",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "artifacts",
- "type": "Artifact",
- "isMany": true
- },
- {
- "name": "participantAssociations",
- "type": "ParticipantAssociation",
- "isMany": true
- },
- {
- "name": "messageFlowAssociations",
- "type": "MessageFlowAssociation",
- "isMany": true
- },
- {
- "name": "conversationAssociations",
- "type": "ConversationAssociation"
- },
- {
- "name": "participants",
- "type": "Participant",
- "isMany": true
- },
- {
- "name": "messageFlows",
- "type": "MessageFlow",
- "isMany": true
- },
- {
- "name": "correlationKeys",
- "type": "CorrelationKey",
- "isMany": true
- },
- {
- "name": "conversations",
- "type": "ConversationNode",
- "isMany": true
- },
- {
- "name": "conversationLinks",
- "type": "ConversationLink",
- "isMany": true
- }
- ]
- },
- {
- "name": "ChoreographyActivity",
- "isAbstract": true,
- "superClass": [
- "FlowNode"
- ],
- "properties": [
- {
- "name": "participantRefs",
- "type": "Participant",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "initiatingParticipantRef",
- "type": "Participant",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "correlationKeys",
- "type": "CorrelationKey",
- "isMany": true
- },
- {
- "name": "loopType",
- "type": "ChoreographyLoopType",
- "default": "None",
- "isAttr": true
- }
- ]
- },
- {
- "name": "CallChoreography",
- "superClass": [
- "ChoreographyActivity"
- ],
- "properties": [
- {
- "name": "calledChoreographyRef",
- "type": "Choreography",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "participantAssociations",
- "type": "ParticipantAssociation",
- "isMany": true
- }
- ]
- },
- {
- "name": "SubChoreography",
- "superClass": [
- "ChoreographyActivity",
- "FlowElementsContainer"
- ],
- "properties": [
- {
- "name": "artifacts",
- "type": "Artifact",
- "isMany": true
- }
- ]
- },
- {
- "name": "ChoreographyTask",
- "superClass": [
- "ChoreographyActivity"
- ],
- "properties": [
- {
- "name": "messageFlowRef",
- "type": "MessageFlow",
- "isMany": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Choreography",
- "superClass": [
- "FlowElementsContainer",
- "Collaboration"
- ]
- },
- {
- "name": "GlobalChoreographyTask",
- "superClass": [
- "Choreography"
- ],
- "properties": [
- {
- "name": "initiatingParticipantRef",
- "type": "Participant",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "TextAnnotation",
- "superClass": [
- "Artifact"
- ],
- "properties": [
- {
- "name": "text",
- "type": "String"
- },
- {
- "name": "textFormat",
- "default": "text/plain",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Group",
- "superClass": [
- "Artifact"
- ],
- "properties": [
- {
- "name": "categoryValueRef",
- "type": "CategoryValue",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Association",
- "superClass": [
- "Artifact"
- ],
- "properties": [
- {
- "name": "associationDirection",
- "type": "AssociationDirection",
- "isAttr": true
- },
- {
- "name": "sourceRef",
- "type": "BaseElement",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "targetRef",
- "type": "BaseElement",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "Category",
- "superClass": [
- "RootElement"
- ],
- "properties": [
- {
- "name": "categoryValue",
- "type": "CategoryValue",
- "isMany": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Artifact",
- "isAbstract": true,
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "CategoryValue",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "categorizedFlowElements",
- "type": "FlowElement",
- "isVirtual": true,
- "isMany": true,
- "isReference": true
- },
- {
- "name": "value",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Activity",
- "isAbstract": true,
- "superClass": [
- "FlowNode"
- ],
- "properties": [
- {
- "name": "isForCompensation",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "default",
- "type": "SequenceFlow",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "ioSpecification",
- "type": "InputOutputSpecification",
- "xml": {
- "serialize": "property"
- }
- },
- {
- "name": "boundaryEventRefs",
- "type": "BoundaryEvent",
- "isMany": true,
- "isReference": true
- },
- {
- "name": "properties",
- "type": "Property",
- "isMany": true
- },
- {
- "name": "dataInputAssociations",
- "type": "DataInputAssociation",
- "isMany": true
- },
- {
- "name": "dataOutputAssociations",
- "type": "DataOutputAssociation",
- "isMany": true
- },
- {
- "name": "startQuantity",
- "default": 1,
- "isAttr": true,
- "type": "Integer"
- },
- {
- "name": "resources",
- "type": "ResourceRole",
- "isMany": true
- },
- {
- "name": "completionQuantity",
- "default": 1,
- "isAttr": true,
- "type": "Integer"
- },
- {
- "name": "loopCharacteristics",
- "type": "LoopCharacteristics"
- }
- ]
- },
- {
- "name": "ServiceTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "operationRef",
- "type": "Operation",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "SubProcess",
- "superClass": [
- "Activity",
- "FlowElementsContainer",
- "InteractionNode"
- ],
- "properties": [
- {
- "name": "triggeredByEvent",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "artifacts",
- "type": "Artifact",
- "isMany": true
- }
- ]
- },
- {
- "name": "LoopCharacteristics",
- "isAbstract": true,
- "superClass": [
- "BaseElement"
- ]
- },
- {
- "name": "MultiInstanceLoopCharacteristics",
- "superClass": [
- "LoopCharacteristics"
- ],
- "properties": [
- {
- "name": "isSequential",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "behavior",
- "type": "MultiInstanceBehavior",
- "default": "All",
- "isAttr": true
- },
- {
- "name": "loopCardinality",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "loopDataInputRef",
- "type": "ItemAwareElement",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "loopDataOutputRef",
- "type": "ItemAwareElement",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "inputDataItem",
- "type": "DataInput"
- },
- {
- "name": "outputDataItem",
- "type": "DataOutput"
- },
- {
- "name": "completionCondition",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "complexBehaviorDefinition",
- "type": "ComplexBehaviorDefinition",
- "isMany": true
- },
- {
- "name": "oneBehaviorEventRef",
- "type": "EventDefinition",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "noneBehaviorEventRef",
- "type": "EventDefinition",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "StandardLoopCharacteristics",
- "superClass": [
- "LoopCharacteristics"
- ],
- "properties": [
- {
- "name": "testBefore",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "loopCondition",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "loopMaximum",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "CallActivity",
- "superClass": [
- "Activity"
- ],
- "properties": [
- {
- "name": "calledElement",
- "type": "String",
- "isAttr": true
- }
- ]
- },
- {
- "name": "Task",
- "superClass": [
- "Activity",
- "InteractionNode"
- ]
- },
- {
- "name": "SendTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "operationRef",
- "type": "Operation",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "messageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ReceiveTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "instantiate",
- "default": false,
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "operationRef",
- "type": "Operation",
- "isAttr": true,
- "isReference": true
- },
- {
- "name": "messageRef",
- "type": "Message",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ScriptTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "scriptFormat",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "script",
- "type": "String"
- }
- ]
- },
- {
- "name": "BusinessRuleTask",
- "superClass": [
- "Task"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "AdHocSubProcess",
- "superClass": [
- "SubProcess"
- ],
- "properties": [
- {
- "name": "completionCondition",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "ordering",
- "type": "AdHocOrdering",
- "isAttr": true
- },
- {
- "name": "cancelRemainingInstances",
- "default": true,
- "isAttr": true,
- "type": "Boolean"
- }
- ]
- },
- {
- "name": "Transaction",
- "superClass": [
- "SubProcess"
- ],
- "properties": [
- {
- "name": "protocol",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "method",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "GlobalScriptTask",
- "superClass": [
- "GlobalTask"
- ],
- "properties": [
- {
- "name": "scriptLanguage",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "script",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "GlobalBusinessRuleTask",
- "superClass": [
- "GlobalTask"
- ],
- "properties": [
- {
- "name": "implementation",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "ComplexBehaviorDefinition",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "condition",
- "type": "FormalExpression"
- },
- {
- "name": "event",
- "type": "ImplicitThrowEvent"
- }
- ]
- },
- {
- "name": "ResourceRole",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "resourceRef",
- "type": "Resource",
- "isReference": true
- },
- {
- "name": "resourceParameterBindings",
- "type": "ResourceParameterBinding",
- "isMany": true
- },
- {
- "name": "resourceAssignmentExpression",
- "type": "ResourceAssignmentExpression"
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "ResourceParameterBinding",
- "properties": [
- {
- "name": "expression",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- },
- {
- "name": "parameterRef",
- "type": "ResourceParameter",
- "isAttr": true,
- "isReference": true
- }
- ]
- },
- {
- "name": "ResourceAssignmentExpression",
- "properties": [
- {
- "name": "expression",
- "type": "Expression",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "Import",
- "properties": [
- {
- "name": "importType",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "location",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "namespace",
- "isAttr": true,
- "type": "String"
- }
- ]
- },
- {
- "name": "Definitions",
- "superClass": [
- "BaseElement"
- ],
- "properties": [
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "targetNamespace",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "expressionLanguage",
- "default": "http://www.w3.org/1999/XPath",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "typeLanguage",
- "default": "http://www.w3.org/2001/XMLSchema",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "imports",
- "type": "Import",
- "isMany": true
- },
- {
- "name": "extensions",
- "type": "Extension",
- "isMany": true
- },
- {
- "name": "rootElements",
- "type": "RootElement",
- "isMany": true
- },
- {
- "name": "diagrams",
- "isMany": true,
- "type": "bpmndi:BPMNDiagram"
- },
- {
- "name": "exporter",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "relationships",
- "type": "Relationship",
- "isMany": true
- },
- {
- "name": "exporterVersion",
- "isAttr": true,
- "type": "String"
- }
- ]
- }
- ],
- "emumerations": [
- {
- "name": "ProcessType",
- "literalValues": [
- {
- "name": "None"
- },
- {
- "name": "Public"
- },
- {
- "name": "Private"
- }
- ]
- },
- {
- "name": "GatewayDirection",
- "literalValues": [
- {
- "name": "Unspecified"
- },
- {
- "name": "Converging"
- },
- {
- "name": "Diverging"
- },
- {
- "name": "Mixed"
- }
- ]
- },
- {
- "name": "EventBasedGatewayType",
- "literalValues": [
- {
- "name": "Parallel"
- },
- {
- "name": "Exclusive"
- }
- ]
- },
- {
- "name": "RelationshipDirection",
- "literalValues": [
- {
- "name": "None"
- },
- {
- "name": "Forward"
- },
- {
- "name": "Backward"
- },
- {
- "name": "Both"
- }
- ]
- },
- {
- "name": "ItemKind",
- "literalValues": [
- {
- "name": "Physical"
- },
- {
- "name": "Information"
- }
- ]
- },
- {
- "name": "ChoreographyLoopType",
- "literalValues": [
- {
- "name": "None"
- },
- {
- "name": "Standard"
- },
- {
- "name": "MultiInstanceSequential"
- },
- {
- "name": "MultiInstanceParallel"
- }
- ]
- },
- {
- "name": "AssociationDirection",
- "literalValues": [
- {
- "name": "None"
- },
- {
- "name": "One"
- },
- {
- "name": "Both"
- }
- ]
- },
- {
- "name": "MultiInstanceBehavior",
- "literalValues": [
- {
- "name": "None"
- },
- {
- "name": "One"
- },
- {
- "name": "All"
- },
- {
- "name": "Complex"
- }
- ]
- },
- {
- "name": "AdHocOrdering",
- "literalValues": [
- {
- "name": "Parallel"
- },
- {
- "name": "Sequential"
- }
- ]
- }
- ],
- "prefix": "bpmn",
- "xml": {
- "tagAlias": "lowerCase",
- "typePrefix": "t"
- }
- }
- },{}],70:[function(_dereq_,module,exports){
- module.exports={
- "name": "BPMNDI",
- "uri": "http://www.omg.org/spec/BPMN/20100524/DI",
- "types": [
- {
- "name": "BPMNDiagram",
- "properties": [
- {
- "name": "plane",
- "type": "BPMNPlane",
- "redefines": "di:Diagram#rootElement"
- },
- {
- "name": "labelStyle",
- "type": "BPMNLabelStyle",
- "isMany": true
- }
- ],
- "superClass": [
- "di:Diagram"
- ]
- },
- {
- "name": "BPMNPlane",
- "properties": [
- {
- "name": "bpmnElement",
- "isAttr": true,
- "isReference": true,
- "type": "bpmn:BaseElement",
- "redefines": "di:DiagramElement#modelElement"
- }
- ],
- "superClass": [
- "di:Plane"
- ]
- },
- {
- "name": "BPMNShape",
- "properties": [
- {
- "name": "bpmnElement",
- "isAttr": true,
- "isReference": true,
- "type": "bpmn:BaseElement",
- "redefines": "di:DiagramElement#modelElement"
- },
- {
- "name": "isHorizontal",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "isExpanded",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "isMarkerVisible",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "label",
- "type": "BPMNLabel"
- },
- {
- "name": "isMessageVisible",
- "isAttr": true,
- "type": "Boolean"
- },
- {
- "name": "participantBandKind",
- "type": "ParticipantBandKind",
- "isAttr": true
- },
- {
- "name": "choreographyActivityShape",
- "type": "BPMNShape",
- "isAttr": true,
- "isReference": true
- }
- ],
- "superClass": [
- "di:LabeledShape"
- ]
- },
- {
- "name": "BPMNEdge",
- "properties": [
- {
- "name": "label",
- "type": "BPMNLabel"
- },
- {
- "name": "bpmnElement",
- "isAttr": true,
- "isReference": true,
- "type": "bpmn:BaseElement",
- "redefines": "di:DiagramElement#modelElement"
- },
- {
- "name": "sourceElement",
- "isAttr": true,
- "isReference": true,
- "type": "di:DiagramElement",
- "redefines": "di:Edge#source"
- },
- {
- "name": "targetElement",
- "isAttr": true,
- "isReference": true,
- "type": "di:DiagramElement",
- "redefines": "di:Edge#target"
- },
- {
- "name": "messageVisibleKind",
- "type": "MessageVisibleKind",
- "isAttr": true,
- "default": "initiating"
- }
- ],
- "superClass": [
- "di:LabeledEdge"
- ]
- },
- {
- "name": "BPMNLabel",
- "properties": [
- {
- "name": "labelStyle",
- "type": "BPMNLabelStyle",
- "isAttr": true,
- "isReference": true,
- "redefines": "di:DiagramElement#style"
- }
- ],
- "superClass": [
- "di:Label"
- ]
- },
- {
- "name": "BPMNLabelStyle",
- "properties": [
- {
- "name": "font",
- "type": "dc:Font"
- }
- ],
- "superClass": [
- "di:Style"
- ]
- }
- ],
- "emumerations": [
- {
- "name": "ParticipantBandKind",
- "literalValues": [
- {
- "name": "top_initiating"
- },
- {
- "name": "middle_initiating"
- },
- {
- "name": "bottom_initiating"
- },
- {
- "name": "top_non_initiating"
- },
- {
- "name": "middle_non_initiating"
- },
- {
- "name": "bottom_non_initiating"
- }
- ]
- },
- {
- "name": "MessageVisibleKind",
- "literalValues": [
- {
- "name": "initiating"
- },
- {
- "name": "non_initiating"
- }
- ]
- }
- ],
- "associations": [],
- "prefix": "bpmndi"
- }
- },{}],71:[function(_dereq_,module,exports){
- module.exports={
- "name": "DC",
- "uri": "http://www.omg.org/spec/DD/20100524/DC",
- "types": [
- {
- "name": "Boolean"
- },
- {
- "name": "Integer"
- },
- {
- "name": "Real"
- },
- {
- "name": "String"
- },
- {
- "name": "Font",
- "properties": [
- {
- "name": "name",
- "type": "String",
- "isAttr": true
- },
- {
- "name": "size",
- "type": "Real",
- "isAttr": true
- },
- {
- "name": "isBold",
- "type": "Boolean",
- "isAttr": true
- },
- {
- "name": "isItalic",
- "type": "Boolean",
- "isAttr": true
- },
- {
- "name": "isUnderline",
- "type": "Boolean",
- "isAttr": true
- },
- {
- "name": "isStrikeThrough",
- "type": "Boolean",
- "isAttr": true
- }
- ]
- },
- {
- "name": "Point",
- "properties": [
- {
- "name": "x",
- "type": "Real",
- "default": "0",
- "isAttr": true
- },
- {
- "name": "y",
- "type": "Real",
- "default": "0",
- "isAttr": true
- }
- ]
- },
- {
- "name": "Bounds",
- "properties": [
- {
- "name": "x",
- "type": "Real",
- "default": "0",
- "isAttr": true
- },
- {
- "name": "y",
- "type": "Real",
- "default": "0",
- "isAttr": true
- },
- {
- "name": "width",
- "type": "Real",
- "isAttr": true
- },
- {
- "name": "height",
- "type": "Real",
- "isAttr": true
- }
- ]
- }
- ],
- "prefix": "dc",
- "associations": []
- }
- },{}],72:[function(_dereq_,module,exports){
- module.exports={
- "name": "DI",
- "uri": "http://www.omg.org/spec/DD/20100524/DI",
- "types": [
- {
- "name": "DiagramElement",
- "isAbstract": true,
- "properties": [
- {
- "name": "extension",
- "type": "Extension"
- },
- {
- "name": "owningDiagram",
- "type": "Diagram",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true
- },
- {
- "name": "owningElement",
- "type": "DiagramElement",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true
- },
- {
- "name": "modelElement",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true,
- "type": "Element"
- },
- {
- "name": "style",
- "type": "Style",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true
- },
- {
- "name": "ownedElement",
- "type": "DiagramElement",
- "isReadOnly": true,
- "isVirtual": true,
- "isMany": true
- }
- ]
- },
- {
- "name": "Node",
- "isAbstract": true,
- "superClass": [
- "DiagramElement"
- ]
- },
- {
- "name": "Edge",
- "isAbstract": true,
- "superClass": [
- "DiagramElement"
- ],
- "properties": [
- {
- "name": "source",
- "type": "DiagramElement",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true
- },
- {
- "name": "target",
- "type": "DiagramElement",
- "isReadOnly": true,
- "isVirtual": true,
- "isReference": true
- },
- {
- "name": "waypoint",
- "isUnique": false,
- "isMany": true,
- "type": "dc:Point",
- "xml": {
- "serialize": "xsi:type"
- }
- }
- ]
- },
- {
- "name": "Diagram",
- "isAbstract": true,
- "properties": [
- {
- "name": "rootElement",
- "type": "DiagramElement",
- "isReadOnly": true,
- "isVirtual": true
- },
- {
- "name": "name",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "documentation",
- "isAttr": true,
- "type": "String"
- },
- {
- "name": "resolution",
- "isAttr": true,
- "type": "Real"
- },
- {
- "name": "ownedStyle",
- "type": "Style",
- "isReadOnly": true,
- "isVirtual": true,
- "isMany": true
- }
- ]
- },
- {
- "name": "Shape",
- "isAbstract": true,
- "superClass": [
- "Node"
- ],
- "properties": [
- {
- "name": "bounds",
- "type": "dc:Bounds"
- }
- ]
- },
- {
- "name": "Plane",
- "isAbstract": true,
- "superClass": [
- "Node"
- ],
- "properties": [
- {
- "name": "planeElement",
- "type": "DiagramElement",
- "subsettedProperty": "DiagramElement-ownedElement",
- "isMany": true
- }
- ]
- },
- {
- "name": "LabeledEdge",
- "isAbstract": true,
- "superClass": [
- "Edge"
- ],
- "properties": [
- {
- "name": "ownedLabel",
- "type": "Label",
- "isReadOnly": true,
- "subsettedProperty": "DiagramElement-ownedElement",
- "isVirtual": true,
- "isMany": true
- }
- ]
- },
- {
- "name": "LabeledShape",
- "isAbstract": true,
- "superClass": [
- "Shape"
- ],
- "properties": [
- {
- "name": "ownedLabel",
- "type": "Label",
- "isReadOnly": true,
- "subsettedProperty": "DiagramElement-ownedElement",
- "isVirtual": true,
- "isMany": true
- }
- ]
- },
- {
- "name": "Label",
- "isAbstract": true,
- "superClass": [
- "Node"
- ],
- "properties": [
- {
- "name": "bounds",
- "type": "dc:Bounds"
- }
- ]
- },
- {
- "name": "Style",
- "isAbstract": true
- },
- {
- "name": "Extension",
- "properties": [
- {
- "name": "values",
- "type": "Element",
- "isMany": true
- }
- ]
- }
- ],
- "associations": [],
- "prefix": "di",
- "xml": {
- "tagAlias": "lowerCase"
- }
- }
- },{}],73:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(108) ],
- __init__: [ 'directEditing' ],
- directEditing: [ 'type', _dereq_(74) ]
- };
- },{"108":108,"74":74}],74:[function(_dereq_,module,exports){
- 'use strict';
- var bind = _dereq_(227),
- find = _dereq_(217);
- var TextBox = _dereq_(75);
- /**
- * A direct editing component that allows users
- * to edit an elements text directly in the diagram
- *
- * @param {EventBus} eventBus the event bus
- */
- function DirectEditing(eventBus, canvas) {
- this._eventBus = eventBus;
- this._providers = [];
- this._textbox = new TextBox({
- container: canvas.getContainer(),
- keyHandler: bind(this._handleKey, this)
- });
- }
- DirectEditing.$inject = [ 'eventBus', 'canvas' ];
- /**
- * Register a direct editing provider
- * @param {Object} provider the provider, must expose an #activate(element) method that returns
- * an activation context ({ bounds: {x, y, width, height }, text }) if
- * direct editing is available for the given element.
- * Additionally the provider must expose a #update(element, value) method
- * to receive direct editing updates.
- */
- DirectEditing.prototype.registerProvider = function(provider) {
- this._providers.push(provider);
- };
- /**
- * Returns true if direct editing is currently active
- *
- * @return {Boolean}
- */
- DirectEditing.prototype.isActive = function() {
- return !!this._active;
- };
- /**
- * Cancel direct editing, if it is currently active
- */
- DirectEditing.prototype.cancel = function() {
- if (!this._active) {
- return;
- }
- this._fire('cancel');
- this.close();
- };
- DirectEditing.prototype._fire = function(event) {
- this._eventBus.fire('directEditing.' + event, { active: this._active });
- };
- DirectEditing.prototype.close = function() {
- this._textbox.destroy();
- this._fire('deactivate');
- this._active = null;
- };
- DirectEditing.prototype.complete = function() {
- var active = this._active;
- if (!active) {
- return;
- }
- var text = this.getValue();
- if (text !== active.context.text) {
- active.provider.update(active.element, text, active.context.text);
- }
- this._fire('complete');
- this.close();
- };
- DirectEditing.prototype.getValue = function() {
- return this._textbox.getValue();
- };
- DirectEditing.prototype._handleKey = function(e) {
- // stop bubble
- e.stopPropagation();
- var key = e.keyCode || e.charCode;
- // ESC
- if (key === 27) {
- e.preventDefault();
- return this.cancel();
- }
- // Enter
- if (key === 13 && !e.shiftKey) {
- e.preventDefault();
- return this.complete();
- }
- };
- /**
- * Activate direct editing on the given element
- *
- * @param {Object} ElementDescriptor the descriptor for a shape or connection
- * @return {Boolean} true if the activation was possible
- */
- DirectEditing.prototype.activate = function(element) {
- if (this.isActive()) {
- this.cancel();
- }
- // the direct editing context
- var context;
- var provider = find(this._providers, function(p) {
- return !!(context = p.activate(element)) ? p : null;
- });
- // check if activation took place
- if (context) {
- this._textbox.create(context.bounds, context.style, context.text);
- this._active = {
- element: element,
- context: context,
- provider: provider
- };
- this._fire('activate');
- }
- return !!context;
- };
- module.exports = DirectEditing;
- },{"217":217,"227":227,"75":75}],75:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- domEvent = _dereq_(357),
- domRemove = _dereq_(360);
- function stopPropagation(event) {
- event.stopPropagation();
- }
- function TextBox(options) {
- this.container = options.container;
- this.textarea = document.createElement('textarea');
- this.keyHandler = options.keyHandler || function() {};
- }
- module.exports = TextBox;
- TextBox.prototype.create = function(bounds, style, value) {
- var textarea = this.textarea,
- container = this.container;
- assign(textarea.style, {
- width: bounds.width + 'px',
- height: bounds.height + 'px',
- left: bounds.x + 'px',
- top: bounds.y + 'px',
- position: 'absolute',
- textAlign: 'center',
- boxSizing: 'border-box'
- }, style || {});
- textarea.value = value;
- textarea.title = 'Press SHIFT+Enter for line feed';
- domEvent.bind(textarea, 'keydown', this.keyHandler);
- domEvent.bind(textarea, 'mousedown', stopPropagation);
- container.appendChild(textarea);
- setTimeout(function() {
- if (textarea.parent) {
- textarea.select();
- }
- textarea.focus();
- }, 100);
- };
- TextBox.prototype.destroy = function() {
- var textarea = this.textarea;
- textarea.value = '';
- domEvent.unbind(textarea, 'keydown', this.keyHandler);
- domEvent.unbind(textarea, 'mousedown', stopPropagation);
- domRemove(textarea);
- };
- TextBox.prototype.getValue = function() {
- return this.textarea.value;
- };
- },{"339":339,"357":357,"360":360}],76:[function(_dereq_,module,exports){
- module.exports = _dereq_(77);
- },{"77":77}],77:[function(_dereq_,module,exports){
- 'use strict';
- var di = _dereq_(202);
- /**
- * Bootstrap an injector from a list of modules, instantiating a number of default components
- *
- * @ignore
- * @param {Array<didi.Module>} bootstrapModules
- *
- * @return {didi.Injector} a injector to use to access the components
- */
- function bootstrap(bootstrapModules) {
- var modules = [],
- components = [];
- function hasModule(m) {
- return modules.indexOf(m) >= 0;
- }
- function addModule(m) {
- modules.push(m);
- }
- function visit(m) {
- if (hasModule(m)) {
- return;
- }
- (m.__depends__ || []).forEach(visit);
- if (hasModule(m)) {
- return;
- }
- addModule(m);
- (m.__init__ || []).forEach(function(c) {
- components.push(c);
- });
- }
- bootstrapModules.forEach(visit);
- var injector = new di.Injector(modules);
- components.forEach(function(c) {
- try {
- // eagerly resolve component (fn or string)
- injector[typeof c === 'string' ? 'get' : 'invoke'](c);
- } catch (e) {
- console.error('Failed to instantiate component');
- console.error(e.stack);
- throw e;
- }
- });
- return injector;
- }
- /**
- * Creates an injector from passed options.
- *
- * @ignore
- * @param {Object} options
- * @return {didi.Injector}
- */
- function createInjector(options) {
- options = options || {};
- var configModule = {
- 'config': ['value', options]
- };
- var coreModule = _dereq_(86);
- var modules = [ configModule, coreModule ].concat(options.modules || []);
- return bootstrap(modules);
- }
- /**
- * The main diagram-js entry point that bootstraps the diagram with the given
- * configuration.
- *
- * To register extensions with the diagram, pass them as Array<didi.Module> to the constructor.
- *
- * @class djs.Diagram
- * @memberOf djs
- * @constructor
- *
- * @example
- *
- * <caption>Creating a plug-in that logs whenever a shape is added to the canvas.</caption>
- *
- * // plug-in implemenentation
- * function MyLoggingPlugin(eventBus) {
- * eventBus.on('shape.added', function(event) {
- * console.log('shape ', event.shape, ' was added to the diagram');
- * });
- * }
- *
- * // export as module
- * module.exports = {
- * __init__: [ 'myLoggingPlugin' ],
- * myLoggingPlugin: [ 'type', MyLoggingPlugin ]
- * };
- *
- *
- * // instantiate the diagram with the new plug-in
- *
- * var diagram = new Diagram({ modules: [ require('path-to-my-logging-plugin') ] });
- *
- * diagram.invoke([ 'canvas', function(canvas) {
- * // add shape to drawing canvas
- * canvas.addShape({ x: 10, y: 10 });
- * });
- *
- * // 'shape ... was added to the diagram' logged to console
- *
- * @param {Object} options
- * @param {Array<didi.Module>} [options.modules] external modules to instantiate with the diagram
- * @param {didi.Injector} [injector] an (optional) injector to bootstrap the diagram with
- */
- function Diagram(options, injector) {
- // create injector unless explicitly specified
- this.injector = injector = injector || createInjector(options);
- // API
- /**
- * Resolves a diagram service
- *
- * @method Diagram#get
- *
- * @param {String} name the name of the diagram service to be retrieved
- * @param {Object} [locals] a number of locals to use to resolve certain dependencies
- */
- this.get = injector.get;
- /**
- * Executes a function into which diagram services are injected
- *
- * @method Diagram#invoke
- *
- * @param {Function|Object[]} fn the function to resolve
- * @param {Object} locals a number of locals to use to resolve certain dependencies
- */
- this.invoke = injector.invoke;
- // init
- // indicate via event
- /**
- * An event indicating that all plug-ins are loaded.
- *
- * Use this event to fire other events to interested plug-ins
- *
- * @memberOf Diagram
- *
- * @event diagram.init
- *
- * @example
- *
- * eventBus.on('diagram.init', function() {
- * eventBus.fire('my-custom-event', { foo: 'BAR' });
- * });
- *
- * @type {Object}
- */
- this.get('eventBus').fire('diagram.init');
- }
- module.exports = Diagram;
- /**
- * Destroys the diagram
- *
- * @method Diagram#destroy
- */
- Diagram.prototype.destroy = function() {
- this.get('eventBus').fire('diagram.destroy');
- };
- },{"202":202,"86":86}],78:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- isFunction = _dereq_(331),
- isArray = _dereq_(330),
- isNumber = _dereq_(333);
- var DEFAULT_PRIORITY = 1000;
- /**
- * A utility that can be used to plug-in into the command execution for
- * extension and/or validation.
- *
- * @param {EventBus} eventBus
- *
- * @example
- *
- * var inherits = require('inherits');
- *
- * var CommandInterceptor = require('diagram-js/lib/command/CommandInterceptor');
- *
- * function CommandLogger(eventBus) {
- * CommandInterceptor.call(this, eventBus);
- *
- * this.preExecute(function(event) {
- * console.log('command pre-execute', event);
- * });
- * }
- *
- * inherits(CommandLogger, CommandInterceptor);
- *
- */
- function CommandInterceptor(eventBus) {
- this._eventBus = eventBus;
- }
- CommandInterceptor.$inject = [ 'eventBus' ];
- module.exports = CommandInterceptor;
- function unwrapEvent(fn) {
- return function(event) {
- return fn(event.context, event.command, event);
- };
- }
- /**
- * Register an interceptor for a command execution
- *
- * @param {String|Array<String>} [events] list of commands to register on
- * @param {String} [hook] command hook, i.e. preExecute, executed to listen on
- * @param {Number} [priority] the priority on which to hook into the execution
- * @param {Function} handlerFn interceptor to be invoked with (event)
- * @param {Boolean} unwrap if true, unwrap the event and pass (context, command, event) to the
- * listener instead
- */
- CommandInterceptor.prototype.on = function(events, hook, priority, handlerFn, unwrap) {
- if (isFunction(hook) || isNumber(hook)) {
- unwrap = handlerFn;
- handlerFn = priority;
- priority = hook;
- hook = null;
- }
- if (isFunction(priority)) {
- unwrap = handlerFn;
- handlerFn = priority;
- priority = DEFAULT_PRIORITY;
- }
- if (!isFunction(handlerFn)) {
- throw new Error('handlerFn must be a function');
- }
- if (!isArray(events)) {
- events = [ events ];
- }
- var eventBus = this._eventBus;
- forEach(events, function(event) {
- // concat commandStack(.event)?(.hook)?
- var fullEvent = [ 'commandStack', event, hook ].filter(function(e) { return e; }).join('.');
- eventBus.on(fullEvent, priority, unwrap ? unwrapEvent(handlerFn) : handlerFn);
- });
- };
- var hooks = [
- 'canExecute',
- 'preExecute',
- 'preExecuted',
- 'execute',
- 'executed',
- 'postExecute',
- 'postExecuted',
- 'revert',
- 'reverted'
- ];
- /*
- * Install hook shortcuts
- *
- * This will generate the CommandInterceptor#(preExecute|...|reverted) methods
- * which will in term forward to CommandInterceptor#on.
- */
- forEach(hooks, function(hook) {
- /**
- * {canExecute|preExecute|preExecuted|execute|executed|postExecute|postExecuted|revert|reverted}
- *
- * A named hook for plugging into the command execution
- *
- * @param {String|Array<String>} [events] list of commands to register on
- * @param {Number} [priority] the priority on which to hook into the execution
- * @param {Function} handlerFn interceptor to be invoked with (event)
- * @param {Boolean} [unwrap=false] if true, unwrap the event and pass (context, command, event) to the
- * listener instead
- */
- CommandInterceptor.prototype[hook] = function(events, priority, handlerFn, unwrap) {
- if (isFunction(events) || isNumber(events)) {
- unwrap = handlerFn;
- handlerFn = priority;
- priority = events;
- events = null;
- }
- this.on(events, hook, priority, handlerFn, unwrap);
- };
- });
- },{"218":218,"330":330,"331":331,"333":333}],79:[function(_dereq_,module,exports){
- 'use strict';
- var unique = _dereq_(211),
- isArray = _dereq_(330),
- assign = _dereq_(339);
- var InternalEvent = _dereq_(84).Event;
- /**
- * A service that offers un- and redoable execution of commands.
- *
- * The command stack is responsible for executing modeling actions
- * in a un- and redoable manner. To do this it delegates the actual
- * command execution to {@link CommandHandler}s.
- *
- * Command handlers provide {@link CommandHandler#execute(ctx)} and
- * {@link CommandHandler#revert(ctx)} methods to un- and redo a command
- * identified by a command context.
- *
- *
- * ## Life-Cycle events
- *
- * In the process the command stack fires a number of life-cycle events
- * that other components to participate in the command execution.
- *
- * * preExecute
- * * preExecuted
- * * execute
- * * executed
- * * postExecute
- * * postExecuted
- * * revert
- * * reverted
- *
- * A special event is used for validating, whether a command can be
- * performed prior to its execution.
- *
- * * canExecute
- *
- * Each of the events is fired as `commandStack.{eventName}` and
- * `commandStack.{commandName}.{eventName}`, respectively. This gives
- * components fine grained control on where to hook into.
- *
- * The event object fired transports `command`, the name of the
- * command and `context`, the command context.
- *
- *
- * ## Creating Command Handlers
- *
- * Command handlers should provide the {@link CommandHandler#execute(ctx)}
- * and {@link CommandHandler#revert(ctx)} methods to implement
- * redoing and undoing of a command. They must ensure undo is performed
- * properly in order not to break the undo chain.
- *
- * Command handlers may execute other modeling operations (and thus
- * commands) in their `preExecute` and `postExecute` phases. The command
- * stack will properly group all commands together into a logical unit
- * that may be re- and undone atomically.
- *
- * Command handlers must not execute other commands from within their
- * core implementation (`execute`, `revert`).
- *
- *
- * ## Change Tracking
- *
- * During the execution of the CommandStack it will keep track of all
- * elements that have been touched during the command's execution.
- *
- * At the end of the CommandStack execution it will notify interested
- * components via an 'elements.changed' event with all the dirty
- * elements.
- *
- * The event can be picked up by components that are interested in the fact
- * that elements have been changed. One use case for this is updating
- * their graphical representation after moving / resizing or deletion.
- *
- *
- * @param {EventBus} eventBus
- * @param {Injector} injector
- */
- function CommandStack(eventBus, injector) {
- /**
- * A map of all registered command handlers.
- *
- * @type {Object}
- */
- this._handlerMap = {};
- /**
- * A stack containing all re/undoable actions on the diagram
- *
- * @type {Array<Object>}
- */
- this._stack = [];
- /**
- * The current index on the stack
- *
- * @type {Number}
- */
- this._stackIdx = -1;
- /**
- * Current active commandStack execution
- *
- * @type {Object}
- */
- this._currentExecution = {
- actions: [],
- dirty: []
- };
- this._injector = injector;
- this._eventBus = eventBus;
- this._uid = 1;
- }
- CommandStack.$inject = [ 'eventBus', 'injector' ];
- module.exports = CommandStack;
- /**
- * Execute a command
- *
- * @param {String} command the command to execute
- * @param {Object} context the environment to execute the command in
- */
- CommandStack.prototype.execute = function(command, context) {
- if (!command) {
- throw new Error('command required');
- }
- var action = { command: command, context: context };
- this._pushAction(action);
- this._internalExecute(action);
- this._popAction(action);
- };
- /**
- * Ask whether a given command can be executed.
- *
- * Implementors may hook into the mechanism on two ways:
- *
- * * in event listeners:
- *
- * Users may prevent the execution via an event listener.
- * It must prevent the default action for `commandStack.(<command>.)canExecute` events.
- *
- * * in command handlers:
- *
- * If the method {@link CommandHandler#canExecute} is implemented in a handler
- * it will be called to figure out whether the execution is allowed.
- *
- * @param {String} command the command to execute
- * @param {Object} context the environment to execute the command in
- *
- * @return {Boolean} true if the command can be executed
- */
- CommandStack.prototype.canExecute = function(command, context) {
- var action = { command: command, context: context };
- var handler = this._getHandler(command);
- if (!handler) {
- return false;
- }
- var result = this._fire(command, 'canExecute', action);
- // handler#canExecute will only be called if no listener
- // decided on a result already
- if (result === undefined && handler.canExecute) {
- result = handler.canExecute(context);
- }
- return result;
- };
- /**
- * Clear the command stack, erasing all undo / redo history
- */
- CommandStack.prototype.clear = function() {
- this._stack.length = 0;
- this._stackIdx = -1;
- this._fire('changed');
- };
- /**
- * Undo last command(s)
- */
- CommandStack.prototype.undo = function() {
- var action = this._getUndoAction(),
- next;
- if (action) {
- this._pushAction(action);
- while (action) {
- this._internalUndo(action);
- next = this._getUndoAction();
- if (!next || next.id !== action.id) {
- break;
- }
- action = next;
- }
- this._popAction();
- }
- };
- /**
- * Redo last command(s)
- */
- CommandStack.prototype.redo = function() {
- var action = this._getRedoAction(),
- next;
- if (action) {
- this._pushAction(action);
- while (action) {
- this._internalExecute(action, true);
- next = this._getRedoAction();
- if (!next || next.id !== action.id) {
- break;
- }
- action = next;
- }
- this._popAction();
- }
- };
- /**
- * Register a handler instance with the command stack
- *
- * @param {String} command
- * @param {CommandHandler} handler
- */
- CommandStack.prototype.register = function(command, handler) {
- this._setHandler(command, handler);
- };
- /**
- * Register a handler type with the command stack
- * by instantiating it and injecting its dependencies.
- *
- * @param {String} command
- * @param {Function} a constructor for a {@link CommandHandler}
- */
- CommandStack.prototype.registerHandler = function(command, handlerCls) {
- if (!command || !handlerCls) {
- throw new Error('command and handlerCls must be defined');
- }
- var handler = this._injector.instantiate(handlerCls);
- this.register(command, handler);
- };
- CommandStack.prototype.canUndo = function() {
- return !!this._getUndoAction();
- };
- CommandStack.prototype.canRedo = function() {
- return !!this._getRedoAction();
- };
- ////// stack access //////////////////////////////////////
- CommandStack.prototype._getRedoAction = function() {
- return this._stack[this._stackIdx + 1];
- };
- CommandStack.prototype._getUndoAction = function() {
- return this._stack[this._stackIdx];
- };
- ////// internal functionality /////////////////////////////
- CommandStack.prototype._internalUndo = function(action) {
- var command = action.command,
- context = action.context;
- var handler = this._getHandler(command);
- this._fire(command, 'revert', action);
- this._markDirty(handler.revert(context));
- this._revertedAction(action);
- this._fire(command, 'reverted', action);
- };
- CommandStack.prototype._fire = function(command, qualifier, event) {
- if (arguments.length < 3) {
- event = qualifier;
- qualifier = null;
- }
- var names = qualifier ? [ command + '.' + qualifier, qualifier ] : [ command ],
- i, name, result;
- event = assign(new InternalEvent(), event);
- for (i = 0; !!(name = names[i]); i++) {
- result = this._eventBus.fire('commandStack.' + name, event);
- if (event.cancelBubble) {
- break;
- }
- }
- return result;
- };
- CommandStack.prototype._createId = function() {
- return this._uid++;
- };
- CommandStack.prototype._internalExecute = function(action, redo) {
- var command = action.command,
- context = action.context;
- var handler = this._getHandler(command);
- if (!handler) {
- throw new Error('no command handler registered for <' + command + '>');
- }
- this._pushAction(action);
- if (!redo) {
- this._fire(command, 'preExecute', action);
- if (handler.preExecute) {
- handler.preExecute(context);
- }
- this._fire(command, 'preExecuted', action);
- }
- this._fire(command, 'execute', action);
- // execute
- this._markDirty(handler.execute(context));
- // log to stack
- this._executedAction(action, redo);
- this._fire(command, 'executed', action);
- if (!redo) {
- this._fire(command, 'postExecute', action);
- if (handler.postExecute) {
- handler.postExecute(context);
- }
- this._fire(command, 'postExecuted', action);
- }
- this._popAction(action);
- };
- CommandStack.prototype._pushAction = function(action) {
- var execution = this._currentExecution,
- actions = execution.actions;
- var baseAction = actions[0];
- if (!action.id) {
- action.id = (baseAction && baseAction.id) || this._createId();
- }
- actions.push(action);
- };
- CommandStack.prototype._popAction = function() {
- var execution = this._currentExecution,
- actions = execution.actions,
- dirty = execution.dirty;
- actions.pop();
- if (!actions.length) {
- this._eventBus.fire('elements.changed', { elements: unique(dirty) });
- dirty.length = 0;
- this._fire('changed');
- }
- };
- CommandStack.prototype._markDirty = function(elements) {
- var execution = this._currentExecution;
- if (!elements) {
- return;
- }
- elements = isArray(elements) ? elements : [ elements ];
- execution.dirty = execution.dirty.concat(elements);
- };
- CommandStack.prototype._executedAction = function(action, redo) {
- var stackIdx = ++this._stackIdx;
- if (!redo) {
- this._stack.splice(stackIdx, this._stack.length, action);
- }
- };
- CommandStack.prototype._revertedAction = function(action) {
- this._stackIdx--;
- };
- CommandStack.prototype._getHandler = function(command) {
- return this._handlerMap[command];
- };
- CommandStack.prototype._setHandler = function(command, handler) {
- if (!command || !handler) {
- throw new Error('command and handler required');
- }
- if (this._handlerMap[command]) {
- throw new Error('overriding handler for command <' + command + '>');
- }
- this._handlerMap[command] = handler;
- };
- },{"211":211,"330":330,"339":339,"84":84}],80:[function(_dereq_,module,exports){
- module.exports = {
- commandStack: [ 'type', _dereq_(79) ]
- };
- },{"79":79}],81:[function(_dereq_,module,exports){
- 'use strict';
- var isNumber = _dereq_(333),
- assign = _dereq_(339),
- forEach = _dereq_(218),
- every = _dereq_(215);
- var Collections = _dereq_(184);
- var Snap = _dereq_(200);
- function round(number, resolution) {
- return Math.round(number * resolution) / resolution;
- }
- function ensurePx(number) {
- return isNumber(number) ? number + 'px' : number;
- }
- /**
- * Creates a HTML container element for a SVG element with
- * the given configuration
- *
- * @param {Object} options
- * @return {HTMLElement} the container element
- */
- function createContainer(options) {
- options = assign({}, { width: '100%', height: '100%' }, options);
- var container = options.container || document.body;
- // create a <div> around the svg element with the respective size
- // this way we can always get the correct container size
- // (this is impossible for <svg> elements at the moment)
- var parent = document.createElement('div');
- parent.setAttribute('class', 'djs-container');
- assign(parent.style, {
- position: 'relative',
- overflow: 'hidden',
- width: ensurePx(options.width),
- height: ensurePx(options.height)
- });
- container.appendChild(parent);
- return parent;
- }
- function createGroup(parent, cls) {
- return parent.group().attr({ 'class' : cls });
- }
- var BASE_LAYER = 'base';
- var REQUIRED_MODEL_ATTRS = {
- shape: [ 'x', 'y', 'width', 'height' ],
- connection: [ 'waypoints' ]
- };
- /**
- * The main drawing canvas.
- *
- * @class
- * @constructor
- *
- * @emits Canvas#canvas.init
- *
- * @param {Object} config
- * @param {EventBus} eventBus
- * @param {GraphicsFactory} graphicsFactory
- * @param {ElementRegistry} elementRegistry
- */
- function Canvas(config, eventBus, graphicsFactory, elementRegistry) {
- this._eventBus = eventBus;
- this._elementRegistry = elementRegistry;
- this._graphicsFactory = graphicsFactory;
- this._init(config || {});
- }
- Canvas.$inject = [ 'config.canvas', 'eventBus', 'graphicsFactory', 'elementRegistry' ];
- module.exports = Canvas;
- Canvas.prototype._init = function(config) {
- // Creates a <svg> element that is wrapped into a <div>.
- // This way we are always able to correctly figure out the size of the svg element
- // by querying the parent node.
- //
- // (It is not possible to get the size of a svg element cross browser @ 2014-04-01)
- //
- // <div class="djs-container" style="width: {desired-width}, height: {desired-height}">
- // <svg width="100%" height="100%">
- // ...
- // </svg>
- // </div>
- // html container
- var eventBus = this._eventBus,
- container = createContainer(config),
- svg = Snap.createSnapAt('100%', '100%', container),
- viewport = createGroup(svg, 'viewport'),
- self = this;
- this._container = container;
- this._svg = svg;
- this._viewport = viewport;
- this._layers = {};
- eventBus.on('diagram.init', function(event) {
- /**
- * An event indicating that the canvas is ready to be drawn on.
- *
- * @memberOf Canvas
- *
- * @event canvas.init
- *
- * @type {Object}
- * @property {Snap<SVGSVGElement>} svg the created svg element
- * @property {Snap<SVGGroup>} viewport the direct parent of diagram elements and shapes
- */
- eventBus.fire('canvas.init', { svg: svg, viewport: viewport });
- });
- eventBus.on('diagram.destroy', function() {
- var parent = self._container.parentNode;
- if (parent) {
- parent.removeChild(container);
- }
- eventBus.fire('canvas.destroy', { svg: self._svg, viewport: self._viewport });
- self._svg.remove();
- self._svg = self._container = self._layers = self._viewport = null;
- });
- };
- /**
- * Returns the default layer on which
- * all elements are drawn.
- *
- * @returns {Snap<SVGGroup>}
- */
- Canvas.prototype.getDefaultLayer = function() {
- return this.getLayer(BASE_LAYER);
- };
- /**
- * Returns a layer that is used to draw elements
- * or annotations on it.
- *
- * @param {String} name
- *
- * @returns {Snap<SVGGroup>}
- */
- Canvas.prototype.getLayer = function(name) {
- if (!name) {
- throw new Error('must specify a name');
- }
- var layer = this._layers[name];
- if (!layer) {
- layer = this._layers[name] = createGroup(this._viewport, 'layer-' + name);
- }
- return layer;
- };
- /**
- * Returns the html element that encloses the
- * drawing canvas.
- *
- * @return {DOMNode}
- */
- Canvas.prototype.getContainer = function() {
- return this._container;
- };
- /////////////// markers ///////////////////////////////////
- Canvas.prototype._updateMarker = function(element, marker, add) {
- var container;
- if (!element.id) {
- element = this._elementRegistry.get(element);
- }
- // we need to access all
- container = this._elementRegistry._elements[element.id];
- if (!container) {
- return;
- }
- forEach([ container.gfx, container.secondaryGfx ], function(gfx) {
- if (gfx) {
- // invoke either addClass or removeClass based on mode
- gfx[add ? 'addClass' : 'removeClass'](marker);
- }
- });
- /**
- * An event indicating that a marker has been updated for an element
- *
- * @event element.marker.update
- * @type {Object}
- * @property {djs.model.Element} element the shape
- * @property {Object} gfx the graphical representation of the shape
- * @property {String} marker
- * @property {Boolean} add true if the marker was added, false if it got removed
- */
- this._eventBus.fire('element.marker.update', { element: element, gfx: container.gfx, marker: marker, add: !!add });
- };
- /**
- * Adds a marker to an element (basically a css class).
- *
- * Fires the element.marker.update event, making it possible to
- * integrate extension into the marker life-cycle, too.
- *
- * @example
- * canvas.addMarker('foo', 'some-marker');
- *
- * var fooGfx = canvas.getGraphics('foo');
- *
- * fooGfx; // <g class="... some-marker"> ... </g>
- *
- * @param {String|djs.model.Base} element
- * @param {String} marker
- */
- Canvas.prototype.addMarker = function(element, marker) {
- this._updateMarker(element, marker, true);
- };
- /**
- * Remove a marker from an element.
- *
- * Fires the element.marker.update event, making it possible to
- * integrate extension into the marker life-cycle, too.
- *
- * @param {String|djs.model.Base} element
- * @param {String} marker
- */
- Canvas.prototype.removeMarker = function(element, marker) {
- this._updateMarker(element, marker, false);
- };
- /**
- * Check the existence of a marker on element.
- *
- * @param {String|djs.model.Base} element
- * @param {String} marker
- */
- Canvas.prototype.hasMarker = function(element, marker) {
- if (!element.id) {
- element = this._elementRegistry.get(element);
- }
- var gfx = this.getGraphics(element);
- return gfx && gfx.hasClass(marker);
- };
- /**
- * Toggles a marker on an element.
- *
- * Fires the element.marker.update event, making it possible to
- * integrate extension into the marker life-cycle, too.
- *
- * @param {String|djs.model.Base} element
- * @param {String} marker
- */
- Canvas.prototype.toggleMarker = function(element, marker) {
- if(this.hasMarker(element, marker)) {
- this.removeMarker(element, marker);
- } else {
- this.addMarker(element, marker);
- }
- };
- Canvas.prototype.getRootElement = function() {
- if (!this._rootElement) {
- this.setRootElement({ id: '__implicitroot' });
- }
- return this._rootElement;
- };
- //////////////// root element handling ///////////////////////////
- /**
- * Sets a given element as the new root element for the canvas
- * and returns the new root element.
- *
- * @param {Object|djs.model.Root} element
- * @param {Boolean} [override] whether to override the current root element, if any
- *
- * @return {Object|djs.model.Root} new root element
- */
- Canvas.prototype.setRootElement = function(element, override) {
- this._ensureValid('root', element);
- var oldRoot = this._rootElement,
- elementRegistry = this._elementRegistry,
- eventBus = this._eventBus;
- if (oldRoot) {
- if (!override) {
- throw new Error('rootElement already set, need to specify override');
- }
- // simulate element remove event sequence
- eventBus.fire('root.remove', { element: oldRoot });
- eventBus.fire('root.removed', { element: oldRoot });
- elementRegistry.remove(oldRoot);
- }
- var gfx = this.getDefaultLayer();
- // resemble element add event sequence
- eventBus.fire('root.add', { element: element });
- elementRegistry.add(element, gfx, this._svg);
- eventBus.fire('root.added', { element: element, gfx: gfx });
- this._rootElement = element;
- return element;
- };
- ///////////// add functionality ///////////////////////////////
- Canvas.prototype._ensureValid = function(type, element) {
- if (!element.id) {
- throw new Error('element must have an id');
- }
- if (this._elementRegistry.get(element.id)) {
- throw new Error('element with id ' + element.id + ' already exists');
- }
- var requiredAttrs = REQUIRED_MODEL_ATTRS[type];
- var valid = every(requiredAttrs, function(attr) {
- return typeof element[attr] !== 'undefined';
- });
- if (!valid) {
- throw new Error(
- 'must supply { ' + requiredAttrs.join(', ') + ' } with ' + type);
- }
- };
- Canvas.prototype._setParent = function(element, parent, idx) {
- Collections.add(parent.children, element, idx);
- element.parent = parent;
- };
- /**
- * Adds an element to the canvas.
- *
- * This wires the parent <-> child relationship between the element and
- * a explicitly specified parent or an implicit root element.
- *
- * During add it emits the events
- *
- * * <{type}.add> (element, parent)
- * * <{type}.added> (element, gfx)
- *
- * Extensions may hook into these events to perform their magic.
- *
- * @param {String} type
- * @param {Object|djs.model.Base} element
- * @param {Object|djs.model.Base} [parent]
- *
- * @return {Object|djs.model.Base} the added element
- */
- Canvas.prototype._addElement = function(type, element, parent) {
- parent = parent || this.getRootElement();
- var eventBus = this._eventBus,
- graphicsFactory = this._graphicsFactory,
- idx;
- this._ensureValid(type, element);
- eventBus.fire(type + '.add', { element: element, parent: parent });
- this._setParent(element, parent, idx);
- // create graphics
- var gfx = graphicsFactory.create(type, element);
- this._elementRegistry.add(element, gfx);
- // update its visual
- graphicsFactory.update(type, element, gfx);
- eventBus.fire(type + '.added', { element: element, gfx: gfx });
- return element;
- };
- /**
- * Adds a shape to the canvas
- *
- * @param {Object|djs.model.Shape} shape to add to the diagram
- * @param {djs.model.Base} [parent]
- *
- * @return {djs.model.Shape} the added shape
- */
- Canvas.prototype.addShape = function(shape, parent) {
- return this._addElement('shape', shape, parent);
- };
- /**
- * Adds a connection to the canvas
- *
- * @param {Object|djs.model.Connection} connection to add to the diagram
- * @param {djs.model.Base} [parent]
- *
- * @return {djs.model.Connection} the added connection
- */
- Canvas.prototype.addConnection = function(connection, parent) {
- return this._addElement('connection', connection, parent);
- };
- /**
- * Internal remove element
- */
- Canvas.prototype._removeElement = function(element, type) {
- var elementRegistry = this._elementRegistry,
- graphicsFactory = this._graphicsFactory,
- eventBus = this._eventBus;
- element = elementRegistry.get(element.id || element);
- if (!element) {
- // element was removed already
- return;
- }
- eventBus.fire(type + '.remove', { element: element });
- graphicsFactory.remove(element);
- // unset parent <-> child relationship
- Collections.remove(element.parent && element.parent.children, element);
- element.parent = null;
- eventBus.fire(type + '.removed', { element: element });
- elementRegistry.remove(element);
- return element;
- };
- /**
- * Removes a shape from the canvas
- *
- * @param {String|djs.model.Shape} shape or shape id to be removed
- *
- * @return {djs.model.Shape} the removed shape
- */
- Canvas.prototype.removeShape = function(shape) {
- /**
- * An event indicating that a shape is about to be removed from the canvas.
- *
- * @memberOf Canvas
- *
- * @event shape.remove
- * @type {Object}
- * @property {djs.model.Shape} element the shape descriptor
- * @property {Object} gfx the graphical representation of the shape
- */
- /**
- * An event indicating that a shape has been removed from the canvas.
- *
- * @memberOf Canvas
- *
- * @event shape.removed
- * @type {Object}
- * @property {djs.model.Shape} element the shape descriptor
- * @property {Object} gfx the graphical representation of the shape
- */
- return this._removeElement(shape, 'shape');
- };
- /**
- * Removes a connection from the canvas
- *
- * @param {String|djs.model.Connection} connection or connection id to be removed
- *
- * @return {djs.model.Connection} the removed connection
- */
- Canvas.prototype.removeConnection = function(connection) {
- /**
- * An event indicating that a connection is about to be removed from the canvas.
- *
- * @memberOf Canvas
- *
- * @event connection.remove
- * @type {Object}
- * @property {djs.model.Connection} element the connection descriptor
- * @property {Object} gfx the graphical representation of the connection
- */
- /**
- * An event indicating that a connection has been removed from the canvas.
- *
- * @memberOf Canvas
- *
- * @event connection.removed
- * @type {Object}
- * @property {djs.model.Connection} element the connection descriptor
- * @property {Object} gfx the graphical representation of the connection
- */
- return this._removeElement(connection, 'connection');
- };
- /**
- * Sends a shape to the front.
- *
- * This method takes parent / child relationships between shapes into account
- * and makes sure that children are properly handled, too.
- *
- * @param {djs.model.Shape} shape descriptor of the shape to be sent to front
- * @param {boolean} [bubble=true] whether to send parent shapes to front, too
- */
- Canvas.prototype.sendToFront = function(shape, bubble) {
- if (bubble !== false) {
- bubble = true;
- }
- if (bubble && shape.parent) {
- this.sendToFront(shape.parent);
- }
- forEach(shape.children, function(child) {
- this.sendToFront(child, false);
- }, this);
- var gfx = this.getGraphics(shape),
- gfxParent = gfx.parent();
- gfx.remove().appendTo(gfxParent);
- };
- /**
- * Return the graphical object underlaying a certain diagram element
- *
- * @param {String|djs.model.Base} element descriptor of the element
- * @param {Boolean} [secondary=false] whether to return the secondary connected element
- *
- * @return {SVGElement}
- */
- Canvas.prototype.getGraphics = function(element, secondary) {
- return this._elementRegistry.getGraphics(element, secondary);
- };
- Canvas.prototype._fireViewboxChange = function() {
- this._eventBus.fire('canvas.viewbox.changed', { viewbox: this.viewbox(false) });
- };
- /**
- * Gets or sets the view box of the canvas, i.e. the area that is currently displayed
- *
- * @param {Object} [box] the new view box to set
- * @param {Number} box.x the top left X coordinate of the canvas visible in view box
- * @param {Number} box.y the top left Y coordinate of the canvas visible in view box
- * @param {Number} box.width the visible width
- * @param {Number} box.height
- *
- * @example
- *
- * canvas.viewbox({ x: 100, y: 100, width: 500, height: 500 })
- *
- * // sets the visible area of the diagram to (100|100) -> (600|100)
- * // and and scales it according to the diagram width
- *
- * @return {Object} the current view box
- */
- Canvas.prototype.viewbox = function(box) {
- if (box === undefined && this._cachedViewbox) {
- return this._cachedViewbox;
- }
- var viewport = this._viewport,
- innerBox,
- outerBox = this.getSize(),
- matrix,
- scale,
- x, y;
- if (!box) {
- // compute the inner box based on the
- // diagrams default layer. This allows us to exclude
- // external components, such as overlays
- innerBox = this.getDefaultLayer().getBBox(true);
- matrix = viewport.transform().localMatrix;
- scale = round(matrix.a, 1000);
- x = round(-matrix.e || 0, 1000);
- y = round(-matrix.f || 0, 1000);
- box = this._cachedViewbox = {
- x: x ? x / scale : 0,
- y: y ? y / scale : 0,
- width: outerBox.width / scale,
- height: outerBox.height / scale,
- scale: scale,
- inner: {
- width: innerBox.width,
- height: innerBox.height,
- x: innerBox.x,
- y: innerBox.y
- },
- outer: outerBox
- };
- return box;
- } else {
- scale = Math.min(outerBox.width / box.width, outerBox.height / box.height);
- matrix = new Snap.Matrix().scale(scale).translate(-box.x, -box.y);
- viewport.transform(matrix);
- this._fireViewboxChange();
- }
- return box;
- };
- /**
- * Gets or sets the scroll of the canvas.
- *
- * @param {Object} [delta] the new scroll to apply.
- *
- * @param {Number} [delta.dx]
- * @param {Number} [delta.dy]
- */
- Canvas.prototype.scroll = function(delta) {
- var node = this._viewport.node;
- var matrix = node.getCTM();
- if (delta) {
- delta = assign({ dx: 0, dy: 0 }, delta || {});
- matrix = this._svg.node.createSVGMatrix().translate(delta.dx, delta.dy).multiply(matrix);
- setCTM(node, matrix);
- this._fireViewboxChange();
- }
- return { x: matrix.e, y: matrix.f };
- };
- /**
- * Gets or sets the current zoom of the canvas, optionally zooming to the specified position.
- *
- * @param {String|Number} [newScale] the new zoom level, either a number, i.e. 0.9,
- * or `fit-viewport` to adjust the size to fit the current viewport
- * @param {String|Point} [center] the reference point { x: .., y: ..} to zoom to, 'auto' to zoom into mid or null
- *
- * @return {Number} the current scale
- */
- Canvas.prototype.zoom = function(newScale, center) {
- if (newScale === 'fit-viewport') {
- return this._fitViewport(center);
- }
- var vbox = this.viewbox(),
- outer,
- matrix;
- if (newScale === undefined) {
- return vbox.scale;
- }
- if (typeof center !== 'object') {
- outer = vbox.outer;
- center = {
- x: outer.width / 2,
- y: outer.height / 2
- };
- }
- matrix = this._setZoom(newScale, center);
- this._fireViewboxChange();
- return round(matrix.a, 1000);
- };
- function setCTM(node, m) {
- var mstr = 'matrix(' + m.a + ',' + m.b + ',' + m.c + ',' + m.d + ',' + m.e + ',' + m.f + ')';
- node.setAttribute('transform', mstr);
- }
- Canvas.prototype._fitViewport = function(center) {
- var vbox = this.viewbox(),
- outer = vbox.outer,
- inner = vbox.inner,
- newScale,
- newViewbox;
- // display the complete diagram without zooming in.
- // instead of relying on internal zoom, we perform a
- // hard reset on the canvas viewbox to realize this
- //
- // if diagram does not need to be zoomed in, we focus it around
- // the diagram origin instead
- if (inner.x >= 0 &&
- inner.y >= 0 &&
- inner.x + inner.width <= outer.width &&
- inner.y + inner.height <= outer.height &&
- !center) {
- newViewbox = {
- x: 0,
- y: 0,
- width: Math.max(inner.width + inner.x, outer.width),
- height: Math.max(inner.height + inner.y, outer.height)
- };
- } else {
- newScale = Math.min(1, outer.width / inner.width, outer.height / inner.height);
- newViewbox = {
- x: inner.x + (center ? inner.width / 2 - outer.width / newScale / 2 : 0),
- y: inner.y + (center ? inner.height / 2 - outer.height / newScale / 2 : 0),
- width: outer.width / newScale,
- height: outer.height / newScale
- };
- }
- this.viewbox(newViewbox);
- return this.viewbox().scale;
- };
- Canvas.prototype._setZoom = function(scale, center) {
- var svg = this._svg.node,
- viewport = this._viewport.node;
- var matrix = svg.createSVGMatrix();
- var point = svg.createSVGPoint();
- var centerPoint,
- originalPoint,
- currentMatrix,
- scaleMatrix,
- newMatrix;
- currentMatrix = viewport.getCTM();
- var currentScale = currentMatrix.a;
- if (center) {
- centerPoint = assign(point, center);
- // revert applied viewport transformations
- originalPoint = centerPoint.matrixTransform(currentMatrix.inverse());
- // create scale matrix
- scaleMatrix = matrix
- .translate(originalPoint.x, originalPoint.y)
- .scale(1 / currentScale * scale)
- .translate(-originalPoint.x, -originalPoint.y);
- newMatrix = currentMatrix.multiply(scaleMatrix);
- } else {
- newMatrix = matrix.scale(scale);
- }
- setCTM(this._viewport.node, newMatrix);
- return newMatrix;
- };
- /**
- * Returns the size of the canvas
- *
- * @return {Dimensions}
- */
- Canvas.prototype.getSize = function () {
- return {
- width: this._container.clientWidth,
- height: this._container.clientHeight
- };
- };
- /**
- * Return the absolute bounding box for the given element
- *
- * The absolute bounding box may be used to display overlays in the
- * callers (browser) coordinate system rather than the zoomed in/out
- * canvas coordinates.
- *
- * @param {ElementDescriptor} element
- * @return {Bounds} the absolute bounding box
- */
- Canvas.prototype.getAbsoluteBBox = function(element) {
- var vbox = this.viewbox();
- var bbox;
- // connection
- // use svg bbox
- if (element.waypoints) {
- var gfx = this.getGraphics(element);
- var transformBBox = gfx.getBBox(true);
- bbox = gfx.getBBox();
- bbox.x -= transformBBox.x;
- bbox.y -= transformBBox.y;
- bbox.width += 2 * transformBBox.x;
- bbox.height += 2 * transformBBox.y;
- }
- // shapes
- // use data
- else {
- bbox = element;
- }
- var x = bbox.x * vbox.scale - vbox.x * vbox.scale;
- var y = bbox.y * vbox.scale - vbox.y * vbox.scale;
- var width = bbox.width * vbox.scale;
- var height = bbox.height * vbox.scale;
- return {
- x: x,
- y: y,
- width: width,
- height: height
- };
- };
- },{"184":184,"200":200,"215":215,"218":218,"333":333,"339":339}],82:[function(_dereq_,module,exports){
- 'use strict';
- var Model = _dereq_(176);
- /**
- * A factory for diagram-js shapes
- */
- function ElementFactory() {
- this._uid = 12;
- }
- module.exports = ElementFactory;
- ElementFactory.prototype.createRoot = function(attrs) {
- return this.create('root', attrs);
- };
- ElementFactory.prototype.createLabel = function(attrs) {
- return this.create('label', attrs);
- };
- ElementFactory.prototype.createShape = function(attrs) {
- return this.create('shape', attrs);
- };
- ElementFactory.prototype.createConnection = function(attrs) {
- return this.create('connection', attrs);
- };
- /**
- * Create a model element with the given type and
- * a number of pre-set attributes.
- *
- * @param {String} type
- * @param {Object} attrs
- * @return {djs.model.Base} the newly created model instance
- */
- ElementFactory.prototype.create = function(type, attrs) {
- attrs = attrs || {};
- if (!attrs.id) {
- attrs.id = type + '_' + (this._uid++);
- }
- return Model.create(type, attrs);
- };
- },{"176":176}],83:[function(_dereq_,module,exports){
- 'use strict';
- var ELEMENT_ID = 'data-element-id';
- /**
- * @class
- *
- * A registry that keeps track of all shapes in the diagram.
- */
- function ElementRegistry() {
- this._elements = {};
- }
- module.exports = ElementRegistry;
- /**
- * Register a pair of (element, gfx, (secondaryGfx)).
- *
- * @param {djs.model.Base} element
- * @param {Snap<SVGElement>} gfx
- * @param {Snap<SVGElement>} [secondaryGfx] optional other element to register, too
- */
- ElementRegistry.prototype.add = function(element, gfx, secondaryGfx) {
- var id = element.id;
- this._validateId(id);
- // associate dom node with element
- gfx.attr(ELEMENT_ID, id);
- if (secondaryGfx) {
- secondaryGfx.attr(ELEMENT_ID, id);
- }
- this._elements[id] = { element: element, gfx: gfx, secondaryGfx: secondaryGfx };
- };
- /**
- * Removes an element from the registry.
- *
- * @param {djs.model.Base} element
- */
- ElementRegistry.prototype.remove = function(element) {
- var elements = this._elements,
- id = element.id || element,
- container = id && elements[id];
- if (container) {
- // unset element id on gfx
- container.gfx.attr(ELEMENT_ID, null);
- if (container.secondaryGfx) {
- container.secondaryGfx.attr(ELEMENT_ID, null);
- }
- delete elements[id];
- }
- };
- /**
- * Update the id of an element
- *
- * @param {djs.model.Base} element
- * @param {String} newId
- */
- ElementRegistry.prototype.updateId = function(element, newId) {
- this._validateId(newId);
- if (typeof element === 'string') {
- element = this.get(element);
- }
- var gfx = this.getGraphics(element),
- secondaryGfx = this.getGraphics(element, true);
- this.remove(element);
- element.id = newId;
- this.add(element, gfx, secondaryGfx);
- };
- /**
- * Return the model element for a given id or graphics.
- *
- * @example
- *
- * elementRegistry.get('SomeElementId_1');
- * elementRegistry.get(gfx);
- *
- *
- * @param {String|SVGElement} filter for selecting the element
- *
- * @return {djs.model.Base}
- */
- ElementRegistry.prototype.get = function(filter) {
- var id;
- if (typeof filter === 'string') {
- id = filter;
- } else {
- id = filter && filter.attr(ELEMENT_ID);
- }
- var container = this._elements[id];
- return container && container.element;
- };
- /**
- * Return all elements that match a given filter function.
- *
- * @param {Function} fn
- *
- * @return {Array<djs.model.Base>}
- */
- ElementRegistry.prototype.filter = function(fn) {
- var filtered = [];
- this.forEach(function(element, gfx) {
- if(fn(element, gfx)) {
- filtered.push(element);
- }
- });
- return filtered;
- };
- /**
- * Return all rendered model elements.
- *
- * @return {Array<djs.model.Base>}
- */
- ElementRegistry.prototype.getAll = function() {
- return this.filter(function(e) { return e; });
- };
- /**
- * Iterate over all diagram elements.
- *
- * @param {Function} fn
- */
- ElementRegistry.prototype.forEach = function(fn) {
- var map = this._elements;
- Object.keys(map).forEach(function(id) {
- var container = map[id],
- element = container.element,
- gfx = container.gfx;
- return fn(element, gfx);
- });
- };
- /**
- * Return the graphical representation of an element or its id.
- *
- * @example
- * elementRegistry.getGraphics('SomeElementId_1');
- * elementRegistry.getGraphics(rootElement); // <g ...>
- *
- * elementRegistry.getGraphics(rootElement, true); // <svg ...>
- *
- *
- * @param {String|djs.model.Base} filter
- * @param {Boolean} [secondary=false] whether to return the secondary connected element
- *
- * @return {SVGElement}
- */
- ElementRegistry.prototype.getGraphics = function(filter, secondary) {
- var id = filter.id || filter;
- var container = this._elements[id];
- return container && (secondary ? container.secondaryGfx : container.gfx);
- };
- /**
- * Validate the suitability of the given id and signals a problem
- * with an exception.
- *
- * @param {String} id
- *
- * @throws {Error} if id is empty or already assigned
- */
- ElementRegistry.prototype._validateId = function(id) {
- if (!id) {
- throw new Error('element must have an id');
- }
- if (this._elements[id]) {
- throw new Error('element with id ' + id + ' already added');
- }
- };
- },{}],84:[function(_dereq_,module,exports){
- 'use strict';
- var isFunction = _dereq_(331),
- isArray = _dereq_(330),
- isNumber = _dereq_(333),
- assign = _dereq_(339);
- var DEFAULT_PRIORITY = 1000;
- /**
- * A general purpose event bus.
- *
- * This component is used to communicate across a diagram instance.
- * Other parts of a diagram can use it to listen to and broadcast events.
- *
- *
- * ## Registering for Events
- *
- * The event bus provides the {@link EventBus#on} and {@link EventBus#once}
- * methods to register for events. {@link EventBus#off} can be used to
- * remove event registrations. Listeners receive an instance of {@link Event}
- * as the first argument. It allows them to hook into the event execution.
- *
- * ```javascript
- *
- * // listen for event
- * eventBus.on('foo', function(event) {
- *
- * // access event type
- * event.type; // 'foo'
- *
- * // stop propagation to other listeners
- * event.stopPropagation();
- *
- * // prevent event default
- * event.preventDefault();
- * });
- *
- * // listen for event with custom payload
- * eventBus.on('bar', function(event, payload) {
- * console.log(payload);
- * });
- *
- * // listen for event returning value
- * eventBus.on('foobar', function(event) {
- *
- * // stop event propagation + prevent default
- * return false;
- *
- * // stop event propagation + return custom result
- * return {
- * complex: 'listening result'
- * };
- * });
- *
- *
- * // listen with custom priority (default=1000, higher is better)
- * eventBus.on('priorityfoo', 1500, function(event) {
- * console.log('invoked first!');
- * });
- * ```
- *
- *
- * ## Emitting Events
- *
- * Events can be emitted via the event bus using {@link EventBus#fire}.
- *
- * ```javascript
- *
- * // false indicates that the default action
- * // was prevented by listeners
- * if (eventBus.fire('foo') === false) {
- * console.log('default has been prevented!');
- * };
- *
- *
- * // custom args + return value listener
- * eventBus.on('sum', function(event, a, b) {
- * return a + b;
- * });
- *
- * // you can pass custom arguments + retrieve result values.
- * var sum = eventBus.fire('sum', 1, 2);
- * console.log(sum); // 3
- * ```
- */
- function EventBus() {
- this._listeners = {};
- // cleanup on destroy
- var self = this;
- // destroy on lowest priority to allow
- // message passing until the bitter end
- this.on('diagram.destroy', 1, function() {
- self._listeners = null;
- });
- }
- module.exports = EventBus;
- /**
- * Register an event listener for events with the given name.
- *
- * The callback will be invoked with `event, ...additionalArguments`
- * that have been passed to {@link EventBus#fire}.
- *
- * Returning false from a listener will prevent the events default action
- * (if any is specified). To stop an event from being processed further in
- * other listeners execute {@link Event#stopPropagation}.
- *
- * Returning anything but `undefined` from a listener will stop the listener propagation.
- *
- * @param {String|Array<String>} events
- * @param {Number} [priority=1000] the priority in which this listener is called, larger is higher
- * @param {Function} callback
- */
- EventBus.prototype.on = function(events, priority, callback) {
- events = isArray(events) ? events : [ events ];
- if (isFunction(priority)) {
- callback = priority;
- priority = DEFAULT_PRIORITY;
- }
- if (!isNumber(priority)) {
- throw new Error('priority must be a number');
- }
- var self = this,
- listener = { priority: priority, callback: callback };
- events.forEach(function(e) {
- self._addListener(e, listener);
- });
- };
- /**
- * Register an event listener that is executed only once.
- *
- * @param {String} event the event name to register for
- * @param {Function} callback the callback to execute
- */
- EventBus.prototype.once = function(event, callback) {
- var self = this;
- function wrappedCallback() {
- callback.apply(self, arguments);
- self.off(event, wrappedCallback);
- }
- this.on(event, wrappedCallback);
- };
- /**
- * Removes event listeners by event and callback.
- *
- * If no callback is given, all listeners for a given event name are being removed.
- *
- * @param {String} event
- * @param {Function} [callback]
- */
- EventBus.prototype.off = function(event, callback) {
- var listeners = this._getListeners(event),
- listener, idx;
- if (callback) {
- // move through listeners from back to front
- // and remove matching listeners
- for (idx = listeners.length - 1; !!(listener = listeners[idx]); idx--) {
- if (listener.callback === callback) {
- listeners.splice(idx, 1);
- }
- }
- } else {
- // clear listeners
- listeners.length = 0;
- }
- };
- /**
- * Fires a named event.
- *
- * @example
- *
- * // fire event by name
- * events.fire('foo');
- *
- * // fire event object with nested type
- * var event = { type: 'foo' };
- * events.fire(event);
- *
- * // fire event with explicit type
- * var event = { x: 10, y: 20 };
- * events.fire('element.moved', event);
- *
- * // pass additional arguments to the event
- * events.on('foo', function(event, bar) {
- * alert(bar);
- * });
- *
- * events.fire({ type: 'foo' }, 'I am bar!');
- *
- * @param {String} [name] the optional event name
- * @param {Object} [event] the event object
- * @param {...Object} additional arguments to be passed to the callback functions
- *
- * @return {Boolean} the events return value, if specified or false if the
- * default action was prevented by listeners
- */
- EventBus.prototype.fire = function(type, data) {
- var event,
- originalType,
- listeners, idx, listener,
- returnValue,
- args;
- args = Array.prototype.slice.call(arguments);
- if (typeof type === 'object') {
- event = type;
- type = event.type;
- }
- if (!type) {
- throw new Error('no event type specified');
- }
- listeners = this._listeners[type];
- if (!listeners) {
- return;
- }
- // we make sure we fire instances of our home made
- // events here. We wrap them only once, though
- if (data instanceof Event) {
- // we are fine, we alread have an event
- event = data;
- } else {
- event = new Event();
- event.init(data);
- }
- // ensure we pass the event as the first parameter
- args[0] = event;
- // original event type (in case we delegate)
- originalType = event.type;
- try {
- // update event type before delegation
- if (type !== originalType) {
- event.type = type;
- }
- for (idx = 0; !!(listener = listeners[idx]); idx++) {
- // handle stopped propagation
- if (event.cancelBubble) {
- break;
- }
- try {
- // returning false prevents the default action
- returnValue = event.returnValue = listener.callback.apply(null, args);
- // stop propagation on return value
- if (returnValue !== undefined) {
- event.stopPropagation();
- }
- // prevent default on return false
- if (returnValue === false) {
- event.preventDefault();
- }
- } catch (e) {
- if (!this.handleError(e)) {
- console.error('unhandled error in event listener');
- console.error(e.stack);
- throw e;
- }
- }
- }
- } finally {
- // reset event type after delegation
- if (type !== originalType) {
- event.type = originalType;
- }
- }
- // set the return value to false if the event default
- // got prevented and no other return value exists
- if (returnValue === undefined && event.defaultPrevented) {
- returnValue = false;
- }
- return returnValue;
- };
- EventBus.prototype.handleError = function(error) {
- return this.fire('error', { error: error }) === false;
- };
- /*
- * Add new listener with a certain priority to the list
- * of listeners (for the given event).
- *
- * The semantics of listener registration / listener execution are
- * first register, first serve: New listeners will always be inserted
- * after existing listeners with the same priority.
- *
- * Example: Inserting two listeners with priority 1000 and 1300
- *
- * * before: [ 1500, 1500, 1000, 1000 ]
- * * after: [ 1500, 1500, (new=1300), 1000, 1000, (new=1000) ]
- *
- * @param {String} event
- * @param {Object} listener { priority, callback }
- */
- EventBus.prototype._addListener = function(event, newListener) {
- var listeners = this._getListeners(event),
- existingListener,
- idx;
- // ensure we order listeners by priority from
- // 0 (high) to n > 0 (low)
- for (idx = 0; !!(existingListener = listeners[idx]); idx++) {
- if (existingListener.priority < newListener.priority) {
- // prepend newListener at before existingListener
- listeners.splice(idx, 0, newListener);
- return;
- }
- }
- listeners.push(newListener);
- };
- EventBus.prototype._getListeners = function(name) {
- var listeners = this._listeners[name];
- if (!listeners) {
- this._listeners[name] = listeners = [];
- }
- return listeners;
- };
- /**
- * A event that is emitted via the event bus.
- */
- function Event() { }
- module.exports.Event = Event;
- Event.prototype.stopPropagation = function() {
- this.cancelBubble = true;
- };
- Event.prototype.preventDefault = function() {
- this.defaultPrevented = true;
- };
- Event.prototype.init = function(data) {
- assign(this, data || {});
- };
- },{"330":330,"331":331,"333":333,"339":339}],85:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- reduce = _dereq_(222);
- var GraphicsUtil = _dereq_(189),
- domClear = _dereq_(353);
- /**
- * A factory that creates graphical elements
- *
- * @param {Renderer} renderer
- */
- function GraphicsFactory(renderer, elementRegistry) {
- this._renderer = renderer;
- this._elementRegistry = elementRegistry;
- }
- GraphicsFactory.$inject = [ 'renderer', 'elementRegistry' ];
- module.exports = GraphicsFactory;
- GraphicsFactory.prototype._getChildren = function(element) {
- var gfx = this._elementRegistry.getGraphics(element);
- var childrenGfx;
- // root element
- if (!element.parent) {
- childrenGfx = gfx;
- } else {
- childrenGfx = GraphicsUtil.getChildren(gfx);
- if (!childrenGfx) {
- childrenGfx = gfx.parent().group().attr('class', 'djs-children');
- }
- }
- return childrenGfx;
- };
- /**
- * Clears the graphical representation of the element and returns the
- * cleared visual (the <g class="djs-visual" /> element).
- */
- GraphicsFactory.prototype._clear = function(gfx) {
- var visual = GraphicsUtil.getVisual(gfx);
- domClear(visual.node);
- return visual;
- };
- /**
- * Creates a gfx container for shapes and connections
- *
- * The layout is as follows:
- *
- * <g class="djs-group">
- *
- * <!-- the gfx -->
- * <g class="djs-element djs-(shape|connection)">
- * <g class="djs-visual">
- * <!-- the renderer draws in here -->
- * </g>
- *
- * <!-- extensions (overlays, click box, ...) goes here
- * </g>
- *
- * <!-- the gfx child nodes -->
- * <g class="djs-children"></g>
- * </g>
- *
- * @param {Object} parent
- * @param {String} type the type of the element, i.e. shape | connection
- */
- GraphicsFactory.prototype._createContainer = function(type, parentGfx) {
- var outerGfx = parentGfx.group().attr('class', 'djs-group'),
- gfx = outerGfx.group().attr('class', 'djs-element djs-' + type);
- // create visual
- gfx.group().attr('class', 'djs-visual');
- return gfx;
- };
- GraphicsFactory.prototype.create = function(type, element) {
- var childrenGfx = this._getChildren(element.parent);
- return this._createContainer(type, childrenGfx);
- };
- GraphicsFactory.prototype.updateContainments = function(elements) {
- var self = this,
- elementRegistry = this._elementRegistry,
- parents;
- parents = reduce(elements, function(map, e) {
- if (e.parent) {
- map[e.parent.id] = e.parent;
- }
- return map;
- }, {});
- // update all parents of changed and reorganized their children
- // in the correct order (as indicated in our model)
- forEach(parents, function(parent) {
- var childGfx = self._getChildren(parent),
- children = parent.children;
- if (!children) {
- return;
- }
- forEach(children.slice().reverse(), function(c) {
- var gfx = elementRegistry.getGraphics(c);
- gfx.parent().prependTo(childGfx);
- });
- });
- };
- GraphicsFactory.prototype.update = function(type, element, gfx) {
- // Do not update root element
- if (!element.parent) {
- return;
- }
- var visual = this._clear(gfx);
- // redraw
- if (type === 'shape') {
- this._renderer.drawShape(visual, element);
- // update positioning
- gfx.translate(element.x, element.y);
- } else
- if (type === 'connection') {
- this._renderer.drawConnection(visual, element);
- } else {
- throw new Error('unknown type: ' + type);
- }
- gfx.attr('display', element.hidden ? 'none' : 'block');
- };
- GraphicsFactory.prototype.remove = function(element) {
- var gfx = this._elementRegistry.getGraphics(element);
- // remove
- gfx.parent().remove();
- };
- },{"189":189,"218":218,"222":222,"353":353}],86:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(89) ],
- __init__: [ 'canvas' ],
- canvas: [ 'type', _dereq_(81) ],
- elementRegistry: [ 'type', _dereq_(83) ],
- elementFactory: [ 'type', _dereq_(82) ],
- eventBus: [ 'type', _dereq_(84) ],
- graphicsFactory: [ 'type', _dereq_(85) ]
- };
- },{"81":81,"82":82,"83":83,"84":84,"85":85,"89":89}],87:[function(_dereq_,module,exports){
- 'use strict';
- var Snap = _dereq_(200);
- /**
- * The default renderer used for shapes and connections.
- *
- * @param {Styles} styles
- */
- function Renderer(styles) {
- this.CONNECTION_STYLE = styles.style([ 'no-fill' ], { strokeWidth: 5, stroke: 'fuchsia' });
- this.SHAPE_STYLE = styles.style({ fill: 'white', stroke: 'fuchsia', strokeWidth: 2 });
- }
- module.exports = Renderer;
- Renderer.$inject = ['styles'];
- Renderer.prototype.drawShape = function drawShape(gfxGroup, data) {
- return gfxGroup.rect(0, 0, data.width || 0, data.height || 0).attr(this.SHAPE_STYLE);
- };
- Renderer.prototype.drawConnection = function drawConnection(gfxGroup, data) {
- return createLine(data.waypoints, this.CONNECTION_STYLE).appendTo(gfxGroup);
- };
- function componentsToPath(components) {
- return components.join(',').replace(/,?([A-z]),?/g, '$1');
- }
- /**
- * Gets the default SVG path of a shape that represents it's visual bounds.
- *
- * @param {djs.model.Shape} shape
- * @return {string} svg path
- */
- Renderer.prototype.getShapePath = function getShapePath(shape) {
- var x = shape.x,
- y = shape.y,
- width = shape.width,
- height = shape.height;
- var shapePath = [
- ['M', x, y],
- ['l', width, 0],
- ['l', 0, height],
- ['l', -width, 0],
- ['z']
- ];
- return componentsToPath(shapePath);
- };
- /**
- * Gets the default SVG path of a connection that represents it's visual bounds.
- *
- * @param {djs.model.Connection} connection
- * @return {string} svg path
- */
- Renderer.prototype.getConnectionPath = function getConnectionPath(connection) {
- var waypoints = connection.waypoints;
- var idx, point, connectionPath = [];
- for (idx = 0; !!(point = waypoints[idx]); idx++) {
- // take invisible docking into account
- // when creating the path
- point = point.original || point;
- connectionPath.push([ idx === 0 ? 'M' : 'L', point.x, point.y ]);
- }
- return componentsToPath(connectionPath);
- };
- function toSVGPoints(points) {
- var result = '';
- for (var i = 0, p; !!(p = points[i]); i++) {
- result += p.x + ',' + p.y + ' ';
- }
- return result;
- }
- function createLine(points, attrs) {
- return Snap.create('polyline', { points: toSVGPoints(points) }).attr(attrs || {});
- }
- function updateLine(gfx, points) {
- return gfx.attr({ points: toSVGPoints(points) });
- }
- module.exports.createLine = createLine;
- module.exports.updateLine = updateLine;
- },{"200":200}],88:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- assign = _dereq_(339),
- reduce = _dereq_(222);
- /**
- * A component that manages shape styles
- */
- function Styles() {
- var defaultTraits = {
- 'no-fill': {
- fill: 'none'
- },
- 'no-border': {
- strokeOpacity: 0.0
- },
- 'no-events': {
- pointerEvents: 'none'
- }
- };
- /**
- * Builds a style definition from a className, a list of traits and an object of additional attributes.
- *
- * @param {String} className
- * @param {Array<String>} traits
- * @param {Object} additionalAttrs
- *
- * @return {Object} the style defintion
- */
- this.cls = function(className, traits, additionalAttrs) {
- var attrs = this.style(traits, additionalAttrs);
- return assign(attrs, { 'class': className });
- };
- /**
- * Builds a style definition from a list of traits and an object of additional attributes.
- *
- * @param {Array<String>} traits
- * @param {Object} additionalAttrs
- *
- * @return {Object} the style defintion
- */
- this.style = function(traits, additionalAttrs) {
- if (!isArray(traits) && !additionalAttrs) {
- additionalAttrs = traits;
- traits = [];
- }
- var attrs = reduce(traits, function(attrs, t) {
- return assign(attrs, defaultTraits[t] || {});
- }, {});
- return additionalAttrs ? assign(attrs, additionalAttrs) : attrs;
- };
- }
- module.exports = Styles;
- },{"222":222,"330":330,"339":339}],89:[function(_dereq_,module,exports){
- module.exports = {
- renderer: [ 'type', _dereq_(87) ],
- styles: [ 'type', _dereq_(88) ]
- };
- },{"87":87,"88":88}],90:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- flatten = _dereq_(208),
- filter = _dereq_(216),
- groupBy = _dereq_(219),
- map = _dereq_(221);
- var saveClear = _dereq_(195).saveClear;
- var inherits = _dereq_(207);
- var LOW_PRIORITY = 250,
- HIGH_PRIORITY = 1500;
- var CommandInterceptor = _dereq_(78);
- function AttachSupport(eventBus, modeling, moveVisuals, rules) {
- CommandInterceptor.call(this, eventBus);
- // remove all the nested attached elements from the moved
- // shapes; they will be moved together with the host element
- // anyway
- eventBus.on('shape.move.start', HIGH_PRIORITY, function(e) {
- var context = e.context,
- shapes = context.shapes;
- context.shapes = removeAttached(shapes);
- });
- // add attachers to the visual's group
- eventBus.on('shape.move.start', LOW_PRIORITY, function(e) {
- var context = e.context,
- shapes = context.shapes,
- attachers = context.movedAttachers = getAttachers(shapes);
- forEach(attachers, function(attacher) {
- moveVisuals.makeDraggable(context, attacher, true);
- });
- });
- // move all attachments after the other shapes are done moving
- this.postExecuted([ 'shapes.move' ], function(event) {
- var context = event.context,
- closure = context.closure,
- enclosedElements = closure.enclosedElements,
- attachers = getAttachers(closure.enclosedElements);
- // ensure we move all attachers with their hosts
- // if they have not been moved already
- forEach(attachers, function(attacher){
- if (!enclosedElements[attacher.id]) {
- modeling.moveShape(attacher, context.delta, context.newParent);
- }
- });
- });
- // perform the attaching after shapes are done moving
- this.postExecuted([ 'shapes.move' ], function(e) {
- var context = e.context,
- shapes = context.shapes,
- newHost = context.newHost,
- attachers;
- if (shapes.length > 1) {
- return;
- }
- if (newHost) {
- attachers = shapes;
- } else {
- attachers = filter(shapes, function(s) {
- return !!s.host;
- });
- }
- forEach(attachers, function(attacher) {
- modeling.updateAttachment(attacher, newHost);
- });
- });
- // update attachments if the host is replaced
- this.postExecute([ 'shape.replace' ], function(e) {
- var context = e.context,
- oldShape = context.oldShape,
- newShape = context.newShape;
- saveClear(oldShape.attachers, function(attacher) {
- var allowed = rules.allowed('shapes.move', {
- target: newShape,
- shapes: [attacher]
- });
- if (allowed === 'attach') {
- modeling.updateAttachment(attacher, newShape);
- } else {
- modeling.removeShape(attacher);
- }
- });
- });
- // remove attachments
- this.preExecute([ 'shape.delete' ], function(event) {
- var shape = event.context.shape;
- saveClear(shape.attachers, function(attacher) {
- modeling.removeShape(attacher);
- });
- });
- }
- inherits(AttachSupport, CommandInterceptor);
- AttachSupport.$inject = [ 'eventBus', 'modeling', 'moveVisuals', 'rules' ];
- module.exports = AttachSupport;
- /**
- * Return attachers of the given shapes
- *
- * @param {Array<djs.model.Base>} shapes
- * @return {Array<djs.model.Base>}
- */
- function getAttachers(shapes) {
- return flatten(map(shapes, function(s) {
- return s.attachers || [];
- }));
- }
- /**
- * Return a filtered list of elements that do not
- * contain attached elements with hosts being part
- * of the selection.
- *
- * @param {Array<djs.model.Base>} elements
- *
- * @return {Array<djs.model.Base>} filtered
- */
- function removeAttached(elements) {
- var ids = groupBy(elements, 'id');
- return filter(elements, function(element) {
- while (element) {
- // host in selection
- if (element.host && ids[element.host.id]) {
- return false;
- }
- element = element.parent;
- }
- return true;
- });
- }
- },{"195":195,"207":207,"208":208,"216":216,"218":218,"219":219,"221":221,"78":78}],91:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(139),
- _dereq_(112)
- ],
- __init__: [ 'attachSupport'],
- attachSupport: [ 'type', _dereq_(90) ]
- };
- },{"112":112,"139":139,"90":90}],92:[function(_dereq_,module,exports){
- 'use strict';
- var Geometry = _dereq_(188),
- BendpointUtil = _dereq_(94);
- var MARKER_OK = 'connect-ok',
- MARKER_NOT_OK = 'connect-not-ok',
- MARKER_CONNECT_HOVER = 'connect-hover',
- MARKER_CONNECT_UPDATING = 'djs-updating';
- var COMMAND_BENDPOINT_UPDATE = 'connection.updateWaypoints',
- COMMAND_RECONNECT_START = 'connection.reconnectStart',
- COMMAND_RECONNECT_END = 'connection.reconnectEnd';
- var round = Math.round;
- /**
- * A component that implements moving of bendpoints
- */
- function BendpointMove(injector, eventBus, canvas, dragging, graphicsFactory, rules, modeling) {
- var connectionDocking;
- // optional connection docking integration
- try {
- connectionDocking = injector.get('connectionDocking');
- } catch (e) {}
- // API
- this.start = function(event, connection, bendpointIndex, insert) {
- var type,
- context,
- waypoints = connection.waypoints,
- gfx = canvas.getGraphics(connection);
- if (!insert && bendpointIndex === 0) {
- type = COMMAND_RECONNECT_START;
- } else
- if (!insert && bendpointIndex === waypoints.length - 1) {
- type = COMMAND_RECONNECT_END;
- } else {
- type = COMMAND_BENDPOINT_UPDATE;
- }
- context = {
- connection: connection,
- bendpointIndex: bendpointIndex,
- insert: insert,
- type: type
- };
- dragging.activate(event, 'bendpoint.move', {
- data: {
- connection: connection,
- connectionGfx: gfx,
- context: context
- }
- });
- };
- // DRAGGING IMPLEMENTATION
- function redrawConnection(data) {
- graphicsFactory.update('connection', data.connection, data.connectionGfx);
- }
- function filterRedundantWaypoints(waypoints) {
- return waypoints.filter(function(r, idx) {
- return !Geometry.pointsOnLine(waypoints[idx - 1], waypoints[idx + 1], r);
- });
- }
- eventBus.on('bendpoint.move.start', function(e) {
- var context = e.context,
- connection = context.connection,
- originalWaypoints = connection.waypoints,
- waypoints = originalWaypoints.slice(),
- insert = context.insert,
- idx = context.bendpointIndex;
- context.originalWaypoints = originalWaypoints;
- if (insert) {
- // insert placeholder for bendpoint to-be-added
- waypoints.splice(idx, 0, null);
- }
- connection.waypoints = waypoints;
- // add dragger gfx
- context.draggerGfx = BendpointUtil.addBendpoint(canvas.getLayer('overlays'));
- context.draggerGfx.addClass('djs-dragging');
- canvas.addMarker(connection, MARKER_CONNECT_UPDATING);
- });
- eventBus.on('bendpoint.move.hover', function(e) {
- e.context.hover = e.hover;
- canvas.addMarker(e.hover, MARKER_CONNECT_HOVER);
- });
- eventBus.on([
- 'bendpoint.move.out',
- 'bendpoint.move.cleanup'
- ], function(e) {
- // remove connect marker
- // if it was added
- var hover = e.context.hover;
- if (hover) {
- canvas.removeMarker(hover, MARKER_CONNECT_HOVER);
- canvas.removeMarker(hover, e.context.target ? MARKER_OK : MARKER_NOT_OK);
- }
- });
- eventBus.on('bendpoint.move.move', function(e) {
- var context = e.context,
- moveType = context.type,
- connection = e.connection,
- source, target;
- connection.waypoints[context.bendpointIndex] = { x: e.x, y: e.y };
- if (connectionDocking) {
- if (context.hover) {
- if (moveType === COMMAND_RECONNECT_START) {
- source = context.hover;
- }
- if (moveType === COMMAND_RECONNECT_END) {
- target = context.hover;
- }
- }
- connection.waypoints = connectionDocking.getCroppedWaypoints(connection, source, target);
- }
- // asks whether reconnect / bendpoint move / bendpoint add
- // is allowed at the given position
- var allowed = context.allowed = rules.allowed(context.type, context);
- if (allowed) {
- if (context.hover) {
- canvas.removeMarker(context.hover, MARKER_NOT_OK);
- canvas.addMarker(context.hover, MARKER_OK);
- context.target = context.hover;
- }
- } else
- if (allowed === false) {
- if (context.hover) {
- canvas.removeMarker(context.hover, MARKER_OK);
- canvas.addMarker(context.hover, MARKER_NOT_OK);
- context.target = null;
- }
- }
- // add dragger gfx
- context.draggerGfx.translate(e.x, e.y);
- redrawConnection(e);
- });
- eventBus.on([
- 'bendpoint.move.end',
- 'bendpoint.move.cancel'
- ], function(e) {
- var context = e.context,
- connection = context.connection;
- // remove dragger gfx
- context.draggerGfx.remove();
- context.newWaypoints = connection.waypoints.slice();
- connection.waypoints = context.originalWaypoints;
- canvas.removeMarker(connection, MARKER_CONNECT_UPDATING);
- });
- eventBus.on('bendpoint.move.end', function(e) {
- var context = e.context,
- waypoints = context.newWaypoints,
- bendpointIndex = context.bendpointIndex,
- bendpoint = waypoints[bendpointIndex],
- allowed = context.allowed;
- // ensure we have actual pixel values bendpoint
- // coordinates (important when zoom level was > 1 during move)
- bendpoint.x = round(bendpoint.x);
- bendpoint.y = round(bendpoint.y);
- if (allowed === true && context.type === COMMAND_RECONNECT_START) {
- modeling.reconnectStart(context.connection, context.target, bendpoint);
- } else
- if (allowed === true && context.type === COMMAND_RECONNECT_END) {
- modeling.reconnectEnd(context.connection, context.target, bendpoint);
- } else
- if (allowed !== false && context.type === COMMAND_BENDPOINT_UPDATE) {
- modeling.updateWaypoints(context.connection, filterRedundantWaypoints(waypoints));
- } else {
- redrawConnection(e);
- return false;
- }
- });
- eventBus.on('bendpoint.move.cancel', function(e) {
- redrawConnection(e);
- });
- }
- BendpointMove.$inject = [ 'injector', 'eventBus', 'canvas', 'dragging', 'graphicsFactory', 'rules', 'modeling' ];
- module.exports = BendpointMove;
- },{"188":188,"94":94}],93:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- pick = _dereq_(345),
- forEach = _dereq_(218);
- var Snap = _dereq_(200);
- var round = Math.round;
- function BendpointSnapping(eventBus) {
- function snapTo(candidates, point) {
- return Snap.snapTo(candidates, point);
- }
- function toPoint(e) {
- return pick(e, [ 'x', 'y' ]);
- }
- function mid(element) {
- if (element.width) {
- return {
- x: round(element.width / 2 + element.x),
- y: round(element.height / 2 + element.y)
- };
- }
- }
- function getSnapPoints(context) {
- var snapPoints = context.snapPoints,
- waypoints = context.connection.waypoints,
- bendpointIndex = context.bendpointIndex,
- referenceWaypoints = [ waypoints[bendpointIndex - 1], waypoints[bendpointIndex + 1] ];
- if (!snapPoints) {
- context.snapPoints = snapPoints = { horizontal: [] , vertical: [] };
- forEach(referenceWaypoints, function(p) {
- // we snap on existing bendpoints only,
- // not placeholders that are inserted during add
- if (p) {
- p = p.original || p;
- snapPoints.horizontal.push(p.y);
- snapPoints.vertical.push(p.x);
- }
- });
- }
- return snapPoints;
- }
- eventBus.on('bendpoint.move.start', function(event) {
- event.context.snapStart = toPoint(event);
- });
- eventBus.on('bendpoint.move.move', 1500, function(event) {
- var context = event.context,
- snapPoints = getSnapPoints(context),
- start = context.snapStart,
- target = context.target,
- targetMid = target && mid(target),
- x = start.x + event.dx,
- y = start.y + event.dy,
- sx, sy;
- if (!snapPoints) {
- return;
- }
- // snap
- sx = snapTo(targetMid ? snapPoints.vertical.concat([ targetMid.x ]) : snapPoints.vertical, x);
- sy = snapTo(targetMid ? snapPoints.horizontal.concat([ targetMid.y ]) : snapPoints.horizontal, y);
- // correction x/y
- var cx = (x - sx),
- cy = (y - sy);
- // update delta
- assign(event, {
- dx: event.dx - cx,
- dy: event.dy - cy,
- x: event.x - cx,
- y: event.y - cy
- });
- });
- }
- BendpointSnapping.$inject = [ 'eventBus' ];
- module.exports = BendpointSnapping;
- },{"200":200,"218":218,"339":339,"345":345}],94:[function(_dereq_,module,exports){
- 'use strict';
- var Events = _dereq_(187);
- var BENDPOINT_CLS = module.exports.BENDPOINT_CLS = 'djs-bendpoint';
- module.exports.toCanvasCoordinates = function(canvas, event) {
- var position = Events.toPoint(event),
- clientRect = canvas._container.getBoundingClientRect(),
- offset;
- // canvas relative position
- offset = {
- x: clientRect.left,
- y: clientRect.top
- };
- // update actual event payload with canvas relative measures
- var viewbox = canvas.viewbox();
- return {
- x: viewbox.x + (position.x - offset.x) / viewbox.scale,
- y: viewbox.y + (position.y - offset.y) / viewbox.scale
- };
- };
- module.exports.addBendpoint = function(parentGfx) {
- var groupGfx = parentGfx.group().addClass(BENDPOINT_CLS);
- groupGfx.circle(0, 0, 4).addClass('djs-visual');
- groupGfx.circle(0, 0, 10).addClass('djs-hit');
- return groupGfx;
- };
- },{"187":187}],95:[function(_dereq_,module,exports){
- 'use strict';
- var domEvent = _dereq_(357),
- BendpointUtil = _dereq_(94);
- var BENDPOINT_CLS = BendpointUtil.BENDPOINT_CLS;
- var getApproxIntersection = _dereq_(191).getApproxIntersection;
- /**
- * A service that adds editable bendpoints to connections.
- */
- function Bendpoints(injector, eventBus, canvas, interactionEvents, bendpointMove) {
- function getConnectionIntersection(waypoints, event) {
- var localPosition = BendpointUtil.toCanvasCoordinates(canvas, event);
- return getApproxIntersection(waypoints, localPosition);
- }
- function activateBendpointMove(event, connection) {
- var waypoints = connection.waypoints,
- intersection = getConnectionIntersection(waypoints, event);
- if (!intersection) {
- return;
- }
- bendpointMove.start(event, connection, intersection.index, !intersection.bendpoint);
- }
- function getBendpointsContainer(element, create) {
- var layer = canvas.getLayer('overlays'),
- gfx = layer.select('.djs-bendpoints[data-element-id=' + element.id + ']');
- if (!gfx && create) {
- gfx = layer.group().addClass('djs-bendpoints').attr('data-element-id', element.id);
- domEvent.bind(gfx.node, 'mousedown', function(event) {
- activateBendpointMove(event, element);
- });
- }
- return gfx;
- }
- function createBendpoints(gfx, connection) {
- connection.waypoints.forEach(function(p, idx) {
- BendpointUtil.addBendpoint(gfx).translate(p.x, p.y);
- });
- // add floating bendpoint
- BendpointUtil.addBendpoint(gfx).addClass('floating');
- }
- function clearBendpoints(gfx) {
- gfx.selectAll('.' + BENDPOINT_CLS).forEach(function(s) {
- s.remove();
- });
- }
- function addBendpoints(connection) {
- var gfx = getBendpointsContainer(connection);
- if (!gfx) {
- gfx = getBendpointsContainer(connection, true);
- createBendpoints(gfx, connection);
- }
- return gfx;
- }
- function updateBendpoints(connection) {
- var gfx = getBendpointsContainer(connection);
- if (gfx) {
- clearBendpoints(gfx);
- createBendpoints(gfx, connection);
- }
- }
- eventBus.on('connection.changed', function(event) {
- updateBendpoints(event.element);
- });
- eventBus.on('connection.remove', function(event) {
- var gfx = getBendpointsContainer(event.element);
- if (gfx) {
- gfx.remove();
- }
- });
- eventBus.on('element.marker.update', function(event) {
- var element = event.element,
- bendpointsGfx;
- if (!element.waypoints) {
- return;
- }
- bendpointsGfx = addBendpoints(element);
- bendpointsGfx[event.add ? 'addClass' : 'removeClass'](event.marker);
- });
- eventBus.on('element.mousemove', function(event) {
- var element = event.element,
- waypoints = element.waypoints,
- bendpointsGfx,
- floating,
- intersection;
- if (waypoints) {
- bendpointsGfx = getBendpointsContainer(element, true);
- floating = bendpointsGfx.select('.floating');
- if (!floating) {
- return;
- }
- intersection = getConnectionIntersection(waypoints, event.originalEvent);
- if (intersection) {
- floating.translate(intersection.point.x, intersection.point.y);
- }
- }
- });
- eventBus.on('element.mousedown', function(event) {
- var originalEvent = event.originalEvent,
- element = event.element,
- waypoints = element.waypoints;
- if (!waypoints) {
- return;
- }
- activateBendpointMove(originalEvent, element, waypoints);
- });
- eventBus.on('selection.changed', function(event) {
- var newSelection = event.newSelection,
- primary = newSelection[0];
- if (primary && primary.waypoints) {
- addBendpoints(primary);
- }
- });
- eventBus.on('element.hover', function(event) {
- var element = event.element;
- if (element.waypoints) {
- addBendpoints(element);
- interactionEvents.registerEvent(event.gfx.node, 'mousemove', 'element.mousemove');
- }
- });
- eventBus.on('element.out', function(event) {
- interactionEvents.unregisterEvent(event.gfx.node, 'mousemove', 'element.mousemove');
- });
- }
- Bendpoints.$inject = [ 'injector', 'eventBus', 'canvas', 'interactionEvents', 'bendpointMove' ];
- module.exports = Bendpoints;
- },{"191":191,"357":357,"94":94}],96:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(106), _dereq_(155) ],
- __init__: [ 'bendpoints', 'bendpointSnapping' ],
- bendpoints: [ 'type', _dereq_(95) ],
- bendpointMove: [ 'type', _dereq_(92) ],
- bendpointSnapping: [ 'type', _dereq_(93) ]
- };
- },{"106":106,"155":155,"92":92,"93":93,"95":95}],97:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Adds change support to the diagram, including
- *
- * <ul>
- * <li>redrawing shapes and connections on change</li>
- * </ul>
- *
- * @param {EventBus} eventBus
- * @param {ElementRegistry} elementRegistry
- * @param {GraphicsFactory} graphicsFactory
- */
- function ChangeSupport(eventBus, elementRegistry, graphicsFactory) {
- // redraw shapes / connections on change
- eventBus.on('element.changed', function(event) {
- var element = event.element;
- if (!event.gfx) {
- event.gfx = elementRegistry.getGraphics(element);
- }
- // shape + gfx may have been deleted
- if (!event.gfx) {
- return;
- }
- if (element.waypoints) {
- eventBus.fire('connection.changed', event);
- } else {
- eventBus.fire('shape.changed', event);
- }
- });
- eventBus.on('elements.changed', function(event) {
- var elements = event.elements;
- elements.forEach(function(e) {
- eventBus.fire('element.changed', { element: e });
- });
- graphicsFactory.updateContainments(elements);
- });
- eventBus.on('shape.changed', function(event) {
- graphicsFactory.update('shape', event.element, event.gfx);
- });
- eventBus.on('connection.changed', function(event) {
- graphicsFactory.update('connection', event.element, event.gfx);
- });
- }
- ChangeSupport.$inject = [ 'eventBus', 'elementRegistry', 'graphicsFactory' ];
- module.exports = ChangeSupport;
- },{}],98:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'changeSupport'],
- changeSupport: [ 'type', _dereq_(97) ]
- };
- },{"97":97}],99:[function(_dereq_,module,exports){
- 'use strict';
- var LayoutUtil = _dereq_(174);
- var MARKER_OK = 'connect-ok',
- MARKER_NOT_OK = 'connect-not-ok';
- function Connect(eventBus, dragging, modeling, rules, canvas, renderer) {
- // TODO(nre): separate UI and events
- // rules
- function canConnect(source, target) {
- return rules.allowed('connection.create', {
- source: source,
- target: target
- });
- }
- // layouting
- function crop(start, end, source, target) {
- var sourcePath = renderer.getShapePath(source),
- targetPath = target && renderer.getShapePath(target),
- connectionPath = renderer.getConnectionPath({ waypoints: [ start, end ] });
- start = LayoutUtil.getElementLineIntersection(sourcePath, connectionPath, true) || start;
- end = (target && LayoutUtil.getElementLineIntersection(targetPath, connectionPath, false)) || end;
- return [ start, end ];
- }
- // event handlers
- eventBus.on('connect.move', function(event) {
- var context = event.context,
- source = context.source,
- target = context.target,
- visual = context.visual,
- start, end, waypoints;
- // update connection visuals during drag
- start = LayoutUtil.getMid(source);
- end = {
- x: event.x,
- y: event.y
- };
- waypoints = crop(start, end, source, target);
- visual.attr('points', [ waypoints[0].x, waypoints[0].y, waypoints[1].x, waypoints[1].y ]);
- });
- eventBus.on('connect.hover', function(event) {
- var context = event.context,
- source = context.source,
- hover = event.hover,
- canExecute;
- canExecute = context.canExecute = canConnect(source, hover);
- // simply ignore hover
- if (canExecute === null) {
- return;
- }
- context.target = hover;
- canvas.addMarker(hover, canExecute ? MARKER_OK : MARKER_NOT_OK);
- });
- eventBus.on([ 'connect.out', 'connect.cleanup' ], function(event) {
- var context = event.context;
- if (context.target) {
- canvas.removeMarker(context.target, context.canExecute ? MARKER_OK : MARKER_NOT_OK);
- }
- context.target = null;
- });
- eventBus.on('connect.cleanup', function(event) {
- var context = event.context;
- if (context.visual) {
- context.visual.remove();
- }
- });
- eventBus.on('connect.start', function(event) {
- var context = event.context,
- visual;
- visual = canvas.getDefaultLayer().polyline().attr({
- 'stroke': '#333',
- 'strokeDasharray': [ 1 ],
- 'strokeWidth': 2,
- 'pointer-events': 'none'
- });
- context.visual = visual;
- });
- eventBus.on('connect.end', function(event) {
- var context = event.context,
- source = context.source,
- target = context.target,
- canExecute = context.canExecute || canConnect(source, target);
- if (!canExecute) {
- return false;
- }
- modeling.connect(source, target);
- });
- // API
- this.start = function(event, source, autoActivate) {
- dragging.activate(event, 'connect', {
- autoActivate: autoActivate,
- data: {
- shape: source,
- context: {
- source: source
- }
- }
- });
- };
- }
- Connect.$inject = [ 'eventBus', 'dragging', 'modeling', 'rules', 'canvas', 'renderer' ];
- module.exports = Connect;
- },{"174":174}],100:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(159),
- _dereq_(155),
- _dereq_(106)
- ],
- connect: [ 'type', _dereq_(99) ]
- };
- },{"106":106,"155":155,"159":159,"99":99}],101:[function(_dereq_,module,exports){
- 'use strict';
- var isFunction = _dereq_(331),
- forEach = _dereq_(218),
- domDelegate = _dereq_(355),
- domClear = _dereq_(353),
- domEvent = _dereq_(357),
- domAttr = _dereq_(351),
- domQuery = _dereq_(359),
- domClasses = _dereq_(352),
- domify = _dereq_(356);
- var entrySelector = '.entry';
- /**
- * A context pad that displays element specific, contextual actions next
- * to a diagram element.
- *
- * @param {EventBus} eventBus
- * @param {Overlays} overlays
- */
- function ContextPad(eventBus, overlays) {
- this._providers = [];
- this._eventBus = eventBus;
- this._overlays = overlays;
- this._current = null;
- this._init();
- }
- ContextPad.$inject = [ 'eventBus', 'overlays' ];
- /**
- * Registers events needed for interaction with other components
- */
- ContextPad.prototype._init = function() {
- var eventBus = this._eventBus;
- var self = this;
- eventBus.on('selection.changed', function(e) {
- var selection = e.newSelection;
- if (selection.length === 1) {
- self.open(selection[0]);
- } else {
- self.close();
- }
- });
- };
- /**
- * Register a provider with the context pad
- *
- * @param {ContextPadProvider} provider
- */
- ContextPad.prototype.registerProvider = function(provider) {
- this._providers.push(provider);
- };
- /**
- * Returns the context pad entries for a given element
- *
- * @param {djs.element.Base} element
- *
- * @return {Array<ContextPadEntryDescriptor>} list of entries
- */
- ContextPad.prototype.getEntries = function(element) {
- var entries = {};
- // loop through all providers and their entries.
- // group entries by id so that overriding an entry is possible
- forEach(this._providers, function(provider) {
- var e = provider.getContextPadEntries(element);
- forEach(e, function(entry, id) {
- entries[id] = entry;
- });
- });
- return entries;
- };
- /**
- * Trigger an action available on the opened context pad
- *
- * @param {String} action
- * @param {Event} event
- * @param {Boolean} [autoActivate=false]
- */
- ContextPad.prototype.trigger = function(action, event, autoActivate) {
- var current = this._current,
- element = current.element,
- entries = current.entries,
- entry,
- handler,
- originalEvent,
- button = event.delegateTarget || event.target;
- if (!button) {
- return event.preventDefault();
- }
- entry = entries[domAttr(button, 'data-action')];
- handler = entry.action;
- originalEvent = event.originalEvent || event;
- // simple action (via callback function)
- if (isFunction(handler)) {
- if (action === 'click') {
- return handler(originalEvent, element, autoActivate);
- }
- } else {
- if (handler[action]) {
- return handler[action](originalEvent, element, autoActivate);
- }
- }
- // silence other actions
- event.preventDefault();
- };
- /**
- * Open the context pad for the given element
- *
- * @param {djs.model.Base} element
- */
- ContextPad.prototype.open = function(element) {
- if (this._current && this._current.open) {
- if (this._current.element === element) {
- // no change needed
- return;
- }
- this.close();
- }
- this._updateAndOpen(element);
- };
- ContextPad.prototype._updateAndOpen = function(element) {
- var entries = this.getEntries(element),
- pad = this.getPad(element),
- html = pad.html;
- domClear(html);
- forEach(entries, function(entry, id) {
- var grouping = entry.group || 'default',
- control = domify(entry.html || '<div class="entry" draggable="true"></div>'),
- container;
- domAttr(control, 'data-action', id);
- container = domQuery('[data-group=' + grouping + ']', html);
- if (!container) {
- container = domify('<div class="group" data-group="' + grouping + '"></div>');
- html.appendChild(container);
- }
- container.appendChild(control);
- if (entry.className) {
- domClasses(control).add(entry.className);
- }
- if (entry.title) {
- domAttr(control, 'title', entry.title);
- }
- if (entry.imageUrl) {
- control.appendChild(domify('<img src="' + entry.imageUrl + '">'));
- }
- });
- domClasses(html).add('open');
- this._current = {
- element: element,
- pad: pad,
- entries: entries,
- open: true
- };
- this._eventBus.fire('contextPad.open', { current: this._current });
- };
- ContextPad.prototype.getPad = function(element) {
- var self = this;
- var overlays = this._overlays,
- pads = overlays.get({ element: element, type: 'context-pad' });
- // create context pad on demand if needed
- if (!pads.length) {
- var html = domify('<div class="djs-context-pad"></div>');
- domDelegate.bind(html, entrySelector, 'click', function(event) {
- self.trigger('click', event);
- });
- domDelegate.bind(html, entrySelector, 'dragstart', function(event) {
- self.trigger('dragstart', event);
- });
- // stop propagation of mouse events
- domEvent.bind(html, 'mousedown', function(event) {
- event.stopPropagation();
- });
- overlays.add(element, 'context-pad', {
- position: {
- right: -9,
- top: -6
- },
- html: html
- });
- pads = overlays.get({ element: element, type: 'context-pad' });
- this._eventBus.fire('contextPad.create', { element: element, pad: pads[0] });
- }
- return pads[0];
- };
- /**
- * Close the context pad
- */
- ContextPad.prototype.close = function() {
- var html;
- if (this._current) {
- if (this._current.open) {
- html = this._current.pad.html;
- domClasses(html).remove('open');
- }
- this._current.open = false;
- this._eventBus.fire('contextPad.close', { current: this._current });
- }
- };
- /**
- * Return the element the context pad is currently opened for,
- * if it is opened.
- *
- * @example
- *
- * contextPad.open(shape1);
- *
- * if (contextPad.isOpen()) {
- * // yes, we are open
- * }
- *
- * @return {djs.model.Base} element
- */
- ContextPad.prototype.isOpen = function() {
- return this._current && this._current.open;
- };
- module.exports = ContextPad;
- },{"218":218,"331":331,"351":351,"352":352,"353":353,"355":355,"356":356,"357":357,"359":359}],102:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(108),
- _dereq_(143)
- ],
- contextPad: [ 'type', _dereq_(101) ]
- };
- },{"101":101,"108":108,"143":143}],103:[function(_dereq_,module,exports){
- 'use strict';
- var MARKER_OK = 'drop-ok',
- MARKER_NOT_OK = 'drop-not-ok',
- MARKER_ATTACH = 'attach-ok';
- function Create(eventBus, dragging, rules, modeling, canvas, renderer, styles) {
- // rules
- function canCreate(shape, target, source, position) {
- if (source) {
- return rules.allowed('shape.append', {
- source: source,
- shape: shape,
- target: target,
- position: position
- });
- } else {
- return rules.allowed('shape.create', {
- shape: shape,
- target: target,
- position: position
- });
- }
- }
- /** set drop marker on an element */
- function setMarker(element, marker) {
- [ MARKER_ATTACH, MARKER_OK, MARKER_NOT_OK ].forEach(function(m) {
- if (m === marker) {
- canvas.addMarker(element, m);
- } else {
- canvas.removeMarker(element, m);
- }
- });
- }
- // visual helpers
- function createVisual(shape) {
- var group, preview, visual;
- group = canvas.getDefaultLayer().group().attr(styles.cls('djs-drag-group', [ 'no-events' ]));
- preview = group.group().addClass('djs-dragger');
- preview.translate(shape.width / -2, shape.height / -2);
- visual = preview.group().addClass('djs-visual');
- // hijack renderer to draw preview
- renderer.drawShape(visual, shape);
- return group;
- }
- // event handlers
- eventBus.on('create.move', function(event) {
- var context = event.context,
- shape = context.shape,
- visual = context.visual;
- // lazy init drag visual once we received the first real
- // drag move event (this allows us to get the proper canvas local coordinates)
- if (!visual) {
- visual = context.visual = createVisual(shape);
- }
- visual.translate(event.x, event.y);
- var hover = event.hover,
- canExecute;
- var position = {
- x: event.x,
- y: event.y
- };
- canExecute = context.canExecute = hover && canCreate(context.shape, hover, context.source, position);
- // ignore hover visually if canExecute is null
- if (hover && canExecute !== null) {
- context.target = hover;
- if (canExecute === 'attach') {
- setMarker(hover, MARKER_ATTACH);
- } else {
- setMarker(hover, context.canExecute ? MARKER_OK : MARKER_NOT_OK);
- }
- }
- });
- eventBus.on([ 'create.end', 'create.out', 'create.cleanup' ], function(event) {
- var context = event.context,
- target = context.target;
- if (target) {
- setMarker(target, null);
- }
- });
- eventBus.on('create.end', function(event) {
- var context = event.context,
- source = context.source,
- shape = context.shape,
- target = context.target,
- canExecute = context.canExecute,
- isAttach,
- position = {
- x: event.x,
- y: event.y
- };
- if (!canExecute) {
- return false;
- }
- if (source) {
- shape = modeling.appendShape(source, shape, position, target);
- } else {
- isAttach = canExecute === 'attach';
- shape = modeling.createShape(shape, position, target, isAttach);
- }
- // make sure we provide the actual attached
- // shape with the context so that selection and
- // other components can use it right after the create
- // operation ends
- context.shape = shape;
- });
- eventBus.on('create.cleanup', function(event) {
- var context = event.context;
- if (context.visual) {
- context.visual.remove();
- }
- });
- // API
- this.start = function(event, shape, source) {
- dragging.activate(event, 'create', {
- cursor: 'grabbing',
- autoActivate: true,
- data: {
- shape: shape,
- context: {
- shape: shape,
- source: source
- }
- }
- });
- };
- }
- Create.$inject = [ 'eventBus', 'dragging', 'rules', 'modeling', 'canvas', 'renderer', 'styles' ];
- module.exports = Create;
- },{}],104:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(106),
- _dereq_(159),
- _dereq_(155)
- ],
- create: [ 'type', _dereq_(103) ]
- };
- },{"103":103,"106":106,"155":155,"159":159}],105:[function(_dereq_,module,exports){
- 'use strict';
- /* global TouchEvent */
- var round = Math.round;
- var assign = _dereq_(339);
- var domEvent = _dereq_(357),
- Event = _dereq_(187),
- ClickTrap = _dereq_(183),
- Cursor = _dereq_(185);
- var EventBusEvent = _dereq_(84).Event;
- function suppressEvent(event) {
- if (event instanceof MouseEvent) {
- Event.stopEvent(event, true);
- } else {
- Event.preventDefault(event);
- }
- }
- function getLength(point) {
- return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2));
- }
- function substract(p1, p2) {
- return {
- x: p1.x - p2.x,
- y: p1.y - p2.y
- };
- }
- function add(p1, p2) {
- return {
- x: p1.x + p2.x,
- y: p1.y + p2.y
- };
- }
- /**
- * A helper that fires canvas localized drag events and realizes
- * the general "drag-and-drop" look and feel.
- *
- * Calling {@link Dragging#activate} activates dragging on a canvas.
- *
- * It provides the following:
- *
- * * emits the events `start`, `move`, `end`, `cancel` and `cleanup` via the {@link EventBus}.
- * Each of the events is prefixed with a prefix that is assigned during activate.
- * * sets and restores the cursor
- * * sets and restores the selection
- * * ensures there can be only one drag operation active at a time
- *
- * Dragging may be canceled manually by calling {@link Dragging#cancel} or by pressing ESC.
- *
- * @example
- *
- * function MyDragComponent(eventBus, dragging) {
- *
- * eventBus.on('mydrag.start', function(event) {
- * console.log('yes, we start dragging');
- * });
- *
- * eventBus.on('mydrag.move', function(event) {
- * console.log('canvas local coordinates', event.x, event.y, event.dx, event.dy);
- *
- * // local drag data is passed with the event
- * event.context.foo; // "BAR"
- *
- * // the original mouse event, too
- * event.originalEvent; // MouseEvent(...)
- * });
- *
- * eventBus.on('element.click', function(event) {
- * dragging.activate(event, 'mydrag', {
- * cursor: 'grabbing',
- * data: {
- * context: {
- * foo: "BAR"
- * }
- * }
- * });
- * });
- * }
- */
- function Dragging(eventBus, canvas, selection) {
- var defaultOptions = {
- threshold: 5
- };
- // the currently active drag operation
- // dragging is active as soon as this context exists.
- //
- // it is visually _active_ only when a context.active flag is set to true.
- var context;
- /* convert a global event into local coordinates */
- function toLocalPoint(globalPosition) {
- var viewbox = canvas.viewbox();
- var clientRect = canvas._container.getBoundingClientRect();
- return {
- x: viewbox.x + round((globalPosition.x - clientRect.left) / viewbox.scale),
- y: viewbox.y + round((globalPosition.y - clientRect.top) / viewbox.scale)
- };
- }
- /* scale point to local coordinates */
- function inLocalScale(point) {
- var viewbox = canvas.viewbox();
- return {
- x: round(point.x / viewbox.scale),
- y: round(point.y / viewbox.scale)
- };
- }
- // helpers
- function fire(type) {
- var event = assign(new EventBusEvent(), context.payload, context.data);
- // default integration
- if (eventBus.fire('drag.' + type, event) === false) {
- return false;
- }
- return eventBus.fire(context.prefix + '.' + type, event);
- }
- // event listeners
- function move(event, activate) {
- var payload = context.payload,
- globalStart = context.globalStart,
- globalCurrent = Event.toPoint(event),
- globalDelta = substract(globalCurrent, globalStart),
- localStart = context.localStart,
- localDelta = inLocalScale(globalDelta),
- localCurrent = add(localStart, localDelta);
- // activate context explicitly or once threshold is reached
- if (!context.active && (activate || getLength(globalDelta) > context.threshold)) {
- // fire start event with original
- // starting coordinates
- assign(payload, {
- x: localStart.x,
- y: localStart.y,
- dx: 0,
- dy: 0
- }, { originalEvent: event });
- if (false === fire('start')) {
- return cancel();
- }
- context.active = true;
- // unset selection and remember old selection
- // the previous (old) selection will always passed
- // with the event via the event.previousSelection property
- if (!context.keepSelection) {
- payload.previousSelection = selection.get();
- selection.select(null);
- }
- // allow custom cursor
- if (context.cursor) {
- Cursor.set(context.cursor);
- }
- }
- suppressEvent(event);
- if (context.active) {
- // update payload with actual coordinates
- assign(payload, {
- x: localCurrent.x,
- y: localCurrent.y,
- dx: localDelta.x,
- dy: localDelta.y
- }, { originalEvent: event });
- // emit move event
- fire('move');
- }
- }
- function end(event) {
- var returnValue = true;
- if (context.active) {
- if (event) {
- context.payload.originalEvent = event;
- // suppress original event (click, ...)
- // because we just ended a drag operation
- suppressEvent(event);
- }
- // implementations may stop restoring the
- // original state (selections, ...) by preventing the
- // end events default action
- returnValue = fire('end');
- }
- if (returnValue === false) {
- fire('rejected');
- }
- cleanup(returnValue !== true);
- }
- // cancel active drag operation if the user presses
- // the ESC key on the keyboard
- function checkCancel(event) {
- if (event.which === 27) {
- event.preventDefault();
- cancel();
- }
- }
- // prevent ghost click that might occur after a finished
- // drag and drop session
- function trapClickAndEnd(event) {
- var untrap;
- // trap the click in case we are part of an active
- // drag operation. This will effectively prevent
- // the ghost click that cannot be canceled otherwise.
- if (context.active) {
- untrap = ClickTrap.install();
- setTimeout(untrap, 400);
- }
- end(event);
- }
- function trapTouch(event) {
- move(event);
- }
- // update the drag events hover (djs.model.Base) and hoverGfx (Snap<SVGElement>)
- // properties during hover and out and fire {prefix}.hover and {prefix}.out properties
- // respectively
- function hover(event) {
- var payload = context.payload;
- payload.hoverGfx = event.gfx;
- payload.hover = event.element;
- fire('hover');
- }
- function out(event) {
- fire('out');
- var payload = context.payload;
- payload.hoverGfx = null;
- payload.hover = null;
- }
- // life-cycle methods
- function cancel(restore) {
- if (!context) {
- return;
- }
- if (context.active) {
- fire('cancel');
- }
- cleanup(restore);
- }
- function cleanup(restore) {
- fire('cleanup');
- // reset cursor
- Cursor.unset();
- // reset dom listeners
- domEvent.unbind(document, 'mousemove', move);
- domEvent.unbind(document, 'mousedown', trapClickAndEnd, true);
- domEvent.unbind(document, 'mouseup', trapClickAndEnd, true);
- domEvent.unbind(document, 'keyup', checkCancel);
- domEvent.unbind(document, 'touchstart', trapTouch, true);
- domEvent.unbind(document, 'touchcancel', cancel, true);
- domEvent.unbind(document, 'touchmove', move, true);
- domEvent.unbind(document, 'touchend', end, true);
- eventBus.off('element.hover', hover);
- eventBus.off('element.out', out);
- // restore selection, unless it has changed
- var previousSelection = context.payload.previousSelection;
- if (restore !== false && previousSelection && !selection.get().length) {
- selection.select(previousSelection);
- }
- context = null;
- }
- /**
- * Activate a drag operation.
- *
- * If `localPosition` is given, drag events will be emitted
- * relative to it.
- *
- * @param {MouseEvent|TouchEvent} [event]
- * @param {Point} [localPosition] actual diagram local position this drag operation should start at
- * @param {String} prefix
- * @param {Object} [options]
- */
- function activate(event, localPosition, prefix, options) {
- // only one drag operation may be active, at a time
- if (context) {
- cancel(false);
- }
- if (typeof localPosition === 'string') {
- options = prefix;
- prefix = localPosition;
- localPosition = null;
- }
- options = assign({}, defaultOptions, options || {});
- var data = options.data || {},
- originalEvent,
- globalStart;
- if (event) {
- originalEvent = Event.getOriginal(event) || event;
- globalStart = Event.toPoint(event);
- suppressEvent(event);
- } else {
- originalEvent = null;
- globalStart = { x: 0, y: 0 };
- }
- if (!localPosition) {
- localPosition = toLocalPoint(globalStart);
- }
- context = assign({
- prefix: prefix,
- data: data,
- payload: {},
- globalStart: globalStart,
- localStart: localPosition,
- }, options);
- // skip dom registration if trigger
- // is set to manual (during testing)
- if (!options.manual) {
- // add dom listeners
- // fixes TouchEvent not being available on desktop Firefox
- if (typeof TouchEvent !== 'undefined' && originalEvent instanceof TouchEvent) {
- domEvent.bind(document, 'touchstart', trapTouch, true);
- domEvent.bind(document, 'touchcancel', cancel, true);
- domEvent.bind(document, 'touchmove', move, true);
- domEvent.bind(document, 'touchend', end, true);
- } else {
- // assume we use the mouse to interact per default
- domEvent.bind(document, 'mousemove', move);
- domEvent.bind(document, 'mousedown', trapClickAndEnd, true);
- domEvent.bind(document, 'mouseup', trapClickAndEnd, true);
- }
- domEvent.bind(document, 'keyup', checkCancel);
- eventBus.on('element.hover', hover);
- eventBus.on('element.out', out);
- }
- fire('activate');
- if (options.autoActivate) {
- move(event, true);
- }
- }
- // cancel on diagram destruction
- eventBus.on('diagram.destroy', cancel);
- // API
- this.activate = activate;
- this.move = move;
- this.hover = hover;
- this.out = out;
- this.end = end;
- this.cancel = cancel;
- // for introspection
- this.active = function() {
- return context;
- };
- this.setOptions = function(options) {
- assign(defaultOptions, options);
- };
- }
- Dragging.$inject = [ 'eventBus', 'canvas', 'selection' ];
- module.exports = Dragging;
- },{"183":183,"185":185,"187":187,"339":339,"357":357,"84":84}],106:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(159)
- ],
- dragging: [ 'type', _dereq_(105) ]
- };
- },{"105":105,"159":159}],107:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- domDelegate = _dereq_(355),
- Renderer = _dereq_(87),
- createLine = Renderer.createLine,
- updateLine = Renderer.updateLine;
- var isPrimaryButton = _dereq_(193).isPrimaryButton;
- var Snap = _dereq_(200);
- /**
- * A plugin that provides interaction events for diagram elements.
- *
- * It emits the following events:
- *
- * * element.hover
- * * element.out
- * * element.click
- * * element.dblclick
- * * element.mousedown
- *
- * Each event is a tuple { element, gfx, originalEvent }.
- *
- * Canceling the event via Event#preventDefault() prevents the original DOM operation.
- *
- * @param {EventBus} eventBus
- */
- function InteractionEvents(eventBus, elementRegistry, styles) {
- var HIT_STYLE = styles.cls('djs-hit', [ 'no-fill', 'no-border' ], {
- stroke: 'white',
- strokeWidth: 15
- });
- function fire(type, event) {
- var target = event.delegateTarget || event.target,
- gfx = target && new Snap(target),
- element = elementRegistry.get(gfx),
- returnValue;
- if (!gfx || !element) {
- return;
- }
- returnValue = eventBus.fire(type, { element: element, gfx: gfx, originalEvent: event });
- if (returnValue === false) {
- event.stopPropagation();
- event.preventDefault();
- }
- }
- var handlers = {};
- function mouseHandler(type) {
- var fn = handlers[type];
- if (!fn) {
- fn = handlers[type] = function(event) {
- // only indicate left mouse button interactions
- if (isPrimaryButton(event)) {
- fire(type, event);
- }
- };
- }
- return fn;
- }
- var bindings = {
- mouseover: 'element.hover',
- mouseout: 'element.out',
- click: 'element.click',
- dblclick: 'element.dblclick',
- mousedown: 'element.mousedown',
- mouseup: 'element.mouseup'
- };
- var elementSelector = 'svg, .djs-element';
- ///// event registration
- function registerEvent(node, event, localEvent) {
- var handler = mouseHandler(localEvent);
- handler.$delegate = domDelegate.bind(node, elementSelector, event, handler);
- }
- function unregisterEvent(node, event, localEvent) {
- domDelegate.unbind(node, event, mouseHandler(localEvent).$delegate);
- }
- function registerEvents(svg) {
- forEach(bindings, function(val, key) {
- registerEvent(svg.node, key, val);
- });
- }
- function unregisterEvents(svg) {
- forEach(bindings, function(val, key) {
- unregisterEvent(svg.node, key, val);
- });
- }
- eventBus.on('canvas.destroy', function(event) {
- unregisterEvents(event.svg);
- });
- eventBus.on('canvas.init', function(event) {
- registerEvents(event.svg);
- });
- eventBus.on([ 'shape.added', 'connection.added' ], function(event) {
- var element = event.element,
- gfx = event.gfx,
- hit,
- type;
- if (element.waypoints) {
- hit = createLine(element.waypoints);
- type = 'connection';
- } else {
- hit = Snap.create('rect', { x: 0, y: 0, width: element.width, height: element.height });
- type = 'shape';
- }
- hit.attr(HIT_STYLE).appendTo(gfx.node);
- });
- // update djs-hit on change
- eventBus.on('shape.changed', function(event) {
- var element = event.element,
- gfx = event.gfx,
- hit = gfx.select('.djs-hit');
- hit.attr({
- width: element.width,
- height: element.height
- });
- });
- eventBus.on('connection.changed', function(event) {
- var element = event.element,
- gfx = event.gfx,
- hit = gfx.select('.djs-hit');
- updateLine(hit, element.waypoints);
- });
- // API
- this.fire = fire;
- this.mouseHandler = mouseHandler;
- this.registerEvent = registerEvent;
- this.unregisterEvent = unregisterEvent;
- }
- InteractionEvents.$inject = [ 'eventBus', 'elementRegistry', 'styles' ];
- module.exports = InteractionEvents;
- /**
- * An event indicating that the mouse hovered over an element
- *
- * @event element.hover
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- /**
- * An event indicating that the mouse has left an element
- *
- * @event element.out
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- /**
- * An event indicating that the mouse has clicked an element
- *
- * @event element.click
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- /**
- * An event indicating that the mouse has double clicked an element
- *
- * @event element.dblclick
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- /**
- * An event indicating that the mouse has gone down on an element.
- *
- * @event element.mousedown
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- /**
- * An event indicating that the mouse has gone up on an element.
- *
- * @event element.mouseup
- *
- * @type {Object}
- * @property {djs.model.Base} element
- * @property {Snap<Element>} gfx
- * @property {Event} originalEvent
- */
- },{"193":193,"200":200,"218":218,"355":355,"87":87}],108:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'interactionEvents' ],
- interactionEvents: [ 'type', _dereq_(107) ]
- };
- },{"107":107}],109:[function(_dereq_,module,exports){
- 'use strict';
- var domEvent = _dereq_(357),
- domMatches = _dereq_(358);
- /**
- * A keyboard abstraction that may be activated and
- * deactivated by users at will, consuming key events
- * and triggering diagram actions.
- *
- * The implementation fires the following key events that allow
- * other components to hook into key handling:
- *
- * - keyboard.bind
- * - keyboard.unbind
- * - keyboard.init
- * - keyboard.destroy
- *
- * All events contain the fields (node, listeners).
- *
- * A default binding for the keyboard may be specified via the
- * `keyboard.bindTo` configuration option.
- *
- * @param {EventBus} eventBus
- * @param {CommandStack} commandStack
- * @param {Modeling} modeling
- * @param {Selection} selection
- */
- function Keyboard(config, eventBus, commandStack, modeling, selection, zoomScroll, canvas) {
- var self = this;
- this._commandStack = commandStack;
- this._modeling = modeling;
- this._selection = selection;
- this._eventBus = eventBus;
- this._zoomScroll = zoomScroll;
- this._canvas = canvas;
- this._listeners = [];
- // our key handler is a singleton that passes
- // (keycode, modifiers) to each listener.
- //
- // listeners must indicate that they handled a key event
- // by returning true. This stops the event propagation.
- //
- this._keyHandler = function(event) {
- var i, l,
- target = event.target,
- listeners = self._listeners,
- code = event.keyCode || event.charCode || -1;
- if (domMatches(target, 'input, textarea')) {
- return;
- }
- for (i = 0; !!(l = listeners[i]); i++) {
- if (l(code, event)) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- };
- // properly clean dom registrations
- eventBus.on('diagram.destroy', function() {
- self._fire('destroy');
- self.unbind();
- self._listeners = null;
- });
- eventBus.on('diagram.init', function() {
- self._fire('init');
- if (config && config.bindTo) {
- self.bind(config.bindTo);
- }
- });
- this._init();
- }
- Keyboard.$inject = [
- 'config.keyboard',
- 'eventBus',
- 'commandStack',
- 'modeling',
- 'selection',
- 'zoomScroll',
- 'canvas'];
- module.exports = Keyboard;
- Keyboard.prototype.bind = function(node) {
- this._node = node;
- // bind key events
- domEvent.bind(node, 'keydown', this._keyHandler, true);
- this._fire('bind');
- };
- Keyboard.prototype.getBinding = function() {
- return this._node;
- };
- Keyboard.prototype.unbind = function() {
- var node = this._node;
- if (node) {
- this._fire('unbind');
- // unbind key events
- domEvent.unbind(node, 'keydown', this._keyHandler, true);
- }
- this._node = null;
- };
- Keyboard.prototype._fire = function(event) {
- this._eventBus.fire('keyboard.' + event, { node: this._node, listeners: this._listeners });
- };
- Keyboard.prototype._init = function() {
- var listeners = this._listeners,
- commandStack = this._commandStack,
- modeling = this._modeling,
- selection = this._selection,
- zoomScroll = this._zoomScroll,
- canvas = this._canvas;
- // init default listeners
- // undo
- // (CTRL|CMD) + Z
- function undo(key, modifiers) {
- if (isCmd(modifiers) && !isShift(modifiers) && key === 90) {
- commandStack.undo();
- return true;
- }
- }
- // redo
- // CTRL + Y
- // CMD + SHIFT + Z
- function redo(key, modifiers) {
- if (isCmd(modifiers) && (key === 89 || (key === 90 && isShift(modifiers)))) {
- commandStack.redo();
- return true;
- }
- }
- /**
- * zoom in one step
- * CTRL + +
- *
- * 107 = numpad plus
- * 187 = regular plus
- * 171 = regular plus in Firefox (german keyboard layout)
- * 61 = regular plus in Firefox (US keyboard layout)
- */
- function zoomIn(key, modifiers) {
- if ((key === 107 || key === 187 || key === 171 || key === 61) && isCmd(modifiers)) {
- zoomScroll.stepZoom(1);
- return true;
- }
- }
- /**
- * zoom out one step
- * CTRL + -
- *
- * 109 = numpad minus
- * 189 = regular minus
- * 173 = regular minus in Firefox (US and german keyboard layout)
- */
- function zoomOut(key, modifiers) {
- if ((key === 109 || key === 189 || key === 173) && isCmd(modifiers)) {
- zoomScroll.stepZoom(-1);
- return true;
- }
- }
- /**
- * zoom to the default level
- * CTRL + 0
- *
- * 96 = numpad zero
- * 48 = regular zero
- */
- function zoomDefault(key, modifiers) {
- if ((key === 96 || key === 48) && isCmd(modifiers)) {
- canvas.zoom(1);
- return true;
- }
- }
- // delete selected element
- // DEL
- function remove(key, modifiers) {
- if (key === 46) {
- var selectedElements = selection.get();
- if (selectedElements.length) {
- modeling.removeElements(selectedElements.slice());
- }
- return true;
- }
- }
- listeners.push(undo);
- listeners.push(redo);
- listeners.push(remove);
- listeners.push(zoomIn);
- listeners.push(zoomOut);
- listeners.push(zoomDefault);
- };
- /**
- * Add a listener function that is notified with (key, modifiers) whenever
- * the keyboard is bound and the user presses a key.
- *
- * @param {Function} listenerFn
- */
- Keyboard.prototype.addListener = function(listenerFn) {
- this._listeners.push(listenerFn);
- };
- Keyboard.prototype.hasModifier = hasModifier;
- Keyboard.prototype.isCmd = isCmd;
- Keyboard.prototype.isShift = isShift;
- function hasModifier(modifiers) {
- return (modifiers.ctrlKey || modifiers.metaKey || modifiers.shiftKey || modifiers.altKey);
- }
- function isCmd(modifiers) {
- return modifiers.ctrlKey || modifiers.metaKey;
- }
- function isShift(modifiers) {
- return modifiers.shiftKey;
- }
- },{"357":357,"358":358}],110:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'keyboard' ],
- keyboard: [ 'type', _dereq_(109) ]
- };
- },{"109":109}],111:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- filter = _dereq_(216),
- inherits = _dereq_(207);
- var LOW_PRIORITY = 250,
- HIGH_PRIORITY = 1500;
- var CommandInterceptor = _dereq_(78);
- /**
- * A handler that makes sure labels are properly moved with
- * their label targets.
- */
- function LabelSupport(eventBus, modeling, moveVisuals) {
- CommandInterceptor.call(this, eventBus);
- // remove labels from the collection that are being
- // moved with other elements anyway
- eventBus.on('shape.move.start', HIGH_PRIORITY, function(e) {
- var context = e.context,
- shapes = context.shapes;
- context.shapes = removeLabels(shapes);
- });
- // add labels to visual's group
- eventBus.on('shape.move.start', LOW_PRIORITY, function(e) {
- var context = e.context,
- shapes = context.shapes;
- var labels = [];
- forEach(shapes, function(element) {
- var label = element.label;
- if (label && !label.hidden && context.shapes.indexOf(label) === -1) {
- labels.push(label);
- }
- if (element.labelTarget) {
- labels.push(element);
- }
- });
- forEach(labels, function(label) {
- moveVisuals.makeDraggable(context, label, true);
- });
- });
- // move labels after the other shapes are done moving
- this.postExecute([ 'shapes.move' ], function(e) {
- var context = e.context,
- closure = context.closure,
- enclosedElements = closure.enclosedElements;
- // ensure we move all labels with their respective elements
- // if they have not been moved already
- forEach(enclosedElements, function(e) {
- if (e.label && !enclosedElements[e.label.id]) {
- modeling.moveShape(e.label, context.delta, e.parent);
- }
- });
- });
- }
- inherits(LabelSupport, CommandInterceptor);
- LabelSupport.$inject = [ 'eventBus', 'modeling', 'moveVisuals' ];
- module.exports = LabelSupport;
- /**
- * Return a filtered list of elements that do not
- * contain attached elements with hosts being part
- * of the selection.
- *
- * @param {Array<djs.model.Base>} elements
- *
- * @return {Array<djs.model.Base>} filtered
- */
- function removeLabels(elements) {
- return filter(elements, function(element) {
- // filter out labels that are move together
- // with their label targets
- return elements.indexOf(element.labelTarget) === -1;
- });
- }
- },{"207":207,"216":216,"218":218,"78":78}],112:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(139)
- ],
- __init__: [ 'labelSupport'],
- labelSupport: [ 'type', _dereq_(111) ]
- };
- },{"111":111,"139":139}],113:[function(_dereq_,module,exports){
- 'use strict';
- var values = _dereq_(347);
- var getEnclosedElements = _dereq_(186).getEnclosedElements;
- var hasPrimaryModifier = _dereq_(193).hasPrimaryModifier;
- var Snap = _dereq_(200);
- function LassoTool(eventBus, canvas, dragging, elementRegistry, selection) {
- this._selection = selection;
- this._dragging = dragging;
- var self = this;
- // lasso visuals implementation
- /**
- * A helper that realizes the selection box visual
- */
- var visuals = {
- create: function(context) {
- var container = canvas.getDefaultLayer(),
- frame;
- frame = context.frame = Snap.create('rect', {
- class: 'djs-lasso-overlay',
- width: 1,
- height: 1,
- x: 0,
- y: 0
- });
- frame.appendTo(container);
- },
- update: function(context) {
- var frame = context.frame,
- bbox = context.bbox;
- frame.attr({
- x: bbox.x,
- y: bbox.y,
- width: bbox.width,
- height: bbox.height
- });
- },
- remove: function(context) {
- if (context.frame) {
- context.frame.remove();
- }
- }
- };
- eventBus.on('lasso.selection.end', function(event) {
- setTimeout(function() {
- self.activateLasso(event.originalEvent, true);
- });
- });
- // lasso interaction implementation
- eventBus.on('lasso.end', function(event) {
- var bbox = toBBox(event);
- var elements = elementRegistry.filter(function(element) {
- return element;
- });
- self.select(elements, bbox);
- });
- eventBus.on('lasso.start', function(event) {
- var context = event.context;
- context.bbox = toBBox(event);
- visuals.create(context);
- });
- eventBus.on('lasso.move', function(event) {
- var context = event.context;
- context.bbox = toBBox(event);
- visuals.update(context);
- });
- eventBus.on('lasso.end', function(event) {
- var context = event.context;
- visuals.remove(context);
- });
- eventBus.on('lasso.cleanup', function(event) {
- var context = event.context;
- visuals.remove(context);
- });
- // event integration
- eventBus.on('element.mousedown', 1500, function(event) {
- if (hasPrimaryModifier(event)) {
- self.activateLasso(event.originalEvent);
- event.stopPropagation();
- }
- });
- }
- LassoTool.$inject = [
- 'eventBus',
- 'canvas',
- 'dragging',
- 'elementRegistry',
- 'selection'
- ];
- module.exports = LassoTool;
- LassoTool.prototype.activateLasso = function(event, autoActivate) {
- this._dragging.activate(event, 'lasso', {
- autoActivate: autoActivate,
- cursor: 'crosshair',
- data: {
- context: {}
- }
- });
- };
- LassoTool.prototype.activateSelection = function(event) {
- this._dragging.activate(event, 'lasso.selection', {
- cursor: 'crosshair'
- });
- };
- LassoTool.prototype.select = function(elements, bbox) {
- var selectedElements = getEnclosedElements(elements, bbox);
- this._selection.select(values(selectedElements));
- };
- function toBBox(event) {
- var start = {
- x: event.x - event.dx,
- y: event.y - event.dy
- };
- var end = {
- x: event.x,
- y: event.y
- };
- var bbox;
- if ((start.x <= end.x && start.y < end.y) ||
- (start.x < end.x && start.y <= end.y)) {
- bbox = {
- x: start.x,
- y: start.y,
- width: end.x - start.x,
- height: end.y - start.y
- };
- } else if ((start.x >= end.x && start.y < end.y) ||
- (start.x > end.x && start.y <= end.y)) {
- bbox = {
- x: end.x,
- y: start.y,
- width: start.x - end.x,
- height: end.y - start.y
- };
- } else if ((start.x <= end.x && start.y > end.y) ||
- (start.x < end.x && start.y >= end.y)) {
- bbox = {
- x: start.x,
- y: end.y,
- width: end.x - start.x,
- height: start.y - end.y
- };
- } else if ((start.x >= end.x && start.y > end.y) ||
- (start.x > end.x && start.y >= end.y)) {
- bbox = {
- x: end.x,
- y: end.y,
- width: start.x - end.x,
- height: start.y - end.y
- };
- } else {
- bbox = {
- x: end.x,
- y: end.y,
- width: 0,
- height: 0
- };
- }
- return bbox;
- }
- },{"186":186,"193":193,"200":200,"347":347}],114:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- __init__: [ 'lassoTool' ],
- lassoTool: [ 'type', _dereq_(113) ]
- };
- },{"113":113}],115:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var model = _dereq_(176);
- /**
- * The basic modeling entry point.
- *
- * @param {EventBus} eventBus
- * @param {ElementFactory} elementFactory
- * @param {CommandStack} commandStack
- */
- function Modeling(eventBus, elementFactory, commandStack) {
- this._eventBus = eventBus;
- this._elementFactory = elementFactory;
- this._commandStack = commandStack;
- var self = this;
- eventBus.on('diagram.init', function() {
- // register modeling handlers
- self.registerHandlers(commandStack);
- });
- }
- Modeling.$inject = [ 'eventBus', 'elementFactory', 'commandStack' ];
- module.exports = Modeling;
- Modeling.prototype.getHandlers = function() {
- return {
- 'shape.append': _dereq_(116),
- 'shape.create': _dereq_(120),
- 'shape.delete': _dereq_(123),
- 'shape.move': _dereq_(126),
- 'shape.attach': _dereq_(117),
- 'shapes.move': _dereq_(127),
- 'shape.resize': _dereq_(131),
- 'shape.replace': _dereq_(130),
- 'spaceTool': _dereq_(132),
- 'label.create': _dereq_(119),
- 'connection.create': _dereq_(118),
- 'connection.delete': _dereq_(121),
- 'connection.move': _dereq_(125),
- 'connection.layout': _dereq_(124),
- 'connection.updateWaypoints': _dereq_(134),
- 'connection.reconnectStart': _dereq_(129),
- 'connection.reconnectEnd': _dereq_(129),
- 'elements.delete': _dereq_(122),
- 'element.updateAnchors': _dereq_(133)
- };
- };
- /**
- * Register handlers with the command stack
- *
- * @param {CommandStack} commandStack
- */
- Modeling.prototype.registerHandlers = function(commandStack) {
- forEach(this.getHandlers(), function(handler, id) {
- commandStack.registerHandler(id, handler);
- });
- };
- ///// modeling helpers /////////////////////////////////////////
- Modeling.prototype.moveShape = function(shape, delta, newParent, hints) {
- var context = {
- shape: shape,
- delta: delta,
- newParent: newParent,
- hints: hints || {}
- };
- this._commandStack.execute('shape.move', context);
- };
- /**
- * Update the attachment of the given shape.
- *
- * @param {djs.mode.Base} shape
- * @param {djs.model.Base} [newHost]
- */
- Modeling.prototype.updateAttachment = function(shape, newHost) {
- var context = {
- shape: shape,
- newHost: newHost
- };
- this._commandStack.execute('shape.attach', context);
- };
- /**
- * Move a number of shapes to a new target, either setting it as
- * the new parent or attaching it.
- *
- * @param {Array<djs.mode.Base>} shapes
- * @param {Point} delta
- * @param {djs.model.Base} [target]
- * @param {Boolean} [isAttach=false]
- * @param {Object} [hints]
- */
- Modeling.prototype.moveShapes = function(shapes, delta, target, isAttach, hints) {
- if (typeof isAttach === 'object') {
- hints = isAttach;
- isAttach = undefined;
- }
- var newParent = target,
- newHost;
- if (isAttach === true) {
- newHost = target;
- newParent = target.parent;
- }
- if (isAttach === false) {
- newHost = null;
- }
- var context = {
- shapes: shapes,
- delta: delta,
- newParent: newParent,
- newHost: newHost,
- hints: hints || {}
- };
- this._commandStack.execute('shapes.move', context);
- };
- /**
- * Update the anchors on the element with the given delta movement
- * @param {djs.model.Element} element
- * @param {Point} delta
- */
- Modeling.prototype.updateAnchors = function(element, delta) {
- var context = {
- element: element,
- delta: delta
- };
- this._commandStack.execute('element.updateAnchors', context);
- };
- Modeling.prototype.moveConnection = function(connection, delta, newParent, hints) {
- var context = {
- connection: connection,
- delta: delta,
- newParent: newParent,
- hints: hints || {}
- };
- this._commandStack.execute('connection.move', context);
- };
- Modeling.prototype.layoutConnection = function(connection, hints) {
- var context = {
- connection: connection,
- hints: hints || {}
- };
- this._commandStack.execute('connection.layout', context);
- };
- Modeling.prototype.createConnection = function(source, target, connection, parent) {
- connection = this._create('connection', connection);
- var context = {
- source: source,
- target: target,
- parent: parent,
- connection: connection
- };
- this._commandStack.execute('connection.create', context);
- return context.connection;
- };
- Modeling.prototype.createShape = function(shape, position, target, isAttach) {
- shape = this._create('shape', shape);
- var context = {
- position: position,
- shape: shape,
- parent: target,
- host: shape.host
- };
- if (isAttach) {
- context.parent = target.parent;
- context.host = target;
- }
- this._commandStack.execute('shape.create', context);
- return context.shape;
- };
- Modeling.prototype.createLabel = function(labelTarget, position, label, parent) {
- label = this._create('label', label);
- var context = {
- labelTarget: labelTarget,
- position: position,
- parent: parent,
- shape: label
- };
- this._commandStack.execute('label.create', context);
- return context.shape;
- };
- Modeling.prototype.appendShape = function(source, shape, position, parent, connection, connectionParent) {
- shape = this._create('shape', shape);
- var context = {
- source: source,
- position: position,
- parent: parent,
- shape: shape,
- connection: connection,
- connectionParent: connectionParent
- };
- this._commandStack.execute('shape.append', context);
- return context.shape;
- };
- Modeling.prototype.removeElements = function(elements) {
- var context = {
- elements: elements
- };
- this._commandStack.execute('elements.delete', context);
- };
- Modeling.prototype.removeShape = function(shape) {
- var context = {
- shape: shape
- };
- this._commandStack.execute('shape.delete', context);
- };
- Modeling.prototype.removeConnection = function(connection) {
- var context = {
- connection: connection
- };
- this._commandStack.execute('connection.delete', context);
- };
- Modeling.prototype.replaceShape = function(oldShape, newShape, options) {
- var context = {
- oldShape: oldShape,
- newData: newShape,
- options: options
- };
- this._commandStack.execute('shape.replace', context);
- return context.newShape;
- };
- Modeling.prototype.resizeShape = function(shape, newBounds) {
- var context = {
- shape: shape,
- newBounds: newBounds
- };
- this._commandStack.execute('shape.resize', context);
- };
- Modeling.prototype.createSpace = function(movingShapes, resizingShapes, delta, direction) {
- var context = {
- movingShapes: movingShapes,
- resizingShapes: resizingShapes,
- delta: delta,
- direction: direction
- };
- this._commandStack.execute('spaceTool', context);
- };
- Modeling.prototype.updateWaypoints = function(connection, newWaypoints) {
- var context = {
- connection: connection,
- newWaypoints: newWaypoints
- };
- this._commandStack.execute('connection.updateWaypoints', context);
- };
- Modeling.prototype.reconnectStart = function(connection, newSource, dockingOrPoints) {
- var context = {
- connection: connection,
- newSource: newSource,
- dockingOrPoints: dockingOrPoints
- };
- this._commandStack.execute('connection.reconnectStart', context);
- };
- Modeling.prototype.reconnectEnd = function(connection, newTarget, dockingOrPoints) {
- var context = {
- connection: connection,
- newTarget: newTarget,
- dockingOrPoints: dockingOrPoints
- };
- this._commandStack.execute('connection.reconnectEnd', context);
- };
- Modeling.prototype.connect = function(source, target, attrs) {
- return this.createConnection(source, target, attrs || {}, source.parent);
- };
- Modeling.prototype._create = function(type, attrs) {
- if (attrs instanceof model.Base) {
- return attrs;
- } else {
- return this._elementFactory.create(type, attrs);
- }
- };
- },{"116":116,"117":117,"118":118,"119":119,"120":120,"121":121,"122":122,"123":123,"124":124,"125":125,"126":126,"127":127,"129":129,"130":130,"131":131,"132":132,"133":133,"134":134,"176":176,"218":218}],116:[function(_dereq_,module,exports){
- 'use strict';
- var any = _dereq_(214);
- var inherits = _dereq_(207);
- /**
- * A handler that implements reversible appending of shapes
- * to a source shape.
- *
- * @param {canvas} Canvas
- * @param {elementFactory} ElementFactory
- * @param {modeling} Modeling
- */
- function AppendShapeHandler(modeling) {
- this._modeling = modeling;
- }
- inherits(AppendShapeHandler, _dereq_(128));
- AppendShapeHandler.$inject = [ 'modeling' ];
- module.exports = AppendShapeHandler;
- ////// api /////////////////////////////////////////////
- /**
- * Creates a new shape
- *
- * @param {Object} context
- * @param {ElementDescriptor} context.shape the new shape
- * @param {ElementDescriptor} context.source the source object
- * @param {ElementDescriptor} context.parent the parent object
- * @param {Point} context.position position of the new element
- */
- AppendShapeHandler.prototype.preExecute = function(context) {
- if (!context.source) {
- throw new Error('source required');
- }
- var parent = context.parent || context.source.parent,
- shape = this._modeling.createShape(context.shape, context.position, parent);
- context.shape = shape;
- };
- AppendShapeHandler.prototype.postExecute = function(context) {
- var parent = context.connectionParent || context.shape.parent;
- if (!existsConnection(context.source, context.shape)) {
- // create connection
- this._modeling.connect(context.source, context.shape, context.connection, parent);
- }
- };
- function existsConnection(source, target) {
- return any(source.outgoing, function(c) {
- return c.target === target;
- });
- }
- },{"128":128,"207":207,"214":214}],117:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- map = _dereq_(221);
- /**
- * A handler that implements reversible attaching/detaching of shapes.
- */
- function AttachShapeHandler(modeling) {
- this._modeling = modeling;
- }
- module.exports = AttachShapeHandler;
- AttachShapeHandler.$inject = [ 'modeling' ];
- AttachShapeHandler.prototype.execute = function(context) {
- var shape = context.shape,
- newHost = context.newHost,
- oldHost = shape.host;
- // (0) detach from old host
- context.oldHost = oldHost;
- context.attacherIdx = removeAttacher(oldHost, shape);
- // (1) attach to new host
- addAttacher(newHost, shape);
- // position attacher and it's label on top of host
- positionOnTop(context);
- // (2) update host
- shape.host = newHost;
- return shape;
- };
- AttachShapeHandler.prototype.revert = function(context) {
- var shape = context.shape,
- newHost = context.newHost,
- oldHost = context.oldHost,
- attacherIdx = context.attacherIdx;
- // (2) update host
- shape.host = oldHost;
- // (1) attach to new host
- removeAttacher(newHost, shape);
- // (0) detach from old host
- addAttacher(oldHost, shape, attacherIdx);
- // position attacher and it's label on top of oldHost
- reposition(context);
- return shape;
- };
- function insertAfter(coll, a, b) {
- // b comes after a
- var aIdx = coll.indexOf(a),
- bIdx = coll.indexOf(b);
- if ((aIdx === -1 || bIdx === -1) || (bIdx > aIdx)) {
- return;
- }
- coll.splice(bIdx, 1);
- aIdx = coll.indexOf(a);
- coll.splice(aIdx, 1, a, b);
- }
- function positionOnTop(context) {
- var shape = context.shape,
- newHost = context.newHost,
- oldHost = context.oldHost,
- parent = shape.parent,
- children = parent.children,
- label;
- if (!newHost) {
- return;
- }
- var elements = (label = shape.label) ? [ oldHost, shape, label ] : [ oldHost, shape ];
- context.elements = map(elements, function(element) {
- return {
- shape: element,
- idx: children.indexOf(element)
- };
- });
- insertAfter(children, newHost, shape);
- if (label) {
- insertAfter(children, shape, label);
- }
- }
- function reposition(context) {
- var shape = context.shape,
- oldHost = context.oldHost,
- parent = shape.parent,
- children = parent.children,
- elements = context.elements;
- if (!oldHost) {
- return;
- }
- forEach(elements, function(element) {
- children.splice(children.indexOf(element.shape), 1);
- children.splice(element.idx, 0, element.shape);
- });
- }
- function removeAttacher(host, attacher) {
- var attachers = host && host.attachers;
- var idx = -1;
- if (attachers) {
- idx = attachers.indexOf(attacher);
- if (idx !== -1) {
- attachers.splice(idx, 1);
- }
- }
- return idx;
- }
- function addAttacher(host, attacher, idx) {
- if (!host) {
- return;
- }
- var attachers = host.attachers;
- if (!attachers) {
- host.attachers = attachers = [];
- }
- attachers.splice(idx || attachers.length, 0, attacher);
- }
- },{"218":218,"221":221}],118:[function(_dereq_,module,exports){
- 'use strict';
- function CreateConnectionHandler(canvas, layouter) {
- this._canvas = canvas;
- this._layouter = layouter;
- }
- CreateConnectionHandler.$inject = [ 'canvas', 'layouter' ];
- module.exports = CreateConnectionHandler;
- ////// api /////////////////////////////////////////
- /**
- * Appends a shape to a target shape
- *
- * @param {Object} context
- * @param {djs.element.Base} context.source the source object
- * @param {djs.element.Base} context.target the parent object
- * @param {Point} context.position position of the new element
- */
- CreateConnectionHandler.prototype.execute = function(context) {
- var source = context.source,
- target = context.target,
- parent = context.parent;
- if (!source || !target) {
- throw new Error('source and target required');
- }
- if (!parent) {
- throw new Error('parent required');
- }
- var connection = context.connection;
- connection.source = source;
- connection.target = target;
- if (!connection.waypoints) {
- connection.waypoints = this._layouter.layoutConnection(connection);
- }
- // add connection
- this._canvas.addConnection(connection, parent);
- return connection;
- };
- CreateConnectionHandler.prototype.revert = function(context) {
- var connection = context.connection;
- this._canvas.removeConnection(connection);
- connection.source = null;
- connection.target = null;
- };
- },{}],119:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var CreateShapeHandler = _dereq_(120);
- /**
- * A handler that attaches a label to a given target shape.
- *
- * @param {canvas} Canvas
- */
- function CreateLabelHandler(canvas) {
- CreateShapeHandler.call(this, canvas);
- }
- inherits(CreateLabelHandler, CreateShapeHandler);
- CreateLabelHandler.$inject = [ 'canvas' ];
- module.exports = CreateLabelHandler;
- ////// api /////////////////////////////////////////
- var originalExecute = CreateShapeHandler.prototype.execute;
- /**
- * Appends a label to a target shape.
- *
- * @method CreateLabelHandler#execute
- *
- * @param {Object} context
- * @param {ElementDescriptor} context.target the element the label is attached to
- * @param {ElementDescriptor} context.parent the parent object
- * @param {Point} context.position position of the new element
- */
- CreateLabelHandler.prototype.execute = function(context) {
- this.ensureValidDimensions(context);
- return originalExecute.call(this, context);
- };
- var originalRevert = CreateShapeHandler.prototype.revert;
- /**
- * Undo append by removing the shape
- */
- CreateLabelHandler.prototype.revert = function(context) {
- context.shape.labelTarget = null;
- return originalRevert.call(this, context);
- };
- ////// helpers /////////////////////////////////////////
- CreateLabelHandler.prototype.ensureValidDimensions = function(context) {
- var label = context.shape;
- // make sure a label has valid { width, height } dimensions
- [ 'width', 'height' ].forEach(function(prop) {
- if (typeof label[prop] === 'undefined') {
- label[prop] = 0;
- }
- });
- };
- CreateLabelHandler.prototype.getParent = function(context) {
- return context.parent || context.labelTarget && context.labelTarget.parent;
- };
- CreateLabelHandler.prototype.addElement = function(shape, parent, context) {
- shape.labelTarget = context.labelTarget;
- this._canvas.addShape(shape, parent, true);
- };
- },{"120":120,"207":207}],120:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- /**
- * A handler that implements reversible addition of shapes.
- *
- * @param {canvas} Canvas
- */
- function CreateShapeHandler(canvas, modeling) {
- this._canvas = canvas;
- this._modeling = modeling;
- }
- CreateShapeHandler.$inject = [ 'canvas', 'modeling' ];
- module.exports = CreateShapeHandler;
- ////// api /////////////////////////////////////////
- /**
- * Appends a shape to a target shape
- *
- * @param {Object} context
- * @param {djs.model.Base} context.parent the parent object
- * @param {Point} context.position position of the new element
- */
- CreateShapeHandler.prototype.execute = function(context) {
- var parent = this.getParent(context);
- var shape = context.shape;
- this.setPosition(shape, context);
- this.addElement(shape, parent, context);
- return shape;
- };
- /**
- * Undo append by removing the shape
- */
- CreateShapeHandler.prototype.revert = function(context) {
- this._canvas.removeShape(context.shape);
- };
- CreateShapeHandler.prototype.postExecute = function(context) {
- var modeling = this._modeling;
- var shape = context.shape,
- host = context.host;
- if (!host) {
- return;
- }
- modeling.updateAttachment(shape, host, true);
- };
- ////// helpers /////////////////////////////////////////
- CreateShapeHandler.prototype.getParent = function(context) {
- var parent = context.parent;
- if (!parent) {
- throw new Error('parent required');
- }
- return parent;
- };
- CreateShapeHandler.prototype.getPosition = function(context) {
- if (!context.position) {
- throw new Error('no position given');
- }
- return context.position;
- };
- CreateShapeHandler.prototype.addElement = function(shape, parent) {
- this._canvas.addShape(shape, parent);
- };
- CreateShapeHandler.prototype.setPosition = function(shape, context) {
- var position = this.getPosition(context);
- // update to center position
- // specified in create context
- assign(shape, {
- x: position.x - shape.width / 2,
- y: position.y - shape.height / 2
- });
- };
- },{"339":339}],121:[function(_dereq_,module,exports){
- 'use strict';
- var Collections = _dereq_(184);
- /**
- * A handler that implements reversible deletion of Connections.
- *
- */
- function DeleteConnectionHandler(canvas, modeling) {
- this._canvas = canvas;
- this._modeling = modeling;
- }
- DeleteConnectionHandler.$inject = [ 'canvas', 'modeling' ];
- module.exports = DeleteConnectionHandler;
- /**
- * - Remove attached label
- */
- DeleteConnectionHandler.prototype.preExecute = function(context) {
- var connection = context.connection;
- // Remove label
- if (connection.label) {
- this._modeling.removeShape(connection.label);
- }
- };
- DeleteConnectionHandler.prototype.execute = function(context) {
- var connection = context.connection,
- parent = connection.parent;
- context.parent = parent;
- context.parentIndex = Collections.indexOf(parent.children, connection);
- context.source = connection.source;
- context.target = connection.target;
- this._canvas.removeConnection(connection);
- connection.source = null;
- connection.target = null;
- connection.label = null;
- };
- /**
- * Command revert implementation.
- */
- DeleteConnectionHandler.prototype.revert = function(context) {
- var connection = context.connection,
- parent = context.parent,
- parentIndex = context.parentIndex;
- connection.source = context.source;
- connection.target = context.target;
- // restore previous location in old parent
- Collections.add(parent.children, connection, parentIndex);
- this._canvas.addConnection(connection, parent);
- };
- },{"184":184}],122:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- inherits = _dereq_(207);
- function DeleteElementsHandler(modeling, elementRegistry) {
- this._modeling = modeling;
- this._elementRegistry = elementRegistry;
- }
- inherits(DeleteElementsHandler, _dereq_(128));
- DeleteElementsHandler.$inject = [ 'modeling', 'elementRegistry' ];
- module.exports = DeleteElementsHandler;
- DeleteElementsHandler.prototype.postExecute = function(context) {
- var modeling = this._modeling,
- elementRegistry = this._elementRegistry,
- elements = context.elements;
- forEach(elements, function(element) {
- // element may have been removed with previous
- // remove operations already (e.g. in case of nesting)
- if (!elementRegistry.get(element.id)) {
- return;
- }
- if (element.waypoints) {
- modeling.removeConnection(element);
- } else {
- modeling.removeShape(element);
- }
- });
- };
- },{"128":128,"207":207,"218":218}],123:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var Collections = _dereq_(184);
- var saveClear = _dereq_(195).saveClear;
- /**
- * A handler that implements reversible deletion of shapes.
- *
- */
- function DeleteShapeHandler(canvas, modeling) {
- this._canvas = canvas;
- this._modeling = modeling;
- }
- DeleteShapeHandler.$inject = [ 'canvas', 'modeling' ];
- module.exports = DeleteShapeHandler;
- /**
- * - Remove connections
- * - Remove all direct children
- */
- DeleteShapeHandler.prototype.preExecute = function(context) {
- var modeling = this._modeling;
- var shape = context.shape,
- label = shape.label;
- // Clean up on removeShape(label)
- if (shape.labelTarget) {
- context.labelTarget = shape.labelTarget;
- shape.labelTarget = null;
- }
- // Remove label
- if (label) {
- this._modeling.removeShape(label);
- }
- // remove connections
- saveClear(shape.incoming, function(connection) {
- // To make sure that the connection isn't removed twice
- // For example if a container is removed
- modeling.removeConnection(connection);
- });
- saveClear(shape.outgoing, function(connection) {
- modeling.removeConnection(connection);
- });
- // remove children
- saveClear(shape.children, function(e) {
- modeling.removeShape(e);
- });
- };
- /**
- * Remove shape and remember the parent
- */
- DeleteShapeHandler.prototype.execute = function(context) {
- var canvas = this._canvas;
- var shape = context.shape,
- parent = shape.parent,
- host = shape.host;
- context.parent = parent;
- context.parentIndex = Collections.indexOf(parent.children, shape);
- if (host) {
- context.hostIndex = Collections.indexOf(host.attachers, shape);
- Collections.remove(host && host.attachers, shape);
- }
- shape.label = null;
- canvas.removeShape(shape);
- };
- /**
- * Command revert implementation
- */
- DeleteShapeHandler.prototype.revert = function(context) {
- var canvas = this._canvas;
- var shape = context.shape,
- parent = context.parent,
- parentIndex = context.parentIndex,
- labelTarget = context.labelTarget,
- attachers = shape.attachers,
- host = shape.host;
- // restore previous location in old parent
- Collections.add(parent.children, shape, parentIndex);
- if (host) {
- Collections.add(host && host.attachers, shape, context.hostIndex);
- }
- if (labelTarget) {
- labelTarget.label = shape;
- }
- canvas.addShape(shape, parent);
- if (attachers) {
- forEach(attachers, function(attacher) {
- canvas.addShape(attacher, parent);
- });
- }
- };
- },{"184":184,"195":195,"218":218}],124:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- /**
- * A handler that implements reversible moving of shapes.
- */
- function LayoutConnectionHandler(layouter, canvas) {
- this._layouter = layouter;
- this._canvas = canvas;
- }
- LayoutConnectionHandler.$inject = [ 'layouter', 'canvas' ];
- module.exports = LayoutConnectionHandler;
- LayoutConnectionHandler.prototype.execute = function(context) {
- var connection = context.connection,
- parent = connection.parent,
- connectionSiblings = parent.children;
- var oldIndex = connectionSiblings.indexOf(connection);
- assign(context, {
- oldWaypoints: connection.waypoints,
- oldIndex: oldIndex
- });
- sendToFront(connection);
- connection.waypoints = this._layouter.layoutConnection(connection, context.hints);
- return connection;
- };
- LayoutConnectionHandler.prototype.revert = function(context) {
- var connection = context.connection,
- parent = connection.parent,
- connectionSiblings = parent.children,
- currentIndex = connectionSiblings.indexOf(connection),
- oldIndex = context.oldIndex;
- connection.waypoints = context.oldWaypoints;
- if (oldIndex !== currentIndex) {
- // change position of connection in shape
- connectionSiblings.splice(currentIndex, 1);
- connectionSiblings.splice(oldIndex, 0, connection);
- }
- return connection;
- };
- // connections should have a higher z-order as there source and targets
- function sendToFront(connection) {
- var connectionSiblings = connection.parent.children;
- var connectionIdx = connectionSiblings.indexOf(connection),
- sourceIdx = findIndex(connectionSiblings, connection.source),
- targetIdx = findIndex(connectionSiblings, connection.target),
- // ensure we do not send the connection back
- // if it is already in front
- insertIndex = Math.max(sourceIdx + 1, targetIdx + 1, connectionIdx);
- if (connectionIdx < insertIndex) {
- connectionSiblings.splice(insertIndex, 0, connection); // add to new position
- connectionSiblings.splice(connectionIdx, 1); // remove from old position
- }
- function findIndex(array, obj) {
- var index = array.indexOf(obj);
- if (index < 0 && obj) {
- var parent = obj.parent;
- index = findIndex(array, parent);
- }
- return index;
- }
- return insertIndex;
- }
- },{"339":339}],125:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var Collections = _dereq_(184);
- /**
- * A handler that implements reversible moving of connections.
- *
- * The handler differs from the layout connection handler in a sense
- * that it preserves the connection layout.
- */
- function MoveConnectionHandler() { }
- module.exports = MoveConnectionHandler;
- MoveConnectionHandler.prototype.execute = function(context) {
- var updateAnchors = (context.hints.updateAnchors !== false);
- var connection = context.connection,
- delta = context.delta;
- var newParent = this.getNewParent(connection, context),
- oldParent = connection.parent;
- // save old position + parent in context
- context.oldParent = oldParent;
- context.oldParentIndex = Collections.indexOf(oldParent.children, connection);
- // update waypoint positions
- forEach(connection.waypoints, function(p) {
- p.x += delta.x;
- p.y += delta.y;
- if (updateAnchors && p.original) {
- p.original.x += delta.x;
- p.original.y += delta.y;
- }
- });
- // update parent
- connection.parent = newParent;
- return connection;
- };
- MoveConnectionHandler.prototype.revert = function(context) {
- var updateAnchors = (context.hints.updateAnchors !== false);
- var connection = context.connection,
- oldParent = context.oldParent,
- oldParentIndex = context.oldParentIndex,
- delta = context.delta;
- // restore previous location in old parent
- Collections.add(oldParent.children, connection, oldParentIndex);
- // restore parent
- connection.parent = oldParent;
- // revert to old waypoint positions
- forEach(connection.waypoints, function(p) {
- p.x -= delta.x;
- p.y -= delta.y;
- if (updateAnchors && p.original) {
- p.original.x -= delta.x;
- p.original.y -= delta.y;
- }
- });
- return connection;
- };
- MoveConnectionHandler.prototype.getNewParent = function(connection, context) {
- return context.newParent || connection.parent;
- };
- },{"184":184,"218":218}],126:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- forEach = _dereq_(218);
- var MoveHelper = _dereq_(135),
- Collections = _dereq_(184);
- /**
- * A handler that implements reversible moving of shapes.
- */
- function MoveShapeHandler(modeling) {
- this._modeling = modeling;
- this._helper = new MoveHelper(modeling);
- }
- MoveShapeHandler.$inject = [ 'modeling' ];
- module.exports = MoveShapeHandler;
- MoveShapeHandler.prototype.execute = function(context) {
- var shape = context.shape,
- delta = context.delta,
- newParent = this.getNewParent(context),
- oldParent = shape.parent;
- // save old parent in context
- context.oldParent = oldParent;
- context.oldParentIndex = Collections.indexOf(oldParent.children, shape);
- // update shape parent + position
- assign(shape, {
- parent: newParent,
- x: shape.x + delta.x,
- y: shape.y + delta.y
- });
- return shape;
- };
- MoveShapeHandler.prototype.postExecute = function(context) {
- var shape = context.shape,
- delta = context.delta;
- var modeling = this._modeling;
- if (context.hints.updateAnchors !== false) {
- modeling.updateAnchors(shape, delta);
- }
- if (context.hints.layout !== false) {
- forEach(shape.incoming, function(c) {
- modeling.layoutConnection(c, { endChanged: true });
- });
- forEach(shape.outgoing, function(c) {
- modeling.layoutConnection(c, { startChanged: true });
- });
- }
- if (context.hints.recurse !== false) {
- this.moveChildren(context);
- }
- };
- MoveShapeHandler.prototype.revert = function(context) {
- var shape = context.shape,
- oldParent = context.oldParent,
- oldParentIndex = context.oldParentIndex,
- delta = context.delta;
- // restore previous location in old parent
- Collections.add(oldParent.children, shape, oldParentIndex);
- // revert to old position and parent
- assign(shape, {
- parent: oldParent,
- x: shape.x - delta.x,
- y: shape.y - delta.y
- });
- return shape;
- };
- MoveShapeHandler.prototype.moveChildren = function(context) {
- var delta = context.delta,
- shape = context.shape;
- this._helper.moveRecursive(shape.children, delta, null);
- };
- MoveShapeHandler.prototype.getNewParent = function(context) {
- return context.newParent || context.shape.parent;
- };
- },{"135":135,"184":184,"218":218,"339":339}],127:[function(_dereq_,module,exports){
- 'use strict';
- var MoveHelper = _dereq_(135);
- /**
- * A handler that implements reversible moving of shapes.
- */
- function MoveShapesHandler(modeling) {
- this._helper = new MoveHelper(modeling);
- }
- MoveShapesHandler.$inject = [ 'modeling' ];
- module.exports = MoveShapesHandler;
- MoveShapesHandler.prototype.preExecute = function(context) {
- context.closure = this._helper.getClosure(context.shapes);
- };
- MoveShapesHandler.prototype.postExecute = function(context) {
- this._helper.moveClosure(context.closure, context.delta, context.newParent, context.newHost);
- };
- MoveShapesHandler.prototype.execute = function(context) { };
- MoveShapesHandler.prototype.revert = function(context) { };
- },{"135":135}],128:[function(_dereq_,module,exports){
- 'use strict';
- function NoopHandler() {}
- module.exports = NoopHandler;
- NoopHandler.prototype.execute = function() {};
- NoopHandler.prototype.revert = function() {};
- },{}],129:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330);
- /**
- * Reconnect connection handler
- */
- function ReconnectConnectionHandler() { }
- ReconnectConnectionHandler.$inject = [ ];
- module.exports = ReconnectConnectionHandler;
- ReconnectConnectionHandler.prototype.execute = function(context) {
- var newSource = context.newSource,
- newTarget = context.newTarget,
- connection = context.connection,
- dockingOrPoints = context.dockingOrPoints,
- oldWaypoints = connection.waypoints,
- newWaypoints;
- if (!newSource && !newTarget) {
- throw new Error('newSource or newTarget are required');
- }
- if (newSource && newTarget) {
- throw new Error('must specify either newSource or newTarget');
- }
- context.oldWaypoints = oldWaypoints;
- if (isArray(dockingOrPoints)) {
- newWaypoints = dockingOrPoints;
- } else {
- newWaypoints = oldWaypoints.slice();
- newWaypoints.splice(newSource ? 0 : -1, 1, dockingOrPoints);
- }
- if (newSource) {
- context.oldSource = connection.source;
- connection.source = newSource;
- }
- if (newTarget) {
- context.oldTarget = connection.target;
- connection.target = newTarget;
- }
- connection.waypoints = newWaypoints;
- return connection;
- };
- ReconnectConnectionHandler.prototype.revert = function(context) {
- var newSource = context.newSource,
- newTarget = context.newTarget,
- connection = context.connection;
- if (newSource) {
- connection.source = context.oldSource;
- }
- if (newTarget) {
- connection.target = context.oldTarget;
- }
- connection.waypoints = context.oldWaypoints;
- return connection;
- };
- },{"330":330}],130:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- /**
- * A handler that implements reversible replacing of shapes.
- * Internally the old shape will be removed and the new shape will be added.
- *
- *
- * @class
- * @constructor
- *
- * @param {canvas} Canvas
- */
- function ReplaceShapeHandler(modeling, rules) {
- this._modeling = modeling;
- this._rules = rules;
- }
- ReplaceShapeHandler.$inject = [ 'modeling', 'rules' ];
- module.exports = ReplaceShapeHandler;
- ////// api /////////////////////////////////////////
- /**
- * Replaces a shape with an replacement Element.
- *
- * The newData object should contain type, x, y.
- *
- * If possible also the incoming/outgoing connection
- * will be restored.
- *
- * @param {Object} context
- */
- ReplaceShapeHandler.prototype.preExecute = function(context) {
- var modeling = this._modeling,
- rules = this._rules;
- var oldShape = context.oldShape,
- newData = context.newData,
- newShape;
- // (1) place a new shape at the given position
- var position = {
- x: newData.x,
- y: newData.y
- };
- newShape = context.newShape = context.newShape || modeling.createShape(newData, position, oldShape.parent);
- // (2) update the host
- if (oldShape.host) {
- modeling.updateAttachment(newShape, oldShape.host);
- }
- // (3) adopt all children from the old shape
- modeling.moveShapes(oldShape.children, { x: 0, y: 0 }, newShape);
- // (4) reconnect connections to the new shape (where allowed)
- var incoming = oldShape.incoming.slice(),
- outgoing = oldShape.outgoing.slice();
- forEach(incoming, function(connection) {
- var waypoints = connection.waypoints,
- docking = waypoints[waypoints.length - 1],
- allowed = rules.allowed('connection.reconnectEnd', {
- source: connection.source,
- target: newShape,
- connection: connection
- });
- if (allowed) {
- modeling.reconnectEnd(connection, newShape, docking);
- }
- });
- forEach(outgoing, function(connection) {
- var waypoints = connection.waypoints,
- docking = waypoints[0],
- allowed = rules.allowed('connection.reconnectStart', {
- source: newShape,
- target: connection.target,
- connection: connection
- });
- if (allowed) {
- modeling.reconnectStart(connection, newShape, docking);
- }
- });
- };
- ReplaceShapeHandler.prototype.postExecute = function(context) {
- var modeling = this._modeling;
- var oldShape = context.oldShape;
- modeling.removeShape(oldShape);
- };
- ReplaceShapeHandler.prototype.execute = function(context) {};
- ReplaceShapeHandler.prototype.revert = function(context) {};
- },{"218":218}],131:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- forEach = _dereq_(218);
- /**
- * A handler that implements reversible resizing of shapes.
- *
- */
- function ResizeShapeHandler(modeling) {
- this._modeling = modeling;
- }
- ResizeShapeHandler.$inject = [ 'modeling' ];
- module.exports = ResizeShapeHandler;
- /**
- * {
- * shape: {....}
- * newBounds: {
- * width: 20,
- * height: 40,
- * x: 5,
- * y: 10
- * }
- *
- * }
- */
- ResizeShapeHandler.prototype.execute = function(context) {
- var shape = context.shape,
- newBounds = context.newBounds;
- if (newBounds.x === undefined || newBounds.y === undefined ||
- newBounds.width === undefined || newBounds.height === undefined) {
- throw new Error('newBounds must have {x, y, width, height} properties');
- }
- if (newBounds.width < 10 || newBounds.height < 10) {
- throw new Error('width and height cannot be less than 10px');
- }
- // save old bbox in context
- context.oldBounds = {
- width: shape.width,
- height: shape.height,
- x: shape.x,
- y: shape.y
- };
- // update shape
- assign(shape, {
- width: newBounds.width,
- height: newBounds.height,
- x: newBounds.x,
- y: newBounds.y
- });
- return shape;
- };
- ResizeShapeHandler.prototype.postExecute = function(context) {
- var shape = context.shape;
- var modeling = this._modeling;
- forEach(shape.incoming, function(c) {
- modeling.layoutConnection(c, { endChanged: true });
- });
- forEach(shape.outgoing, function(c) {
- modeling.layoutConnection(c, { startChanged: true });
- });
- };
- ResizeShapeHandler.prototype.revert = function(context) {
- var shape = context.shape,
- oldBounds = context.oldBounds;
- // restore previous bbox
- assign(shape, {
- width: oldBounds.width,
- height: oldBounds.height,
- x: oldBounds.x,
- y: oldBounds.y
- });
- return shape;
- };
- },{"218":218,"339":339}],132:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var SpaceUtil = _dereq_(165);
- /**
- * A handler that implements reversible creating and removing of space.
- *
- * It executes in two phases:
- *
- * (1) resize all affected resizeShapes
- * (2) move all affected moveShapes
- */
- function SpaceToolHandler(modeling) {
- this._modeling = modeling;
- }
- SpaceToolHandler.$inject = [ 'modeling' ];
- module.exports = SpaceToolHandler;
- SpaceToolHandler.prototype.preExecute = function(context) {
- // resize
- var modeling = this._modeling,
- resizingShapes = context.resizingShapes,
- delta = context.delta,
- direction = context.direction;
- forEach(resizingShapes, function(shape) {
- var newBounds = SpaceUtil.resizeBounds(shape, direction, delta);
- modeling.resizeShape(shape, newBounds);
- });
- };
- SpaceToolHandler.prototype.postExecute = function(context) {
- // move
- var modeling = this._modeling,
- movingShapes = context.movingShapes,
- delta = context.delta;
- modeling.moveShapes(movingShapes, delta);
- };
- SpaceToolHandler.prototype.execute = function(context) {};
- SpaceToolHandler.prototype.revert = function(context) {};
- },{"165":165,"218":218}],133:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- assign = _dereq_(339);
- /**
- * Update the anchors of
- */
- function UpdateAnchorsHandler() { }
- module.exports = UpdateAnchorsHandler;
- UpdateAnchorsHandler.prototype.execute = function(context) {
- // update connection anchors
- return this.updateAnchors(context.element, context.delta);
- };
- UpdateAnchorsHandler.prototype.revert = function(context) {
- var delta = context.delta,
- revertedDelta = { x: -1 * delta.x, y: -1 * delta.y };
- // revert update connection anchors
- return this.updateAnchors(context.element, revertedDelta);
- };
- /**
- * Update anchors on the element according to the delta movement.
- *
- * @param {djs.model.Element} element
- * @param {Point} delta
- *
- * @return Array<djs.model.Connection>
- */
- UpdateAnchorsHandler.prototype.updateAnchors = function(element, delta) {
- function add(point, delta) {
- return {
- x: point.x + delta.x,
- y: point.y + delta.y
- };
- }
- function updateAnchor(waypoint) {
- var original = waypoint.original;
- waypoint.original = assign(original || {}, add(original || waypoint, delta));
- }
- var changed = [];
- forEach(element.incoming, function(c) {
- var waypoints = c.waypoints;
- updateAnchor(waypoints[waypoints.length - 1]);
- changed.push(c);
- });
- forEach(element.outgoing, function(c) {
- var waypoints = c.waypoints;
- updateAnchor(waypoints[0]);
- changed.push(c);
- });
- return changed;
- };
- },{"218":218,"339":339}],134:[function(_dereq_,module,exports){
- 'use strict';
- function UpdateWaypointsHandler() { }
- module.exports = UpdateWaypointsHandler;
- UpdateWaypointsHandler.prototype.execute = function(context) {
- var connection = context.connection,
- newWaypoints = context.newWaypoints;
- context.oldWaypoints = connection.waypoints;
- connection.waypoints = newWaypoints;
- return connection;
- };
- UpdateWaypointsHandler.prototype.revert = function(context) {
- var connection = context.connection,
- oldWaypoints = context.oldWaypoints;
- connection.waypoints = oldWaypoints;
- return connection;
- };
- },{}],135:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var Elements = _dereq_(186);
- /**
- * A helper that is able to carry out serialized move operations on multiple elements.
- *
- * @param {Modeling} modeling
- */
- function MoveHelper(modeling) {
- this._modeling = modeling;
- }
- module.exports = MoveHelper;
- /**
- * Move the specified elements and all children by the given delta.
- *
- * This moves all enclosed connections, too and layouts all affected
- * external connections.
- *
- * @param {Array<djs.model.Base>} elements
- * @param {Point} delta
- * @param {djs.model.Base} newParent applied to the first level of shapes
- *
- * @return {Array<djs.model.Base>} list of touched elements
- */
- MoveHelper.prototype.moveRecursive = function(elements, delta, newParent) {
- return this.moveClosure(this.getClosure(elements), delta, newParent);
- };
- /**
- * Move the given closure of elmements.
- *
- * @param {Object} closure
- * @param {Point} delta
- * @param {djs.model.Base} [newParent]
- * @param {djs.model.Base} [newHost]
- */
- MoveHelper.prototype.moveClosure = function(closure, delta, newParent, newHost) {
- var modeling = this._modeling;
- var allShapes = closure.allShapes,
- allConnections = closure.allConnections,
- enclosedConnections = closure.enclosedConnections,
- topLevel = closure.topLevel;
- // move all shapes
- forEach(allShapes, function(s) {
- // move the element according to the given delta
- modeling.moveShape(s, delta, topLevel[s.id] && newParent, {
- recurse: false,
- layout: false
- });
- });
- // move all child connections / layout external connections
- forEach(allConnections, function(c) {
- var startMoved = !!allShapes[c.source.id],
- endMoved = !!allShapes[c.target.id];
- if (enclosedConnections[c.id] && startMoved && endMoved) {
- modeling.moveConnection(c, delta, topLevel[c.id] && newParent, { updateAnchors: false });
- } else {
- modeling.layoutConnection(c, {
- startChanged: startMoved,
- endChanged: endMoved
- });
- }
- });
- };
- /**
- * Returns the closure for the selected elements
- *
- * @param {Array<djs.model.Base>} elements
- * @return {Object} closure
- */
- MoveHelper.prototype.getClosure = function(elements) {
- return Elements.getClosure(elements);
- };
- },{"186":186,"218":218}],136:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(80),
- _dereq_(98),
- _dereq_(155)
- ],
- __init__: [ 'modeling' ],
- modeling: [ 'type', _dereq_(115) ],
- layouter: [ 'type', _dereq_(172) ]
- };
- },{"115":115,"155":155,"172":172,"80":80,"98":98}],137:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- filter = _dereq_(216),
- groupBy = _dereq_(219);
- var LOW_PRIORITY = 500,
- MEDIUM_PRIORITY = 1250,
- HIGH_PRIORITY = 1500;
- var getOriginalEvent = _dereq_(187).getOriginal;
- var round = Math.round;
- function mid(element) {
- return {
- x: element.x + round(element.width / 2),
- y: element.y + round(element.height / 2)
- };
- }
- /**
- * A plugin that makes shapes draggable / droppable.
- *
- * @param {EventBus} eventBus
- * @param {Dragging} dragging
- * @param {Modeling} modeling
- * @param {Selection} selection
- * @param {Rules} rules
- */
- function MoveEvents(eventBus, dragging, modeling, selection, rules) {
- // rules
- function canMove(shapes, delta, position, target) {
- return rules.allowed('shapes.move', {
- shapes: shapes,
- delta: delta,
- position: position,
- target: target
- });
- }
- // move events
- // assign a high priority to this handler to setup the environment
- // others may hook up later, e.g. at default priority and modify
- // the move environment
- //
- eventBus.on('shape.move.start', HIGH_PRIORITY, function(event) {
- var context = event.context,
- shape = event.shape,
- shapes = selection.get().slice();
- // move only single shape if the dragged element
- // is not part of the current selection
- if (shapes.indexOf(shape) === -1) {
- shapes = [ shape ];
- }
- // ensure we remove nested elements in the collection
- // and add attachers for a proper dragger
- shapes = removeNested(shapes);
- // attach shapes to drag context
- assign(context, {
- shapes: shapes,
- shape: shape
- });
- });
- // assign a high priority to this handler to setup the environment
- // others may hook up later, e.g. at default priority and modify
- // the move environment
- //
- eventBus.on('shape.move.start', MEDIUM_PRIORITY, function(event) {
- var context = event.context,
- shapes = context.shapes,
- canExecute;
- canExecute = context.canExecute = canMove(shapes);
- // check if we can move the elements
- if (!canExecute) {
- // suppress move operation
- event.stopPropagation();
- return false;
- }
- });
- // assign a low priority to this handler
- // to let others modify the move event before we update
- // the context
- //
- eventBus.on('shape.move.move', LOW_PRIORITY, function(event) {
- var context = event.context,
- shapes = context.shapes,
- hover = event.hover,
- delta = { x: event.dx, y: event.dy },
- position = { x: event.x, y: event.y },
- canExecute;
- // check if we can move the elements
- canExecute = canMove(shapes, delta, position, hover);
- context.delta = delta;
- context.canExecute = canExecute;
- // simply ignore move over
- if (canExecute === null) {
- context.target = null;
- return;
- }
- context.target = hover;
- });
- eventBus.on('shape.move.end', function(event) {
- var context = event.context;
- var delta = context.delta,
- canExecute = context.canExecute,
- isAttach = canExecute === 'attach';
- if (!canExecute) {
- return false;
- }
- // ensure we have actual pixel values deltas
- // (important when zoom level was > 1 during move)
- delta.x = round(delta.x);
- delta.y = round(delta.y);
- modeling.moveShapes(context.shapes, delta, context.target, isAttach);
- });
- // move activation
- eventBus.on('element.mousedown', function(event) {
- var originalEvent = getOriginalEvent(event);
- if (!originalEvent) {
- throw new Error('must supply DOM mousedown event');
- }
- start(originalEvent, event.element);
- });
- function start(event, element, activate) {
- // do not move connections or the root element
- if (element.waypoints || !element.parent) {
- return;
- }
- var startPosition = mid(element);
- dragging.activate(event, startPosition, 'shape.move', {
- cursor: 'grabbing',
- autoActivate: activate,
- data: {
- shape: element,
- context: {}
- }
- });
- }
- // API
- this.start = start;
- }
- MoveEvents.$inject = [ 'eventBus', 'dragging', 'modeling', 'selection', 'rules' ];
- module.exports = MoveEvents;
- /**
- * Return a filtered list of elements that do not contain
- * those nested into others.
- *
- * @param {Array<djs.model.Base>} elements
- *
- * @return {Array<djs.model.Base>} filtered
- */
- function removeNested(elements) {
- var ids = groupBy(elements, 'id');
- return filter(elements, function(element) {
- while (!!(element = element.parent)) {
- // parent in selection
- if (ids[element.id]) {
- return false;
- }
- }
- return true;
- });
- }
- },{"187":187,"216":216,"219":219,"339":339}],138:[function(_dereq_,module,exports){
- 'use strict';
- var flatten = _dereq_(208),
- forEach = _dereq_(218),
- filter = _dereq_(216),
- find = _dereq_(217),
- map = _dereq_(221);
- var Elements = _dereq_(186);
- var LOW_PRIORITY = 500;
- var MARKER_DRAGGING = 'djs-dragging',
- MARKER_OK = 'drop-ok',
- MARKER_NOT_OK = 'drop-not-ok',
- MARKER_ATTACH = 'attach-ok';
- /**
- * A plugin that makes shapes draggable / droppable.
- *
- * @param {EventBus} eventBus
- * @param {ElementRegistry} elementRegistry
- * @param {Canvas} canvas
- * @param {Styles} styles
- */
- function MoveVisuals(eventBus, elementRegistry, canvas, styles) {
- function getGfx(e) {
- return elementRegistry.getGraphics(e);
- }
- function getVisualDragShapes(shapes) {
- var elements = Elements.selfAndDirectChildren(shapes, true);
- var filteredElements = removeEdges(elements);
- return filteredElements;
- }
- function getAllDraggedElements(shapes) {
- var allShapes = Elements.selfAndAllChildren(shapes, true);
- var allConnections = map(allShapes, function(shape) {
- return (shape.incoming || []).concat(shape.outgoing || []);
- });
- return flatten(allShapes.concat(allConnections), true);
- }
- /** set drop marker on an element */
- function setMarker(element, marker) {
- [ MARKER_ATTACH, MARKER_OK, MARKER_NOT_OK ].forEach(function(m) {
- if (m === marker) {
- canvas.addMarker(element, m);
- } else {
- canvas.removeMarker(element, m);
- }
- });
- }
- /**
- * Add a dragger for the given shape in the specific
- * move context.
- *
- * @param {Object} context
- * @param {djs.model.Base} element
- */
- function addDragger(context, element) {
- var dragGroup = context.dragGroup;
- if (!dragGroup) {
- dragGroup = context.dragGroup =
- canvas.getDefaultLayer()
- .group()
- .attr(styles.cls('djs-drag-group', [ 'no-events' ]));
- }
- var gfx = getGfx(element),
- dragger = gfx.clone(),
- bbox = gfx.getBBox();
- dragger.attr(styles.cls('djs-dragger', [], {
- x: bbox.x,
- y: bbox.y
- }));
- dragGroup.add(dragger);
- }
- function makeDraggable(context, element, addMarker) {
- addDragger(context, element);
- if (addMarker) {
- canvas.addMarker(element, MARKER_DRAGGING);
- }
- if (context.allDraggedElements) {
- context.allDraggedElements.push(element);
- } else {
- context.allDraggedElements = [ element ];
- }
- }
- // expose to other components
- // that plug into the drag behavior
- this.makeDraggable = makeDraggable;
- // assign a low priority to this handler
- // to let others modify the move context before
- // we draw things
- //
- eventBus.on('shape.move.start', LOW_PRIORITY, function(event) {
- var context = event.context,
- dragShapes = context.shapes,
- allDraggedElements = context.allDraggedElements;
- var visuallyDraggedShapes = getVisualDragShapes(dragShapes);
- visuallyDraggedShapes.forEach(function(shape) {
- addDragger(context, shape);
- });
- // cache all dragged elements / gfx
- // so that we can quickly undo their state changes later
- if (!allDraggedElements) {
- allDraggedElements = getAllDraggedElements(dragShapes);
- } else {
- allDraggedElements = flatten(allDraggedElements, getAllDraggedElements(dragShapes));
- }
- // add dragging marker
- forEach(allDraggedElements, function(e) {
- canvas.addMarker(e, MARKER_DRAGGING);
- });
- context.allDraggedElements = allDraggedElements;
- });
- // assign a low priority to this handler
- // to let others modify the move context before
- // we draw things
- //
- eventBus.on('shape.move.move', LOW_PRIORITY, function(event) {
- var context = event.context,
- dragGroup = context.dragGroup,
- target = context.target,
- canExecute = context.canExecute;
- if (target) {
- if (canExecute === 'attach') {
- setMarker(target, MARKER_ATTACH);
- } else {
- setMarker(target, context.canExecute ? MARKER_OK : MARKER_NOT_OK);
- }
- }
- dragGroup.translate(event.dx, event.dy);
- });
- eventBus.on([ 'shape.move.out', 'shape.move.cleanup' ], function(event) {
- var context = event.context,
- target = context.target;
- if (target) {
- setMarker(target, null);
- }
- });
- eventBus.on('shape.move.cleanup', function(event) {
- var context = event.context,
- allDraggedElements = context.allDraggedElements,
- dragGroup = context.dragGroup;
- // remove dragging marker
- forEach(allDraggedElements, function(e) {
- canvas.removeMarker(e, MARKER_DRAGGING);
- });
- if (dragGroup) {
- dragGroup.remove();
- }
- });
- }
- // returns elements minus all connections
- // where source or target is not elements
- function removeEdges(elements) {
- var filteredElements = filter(elements, function(element) {
- if (!element.waypoints) { // shapes
- return true;
- } else { // connections
- var srcFound = find(elements, element.source);
- var targetFound = find(elements, element.target);
- return srcFound && targetFound;
- }
- });
- return filteredElements;
- }
- MoveVisuals.$inject = [ 'eventBus', 'elementRegistry', 'canvas', 'styles' ];
- module.exports = MoveVisuals;
- },{"186":186,"208":208,"216":216,"217":217,"218":218,"221":221}],139:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(108),
- _dereq_(159),
- _dereq_(141),
- _dereq_(155),
- _dereq_(106)
- ],
- __init__: [ 'move', 'moveVisuals' ],
- move: [ 'type', _dereq_(137) ],
- moveVisuals: [ 'type', _dereq_(138) ]
- };
- },{"106":106,"108":108,"137":137,"138":138,"141":141,"155":155,"159":159}],140:[function(_dereq_,module,exports){
- 'use strict';
- var getBBox = _dereq_(186).getBBox;
- /**
- * @class
- *
- * A plugin that adds an outline to shapes and connections that may be activated and styled
- * via CSS classes.
- *
- * @param {EventBus} events the event bus
- */
- function Outline(eventBus, styles, elementRegistry) {
- var OUTLINE_OFFSET = 6;
- var OUTLINE_STYLE = styles.cls('djs-outline', [ 'no-fill' ]);
- function createOutline(gfx, bounds) {
- return gfx.rect(10, 10, 0, 0).attr(OUTLINE_STYLE);
- }
- function updateShapeOutline(outline, bounds) {
- outline.attr({
- x: -OUTLINE_OFFSET,
- y: -OUTLINE_OFFSET,
- width: bounds.width + OUTLINE_OFFSET * 2,
- height: bounds.height + OUTLINE_OFFSET * 2
- });
- }
- function updateConnectionOutline(outline, connection) {
- var bbox = getBBox(connection);
- outline.attr({
- x: bbox.x - OUTLINE_OFFSET,
- y: bbox.y - OUTLINE_OFFSET,
- width: bbox.width + OUTLINE_OFFSET * 2,
- height: bbox.height + OUTLINE_OFFSET * 2
- });
- }
- eventBus.on([ 'shape.added', 'shape.changed' ], function(event) {
- var element = event.element,
- gfx = event.gfx;
- var outline = gfx.select('.djs-outline');
- if (!outline) {
- outline = createOutline(gfx, element);
- }
- updateShapeOutline(outline, element);
- });
- eventBus.on([ 'connection.added', 'connection.changed' ], function(event) {
- var element = event.element,
- gfx = event.gfx;
- var outline = gfx.select('.djs-outline');
- if (!outline) {
- outline = createOutline(gfx, element);
- }
- updateConnectionOutline(outline, element);
- });
- }
- Outline.$inject = ['eventBus', 'styles', 'elementRegistry'];
- module.exports = Outline;
- },{"186":186}],141:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- __init__: [ 'outline' ],
- outline: [ 'type', _dereq_(140) ]
- };
- },{"140":140}],142:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- isString = _dereq_(336),
- isObject = _dereq_(334),
- assign = _dereq_(339),
- forEach = _dereq_(218),
- filter = _dereq_(216),
- debounce = _dereq_(228);
- var domify = _dereq_(356),
- domClasses = _dereq_(352),
- domRemove = _dereq_(360);
- var getBBox = _dereq_(186).getBBox;
- // document wide unique overlay ids
- var ids = new (_dereq_(190))('ov');
- function createRoot(parent) {
- var root = domify('<div class="djs-overlay-container" style="position: absolute; width: 0; height: 0;" />');
- parent.insertBefore(root, parent.firstChild);
- return root;
- }
- function setPosition(el, x, y) {
- assign(el.style, { left: x + 'px', top: y + 'px' });
- }
- function setVisible(el, visible) {
- el.style.display = visible === false ? 'none' : '';
- }
- /**
- * A service that allows users to attach overlays to diagram elements.
- *
- * The overlay service will take care of overlay positioning during updates.
- *
- * @example
- *
- * // add a pink badge on the top left of the shape
- * overlays.add(someShape, {
- * position: {
- * top: -5,
- * left: -5
- * },
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
- * });
- *
- * // or add via shape id
- *
- * overlays.add('some-element-id', {
- * position: {
- * top: -5,
- * left: -5
- * }
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
- * });
- *
- * // or add with optional type
- *
- * overlays.add(someShape, 'badge', {
- * position: {
- * top: -5,
- * left: -5
- * }
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
- * });
- *
- *
- * // remove an overlay
- *
- * var id = overlays.add(...);
- * overlays.remove(id);
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- * @param {ElementRegistry} elementRegistry
- */
- function Overlays(config, eventBus, canvas, elementRegistry) {
- this._eventBus = eventBus;
- this._canvas = canvas;
- this._elementRegistry = elementRegistry;
- this._ids = ids;
- this._overlayDefaults = {
- show: {
- minZoom: 0.7,
- maxZoom: 5.0
- }
- };
- /**
- * Mapping overlayId -> overlay
- */
- this._overlays = {};
- /**
- * Mapping elementId -> overlay container
- */
- this._overlayContainers = {};
- // root html element for all overlays
- this._overlayRoot = createRoot(canvas.getContainer());
- this._init(config);
- }
- Overlays.$inject = [ 'config.overlays', 'eventBus', 'canvas', 'elementRegistry' ];
- module.exports = Overlays;
- /**
- * Returns the overlay with the specified id or a list of overlays
- * for an element with a given type.
- *
- * @example
- *
- * // return the single overlay with the given id
- * overlays.get('some-id');
- *
- * // return all overlays for the shape
- * overlays.get({ element: someShape });
- *
- * // return all overlays on shape with type 'badge'
- * overlays.get({ element: someShape, type: 'badge' });
- *
- * // shape can also be specified as id
- * overlays.get({ element: 'element-id', type: 'badge' });
- *
- *
- * @param {Object} search
- * @param {String} [search.id]
- * @param {String|djs.model.Base} [search.element]
- * @param {String} [search.type]
- *
- * @return {Object|Array<Object>} the overlay(s)
- */
- Overlays.prototype.get = function(search) {
- if (isString(search)) {
- search = { id: search };
- }
- if (search.element) {
- var container = this._getOverlayContainer(search.element, true);
- // return a list of overlays when searching by element (+type)
- if (container) {
- return search.type ? filter(container.overlays, { type: search.type }) : container.overlays.slice();
- } else {
- return [];
- }
- } else
- if (search.type) {
- return filter(this._overlays, { type: search.type });
- } else {
- // return single element when searching by id
- return search.id ? this._overlays[search.id] : null;
- }
- };
- /**
- * Adds a HTML overlay to an element.
- *
- * @param {String|djs.model.Base} element attach overlay to this shape
- * @param {String} [type] optional type to assign to the overlay
- * @param {Object} overlay the overlay configuration
- *
- * @param {String|DOMElement} overlay.html html element to use as an overlay
- * @param {Object} [overlay.show] show configuration
- * @param {Number} [overlay.show.minZoom] minimal zoom level to show the overlay
- * @param {Number} [overlay.show.maxZoom] maximum zoom level to show the overlay
- * @param {Object} overlay.position where to attach the overlay
- * @param {Number} [overlay.position.left] relative to element bbox left attachment
- * @param {Number} [overlay.position.top] relative to element bbox top attachment
- * @param {Number} [overlay.position.bottom] relative to element bbox bottom attachment
- * @param {Number} [overlay.position.right] relative to element bbox right attachment
- *
- * @return {String} id that may be used to reference the overlay for update or removal
- */
- Overlays.prototype.add = function(element, type, overlay) {
- if (isObject(type)) {
- overlay = type;
- type = null;
- }
- if (!element.id) {
- element = this._elementRegistry.get(element);
- }
- if (!overlay.position) {
- throw new Error('must specifiy overlay position');
- }
- if (!overlay.html) {
- throw new Error('must specifiy overlay html');
- }
- if (!element) {
- throw new Error('invalid element specified');
- }
- var id = this._ids.next();
- overlay = assign({}, this._overlayDefaults, overlay, {
- id: id,
- type: type,
- element: element,
- html: overlay.html
- });
- this._addOverlay(overlay);
- return id;
- };
- /**
- * Remove an overlay with the given id or all overlays matching the given filter.
- *
- * @see Overlays#get for filter options.
- *
- * @param {String} [id]
- * @param {Object} [filter]
- */
- Overlays.prototype.remove = function(filter) {
- var overlays = this.get(filter) || [];
- if (!isArray(overlays)) {
- overlays = [ overlays ];
- }
- var self = this;
- forEach(overlays, function(overlay) {
- var container = self._getOverlayContainer(overlay.element, true);
- if (overlay) {
- domRemove(overlay.html);
- domRemove(overlay.htmlContainer);
- delete overlay.htmlContainer;
- delete overlay.element;
- delete self._overlays[overlay.id];
- }
- if (container) {
- var idx = container.overlays.indexOf(overlay);
- if (idx !== -1) {
- container.overlays.splice(idx, 1);
- }
- }
- });
- };
- Overlays.prototype.show = function() {
- setVisible(this._overlayRoot);
- };
- Overlays.prototype.hide = function() {
- setVisible(this._overlayRoot, false);
- };
- Overlays.prototype._updateOverlayContainer = function(container) {
- var element = container.element,
- html = container.html;
- // update container left,top according to the elements x,y coordinates
- // this ensures we can attach child elements relative to this container
- var x = element.x,
- y = element.y;
- if (element.waypoints) {
- var bbox = getBBox(element);
- x = bbox.x;
- y = bbox.y;
- }
- setPosition(html, x, y);
- };
- Overlays.prototype._updateOverlay = function(overlay) {
- var position = overlay.position,
- htmlContainer = overlay.htmlContainer,
- element = overlay.element;
- // update overlay html relative to shape because
- // it is already positioned on the element
- // update relative
- var left = position.left,
- top = position.top;
- if (position.right !== undefined) {
- var width;
- if (element.waypoints) {
- width = getBBox(element).width;
- } else {
- width = element.width;
- }
- left = position.right * -1 + width;
- }
- if (position.bottom !== undefined) {
- var height;
- if (element.waypoints) {
- height = getBBox(element).height;
- } else {
- height = element.height;
- }
- top = position.bottom * -1 + height;
- }
- setPosition(htmlContainer, left || 0, top || 0);
- };
- Overlays.prototype._createOverlayContainer = function(element) {
- var html = domify('<div class="djs-overlays djs-overlays-' + element.id + '" style="position: absolute" />');
- this._overlayRoot.appendChild(html);
- var container = {
- html: html,
- element: element,
- overlays: []
- };
- this._updateOverlayContainer(container);
- return container;
- };
- Overlays.prototype._updateRoot = function(viewbox) {
- var a = viewbox.scale || 1;
- var d = viewbox.scale || 1;
- var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
- this._overlayRoot.style.transform = matrix;
- this._overlayRoot.style['-ms-transform'] = matrix;
- };
- Overlays.prototype._getOverlayContainer = function(element, raw) {
- var id = (element && element.id) || element;
- var container = this._overlayContainers[id];
- if (!container && !raw) {
- container = this._overlayContainers[id] = this._createOverlayContainer(element);
- }
- return container;
- };
- Overlays.prototype._addOverlay = function(overlay) {
- var id = overlay.id,
- element = overlay.element,
- html = overlay.html,
- htmlContainer,
- overlayContainer;
- // unwrap jquery (for those who need it)
- if (html.get) {
- html = html.get(0);
- }
- // create proper html elements from
- // overlay HTML strings
- if (isString(html)) {
- html = domify(html);
- }
- overlayContainer = this._getOverlayContainer(element);
- htmlContainer = domify('<div class="djs-overlay" data-overlay-id="' + id + '" style="position: absolute">');
- htmlContainer.appendChild(html);
- if (overlay.type) {
- domClasses(htmlContainer).add('djs-overlay-' + overlay.type);
- }
- overlay.htmlContainer = htmlContainer;
- overlayContainer.overlays.push(overlay);
- overlayContainer.html.appendChild(htmlContainer);
- this._overlays[id] = overlay;
- this._updateOverlay(overlay);
- };
- Overlays.prototype._updateOverlayVisibilty = function(viewbox) {
- forEach(this._overlays, function(overlay) {
- var show = overlay.show,
- htmlContainer = overlay.htmlContainer,
- visible = true;
- if (show) {
- if (show.minZoom > viewbox.scale ||
- show.maxZoom < viewbox.scale) {
- visible = false;
- }
- setVisible(htmlContainer, visible);
- }
- });
- };
- Overlays.prototype._init = function(config) {
- var eventBus = this._eventBus;
- var self = this;
- // scroll/zoom integration
- var updateViewbox = function(viewbox) {
- self._updateRoot(viewbox);
- self._updateOverlayVisibilty(viewbox);
- self.show();
- };
- if (!config || config.deferUpdate !== false) {
- updateViewbox = debounce(updateViewbox, 300);
- }
- eventBus.on('canvas.viewbox.changed', function(event) {
- self.hide();
- updateViewbox(event.viewbox);
- });
- // remove integration
- eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
- var overlays = self.get({ element: e.element });
- forEach(overlays, function(o) {
- self.remove(o.id);
- });
- });
- // move integration
- eventBus.on([
- 'element.changed'
- ], function(e) {
- var element = e.element;
- var container = self._getOverlayContainer(element, true);
- if (container) {
- forEach(container.overlays, function(overlay) {
- self._updateOverlay(overlay);
- });
- self._updateOverlayContainer(container);
- }
- });
- // marker integration, simply add them on the overlays as classes, too.
- eventBus.on('element.marker.update', function(e) {
- var container = self._getOverlayContainer(e.element, true);
- if (container) {
- domClasses(container.html)[e.add ? 'add' : 'remove'](e.marker);
- }
- });
- };
- },{"186":186,"190":190,"216":216,"218":218,"228":228,"330":330,"334":334,"336":336,"339":339,"352":352,"356":356,"360":360}],143:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'overlays' ],
- overlays: [ 'type', _dereq_(142) ]
- };
- },{"142":142}],144:[function(_dereq_,module,exports){
- 'use strict';
- var isFunction = _dereq_(331),
- forEach = _dereq_(218);
- var domify = _dereq_(356),
- domQuery = _dereq_(359),
- domAttr = _dereq_(351),
- domClear = _dereq_(353),
- domClasses = _dereq_(352),
- domMatches = _dereq_(358),
- domDelegate = _dereq_(355),
- domEvent = _dereq_(357);
- var toggleSelector = '.djs-palette-toggle',
- entrySelector = '.entry',
- elementSelector = toggleSelector + ', ' + entrySelector;
- /**
- * A palette containing modeling elements.
- */
- function Palette(eventBus, canvas) {
- this._eventBus = eventBus;
- this._canvas = canvas;
- this._providers = [];
- }
- Palette.$inject = [ 'eventBus', 'canvas' ];
- module.exports = Palette;
- /**
- * Register a provider with the palette
- *
- * @param {PaletteProvider} provider
- */
- Palette.prototype.registerProvider = function(provider) {
- this._providers.push(provider);
- if (!this._container) {
- this._init();
- }
- this._update();
- };
- /**
- * Returns the palette entries for a given element
- *
- * @return {Array<PaletteEntryDescriptor>} list of entries
- */
- Palette.prototype.getEntries = function() {
- var entries = {};
- // loop through all providers and their entries.
- // group entries by id so that overriding an entry is possible
- forEach(this._providers, function(provider) {
- var e = provider.getPaletteEntries();
- forEach(e, function(entry, id) {
- entries[id] = entry;
- });
- });
- return entries;
- };
- /**
- * Initialize
- */
- Palette.prototype._init = function() {
- var parent = this._canvas.getContainer(),
- container = this._container = domify(Palette.HTML_MARKUP),
- self = this;
- parent.appendChild(container);
- domDelegate.bind(container, elementSelector, 'click', function(event) {
- var target = event.delegateTarget;
- if (domMatches(target, toggleSelector)) {
- return self.toggle();
- }
- self.trigger('click', event);
- });
- // prevent drag propagation
- domEvent.bind(container, 'mousedown', function(event) {
- event.stopPropagation();
- });
- // prevent drag propagation
- domDelegate.bind(container, entrySelector, 'dragstart', function(event) {
- self.trigger('dragstart', event);
- });
- this._eventBus.fire('palette.create', {
- html: container
- });
- };
- Palette.prototype._update = function() {
- var entriesContainer = domQuery('.djs-palette-entries', this._container),
- entries = this._entries = this.getEntries();
- domClear(entriesContainer);
- forEach(entries, function(entry, id) {
- var grouping = entry.group || 'default';
- var container = domQuery('[data-group=' + grouping + ']', entriesContainer);
- if (!container) {
- container = domify('<div class="group" data-group="' + grouping + '"></div>');
- entriesContainer.appendChild(container);
- }
- var html = entry.html || (
- entry.separator ?
- '<hr class="separator" />' :
- '<div class="entry" draggable="true"></div>');
- var control = domify(html);
- container.appendChild(control);
- if (!entry.separator) {
- domAttr(control, 'data-action', id);
- if (entry.title) {
- domAttr(control, 'title', entry.title);
- }
- if (entry.className) {
- domClasses(control).add(entry.className);
- }
- if (entry.imageUrl) {
- control.appendChild(domify('<img src="' + entry.imageUrl + '">'));
- }
- }
- });
- // open after update
- this.open(true);
- };
- /**
- * Trigger an action available on the palette
- *
- * @param {String} action
- * @param {Event} event
- */
- Palette.prototype.trigger = function(action, event, autoActivate) {
- var entries = this._entries,
- entry,
- handler,
- originalEvent,
- button = event.delegateTarget || event.target;
- if (!button) {
- return event.preventDefault();
- }
- entry = entries[domAttr(button, 'data-action')];
- handler = entry.action;
- originalEvent = event.originalEvent || event;
- // simple action (via callback function)
- if (isFunction(handler)) {
- if (action === 'click') {
- return handler(originalEvent, autoActivate);
- }
- } else {
- if (handler[action]) {
- return handler[action](originalEvent, autoActivate);
- }
- }
- // silence other actions
- event.preventDefault();
- };
- /**
- * Close the palette
- */
- Palette.prototype.close = function() {
- domClasses(this._container).remove('open');
- };
- /**
- * Open the palette
- */
- Palette.prototype.open = function() {
- domClasses(this._container).add('open');
- };
- Palette.prototype.toggle = function(open) {
- if (this.isOpen()) {
- this.close();
- } else {
- this.open();
- }
- };
- /**
- * Return true if the palette is opened.
- *
- * @example
- *
- * palette.open();
- *
- * if (palette.isOpen()) {
- * // yes, we are open
- * }
- *
- * @return {boolean} true if palette is opened
- */
- Palette.prototype.isOpen = function() {
- return this._container && domClasses(this._container).has('open');
- };
- /* markup definition */
- Palette.HTML_MARKUP =
- '<div class="djs-palette">' +
- '<div class="djs-palette-entries"></div>' +
- '<div class="djs-palette-toggle"></div>' +
- '</div>';
- },{"218":218,"331":331,"351":351,"352":352,"353":353,"355":355,"356":356,"357":357,"358":358,"359":359}],145:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'palette' ],
- palette: [ 'type', _dereq_(144) ]
- };
- },{"144":144}],146:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- assign = _dereq_(339),
- find = _dereq_(217);
- var domDelegate = _dereq_(355),
- domify = _dereq_(356),
- domClasses = _dereq_(352),
- domAttr = _dereq_(351),
- domRemove = _dereq_(360);
- var DATA_REF = 'data-id';
- /**
- * A popup menu that can be used to display a list of actions anywhere in the canvas.
- *
- * {@link PopupMenu#open} is used to create and open the popup menu.
- * With {@link PopupMenu#update} it is possible to update certain entries in the popup menu
- * (see examples below).
- *
- * @example
- *
- * // create a basic popup menu
- * popupMenu.open(
- * {
- * position: { x: 100, y: 100 },
- * entries: [
- * {
- * id: 'entry-1',
- * label: 'Entry 1',
- * action: function(event, entry) {
- * // do some stuff
- * }
- * },
- * {
- * id: 'entry-2',
- * label: 'Entry 2'
- * }
- * ]
- * }
- * );
- *
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- *
- * @class
- * @constructor
- */
- function PopupMenu(eventBus, canvas, modeling) {
- this._eventBus = eventBus;
- this._canvas = canvas;
- this._modeling = modeling;
- }
- PopupMenu.$inject = [ 'eventBus', 'canvas', 'modeling' ];
- /**
- * Creates the popup menu, adds entries and attaches it to the DOM.
- *
- * @param {Object} menu
- * @param {Object} menu.position
- * @param {String} [menu.className] a custom HTML class name for the popup menu
- *
- * @param {Array.<Object>} menu.entries
- * @param {String} menu.entries[].id
- * @param {String} menu.entries[].label
- * @param {String} [menu.entries[].className] a custom HTML class name for the entry div element
- * @param {Object} [menu.entries[].action] a handler function that will be called on a click on the entry
- *
- * @param {Array.<Object>} [menu.headerEntries]
- * @param {String} menu.headerEntries[].id
- * @param {String} [menu.headerEntries[].label]
- * @param {String} [menu.headerEntries[].imageUrl]
- * @param {String} [menu.headerEntries[].className] a custom HTML class name for the entry div element
- * @param {Object} [menu.headerEntries[].action] a handler function that will be called on a click on the entry
- *
- * @return {PopupMenu}
- */
- PopupMenu.prototype.open = function(menu) {
- var className = menu.className || 'popup-menu',
- position = menu.position,
- entries = menu.entries,
- headerEntries = menu.headerEntries;
- if (!position) {
- throw new Error('the position argument is missing');
- }
- if (!entries) {
- throw new Error('the entries argument is missing');
- }
- // make sure, only one popup menu is open at a time
- if (this.isOpen()) {
- this.close();
- }
- var canvas = this._canvas,
- parent = canvas.getContainer(),
- container = this._createContainer(className, position);
- if (headerEntries) {
- var headerEntriesContainer = this._createEntries(headerEntries, 'djs-popup-header');
- container.appendChild(headerEntriesContainer);
- }
- var entriesContainer = this._createEntries(entries, 'djs-popup-body');
- container.appendChild(entriesContainer);
- this._attachContainer(container, parent);
- this._current = {
- container: container,
- menu: menu
- };
- return this;
- };
- /**
- * Removes the popup menu and unbinds the event handlers.
- */
- PopupMenu.prototype.close = function() {
- if (!this.isOpen()) {
- return;
- }
- this._unbindHandlers();
- domRemove(this._current.container);
- this._current = null;
- };
- /**
- * Determines, if an open popup menu exist.
- * @return {Boolean}
- */
- PopupMenu.prototype.isOpen = function() {
- return !!this._current;
- };
- /**
- * Trigger an action associated with an entry.
- *
- * @param {Object} event
- */
- PopupMenu.prototype.trigger = function(event) {
- // silence other actions
- event.preventDefault();
- var element = event.delegateTarget || event.target,
- entryId = domAttr(element, DATA_REF);
- var entry = this._getEntry(entryId);
- if (entry.action) {
- var result = entry.action.call(null, event, entry);
- this.close();
- return result;
- }
- };
- /**
- * Gets an entry instance (either entry or headerEntry) by id.
- *
- * @param {String} entryId
- *
- * @return {Object} entry instance
- */
- PopupMenu.prototype._getEntry = function(entryId) {
- var menu = this._current.menu,
- search = { id: entryId };
- var entry = find(menu.entries, search) || find(menu.headerEntries, search);
- if (!entry) {
- throw new Error('entry not found');
- }
- return entry;
- };
- /**
- * Creates the popup menu container.
- *
- * @param {String} event
- * @param {Object} position
- */
- PopupMenu.prototype._createContainer = function(className, position) {
- var container = domify('<div class="djs-popup">');
- assign(container.style, {
- position: 'absolute',
- left: position.x + 'px',
- top: position.y + 'px'
- });
- domClasses(container).add(className);
- return container;
- };
- /**
- * Attaches the container to the DOM and binds the event handlers.
- *
- * @param {Object} container
- * @param {Object} parent
- */
- PopupMenu.prototype._attachContainer = function(container, parent) {
- var self = this;
- // Event handler
- domDelegate.bind(container, '.entry' ,'click', function(event) {
- self.trigger(event);
- });
- // apply canvas zoom level
- var zoom = this._canvas.zoom();
- container.style.transformOrigin = 'top left';
- container.style.transform = 'scale(' + zoom + ')';
- // Attach to DOM
- parent.appendChild(container);
- // Add Handler
- this._bindHandlers();
- };
- /**
- * Creates and attaches entries to the popup menu.
- *
- * @param {Array<Object>} entries an array of entry objects
- * @param {Object} container the parent DOM container
- * @param {String} className the class name of the entry container
- */
- PopupMenu.prototype._createEntries = function(entries, className) {
- var entriesContainer = domify('<div>'),
- self = this;
- domClasses(entriesContainer).add(className);
- forEach(entries, function(entry) {
- var entryContainer = self._createEntry(entry, entriesContainer);
- entriesContainer.appendChild(entryContainer);
- });
- return entriesContainer;
- };
- /**
- * Creates a single entry and attaches it to the specified DOM container.
- *
- * @param {Object} entry
- * @param {Object} container
- */
- PopupMenu.prototype._createEntry = function(entry) {
- if (!entry.id) {
- throw new Error ('every entry must have the id property set');
- }
- var entryContainer = domify('<div>'),
- entryClasses = domClasses(entryContainer);
- entryClasses.add('entry');
- if (entry.className) {
- entryClasses.add(entry.className);
- }
- domAttr(entryContainer, DATA_REF, entry.id);
- if (entry.label) {
- var label = domify('<span>');
- label.textContent = entry.label;
- entryContainer.appendChild(label);
- }
- if (entry.imageUrl) {
- entryContainer.appendChild(domify('<img src="' + entry.imageUrl + '" />'));
- }
- if (entry.active === true) {
- entryClasses.add('active');
- }
- if (entry.disabled === true) {
- entryClasses.add('disabled');
- }
- return entryContainer;
- };
- /**
- * Binds the `close` method to 'contextPad.close' & 'canvas.viewbox.changed'.
- */
- PopupMenu.prototype._bindHandlers = function() {
- var eventBus = this._eventBus,
- self = this;
- function close() {
- self.close();
- }
- eventBus.once('contextPad.close', close);
- eventBus.once('canvas.viewbox.changed', close);
- eventBus.once('commandStack.changed', close);
- };
- /**
- * Unbinds the `close` method to 'contextPad.close' & 'canvas.viewbox.changed'.
- */
- PopupMenu.prototype._unbindHandlers = function() {
- var eventBus = this._eventBus,
- self = this;
- function close() {
- self.close();
- }
- eventBus.off('contextPad.close', close);
- eventBus.off('canvas.viewbox.changed', close);
- eventBus.off('commandStack.changed', close);
- };
- module.exports = PopupMenu;
- },{"217":217,"218":218,"339":339,"351":351,"352":352,"355":355,"356":356,"360":360}],147:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- __init__: [ 'popupMenu' ],
- popupMenu: [ 'type', _dereq_(146) ]
- };
- },{"146":146}],148:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Service that allow replacing of elements.
- *
- *
- * @class
- * @constructor
- */
- function Replace(modeling) {
- this._modeling = modeling;
- }
- module.exports = Replace;
- Replace.$inject = [ 'modeling' ];
- /**
- * @param {Element} oldElement - Element to be replaced
- * @param {Object} newElementData - Containing information about the new Element, for example height, width, type.
- * @param {Object} options - Custom options that will be attached to the context. It can be used to inject data
- * that is needed in the command chain. For example it could be used in
- * eventbus.on('commandStack.shape.replace.postExecute') to change shape attributes after
- * shape creation.
- */
- Replace.prototype.replaceElement = function(oldElement, newElementData, options) {
- var modeling = this._modeling;
- var newElement = null;
- if (oldElement.waypoints) {
- // TODO
- // modeling.replaceConnection
- } else {
- // set center of element for modeling API
- // if no new width / height is given use old elements size
- newElementData.x = oldElement.x + (newElementData.width || oldElement.width) / 2;
- newElementData.y = oldElement.y + (newElementData.height || oldElement.height) / 2;
- newElement = modeling.replaceShape(oldElement, newElementData, options);
- }
- return newElement;
- };
- },{}],149:[function(_dereq_,module,exports){
- 'use strict';
- module.exports = {
- __init__: [ 'replace' ],
- replace: [ 'type', _dereq_(148) ]
- };
- },{"148":148}],150:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- filter = _dereq_(216),
- pick = _dereq_(345),
- assign = _dereq_(339);
- var ResizeUtil = _dereq_(151),
- domEvent = _dereq_(357),
- Elements = _dereq_(186);
- var isPrimaryButton = _dereq_(193).isPrimaryButton;
- var round = Math.round;
- var Snap = _dereq_(200);
- var HANDLE_OFFSET = -2,
- HANDLE_SIZE = 5,
- HANDLE_HIT_SIZE = 20;
- var MARKER_RESIZING = 'djs-resizing',
- MARKER_RESIZE_NOT_OK = 'resize-not-ok',
- CLS_RESIZER = 'djs-resizer';
- var DEFAULT_MIN_WIDTH = 10;
- var DEFAULT_CHILD_BOX_PADDING = 20;
- /**
- * A component that provides resizing of shapes on the canvas.
- *
- * The following components are part of shape resize:
- *
- * * adding resize handles,
- * * creating a visual during resize
- * * checking resize rules
- * * committing a change once finished
- *
- *
- * ## Customizing
- *
- * It's possible to customize the resizing behaviour by intercepting 'resize.start'
- * and providing the following parameters through the 'context':
- *
- * * minDimensions ({ width, height }): minimum shape dimensions
- *
- * * childrenBoxPadding ({ left, top, bottom, right } || number):
- * gap between the minimum bounding box and the container
- *
- * f.ex:
- *
- * ```javascript
- * eventBus.on('resize.start', 1500, function(event) {
- * var context = event.context,
- *
- * context.minDimensions = { width: 140, height: 120 };
- *
- * // Passing general padding
- * context.childrenBoxPadding = 30;
- *
- * // Passing padding to a specific side
- * context.childrenBoxPadding.left = 20;
- * });
- * ```
- */
- function Resize(eventBus, elementRegistry, rules, modeling, canvas, selection, dragging) {
- function canResize(context) {
- var ctx = pick(context, [ 'newBounds', 'shape', 'delta', 'direction' ]);
- return rules.allowed('shape.resize', ctx);
- }
- // resizing implementation //////////////////////////////////
- /**
- * A helper that realizes the resize visuals
- */
- var visuals = {
- create: function(context) {
- var container = canvas.getDefaultLayer(),
- shape = context.shape,
- frame;
- frame = context.frame = Snap.create('rect', {
- class: 'djs-resize-overlay',
- width: shape.width + 10,
- height: shape.height + 10,
- x: shape.x -5,
- y: shape.y -5
- });
- frame.appendTo(container);
- },
- update: function(context) {
- var frame = context.frame,
- bounds = context.newBounds;
- if (bounds.width > 5) {
- frame.attr({
- x: bounds.x,
- width: bounds.width
- });
- }
- if (bounds.height > 5) {
- frame.attr({
- y: bounds.y,
- height: bounds.height
- });
- }
- frame[context.canExecute ? 'removeClass' : 'addClass'](MARKER_RESIZE_NOT_OK);
- },
- remove: function(context) {
- if (context.frame) {
- context.frame.remove();
- }
- }
- };
- /**
- * is the given element part of the
- * resize targets min boundary box
- *
- * @param {djs.model.Base} element
- */
- function isBBoxChild(element) {
- // exclude connections
- if (element.waypoints) {
- return false;
- }
- // labels
- if (element.type === 'label') {
- return false;
- }
- return true;
- }
- function addPadding(bbox, padding) {
- var left, right, top, bottom;
- if (typeof padding === 'object') {
- left = padding.left || DEFAULT_CHILD_BOX_PADDING;
- right = padding.right || DEFAULT_CHILD_BOX_PADDING;
- top = padding.top || DEFAULT_CHILD_BOX_PADDING;
- bottom = padding.bottom || DEFAULT_CHILD_BOX_PADDING;
- } else {
- left = right = top = bottom = padding || DEFAULT_CHILD_BOX_PADDING;
- }
- return {
- x: bbox.x - left,
- y: bbox.y - top,
- width: bbox.width + left + right,
- height: bbox.height + top + bottom
- };
- }
- function computeChildrenBBox(shape, padding) {
- // grab all the children that are part of the
- // parents children box
- var children = filter(shape.children, isBBoxChild);
- if (children.length) {
- return addPadding(Elements.getBBox(children), padding);
- }
- }
- function computeMinResizeBox(context) {
- var shape = context.shape,
- direction = context.direction,
- childrenBounds;
- // get children bounds
- childrenBounds = computeChildrenBBox(shape, context.childrenBoxPadding);
- // get correct minimum bounds from given resize direction
- // basically ensures that the minBounds is max(childrenBounds, minDimensions)
- return ResizeUtil.getMinResizeBounds(direction, shape, context.minDimensions || {
- width: DEFAULT_MIN_WIDTH,
- height: DEFAULT_MIN_WIDTH
- }, childrenBounds);
- }
- eventBus.on('resize.start', function(event) {
- var context = event.context,
- shape = context.shape,
- minBounds = context.minBounds;
- if (minBounds === undefined) {
- context.minBounds = computeMinResizeBox(context);
- }
- // add resizable indicator
- canvas.addMarker(shape, MARKER_RESIZING);
- visuals.create(context);
- });
- eventBus.on('resize.move', function(event) {
- var context = event.context,
- shape = context.shape,
- direction = context.direction,
- minBounds = context.minBounds,
- delta;
- delta = {
- x: event.dx,
- y: event.dy
- };
- context.delta = delta;
- context.newBounds = ResizeUtil.resizeBounds(shape, direction, delta);
- if (minBounds) {
- context.newBounds = ResizeUtil.ensureMinBounds(context.newBounds, minBounds);
- }
- // update + cache executable state
- context.canExecute = canResize(context);
- // update resize frame visuals
- visuals.update(context);
- });
- eventBus.on('resize.end', function(event) {
- var context = event.context,
- shape = context.shape;
- var newBounds = context.newBounds;
- // ensure we have actual pixel values for new bounds
- // (important when zoom level was > 1 during move)
- newBounds.x = round(newBounds.x);
- newBounds.y = round(newBounds.y);
- newBounds.width = round(newBounds.width);
- newBounds.height = round(newBounds.height);
- // perform the actual resize
- if (context.canExecute) {
- modeling.resizeShape(shape, context.newBounds);
- }
- });
- eventBus.on('resize.cleanup', function(event) {
- var context = event.context,
- shape = context.shape;
- // remove resizable indicator
- canvas.removeMarker(shape, MARKER_RESIZING);
- // remove frame + destroy context
- visuals.remove(context);
- });
- /**
- * Activate a resize operation
- *
- * You may specify additional contextual information and must specify a
- * resize direction during activation of the resize event.
- *
- * @param {MouseEvent} event
- * @param {djs.model.Shape} shape
- * @param {Object|String} contextOrDirection
- */
- function activate(event, shape, contextOrDirection) {
- var context,
- direction;
- if (typeof contextOrDirection === 'string') {
- contextOrDirection = {
- direction: contextOrDirection
- };
- }
- context = assign({ shape: shape }, contextOrDirection);
- direction = context.direction;
- if (!direction) {
- throw new Error('must provide a direction (nw|se|ne|sw)');
- }
- dragging.activate(event, 'resize', {
- autoActivate: true,
- cursor: 'resize-' + (/nw|se/.test(direction) ? 'nwse' : 'nesw'),
- data: {
- shape: shape,
- context: context
- }
- });
- }
- function makeDraggable(element, gfx, direction) {
- function listener(event) {
- // only trigger on left mouse button
- if (isPrimaryButton(event)) {
- activate(event, element, direction);
- }
- }
- domEvent.bind(gfx.node, 'mousedown', listener);
- domEvent.bind(gfx.node, 'touchstart', listener);
- }
- function __createResizer(gfx, x, y, rotation, direction) {
- var group = gfx.group().addClass(CLS_RESIZER).addClass(CLS_RESIZER + '-' + direction);
- var origin = -HANDLE_SIZE + HANDLE_OFFSET;
- // Create four drag indicators on the outline
- group.rect(origin, origin, HANDLE_SIZE, HANDLE_SIZE).addClass(CLS_RESIZER + '-visual');
- group.rect(origin, origin, HANDLE_HIT_SIZE, HANDLE_HIT_SIZE).addClass(CLS_RESIZER + '-hit');
- var matrix = new Snap.Matrix().translate(x, y).rotate(rotation, 0, 0);
- group.transform(matrix);
- return group;
- }
- function createResizer(element, gfx, direction) {
- var resizer;
- if (direction === 'nw') {
- resizer = __createResizer(gfx, 0, 0, 0, direction);
- } else if (direction === 'ne') {
- resizer = __createResizer(gfx, element.width, 0, 90, direction);
- } else if (direction === 'se') {
- resizer = __createResizer(gfx, element.width, element.height, 180, direction);
- } else {
- resizer = __createResizer(gfx, 0, element.height, 270, direction);
- }
- makeDraggable(element, resizer, direction);
- }
- // resize handles implementation ///////////////////////////////
- function addResize(shape) {
- if (!canResize({ shape: shape })) {
- return;
- }
- var gfx = elementRegistry.getGraphics(shape);
- createResizer(shape, gfx, 'nw');
- createResizer(shape, gfx, 'ne');
- createResizer(shape, gfx, 'se');
- createResizer(shape, gfx, 'sw');
- }
- function removeResize(shape) {
- var gfx = elementRegistry.getGraphics(shape);
- var resizers = gfx.selectAll('.' + CLS_RESIZER);
- forEach(resizers, function(resizer){
- resizer.remove();
- });
- }
- eventBus.on('selection.changed', function(e) {
- var oldSelection = e.oldSelection,
- newSelection = e.newSelection;
- // remove old selection markers
- forEach(oldSelection, removeResize);
- // add new selection markers ONLY if single selection
- if (newSelection.length === 1) {
- forEach(newSelection, addResize);
- }
- });
- eventBus.on('shape.changed', function(e) {
- var shape = e.element;
- removeResize(shape);
- if (selection.isSelected(shape)) {
- addResize(shape);
- }
- });
- // API
- this.activate = activate;
- }
- Resize.$inject = [ 'eventBus', 'elementRegistry', 'rules', 'modeling', 'canvas', 'selection', 'dragging' ];
- module.exports = Resize;
- },{"151":151,"186":186,"193":193,"200":200,"216":216,"218":218,"339":339,"345":345,"357":357}],151:[function(_dereq_,module,exports){
- 'use strict';
- var max = Math.max,
- min = Math.min;
- /**
- * Resize the given bounds by the specified delta from a given anchor point.
- *
- * @param {Bounds} bounds the bounding box that should be resized
- * @param {String} direction in which the element is resized (nw, ne, se, sw)
- * @param {Point} delta of the resize operation
- *
- * @return {Bounds} resized bounding box
- */
- module.exports.resizeBounds = function(bounds, direction, delta) {
- var dx = delta.x,
- dy = delta.y;
- switch (direction) {
- case 'nw':
- return {
- x: bounds.x + dx,
- y: bounds.y + dy,
- width: bounds.width - dx,
- height: bounds.height - dy
- };
- case 'sw':
- return {
- x: bounds.x + dx,
- y: bounds.y,
- width: bounds.width - dx,
- height: bounds.height + dy
- };
- case 'ne':
- return {
- x: bounds.x,
- y: bounds.y + dy,
- width: bounds.width + dx,
- height: bounds.height - dy
- };
- case 'se':
- return {
- x: bounds.x,
- y: bounds.y,
- width: bounds.width + dx,
- height: bounds.height + dy
- };
- default:
- throw new Error('unrecognized direction: ' + direction);
- }
- };
- module.exports.reattachPoint = function(bounds, newBounds, point) {
- var sx = bounds.width / newBounds.width,
- sy = bounds.height / newBounds.height;
- return {
- x: Math.round((newBounds.x + newBounds.width / 2)) - Math.floor(((bounds.x + bounds.width / 2) - point.x) / sx),
- y: Math.round((newBounds.y + newBounds.height / 2)) - Math.floor(((bounds.y + bounds.height / 2) - point.y) / sy)
- };
- };
- module.exports.ensureMinBounds = function(currentBounds, minBounds) {
- var topLeft = {
- x: Math.min(currentBounds.x, minBounds.x),
- y: Math.min(currentBounds.y, minBounds.y)
- };
- var bottomRight = {
- x: Math.max(currentBounds.x + currentBounds.width, minBounds.x + minBounds.width),
- y: Math.max(currentBounds.y + currentBounds.height, minBounds.y + minBounds.height)
- };
- return {
- x: topLeft.x,
- y: topLeft.y,
- width: bottomRight.x - topLeft.x,
- height: bottomRight.y - topLeft.y
- };
- };
- function toTLBR(bounds) {
- return {
- top: bounds.y,
- left: bounds.x,
- bottom: bounds.y + bounds.height,
- right: bounds.x + bounds.width
- };
- }
- module.exports.getMinResizeBounds = function(direction, currentBounds, minDimensions, childrenBounds) {
- var currentBox = toTLBR(currentBounds);
- var minBox = {
- top: /n/.test(direction) ? currentBox.bottom - minDimensions.height : currentBox.top,
- left: /w/.test(direction) ? currentBox.right - minDimensions.width : currentBox.left,
- bottom: /s/.test(direction) ? currentBox.top + minDimensions.height : currentBox.bottom,
- right: /e/.test(direction) ? currentBox.left + minDimensions.width : currentBox.right
- };
- var childrenBox = childrenBounds ? toTLBR(childrenBounds) : minBox;
- var combinedBox = {
- top: min(minBox.top, childrenBox.top),
- left: min(minBox.left, childrenBox.left),
- bottom: max(minBox.bottom, childrenBox.bottom),
- right: max(minBox.right, childrenBox.right),
- };
- return {
- x: combinedBox.left,
- y: combinedBox.top,
- width: combinedBox.right - combinedBox.left,
- height: combinedBox.bottom - combinedBox.top
- };
- };
- },{}],152:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [
- _dereq_(136),
- _dereq_(155),
- _dereq_(106)
- ],
- __init__: [ 'resize' ],
- resize: [ 'type', _dereq_(150) ]
- };
- },{"106":106,"136":136,"150":150,"155":155}],153:[function(_dereq_,module,exports){
- 'use strict';
- var inherits = _dereq_(207);
- var CommandInterceptor = _dereq_(78);
- /**
- * A basic provider that may be extended to implement modeling rules.
- *
- * Extensions should implement the init method to actually add their custom
- * modeling checks. Checks may be added via the #addRule(action, fn) method.
- *
- * @param {EventBus} eventBus
- */
- function RuleProvider(eventBus) {
- CommandInterceptor.call(this, eventBus);
- this.init();
- }
- RuleProvider.$inject = [ 'eventBus' ];
- inherits(RuleProvider, CommandInterceptor);
- module.exports = RuleProvider;
- /**
- * Adds a modeling rule for the given action, implemented through a callback function.
- *
- * The function will receive the modeling specific action context to perform its check.
- * It must return false or null to disallow the action from happening.
- *
- * Returning <code>null</code> may encode simply ignoring the action.
- *
- * @example
- *
- * ResizableRules.prototype.init = function() {
- *
- * this.addRule('shape.resize', function(context) {
- *
- * var shape = context.shape;
- *
- * if (!context.newBounds) {
- * // check general resizability
- * if (!shape.resizable) {
- * return false;
- * }
- * } else {
- * // element must have minimum size of 10*10 points
- * return context.newBounds.width > 10 && context.newBounds.height > 10;
- * }
- * });
- * };
- *
- * @param {String|Array<String>} actions the identifier for the modeling action to check
- * @param {Number} [priority] the priority at which this rule is being applied
- * @param {Function} fn the callback function that performs the actual check
- */
- RuleProvider.prototype.addRule = function(actions, priority, fn) {
- var self = this;
- if (typeof actions === 'string') {
- actions = [ actions ];
- }
- actions.forEach(function(action) {
- self.canExecute(action, priority, function(context, action, event) {
- return fn(context);
- }, true);
- });
- };
- },{"207":207,"78":78}],154:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * A service that provides rules for certain diagram actions.
- *
- * @param {CommandStack} commandStack
- */
- function Rules(commandStack) {
- this._commandStack = commandStack;
- }
- Rules.$inject = [ 'commandStack' ];
- module.exports = Rules;
- /**
- * This method can be queried to ask whether certain modeling actions
- * are allowed or not.
- *
- * @param {String} action the action to be checked
- * @param {Object} [context] the context to check the action in
- *
- * @return {Boolean} returns true, false or null depending on whether the
- * operation is allowed, not allowed or should be ignored.
- */
- Rules.prototype.allowed = function(action, context) {
- var allowed = this._commandStack.canExecute(action, context);
- // map undefined to true, i.e. no rules
- return allowed === undefined ? true : allowed;
- };
- },{}],155:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(80) ],
- __init__: [ 'rules' ],
- rules: [ 'type', _dereq_(154) ]
- };
- },{"154":154,"80":80}],156:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- forEach = _dereq_(218);
- /**
- * A service that offers the current selection in a diagram.
- * Offers the api to control the selection, too.
- *
- * @class
- *
- * @param {EventBus} eventBus the event bus
- */
- function Selection(eventBus) {
- this._eventBus = eventBus;
- this._selectedElements = [];
- var self = this;
- eventBus.on([ 'shape.remove', 'connection.remove' ], function(e) {
- var element = e.element;
- self.deselect(element);
- });
- }
- Selection.$inject = [ 'eventBus' ];
- module.exports = Selection;
- Selection.prototype.deselect = function(element) {
- var selectedElements = this._selectedElements;
- var idx = selectedElements.indexOf(element);
- if (idx !== -1) {
- var oldSelection = selectedElements.slice();
- selectedElements.splice(idx, 1);
- this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
- }
- };
- Selection.prototype.get = function() {
- return this._selectedElements;
- };
- Selection.prototype.isSelected = function(element) {
- return this._selectedElements.indexOf(element) !== -1;
- };
- /**
- * This method selects one or more elements on the diagram.
- *
- * By passing an additional add parameter you can decide whether or not the element(s)
- * should be added to the already existing selection or not.
- *
- * @method Selection#select
- *
- * @param {Object|Object[]} elements element or array of elements to be selected
- * @param {boolean} [add] whether the element(s) should be appended to the current selection, defaults to false
- */
- Selection.prototype.select = function(elements, add) {
- var selectedElements = this._selectedElements,
- oldSelection = selectedElements.slice();
- if (!isArray(elements)) {
- elements = elements ? [ elements ] : [];
- }
- // selection may be cleared by passing an empty array or null
- // to the method
- if (add) {
- forEach(elements, function(element) {
- if (selectedElements.indexOf(element) !== -1) {
- // already selected
- return;
- } else {
- selectedElements.push(element);
- }
- });
- } else {
- this._selectedElements = selectedElements = elements.slice();
- }
- this._eventBus.fire('selection.changed', { oldSelection: oldSelection, newSelection: selectedElements });
- };
- },{"218":218,"330":330}],157:[function(_dereq_,module,exports){
- 'use strict';
- var hasPrimaryModifier = _dereq_(193).hasPrimaryModifier;
- function SelectionBehavior(eventBus, selection, canvas) {
- eventBus.on('create.end', 500, function(e) {
- // select the created shape after a
- // successful create operation
- if (e.context.canExecute) {
- selection.select(e.context.shape);
- }
- });
- eventBus.on('connect.end', 500, function(e) {
- // select the connect end target
- // after a connect operation
- if (e.context.canExecute && e.context.target) {
- selection.select(e.context.target);
- }
- });
- eventBus.on('shape.move.end', 500, function(e) {
- var previousSelection = e.previousSelection || [];
- var shape = e.context.shape;
- // make sure at least the main moved element is being
- // selected after a move operation
- if (previousSelection.indexOf(shape) === -1) {
- selection.select(shape);
- }
- });
- // Shift + click selection
- eventBus.on('element.click', function(event) {
- var element = event.element;
- // do not select the root element
- // or connections
- if (element === canvas.getRootElement()) {
- element = null;
- }
- var isSelected = selection.isSelected(element),
- isMultiSelect = selection.get().length > 1;
- // mouse-event: SELECTION_KEY
- var add = hasPrimaryModifier(event);
- // select OR deselect element in multi selection
- if (isSelected && isMultiSelect) {
- if (add) {
- return selection.deselect(element);
- } else {
- return selection.select(element);
- }
- } else
- if (!isSelected) {
- selection.select(element, add);
- } else {
- selection.deselect(element);
- }
- });
- }
- SelectionBehavior.$inject = [ 'eventBus', 'selection', 'canvas' ];
- module.exports = SelectionBehavior;
- },{"193":193}],158:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var MARKER_HOVER = 'hover',
- MARKER_SELECTED = 'selected';
- /**
- * A plugin that adds a visible selection UI to shapes and connections
- * by appending the <code>hover</code> and <code>selected</code> classes to them.
- *
- * @class
- *
- * Makes elements selectable, too.
- *
- * @param {EventBus} events
- * @param {SelectionService} selection
- * @param {Canvas} canvas
- */
- function SelectionVisuals(events, canvas, selection, graphicsFactory, styles) {
- this._multiSelectionBox = null;
- function addMarker(e, cls) {
- canvas.addMarker(e, cls);
- }
- function removeMarker(e, cls) {
- canvas.removeMarker(e, cls);
- }
- events.on('element.hover', function(event) {
- addMarker(event.element, MARKER_HOVER);
- });
- events.on('element.out', function(event) {
- removeMarker(event.element, MARKER_HOVER);
- });
- events.on('selection.changed', function(event) {
- function deselect(s) {
- removeMarker(s, MARKER_SELECTED);
- }
- function select(s) {
- addMarker(s, MARKER_SELECTED);
- }
- var oldSelection = event.oldSelection,
- newSelection = event.newSelection;
- forEach(oldSelection, function(e) {
- if (newSelection.indexOf(e) === -1) {
- deselect(e);
- }
- });
- forEach(newSelection, function(e) {
- if (oldSelection.indexOf(e) === -1) {
- select(e);
- }
- });
- });
- }
- SelectionVisuals.$inject = [
- 'eventBus',
- 'canvas',
- 'selection',
- 'graphicsFactory',
- 'styles'
- ];
- module.exports = SelectionVisuals;
- },{"218":218}],159:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'selectionVisuals', 'selectionBehavior' ],
- __depends__: [
- _dereq_(108),
- _dereq_(141)
- ],
- selection: [ 'type', _dereq_(156) ],
- selectionVisuals: [ 'type', _dereq_(158) ],
- selectionBehavior: [ 'type', _dereq_(157) ]
- };
- },{"108":108,"141":141,"156":156,"157":157,"158":158}],160:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var snapTo = _dereq_(161).snapTo;
- /**
- * A snap context, containing the (possibly incomplete)
- * mappings of drop targets (to identify the snapping)
- * to computed snap points.
- */
- function SnapContext() {
- /**
- * Map<String, SnapPoints> mapping drop targets to
- * a list of possible snappings.
- *
- * @type {Object}
- */
- this._targets = {};
- /**
- * Map<String, Point> initial positioning of element
- * regarding various snap directions.
- *
- * @type {Object}
- */
- this._snapOrigins = {};
- /**
- * List of snap locations
- *
- * @type {Array<String>}
- */
- this._snapLocations = [];
- /**
- * Map<String, Array<Point>> of default snapping locations
- *
- * @type {Object}
- */
- this._defaultSnaps = {};
- }
- SnapContext.prototype.getSnapOrigin = function(snapLocation) {
- return this._snapOrigins[snapLocation];
- };
- SnapContext.prototype.setSnapOrigin = function(snapLocation, initialValue) {
- this._snapOrigins[snapLocation] = initialValue;
- if (this._snapLocations.indexOf(snapLocation) === -1) {
- this._snapLocations.push(snapLocation);
- }
- };
- SnapContext.prototype.addDefaultSnap = function(type, point) {
- var snapValues = this._defaultSnaps[type];
- if (!snapValues) {
- snapValues = this._defaultSnaps[type] = [];
- }
- snapValues.push(point);
- };
- /**
- * Return a number of initialized snaps, i.e. snap locations such as
- * top-left, mid, bottom-right and so forth.
- *
- * @return {Array<String>} snapLocations
- */
- SnapContext.prototype.getSnapLocations = function() {
- return this._snapLocations;
- };
- /**
- * Set the snap locations for this context.
- *
- * The order of locations determines precedence.
- *
- * @param {Array<String>} snapLocations
- */
- SnapContext.prototype.setSnapLocations = function(snapLocations) {
- this._snapLocations = snapLocations;
- };
- /**
- * Get snap points for a given target
- *
- * @param {Element|String} target
- */
- SnapContext.prototype.pointsForTarget = function(target) {
- var targetId = target.id || target;
- var snapPoints = this._targets[targetId];
- if (!snapPoints) {
- snapPoints = this._targets[targetId] = new SnapPoints();
- snapPoints.initDefaults(this._defaultSnaps);
- }
- return snapPoints;
- };
- module.exports = SnapContext;
- /**
- * Creates the snap points and initializes them with the
- * given default values.
- *
- * @param {Object<String, Array<Point>>} [defaultPoints]
- */
- function SnapPoints(defaultSnaps) {
- /**
- * Map<String, Map<(x|y), Array<Number>>> mapping snap locations,
- * i.e. top-left, bottom-right, center to actual snap values.
- *
- * @type {Object}
- */
- this._snapValues = {};
- }
- SnapPoints.prototype.add = function(snapLocation, point) {
- var snapValues = this._snapValues[snapLocation];
- if (!snapValues) {
- snapValues = this._snapValues[snapLocation] = { x: [], y: [] };
- }
- if (snapValues.x.indexOf(point.x) === -1) {
- snapValues.x.push(point.x);
- }
- if (snapValues.y.indexOf(point.y) === -1) {
- snapValues.y.push(point.y);
- }
- };
- SnapPoints.prototype.snap = function(point, snapLocation, axis, tolerance) {
- var snappingValues = this._snapValues[snapLocation];
-
- return snappingValues && snapTo(point[axis], snappingValues[axis], tolerance);
- };
- /**
- * Initialize a number of default snapping points.
- *
- * @param {Object} defaultSnaps
- */
- SnapPoints.prototype.initDefaults = function(defaultSnaps) {
- var self = this;
- forEach(defaultSnaps || {}, function(snapPoints, snapLocation) {
- forEach(snapPoints, function(point) {
- self.add(snapLocation, point);
- });
- });
- };
- },{"161":161,"218":218}],161:[function(_dereq_,module,exports){
- 'use strict';
- var abs = Math.abs,
- round = Math.round;
- /**
- * Snap value to a collection of reference values.
- *
- * @param {Number} value
- * @param {Array<Number>} values
- * @param {Number} [tolerance=10]
- *
- * @return {Number} the value we snapped to or null, if none snapped
- */
- function snapTo(value, values, tolerance) {
- tolerance = tolerance === undefined ? 10 : tolerance;
- var idx, snapValue;
- for (idx = 0; idx < values.length; idx++) {
- snapValue = values[idx];
- if (abs(snapValue - value) <= tolerance) {
- return snapValue;
- }
- }
- }
- module.exports.snapTo = snapTo;
- function topLeft(bounds) {
- return {
- x: bounds.x,
- y: bounds.y
- };
- }
- module.exports.topLeft = topLeft;
- function mid(bounds, defaultValue) {
- if (!bounds || isNaN(bounds.x) || isNaN(bounds.y)) {
- return defaultValue;
- }
- return {
- x: round(bounds.x + bounds.width / 2),
- y: round(bounds.y + bounds.height / 2)
- };
- }
- module.exports.mid = mid;
- function bottomRight(bounds) {
- return {
- x: bounds.x + bounds.width,
- y: bounds.y + bounds.height
- };
- }
- module.exports.bottomRight = bottomRight;
- /**
- * Retrieve the snap state of the given event.
- *
- * @param {Event} event
- * @param {String} axis
- *
- * @return {Boolean} the snapped state
- *
- */
- module.exports.isSnapped = function(event, axis) {
- var snapped = event.snapped;
- if (!snapped) {
- return false;
- }
- if (typeof axis === 'string') {
- return snapped[axis];
- }
- return snapped.x && snapped.y;
- };
- /**
- * Set the given event as snapped.
- *
- * @param {Event} event
- * @param {String} axis
- * @param {Number|Boolean} value
- *
- * @return {Number} old value
- */
- module.exports.setSnapped = function(event, axis, value) {
- if (typeof axis !== 'string') {
- throw new Error('axis must be in [x, y]');
- }
- if (typeof value !== 'number' && value !== false) {
- throw new Error('value must be Number or false');
- }
- var delta,
- previousValue = event[axis];
- var snapped = event.snapped = (event.snapped || {});
- if (value === false) {
- snapped[axis] = false;
- } else {
- snapped[axis] = true;
- delta = value - previousValue;
- event[axis] += delta;
- event['d' + axis] += delta;
- }
- return previousValue;
- };
- },{}],162:[function(_dereq_,module,exports){
- 'use strict';
- var filter = _dereq_(216),
- forEach = _dereq_(218),
- debounce = _dereq_(228);
- var mid = _dereq_(161).mid;
- var SnapContext = _dereq_(160);
- var SnapUtil = _dereq_(161);
- var isSnapped = SnapUtil.isSnapped,
- setSnapped = SnapUtil.setSnapped;
- /**
- * A general purpose snapping component for diagram elements.
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- */
- function Snapping(eventBus, canvas) {
- this._canvas = canvas;
- var self = this;
- eventBus.on([ 'shape.move.start', 'create.start' ], function(event) {
- self.initSnap(event);
- });
- eventBus.on([ 'shape.move.move', 'shape.move.end', 'create.move', 'create.end' ], function(event) {
- if (event.originalEvent && event.originalEvent.ctrlKey) {
- return;
- }
- if (isSnapped(event)) {
- return;
- }
- self.snap(event);
- });
- eventBus.on([ 'shape.move.cleanup', 'create.cleanup' ], function(event) {
- self.hide();
- });
- // delay hide by 1000 seconds since last match
- this._asyncHide = debounce(this.hide, 1000);
- }
- Snapping.$inject = [ 'eventBus', 'canvas' ];
- module.exports = Snapping;
- Snapping.prototype.initSnap = function(event) {
- var context = event.context,
- shape = context.shape,
- snapContext = context.snapContext;
- if (!snapContext) {
- snapContext = context.snapContext = new SnapContext();
- }
- var snapMid = mid(shape, event);
- snapContext.setSnapOrigin('mid', {
- x: snapMid.x - event.x,
- y: snapMid.y - event.y
- });
- return snapContext;
- };
- Snapping.prototype.snap = function(event) {
- var context = event.context,
- snapContext = context.snapContext,
- shape = context.shape,
- target = context.target,
- snapLocations = snapContext.getSnapLocations();
- if (!target) {
- return;
- }
- var snapPoints = snapContext.pointsForTarget(target);
- if (!snapPoints.initialized) {
- this.addTargetSnaps(snapPoints, shape, target);
- snapPoints.initialized = true;
- }
- var snapping = {
- x: isSnapped(event, 'x'),
- y: isSnapped(event, 'y')
- };
- forEach(snapLocations, function(location) {
- var snapOrigin = snapContext.getSnapOrigin(location);
- var snapCurrent = {
- x: event.x + snapOrigin.x,
- y: event.y + snapOrigin.y
- };
- // snap on both axis, if not snapped already
- forEach([ 'x', 'y' ], function(axis) {
- var locationSnapping;
- if (!snapping[axis]) {
- locationSnapping = snapPoints.snap(snapCurrent, location, axis, 7);
- if (locationSnapping !== undefined) {
- snapping[axis] = {
- value: locationSnapping,
- originValue: locationSnapping - snapOrigin[axis]
- };
- }
- }
- });
- // no more need to snap, drop out of interation
- if (snapping.x && snapping.y) {
- return false;
- }
- });
- // show snap visuals
- this.showSnapLine('vertical', snapping.x && snapping.x.value);
- this.showSnapLine('horizontal', snapping.y && snapping.y.value);
- // adjust event { x, y, dx, dy } and mark as snapping
- forEach([ 'x', 'y' ], function(axis) {
- var axisSnapping = snapping[axis];
- if (typeof axisSnapping === 'object') {
- setSnapped(event, axis, axisSnapping.originValue);
- }
- });
- };
- Snapping.prototype._createLine = function(orientation) {
- var root = this._canvas.getLayer('snap');
- var line = root.path('M0,0 L0,0').addClass('djs-snap-line');
- return {
- update: function(position) {
- if (typeof position !== 'number') {
- line.attr({ display: 'none' });
- } else {
- if (orientation === 'horizontal') {
- line.attr({
- path: 'M-100000,' + position + ' L+100000,' + position,
- display: ''
- });
- } else {
- line.attr({
- path: 'M ' + position + ',-100000 L ' + position + ', +100000',
- display: ''
- });
- }
- }
- }
- };
- };
- Snapping.prototype._createSnapLines = function() {
- this._snapLines = {
- horizontal: this._createLine('horizontal'),
- vertical: this._createLine('vertical')
- };
- };
- Snapping.prototype.showSnapLine = function(orientation, position) {
- var line = this.getSnapLine(orientation);
- if (line) {
- line.update(position);
- }
- this._asyncHide();
- };
- Snapping.prototype.getSnapLine = function(orientation) {
- if (!this._snapLines) {
- this._createSnapLines();
- }
- return this._snapLines[orientation];
- };
- Snapping.prototype.hide = function() {
- forEach(this._snapLines, function(l) {
- l.update();
- });
- };
- Snapping.prototype.addTargetSnaps = function(snapPoints, shape, target) {
- var siblings = this.getSiblings(shape, target);
- forEach(siblings, function(s) {
- snapPoints.add('mid', mid(s));
- });
- };
- Snapping.prototype.getSiblings = function(element, target) {
- // snap to all non connection siblings
- return target && filter(target.children, function(e) {
- return !e.hidden && !e.labelTarget && !e.waypoints && e.host !== element && e !== element;
- });
- };
- },{"160":160,"161":161,"216":216,"218":218,"228":228}],163:[function(_dereq_,module,exports){
- 'use strict';
- var SpaceUtil = _dereq_(165);
- var Cursor = _dereq_(185);
- var hasPrimaryModifier = _dereq_(193).hasPrimaryModifier;
- var abs = Math.abs,
- round = Math.round;
- var HIGH_PRIORITY = 1500;
- /**
- * A tool that allows users to create and remove space in a diagram.
- *
- * The tool needs to be activated manually via {@link SpaceTool#activate(MouseEvent)}.
- */
- function SpaceTool(eventBus, dragging, elementRegistry, modeling, rules) {
- function canResize(shape) {
- var ctx = { shape: shape };
- return rules.allowed('shape.resize', ctx);
- }
- function activateSelection(event, autoActivate) {
- dragging.activate(event, 'spaceTool.selection', {
- cursor: 'crosshair',
- autoActivate: autoActivate,
- data: {
- context: {
- crosshair: {}
- }
- }
- });
- }
- function activateMakeSpace(event) {
- dragging.activate(event, 'spaceTool', {
- autoActivate: true,
- cursor: 'crosshair',
- data: {
- context: {}
- }
- });
- }
- eventBus.on('spaceTool.selection.end', function(event) {
- setTimeout(function() {
- activateMakeSpace(event.originalEvent);
- });
- });
- var AXIS_TO_DIMENSION = { x: 'width', y: 'height' },
- AXIS_INVERTED = { x: 'y', y: 'x' };
- function initializeMakeSpace(event, context) {
- var axis = abs(event.dx) > abs(event.dy) ? 'x' : 'y',
- offset = event['d' + axis],
- // start point of create space operation
- spacePos = event[axis] - offset,
- // list of moving shapes
- movingShapes = [],
- // list of resizing shapes
- resizingShapes = [];
- if (abs(offset) < 5) {
- return false;
- }
- // inverts the offset to choose the shapes
- // on the opposite side of the resizer if
- // a key modifier is pressed
- if (hasPrimaryModifier(event)) {
- offset *= -1;
- }
- // collect all elements that need to be moved _AND_
- // resized given on the initial create space position
- elementRegistry.forEach(function (shape) {
- var shapeStart = shape[ [ axis ]],
- shapeEnd = shapeStart + shape[ AXIS_TO_DIMENSION[ axis ]];
- // checking if it's root
- if (!shape.parent) {
- return;
- }
- // checking if it's a shape
- if (shape.waypoints) {
- return;
- }
- // shape after spacePos
- if (offset > 0 && shapeStart > spacePos) {
- return movingShapes.push(shape);
- }
- // shape before spacePos
- if (offset < 0 && shapeEnd < spacePos) {
- return movingShapes.push(shape);
- }
- // shape on top of spacePos, resize only if allowed
- if (shapeStart < spacePos && shapeEnd > spacePos && canResize(shape)) {
- return resizingShapes.push(shape);
- }
- });
- // store data in context
- context.axis = axis;
- context.direction = SpaceUtil.getDirection(axis, offset);
- context.movingShapes = movingShapes;
- context.resizingShapes = resizingShapes;
- Cursor.set('resize-' + (axis === 'x' ? 'ew' : 'ns'));
- return true;
- }
- eventBus.on('spaceTool.move', HIGH_PRIORITY , function(event) {
- var context = event.context;
- if (!context.initialized) {
- context.initialized = initializeMakeSpace(event, context);
- }
- });
- eventBus.on('spaceTool.end', function(event) {
- var context = event.context,
- axis = context.axis,
- direction = context.direction,
- movingShapes = context.movingShapes,
- resizingShapes = context.resizingShapes;
- // skip if create space has not been initialized yet
- if (!context.initialized) {
- return;
- }
- var delta = { x: round(event.dx), y: round(event.dy) };
- delta[ AXIS_INVERTED[ axis ] ] = 0;
- return modeling.createSpace(movingShapes, resizingShapes, delta, direction);
- });
- // API
- this.activateSelection = activateSelection;
- this.activateMakeSpace = activateMakeSpace;
- }
- SpaceTool.$inject = ['eventBus', 'dragging', 'elementRegistry', 'modeling', 'rules'];
- module.exports = SpaceTool;
- },{"165":165,"185":185,"193":193}],164:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218);
- var MARKER_DRAGGING = 'djs-dragging';
- /**
- * A plugin that makes shapes draggable / droppable.
- *
- * @param {EventBus} eventBus
- * @param {ElementRegistry} elementRegistry
- * @param {Canvas} canvas
- * @param {Styles} styles
- */
- function SpaceToolVisuals(eventBus, elementRegistry, canvas, styles) {
- function getGfx(e) {
- return elementRegistry.getGraphics(e);
- }
- function addDragger(shape, dragGroup) {
- var gfx = getGfx(shape);
- var dragger = gfx.clone();
- var bbox = gfx.getBBox();
- dragger.attr(styles.cls('djs-dragger', [], {
- x: bbox.x,
- y: bbox.y
- }));
- dragGroup.add(dragger);
- }
- eventBus.on('spaceTool.selection.start', function(event) {
- var space = canvas.getLayer('space'),
- context = event.context;
- var orientation = {
- x: 'M 0,-10000 L 0,10000',
- y: 'M -10000,0 L 10000,0'
- };
- var crosshairGroup = space.group().attr(styles.cls('djs-crosshair-group', [ 'no-events' ]));
- crosshairGroup.path(orientation.x).addClass('djs-crosshair');
- crosshairGroup.path(orientation.y).addClass('djs-crosshair');
- context.crosshairGroup = crosshairGroup;
- });
- eventBus.on('spaceTool.selection.move', function(event) {
- var crosshairGroup = event.context.crosshairGroup;
- crosshairGroup.translate(event.x, event.y);
- });
- eventBus.on('spaceTool.selection.cleanup', function(event) {
- var context = event.context,
- crosshairGroup = context.crosshairGroup;
- if (crosshairGroup) {
- crosshairGroup.remove();
- }
- });
- // assign a low priority to this handler
- // to let others modify the move context before
- // we draw things
- eventBus.on('spaceTool.move', function(event) {
- /*
- TODO (Ricardo): extend connections while adding space
- */
- var context = event.context,
- line = context.line,
- axis = context.axis,
- dragShapes = context.movingShapes;
- if (!context.initialized) {
- return;
- }
- if (!context.dragGroup) {
- var spaceLayer = canvas.getLayer('space');
- line = spaceLayer.path('M0,0 L0,0').addClass('djs-crosshair');
- context.line = line;
- var dragGroup = canvas.getDefaultLayer().group().attr(styles.cls('djs-drag-group', [ 'no-events' ]));
- forEach(dragShapes, function(shape) {
- addDragger(shape, dragGroup);
- canvas.addMarker(shape, MARKER_DRAGGING);
- });
- context.dragGroup = dragGroup;
- }
- var orientation = {
- x: 'M' + event.x + ', -10000 L' + event.x + ', 10000',
- y: 'M -10000, ' + event.y + ' L 10000, ' + event.y
- };
- line.attr({
- path: orientation[ axis ],
- display: ''
- });
- var opposite = { x: 'y', y: 'x' };
- var delta = { x: event.dx, y: event.dy };
- delta[ opposite[ context.axis ] ] = 0;
- context.dragGroup.translate(delta.x, delta.y);
- });
- eventBus.on('spaceTool.cleanup', function(event) {
- var context = event.context,
- shapes = context.movingShapes,
- line = context.line,
- dragGroup = context.dragGroup;
- // remove dragging marker
- forEach(shapes, function(e) {
- canvas.removeMarker(e, MARKER_DRAGGING);
- });
- if (dragGroup) {
- line.remove();
- dragGroup.remove();
- }
- });
- }
- SpaceToolVisuals.$inject = [ 'eventBus', 'elementRegistry', 'canvas', 'styles' ];
- module.exports = SpaceToolVisuals;
- },{"218":218}],165:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Get Resize direction given axis + offset
- *
- * @param {String} axis (x|y)
- * @param {Number} offset
- *
- * @return {String} (e|w|n|s)
- */
- function getDirection(axis, offset) {
- if (axis === 'x') {
- if (offset > 0) {
- return 'e';
- }
- if (offset < 0) {
- return 'w';
- }
- }
- if (axis === 'y') {
- if (offset > 0) {
- return 's';
- }
- if (offset < 0) {
- return 'n';
- }
- }
- return null;
- }
- module.exports.getDirection = getDirection;
- /**
- * Resize the given bounds by the specified delta from a given anchor point.
- *
- * @param {Bounds} bounds the bounding box that should be resized
- * @param {String} direction in which the element is resized (n, s, e, w)
- * @param {Point} delta of the resize operation
- *
- * @return {Bounds} resized bounding box
- */
- module.exports.resizeBounds = function(bounds, direction, delta) {
- var dx = delta.x,
- dy = delta.y;
- switch (direction) {
- case 'n':
- return {
- x: bounds.x,
- y: bounds.y + dy,
- width: bounds.width,
- height: bounds.height - dy
- };
- case 's':
- return {
- x: bounds.x,
- y: bounds.y,
- width: bounds.width,
- height: bounds.height + dy
- };
- case 'w':
- return {
- x: bounds.x + dx,
- y: bounds.y,
- width: bounds.width - dx,
- height: bounds.height
- };
- case 'e':
- return {
- x: bounds.x,
- y: bounds.y,
- width: bounds.width + dx,
- height: bounds.height
- };
- default:
- throw new Error('unrecognized direction: ' + direction);
- }
- };
- },{}],166:[function(_dereq_,module,exports){
- module.exports = {
- __init__: ['spaceToolVisuals'],
- __depends__: [_dereq_(106), _dereq_(136), _dereq_(155) ],
- spaceTool: ['type', _dereq_(163)],
- spaceToolVisuals: ['type', _dereq_(164) ]
- };
- },{"106":106,"136":136,"155":155,"163":163,"164":164}],167:[function(_dereq_,module,exports){
- 'use strict';
- var isString = _dereq_(336),
- assign = _dereq_(339),
- forEach = _dereq_(218),
- debounce = _dereq_(228);
- var domify = _dereq_(356),
- domAttr = _dereq_(351),
- domClasses = _dereq_(352),
- domRemove = _dereq_(360),
- domDelegate = _dereq_(355);
- // document wide unique tooltip ids
- var ids = new (_dereq_(190))('tt');
- function createRoot(parent) {
- var root = domify('<div class="djs-tooltip-container" style="position: absolute; width: 0; height: 0;" />');
- parent.insertBefore(root, parent.firstChild);
- return root;
- }
- function setPosition(el, x, y) {
- assign(el.style, { left: x + 'px', top: y + 'px' });
- }
- function setVisible(el, visible) {
- el.style.display = visible === false ? 'none' : '';
- }
- var tooltipClass = 'djs-tooltip',
- tooltipSelector = '.' + tooltipClass;
- /**
- * A service that allows users to render tool tips on the diagram.
- *
- * The tooltip service will take care of updating the tooltip positioning
- * during navigation + zooming.
- *
- * @example
- *
- * ```javascript
- *
- * // add a pink badge on the top left of the shape
- * tooltips.add({
- * position: {
- * x: 50,
- * y: 100
- * },
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>'
- * });
- *
- * // or with optional life span
- * tooltips.add({
- * position: {
- * top: -5,
- * left: -5
- * },
- * html: '<div style="width: 10px; background: fuchsia; color: white;">0</div>',
- * ttl: 2000
- * });
- *
- * // remove a tool tip
- * var id = tooltips.add(...);
- * tooltips.remove(id);
- * ```
- *
- * @param {Object} config
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- */
- function Tooltips(config, eventBus, canvas) {
- this._eventBus = eventBus;
- this._canvas = canvas;
- this._ids = ids;
- this._tooltipDefaults = {
- show: {
- minZoom: 0.7,
- maxZoom: 5.0
- }
- };
- /**
- * Mapping tooltipId -> tooltip
- */
- this._tooltips = {};
- // root html element for all tooltips
- this._tooltipRoot = createRoot(canvas.getContainer());
- var self = this;
- domDelegate.bind(this._tooltipRoot, tooltipSelector, 'mousedown', function(event) {
- event.stopPropagation();
- });
- domDelegate.bind(this._tooltipRoot, tooltipSelector, 'mouseover', function(event) {
- self.trigger('mouseover', event);
- });
- domDelegate.bind(this._tooltipRoot, tooltipSelector, 'mouseout', function(event) {
- self.trigger('mouseout', event);
- });
- this._init(config);
- }
- Tooltips.$inject = [ 'config.tooltips', 'eventBus', 'canvas' ];
- module.exports = Tooltips;
- /**
- * Adds a HTML tooltip to the diagram
- *
- * @param {Object} tooltip the tooltip configuration
- *
- * @param {String|DOMElement} tooltip.html html element to use as an tooltip
- * @param {Object} [tooltip.show] show configuration
- * @param {Number} [tooltip.show.minZoom] minimal zoom level to show the tooltip
- * @param {Number} [tooltip.show.maxZoom] maximum zoom level to show the tooltip
- * @param {Object} tooltip.position where to attach the tooltip
- * @param {Number} [tooltip.position.left] relative to element bbox left attachment
- * @param {Number} [tooltip.position.top] relative to element bbox top attachment
- * @param {Number} [tooltip.position.bottom] relative to element bbox bottom attachment
- * @param {Number} [tooltip.position.right] relative to element bbox right attachment
- * @param {Number} [tooltip.timeout=-1]
- *
- * @return {String} id that may be used to reference the tooltip for update or removal
- */
- Tooltips.prototype.add = function(tooltip) {
- if (!tooltip.position) {
- throw new Error('must specifiy tooltip position');
- }
- if (!tooltip.html) {
- throw new Error('must specifiy tooltip html');
- }
- var id = this._ids.next();
- tooltip = assign({}, this._tooltipDefaults, tooltip, {
- id: id
- });
- this._addTooltip(tooltip);
- if (tooltip.timeout) {
- this.setTimeout(tooltip);
- }
- return id;
- };
- Tooltips.prototype.trigger = function(action, event) {
- var node = event.delegateTarget || event.target;
- var tooltip = this.get(domAttr(node, 'data-tooltip-id'));
- if (!tooltip) {
- return;
- }
- if (action === 'mouseover' && tooltip.timeout) {
- this.clearTimeout(tooltip);
- }
- if (action === 'mouseout' && tooltip.timeout) {
- // cut timeout after mouse out
- tooltip.timeout = 1000;
- this.setTimeout(tooltip);
- }
- };
- /**
- * Get a tooltip with the given id
- *
- * @param {String} id
- */
- Tooltips.prototype.get = function(id) {
- if (typeof id !== 'string') {
- id = id.id;
- }
- return this._tooltips[id];
- };
- Tooltips.prototype.clearTimeout = function(tooltip) {
- tooltip = this.get(tooltip);
- if (!tooltip) {
- return;
- }
- var removeTimer = tooltip.removeTimer;
- if (removeTimer) {
- clearTimeout(removeTimer);
- tooltip.removeTimer = null;
- }
- };
- Tooltips.prototype.setTimeout = function(tooltip) {
- tooltip = this.get(tooltip);
- if (!tooltip) {
- return;
- }
- this.clearTimeout(tooltip);
- var self = this;
- tooltip.removeTimer = setTimeout(function() {
- self.remove(tooltip);
- }, tooltip.timeout);
- };
- /**
- * Remove an tooltip with the given id
- *
- * @param {String} id
- */
- Tooltips.prototype.remove = function(id) {
- var tooltip = this.get(id);
- if (tooltip) {
- domRemove(tooltip.html);
- domRemove(tooltip.htmlContainer);
- delete tooltip.htmlContainer;
- delete this._tooltips[tooltip.id];
- }
- };
- Tooltips.prototype.show = function() {
- setVisible(this._tooltipRoot);
- };
- Tooltips.prototype.hide = function() {
- setVisible(this._tooltipRoot, false);
- };
- Tooltips.prototype._updateRoot = function(viewbox) {
- var a = viewbox.scale || 1;
- var d = viewbox.scale || 1;
- var matrix = 'matrix(' + a + ',0,0,' + d + ',' + (-1 * viewbox.x * a) + ',' + (-1 * viewbox.y * d) + ')';
- this._tooltipRoot.style.transform = matrix;
- this._tooltipRoot.style['-ms-transform'] = matrix;
- };
- Tooltips.prototype._addTooltip = function(tooltip) {
- var id = tooltip.id,
- html = tooltip.html,
- htmlContainer,
- tooltipRoot = this._tooltipRoot;
- // unwrap jquery (for those who need it)
- if (html.get) {
- html = html.get(0);
- }
- // create proper html elements from
- // tooltip HTML strings
- if (isString(html)) {
- html = domify(html);
- }
- htmlContainer = domify('<div data-tooltip-id="' + id + '" class="' + tooltipClass + '" style="position: absolute">');
- htmlContainer.appendChild(html);
- if (tooltip.type) {
- domClasses(htmlContainer).add('djs-tooltip-' + tooltip.type);
- }
- if (tooltip.className) {
- domClasses(htmlContainer).add(tooltip.className);
- }
- tooltip.htmlContainer = htmlContainer;
- tooltipRoot.appendChild(htmlContainer);
- this._tooltips[id] = tooltip;
- this._updateTooltip(tooltip);
- };
- Tooltips.prototype._updateTooltip = function(tooltip) {
- var position = tooltip.position,
- htmlContainer = tooltip.htmlContainer;
- // update overlay html based on tooltip x, y
- setPosition(htmlContainer, position.x, position.y);
- };
- Tooltips.prototype._updateTooltipVisibilty = function(viewbox) {
- forEach(this._tooltips, function(tooltip) {
- var show = tooltip.show,
- htmlContainer = tooltip.htmlContainer,
- visible = true;
- if (show) {
- if (show.minZoom > viewbox.scale ||
- show.maxZoom < viewbox.scale) {
- visible = false;
- }
- setVisible(htmlContainer, visible);
- }
- });
- };
- Tooltips.prototype._init = function(config) {
- var self = this;
- // scroll/zoom integration
- var updateViewbox = function(viewbox) {
- self._updateRoot(viewbox);
- self._updateTooltipVisibilty(viewbox);
- self.show();
- };
- if (!config || config.deferUpdate !== false) {
- updateViewbox = debounce(updateViewbox, 300);
- }
- this._eventBus.on('canvas.viewbox.changed', function(event) {
- self.hide();
- updateViewbox(event.viewbox);
- });
- };
- },{"190":190,"218":218,"228":228,"336":336,"339":339,"351":351,"352":352,"355":355,"356":356,"360":360}],168:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'tooltips' ],
- tooltips: [ 'type', _dereq_(167) ]
- };
- },{"167":167}],169:[function(_dereq_,module,exports){
- 'use strict';
- function TouchFix(canvas, eventBus) {
- var self = this;
- eventBus.on('canvas.init', function(e) {
- self.addBBoxMarker(e.svg);
- });
- }
- TouchFix.$inject = [ 'canvas', 'eventBus' ];
- module.exports = TouchFix;
- /**
- * Safari mobile (iOS 7) does not fire touchstart event in <SVG> element
- * if there is no shape between 0,0 and viewport elements origin.
- *
- * So touchstart event is only fired when the <g class="viewport"> element was hit.
- * Putting an element over and below the 'viewport' fixes that behavior.
- */
- TouchFix.prototype.addBBoxMarker = function(paper) {
- var markerStyle = {
- fill: 'none',
- class: 'outer-bound-marker'
- };
- paper.rect(-10000, -10000, 10, 10).attr(markerStyle);
- paper.rect(10000, 10000, 10, 10).attr(markerStyle);
- };
- },{}],170:[function(_dereq_,module,exports){
- 'use strict';
- var forEach = _dereq_(218),
- domEvent = _dereq_(357),
- domClosest = _dereq_(354),
- Hammer = _dereq_(198),
- Snap = _dereq_(200),
- Event = _dereq_(187);
- var MIN_ZOOM = 0.2,
- MAX_ZOOM = 4;
- var mouseEvents = [
- 'mousedown',
- 'mouseup',
- 'mouseover',
- 'mouseout',
- 'click',
- 'dblclick'
- ];
- function log() {
- if (false) {
- console.log.apply(console, arguments);
- }
- }
- function get(service, injector) {
- try {
- return injector.get(service);
- } catch (e) {
- return null;
- }
- }
- function createTouchRecognizer(node) {
- function stopEvent(event) {
- Event.stopEvent(event, true);
- }
- function stopMouse(event) {
- forEach(mouseEvents, function(e) {
- domEvent.bind(node, e, stopEvent, true);
- });
- }
- function allowMouse(event) {
- setTimeout(function() {
- forEach(mouseEvents, function(e) {
- domEvent.unbind(node, e, stopEvent, true);
- });
- }, 500);
- }
- domEvent.bind(node, 'touchstart', stopMouse, true);
- domEvent.bind(node, 'touchend', allowMouse, true);
- domEvent.bind(node, 'touchcancel', allowMouse, true);
- // A touch event recognizer that handles
- // touch events only (we know, we can already handle
- // mouse events out of the box)
- var recognizer = new Hammer.Manager(node, {
- inputClass: Hammer.TouchInput,
- recognizers: []
- });
- var tap = new Hammer.Tap();
- var pan = new Hammer.Pan({ threshold: 10 });
- var press = new Hammer.Press();
- var pinch = new Hammer.Pinch();
- var doubleTap = new Hammer.Tap({ event: 'doubletap', taps: 2 });
- pinch.requireFailure(pan);
- pinch.requireFailure(press);
- recognizer.add([ pan, press, pinch, doubleTap, tap ]);
- recognizer.reset = function(force) {
- var recognizers = this.recognizers,
- session = this.session;
- if (session.stopped) {
- return;
- }
- log('recognizer', 'stop');
- recognizer.stop(force);
- setTimeout(function() {
- var i, r;
- log('recognizer', 'reset');
- for (i = 0; !!(r = recognizers[i]); i++) {
- r.reset();
- r.state = 8; // FAILED STATE
- }
- session.curRecognizer = null;
- }, 0);
- };
- recognizer.on('hammer.input', function(event) {
- if (event.srcEvent.defaultPrevented) {
- recognizer.reset(true);
- }
- });
- return recognizer;
- }
- /**
- * A plugin that provides touch events for elements.
- *
- * @param {EventBus} eventBus
- * @param {InteractionEvents} interactionEvents
- */
- function TouchInteractionEvents(injector, canvas, eventBus, elementRegistry, interactionEvents, snap) {
- // optional integrations
- var dragging = get('dragging', injector),
- move = get('move', injector),
- contextPad = get('contextPad', injector),
- palette = get('palette', injector);
- // the touch recognizer
- var recognizer;
- function handler(type) {
- return function(event) {
- log('element', type, event);
- interactionEvents.fire(type, event);
- };
- }
- function getGfx(target) {
- var node = domClosest(target, 'svg, .djs-element', true);
- return node && new Snap(node);
- }
- function initEvents(svg) {
- // touch recognizer
- recognizer = createTouchRecognizer(svg);
- recognizer.on('doubletap', handler('element.dblclick'));
- recognizer.on('tap', handler('element.click'));
- function startGrabCanvas(event) {
- log('canvas', 'grab start');
- var lx = 0, ly = 0;
- function update(e) {
- var dx = e.deltaX - lx,
- dy = e.deltaY - ly;
- canvas.scroll({ dx: dx, dy: dy });
- lx = e.deltaX;
- ly = e.deltaY;
- }
- function end(e) {
- recognizer.off('panmove', update);
- recognizer.off('panend', end);
- recognizer.off('pancancel', end);
- log('canvas', 'grab end');
- }
- recognizer.on('panmove', update);
- recognizer.on('panend', end);
- recognizer.on('pancancel', end);
- }
- function startGrab(event) {
- var gfx = getGfx(event.target),
- element = gfx && elementRegistry.get(gfx);
- // recognizer
- if (move && canvas.getRootElement() !== element) {
- log('element', 'move start', element, event, true);
- return move.start(event, element, true);
- } else {
- startGrabCanvas(event);
- }
- }
- function startZoom(e) {
- log('canvas', 'zoom start');
- var zoom = canvas.zoom(),
- mid = e.center;
- function update(e) {
- var ratio = 1 - (1 - e.scale) / 1.50,
- newZoom = Math.max(MIN_ZOOM, Math.min(MAX_ZOOM, ratio * zoom));
- canvas.zoom(newZoom, mid);
- Event.stopEvent(e, true);
- }
- function end(e) {
- recognizer.off('pinchmove', update);
- recognizer.off('pinchend', end);
- recognizer.off('pinchcancel', end);
- recognizer.reset(true);
- log('canvas', 'zoom end');
- }
- recognizer.on('pinchmove', update);
- recognizer.on('pinchend', end);
- recognizer.on('pinchcancel', end);
- }
- recognizer.on('panstart', startGrab);
- recognizer.on('press', startGrab);
- recognizer.on('pinchstart', startZoom);
- }
- if (dragging) {
- // simulate hover during dragging
- eventBus.on('drag.move', function(event) {
- var position = Event.toPoint(event.originalEvent);
- var node = document.elementFromPoint(position.x, position.y),
- gfx = getGfx(node),
- element = gfx && elementRegistry.get(gfx);
- if (element !== event.hover) {
- if (event.hover) {
- dragging.out(event);
- }
- if (element) {
- dragging.hover({ element: element, gfx: gfx });
- event.hover = element;
- event.hoverGfx = gfx;
- }
- }
- });
- }
- if (contextPad) {
- eventBus.on('contextPad.create', function(event) {
- var node = event.pad.html;
- // touch recognizer
- var padRecognizer = createTouchRecognizer(node);
- padRecognizer.on('panstart', function(event) {
- log('context-pad', 'panstart', event);
- contextPad.trigger('dragstart', event, true);
- });
- padRecognizer.on('press', function(event) {
- log('context-pad', 'press', event);
- contextPad.trigger('dragstart', event, true);
- });
- padRecognizer.on('tap', function(event) {
- log('context-pad', 'tap', event);
- contextPad.trigger('click', event);
- });
- });
- }
- if (palette) {
- eventBus.on('palette.create', function(event) {
- var node = event.html;
- // touch recognizer
- var padRecognizer = createTouchRecognizer(node);
- padRecognizer.on('panstart', function(event) {
- log('palette', 'panstart', event);
- palette.trigger('dragstart', event, true);
- });
- padRecognizer.on('press', function(event) {
- log('palette', 'press', event);
- palette.trigger('dragstart', event, true);
- });
- padRecognizer.on('tap', function(event) {
- log('palette', 'tap', event);
- palette.trigger('click', event);
- });
- });
- }
- eventBus.on('canvas.init', function(event) {
- initEvents(event.svg.node);
- });
- }
- TouchInteractionEvents.$inject = [
- 'injector',
- 'canvas',
- 'eventBus',
- 'elementRegistry',
- 'interactionEvents',
- 'touchFix'
- ];
- module.exports = TouchInteractionEvents;
- },{"187":187,"198":198,"200":200,"218":218,"354":354,"357":357}],171:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(108) ],
- __init__: [ 'touchInteractionEvents' ],
- touchInteractionEvents: [ 'type', _dereq_(170) ],
- touchFix: [ 'type', _dereq_(169) ]
- };
- },{"108":108,"169":169,"170":170}],172:[function(_dereq_,module,exports){
- 'use strict';
- var getMid = _dereq_(174).getMid;
- /**
- * A base connection layouter implementation
- * that layouts the connection by directly connecting
- * mid(source) + mid(target).
- */
- function BaseLayouter() {}
- module.exports = BaseLayouter;
- /**
- * Return the new layouted waypoints for the given connection.
- *
- * @param {djs.model.Connection} connection
- * @param {Object} hints
- * @param {Boolean} [hints.movedStart=false]
- * @param {Boolean} [hints.movedEnd=false]
- *
- * @return {Array<Point>} the layouted connection waypoints
- */
- BaseLayouter.prototype.layoutConnection = function(connection, hints) {
- return [
- getMid(connection.source),
- getMid(connection.target)
- ];
- };
- },{"174":174}],173:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339);
- var LayoutUtil = _dereq_(174);
- function dockingToPoint(docking) {
- // use the dockings actual point and
- // retain the original docking
- return assign({ original: docking.point.original || docking.point }, docking.actual);
- }
- /**
- * A {@link ConnectionDocking} that crops connection waypoints based on
- * the path(s) of the connection source and target.
- *
- * @param {djs.core.ElementRegistry} elementRegistry
- */
- function CroppingConnectionDocking(elementRegistry, renderer) {
- this._elementRegistry = elementRegistry;
- this._renderer = renderer;
- }
- CroppingConnectionDocking.$inject = [ 'elementRegistry', 'renderer' ];
- module.exports = CroppingConnectionDocking;
- /**
- * @inheritDoc ConnectionDocking#getCroppedWaypoints
- */
- CroppingConnectionDocking.prototype.getCroppedWaypoints = function(connection, source, target) {
- source = source || connection.source;
- target = target || connection.target;
- var sourceDocking = this.getDockingPoint(connection, source, true),
- targetDocking = this.getDockingPoint(connection, target);
- var croppedWaypoints = connection.waypoints.slice(sourceDocking.idx + 1, targetDocking.idx);
- croppedWaypoints.unshift(dockingToPoint(sourceDocking));
- croppedWaypoints.push(dockingToPoint(targetDocking));
- return croppedWaypoints;
- };
- /**
- * Return the connection docking point on the specified shape
- *
- * @inheritDoc ConnectionDocking#getDockingPoint
- */
- CroppingConnectionDocking.prototype.getDockingPoint = function(connection, shape, dockStart) {
- var waypoints = connection.waypoints,
- dockingIdx,
- dockingPoint,
- croppedPoint;
- dockingIdx = dockStart ? 0 : waypoints.length - 1;
- dockingPoint = waypoints[dockingIdx];
- croppedPoint = this._getIntersection(shape, connection, dockStart);
- return {
- point: dockingPoint,
- actual: croppedPoint || dockingPoint,
- idx: dockingIdx
- };
- };
- ////// helper methods ///////////////////////////////////////////////////
- CroppingConnectionDocking.prototype._getIntersection = function(shape, connection, takeFirst) {
- var shapePath = this._getShapePath(shape),
- connectionPath = this._getConnectionPath(connection);
- return LayoutUtil.getElementLineIntersection(shapePath, connectionPath, takeFirst);
- };
- CroppingConnectionDocking.prototype._getConnectionPath = function(connection) {
- return this._renderer.getConnectionPath(connection);
- };
- CroppingConnectionDocking.prototype._getShapePath = function(shape) {
- return this._renderer.getShapePath(shape);
- };
- CroppingConnectionDocking.prototype._getGfx = function(element) {
- return this._elementRegistry.getGraphics(element);
- };
- },{"174":174,"339":339}],174:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- isObject = _dereq_(334),
- sortBy = _dereq_(225);
- var Snap = _dereq_(200);
- var ALIGNED_THRESHOLD = 2;
- /**
- * Returns whether two points are in a horizontal or vertical line.
- *
- * @param {Point} a
- * @param {Point} b
- *
- * @return {String|Boolean} returns false if the points are not
- * aligned or 'h|v' if they are aligned
- * horizontally / vertically.
- */
- function pointsAligned(a, b) {
- if (Math.abs(a.x - b.x) <= ALIGNED_THRESHOLD) {
- return 'h';
- }
- if (Math.abs(a.y - b.y) <= ALIGNED_THRESHOLD) {
- return 'v';
- }
- return false;
- }
- module.exports.pointsAligned = pointsAligned;
- function roundPoint(point) {
- return {
- x: Math.round(point.x),
- y: Math.round(point.y)
- };
- }
- module.exports.roundPoint = roundPoint;
- function pointsEqual(a, b) {
- return a.x === b.x && a.y === b.y;
- }
- module.exports.pointsEqual = pointsEqual;
- function pointDistance(a, b) {
- return Math.sqrt(Math.pow(a.x - b.x, 2) + Math.pow(a.y - b.y, 2));
- }
- module.exports.pointDistance = pointDistance;
- /**
- * Convert the given bounds to a { top, left, bottom, right } descriptor.
- *
- * @param {Bounds|Point} bounds
- *
- * @return {Object}
- */
- function asTRBL(bounds) {
- return {
- top: bounds.y,
- right: bounds.x + (bounds.width || 0),
- bottom: bounds.y + (bounds.height || 0),
- left: bounds.x
- };
- }
- module.exports.asTRBL = asTRBL;
- /**
- * Get the mid of the given bounds or point.
- *
- * @param {Bounds|Point} bounds
- *
- * @return {Point}
- */
- function getMid(bounds) {
- return roundPoint({
- x: bounds.x + (bounds.width || 0) / 2,
- y: bounds.y + (bounds.height || 0) / 2
- });
- }
- module.exports.getMid = getMid;
- ////// orientation utils //////////////////////////////
- /**
- * Get orientation of the given rectangle with respect to
- * the reference rectangle.
- *
- * A padding (positive or negative) may be passed to influence
- * horizontal / vertical orientation and intersection.
- *
- * @param {Bounds} rect
- * @param {Bounds} reference
- * @param {Point|Number} padding
- *
- * @return {String} the orientation; one of top, top-left, left, ..., bottom, right or intersect.
- */
- function getOrientation(rect, reference, padding) {
- padding = padding || 0;
- // make sure we can use an object, too
- // for individual { x, y } padding
- if (!isObject(padding)) {
- padding = { x: padding, y: padding };
- }
- var rectOrientation = asTRBL(rect),
- referenceOrientation = asTRBL(reference);
- var top = rectOrientation.bottom + padding.y <= referenceOrientation.top,
- right = rectOrientation.left - padding.x >= referenceOrientation.right,
- bottom = rectOrientation.top - padding.y >= referenceOrientation.bottom,
- left = rectOrientation.right + padding.x <= referenceOrientation.left;
- var vertical = top ? 'top' : (bottom ? 'bottom' : null),
- horizontal = left ? 'left' : (right ? 'right' : null);
- if (horizontal && vertical) {
- return vertical + '-' + horizontal;
- } else {
- return horizontal || vertical || 'intersect';
- }
- }
- module.exports.getOrientation = getOrientation;
- function hasAnyOrientation(rect, reference, pointDistance, locations) {
- if (isArray(pointDistance)) {
- locations = pointDistance;
- pointDistance = 0;
- }
- var orientation = getOrientation(rect, reference, pointDistance);
- return locations.indexOf(orientation) !== -1;
- }
- module.exports.hasAnyOrientation = hasAnyOrientation;
- ////// intersection utils //////////////////////////////
- function getElementLineIntersection(elementPath, linePath, cropStart) {
- var intersections = getIntersections(elementPath, linePath);
- // recognize intersections
- // only one -> choose
- // two close together -> choose first
- // two or more distinct -> pull out appropriate one
- // none -> ok (fallback to point itself)
- if (intersections.length === 1) {
- return roundPoint(intersections[0]);
- } else if (intersections.length === 2 && pointDistance(intersections[0], intersections[1]) < 1) {
- return roundPoint(intersections[0]);
- } else if (intersections.length > 1) {
- // sort by intersections based on connection segment +
- // distance from start
- intersections = sortBy(intersections, function(i) {
- var distance = Math.floor(i.t2 * 100) || 1;
- distance = 100 - distance;
- distance = (distance < 10 ? '0' : '') + distance;
- // create a sort string that makes sure we sort
- // line segment ASC + line segment position DESC (for cropStart)
- // line segment ASC + line segment position ASC (for cropEnd)
- return i.segment2 + '#' + distance;
- });
- return roundPoint(intersections[cropStart ? 0 : intersections.length - 1]);
- }
- return null;
- }
- module.exports.getElementLineIntersection = getElementLineIntersection;
- function getIntersections(a, b) {
- return Snap.path.intersection(a, b);
- }
- module.exports.getIntersections = getIntersections;
- },{"200":200,"225":225,"330":330,"334":334}],175:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- find = _dereq_(217),
- without = _dereq_(212),
- assign = _dereq_(339);
- var LayoutUtil = _dereq_(174),
- Geometry = _dereq_(188);
- var getOrientation = LayoutUtil.getOrientation,
- getMid = LayoutUtil.getMid,
- pointsAligned = LayoutUtil.pointsAligned;
- var pointInRect = Geometry.pointInRect,
- pointDistance = Geometry.pointDistance;
- var INTERSECTION_THRESHOLD = 20,
- ORIENTATION_THRESHOLD = {
- 'h:h': 20,
- 'v:v': 20,
- 'h:v': -10,
- 'v:h': -10
- };
- /**
- * Returns the mid points for a manhattan connection between two points.
- *
- * @example
- *
- * [a]----[x]
- * |
- * [x]----[b]
- *
- * @example
- *
- * [a]----[x]
- * |
- * [b]
- *
- * @param {Point} a
- * @param {Point} b
- * @param {String} directions
- *
- * @return {Array<Point>}
- */
- module.exports.getBendpoints = function(a, b, directions) {
- directions = directions || 'h:h';
- var xmid, ymid;
- // one point, next to a
- if (directions === 'h:v') {
- return [ { x: b.x, y: a.y } ];
- } else
- // one point, above a
- if (directions === 'v:h') {
- return [ { x: a.x, y: b.y } ];
- } else
- // vertical edge xmid
- if (directions === 'h:h') {
- xmid = Math.round((b.x - a.x) / 2 + a.x);
- return [
- { x: xmid, y: a.y },
- { x: xmid, y: b.y }
- ];
- } else
- // horizontal edge ymid
- if (directions === 'v:v') {
- ymid = Math.round((b.y - a.y) / 2 + a.y);
- return [
- { x: a.x, y: ymid },
- { x: b.x, y: ymid }
- ];
- } else {
- throw new Error(
- 'unknown directions: <' + directions + '>: ' +
- 'directions must be specified as {a direction}:{b direction} (direction in h|v)');
- }
- };
- /**
- * Create a connection between the two points according
- * to the manhattan layout (only horizontal and vertical) edges.
- *
- * @param {Point} a
- * @param {Point} b
- *
- * @param {String} [directions='h:h'] specifies manhattan directions for each point as {adirection}:{bdirection}.
- A directionfor a point is either `h` (horizontal) or `v` (vertical)
- *
- * @return {Array<Point>}
- */
- module.exports.connectPoints = function(a, b, directions) {
- var points = [];
- if (!pointsAligned(a, b)) {
- points = this.getBendpoints(a, b, directions);
- }
- points.unshift(a);
- points.push(b);
- return points;
- };
- /**
- * Connect two rectangles using a manhattan layouted connection.
- *
- * @param {Bounds} source source rectangle
- * @param {Bounds} target target rectangle
- * @param {Point} [start] source docking
- * @param {Point} [end] target docking
- *
- * @param {Object} [hints]
- * @param {Array<String>} [hints.preferredLayouts]
- *
- * @return {Array<Point>} connection points
- */
- module.exports.connectRectangles = function(source, target, start, end, hints) {
- var preferredLayouts = hints && hints.preferredLayouts || [];
- var preferredLayout = without(preferredLayouts, 'straight')[0] || 'h:h';
- var threshold = ORIENTATION_THRESHOLD[preferredLayout] || 0;
- var orientation = getOrientation(source, target, threshold);
- var directions = getDirections(orientation, preferredLayout);
- start = start || getMid(source);
- end = end || getMid(target);
- // overlapping elements
- if (!directions) {
- return;
- }
- if (directions === 'h:h') {
- switch (orientation) {
- case 'top-right':
- case 'right':
- case 'bottom-right':
- start = { original: start, x: source.x, y: start.y };
- end = { original: end, x: target.x + target.width, y: end.y };
- break;
- case 'top-left':
- case 'left':
- case 'bottom-left':
- start = { original: start, x: source.x + source.width, y: start.y };
- end = { original: end, x: target.x, y: end.y };
- break;
- }
- }
- if (directions === 'v:v') {
- switch (orientation) {
- case 'top-left':
- case 'top':
- case 'top-right':
- start = { original: start, x: start.x, y: source.y + source.height };
- end = { original: end, x: end.x, y: target.y };
- break;
- case 'bottom-left':
- case 'bottom':
- case 'bottom-right':
- start = { original: start, x: start.x, y: source.y };
- end = { original: end, x: end.x, y: target.y + target.height };
- break;
- }
- }
- return this.connectPoints(start, end, directions);
- };
- /**
- * Repair the connection between two rectangles, of which one has been updated.
- *
- * @param {Bounds} source
- * @param {Bounds} target
- * @param {Point} [start]
- * @param {Point} [end]
- * @param {Array<Point>} waypoints
- * @param {Object} [hints]
- * @param {Array<String>} [hints.preferredLayouts] list of preferred layouts
- * @param {Boolean} [hints.startChanged]
- * @param {Boolean} [hints.endChanged]
- *
- * @return {Array<Point>} repaired waypoints
- */
- module.exports.repairConnection = function(source, target, start, end, waypoints, hints) {
- if (isArray(start)) {
- waypoints = start;
- hints = end;
- start = getMid(source);
- end = getMid(target);
- }
- hints = assign({ preferredLayouts: [] }, hints);
- var preferredLayouts = hints.preferredLayouts,
- layoutStraight = preferredLayouts.indexOf('straight') !== -1,
- repairedWaypoints;
- // just layout non-existing or simple connections
- // attempt to render straight lines, if required
- if (!waypoints || waypoints.length < 3) {
- if (layoutStraight) {
- // attempt to layout a straight line
- repairedWaypoints = this.layoutStraight(source, target, start, end, hints);
- }
- } else {
- // check if we layout from start or end
- if (hints.endChanged) {
- repairedWaypoints = this._repairConnectionSide(target, source, end, waypoints.slice().reverse());
- repairedWaypoints = repairedWaypoints && repairedWaypoints.reverse();
- } else
- if (hints.startChanged) {
- repairedWaypoints = this._repairConnectionSide(source, target, start, waypoints);
- }
- // or whether nothing seems to have changed
- else {
- repairedWaypoints = waypoints;
- }
- }
- // simply reconnect if nothing else worked
- if (!repairedWaypoints) {
- repairedWaypoints = this.connectRectangles(source, target, start, end, hints);
- }
- return repairedWaypoints;
- };
- var max = Math.max,
- min = Math.min;
- function inRange(a, start, end) {
- return a >= start && a <= end;
- }
- module.exports.layoutStraight = function(source, target, start, end, hints) {
- var startX, endX, x,
- startY, endY, y;
- startX = max(source.x + 10, target.x + 10);
- endX = min(source.x + source.width - 10, target.x + target.width - 10);
- if (startX < endX) {
- if (source.width === target.width) {
- if (hints.endChanged && inRange(end.x, startX, endX)) {
- x = end.x;
- } else
- if (inRange(start.x, startX, endX)) {
- x = start.x;
- }
- }
- if (x === undefined) {
- if (source.width < target.width && inRange(start.x, startX, endX)) {
- x = start.x;
- } else
- if (source.width > target.width && inRange(end.x, startX, endX)) {
- x = end.x;
- } else {
- x = (startX + endX) / 2;
- }
- }
- }
- startY = max(source.y + 10, target.y + 10);
- endY = min(source.y + source.height - 10, target.y + target.height - 10);
- if (startY < endY) {
- if (source.height === target.height) {
- if (hints.endChanged && inRange(end.y, startY, endY)) {
- y = end.y;
- } else
- if (inRange(start.y, startY, endY)) {
- y = start.y;
- }
- }
- if (y === undefined) {
- if (source.height <= target.height && inRange(start.y, startY, endY)) {
- y = start.y;
- } else
- if (target.height <= source.height && inRange(end.y, startY, endY)) {
- y = end.y;
- } else {
- y = (startY + endY) / 2;
- }
- }
- }
- // cannot layout straight
- if (x === undefined && y === undefined) {
- return null;
- }
- return [
- {
- x: x !== undefined ? x : start.x,
- y: y !== undefined ? y : start.y
- },
- {
- x: x !== undefined ? x : end.x,
- y: y !== undefined ? y : end.y
- }
- ];
- };
- /**
- * Repair a connection from one side that moved.
- *
- * @param {Bounds} moved
- * @param {Bounds} other
- * @param {Point} newDocking
- * @param {Array<Point>} points originalPoints from moved to other
- *
- * @return {Array<Point>} the repaired points between the two rectangles
- */
- module.exports._repairConnectionSide = function(moved, other, newDocking, points) {
- function needsRelayout(moved, other, points) {
- if (points.length < 3) {
- return true;
- }
- if (points.length > 4) {
- return false;
- }
- // relayout if two points overlap
- // this is most likely due to
- return !!find(points, function(p, idx) {
- var q = points[idx - 1];
- return q && pointDistance(p, q) < 3;
- });
- }
- function repairBendpoint(candidate, oldPeer, newPeer) {
- var alignment = pointsAligned(oldPeer, candidate);
- switch (alignment) {
- case 'v':
- // repair vertical alignment
- return { x: candidate.x, y: newPeer.y };
- case 'h':
- // repair horizontal alignment
- return { x: newPeer.x, y: candidate.y };
- }
- return { x: candidate.x, y: candidate. y };
- }
- function removeOverlapping(points, a, b) {
- var i;
- for (i = points.length - 2; i !== 0; i--) {
- // intersects (?) break, remove all bendpoints up to this one and relayout
- if (pointInRect(points[i], a, INTERSECTION_THRESHOLD) ||
- pointInRect(points[i], b, INTERSECTION_THRESHOLD)) {
- // return sliced old connection
- return points.slice(i);
- }
- }
- return points;
- }
- // (0) only repair what has layoutable bendpoints
- // (1) if only one bendpoint and on shape moved onto other shapes axis
- // (horizontally / vertically), relayout
- if (needsRelayout(moved, other, points)) {
- return null;
- }
- var oldDocking = points[0],
- newPoints = points.slice(),
- slicedPoints;
- // (2) repair only last line segment and only if it was layouted before
- newPoints[0] = newDocking;
- newPoints[1] = repairBendpoint(newPoints[1], oldDocking, newDocking);
- // (3) if shape intersects with any bendpoint after repair,
- // remove all segments up to this bendpoint and repair from there
- slicedPoints = removeOverlapping(newPoints, moved, other);
- if (slicedPoints !== newPoints) {
- return this._repairConnectionSide(moved, other, newDocking, slicedPoints);
- }
- return newPoints;
- };
- /**
- * Returns the manhattan directions connecting two rectangles
- * with the given orientation.
- *
- * @example
- *
- * getDirections('top'); // -> 'v:v'
- *
- * getDirections('top-right', 'v:h'); // -> 'v:h'
- * getDirections('top-right', 'h:h'); // -> 'h:h'
- *
- *
- * @param {String} orientation
- * @param {String} defaultLayout
- *
- * @return {String}
- */
- function getDirections(orientation, defaultLayout) {
- switch (orientation) {
- case 'intersect':
- return null;
- case 'top':
- case 'bottom':
- return 'v:v';
- case 'left':
- case 'right':
- return 'h:h';
- // 'top-left'
- // 'top-right'
- // 'bottom-left'
- // 'bottom-right'
- default:
- return defaultLayout;
- }
- }
- },{"174":174,"188":188,"212":212,"217":217,"330":330,"339":339}],176:[function(_dereq_,module,exports){
- 'use strict';
- var assign = _dereq_(339),
- inherits = _dereq_(207);
- var Refs = _dereq_(369);
- var parentRefs = new Refs({ name: 'children', enumerable: true, collection: true }, { name: 'parent' }),
- labelRefs = new Refs({ name: 'label', enumerable: true }, { name: 'labelTarget' }),
- attacherRefs = new Refs({ name: 'attachers', collection: true }, { name: 'host' }),
- outgoingRefs = new Refs({ name: 'outgoing', collection: true }, { name: 'source' }),
- incomingRefs = new Refs({ name: 'incoming', collection: true }, { name: 'target' });
- /**
- * @namespace djs.model
- */
- /**
- * @memberOf djs.model
- */
- /**
- * The basic graphical representation
- *
- * @class
- *
- * @abstract
- */
- function Base() {
- /**
- * The object that backs up the shape
- *
- * @name Base#businessObject
- * @type Object
- */
- Object.defineProperty(this, 'businessObject', {
- writable: true
- });
- /**
- * The parent shape
- *
- * @name Base#parent
- * @type Shape
- */
- parentRefs.bind(this, 'parent');
- /**
- * @name Base#label
- * @type Label
- */
- labelRefs.bind(this, 'label');
- /**
- * The list of outgoing connections
- *
- * @name Base#outgoing
- * @type Array<Connection>
- */
- outgoingRefs.bind(this, 'outgoing');
- /**
- * The list of outgoing connections
- *
- * @name Base#incoming
- * @type Array<Connection>
- */
- incomingRefs.bind(this, 'incoming');
- }
- /**
- * A graphical object
- *
- * @class
- * @constructor
- *
- * @extends Base
- */
- function Shape() {
- Base.call(this);
- /**
- * The list of children
- *
- * @name Shape#children
- * @type Array<Base>
- */
- parentRefs.bind(this, 'children');
- /**
- * @name Shape#host
- * @type Shape
- */
- attacherRefs.bind(this, 'host');
- /**
- * @name Shape#attachers
- * @type Shape
- */
- attacherRefs.bind(this, 'attachers');
- }
- inherits(Shape, Base);
- /**
- * A root graphical object
- *
- * @class
- * @constructor
- *
- * @extends Shape
- */
- function Root() {
- Shape.call(this);
- }
- inherits(Root, Shape);
- /**
- * A label for an element
- *
- * @class
- * @constructor
- *
- * @extends Shape
- */
- function Label() {
- Shape.call(this);
- /**
- * The labeled element
- *
- * @name Label#labelTarget
- * @type Base
- */
- labelRefs.bind(this, 'labelTarget');
- }
- inherits(Label, Shape);
- /**
- * A connection between two elements
- *
- * @class
- * @constructor
- *
- * @extends Base
- */
- function Connection() {
- Base.call(this);
- /**
- * The element this connection originates from
- *
- * @name Connection#source
- * @type Base
- */
- outgoingRefs.bind(this, 'source');
- /**
- * The element this connection points to
- *
- * @name Connection#target
- * @type Base
- */
- incomingRefs.bind(this, 'target');
- }
- inherits(Connection, Base);
- var types = {
- connection: Connection,
- shape: Shape,
- label: Label,
- root: Root
- };
- /**
- * Creates a new model element of the specified type
- *
- * @method create
- *
- * @example
- *
- * var shape1 = Model.create('shape', { x: 10, y: 10, width: 100, height: 100 });
- * var shape2 = Model.create('shape', { x: 210, y: 210, width: 100, height: 100 });
- *
- * var connection = Model.create('connection', { waypoints: [ { x: 110, y: 55 }, {x: 210, y: 55 } ] });
- *
- * @param {String} type lower-cased model name
- * @param {Object} attrs attributes to initialize the new model instance with
- *
- * @return {Base} the new model instance
- */
- module.exports.create = function(type, attrs) {
- var Type = types[type];
- if (!Type) {
- throw new Error('unknown type: <' + type + '>');
- }
- return assign(new Type(), attrs);
- };
- module.exports.Base = Base;
- module.exports.Root = Root;
- module.exports.Shape = Shape;
- module.exports.Connection = Connection;
- module.exports.Label = Label;
- },{"207":207,"339":339,"369":369}],177:[function(_dereq_,module,exports){
- 'use strict';
- var Cursor = _dereq_(185),
- ClickTrap = _dereq_(183),
- domEvent = _dereq_(357),
- Event = _dereq_(187);
- function substract(p1, p2) {
- return {
- x: p1.x - p2.x,
- y: p1.y - p2.y
- };
- }
- function length(point) {
- return Math.sqrt(Math.pow(point.x, 2) + Math.pow(point.y, 2));
- }
- var THRESHOLD = 15;
- function MoveCanvas(eventBus, canvas) {
- var container = canvas._container,
- context;
- function handleMove(event) {
- var start = context.start,
- position = Event.toPoint(event),
- delta = substract(position, start);
- if (!context.dragging && length(delta) > THRESHOLD) {
- context.dragging = true;
- // prevent mouse click in this
- // interaction sequence
- ClickTrap.install();
- Cursor.set('move');
- }
- if (context.dragging) {
- var lastPosition = context.last || context.start;
- delta = substract(position, lastPosition);
- canvas.scroll({
- dx: delta.x,
- dy: delta.y
- });
- context.last = position;
- }
- // prevent select
- event.preventDefault();
- }
- function handleEnd(event) {
- domEvent.unbind(document, 'mousemove', handleMove);
- domEvent.unbind(document, 'mouseup', handleEnd);
- context = null;
- Cursor.unset();
- // prevent select
- Event.stopEvent(event);
- }
- function handleStart(event) {
- // reject non-left left mouse button or modifier key
- if (event.button || event.ctrlKey || event.shiftKey || event.altKey) {
- return;
- }
- context = {
- start: Event.toPoint(event)
- };
- domEvent.bind(document, 'mousemove', handleMove);
- domEvent.bind(document, 'mouseup', handleEnd);
- // prevent select
- Event.stopEvent(event);
- }
- domEvent.bind(container, 'mousedown', handleStart);
- }
- MoveCanvas.$inject = [ 'eventBus', 'canvas' ];
- module.exports = MoveCanvas;
- },{"183":183,"185":185,"187":187,"357":357}],178:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'moveCanvas' ],
- moveCanvas: [ 'type', _dereq_(177) ]
- };
- },{"177":177}],179:[function(_dereq_,module,exports){
- module.exports = {
- __depends__: [ _dereq_(171) ]
- };
- },{"171":171}],180:[function(_dereq_,module,exports){
- 'use strict';
- var domEvent = _dereq_(357);
- var hasPrimaryModifier = _dereq_(193).hasPrimaryModifier,
- hasSecondaryModifier = _dereq_(193).hasSecondaryModifier;
- var isMac = _dereq_(194).isMac;
- var getStepRange = _dereq_(181).getStepRange,
- cap = _dereq_(181).cap;
- var log10 = _dereq_(192).log10;
- var RANGE = { min: 0.2, max: 4 },
- NUM_STEPS = 10;
- /**
- * An implementation of zooming and scrolling within the {@link Canvas}.
- *
- * @param {EventBus} eventBus
- * @param {Canvas} canvas
- */
- function ZoomScroll(eventBus, canvas) {
- this._canvas = canvas;
- var self = this;
- eventBus.on('canvas.init', function(e) {
- self._init(canvas._container);
- });
- }
- ZoomScroll.prototype.scroll = function scroll(delta) {
- this._canvas.scroll(delta);
- };
- ZoomScroll.prototype.reset = function reset() {
- this._canvas.zoom('fit-viewport');
- };
- ZoomScroll.prototype.zoom = function zoom(direction, position) {
- var canvas = this._canvas;
- var currentZoom = canvas.zoom();
- var factor = Math.pow(1 + Math.abs(direction) , direction > 0 ? 1 : -1);
- canvas.zoom(cap(RANGE, currentZoom * factor), position);
- };
- /**
- * Zoom along fixed zoom steps
- *
- * @param {Integer} direction zoom direction (1 for zooming in, -1 for out)
- */
- ZoomScroll.prototype.stepZoom = function stepZoom(direction, position) {
- var canvas = this._canvas,
- stepRange = getStepRange(RANGE, NUM_STEPS);
- direction = direction > 0 ? 1 : -1;
- var currentLinearZoomLevel = log10(canvas.zoom());
- // snap to a proximate zoom step
- var newLinearZoomLevel = Math.round(currentLinearZoomLevel / stepRange) * stepRange;
- // increase or decrease one zoom step in the given direction
- newLinearZoomLevel += stepRange * direction;
- // calculate the absolute logarithmic zoom level based on the linear zoom level
- // (e.g. 2 for an absolute x2 zoom)
- var newLogZoomLevel = Math.pow(10, newLinearZoomLevel);
- canvas.zoom(cap(RANGE, newLogZoomLevel), position);
- };
- ZoomScroll.prototype._init = function(element) {
- var self = this;
- domEvent.bind(element, 'wheel', function(event) {
- event.preventDefault();
- // mouse-event: SELECTION_KEY
- // mouse-event: AND_KEY
- var isVerticalScroll = hasPrimaryModifier(event),
- isHorizontalScroll = hasSecondaryModifier(event);
- var factor;
- if (isVerticalScroll || isHorizontalScroll) {
- if (isMac) {
- factor = event.deltaMode === 0 ? 1.25 : 50;
- } else {
- factor = event.deltaMode === 0 ? 1/40 : 1/2;
- }
- var delta = {};
- if (isHorizontalScroll) {
- delta.dx = (factor * (event.deltaX || event.deltaY));
- } else {
- delta.dy = (factor * event.deltaY);
- }
- self.scroll(delta);
- } else {
- factor = (event.deltaMode === 0 ? 1/40 : 1/2);
- var elementRect = element.getBoundingClientRect();
- var offset = {
- x: event.clientX - elementRect.left,
- y: event.clientY - elementRect.top
- };
- // zoom in relative to diagram {x,y} coordinates
- self.zoom(event.deltaY * factor / (-5), offset);
- }
- });
- };
- ZoomScroll.$inject = [ 'eventBus', 'canvas' ];
- module.exports = ZoomScroll;
- },{"181":181,"192":192,"193":193,"194":194,"357":357}],181:[function(_dereq_,module,exports){
- 'use strict';
- var log10 = _dereq_(192).log10;
- /**
- * Get the linear range between two zoom steps based on the
- * total number of zoom steps (defined as NUM_STEPS)
- */
- module.exports.getStepRange = function(range, steps) {
- var minLinearRange = log10(range.min),
- maxLinearRange = log10(range.max);
- var absoluteLinearRange = Math.abs(minLinearRange) + Math.abs(maxLinearRange);
- return absoluteLinearRange / steps;
- };
- module.exports.cap = function(range, scale) {
- return Math.max(range.min, Math.min(range.max, scale));
- };
- },{"192":192}],182:[function(_dereq_,module,exports){
- module.exports = {
- __init__: [ 'zoomScroll' ],
- zoomScroll: [ 'type', _dereq_(180) ]
- };
- },{"180":180}],183:[function(_dereq_,module,exports){
- 'use strict';
- var domEvent = _dereq_(357),
- stopEvent = _dereq_(187).stopEvent;
- function trap(event) {
- stopEvent(event);
- toggle(false);
- }
- function toggle(active) {
- domEvent[active ? 'bind' : 'unbind'](document.body, 'click', trap, true);
- }
- /**
- * Installs a click trap that prevents a ghost click following a dragging operation.
- *
- * @return {Function} a function to immediately remove the installed trap.
- */
- function install() {
- toggle(true);
- return function() {
- toggle(false);
- };
- }
- module.exports.install = install;
- },{"187":187,"357":357}],184:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Failsafe remove an element from a collection
- *
- * @param {Array<Object>} [collection]
- * @param {Object} [element]
- *
- * @return {Object} the element that got removed or undefined
- */
- module.exports.remove = function(collection, element) {
- if (!collection || !element) {
- return;
- }
- var idx = collection.indexOf(element);
- if (idx === -1) {
- return;
- }
- collection.splice(idx, 1);
- return element;
- };
- /**
- * Fail save add an element to the given connection, ensuring
- * it does not yet exist.
- *
- * @param {Array<Object>} collection
- * @param {Object} element
- * @param {Number} idx
- */
- module.exports.add = function(collection, element, idx) {
- if (!collection || !element) {
- return;
- }
- if (isNaN(idx)) {
- idx = -1;
- }
- var currentIdx = collection.indexOf(element);
- if (currentIdx !== -1) {
- if (currentIdx === idx) {
- // nothing to do, position has not changed
- return;
- } else {
- if (idx !== -1) {
- // remove from current position
- collection.splice(currentIdx, 1);
- } else {
- // already exists in collection
- return;
- }
- }
- }
- if (idx !== -1) {
- // insert at specified position
- collection.splice(idx, 0, element);
- } else {
- // push to end
- collection.push(element);
- }
- };
- /**
- * Fail get the index of an element in a collection.
- *
- * @param {Array<Object>} collection
- * @param {Object} element
- *
- * @return {Number} the index or -1 if collection or element do
- * not exist or the element is not contained.
- */
- module.exports.indexOf = function(collection, element) {
- if (!collection || !element) {
- return -1;
- }
- return collection.indexOf(element);
- };
- },{}],185:[function(_dereq_,module,exports){
- 'use strict';
- var domClasses = _dereq_(352);
- var CURSOR_CLS_PATTERN = /^djs-cursor-.*$/;
- module.exports.set = function(mode) {
- var classes = domClasses(document.body);
- classes.removeMatching(CURSOR_CLS_PATTERN);
- if (mode) {
- classes.add('djs-cursor-' + mode);
- }
- };
- module.exports.unset = function() {
- this.set(null);
- };
- },{"352":352}],186:[function(_dereq_,module,exports){
- 'use strict';
- var isArray = _dereq_(330),
- isNumber = _dereq_(333),
- groupBy = _dereq_(219),
- forEach = _dereq_(218);
- /**
- * Adds an element to a collection and returns true if the
- * element was added.
- *
- * @param {Array<Object>} elements
- * @param {Object} e
- * @param {Boolean} unique
- */
- function add(elements, e, unique) {
- var canAdd = !unique || elements.indexOf(e) === -1;
- if (canAdd) {
- elements.push(e);
- }
- return canAdd;
- }
- function eachElement(elements, fn, depth) {
- depth = depth || 0;
- forEach(elements, function(s, i) {
- var filter = fn(s, i, depth);
- if (isArray(filter) && filter.length) {
- eachElement(filter, fn, depth + 1);
- }
- });
- }
- /**
- * Collects self + child elements up to a given depth from a list of elements.
- *
- * @param {Array<djs.model.Base>} elements the elements to select the children from
- * @param {Boolean} unique whether to return a unique result set (no duplicates)
- * @param {Number} maxDepth the depth to search through or -1 for infinite
- *
- * @return {Array<djs.model.Base>} found elements
- */
- function selfAndChildren(elements, unique, maxDepth) {
- var result = [],
- processedChildren = [];
- eachElement(elements, function(element, i, depth) {
- add(result, element, unique);
- var children = element.children;
- // max traversal depth not reached yet
- if (maxDepth === -1 || depth < maxDepth) {
- // children exist && children not yet processed
- if (children && add(processedChildren, children, unique)) {
- return children;
- }
- }
- });
- return result;
- }
- /**
- * Return self + direct children for a number of elements
- *
- * @param {Array<djs.model.Base>} elements to query
- * @param {Boolean} allowDuplicates to allow duplicates in the result set
- *
- * @return {Array<djs.model.Base>} the collected elements
- */
- function selfAndDirectChildren(elements, allowDuplicates) {
- return selfAndChildren(elements, !allowDuplicates, 1);
- }
- /**
- * Return self + ALL children for a number of elements
- *
- * @param {Array<djs.model.Base>} elements to query
- * @param {Boolean} allowDuplicates to allow duplicates in the result set
- *
- * @return {Array<djs.model.Base>} the collected elements
- */
- function selfAndAllChildren(elements, allowDuplicates) {
- return selfAndChildren(elements, !allowDuplicates, -1);
- }
- /**
- * Gets the the closure fo all selected elements,
- * their connections and
- *
- * @param {Array<djs.model.Base>} elements
- * @return {Object} enclosure
- */
- function getClosure(elements) {
- // original elements passed to this function
- var topLevel = groupBy(elements, function(e) { return e.id; });
- var allShapes = {},
- allConnections = {},
- enclosedElements = {},
- enclosedConnections = {};
- function handleConnection(c) {
- if (topLevel[c.source.id] && topLevel[c.target.id]) {
- topLevel[c.id] = c;
- }
- // not enclosed as a child, but maybe logically
- // (connecting two moved elements?)
- if (allShapes[c.source.id] && allShapes[c.target.id]) {
- enclosedConnections[c.id] = enclosedElements[c.id] = c;
- }
- allConnections[c.id] = c;
- }
- function handleElement(element) {
- enclosedElements[element.id] = element;
- if (element.waypoints) {
- // remember connection
- enclosedConnections[element.id] = allConnections[element.id] = element;
- } else {
- // remember shape
- allShapes[element.id] = element;
- // remember all connections
- forEach(element.incoming, handleConnection);
- forEach(element.outgoing, handleConnection);
- // recurse into children
- return element.children;
- }
- }
- eachElement(elements, handleElement);
- return {
- allShapes: allShapes,
- allConnections: allConnections,
- topLevel: topLevel,
- enclosedConnections: enclosedConnections,
- enclosedElements: enclosedElements
- };
- }
- /**
- * Returns the surrounding bbox for all elements in the array or the element primitive.
- */
- function getBBox(elements, stopRecursion) {
- stopRecursion = !!stopRecursion;
- if (!isArray(elements)) {
- elements = [elements];
- }
- var minX,
- minY,
- maxX,
- maxY;
- forEach(elements, function(element) {
- // If element is a connection the bbox must be computed first
- var bbox = element;
- if (element.waypoints && !stopRecursion) {
- bbox = getBBox(element.waypoints, true);
- }
- var x = bbox.x,
- y = bbox.y,
- height = bbox.height || 0,
- width = bbox.width || 0;
- if (x < minX || minX === undefined) {
- minX = x;
- }
- if (y < minY || minY === undefined) {
- minY = y;
- }
- if ((x + width) > maxX || maxX === undefined) {
- maxX = x + width;
- }
- if ((y + height) > maxY || maxY === undefined) {
- maxY = y + height;
- }
- });
- return {
- x: minX,
- y: minY,
- height: maxY - minY,
- width: maxX - minX
- };
- }
- /**
- * Returns all elements that are enclosed from the bounding box.
- *
- * @param {Array<Object>} elements List of Elements to search through
- * @param {Object} bbox the enclosing bbox.
- * <ul>
- * <li>If bbox.(width|height) is not specified
- * the method returns all elements with element.x/y > bbox.x/y
- * </li>
- * <li>If only bbox.x or bbox.y is specified, method return all elements with
- * e.x > bbox.x or e.y > bbox.y.</li>
- * </ul>
- *
- */
- function getEnclosedElements(elements, bbox) {
- var filteredElements = {};
- forEach(elements, function(element) {
- var e = element;
- if (e.waypoints) {
- e = getBBox(e);
- }
- if (!isNumber(bbox.y) && (e.x > bbox.x)) {
- filteredElements[element.id] = element;
- }
- if (!isNumber(bbox.x) && (e.y > bbox.y)) {
- filteredElements[element.id] = element;
- }
- if (e.x > bbox.x && e.y > bbox.y) {
- if (isNumber(bbox.width) && isNumber(bbox.height) &&
- e.width + e.x < bbox.width + bbox.x &&
- e.height + e.y < bbox.height + bbox.y) {
- filteredElements[element.id] = element;
- } else if (!isNumber(bbox.width) || !isNumber(bbox.height)) {
- filteredElements[element.id] = element;
- }
- }
- });
- return filteredElements;
- }
- module.exports.eachElement = eachElement;
- module.exports.selfAndDirectChildren = selfAndDirectChildren;
- module.exports.selfAndAllChildren = selfAndAllChildren;
- module.exports.getBBox = getBBox;
- module.exports.getEnclosedElements = getEnclosedElements;
- module.exports.getClosure = getClosure;
- },{"218":218,"219":219,"330":330,"333":333}],187:[function(_dereq_,module,exports){
- 'use strict';
- function __preventDefault(event) {
- return event && event.preventDefault();
- }
- function __stopPropagation(event, immediate) {
- if (!event) {
- return;
- }
- if (event.stopPropagation) {
- event.stopPropagation();
- }
- if (immediate && event.stopImmediatePropagation) {
- event.stopImmediatePropagation();
- }
- }
- function getOriginal(event) {
- return event.originalEvent || event.srcEvent;
- }
- module.exports.getOriginal = getOriginal;
- function stopEvent(event, immediate) {
- stopPropagation(event, immediate);
- preventDefault(event);
- }
- module.exports.stopEvent = stopEvent;
- function preventDefault(event) {
- __preventDefault(event);
- __preventDefault(getOriginal(event));
- }
- module.exports.preventDefault = preventDefault;
- function stopPropagation(event, immediate) {
- __stopPropagation(event, immediate);
- __stopPropagation(getOriginal(event), immediate);
- }
- module.exports.stopPropagation = stopPropagation;
- function toPoint(event) {
- if (event.pointers && event.pointers.length) {
- event = event.pointers[0];
- }
- if (event.touches && event.touches.length) {
- event = event.touches[0];
- }
- return event ? {
- x: event.clientX,
- y: event.clientY
- } : null;
- }
- module.exports.toPoint = toPoint;
- },{}],188:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Computes the distance between two points
- *
- * @param {Point} p
- * @param {Point} q
- *
- * @return {Number} distance
- */
- var pointDistance = module.exports.pointDistance = function(p, q) {
- return Math.sqrt(Math.pow(q.x - p.x, 2) + Math.pow(q.y - p.y, 2));
- };
- /**
- * Returns true if the point r is on the line between p and y
- *
- * @param {Point} p
- * @param {Point} q
- * @param {Point} r
- *
- * @return {Boolean}
- */
- module.exports.pointsOnLine = function(p, q, r) {
- if (!p || !q || !r) {
- return false;
- }
- var val = (q.x - p.x) * (r.y - p.y) - (q.y - p.y) * (r.x - p.x),
- dist = pointDistance(p, q);
- // @see http://stackoverflow.com/a/907491/412190
- return Math.abs(val / dist) < 5;
- };
- module.exports.pointInRect = function(p, rect, tolerance) {
- tolerance = tolerance || 0;
- return p.x > rect.x - tolerance &&
- p.y > rect.y - tolerance &&
- p.x < rect.x + rect.width + tolerance &&
- p.y < rect.y + rect.height + tolerance;
- };
- },{}],189:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * SVGs for elements are generated by the {@link GraphicsFactory}.
- *
- * This utility gives quick access to the important semantic
- * parts of an element.
- */
- /**
- * Returns the visual part of a diagram element
- *
- * @param {Snap<SVGElement>} gfx
- *
- * @return {Snap<SVGElement>}
- */
- function getVisual(gfx) {
- return gfx.select('.djs-visual');
- }
- /**
- * Returns the children for a given diagram element.
- *
- * @param {Snap<SVGElement>} gfx
- * @return {Snap<SVGElement>}
- */
- function getChildren(gfx) {
- return gfx.parent().children()[1];
- }
- /**
- * Returns the visual bbox of an element
- *
- * @param {Snap<SVGElement>} gfx
- *
- * @return {Bounds}
- */
- function getBBox(gfx) {
- return getVisual(gfx).select('*').getBBox();
- }
- module.exports.getVisual = getVisual;
- module.exports.getChildren = getChildren;
- module.exports.getBBox = getBBox;
- },{}],190:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Util that provides unique IDs.
- *
- * @class djs.util.IdGenerator
- * @constructor
- * @memberOf djs.util
- *
- * The ids can be customized via a given prefix and contain a random value to avoid collisions.
- *
- * @param {String} prefix a prefix to prepend to generated ids (for better readability)
- */
- function IdGenerator(prefix) {
- this._counter = 0;
- this._prefix = (prefix ? prefix + '-' : '') + Math.floor(Math.random() * 1000000000) + '-';
- }
- module.exports = IdGenerator;
- /**
- * Returns a next unique ID.
- *
- * @method djs.util.IdGenerator#next
- *
- * @returns {String} the id
- */
- IdGenerator.prototype.next = function() {
- return this._prefix + (++this._counter);
- };
- },{}],191:[function(_dereq_,module,exports){
- 'use strict';
- var pointDistance = _dereq_(188).pointDistance;
- var Snap = _dereq_(200);
- var round = Math.round,
- max = Math.max;
- function circlePath(center, r) {
- var x = center.x,
- y = center.y;
- return [
- ['M', x, y],
- ['m', 0, -r],
- ['a', r, r, 0, 1, 1, 0, 2 * r],
- ['a', r, r, 0, 1, 1, 0, -2 * r],
- ['z']
- ];
- }
- function linePath(points) {
- var segments = [];
- points.forEach(function(p, idx) {
- segments.push([ idx === 0 ? 'M' : 'L', p.x, p.y ]);
- });
- return segments;
- }
- var INTERSECTION_THRESHOLD = 10;
- function getBendpointIntersection(waypoints, reference) {
- var i, w;
- for (i = 0; !!(w = waypoints[i]); i++) {
- if (pointDistance(w, reference) <= INTERSECTION_THRESHOLD) {
- return {
- point: waypoints[i],
- bendpoint: true,
- index: i
- };
- }
- }
- return null;
- }
- function getPathIntersection(waypoints, reference) {
- var intersections = Snap.path.intersection(circlePath(reference, INTERSECTION_THRESHOLD), linePath(waypoints));
- var a = intersections[0],
- b = intersections[intersections.length - 1],
- idx;
- if (!a) {
- // no intersection
- return null;
- }
- if (a !== b) {
- if (a.segment2 !== b.segment2) {
- // we use the bendpoint in between both segments
- // as the intersection point
- idx = max(a.segment2, b.segment2) - 1;
- return {
- point: waypoints[idx],
- bendpoint: true,
- index: idx
- };
- }
- return {
- point: {
- x: (round(a.x + b.x) / 2),
- y: (round(a.y + b.y) / 2)
- },
- index: a.segment2
- };
- }
- return {
- point: {
- x: round(a.x),
- y: round(a.y)
- },
- index: a.segment2
- };
- }
- /**
- * Returns the closest point on the connection towards a given reference point.
- *
- * @param {Array<Point>} waypoints
- * @param {Point} reference
- *
- * @return {Object} intersection data (segment, point)
- */
- module.exports.getApproxIntersection = function(waypoints, reference) {
- return getBendpointIntersection(waypoints, reference) || getPathIntersection(waypoints, reference);
- };
- },{"188":188,"200":200}],192:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Get the logarithm of x with base 10
- * @param {Integer} value
- */
- function log10(x) {
- return Math.log(x) / Math.log(10);
- }
- module.exports.log10 = log10;
- },{}],193:[function(_dereq_,module,exports){
- 'use strict';
- var getOriginalEvent = _dereq_(187).getOriginal;
- var isMac = _dereq_(194).isMac;
- function isPrimaryButton(event) {
- // button === 0 -> left áka primary mouse button
- return !(getOriginalEvent(event) || event).button;
- }
- module.exports.isPrimaryButton = isPrimaryButton;
- module.exports.isMac = isMac;
- module.exports.hasPrimaryModifier = function(event) {
- var originalEvent = getOriginalEvent(event) || event;
- if (!isPrimaryButton(event)) {
- return false;
- }
- // Use alt as primary modifier key for mac OS
- if (isMac()) {
- return originalEvent.altKey;
- } else {
- return originalEvent.ctrlKey;
- }
- };
- module.exports.hasSecondaryModifier = function(event) {
- var originalEvent = getOriginalEvent(event) || event;
- return isPrimaryButton(event) && originalEvent.shiftKey;
- };
- },{"187":187,"194":194}],194:[function(_dereq_,module,exports){
- 'use strict';
- module.exports.isMac = function isMac() {
- return (/mac/i).test(navigator.platform);
- };
- },{}],195:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * Remove from the beginning of a collection until it is empty.
- *
- * This is a null-safe operation that ensures elements
- * are being removed from the given collection until the
- * collection is empty.
- *
- * The implementation deals with the fact that a remove operation
- * may touch, i.e. remove multiple elements in the collection
- * at a time.
- *
- * @param {Array<Object>} [collection]
- * @param {Function} removeFn
- *
- * @return {Array<Object>} the cleared collection
- */
- module.exports.saveClear = function(collection, removeFn) {
- if (typeof removeFn !== 'function') {
- throw new Error('removeFn iterator must be a function');
- }
- if (!collection) {
- return;
- }
- var e;
- while (!!(e = collection[0])) {
- removeFn(e);
- }
- return collection;
- };
- },{}],196:[function(_dereq_,module,exports){
- 'use strict';
- var isObject = _dereq_(334),
- assign = _dereq_(339),
- pick = _dereq_(345),
- forEach = _dereq_(218),
- reduce = _dereq_(222),
- merge = _dereq_(342);
- var Snap = _dereq_(200);
- var DEFAULT_BOX_PADDING = 0;
- var DEFAULT_LABEL_SIZE = {
- width: 150,
- height: 50
- };
- function parseAlign(align) {
- var parts = align.split('-');
- return {
- horizontal: parts[0] || 'center',
- vertical: parts[1] || 'top'
- };
- }
- function parsePadding(padding) {
- if (isObject(padding)) {
- return assign({ top: 0, left: 0, right: 0, bottom: 0 }, padding);
- } else {
- return {
- top: padding,
- left: padding,
- right: padding,
- bottom: padding
- };
- }
- }
- function getTextBBox(text, fakeText) {
- fakeText.textContent = text;
- return pick(fakeText.getBBox(), [ 'width', 'height' ]);
- }
- /**
- * Layout the next line and return the layouted element.
- *
- * Alters the lines passed.
- *
- * @param {Array<String>} lines
- * @return {Object} the line descriptor, an object { width, height, text }
- */
- function layoutNext(lines, maxWidth, fakeText) {
- var originalLine = lines.shift(),
- fitLine = originalLine;
- var textBBox;
- while (true) {
- textBBox = getTextBBox(fitLine, fakeText);
- textBBox.width = fitLine ? textBBox.width : 0;
- // try to fit
- if (fitLine === ' ' || fitLine === '' || textBBox.width < Math.round(maxWidth) || fitLine.length < 4) {
- return fit(lines, fitLine, originalLine, textBBox);
- }
- fitLine = shortenLine(fitLine, textBBox.width, maxWidth);
- }
- }
- function fit(lines, fitLine, originalLine, textBBox) {
- if (fitLine.length < originalLine.length) {
- var nextLine = lines[0] || '',
- remainder = originalLine.slice(fitLine.length).trim();
- if (/-\s*$/.test(remainder)) {
- nextLine = remainder.replace(/-\s*$/, '') + nextLine.replace(/^\s+/, '');
- } else {
- nextLine = remainder + ' ' + nextLine;
- }
- lines[0] = nextLine;
- }
- return { width: textBBox.width, height: textBBox.height, text: fitLine };
- }
- /**
- * Shortens a line based on spacing and hyphens.
- * Returns the shortened result on success.
- *
- * @param {String} line
- * @param {Number} maxLength the maximum characters of the string
- * @return {String} the shortened string
- */
- function semanticShorten(line, maxLength) {
- var parts = line.split(/(\s|-)/g),
- part,
- shortenedParts = [],
- length = 0;
- // try to shorten via spaces + hyphens
- if (parts.length > 1) {
- while ((part = parts.shift())) {
- if (part.length + length < maxLength) {
- shortenedParts.push(part);
- length += part.length;
- } else {
- // remove previous part, too if hyphen does not fit anymore
- if (part === '-') {
- shortenedParts.pop();
- }
- break;
- }
- }
- }
- return shortenedParts.join('');
- }
- function shortenLine(line, width, maxWidth) {
- var length = Math.max(line.length * (maxWidth / width), 1);
- // try to shorten semantically (i.e. based on spaces and hyphens)
- var shortenedLine = semanticShorten(line, length);
- if (!shortenedLine) {
- // force shorten by cutting the long word
- shortenedLine = line.slice(0, Math.max(Math.round(length - 1), 1));
- }
- return shortenedLine;
- }
- /**
- * Creates a new label utility
- *
- * @param {Object} config
- * @param {Dimensions} config.size
- * @param {Number} config.padding
- * @param {Object} config.style
- * @param {String} config.align
- */
- function Text(config) {
- this._config = assign({}, {
- size: DEFAULT_LABEL_SIZE,
- padding: DEFAULT_BOX_PADDING,
- style: {},
- align: 'center-top'
- }, config || {});
- }
- /**
- * Create a label in the parent node.
- *
- * @method Text#createText
- *
- * @param {SVGElement} parent the parent to draw the label on
- * @param {String} text the text to render on the label
- * @param {Object} options
- * @param {String} options.align how to align in the bounding box.
- * Any of { 'center-middle', 'center-top' }, defaults to 'center-top'.
- * @param {String} options.style style to be applied to the text
- *
- * @return {SVGText} the text element created
- */
- Text.prototype.createText = function(parent, text, options) {
- var box = merge({}, this._config.size, options.box || {}),
- style = merge({}, this._config.style, options.style || {}),
- align = parseAlign(options.align || this._config.align),
- padding = parsePadding(options.padding !== undefined ? options.padding : this._config.padding);
- var lines = text.split(/\r?\n/g),
- layouted = [];
- var maxWidth = box.width - padding.left - padding.right;
- // FF regression: ensure text is shown during rendering
- // by attaching it directly to the body
- var fakeText = parent.paper.text(0, 0, '').attr(style).node;
- while (lines.length) {
- layouted.push(layoutNext(lines, maxWidth, fakeText));
- }
- var totalHeight = reduce(layouted, function(sum, line, idx) {
- return sum + line.height;
- }, 0);
- // the y position of the next line
- var y, x;
- switch (align.vertical) {
- case 'middle':
- y = (box.height - totalHeight) / 2 - layouted[0].height / 4;
- break;
- default:
- y = padding.top;
- }
- var textElement = parent.text().attr(style);
- forEach(layouted, function(line) {
- y += line.height;
- switch (align.horizontal) {
- case 'left':
- x = padding.left;
- break;
- case 'right':
- x = (maxWidth - padding.right - line.width);
- break;
- default:
- // aka center
- x = Math.max(((maxWidth - line.width) / 2 + padding.left), 0);
- }
- var tspan = Snap.create('tspan', { x: x, y: y }).node;
- tspan.textContent = line.text;
- textElement.append(tspan);
- });
- // remove fake text
- fakeText.parentNode.removeChild(fakeText);
- return textElement;
- };
- module.exports = Text;
- },{"200":200,"218":218,"222":222,"334":334,"339":339,"342":342,"345":345}],197:[function(_dereq_,module,exports){
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- // ┌────────────────────────────────────────────────────────────┐ \\
- // │ Eve 0.4.2 - JavaScript Events Library │ \\
- // ├────────────────────────────────────────────────────────────┤ \\
- // │ Author Dmitry Baranovskiy (http://dmitry.baranovskiy.com/) │ \\
- // └────────────────────────────────────────────────────────────┘ \\
- (function (glob) {
- var version = "0.4.2",
- has = "hasOwnProperty",
- separator = /[\.\/]/,
- comaseparator = /\s*,\s*/,
- wildcard = "*",
- fun = function () {},
- numsort = function (a, b) {
- return a - b;
- },
- current_event,
- stop,
- events = {n: {}},
- firstDefined = function () {
- for (var i = 0, ii = this.length; i < ii; i++) {
- if (typeof this[i] != "undefined") {
- return this[i];
- }
- }
- },
- lastDefined = function () {
- var i = this.length;
- while (--i) {
- if (typeof this[i] != "undefined") {
- return this[i];
- }
- }
- },
- /*\
- * eve
- [ method ]
- * Fires event with given `name`, given scope and other parameters.
- > Arguments
- - name (string) name of the *event*, dot (`.`) or slash (`/`) separated
- - scope (object) context for the event handlers
- - varargs (...) the rest of arguments will be sent to event handlers
- = (object) array of returned values from the listeners. Array has two methods `.firstDefined()` and `.lastDefined()` to get first or last not `undefined` value.
- \*/
- eve = function (name, scope) {
- name = String(name);
- var e = events,
- oldstop = stop,
- args = Array.prototype.slice.call(arguments, 2),
- listeners = eve.listeners(name),
- z = 0,
- f = false,
- l,
- indexed = [],
- queue = {},
- out = [],
- ce = current_event,
- errors = [];
- out.firstDefined = firstDefined;
- out.lastDefined = lastDefined;
- current_event = name;
- stop = 0;
- for (var i = 0, ii = listeners.length; i < ii; i++) if ("zIndex" in listeners[i]) {
- indexed.push(listeners[i].zIndex);
- if (listeners[i].zIndex < 0) {
- queue[listeners[i].zIndex] = listeners[i];
- }
- }
- indexed.sort(numsort);
- while (indexed[z] < 0) {
- l = queue[indexed[z++]];
- out.push(l.apply(scope, args));
- if (stop) {
- stop = oldstop;
- return out;
- }
- }
- for (i = 0; i < ii; i++) {
- l = listeners[i];
- if ("zIndex" in l) {
- if (l.zIndex == indexed[z]) {
- out.push(l.apply(scope, args));
- if (stop) {
- break;
- }
- do {
- z++;
- l = queue[indexed[z]];
- l && out.push(l.apply(scope, args));
- if (stop) {
- break;
- }
- } while (l)
- } else {
- queue[l.zIndex] = l;
- }
- } else {
- out.push(l.apply(scope, args));
- if (stop) {
- break;
- }
- }
- }
- stop = oldstop;
- current_event = ce;
- return out;
- };
- // Undocumented. Debug only.
- eve._events = events;
- /*\
- * eve.listeners
- [ method ]
- * Internal method which gives you array of all event handlers that will be triggered by the given `name`.
- > Arguments
- - name (string) name of the event, dot (`.`) or slash (`/`) separated
- = (array) array of event handlers
- \*/
- eve.listeners = function (name) {
- var names = name.split(separator),
- e = events,
- item,
- items,
- k,
- i,
- ii,
- j,
- jj,
- nes,
- es = [e],
- out = [];
- for (i = 0, ii = names.length; i < ii; i++) {
- nes = [];
- for (j = 0, jj = es.length; j < jj; j++) {
- e = es[j].n;
- items = [e[names[i]], e[wildcard]];
- k = 2;
- while (k--) {
- item = items[k];
- if (item) {
- nes.push(item);
- out = out.concat(item.f || []);
- }
- }
- }
- es = nes;
- }
- return out;
- };
-
- /*\
- * eve.on
- [ method ]
- **
- * Binds given event handler with a given name. You can use wildcards “`*`” for the names:
- | eve.on("*.under.*", f);
- | eve("mouse.under.floor"); // triggers f
- * Use @eve to trigger the listener.
- **
- > Arguments
- **
- - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
- - f (function) event handler function
- **
- = (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.
- > Example:
- | eve.on("mouse", eatIt)(2);
- | eve.on("mouse", scream);
- | eve.on("mouse", catchIt)(1);
- * This will ensure that `catchIt` function will be called before `eatIt`.
- *
- * If you want to put your handler before non-indexed handlers, specify a negative value.
- * 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”.
- \*/
- eve.on = function (name, f) {
- name = String(name);
- if (typeof f != "function") {
- return function () {};
- }
- var names = name.split(comaseparator);
- for (var i = 0, ii = names.length; i < ii; i++) {
- (function (name) {
- var names = name.split(separator),
- e = events,
- exist;
- for (var i = 0, ii = names.length; i < ii; i++) {
- e = e.n;
- e = e.hasOwnProperty(names[i]) && e[names[i]] || (e[names[i]] = {n: {}});
- }
- e.f = e.f || [];
- for (i = 0, ii = e.f.length; i < ii; i++) if (e.f[i] == f) {
- exist = true;
- break;
- }
- !exist && e.f.push(f);
- }(names[i]));
- }
- return function (zIndex) {
- if (+zIndex == +zIndex) {
- f.zIndex = +zIndex;
- }
- };
- };
- /*\
- * eve.f
- [ method ]
- **
- * Returns function that will fire given event with optional arguments.
- * Arguments that will be passed to the result function will be also
- * concated to the list of final arguments.
- | el.onclick = eve.f("click", 1, 2);
- | eve.on("click", function (a, b, c) {
- | console.log(a, b, c); // 1, 2, [event object]
- | });
- > Arguments
- - event (string) event name
- - varargs (…) and any other arguments
- = (function) possible event handler function
- \*/
- eve.f = function (event) {
- var attrs = [].slice.call(arguments, 1);
- return function () {
- eve.apply(null, [event, null].concat(attrs).concat([].slice.call(arguments, 0)));
- };
- };
- /*\
- * eve.stop
- [ method ]
- **
- * Is used inside an event handler to stop the event, preventing any subsequent listeners from firing.
- \*/
- eve.stop = function () {
- stop = 1;
- };
- /*\
- * eve.nt
- [ method ]
- **
- * Could be used inside event handler to figure out actual name of the event.
- **
- > Arguments
- **
- - subname (string) #optional subname of the event
- **
- = (string) name of the event, if `subname` is not specified
- * or
- = (boolean) `true`, if current event’s name contains `subname`
- \*/
- eve.nt = function (subname) {
- if (subname) {
- return new RegExp("(?:\\.|\\/|^)" + subname + "(?:\\.|\\/|$)").test(current_event);
- }
- return current_event;
- };
- /*\
- * eve.nts
- [ method ]
- **
- * Could be used inside event handler to figure out actual name of the event.
- **
- **
- = (array) names of the event
- \*/
- eve.nts = function () {
- return current_event.split(separator);
- };
- /*\
- * eve.off
- [ method ]
- **
- * Removes given function from the list of event listeners assigned to given name.
- * If no arguments specified all the events will be cleared.
- **
- > Arguments
- **
- - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
- - f (function) event handler function
- \*/
- /*\
- * eve.unbind
- [ method ]
- **
- * See @eve.off
- \*/
- eve.off = eve.unbind = function (name, f) {
- if (!name) {
- eve._events = events = {n: {}};
- return;
- }
- var names = name.split(comaseparator);
- if (names.length > 1) {
- for (var i = 0, ii = names.length; i < ii; i++) {
- eve.off(names[i], f);
- }
- return;
- }
- names = name.split(separator);
- var e,
- key,
- splice,
- i, ii, j, jj,
- cur = [events];
- for (i = 0, ii = names.length; i < ii; i++) {
- for (j = 0; j < cur.length; j += splice.length - 2) {
- splice = [j, 1];
- e = cur[j].n;
- if (names[i] != wildcard) {
- if (e[names[i]]) {
- splice.push(e[names[i]]);
- }
- } else {
- for (key in e) if (e[has](key)) {
- splice.push(e[key]);
- }
- }
- cur.splice.apply(cur, splice);
- }
- }
- for (i = 0, ii = cur.length; i < ii; i++) {
- e = cur[i];
- while (e.n) {
- if (f) {
- if (e.f) {
- for (j = 0, jj = e.f.length; j < jj; j++) if (e.f[j] == f) {
- e.f.splice(j, 1);
- break;
- }
- !e.f.length && delete e.f;
- }
- for (key in e.n) if (e.n[has](key) && e.n[key].f) {
- var funcs = e.n[key].f;
- for (j = 0, jj = funcs.length; j < jj; j++) if (funcs[j] == f) {
- funcs.splice(j, 1);
- break;
- }
- !funcs.length && delete e.n[key].f;
- }
- } else {
- delete e.f;
- for (key in e.n) if (e.n[has](key) && e.n[key].f) {
- delete e.n[key].f;
- }
- }
- e = e.n;
- }
- }
- };
- /*\
- * eve.once
- [ method ]
- **
- * Binds given event handler with a given name to only run once then unbind itself.
- | eve.once("login", f);
- | eve("login"); // triggers f
- | eve("login"); // no listeners
- * Use @eve to trigger the listener.
- **
- > Arguments
- **
- - name (string) name of the event, dot (`.`) or slash (`/`) separated, with optional wildcards
- - f (function) event handler function
- **
- = (function) same return function as @eve.on
- \*/
- eve.once = function (name, f) {
- var f2 = function () {
- eve.unbind(name, f2);
- return f.apply(this, arguments);
- };
- return eve.on(name, f2);
- };
- /*\
- * eve.version
- [ property (string) ]
- **
- * Current version of the library.
- \*/
- eve.version = version;
- eve.toString = function () {
- return "You are running Eve " + version;
- };
- (typeof module != "undefined" && module.exports) ? (module.exports = eve) : (typeof define === "function" && define.amd ? (define("eve", [], function() { return eve; })) : (glob.eve = eve));
- })(this);
- },{}],198:[function(_dereq_,module,exports){
- /*! Hammer.JS - v2.0.4 - 2014-09-28
- * http://hammerjs.github.io/
- *
- * Copyright (c) 2014 Jorik Tangelder;
- * Licensed under the MIT license */
- (function(window, document, exportName, undefined) {
- 'use strict';
- var VENDOR_PREFIXES = ['', 'webkit', 'moz', 'MS', 'ms', 'o'];
- var TEST_ELEMENT = document.createElement('div');
- var TYPE_FUNCTION = 'function';
- var round = Math.round;
- var abs = Math.abs;
- var now = Date.now;
- /**
- * set a timeout with a given scope
- * @param {Function} fn
- * @param {Number} timeout
- * @param {Object} context
- * @returns {number}
- */
- function setTimeoutContext(fn, timeout, context) {
- return setTimeout(bindFn(fn, context), timeout);
- }
- /**
- * if the argument is an array, we want to execute the fn on each entry
- * if it aint an array we don't want to do a thing.
- * this is used by all the methods that accept a single and array argument.
- * @param {*|Array} arg
- * @param {String} fn
- * @param {Object} [context]
- * @returns {Boolean}
- */
- function invokeArrayArg(arg, fn, context) {
- if (Array.isArray(arg)) {
- each(arg, context[fn], context);
- return true;
- }
- return false;
- }
- /**
- * walk objects and arrays
- * @param {Object} obj
- * @param {Function} iterator
- * @param {Object} context
- */
- function each(obj, iterator, context) {
- var i;
- if (!obj) {
- return;
- }
- if (obj.forEach) {
- obj.forEach(iterator, context);
- } else if (obj.length !== undefined) {
- i = 0;
- while (i < obj.length) {
- iterator.call(context, obj[i], i, obj);
- i++;
- }
- } else {
- for (i in obj) {
- obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
- }
- }
- }
- /**
- * extend object.
- * means that properties in dest will be overwritten by the ones in src.
- * @param {Object} dest
- * @param {Object} src
- * @param {Boolean} [merge]
- * @returns {Object} dest
- */
- function extend(dest, src, merge) {
- var keys = Object.keys(src);
- var i = 0;
- while (i < keys.length) {
- if (!merge || (merge && dest[keys[i]] === undefined)) {
- dest[keys[i]] = src[keys[i]];
- }
- i++;
- }
- return dest;
- }
- /**
- * merge the values from src in the dest.
- * means that properties that exist in dest will not be overwritten by src
- * @param {Object} dest
- * @param {Object} src
- * @returns {Object} dest
- */
- function merge(dest, src) {
- return extend(dest, src, true);
- }
- /**
- * simple class inheritance
- * @param {Function} child
- * @param {Function} base
- * @param {Object} [properties]
- */
- function inherit(child, base, properties) {
- var baseP = base.prototype,
- childP;
- childP = child.prototype = Object.create(baseP);
- childP.constructor = child;
- childP._super = baseP;
- if (properties) {
- extend(childP, properties);
- }
- }
- /**
- * simple function bind
- * @param {Function} fn
- * @param {Object} context
- * @returns {Function}
- */
- function bindFn(fn, context) {
- return function boundFn() {
- return fn.apply(context, arguments);
- };
- }
- /**
- * let a boolean value also be a function that must return a boolean
- * this first item in args will be used as the context
- * @param {Boolean|Function} val
- * @param {Array} [args]
- * @returns {Boolean}
- */
- function boolOrFn(val, args) {
- if (typeof val == TYPE_FUNCTION) {
- return val.apply(args ? args[0] || undefined : undefined, args);
- }
- return val;
- }
- /**
- * use the val2 when val1 is undefined
- * @param {*} val1
- * @param {*} val2
- * @returns {*}
- */
- function ifUndefined(val1, val2) {
- return (val1 === undefined) ? val2 : val1;
- }
- /**
- * addEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function addEventListeners(target, types, handler) {
- each(splitStr(types), function(type) {
- target.addEventListener(type, handler, false);
- });
- }
- /**
- * removeEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function removeEventListeners(target, types, handler) {
- each(splitStr(types), function(type) {
- target.removeEventListener(type, handler, false);
- });
- }
- /**
- * find if a node is in the given parent
- * @method hasParent
- * @param {HTMLElement} node
- * @param {HTMLElement} parent
- * @return {Boolean} found
- */
- function hasParent(node, parent) {
- while (node) {
- if (node == parent) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
- }
- /**
- * small indexOf wrapper
- * @param {String} str
- * @param {String} find
- * @returns {Boolean} found
- */
- function inStr(str, find) {
- return str.indexOf(find) > -1;
- }
- /**
- * split string on whitespace
- * @param {String} str
- * @returns {Array} words
- */
- function splitStr(str) {
- return str.trim().split(/\s+/g);
- }
- /**
- * find if a array contains the object using indexOf or a simple polyFill
- * @param {Array} src
- * @param {String} find
- * @param {String} [findByKey]
- * @return {Boolean|Number} false when not found, or the index
- */
- function inArray(src, find, findByKey) {
- if (src.indexOf && !findByKey) {
- return src.indexOf(find);
- } else {
- var i = 0;
- while (i < src.length) {
- if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
- return i;
- }
- i++;
- }
- return -1;
- }
- }
- /**
- * convert array-like objects to real arrays
- * @param {Object} obj
- * @returns {Array}
- */
- function toArray(obj) {
- return Array.prototype.slice.call(obj, 0);
- }
- /**
- * unique array with objects based on a key (like 'id') or just by the array's value
- * @param {Array} src [{id:1},{id:2},{id:1}]
- * @param {String} [key]
- * @param {Boolean} [sort=False]
- * @returns {Array} [{id:1},{id:2}]
- */
- function uniqueArray(src, key, sort) {
- var results = [];
- var values = [];
- var i = 0;
- while (i < src.length) {
- var val = key ? src[i][key] : src[i];
- if (inArray(values, val) < 0) {
- results.push(src[i]);
- }
- values[i] = val;
- i++;
- }
- if (sort) {
- if (!key) {
- results = results.sort();
- } else {
- results = results.sort(function sortUniqueArray(a, b) {
- return a[key] > b[key];
- });
- }
- }
- return results;
- }
- /**
- * get the prefixed property
- * @param {Object} obj
- * @param {String} property
- * @returns {String|Undefined} prefixed
- */
- function prefixed(obj, property) {
- var prefix, prop;
- var camelProp = property[0].toUpperCase() + property.slice(1);
- var i = 0;
- while (i < VENDOR_PREFIXES.length) {
- prefix = VENDOR_PREFIXES[i];
- prop = (prefix) ? prefix + camelProp : property;
- if (prop in obj) {
- return prop;
- }
- i++;
- }
- return undefined;
- }
- /**
- * get a unique id
- * @returns {number} uniqueId
- */
- var _uniqueId = 1;
- function uniqueId() {
- return _uniqueId++;
- }
- /**
- * get the window object of an element
- * @param {HTMLElement} element
- * @returns {DocumentView|Window}
- */
- function getWindowForElement(element) {
- var doc = element.ownerDocument;
- return (doc.defaultView || doc.parentWindow);
- }
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
- var SUPPORT_TOUCH = ('ontouchstart' in window);
- var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
- var INPUT_TYPE_TOUCH = 'touch';
- var INPUT_TYPE_PEN = 'pen';
- var INPUT_TYPE_MOUSE = 'mouse';
- var INPUT_TYPE_KINECT = 'kinect';
- var COMPUTE_INTERVAL = 25;
- var INPUT_START = 1;
- var INPUT_MOVE = 2;
- var INPUT_END = 4;
- var INPUT_CANCEL = 8;
- var DIRECTION_NONE = 1;
- var DIRECTION_LEFT = 2;
- var DIRECTION_RIGHT = 4;
- var DIRECTION_UP = 8;
- var DIRECTION_DOWN = 16;
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
- var PROPS_XY = ['x', 'y'];
- var PROPS_CLIENT_XY = ['clientX', 'clientY'];
- /**
- * create new input type manager
- * @param {Manager} manager
- * @param {Function} callback
- * @returns {Input}
- * @constructor
- */
- function Input(manager, callback) {
- var self = this;
- this.manager = manager;
- this.callback = callback;
- this.element = manager.element;
- this.target = manager.options.inputTarget;
- // smaller wrapper around the handler, for the scope and the enabled state of the manager,
- // so when disabled the input events are completely bypassed.
- this.domHandler = function(ev) {
- if (boolOrFn(manager.options.enable, [manager])) {
- self.handler(ev);
- }
- };
- this.init();
- }
- Input.prototype = {
- /**
- * should handle the inputEvent data and trigger the callback
- * @virtual
- */
- handler: function() { },
- /**
- * bind the events
- */
- init: function() {
- this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- },
- /**
- * unbind the events
- */
- destroy: function() {
- this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- }
- };
- /**
- * create new input type manager
- * called by the Manager constructor
- * @param {Hammer} manager
- * @returns {Input}
- */
- function createInputInstance(manager) {
- var Type;
- var inputClass = manager.options.inputClass;
- if (inputClass) {
- Type = inputClass;
- } else if (SUPPORT_POINTER_EVENTS) {
- Type = PointerEventInput;
- } else if (SUPPORT_ONLY_TOUCH) {
- Type = TouchInput;
- } else if (!SUPPORT_TOUCH) {
- Type = MouseInput;
- } else {
- Type = TouchMouseInput;
- }
- return new (Type)(manager, inputHandler);
- }
- /**
- * handle input events
- * @param {Manager} manager
- * @param {String} eventType
- * @param {Object} input
- */
- function inputHandler(manager, eventType, input) {
- var pointersLen = input.pointers.length;
- var changedPointersLen = input.changedPointers.length;
- var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
- var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
- input.isFirst = !!isFirst;
- input.isFinal = !!isFinal;
- if (isFirst) {
- manager.session = {};
- }
- // source event is the normalized value of the domEvents
- // like 'touchstart, mouseup, pointerdown'
- input.eventType = eventType;
- // compute scale, rotation etc
- computeInputData(manager, input);
- // emit secret event
- manager.emit('hammer.input', input);
- manager.recognize(input);
- manager.session.prevInput = input;
- }
- /**
- * extend the data with some usable properties like scale, rotate, velocity etc
- * @param {Object} manager
- * @param {Object} input
- */
- function computeInputData(manager, input) {
- var session = manager.session;
- var pointers = input.pointers;
- var pointersLength = pointers.length;
- // store the first input to calculate the distance and direction
- if (!session.firstInput) {
- session.firstInput = simpleCloneInputData(input);
- }
- // to compute scale and rotation we need to store the multiple touches
- if (pointersLength > 1 && !session.firstMultiple) {
- session.firstMultiple = simpleCloneInputData(input);
- } else if (pointersLength === 1) {
- session.firstMultiple = false;
- }
- var firstInput = session.firstInput;
- var firstMultiple = session.firstMultiple;
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
- var center = input.center = getCenter(pointers);
- input.timeStamp = now();
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
- input.angle = getAngle(offsetCenter, center);
- input.distance = getDistance(offsetCenter, center);
- computeDeltaXY(session, input);
- input.offsetDirection = getDirection(input.deltaX, input.deltaY);
- input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
- input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
- computeIntervalInputData(session, input);
- // find the correct target
- var target = manager.element;
- if (hasParent(input.srcEvent.target, target)) {
- target = input.srcEvent.target;
- }
- input.target = target;
- }
- function computeDeltaXY(session, input) {
- var center = input.center;
- var offset = session.offsetDelta || {};
- var prevDelta = session.prevDelta || {};
- var prevInput = session.prevInput || {};
- if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
- prevDelta = session.prevDelta = {
- x: prevInput.deltaX || 0,
- y: prevInput.deltaY || 0
- };
- offset = session.offsetDelta = {
- x: center.x,
- y: center.y
- };
- }
- input.deltaX = prevDelta.x + (center.x - offset.x);
- input.deltaY = prevDelta.y + (center.y - offset.y);
- }
- /**
- * velocity is calculated every x ms
- * @param {Object} session
- * @param {Object} input
- */
- function computeIntervalInputData(session, input) {
- var last = session.lastInterval || input,
- deltaTime = input.timeStamp - last.timeStamp,
- velocity, velocityX, velocityY, direction;
- if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
- var deltaX = last.deltaX - input.deltaX;
- var deltaY = last.deltaY - input.deltaY;
- var v = getVelocity(deltaTime, deltaX, deltaY);
- velocityX = v.x;
- velocityY = v.y;
- velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
- direction = getDirection(deltaX, deltaY);
- session.lastInterval = input;
- } else {
- // use latest velocity info if it doesn't overtake a minimum period
- velocity = last.velocity;
- velocityX = last.velocityX;
- velocityY = last.velocityY;
- direction = last.direction;
- }
- input.velocity = velocity;
- input.velocityX = velocityX;
- input.velocityY = velocityY;
- input.direction = direction;
- }
- /**
- * create a simple clone from the input used for storage of firstInput and firstMultiple
- * @param {Object} input
- * @returns {Object} clonedInputData
- */
- function simpleCloneInputData(input) {
- // make a simple copy of the pointers because we will get a reference if we don't
- // we only need clientXY for the calculations
- var pointers = [];
- var i = 0;
- while (i < input.pointers.length) {
- pointers[i] = {
- clientX: round(input.pointers[i].clientX),
- clientY: round(input.pointers[i].clientY)
- };
- i++;
- }
- return {
- timeStamp: now(),
- pointers: pointers,
- center: getCenter(pointers),
- deltaX: input.deltaX,
- deltaY: input.deltaY
- };
- }
- /**
- * get the center of all the pointers
- * @param {Array} pointers
- * @return {Object} center contains `x` and `y` properties
- */
- function getCenter(pointers) {
- var pointersLength = pointers.length;
- // no need to loop when only one touch
- if (pointersLength === 1) {
- return {
- x: round(pointers[0].clientX),
- y: round(pointers[0].clientY)
- };
- }
- var x = 0, y = 0, i = 0;
- while (i < pointersLength) {
- x += pointers[i].clientX;
- y += pointers[i].clientY;
- i++;
- }
- return {
- x: round(x / pointersLength),
- y: round(y / pointersLength)
- };
- }
- /**
- * calculate the velocity between two points. unit is in px per ms.
- * @param {Number} deltaTime
- * @param {Number} x
- * @param {Number} y
- * @return {Object} velocity `x` and `y`
- */
- function getVelocity(deltaTime, x, y) {
- return {
- x: x / deltaTime || 0,
- y: y / deltaTime || 0
- };
- }
- /**
- * get the direction between two points
- * @param {Number} x
- * @param {Number} y
- * @return {Number} direction
- */
- function getDirection(x, y) {
- if (x === y) {
- return DIRECTION_NONE;
- }
- if (abs(x) >= abs(y)) {
- return x > 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
- }
- return y > 0 ? DIRECTION_UP : DIRECTION_DOWN;
- }
- /**
- * calculate the absolute distance between two points
- * @param {Object} p1 {x, y}
- * @param {Object} p2 {x, y}
- * @param {Array} [props] containing x and y keys
- * @return {Number} distance
- */
- function getDistance(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]],
- y = p2[props[1]] - p1[props[1]];
- return Math.sqrt((x * x) + (y * y));
- }
- /**
- * calculate the angle between two coordinates
- * @param {Object} p1
- * @param {Object} p2
- * @param {Array} [props] containing x and y keys
- * @return {Number} angle
- */
- function getAngle(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]],
- y = p2[props[1]] - p1[props[1]];
- return Math.atan2(y, x) * 180 / Math.PI;
- }
- /**
- * calculate the rotation degrees between two pointersets
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} rotation
- */
- function getRotation(start, end) {
- return getAngle(end[1], end[0], PROPS_CLIENT_XY) - getAngle(start[1], start[0], PROPS_CLIENT_XY);
- }
- /**
- * calculate the scale factor between two pointersets
- * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} scale
- */
- function getScale(start, end) {
- return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
- }
- var MOUSE_INPUT_MAP = {
- mousedown: INPUT_START,
- mousemove: INPUT_MOVE,
- mouseup: INPUT_END
- };
- var MOUSE_ELEMENT_EVENTS = 'mousedown';
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
- /**
- * Mouse events input
- * @constructor
- * @extends Input
- */
- function MouseInput() {
- this.evEl = MOUSE_ELEMENT_EVENTS;
- this.evWin = MOUSE_WINDOW_EVENTS;
- this.allow = true; // used by Input.TouchMouse to disable mouse events
- this.pressed = false; // mousedown state
- Input.apply(this, arguments);
- }
- inherit(MouseInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function MEhandler(ev) {
- var eventType = MOUSE_INPUT_MAP[ev.type];
- // on start we want to have the left mouse button down
- if (eventType & INPUT_START && ev.button === 0) {
- this.pressed = true;
- }
- if (eventType & INPUT_MOVE && ev.which !== 1) {
- eventType = INPUT_END;
- }
- // mouse must be down, and mouse events are allowed (see the TouchMouse input)
- if (!this.pressed || !this.allow) {
- return;
- }
- if (eventType & INPUT_END) {
- this.pressed = false;
- }
- this.callback(this.manager, eventType, {
- pointers: [ev],
- changedPointers: [ev],
- pointerType: INPUT_TYPE_MOUSE,
- srcEvent: ev
- });
- }
- });
- var POINTER_INPUT_MAP = {
- pointerdown: INPUT_START,
- pointermove: INPUT_MOVE,
- pointerup: INPUT_END,
- pointercancel: INPUT_CANCEL,
- pointerout: INPUT_CANCEL
- };
- // in IE10 the pointer types is defined as an enum
- var IE10_POINTER_TYPE_ENUM = {
- 2: INPUT_TYPE_TOUCH,
- 3: INPUT_TYPE_PEN,
- 4: INPUT_TYPE_MOUSE,
- 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
- };
- var POINTER_ELEMENT_EVENTS = 'pointerdown';
- var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
- // IE10 has prefixed support, and case-sensitive
- if (window.MSPointerEvent) {
- POINTER_ELEMENT_EVENTS = 'MSPointerDown';
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
- }
- /**
- * Pointer events input
- * @constructor
- * @extends Input
- */
- function PointerEventInput() {
- this.evEl = POINTER_ELEMENT_EVENTS;
- this.evWin = POINTER_WINDOW_EVENTS;
- Input.apply(this, arguments);
- this.store = (this.manager.session.pointerEvents = []);
- }
- inherit(PointerEventInput, Input, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function PEhandler(ev) {
- var store = this.store;
- var removePointer = false;
- var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
- var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
- var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
- var isTouch = (pointerType == INPUT_TYPE_TOUCH);
- // get index of the event in the store
- var storeIndex = inArray(store, ev.pointerId, 'pointerId');
- // start and mouse must be down
- if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
- if (storeIndex < 0) {
- store.push(ev);
- storeIndex = store.length - 1;
- }
- } else if (eventType & (INPUT_END | INPUT_CANCEL)) {
- removePointer = true;
- }
- // it not found, so the pointer hasn't been down (so it's probably a hover)
- if (storeIndex < 0) {
- return;
- }
- // update the event in the store
- store[storeIndex] = ev;
- this.callback(this.manager, eventType, {
- pointers: store,
- changedPointers: [ev],
- pointerType: pointerType,
- srcEvent: ev
- });
- if (removePointer) {
- // remove from the store
- store.splice(storeIndex, 1);
- }
- }
- });
- var SINGLE_TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
- var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Touch events input
- * @constructor
- * @extends Input
- */
- function SingleTouchInput() {
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
- this.started = false;
- Input.apply(this, arguments);
- }
- inherit(SingleTouchInput, Input, {
- handler: function TEhandler(ev) {
- var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
- // should we handle the touch events?
- if (type === INPUT_START) {
- this.started = true;
- }
- if (!this.started) {
- return;
- }
- var touches = normalizeSingleTouches.call(this, ev, type);
- // when done, reset the started state
- if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
- this.started = false;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function normalizeSingleTouches(ev, type) {
- var all = toArray(ev.touches);
- var changed = toArray(ev.changedTouches);
- if (type & (INPUT_END | INPUT_CANCEL)) {
- all = uniqueArray(all.concat(changed), 'identifier', true);
- }
- return [all, changed];
- }
- var TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Multi-user touch events input
- * @constructor
- * @extends Input
- */
- function TouchInput() {
- this.evTarget = TOUCH_TARGET_EVENTS;
- this.targetIds = {};
- Input.apply(this, arguments);
- }
- inherit(TouchInput, Input, {
- handler: function MTEhandler(ev) {
- var type = TOUCH_INPUT_MAP[ev.type];
- var touches = getTouches.call(this, ev, type);
- if (!touches) {
- return;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function getTouches(ev, type) {
- var allTouches = toArray(ev.touches);
- var targetIds = this.targetIds;
- // when there is only one touch, the process can be simplified
- if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
- targetIds[allTouches[0].identifier] = true;
- return [allTouches, allTouches];
- }
- var i,
- targetTouches,
- changedTouches = toArray(ev.changedTouches),
- changedTargetTouches = [],
- target = this.target;
- // get target touches from touches
- targetTouches = allTouches.filter(function(touch) {
- return hasParent(touch.target, target);
- });
- // collect touches
- if (type === INPUT_START) {
- i = 0;
- while (i < targetTouches.length) {
- targetIds[targetTouches[i].identifier] = true;
- i++;
- }
- }
- // filter changed touches to only contain touches that exist in the collected target ids
- i = 0;
- while (i < changedTouches.length) {
- if (targetIds[changedTouches[i].identifier]) {
- changedTargetTouches.push(changedTouches[i]);
- }
- // cleanup removed touches
- if (type & (INPUT_END | INPUT_CANCEL)) {
- delete targetIds[changedTouches[i].identifier];
- }
- i++;
- }
- if (!changedTargetTouches.length) {
- return;
- }
- return [
- // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
- uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
- changedTargetTouches
- ];
- }
- /**
- * Combined touch and mouse input
- *
- * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
- * This because touch devices also emit mouse events while doing a touch.
- *
- * @constructor
- * @extends Input
- */
- function TouchMouseInput() {
- Input.apply(this, arguments);
- var handler = bindFn(this.handler, this);
- this.touch = new TouchInput(this.manager, handler);
- this.mouse = new MouseInput(this.manager, handler);
- }
- inherit(TouchMouseInput, Input, {
- /**
- * handle mouse and touch events
- * @param {Hammer} manager
- * @param {String} inputEvent
- * @param {Object} inputData
- */
- handler: function TMEhandler(manager, inputEvent, inputData) {
- var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH),
- isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
- // when we're in a touch event, so block all upcoming mouse events
- // most mobile browser also emit mouseevents, right after touchstart
- if (isTouch) {
- this.mouse.allow = false;
- } else if (isMouse && !this.mouse.allow) {
- return;
- }
- // reset the allowMouse when we're done
- if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
- this.mouse.allow = true;
- }
- this.callback(manager, inputEvent, inputData);
- },
- /**
- * remove the event listeners
- */
- destroy: function destroy() {
- this.touch.destroy();
- this.mouse.destroy();
- }
- });
- var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
- // magical touchAction value
- var TOUCH_ACTION_COMPUTE = 'compute';
- var TOUCH_ACTION_AUTO = 'auto';
- var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
- var TOUCH_ACTION_NONE = 'none';
- var TOUCH_ACTION_PAN_X = 'pan-x';
- var TOUCH_ACTION_PAN_Y = 'pan-y';
- /**
- * Touch Action
- * sets the touchAction property or uses the js alternative
- * @param {Manager} manager
- * @param {String} value
- * @constructor
- */
- function TouchAction(manager, value) {
- this.manager = manager;
- this.set(value);
- }
- TouchAction.prototype = {
- /**
- * set the touchAction value on the element or enable the polyfill
- * @param {String} value
- */
- set: function(value) {
- // find out the touch-action by the event handlers
- if (value == TOUCH_ACTION_COMPUTE) {
- value = this.compute();
- }
- if (NATIVE_TOUCH_ACTION) {
- this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
- }
- this.actions = value.toLowerCase().trim();
- },
- /**
- * just re-set the touchAction value
- */
- update: function() {
- this.set(this.manager.options.touchAction);
- },
- /**
- * compute the value for the touchAction property based on the recognizer's settings
- * @returns {String} value
- */
- compute: function() {
- var actions = [];
- each(this.manager.recognizers, function(recognizer) {
- if (boolOrFn(recognizer.options.enable, [recognizer])) {
- actions = actions.concat(recognizer.getTouchAction());
- }
- });
- return cleanTouchActions(actions.join(' '));
- },
- /**
- * this method is called on each input cycle and provides the preventing of the browser behavior
- * @param {Object} input
- */
- preventDefaults: function(input) {
- // not needed with native support for the touchAction property
- if (NATIVE_TOUCH_ACTION) {
- return;
- }
- var srcEvent = input.srcEvent;
- var direction = input.offsetDirection;
- // if the touch action did prevented once this session
- if (this.manager.session.prevented) {
- srcEvent.preventDefault();
- return;
- }
- var actions = this.actions;
- var hasNone = inStr(actions, TOUCH_ACTION_NONE);
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
- if (hasNone ||
- (hasPanY && direction & DIRECTION_HORIZONTAL) ||
- (hasPanX && direction & DIRECTION_VERTICAL)) {
- return this.preventSrc(srcEvent);
- }
- },
- /**
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
- * @param {Object} srcEvent
- */
- preventSrc: function(srcEvent) {
- this.manager.session.prevented = true;
- srcEvent.preventDefault();
- }
- };
- /**
- * when the touchActions are collected they are not a valid value, so we need to clean things up. *
- * @param {String} actions
- * @returns {*}
- */
- function cleanTouchActions(actions) {
- // none
- if (inStr(actions, TOUCH_ACTION_NONE)) {
- return TOUCH_ACTION_NONE;
- }
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
- // pan-x and pan-y can be combined
- if (hasPanX && hasPanY) {
- return TOUCH_ACTION_PAN_X + ' ' + TOUCH_ACTION_PAN_Y;
- }
- // pan-x OR pan-y
- if (hasPanX || hasPanY) {
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
- }
- // manipulation
- if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
- return TOUCH_ACTION_MANIPULATION;
- }
- return TOUCH_ACTION_AUTO;
- }
- /**
- * Recognizer flow explained; *
- * All recognizers have the initial state of POSSIBLE when a input session starts.
- * The definition of a input session is from the first input until the last input, with all it's movement in it. *
- * Example session for mouse-input: mousedown -> mousemove -> mouseup
- *
- * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
- * which determines with state it should be.
- *
- * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
- * POSSIBLE to give it another change on the next cycle.
- *
- * Possible
- * |
- * +-----+---------------+
- * | |
- * +-----+-----+ |
- * | | |
- * Failed Cancelled |
- * +-------+------+
- * | |
- * Recognized Began
- * |
- * Changed
- * |
- * Ended/Recognized
- */
- var STATE_POSSIBLE = 1;
- var STATE_BEGAN = 2;
- var STATE_CHANGED = 4;
- var STATE_ENDED = 8;
- var STATE_RECOGNIZED = STATE_ENDED;
- var STATE_CANCELLED = 16;
- var STATE_FAILED = 32;
- /**
- * Recognizer
- * Every recognizer needs to extend from this class.
- * @constructor
- * @param {Object} options
- */
- function Recognizer(options) {
- this.id = uniqueId();
- this.manager = null;
- this.options = merge(options || {}, this.defaults);
- // default is enable true
- this.options.enable = ifUndefined(this.options.enable, true);
- this.state = STATE_POSSIBLE;
- this.simultaneous = {};
- this.requireFail = [];
- }
- Recognizer.prototype = {
- /**
- * @virtual
- * @type {Object}
- */
- defaults: {},
- /**
- * set options
- * @param {Object} options
- * @return {Recognizer}
- */
- set: function(options) {
- extend(this.options, options);
- // also update the touchAction, in case something changed about the directions/enabled state
- this.manager && this.manager.touchAction.update();
- return this;
- },
- /**
- * recognize simultaneous with an other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- recognizeWith: function(otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
- return this;
- }
- var simultaneous = this.simultaneous;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (!simultaneous[otherRecognizer.id]) {
- simultaneous[otherRecognizer.id] = otherRecognizer;
- otherRecognizer.recognizeWith(this);
- }
- return this;
- },
- /**
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRecognizeWith: function(otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- delete this.simultaneous[otherRecognizer.id];
- return this;
- },
- /**
- * recognizer can only run when an other is failing
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- requireFailure: function(otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
- return this;
- }
- var requireFail = this.requireFail;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (inArray(requireFail, otherRecognizer) === -1) {
- requireFail.push(otherRecognizer);
- otherRecognizer.requireFailure(this);
- }
- return this;
- },
- /**
- * drop the requireFailure link. it does not remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRequireFailure: function(otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- var index = inArray(this.requireFail, otherRecognizer);
- if (index > -1) {
- this.requireFail.splice(index, 1);
- }
- return this;
- },
- /**
- * has require failures boolean
- * @returns {boolean}
- */
- hasRequireFailures: function() {
- return this.requireFail.length > 0;
- },
- /**
- * if the recognizer can recognize simultaneous with an other recognizer
- * @param {Recognizer} otherRecognizer
- * @returns {Boolean}
- */
- canRecognizeWith: function(otherRecognizer) {
- return !!this.simultaneous[otherRecognizer.id];
- },
- /**
- * You should use `tryEmit` instead of `emit` directly to check
- * that all the needed recognizers has failed before emitting.
- * @param {Object} input
- */
- emit: function(input) {
- var self = this;
- var state = this.state;
- function emit(withState) {
- self.manager.emit(self.options.event + (withState ? stateStr(state) : ''), input);
- }
- // 'panstart' and 'panmove'
- if (state < STATE_ENDED) {
- emit(true);
- }
- emit(); // simple 'eventName' events
- // panend and pancancel
- if (state >= STATE_ENDED) {
- emit(true);
- }
- },
- /**
- * Check that all the require failure recognizers has failed,
- * if true, it emits a gesture event,
- * otherwise, setup the state to FAILED.
- * @param {Object} input
- */
- tryEmit: function(input) {
- if (this.canEmit()) {
- return this.emit(input);
- }
- // it's failing anyway
- this.state = STATE_FAILED;
- },
- /**
- * can we emit?
- * @returns {boolean}
- */
- canEmit: function() {
- var i = 0;
- while (i < this.requireFail.length) {
- if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
- return false;
- }
- i++;
- }
- return true;
- },
- /**
- * update the recognizer
- * @param {Object} inputData
- */
- recognize: function(inputData) {
- // make a new copy of the inputData
- // so we can change the inputData without messing up the other recognizers
- var inputDataClone = extend({}, inputData);
- // is is enabled and allow recognizing?
- if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
- this.reset();
- this.state = STATE_FAILED;
- return;
- }
- // reset when we've reached the end
- if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
- this.state = STATE_POSSIBLE;
- }
- this.state = this.process(inputDataClone);
- // the recognizer has recognized a gesture
- // so trigger an event
- if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
- this.tryEmit(inputDataClone);
- }
- },
- /**
- * return the state of the recognizer
- * the actual recognizing happens in this method
- * @virtual
- * @param {Object} inputData
- * @returns {Const} STATE
- */
- process: function(inputData) { }, // jshint ignore:line
- /**
- * return the preferred touch-action
- * @virtual
- * @returns {Array}
- */
- getTouchAction: function() { },
- /**
- * called when the gesture isn't allowed to recognize
- * like when another is being recognized or it is disabled
- * @virtual
- */
- reset: function() { }
- };
- /**
- * get a usable string, used as event postfix
- * @param {Const} state
- * @returns {String} state
- */
- function stateStr(state) {
- if (state & STATE_CANCELLED) {
- return 'cancel';
- } else if (state & STATE_ENDED) {
- return 'end';
- } else if (state & STATE_CHANGED) {
- return 'move';
- } else if (state & STATE_BEGAN) {
- return 'start';
- }
- return '';
- }
- /**
- * direction cons to string
- * @param {Const} direction
- * @returns {String}
- */
- function directionStr(direction) {
- if (direction == DIRECTION_DOWN) {
- return 'down';
- } else if (direction == DIRECTION_UP) {
- return 'up';
- } else if (direction == DIRECTION_LEFT) {
- return 'left';
- } else if (direction == DIRECTION_RIGHT) {
- return 'right';
- }
- return '';
- }
- /**
- * get a recognizer by name if it is bound to a manager
- * @param {Recognizer|String} otherRecognizer
- * @param {Recognizer} recognizer
- * @returns {Recognizer}
- */
- function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
- var manager = recognizer.manager;
- if (manager) {
- return manager.get(otherRecognizer);
- }
- return otherRecognizer;
- }
- /**
- * This recognizer is just used as a base for the simple attribute recognizers.
- * @constructor
- * @extends Recognizer
- */
- function AttrRecognizer() {
- Recognizer.apply(this, arguments);
- }
- inherit(AttrRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof AttrRecognizer
- */
- defaults: {
- /**
- * @type {Number}
- * @default 1
- */
- pointers: 1
- },
- /**
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {Boolean} recognized
- */
- attrTest: function(input) {
- var optionPointers = this.options.pointers;
- return optionPointers === 0 || input.pointers.length === optionPointers;
- },
- /**
- * Process the input and return the state for the recognizer
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {*} State
- */
- process: function(input) {
- var state = this.state;
- var eventType = input.eventType;
- var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
- var isValid = this.attrTest(input);
- // on cancel input and we've recognized before, return STATE_CANCELLED
- if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
- return state | STATE_CANCELLED;
- } else if (isRecognized || isValid) {
- if (eventType & INPUT_END) {
- return state | STATE_ENDED;
- } else if (!(state & STATE_BEGAN)) {
- return STATE_BEGAN;
- }
- return state | STATE_CHANGED;
- }
- return STATE_FAILED;
- }
- });
- /**
- * Pan
- * Recognized when the pointer is down and moved in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function PanRecognizer() {
- AttrRecognizer.apply(this, arguments);
- this.pX = null;
- this.pY = null;
- }
- inherit(PanRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PanRecognizer
- */
- defaults: {
- event: 'pan',
- threshold: 10,
- pointers: 1,
- direction: DIRECTION_ALL
- },
- getTouchAction: function() {
- var direction = this.options.direction;
- var actions = [];
- if (direction & DIRECTION_HORIZONTAL) {
- actions.push(TOUCH_ACTION_PAN_Y);
- }
- if (direction & DIRECTION_VERTICAL) {
- actions.push(TOUCH_ACTION_PAN_X);
- }
- return actions;
- },
- directionTest: function(input) {
- var options = this.options;
- var hasMoved = true;
- var distance = input.distance;
- var direction = input.direction;
- var x = input.deltaX;
- var y = input.deltaY;
- // lock to axis?
- if (!(direction & options.direction)) {
- if (options.direction & DIRECTION_HORIZONTAL) {
- direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
- hasMoved = x != this.pX;
- distance = Math.abs(input.deltaX);
- } else {
- direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
- hasMoved = y != this.pY;
- distance = Math.abs(input.deltaY);
- }
- }
- input.direction = direction;
- return hasMoved && distance > options.threshold && direction & options.direction;
- },
- attrTest: function(input) {
- return AttrRecognizer.prototype.attrTest.call(this, input) &&
- (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
- },
- emit: function(input) {
- this.pX = input.deltaX;
- this.pY = input.deltaY;
- var direction = directionStr(input.direction);
- if (direction) {
- this.manager.emit(this.options.event + direction, input);
- }
- this._super.emit.call(this, input);
- }
- });
- /**
- * Pinch
- * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
- * @constructor
- * @extends AttrRecognizer
- */
- function PinchRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(PinchRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'pinch',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function() {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function(input) {
- return this._super.attrTest.call(this, input) &&
- (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
- },
- emit: function(input) {
- this._super.emit.call(this, input);
- if (input.scale !== 1) {
- var inOut = input.scale < 1 ? 'in' : 'out';
- this.manager.emit(this.options.event + inOut, input);
- }
- }
- });
- /**
- * Press
- * Recognized when the pointer is down for x ms without any movement.
- * @constructor
- * @extends Recognizer
- */
- function PressRecognizer() {
- Recognizer.apply(this, arguments);
- this._timer = null;
- this._input = null;
- }
- inherit(PressRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PressRecognizer
- */
- defaults: {
- event: 'press',
- pointers: 1,
- time: 500, // minimal time of the pointer to be pressed
- threshold: 5 // a minimal movement is ok, but keep it low
- },
- getTouchAction: function() {
- return [TOUCH_ACTION_AUTO];
- },
- process: function(input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTime = input.deltaTime > options.time;
- this._input = input;
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
- this.reset();
- } else if (input.eventType & INPUT_START) {
- this.reset();
- this._timer = setTimeoutContext(function() {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.time, this);
- } else if (input.eventType & INPUT_END) {
- return STATE_RECOGNIZED;
- }
- return STATE_FAILED;
- },
- reset: function() {
- clearTimeout(this._timer);
- },
- emit: function(input) {
- if (this.state !== STATE_RECOGNIZED) {
- return;
- }
- if (input && (input.eventType & INPUT_END)) {
- this.manager.emit(this.options.event + 'up', input);
- } else {
- this._input.timeStamp = now();
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Rotate
- * Recognized when two or more pointer are moving in a circular motion.
- * @constructor
- * @extends AttrRecognizer
- */
- function RotateRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(RotateRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof RotateRecognizer
- */
- defaults: {
- event: 'rotate',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function() {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function(input) {
- return this._super.attrTest.call(this, input) &&
- (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
- }
- });
- /**
- * Swipe
- * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function SwipeRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(SwipeRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof SwipeRecognizer
- */
- defaults: {
- event: 'swipe',
- threshold: 10,
- velocity: 0.65,
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
- pointers: 1
- },
- getTouchAction: function() {
- return PanRecognizer.prototype.getTouchAction.call(this);
- },
- attrTest: function(input) {
- var direction = this.options.direction;
- var velocity;
- if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
- velocity = input.velocity;
- } else if (direction & DIRECTION_HORIZONTAL) {
- velocity = input.velocityX;
- } else if (direction & DIRECTION_VERTICAL) {
- velocity = input.velocityY;
- }
- return this._super.attrTest.call(this, input) &&
- direction & input.direction &&
- input.distance > this.options.threshold &&
- abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
- },
- emit: function(input) {
- var direction = directionStr(input.direction);
- if (direction) {
- this.manager.emit(this.options.event + direction, input);
- }
- this.manager.emit(this.options.event, input);
- }
- });
- /**
- * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
- * between the given interval and position. The delay option can be used to recognize multi-taps without firing
- * a single tap.
- *
- * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
- * multi-taps being recognized.
- * @constructor
- * @extends Recognizer
- */
- function TapRecognizer() {
- Recognizer.apply(this, arguments);
- // previous time and center,
- // used for tap counting
- this.pTime = false;
- this.pCenter = false;
- this._timer = null;
- this._input = null;
- this.count = 0;
- }
- inherit(TapRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'tap',
- pointers: 1,
- taps: 1,
- interval: 300, // max time between the multi-tap taps
- time: 250, // max time of the pointer to be down (like finger on the screen)
- threshold: 2, // a minimal movement is ok, but keep it low
- posThreshold: 10 // a multi-tap can be a bit off the initial position
- },
- getTouchAction: function() {
- return [TOUCH_ACTION_MANIPULATION];
- },
- process: function(input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTouchTime = input.deltaTime < options.time;
- this.reset();
- if ((input.eventType & INPUT_START) && (this.count === 0)) {
- return this.failTimeout();
- }
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (validMovement && validTouchTime && validPointers) {
- if (input.eventType != INPUT_END) {
- return this.failTimeout();
- }
- var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
- var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
- this.pTime = input.timeStamp;
- this.pCenter = input.center;
- if (!validMultiTap || !validInterval) {
- this.count = 1;
- } else {
- this.count += 1;
- }
- this._input = input;
- // if tap count matches we have recognized it,
- // else it has began recognizing...
- var tapCount = this.count % options.taps;
- if (tapCount === 0) {
- // no failing requirements, immediately trigger the tap event
- // or wait as long as the multitap interval to trigger
- if (!this.hasRequireFailures()) {
- return STATE_RECOGNIZED;
- } else {
- this._timer = setTimeoutContext(function() {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.interval, this);
- return STATE_BEGAN;
- }
- }
- }
- return STATE_FAILED;
- },
- failTimeout: function() {
- this._timer = setTimeoutContext(function() {
- this.state = STATE_FAILED;
- }, this.options.interval, this);
- return STATE_FAILED;
- },
- reset: function() {
- clearTimeout(this._timer);
- },
- emit: function() {
- if (this.state == STATE_RECOGNIZED ) {
- this._input.tapCount = this.count;
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Simple way to create an manager with a default set of recognizers.
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Hammer(element, options) {
- options = options || {};
- options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
- return new Manager(element, options);
- }
- /**
- * @const {string}
- */
- Hammer.VERSION = '2.0.4';
- /**
- * default settings
- * @namespace
- */
- Hammer.defaults = {
- /**
- * set if DOM events are being triggered.
- * But this is slower and unused by simple implementations, so disabled by default.
- * @type {Boolean}
- * @default false
- */
- domEvents: false,
- /**
- * The value for the touchAction property/fallback.
- * When set to `compute` it will magically set the correct value based on the added recognizers.
- * @type {String}
- * @default compute
- */
- touchAction: TOUCH_ACTION_COMPUTE,
- /**
- * @type {Boolean}
- * @default true
- */
- enable: true,
- /**
- * EXPERIMENTAL FEATURE -- can be removed/changed
- * Change the parent input target element.
- * If Null, then it is being set the to main element.
- * @type {Null|EventTarget}
- * @default null
- */
- inputTarget: null,
- /**
- * force an input class
- * @type {Null|Function}
- * @default null
- */
- inputClass: null,
- /**
- * Default recognizer setup when calling `Hammer()`
- * When creating a new Manager these will be skipped.
- * @type {Array}
- */
- preset: [
- // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
- [RotateRecognizer, { enable: false }],
- [PinchRecognizer, { enable: false }, ['rotate']],
- [SwipeRecognizer,{ direction: DIRECTION_HORIZONTAL }],
- [PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ['swipe']],
- [TapRecognizer],
- [TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']],
- [PressRecognizer]
- ],
- /**
- * Some CSS properties can be used to improve the working of Hammer.
- * Add them to this method and they will be set when creating a new Manager.
- * @namespace
- */
- cssProps: {
- /**
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userSelect: 'none',
- /**
- * Disable the Windows Phone grippers when pressing an element.
- * @type {String}
- * @default 'none'
- */
- touchSelect: 'none',
- /**
- * Disables the default callout shown when you touch and hold a touch target.
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
- * a callout containing information about the link. This property allows you to disable that callout.
- * @type {String}
- * @default 'none'
- */
- touchCallout: 'none',
- /**
- * Specifies whether zooming is enabled. Used by IE10>
- * @type {String}
- * @default 'none'
- */
- contentZooming: 'none',
- /**
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userDrag: 'none',
- /**
- * Overrides the highlight color shown when the user taps a link or a JavaScript
- * clickable element in iOS. This property obeys the alpha value, if specified.
- * @type {String}
- * @default 'rgba(0,0,0,0)'
- */
- tapHighlightColor: 'rgba(0,0,0,0)'
- }
- };
- var STOP = 1;
- var FORCED_STOP = 2;
- /**
- * Manager
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Manager(element, options) {
- options = options || {};
- this.options = merge(options, Hammer.defaults);
- this.options.inputTarget = this.options.inputTarget || element;
- this.handlers = {};
- this.session = {};
- this.recognizers = [];
- this.element = element;
- this.input = createInputInstance(this);
- this.touchAction = new TouchAction(this, this.options.touchAction);
- toggleCssProps(this, true);
- each(options.recognizers, function(item) {
- var recognizer = this.add(new (item[0])(item[1]));
- item[2] && recognizer.recognizeWith(item[2]);
- item[3] && recognizer.requireFailure(item[3]);
- }, this);
- }
- Manager.prototype = {
- /**
- * set options
- * @param {Object} options
- * @returns {Manager}
- */
- set: function(options) {
- extend(this.options, options);
- // Options that need a little more setup
- if (options.touchAction) {
- this.touchAction.update();
- }
- if (options.inputTarget) {
- // Clean up existing event listeners and reinitialize
- this.input.destroy();
- this.input.target = options.inputTarget;
- this.input.init();
- }
- return this;
- },
- /**
- * stop recognizing for this session.
- * This session will be discarded, when a new [input]start event is fired.
- * When forced, the recognizer cycle is stopped immediately.
- * @param {Boolean} [force]
- */
- stop: function(force) {
- this.session.stopped = force ? FORCED_STOP : STOP;
- },
- /**
- * run the recognizers!
- * called by the inputHandler function on every movement of the pointers (touches)
- * it walks through all the recognizers and tries to detect the gesture that is being made
- * @param {Object} inputData
- */
- recognize: function(inputData) {
- var session = this.session;
- if (session.stopped) {
- return;
- }
- // run the touch-action polyfill
- this.touchAction.preventDefaults(inputData);
- var recognizer;
- var recognizers = this.recognizers;
- // this holds the recognizer that is being recognized.
- // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
- // if no recognizer is detecting a thing, it is set to `null`
- var curRecognizer = session.curRecognizer;
- // reset when the last recognizer is recognized
- // or when we're in a new session
- if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
- curRecognizer = session.curRecognizer = null;
- }
- var i = 0;
- while (i < recognizers.length) {
- recognizer = recognizers[i];
- // find out if we are allowed try to recognize the input for this one.
- // 1. allow if the session is NOT forced stopped (see the .stop() method)
- // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
- // that is being recognized.
- // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
- // this can be setup with the `recognizeWith()` method on the recognizer.
- if (session.stopped !== FORCED_STOP && ( // 1
- !curRecognizer || recognizer == curRecognizer || // 2
- recognizer.canRecognizeWith(curRecognizer))) { // 3
- recognizer.recognize(inputData);
- } else {
- recognizer.reset();
- }
- // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
- // current active recognizer. but only if we don't already have an active recognizer
- if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
- curRecognizer = session.curRecognizer = recognizer;
- }
- i++;
- }
- },
- /**
- * get a recognizer by its event name.
- * @param {Recognizer|String} recognizer
- * @returns {Recognizer|Null}
- */
- get: function(recognizer) {
- if (recognizer instanceof Recognizer) {
- return recognizer;
- }
- var recognizers = this.recognizers;
- for (var i = 0; i < recognizers.length; i++) {
- if (recognizers[i].options.event == recognizer) {
- return recognizers[i];
- }
- }
- return null;
- },
- /**
- * add a recognizer to the manager
- * existing recognizers with the same event name will be removed
- * @param {Recognizer} recognizer
- * @returns {Recognizer|Manager}
- */
- add: function(recognizer) {
- if (invokeArrayArg(recognizer, 'add', this)) {
- return this;
- }
- // remove existing
- var existing = this.get(recognizer.options.event);
- if (existing) {
- this.remove(existing);
- }
- this.recognizers.push(recognizer);
- recognizer.manager = this;
- this.touchAction.update();
- return recognizer;
- },
- /**
- * remove a recognizer by name or instance
- * @param {Recognizer|String} recognizer
- * @returns {Manager}
- */
- remove: function(recognizer) {
- if (invokeArrayArg(recognizer, 'remove', this)) {
- return this;
- }
- var recognizers = this.recognizers;
- recognizer = this.get(recognizer);
- recognizers.splice(inArray(recognizers, recognizer), 1);
- this.touchAction.update();
- return this;
- },
- /**
- * bind event
- * @param {String} events
- * @param {Function} handler
- * @returns {EventEmitter} this
- */
- on: function(events, handler) {
- var handlers = this.handlers;
- each(splitStr(events), function(event) {
- handlers[event] = handlers[event] || [];
- handlers[event].push(handler);
- });
- return this;
- },
- /**
- * unbind event, leave emit blank to remove all handlers
- * @param {String} events
- * @param {Function} [handler]
- * @returns {EventEmitter} this
- */
- off: function(events, handler) {
- var handlers = this.handlers;
- each(splitStr(events), function(event) {
- if (!handler) {
- delete handlers[event];
- } else {
- handlers[event].splice(inArray(handlers[event], handler), 1);
- }
- });
- return this;
- },
- /**
- * emit event to the listeners
- * @param {String} event
- * @param {Object} data
- */
- emit: function(event, data) {
- // we also want to trigger dom events
- if (this.options.domEvents) {
- triggerDomEvent(event, data);
- }
- // no handlers, so skip it all
- var handlers = this.handlers[event] && this.handlers[event].slice();
- if (!handlers || !handlers.length) {
- return;
- }
- data.type = event;
- data.preventDefault = function() {
- data.srcEvent.preventDefault();
- };
- var i = 0;
- while (i < handlers.length) {
- handlers[i](data);
- i++;
- }
- },
- /**
- * destroy the manager and unbinds all events
- * it doesn't unbind dom events, that is the user own responsibility
- */
- destroy: function() {
- this.element && toggleCssProps(this, false);
- this.handlers = {};
- this.session = {};
- this.input.destroy();
- this.element = null;
- }
- };
- /**
- * add/remove the css properties as defined in manager.options.cssProps
- * @param {Manager} manager
- * @param {Boolean} add
- */
- function toggleCssProps(manager, add) {
- var element = manager.element;
- each(manager.options.cssProps, function(value, name) {
- element.style[prefixed(element.style, name)] = add ? value : '';
- });
- }
- /**
- * trigger dom event
- * @param {String} event
- * @param {Object} data
- */
- function triggerDomEvent(event, data) {
- var gestureEvent = document.createEvent('Event');
- gestureEvent.initEvent(event, true, true);
- gestureEvent.gesture = data;
- data.target.dispatchEvent(gestureEvent);
- }
- extend(Hammer, {
- INPUT_START: INPUT_START,
- INPUT_MOVE: INPUT_MOVE,
- INPUT_END: INPUT_END,
- INPUT_CANCEL: INPUT_CANCEL,
- STATE_POSSIBLE: STATE_POSSIBLE,
- STATE_BEGAN: STATE_BEGAN,
- STATE_CHANGED: STATE_CHANGED,
- STATE_ENDED: STATE_ENDED,
- STATE_RECOGNIZED: STATE_RECOGNIZED,
- STATE_CANCELLED: STATE_CANCELLED,
- STATE_FAILED: STATE_FAILED,
- DIRECTION_NONE: DIRECTION_NONE,
- DIRECTION_LEFT: DIRECTION_LEFT,
- DIRECTION_RIGHT: DIRECTION_RIGHT,
- DIRECTION_UP: DIRECTION_UP,
- DIRECTION_DOWN: DIRECTION_DOWN,
- DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
- DIRECTION_VERTICAL: DIRECTION_VERTICAL,
- DIRECTION_ALL: DIRECTION_ALL,
- Manager: Manager,
- Input: Input,
- TouchAction: TouchAction,
- TouchInput: TouchInput,
- MouseInput: MouseInput,
- PointerEventInput: PointerEventInput,
- TouchMouseInput: TouchMouseInput,
- SingleTouchInput: SingleTouchInput,
- Recognizer: Recognizer,
- AttrRecognizer: AttrRecognizer,
- Tap: TapRecognizer,
- Pan: PanRecognizer,
- Swipe: SwipeRecognizer,
- Pinch: PinchRecognizer,
- Rotate: RotateRecognizer,
- Press: PressRecognizer,
- on: addEventListeners,
- off: removeEventListeners,
- each: each,
- merge: merge,
- extend: extend,
- inherit: inherit,
- bindFn: bindFn,
- prefixed: prefixed
- });
- if (typeof define == TYPE_FUNCTION && define.amd) {
- define(function() {
- return Hammer;
- });
- } else if (typeof module != 'undefined' && module.exports) {
- module.exports = Hammer;
- } else {
- window[exportName] = Hammer;
- }
- })(window, document, 'Hammer');
- },{}],199:[function(_dereq_,module,exports){
- // Snap.svg 0.3.0
- //
- // Copyright (c) 2013 – 2014 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- //
- // build: 2014-09-08
- (function (glob, factory) {
- // AMD support
- if (typeof define === "function" && define.amd) {
- // Define as an anonymous module
- define(["eve"], function( eve ) {
- return factory(glob, eve);
- });
- } else if (typeof exports !== 'undefined') {
- // Next for Node.js or CommonJS
- var eve = _dereq_(197);
- module.exports = factory(glob, eve);
- } else {
- // Browser globals (glob is window)
- // Snap adds itself to window
- factory(glob, glob.eve);
- }
- }(window || this, function (window, eve) {
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- var mina = (function (eve) {
- var animations = {},
- requestAnimFrame = window.requestAnimationFrame ||
- window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame ||
- window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame ||
- function (callback) {
- setTimeout(callback, 16);
- },
- isArray = Array.isArray || function (a) {
- return a instanceof Array ||
- Object.prototype.toString.call(a) == "[object Array]";
- },
- idgen = 0,
- idprefix = "M" + (+new Date).toString(36),
- ID = function () {
- return idprefix + (idgen++).toString(36);
- },
- diff = function (a, b, A, B) {
- if (isArray(a)) {
- res = [];
- for (var i = 0, ii = a.length; i < ii; i++) {
- res[i] = diff(a[i], b, A[i], B);
- }
- return res;
- }
- var dif = (A - a) / (B - b);
- return function (bb) {
- return a + dif * (bb - b);
- };
- },
- timer = Date.now || function () {
- return +new Date;
- },
- sta = function (val) {
- var a = this;
- if (val == null) {
- return a.s;
- }
- var ds = a.s - val;
- a.b += a.dur * ds;
- a.B += a.dur * ds;
- a.s = val;
- },
- speed = function (val) {
- var a = this;
- if (val == null) {
- return a.spd;
- }
- a.spd = val;
- },
- duration = function (val) {
- var a = this;
- if (val == null) {
- return a.dur;
- }
- a.s = a.s * val / a.dur;
- a.dur = val;
- },
- stopit = function () {
- var a = this;
- delete animations[a.id];
- a.update();
- eve("mina.stop." + a.id, a);
- },
- pause = function () {
- var a = this;
- if (a.pdif) {
- return;
- }
- delete animations[a.id];
- a.update();
- a.pdif = a.get() - a.b;
- },
- resume = function () {
- var a = this;
- if (!a.pdif) {
- return;
- }
- a.b = a.get() - a.pdif;
- delete a.pdif;
- animations[a.id] = a;
- },
- update = function () {
- var a = this,
- res;
- if (isArray(a.start)) {
- res = [];
- for (var j = 0, jj = a.start.length; j < jj; j++) {
- res[j] = +a.start[j] +
- (a.end[j] - a.start[j]) * a.easing(a.s);
- }
- } else {
- res = +a.start + (a.end - a.start) * a.easing(a.s);
- }
- a.set(res);
- },
- frame = function () {
- var len = 0;
- for (var i in animations) if (animations.hasOwnProperty(i)) {
- var a = animations[i],
- b = a.get(),
- res;
- len++;
- a.s = (b - a.b) / (a.dur / a.spd);
- if (a.s >= 1) {
- delete animations[i];
- a.s = 1;
- len--;
- (function (a) {
- setTimeout(function () {
- eve("mina.finish." + a.id, a);
- });
- }(a));
- }
- a.update();
- }
- len && requestAnimFrame(frame);
- },
- /*\
- * mina
- [ method ]
- **
- * Generic animation of numbers
- **
- - a (number) start _slave_ number
- - A (number) end _slave_ number
- - b (number) start _master_ number (start time in general case)
- - B (number) end _master_ number (end time in gereal case)
- - get (function) getter of _master_ number (see @mina.time)
- - set (function) setter of _slave_ number
- - easing (function) #optional easing function, default is @mina.linear
- = (object) animation descriptor
- o {
- o id (string) animation id,
- o start (number) start _slave_ number,
- o end (number) end _slave_ number,
- o b (number) start _master_ number,
- o s (number) animation status (0..1),
- o dur (number) animation duration,
- o spd (number) animation speed,
- o get (function) getter of _master_ number (see @mina.time),
- o set (function) setter of _slave_ number,
- o easing (function) easing function, default is @mina.linear,
- o status (function) status getter/setter,
- o speed (function) speed getter/setter,
- o duration (function) duration getter/setter,
- o stop (function) animation stopper
- o pause (function) pauses the animation
- o resume (function) resumes the animation
- o update (function) calles setter with the right value of the animation
- o }
- \*/
- mina = function (a, A, b, B, get, set, easing) {
- var anim = {
- id: ID(),
- start: a,
- end: A,
- b: b,
- s: 0,
- dur: B - b,
- spd: 1,
- get: get,
- set: set,
- easing: easing || mina.linear,
- status: sta,
- speed: speed,
- duration: duration,
- stop: stopit,
- pause: pause,
- resume: resume,
- update: update
- };
- animations[anim.id] = anim;
- var len = 0, i;
- for (i in animations) if (animations.hasOwnProperty(i)) {
- len++;
- if (len == 2) {
- break;
- }
- }
- len == 1 && requestAnimFrame(frame);
- return anim;
- };
- /*\
- * mina.time
- [ method ]
- **
- * Returns the current time. Equivalent to:
- | function () {
- | return (new Date).getTime();
- | }
- \*/
- mina.time = timer;
- /*\
- * mina.getById
- [ method ]
- **
- * Returns an animation by its id
- - id (string) animation's id
- = (object) See @mina
- \*/
- mina.getById = function (id) {
- return animations[id] || null;
- };
- /*\
- * mina.linear
- [ method ]
- **
- * Default linear easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.linear = function (n) {
- return n;
- };
- /*\
- * mina.easeout
- [ method ]
- **
- * Easeout easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.easeout = function (n) {
- return Math.pow(n, 1.7);
- };
- /*\
- * mina.easein
- [ method ]
- **
- * Easein easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.easein = function (n) {
- return Math.pow(n, .48);
- };
- /*\
- * mina.easeinout
- [ method ]
- **
- * Easeinout easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.easeinout = function (n) {
- if (n == 1) {
- return 1;
- }
- if (n == 0) {
- return 0;
- }
- var q = .48 - n / 1.04,
- Q = Math.sqrt(.1734 + q * q),
- x = Q - q,
- X = Math.pow(Math.abs(x), 1 / 3) * (x < 0 ? -1 : 1),
- y = -Q - q,
- Y = Math.pow(Math.abs(y), 1 / 3) * (y < 0 ? -1 : 1),
- t = X + Y + .5;
- return (1 - t) * 3 * t * t + t * t * t;
- };
- /*\
- * mina.backin
- [ method ]
- **
- * Backin easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.backin = function (n) {
- if (n == 1) {
- return 1;
- }
- var s = 1.70158;
- return n * n * ((s + 1) * n - s);
- };
- /*\
- * mina.backout
- [ method ]
- **
- * Backout easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.backout = function (n) {
- if (n == 0) {
- return 0;
- }
- n = n - 1;
- var s = 1.70158;
- return n * n * ((s + 1) * n + s) + 1;
- };
- /*\
- * mina.elastic
- [ method ]
- **
- * Elastic easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.elastic = function (n) {
- if (n == !!n) {
- return n;
- }
- return Math.pow(2, -10 * n) * Math.sin((n - .075) *
- (2 * Math.PI) / .3) + 1;
- };
- /*\
- * mina.bounce
- [ method ]
- **
- * Bounce easing
- - n (number) input 0..1
- = (number) output 0..1
- \*/
- mina.bounce = function (n) {
- var s = 7.5625,
- p = 2.75,
- l;
- if (n < (1 / p)) {
- l = s * n * n;
- } else {
- if (n < (2 / p)) {
- n -= (1.5 / p);
- l = s * n * n + .75;
- } else {
- if (n < (2.5 / p)) {
- n -= (2.25 / p);
- l = s * n * n + .9375;
- } else {
- n -= (2.625 / p);
- l = s * n * n + .984375;
- }
- }
- }
- return l;
- };
- window.mina = mina;
- return mina;
- })(typeof eve == "undefined" ? function () {} : eve);
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- var Snap = (function(root) {
- Snap.version = "0.3.0";
- /*\
- * Snap
- [ method ]
- **
- * Creates a drawing surface or wraps existing SVG element.
- **
- - width (number|string) width of surface
- - height (number|string) height of surface
- * or
- - DOM (SVGElement) element to be wrapped into Snap structure
- * or
- - array (array) array of elements (will return set of elements)
- * or
- - query (string) CSS query selector
- = (object) @Element
- \*/
- function Snap(w, h) {
- if (w) {
- if (w.tagName) {
- return wrap(w);
- }
- if (is(w, "array") && Snap.set) {
- return Snap.set.apply(Snap, w);
- }
- if (w instanceof Element) {
- return w;
- }
- if (h == null) {
- w = glob.doc.querySelector(w);
- return wrap(w);
- }
- }
- w = w == null ? "100%" : w;
- h = h == null ? "100%" : h;
- return new Paper(w, h);
- }
- Snap.toString = function () {
- return "Snap v" + this.version;
- };
- Snap._ = {};
- var glob = {
- win: root.window,
- doc: root.window.document
- };
- Snap._.glob = glob;
- var has = "hasOwnProperty",
- Str = String,
- toFloat = parseFloat,
- toInt = parseInt,
- math = Math,
- mmax = math.max,
- mmin = math.min,
- abs = math.abs,
- pow = math.pow,
- PI = math.PI,
- round = math.round,
- E = "",
- S = " ",
- objectToString = Object.prototype.toString,
- ISURL = /^url\(['"]?([^\)]+?)['"]?\)$/i,
- 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,
- bezierrg = /^(?:cubic-)?bezier\(([^,]+),([^,]+),([^,]+),([^\)]+)\)/,
- reURLValue = /^url\(#?([^)]+)\)$/,
- separator = Snap._.separator = /[,\s]+/,
- whitespace = /[\s]/g,
- commaSpaces = /[\s]*,[\s]*/,
- hsrg = {hs: 1, rg: 1},
- pathCommand = /([a-z])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
- tCommand = /([rstm])[\s,]*((-?\d*\.?\d*(?:e[\-+]?\d+)?[\s]*,?[\s]*)+)/ig,
- pathValues = /(-?\d*\.?\d*(?:e[\-+]?\\d+)?)[\s]*,?[\s]*/ig,
- idgen = 0,
- idprefix = "S" + (+new Date).toString(36),
- ID = function (el) {
- return (el && el.type ? el.type : E) + idprefix + (idgen++).toString(36);
- },
- xlink = "http://www.w3.org/1999/xlink",
- xmlns = "http://www.w3.org/2000/svg",
- hub = {},
- URL = Snap.url = function (url) {
- return "url('#" + url + "')";
- };
- function $(el, attr) {
- if (attr) {
- if (el == "#text") {
- el = glob.doc.createTextNode(attr.text || "");
- }
- if (typeof el == "string") {
- el = $(el);
- }
- if (typeof attr == "string") {
- if (attr.substring(0, 6) == "xlink:") {
- return el.getAttributeNS(xlink, attr.substring(6));
- }
- if (attr.substring(0, 4) == "xml:") {
- return el.getAttributeNS(xmlns, attr.substring(4));
- }
- return el.getAttribute(attr);
- }
- for (var key in attr) if (attr[has](key)) {
- var val = Str(attr[key]);
- if (val) {
- if (key.substring(0, 6) == "xlink:") {
- el.setAttributeNS(xlink, key.substring(6), val);
- } else if (key.substring(0, 4) == "xml:") {
- el.setAttributeNS(xmlns, key.substring(4), val);
- } else {
- el.setAttribute(key, val);
- }
- } else {
- el.removeAttribute(key);
- }
- }
- } else {
- el = glob.doc.createElementNS(xmlns, el);
- }
- return el;
- }
- Snap._.$ = $;
- Snap._.id = ID;
- function getAttrs(el) {
- var attrs = el.attributes,
- name,
- out = {};
- for (var i = 0; i < attrs.length; i++) {
- if (attrs[i].namespaceURI == xlink) {
- name = "xlink:";
- } else {
- name = "";
- }
- name += attrs[i].name;
- out[name] = attrs[i].textContent;
- }
- return out;
- }
- function is(o, type) {
- type = Str.prototype.toLowerCase.call(type);
- if (type == "finite") {
- return isFinite(o);
- }
- if (type == "array" &&
- (o instanceof Array || Array.isArray && Array.isArray(o))) {
- return true;
- }
- return (type == "null" && o === null) ||
- (type == typeof o && o !== null) ||
- (type == "object" && o === Object(o)) ||
- objectToString.call(o).slice(8, -1).toLowerCase() == type;
- }
- /*\
- * Snap.format
- [ method ]
- **
- * Replaces construction of type `{<name>}` to the corresponding argument
- **
- - token (string) string to format
- - json (object) object which properties are used as a replacement
- = (string) formatted string
- > Usage
- | // this draws a rectangular shape equivalent to "M10,20h40v50h-40z"
- | paper.path(Snap.format("M{x},{y}h{dim.width}v{dim.height}h{dim['negative width']}z", {
- | x: 10,
- | y: 20,
- | dim: {
- | width: 40,
- | height: 50,
- | "negative width": -40
- | }
- | }));
- \*/
- Snap.format = (function () {
- var tokenRegex = /\{([^\}]+)\}/g,
- objNotationRegex = /(?:(?:^|\.)(.+?)(?=\[|\.|$|\()|\[('|")(.+?)\2\])(\(\))?/g, // matches .xxxxx or ["xxxxx"] to run over object properties
- replacer = function (all, key, obj) {
- var res = obj;
- key.replace(objNotationRegex, function (all, name, quote, quotedName, isFunc) {
- name = name || quotedName;
- if (res) {
- if (name in res) {
- res = res[name];
- }
- typeof res == "function" && isFunc && (res = res());
- }
- });
- res = (res == null || res == obj ? all : res) + "";
- return res;
- };
- return function (str, obj) {
- return Str(str).replace(tokenRegex, function (all, key) {
- return replacer(all, key, obj);
- });
- };
- })();
- function clone(obj) {
- if (typeof obj == "function" || Object(obj) !== obj) {
- return obj;
- }
- var res = new obj.constructor;
- for (var key in obj) if (obj[has](key)) {
- res[key] = clone(obj[key]);
- }
- return res;
- }
- Snap._.clone = clone;
- function repush(array, item) {
- for (var i = 0, ii = array.length; i < ii; i++) if (array[i] === item) {
- return array.push(array.splice(i, 1)[0]);
- }
- }
- function cacher(f, scope, postprocessor) {
- function newf() {
- var arg = Array.prototype.slice.call(arguments, 0),
- args = arg.join("\u2400"),
- cache = newf.cache = newf.cache || {},
- count = newf.count = newf.count || [];
- if (cache[has](args)) {
- repush(count, args);
- return postprocessor ? postprocessor(cache[args]) : cache[args];
- }
- count.length >= 1e3 && delete cache[count.shift()];
- count.push(args);
- cache[args] = f.apply(scope, arg);
- return postprocessor ? postprocessor(cache[args]) : cache[args];
- }
- return newf;
- }
- Snap._.cacher = cacher;
- function angle(x1, y1, x2, y2, x3, y3) {
- if (x3 == null) {
- var x = x1 - x2,
- y = y1 - y2;
- if (!x && !y) {
- return 0;
- }
- return (180 + math.atan2(-y, -x) * 180 / PI + 360) % 360;
- } else {
- return angle(x1, y1, x3, y3) - angle(x2, y2, x3, y3);
- }
- }
- function rad(deg) {
- return deg % 360 * PI / 180;
- }
- function deg(rad) {
- return rad * 180 / PI % 360;
- }
- function x_y() {
- return this.x + S + this.y;
- }
- function x_y_w_h() {
- return this.x + S + this.y + S + this.width + " \xd7 " + this.height;
- }
- /*\
- * Snap.rad
- [ method ]
- **
- * Transform angle to radians
- - deg (number) angle in degrees
- = (number) angle in radians
- \*/
- Snap.rad = rad;
- /*\
- * Snap.deg
- [ method ]
- **
- * Transform angle to degrees
- - rad (number) angle in radians
- = (number) angle in degrees
- \*/
- Snap.deg = deg;
- /*\
- * Snap.angle
- [ method ]
- **
- * Returns an angle between two or three points
- > Parameters
- - x1 (number) x coord of first point
- - y1 (number) y coord of first point
- - x2 (number) x coord of second point
- - y2 (number) y coord of second point
- - x3 (number) #optional x coord of third point
- - y3 (number) #optional y coord of third point
- = (number) angle in degrees
- \*/
- Snap.angle = angle;
- /*\
- * Snap.is
- [ method ]
- **
- * Handy replacement for the `typeof` operator
- - o (…) any object or primitive
- - type (string) name of the type, e.g., `string`, `function`, `number`, etc.
- = (boolean) `true` if given value is of given type
- \*/
- Snap.is = is;
- /*\
- * Snap.snapTo
- [ method ]
- **
- * Snaps given value to given grid
- - values (array|number) given array of values or step of the grid
- - value (number) value to adjust
- - tolerance (number) #optional maximum distance to the target value that would trigger the snap. Default is `10`.
- = (number) adjusted value
- \*/
- Snap.snapTo = function (values, value, tolerance) {
- tolerance = is(tolerance, "finite") ? tolerance : 10;
- if (is(values, "array")) {
- var i = values.length;
- while (i--) if (abs(values[i] - value) <= tolerance) {
- return values[i];
- }
- } else {
- values = +values;
- var rem = value % values;
- if (rem < tolerance) {
- return value - rem;
- }
- if (rem > values - tolerance) {
- return value - rem + values;
- }
- }
- return value;
- };
- // Colour
- /*\
- * Snap.getRGB
- [ method ]
- **
- * Parses color string as RGB object
- - color (string) color string in one of the following formats:
- # <ul>
- # <li>Color name (<code>red</code>, <code>green</code>, <code>cornflowerblue</code>, etc)</li>
- # <li>#••• — shortened HTML color: (<code>#000</code>, <code>#fc0</code>, etc.)</li>
- # <li>#•••••• — full length HTML color: (<code>#000000</code>, <code>#bd2300</code>)</li>
- # <li>rgb(•••, •••, •••) — red, green and blue channels values: (<code>rgb(200, 100, 0)</code>)</li>
- # <li>rgba(•••, •••, •••, •••) — also with opacity</li>
- # <li>rgb(•••%, •••%, •••%) — same as above, but in %: (<code>rgb(100%, 175%, 0%)</code>)</li>
- # <li>rgba(•••%, •••%, •••%, •••%) — also with opacity</li>
- # <li>hsb(•••, •••, •••) — hue, saturation and brightness values: (<code>hsb(0.5, 0.25, 1)</code>)</li>
- # <li>hsba(•••, •••, •••, •••) — also with opacity</li>
- # <li>hsb(•••%, •••%, •••%) — same as above, but in %</li>
- # <li>hsba(•••%, •••%, •••%, •••%) — also with opacity</li>
- # <li>hsl(•••, •••, •••) — hue, saturation and luminosity values: (<code>hsb(0.5, 0.25, 0.5)</code>)</li>
- # <li>hsla(•••, •••, •••, •••) — also with opacity</li>
- # <li>hsl(•••%, •••%, •••%) — same as above, but in %</li>
- # <li>hsla(•••%, •••%, •••%, •••%) — also with opacity</li>
- # </ul>
- * Note that `%` can be used any time: `rgb(20%, 255, 50%)`.
- = (object) RGB object in the following format:
- o {
- o r (number) red,
- o g (number) green,
- o b (number) blue,
- o hex (string) color in HTML/CSS format: #••••••,
- o error (boolean) true if string can't be parsed
- o }
- \*/
- Snap.getRGB = cacher(function (colour) {
- if (!colour || !!((colour = Str(colour)).indexOf("-") + 1)) {
- return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
- }
- if (colour == "none") {
- return {r: -1, g: -1, b: -1, hex: "none", toString: rgbtoString};
- }
- !(hsrg[has](colour.toLowerCase().substring(0, 2)) || colour.charAt() == "#") && (colour = toHex(colour));
- if (!colour) {
- return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
- }
- var res,
- red,
- green,
- blue,
- opacity,
- t,
- values,
- rgb = colour.match(colourRegExp);
- if (rgb) {
- if (rgb[2]) {
- blue = toInt(rgb[2].substring(5), 16);
- green = toInt(rgb[2].substring(3, 5), 16);
- red = toInt(rgb[2].substring(1, 3), 16);
- }
- if (rgb[3]) {
- blue = toInt((t = rgb[3].charAt(3)) + t, 16);
- green = toInt((t = rgb[3].charAt(2)) + t, 16);
- red = toInt((t = rgb[3].charAt(1)) + t, 16);
- }
- if (rgb[4]) {
- values = rgb[4].split(commaSpaces);
- red = toFloat(values[0]);
- values[0].slice(-1) == "%" && (red *= 2.55);
- green = toFloat(values[1]);
- values[1].slice(-1) == "%" && (green *= 2.55);
- blue = toFloat(values[2]);
- values[2].slice(-1) == "%" && (blue *= 2.55);
- rgb[1].toLowerCase().slice(0, 4) == "rgba" && (opacity = toFloat(values[3]));
- values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
- }
- if (rgb[5]) {
- values = rgb[5].split(commaSpaces);
- red = toFloat(values[0]);
- values[0].slice(-1) == "%" && (red /= 100);
- green = toFloat(values[1]);
- values[1].slice(-1) == "%" && (green /= 100);
- blue = toFloat(values[2]);
- values[2].slice(-1) == "%" && (blue /= 100);
- (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
- rgb[1].toLowerCase().slice(0, 4) == "hsba" && (opacity = toFloat(values[3]));
- values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
- return Snap.hsb2rgb(red, green, blue, opacity);
- }
- if (rgb[6]) {
- values = rgb[6].split(commaSpaces);
- red = toFloat(values[0]);
- values[0].slice(-1) == "%" && (red /= 100);
- green = toFloat(values[1]);
- values[1].slice(-1) == "%" && (green /= 100);
- blue = toFloat(values[2]);
- values[2].slice(-1) == "%" && (blue /= 100);
- (values[0].slice(-3) == "deg" || values[0].slice(-1) == "\xb0") && (red /= 360);
- rgb[1].toLowerCase().slice(0, 4) == "hsla" && (opacity = toFloat(values[3]));
- values[3] && values[3].slice(-1) == "%" && (opacity /= 100);
- return Snap.hsl2rgb(red, green, blue, opacity);
- }
- red = mmin(math.round(red), 255);
- green = mmin(math.round(green), 255);
- blue = mmin(math.round(blue), 255);
- opacity = mmin(mmax(opacity, 0), 1);
- rgb = {r: red, g: green, b: blue, toString: rgbtoString};
- rgb.hex = "#" + (16777216 | blue | (green << 8) | (red << 16)).toString(16).slice(1);
- rgb.opacity = is(opacity, "finite") ? opacity : 1;
- return rgb;
- }
- return {r: -1, g: -1, b: -1, hex: "none", error: 1, toString: rgbtoString};
- }, Snap);
- // SIERRA It seems odd that the following 3 conversion methods are not expressed as .this2that(), like the others.
- /*\
- * Snap.hsb
- [ method ]
- **
- * Converts HSB values to a hex representation of the color
- - h (number) hue
- - s (number) saturation
- - b (number) value or brightness
- = (string) hex representation of the color
- \*/
- Snap.hsb = cacher(function (h, s, b) {
- return Snap.hsb2rgb(h, s, b).hex;
- });
- /*\
- * Snap.hsl
- [ method ]
- **
- * Converts HSL values to a hex representation of the color
- - h (number) hue
- - s (number) saturation
- - l (number) luminosity
- = (string) hex representation of the color
- \*/
- Snap.hsl = cacher(function (h, s, l) {
- return Snap.hsl2rgb(h, s, l).hex;
- });
- /*\
- * Snap.rgb
- [ method ]
- **
- * Converts RGB values to a hex representation of the color
- - r (number) red
- - g (number) green
- - b (number) blue
- = (string) hex representation of the color
- \*/
- Snap.rgb = cacher(function (r, g, b, o) {
- if (is(o, "finite")) {
- var round = math.round;
- return "rgba(" + [round(r), round(g), round(b), +o.toFixed(2)] + ")";
- }
- return "#" + (16777216 | b | (g << 8) | (r << 16)).toString(16).slice(1);
- });
- var toHex = function (color) {
- var i = glob.doc.getElementsByTagName("head")[0] || glob.doc.getElementsByTagName("svg")[0],
- red = "rgb(255, 0, 0)";
- toHex = cacher(function (color) {
- if (color.toLowerCase() == "red") {
- return red;
- }
- i.style.color = red;
- i.style.color = color;
- var out = glob.doc.defaultView.getComputedStyle(i, E).getPropertyValue("color");
- return out == red ? null : out;
- });
- return toHex(color);
- },
- hsbtoString = function () {
- return "hsb(" + [this.h, this.s, this.b] + ")";
- },
- hsltoString = function () {
- return "hsl(" + [this.h, this.s, this.l] + ")";
- },
- rgbtoString = function () {
- return this.opacity == 1 || this.opacity == null ?
- this.hex :
- "rgba(" + [this.r, this.g, this.b, this.opacity] + ")";
- },
- prepareRGB = function (r, g, b) {
- if (g == null && is(r, "object") && "r" in r && "g" in r && "b" in r) {
- b = r.b;
- g = r.g;
- r = r.r;
- }
- if (g == null && is(r, string)) {
- var clr = Snap.getRGB(r);
- r = clr.r;
- g = clr.g;
- b = clr.b;
- }
- if (r > 1 || g > 1 || b > 1) {
- r /= 255;
- g /= 255;
- b /= 255;
- }
- return [r, g, b];
- },
- packageRGB = function (r, g, b, o) {
- r = math.round(r * 255);
- g = math.round(g * 255);
- b = math.round(b * 255);
- var rgb = {
- r: r,
- g: g,
- b: b,
- opacity: is(o, "finite") ? o : 1,
- hex: Snap.rgb(r, g, b),
- toString: rgbtoString
- };
- is(o, "finite") && (rgb.opacity = o);
- return rgb;
- };
- // SIERRA Clarify if Snap does not support consolidated HSLA/RGBA colors. E.g., can you specify a semi-transparent value for Snap.filter.shadow()?
- /*\
- * Snap.color
- [ method ]
- **
- * Parses the color string and returns an object featuring the color's component values
- - clr (string) color string in one of the supported formats (see @Snap.getRGB)
- = (object) Combined RGB/HSB object in the following format:
- o {
- o r (number) red,
- o g (number) green,
- o b (number) blue,
- o hex (string) color in HTML/CSS format: #••••••,
- o error (boolean) `true` if string can't be parsed,
- o h (number) hue,
- o s (number) saturation,
- o v (number) value (brightness),
- o l (number) lightness
- o }
- \*/
- Snap.color = function (clr) {
- var rgb;
- if (is(clr, "object") && "h" in clr && "s" in clr && "b" in clr) {
- rgb = Snap.hsb2rgb(clr);
- clr.r = rgb.r;
- clr.g = rgb.g;
- clr.b = rgb.b;
- clr.opacity = 1;
- clr.hex = rgb.hex;
- } else if (is(clr, "object") && "h" in clr && "s" in clr && "l" in clr) {
- rgb = Snap.hsl2rgb(clr);
- clr.r = rgb.r;
- clr.g = rgb.g;
- clr.b = rgb.b;
- clr.opacity = 1;
- clr.hex = rgb.hex;
- } else {
- if (is(clr, "string")) {
- clr = Snap.getRGB(clr);
- }
- if (is(clr, "object") && "r" in clr && "g" in clr && "b" in clr && !("error" in clr)) {
- rgb = Snap.rgb2hsl(clr);
- clr.h = rgb.h;
- clr.s = rgb.s;
- clr.l = rgb.l;
- rgb = Snap.rgb2hsb(clr);
- clr.v = rgb.b;
- } else {
- clr = {hex: "none"};
- clr.r = clr.g = clr.b = clr.h = clr.s = clr.v = clr.l = -1;
- clr.error = 1;
- }
- }
- clr.toString = rgbtoString;
- return clr;
- };
- /*\
- * Snap.hsb2rgb
- [ method ]
- **
- * Converts HSB values to an RGB object
- - h (number) hue
- - s (number) saturation
- - v (number) value or brightness
- = (object) RGB object in the following format:
- o {
- o r (number) red,
- o g (number) green,
- o b (number) blue,
- o hex (string) color in HTML/CSS format: #••••••
- o }
- \*/
- Snap.hsb2rgb = function (h, s, v, o) {
- if (is(h, "object") && "h" in h && "s" in h && "b" in h) {
- v = h.b;
- s = h.s;
- h = h.h;
- o = h.o;
- }
- h *= 360;
- var R, G, B, X, C;
- h = (h % 360) / 60;
- C = v * s;
- X = C * (1 - abs(h % 2 - 1));
- R = G = B = v - C;
- h = ~~h;
- R += [C, X, 0, 0, X, C][h];
- G += [X, C, C, X, 0, 0][h];
- B += [0, 0, X, C, C, X][h];
- return packageRGB(R, G, B, o);
- };
- /*\
- * Snap.hsl2rgb
- [ method ]
- **
- * Converts HSL values to an RGB object
- - h (number) hue
- - s (number) saturation
- - l (number) luminosity
- = (object) RGB object in the following format:
- o {
- o r (number) red,
- o g (number) green,
- o b (number) blue,
- o hex (string) color in HTML/CSS format: #••••••
- o }
- \*/
- Snap.hsl2rgb = function (h, s, l, o) {
- if (is(h, "object") && "h" in h && "s" in h && "l" in h) {
- l = h.l;
- s = h.s;
- h = h.h;
- }
- if (h > 1 || s > 1 || l > 1) {
- h /= 360;
- s /= 100;
- l /= 100;
- }
- h *= 360;
- var R, G, B, X, C;
- h = (h % 360) / 60;
- C = 2 * s * (l < .5 ? l : 1 - l);
- X = C * (1 - abs(h % 2 - 1));
- R = G = B = l - C / 2;
- h = ~~h;
- R += [C, X, 0, 0, X, C][h];
- G += [X, C, C, X, 0, 0][h];
- B += [0, 0, X, C, C, X][h];
- return packageRGB(R, G, B, o);
- };
- /*\
- * Snap.rgb2hsb
- [ method ]
- **
- * Converts RGB values to an HSB object
- - r (number) red
- - g (number) green
- - b (number) blue
- = (object) HSB object in the following format:
- o {
- o h (number) hue,
- o s (number) saturation,
- o b (number) brightness
- o }
- \*/
- Snap.rgb2hsb = function (r, g, b) {
- b = prepareRGB(r, g, b);
- r = b[0];
- g = b[1];
- b = b[2];
- var H, S, V, C;
- V = mmax(r, g, b);
- C = V - mmin(r, g, b);
- H = (C == 0 ? null :
- V == r ? (g - b) / C :
- V == g ? (b - r) / C + 2 :
- (r - g) / C + 4
- );
- H = ((H + 360) % 6) * 60 / 360;
- S = C == 0 ? 0 : C / V;
- return {h: H, s: S, b: V, toString: hsbtoString};
- };
- /*\
- * Snap.rgb2hsl
- [ method ]
- **
- * Converts RGB values to an HSL object
- - r (number) red
- - g (number) green
- - b (number) blue
- = (object) HSL object in the following format:
- o {
- o h (number) hue,
- o s (number) saturation,
- o l (number) luminosity
- o }
- \*/
- Snap.rgb2hsl = function (r, g, b) {
- b = prepareRGB(r, g, b);
- r = b[0];
- g = b[1];
- b = b[2];
- var H, S, L, M, m, C;
- M = mmax(r, g, b);
- m = mmin(r, g, b);
- C = M - m;
- H = (C == 0 ? null :
- M == r ? (g - b) / C :
- M == g ? (b - r) / C + 2 :
- (r - g) / C + 4);
- H = ((H + 360) % 6) * 60 / 360;
- L = (M + m) / 2;
- S = (C == 0 ? 0 :
- L < .5 ? C / (2 * L) :
- C / (2 - 2 * L));
- return {h: H, s: S, l: L, toString: hsltoString};
- };
- // Transformations
- // 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?
- /*\
- * Snap.parsePathString
- [ method ]
- **
- * Utility method
- **
- * Parses given path string into an array of arrays of path segments
- - pathString (string|array) path string or array of segments (in the last case it is returned straight away)
- = (array) array of segments
- \*/
- Snap.parsePathString = function (pathString) {
- if (!pathString) {
- return null;
- }
- var pth = Snap.path(pathString);
- if (pth.arr) {
- return Snap.path.clone(pth.arr);
- }
- 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},
- data = [];
- if (is(pathString, "array") && is(pathString[0], "array")) { // rough assumption
- data = Snap.path.clone(pathString);
- }
- if (!data.length) {
- Str(pathString).replace(pathCommand, function (a, b, c) {
- var params = [],
- name = b.toLowerCase();
- c.replace(pathValues, function (a, b) {
- b && params.push(+b);
- });
- if (name == "m" && params.length > 2) {
- data.push([b].concat(params.splice(0, 2)));
- name = "l";
- b = b == "m" ? "l" : "L";
- }
- if (name == "o" && params.length == 1) {
- data.push([b, params[0]]);
- }
- if (name == "r") {
- data.push([b].concat(params));
- } else while (params.length >= paramCounts[name]) {
- data.push([b].concat(params.splice(0, paramCounts[name])));
- if (!paramCounts[name]) {
- break;
- }
- }
- });
- }
- data.toString = Snap.path.toString;
- pth.arr = Snap.path.clone(data);
- return data;
- };
- /*\
- * Snap.parseTransformString
- [ method ]
- **
- * Utility method
- **
- * Parses given transform string into an array of transformations
- - TString (string|array) transform string or array of transformations (in the last case it is returned straight away)
- = (array) array of transformations
- \*/
- var parseTransformString = Snap.parseTransformString = function (TString) {
- if (!TString) {
- return null;
- }
- var paramCounts = {r: 3, s: 4, t: 2, m: 6},
- data = [];
- if (is(TString, "array") && is(TString[0], "array")) { // rough assumption
- data = Snap.path.clone(TString);
- }
- if (!data.length) {
- Str(TString).replace(tCommand, function (a, b, c) {
- var params = [],
- name = b.toLowerCase();
- c.replace(pathValues, function (a, b) {
- b && params.push(+b);
- });
- data.push([b].concat(params));
- });
- }
- data.toString = Snap.path.toString;
- return data;
- };
- function svgTransform2string(tstr) {
- var res = [];
- tstr = tstr.replace(/(?:^|\s)(\w+)\(([^)]+)\)/g, function (all, name, params) {
- params = params.split(/\s*,\s*|\s+/);
- if (name == "rotate" && params.length == 1) {
- params.push(0, 0);
- }
- if (name == "scale") {
- if (params.length > 2) {
- params = params.slice(0, 2);
- } else if (params.length == 2) {
- params.push(0, 0);
- }
- if (params.length == 1) {
- params.push(params[0], 0, 0);
- }
- }
- if (name == "skewX") {
- res.push(["m", 1, 0, math.tan(rad(params[0])), 1, 0, 0]);
- } else if (name == "skewY") {
- res.push(["m", 1, math.tan(rad(params[0])), 0, 1, 0, 0]);
- } else {
- res.push([name.charAt(0)].concat(params));
- }
- return all;
- });
- return res;
- }
- Snap._.svgTransform2string = svgTransform2string;
- Snap._.rgTransform = /^[a-z][\s]*-?\.?\d/i;
- function transform2matrix(tstr, bbox) {
- var tdata = parseTransformString(tstr),
- m = new Snap.Matrix;
- if (tdata) {
- for (var i = 0, ii = tdata.length; i < ii; i++) {
- var t = tdata[i],
- tlen = t.length,
- command = Str(t[0]).toLowerCase(),
- absolute = t[0] != command,
- inver = absolute ? m.invert() : 0,
- x1,
- y1,
- x2,
- y2,
- bb;
- if (command == "t" && tlen == 2){
- m.translate(t[1], 0);
- } else if (command == "t" && tlen == 3) {
- if (absolute) {
- x1 = inver.x(0, 0);
- y1 = inver.y(0, 0);
- x2 = inver.x(t[1], t[2]);
- y2 = inver.y(t[1], t[2]);
- m.translate(x2 - x1, y2 - y1);
- } else {
- m.translate(t[1], t[2]);
- }
- } else if (command == "r") {
- if (tlen == 2) {
- bb = bb || bbox;
- m.rotate(t[1], bb.x + bb.width / 2, bb.y + bb.height / 2);
- } else if (tlen == 4) {
- if (absolute) {
- x2 = inver.x(t[2], t[3]);
- y2 = inver.y(t[2], t[3]);
- m.rotate(t[1], x2, y2);
- } else {
- m.rotate(t[1], t[2], t[3]);
- }
- }
- } else if (command == "s") {
- if (tlen == 2 || tlen == 3) {
- bb = bb || bbox;
- m.scale(t[1], t[tlen - 1], bb.x + bb.width / 2, bb.y + bb.height / 2);
- } else if (tlen == 4) {
- if (absolute) {
- x2 = inver.x(t[2], t[3]);
- y2 = inver.y(t[2], t[3]);
- m.scale(t[1], t[1], x2, y2);
- } else {
- m.scale(t[1], t[1], t[2], t[3]);
- }
- } else if (tlen == 5) {
- if (absolute) {
- x2 = inver.x(t[3], t[4]);
- y2 = inver.y(t[3], t[4]);
- m.scale(t[1], t[2], x2, y2);
- } else {
- m.scale(t[1], t[2], t[3], t[4]);
- }
- }
- } else if (command == "m" && tlen == 7) {
- m.add(t[1], t[2], t[3], t[4], t[5], t[6]);
- }
- }
- }
- return m;
- }
- Snap._.transform2matrix = transform2matrix;
- Snap._unit2px = unit2px;
- var contains = glob.doc.contains || glob.doc.compareDocumentPosition ?
- function (a, b) {
- var adown = a.nodeType == 9 ? a.documentElement : a,
- bup = b && b.parentNode;
- return a == bup || !!(bup && bup.nodeType == 1 && (
- adown.contains ?
- adown.contains(bup) :
- a.compareDocumentPosition && a.compareDocumentPosition(bup) & 16
- ));
- } :
- function (a, b) {
- if (b) {
- while (b) {
- b = b.parentNode;
- if (b == a) {
- return true;
- }
- }
- }
- return false;
- };
- function getSomeDefs(el) {
- var p = (el.node.ownerSVGElement && wrap(el.node.ownerSVGElement)) ||
- (el.node.parentNode && wrap(el.node.parentNode)) ||
- Snap.select("svg") ||
- Snap(0, 0),
- pdefs = p.select("defs"),
- defs = pdefs == null ? false : pdefs.node;
- if (!defs) {
- defs = make("defs", p.node).node;
- }
- return defs;
- }
- function getSomeSVG(el) {
- return el.node.ownerSVGElement && wrap(el.node.ownerSVGElement) || Snap.select("svg");
- }
- Snap._.getSomeDefs = getSomeDefs;
- Snap._.getSomeSVG = getSomeSVG;
- function unit2px(el, name, value) {
- var svg = getSomeSVG(el).node,
- out = {},
- mgr = svg.querySelector(".svg---mgr");
- if (!mgr) {
- mgr = $("rect");
- $(mgr, {x: -9e9, y: -9e9, width: 10, height: 10, "class": "svg---mgr", fill: "none"});
- svg.appendChild(mgr);
- }
- function getW(val) {
- if (val == null) {
- return E;
- }
- if (val == +val) {
- return val;
- }
- $(mgr, {width: val});
- try {
- return mgr.getBBox().width;
- } catch (e) {
- return 0;
- }
- }
- function getH(val) {
- if (val == null) {
- return E;
- }
- if (val == +val) {
- return val;
- }
- $(mgr, {height: val});
- try {
- return mgr.getBBox().height;
- } catch (e) {
- return 0;
- }
- }
- function set(nam, f) {
- if (name == null) {
- out[nam] = f(el.attr(nam) || 0);
- } else if (nam == name) {
- out = f(value == null ? el.attr(nam) || 0 : value);
- }
- }
- switch (el.type) {
- case "rect":
- set("rx", getW);
- set("ry", getH);
- case "image":
- set("width", getW);
- set("height", getH);
- case "text":
- set("x", getW);
- set("y", getH);
- break;
- case "circle":
- set("cx", getW);
- set("cy", getH);
- set("r", getW);
- break;
- case "ellipse":
- set("cx", getW);
- set("cy", getH);
- set("rx", getW);
- set("ry", getH);
- break;
- case "line":
- set("x1", getW);
- set("x2", getW);
- set("y1", getH);
- set("y2", getH);
- break;
- case "marker":
- set("refX", getW);
- set("markerWidth", getW);
- set("refY", getH);
- set("markerHeight", getH);
- break;
- case "radialGradient":
- set("fx", getW);
- set("fy", getH);
- break;
- case "tspan":
- set("dx", getW);
- set("dy", getH);
- break;
- default:
- set(name, getW);
- }
- svg.removeChild(mgr);
- return out;
- }
- /*\
- * Snap.select
- [ method ]
- **
- * Wraps a DOM element specified by CSS selector as @Element
- - query (string) CSS selector of the element
- = (Element) the current element
- \*/
- Snap.select = function (query) {
- query = Str(query).replace(/([^\\]):/g, "$1\\:");
- return wrap(glob.doc.querySelector(query));
- };
- /*\
- * Snap.selectAll
- [ method ]
- **
- * Wraps DOM elements specified by CSS selector as set or array of @Element
- - query (string) CSS selector of the element
- = (Element) the current element
- \*/
- Snap.selectAll = function (query) {
- var nodelist = glob.doc.querySelectorAll(query),
- set = (Snap.set || Array)();
- for (var i = 0; i < nodelist.length; i++) {
- set.push(wrap(nodelist[i]));
- }
- return set;
- };
- function add2group(list) {
- if (!is(list, "array")) {
- list = Array.prototype.slice.call(arguments, 0);
- }
- var i = 0,
- j = 0,
- node = this.node;
- while (this[i]) delete this[i++];
- for (i = 0; i < list.length; i++) {
- if (list[i].type == "set") {
- list[i].forEach(function (el) {
- node.appendChild(el.node);
- });
- } else {
- node.appendChild(list[i].node);
- }
- }
- var children = node.childNodes;
- for (i = 0; i < children.length; i++) {
- this[j++] = wrap(children[i]);
- }
- return this;
- }
- // Hub garbage collector every 10s
- setInterval(function () {
- for (var key in hub) if (hub[has](key)) {
- var el = hub[key],
- node = el.node;
- if (el.type != "svg" && !node.ownerSVGElement || el.type == "svg" && (!node.parentNode || "ownerSVGElement" in node.parentNode && !node.ownerSVGElement)) {
- delete hub[key];
- }
- }
- }, 1e4);
- function Element(el) {
- if (el.snap in hub) {
- return hub[el.snap];
- }
- var svg;
- try {
- svg = el.ownerSVGElement;
- } catch(e) {}
- /*\
- * Element.node
- [ property (object) ]
- **
- * Gives you a reference to the DOM object, so you can assign event handlers or just mess around.
- > Usage
- | // draw a circle at coordinate 10,10 with radius of 10
- | var c = paper.circle(10, 10, 10);
- | c.node.onclick = function () {
- | c.attr("fill", "red");
- | };
- \*/
- this.node = el;
- if (svg) {
- this.paper = new Paper(svg);
- }
- /*\
- * Element.type
- [ property (string) ]
- **
- * SVG tag name of the given element.
- \*/
- this.type = el.tagName;
- var id = this.id = ID(this);
- this.anims = {};
- this._ = {
- transform: []
- };
- el.snap = id;
- hub[id] = this;
- if (this.type == "g") {
- this.add = add2group;
- }
- if (this.type in {g: 1, mask: 1, pattern: 1, symbol: 1}) {
- for (var method in Paper.prototype) if (Paper.prototype[has](method)) {
- this[method] = Paper.prototype[method];
- }
- }
- }
- /*\
- * Element.attr
- [ method ]
- **
- * Gets or sets given attributes of the element.
- **
- - params (object) contains key-value pairs of attributes you want to set
- * or
- - param (string) name of the attribute
- = (Element) the current element
- * or
- = (string) value of attribute
- > Usage
- | el.attr({
- | fill: "#fc0",
- | stroke: "#000",
- | strokeWidth: 2, // CamelCase...
- | "fill-opacity": 0.5, // or dash-separated names
- | width: "*=2" // prefixed values
- | });
- | console.log(el.attr("fill")); // #fc0
- * Prefixed values in format `"+=10"` supported. All four operations
- * (`+`, `-`, `*` and `/`) could be used. Optionally you can use units for `+`
- * and `-`: `"+=2em"`.
- \*/
- Element.prototype.attr = function (params, value) {
- var el = this,
- node = el.node;
- if (!params) {
- return el;
- }
- if (is(params, "string")) {
- if (arguments.length > 1) {
- var json = {};
- json[params] = value;
- params = json;
- } else {
- return eve("snap.util.getattr." + params, el).firstDefined();
- }
- }
- for (var att in params) {
- if (params[has](att)) {
- eve("snap.util.attr." + att, el, params[att]);
- }
- }
- return el;
- };
- /*\
- * Snap.parse
- [ method ]
- **
- * Parses SVG fragment and converts it into a @Fragment
- **
- - svg (string) SVG string
- = (Fragment) the @Fragment
- \*/
- Snap.parse = function (svg) {
- var f = glob.doc.createDocumentFragment(),
- full = true,
- div = glob.doc.createElement("div");
- svg = Str(svg);
- if (!svg.match(/^\s*<\s*svg(?:\s|>)/)) {
- svg = "<svg>" + svg + "</svg>";
- full = false;
- }
- div.innerHTML = svg;
- svg = div.getElementsByTagName("svg")[0];
- if (svg) {
- if (full) {
- f = svg;
- } else {
- while (svg.firstChild) {
- f.appendChild(svg.firstChild);
- }
- div.innerHTML = E;
- }
- }
- return new Fragment(f);
- };
- function Fragment(frag) {
- this.node = frag;
- }
- // SIERRA Snap.fragment() could especially use a code example
- /*\
- * Snap.fragment
- [ method ]
- **
- * Creates a DOM fragment from a given list of elements or strings
- **
- - varargs (…) SVG string
- = (Fragment) the @Fragment
- \*/
- Snap.fragment = function () {
- var args = Array.prototype.slice.call(arguments, 0),
- f = glob.doc.createDocumentFragment();
- for (var i = 0, ii = args.length; i < ii; i++) {
- var item = args[i];
- if (item.node && item.node.nodeType) {
- f.appendChild(item.node);
- }
- if (item.nodeType) {
- f.appendChild(item);
- }
- if (typeof item == "string") {
- f.appendChild(Snap.parse(item).node);
- }
- }
- return new Fragment(f);
- };
- function make(name, parent) {
- var res = $(name);
- parent.appendChild(res);
- var el = wrap(res);
- return el;
- }
- function Paper(w, h) {
- var res,
- desc,
- defs,
- proto = Paper.prototype;
- if (w && w.tagName == "svg") {
- if (w.snap in hub) {
- return hub[w.snap];
- }
- var doc = w.ownerDocument;
- res = new Element(w);
- desc = w.getElementsByTagName("desc")[0];
- defs = w.getElementsByTagName("defs")[0];
- if (!desc) {
- desc = $("desc");
- desc.appendChild(doc.createTextNode("Created with Snap"));
- res.node.appendChild(desc);
- }
- if (!defs) {
- defs = $("defs");
- res.node.appendChild(defs);
- }
- res.defs = defs;
- for (var key in proto) if (proto[has](key)) {
- res[key] = proto[key];
- }
- res.paper = res.root = res;
- } else {
- res = make("svg", glob.doc.body);
- $(res.node, {
- height: h,
- version: 1.1,
- width: w,
- xmlns: xmlns
- });
- }
- return res;
- }
- function wrap(dom) {
- if (!dom) {
- return dom;
- }
- if (dom instanceof Element || dom instanceof Fragment) {
- return dom;
- }
- if (dom.tagName && dom.tagName.toLowerCase() == "svg") {
- return new Paper(dom);
- }
- if (dom.tagName && dom.tagName.toLowerCase() == "object" && dom.type == "image/svg+xml") {
- return new Paper(dom.contentDocument.getElementsByTagName("svg")[0]);
- }
- return new Element(dom);
- }
- Snap._.make = make;
- Snap._.wrap = wrap;
- /*\
- * Paper.el
- [ method ]
- **
- * Creates an element on paper with a given name and no attributes
- **
- - name (string) tag name
- - attr (object) attributes
- = (Element) the current element
- > Usage
- | var c = paper.circle(10, 10, 10); // is the same as...
- | var c = paper.el("circle").attr({
- | cx: 10,
- | cy: 10,
- | r: 10
- | });
- | // and the same as
- | var c = paper.el("circle", {
- | cx: 10,
- | cy: 10,
- | r: 10
- | });
- \*/
- Paper.prototype.el = function (name, attr) {
- var el = make(name, this.node);
- attr && el.attr(attr);
- return el;
- };
- // default
- eve.on("snap.util.getattr", function () {
- var att = eve.nt();
- att = att.substring(att.lastIndexOf(".") + 1);
- var css = att.replace(/[A-Z]/g, function (letter) {
- return "-" + letter.toLowerCase();
- });
- if (cssAttr[has](css)) {
- return this.node.ownerDocument.defaultView.getComputedStyle(this.node, null).getPropertyValue(css);
- } else {
- return $(this.node, att);
- }
- });
- var cssAttr = {
- "alignment-baseline": 0,
- "baseline-shift": 0,
- "clip": 0,
- "clip-path": 0,
- "clip-rule": 0,
- "color": 0,
- "color-interpolation": 0,
- "color-interpolation-filters": 0,
- "color-profile": 0,
- "color-rendering": 0,
- "cursor": 0,
- "direction": 0,
- "display": 0,
- "dominant-baseline": 0,
- "enable-background": 0,
- "fill": 0,
- "fill-opacity": 0,
- "fill-rule": 0,
- "filter": 0,
- "flood-color": 0,
- "flood-opacity": 0,
- "font": 0,
- "font-family": 0,
- "font-size": 0,
- "font-size-adjust": 0,
- "font-stretch": 0,
- "font-style": 0,
- "font-variant": 0,
- "font-weight": 0,
- "glyph-orientation-horizontal": 0,
- "glyph-orientation-vertical": 0,
- "image-rendering": 0,
- "kerning": 0,
- "letter-spacing": 0,
- "lighting-color": 0,
- "marker": 0,
- "marker-end": 0,
- "marker-mid": 0,
- "marker-start": 0,
- "mask": 0,
- "opacity": 0,
- "overflow": 0,
- "pointer-events": 0,
- "shape-rendering": 0,
- "stop-color": 0,
- "stop-opacity": 0,
- "stroke": 0,
- "stroke-dasharray": 0,
- "stroke-dashoffset": 0,
- "stroke-linecap": 0,
- "stroke-linejoin": 0,
- "stroke-miterlimit": 0,
- "stroke-opacity": 0,
- "stroke-width": 0,
- "text-anchor": 0,
- "text-decoration": 0,
- "text-rendering": 0,
- "unicode-bidi": 0,
- "visibility": 0,
- "word-spacing": 0,
- "writing-mode": 0
- };
- eve.on("snap.util.attr", function (value) {
- var att = eve.nt(),
- attr = {};
- att = att.substring(att.lastIndexOf(".") + 1);
- attr[att] = value;
- var style = att.replace(/-(\w)/gi, function (all, letter) {
- return letter.toUpperCase();
- }),
- css = att.replace(/[A-Z]/g, function (letter) {
- return "-" + letter.toLowerCase();
- });
- if (cssAttr[has](css)) {
- this.node.style[style] = value == null ? E : value;
- } else {
- $(this.node, attr);
- }
- });
- (function (proto) {}(Paper.prototype));
- // simple ajax
- /*\
- * Snap.ajax
- [ method ]
- **
- * Simple implementation of Ajax
- **
- - url (string) URL
- - postData (object|string) data for post request
- - callback (function) callback
- - scope (object) #optional scope of callback
- * or
- - url (string) URL
- - callback (function) callback
- - scope (object) #optional scope of callback
- = (XMLHttpRequest) the XMLHttpRequest object, just in case
- \*/
- Snap.ajax = function (url, postData, callback, scope){
- var req = new XMLHttpRequest,
- id = ID();
- if (req) {
- if (is(postData, "function")) {
- scope = callback;
- callback = postData;
- postData = null;
- } else if (is(postData, "object")) {
- var pd = [];
- for (var key in postData) if (postData.hasOwnProperty(key)) {
- pd.push(encodeURIComponent(key) + "=" + encodeURIComponent(postData[key]));
- }
- postData = pd.join("&");
- }
- req.open((postData ? "POST" : "GET"), url, true);
- if (postData) {
- req.setRequestHeader("X-Requested-With", "XMLHttpRequest");
- req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
- }
- if (callback) {
- eve.once("snap.ajax." + id + ".0", callback);
- eve.once("snap.ajax." + id + ".200", callback);
- eve.once("snap.ajax." + id + ".304", callback);
- }
- req.onreadystatechange = function() {
- if (req.readyState != 4) return;
- eve("snap.ajax." + id + "." + req.status, scope, req);
- };
- if (req.readyState == 4) {
- return req;
- }
- req.send(postData);
- return req;
- }
- };
- /*\
- * Snap.load
- [ method ]
- **
- * Loads external SVG file as a @Fragment (see @Snap.ajax for more advanced AJAX)
- **
- - url (string) URL
- - callback (function) callback
- - scope (object) #optional scope of callback
- \*/
- Snap.load = function (url, callback, scope) {
- Snap.ajax(url, function (req) {
- var f = Snap.parse(req.responseText);
- scope ? callback.call(scope, f) : callback(f);
- });
- };
- var getOffset = function (elem) {
- var box = elem.getBoundingClientRect(),
- doc = elem.ownerDocument,
- body = doc.body,
- docElem = doc.documentElement,
- clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
- top = box.top + (g.win.pageYOffset || docElem.scrollTop || body.scrollTop ) - clientTop,
- left = box.left + (g.win.pageXOffset || docElem.scrollLeft || body.scrollLeft) - clientLeft;
- return {
- y: top,
- x: left
- };
- };
- /*\
- * Snap.getElementByPoint
- [ method ]
- **
- * Returns you topmost element under given point.
- **
- = (object) Snap element object
- - x (number) x coordinate from the top left corner of the window
- - y (number) y coordinate from the top left corner of the window
- > Usage
- | Snap.getElementByPoint(mouseX, mouseY).attr({stroke: "#f00"});
- \*/
- Snap.getElementByPoint = function (x, y) {
- var paper = this,
- svg = paper.canvas,
- target = glob.doc.elementFromPoint(x, y);
- if (glob.win.opera && target.tagName == "svg") {
- var so = getOffset(target),
- sr = target.createSVGRect();
- sr.x = x - so.x;
- sr.y = y - so.y;
- sr.width = sr.height = 1;
- var hits = target.getIntersectionList(sr, null);
- if (hits.length) {
- target = hits[hits.length - 1];
- }
- }
- if (!target) {
- return null;
- }
- return wrap(target);
- };
- /*\
- * Snap.plugin
- [ method ]
- **
- * Let you write plugins. You pass in a function with four arguments, like this:
- | Snap.plugin(function (Snap, Element, Paper, global, Fragment) {
- | Snap.newmethod = function () {};
- | Element.prototype.newmethod = function () {};
- | Paper.prototype.newmethod = function () {};
- | });
- * Inside the function you have access to all main objects (and their
- * prototypes). This allow you to extend anything you want.
- **
- - f (function) your plugin body
- \*/
- Snap.plugin = function (f) {
- f(Snap, Element, Paper, glob, Fragment);
- };
- glob.win.Snap = Snap;
- return Snap;
- }(window || this));
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
- var elproto = Element.prototype,
- is = Snap.is,
- Str = String,
- unit2px = Snap._unit2px,
- $ = Snap._.$,
- make = Snap._.make,
- getSomeDefs = Snap._.getSomeDefs,
- has = "hasOwnProperty",
- wrap = Snap._.wrap;
- /*\
- * Element.getBBox
- [ method ]
- **
- * Returns the bounding box descriptor for the given element
- **
- = (object) bounding box descriptor:
- o {
- o cx: (number) x of the center,
- o cy: (number) x of the center,
- o h: (number) height,
- o height: (number) height,
- o path: (string) path command for the box,
- o r0: (number) radius of a circle that fully encloses the box,
- o r1: (number) radius of the smallest circle that can be enclosed,
- o r2: (number) radius of the largest circle that can be enclosed,
- o vb: (string) box as a viewbox command,
- o w: (number) width,
- o width: (number) width,
- o x2: (number) x of the right side,
- o x: (number) x of the left side,
- o y2: (number) y of the bottom edge,
- o y: (number) y of the top edge
- o }
- \*/
- elproto.getBBox = function (isWithoutTransform) {
- if (!Snap.Matrix || !Snap.path) {
- return this.node.getBBox();
- }
- var el = this,
- m = new Snap.Matrix;
- if (el.removed) {
- return Snap._.box();
- }
- while (el.type == "use") {
- if (!isWithoutTransform) {
- m = m.add(el.transform().localMatrix.translate(el.attr("x") || 0, el.attr("y") || 0));
- }
- if (el.original) {
- el = el.original;
- } else {
- var href = el.attr("xlink:href");
- el = el.original = el.node.ownerDocument.getElementById(href.substring(href.indexOf("#") + 1));
- }
- }
- var _ = el._,
- pathfinder = Snap.path.get[el.type] || Snap.path.get.deflt;
- try {
- if (isWithoutTransform) {
- _.bboxwt = pathfinder ? Snap.path.getBBox(el.realPath = pathfinder(el)) : Snap._.box(el.node.getBBox());
- return Snap._.box(_.bboxwt);
- } else {
- el.realPath = pathfinder(el);
- el.matrix = el.transform().localMatrix;
- _.bbox = Snap.path.getBBox(Snap.path.map(el.realPath, m.add(el.matrix)));
- return Snap._.box(_.bbox);
- }
- } catch (e) {
- // Firefox doesn’t give you bbox of hidden element
- return Snap._.box();
- }
- };
- var propString = function () {
- return this.string;
- };
- function extractTransform(el, tstr) {
- if (tstr == null) {
- var doReturn = true;
- if (el.type == "linearGradient" || el.type == "radialGradient") {
- tstr = el.node.getAttribute("gradientTransform");
- } else if (el.type == "pattern") {
- tstr = el.node.getAttribute("patternTransform");
- } else {
- tstr = el.node.getAttribute("transform");
- }
- if (!tstr) {
- return new Snap.Matrix;
- }
- tstr = Snap._.svgTransform2string(tstr);
- } else {
- if (!Snap._.rgTransform.test(tstr)) {
- tstr = Snap._.svgTransform2string(tstr);
- } else {
- tstr = Str(tstr).replace(/\.{3}|\u2026/g, el._.transform || E);
- }
- if (is(tstr, "array")) {
- tstr = Snap.path ? Snap.path.toString.call(tstr) : Str(tstr);
- }
- el._.transform = tstr;
- }
- var m = Snap._.transform2matrix(tstr, el.getBBox(1));
- if (doReturn) {
- return m;
- } else {
- el.matrix = m;
- }
- }
- /*\
- * Element.transform
- [ method ]
- **
- * Gets or sets transformation of the element
- **
- - tstr (string) transform string in Snap or SVG format
- = (Element) the current element
- * or
- = (object) transformation descriptor:
- o {
- o string (string) transform string,
- o globalMatrix (Matrix) matrix of all transformations applied to element or its parents,
- o localMatrix (Matrix) matrix of transformations applied only to the element,
- o diffMatrix (Matrix) matrix of difference between global and local transformations,
- o global (string) global transformation as string,
- o local (string) local transformation as string,
- o toString (function) returns `string` property
- o }
- \*/
- elproto.transform = function (tstr) {
- var _ = this._;
- if (tstr == null) {
- var papa = this,
- global = new Snap.Matrix(this.node.getCTM()),
- local = extractTransform(this),
- ms = [local],
- m = new Snap.Matrix,
- i,
- localString = local.toTransformString(),
- string = Str(local) == Str(this.matrix) ?
- Str(_.transform) : localString;
- while (papa.type != "svg" && (papa = papa.parent())) {
- ms.push(extractTransform(papa));
- }
- i = ms.length;
- while (i--) {
- m.add(ms[i]);
- }
- return {
- string: string,
- globalMatrix: global,
- totalMatrix: m,
- localMatrix: local,
- diffMatrix: global.clone().add(local.invert()),
- global: global.toTransformString(),
- total: m.toTransformString(),
- local: localString,
- toString: propString
- };
- }
- if (tstr instanceof Snap.Matrix) {
- this.matrix = tstr;
- this._.transform = tstr.toTransformString();
- } else {
- extractTransform(this, tstr);
- }
- if (this.node) {
- if (this.type == "linearGradient" || this.type == "radialGradient") {
- $(this.node, {gradientTransform: this.matrix});
- } else if (this.type == "pattern") {
- $(this.node, {patternTransform: this.matrix});
- } else {
- $(this.node, {transform: this.matrix});
- }
- }
- return this;
- };
- /*\
- * Element.parent
- [ method ]
- **
- * Returns the element's parent
- **
- = (Element) the parent element
- \*/
- elproto.parent = function () {
- return wrap(this.node.parentNode);
- };
- /*\
- * Element.append
- [ method ]
- **
- * Appends the given element to current one
- **
- - el (Element|Set) element to append
- = (Element) the parent element
- \*/
- /*\
- * Element.add
- [ method ]
- **
- * See @Element.append
- \*/
- elproto.append = elproto.add = function (el) {
- if (el) {
- if (el.type == "set") {
- var it = this;
- el.forEach(function (el) {
- it.add(el);
- });
- return this;
- }
- el = wrap(el);
- this.node.appendChild(el.node);
- el.paper = this.paper;
- }
- return this;
- };
- /*\
- * Element.appendTo
- [ method ]
- **
- * Appends the current element to the given one
- **
- - el (Element) parent element to append to
- = (Element) the child element
- \*/
- elproto.appendTo = function (el) {
- if (el) {
- el = wrap(el);
- el.append(this);
- }
- return this;
- };
- /*\
- * Element.prepend
- [ method ]
- **
- * Prepends the given element to the current one
- **
- - el (Element) element to prepend
- = (Element) the parent element
- \*/
- elproto.prepend = function (el) {
- if (el) {
- if (el.type == "set") {
- var it = this,
- first;
- el.forEach(function (el) {
- if (first) {
- first.after(el);
- } else {
- it.prepend(el);
- }
- first = el;
- });
- return this;
- }
- el = wrap(el);
- var parent = el.parent();
- this.node.insertBefore(el.node, this.node.firstChild);
- this.add && this.add();
- el.paper = this.paper;
- this.parent() && this.parent().add();
- parent && parent.add();
- }
- return this;
- };
- /*\
- * Element.prependTo
- [ method ]
- **
- * Prepends the current element to the given one
- **
- - el (Element) parent element to prepend to
- = (Element) the child element
- \*/
- elproto.prependTo = function (el) {
- el = wrap(el);
- el.prepend(this);
- return this;
- };
- /*\
- * Element.before
- [ method ]
- **
- * Inserts given element before the current one
- **
- - el (Element) element to insert
- = (Element) the parent element
- \*/
- elproto.before = function (el) {
- if (el.type == "set") {
- var it = this;
- el.forEach(function (el) {
- var parent = el.parent();
- it.node.parentNode.insertBefore(el.node, it.node);
- parent && parent.add();
- });
- this.parent().add();
- return this;
- }
- el = wrap(el);
- var parent = el.parent();
- this.node.parentNode.insertBefore(el.node, this.node);
- this.parent() && this.parent().add();
- parent && parent.add();
- el.paper = this.paper;
- return this;
- };
- /*\
- * Element.after
- [ method ]
- **
- * Inserts given element after the current one
- **
- - el (Element) element to insert
- = (Element) the parent element
- \*/
- elproto.after = function (el) {
- el = wrap(el);
- var parent = el.parent();
- if (this.node.nextSibling) {
- this.node.parentNode.insertBefore(el.node, this.node.nextSibling);
- } else {
- this.node.parentNode.appendChild(el.node);
- }
- this.parent() && this.parent().add();
- parent && parent.add();
- el.paper = this.paper;
- return this;
- };
- /*\
- * Element.insertBefore
- [ method ]
- **
- * Inserts the element after the given one
- **
- - el (Element) element next to whom insert to
- = (Element) the parent element
- \*/
- elproto.insertBefore = function (el) {
- el = wrap(el);
- var parent = this.parent();
- el.node.parentNode.insertBefore(this.node, el.node);
- this.paper = el.paper;
- parent && parent.add();
- el.parent() && el.parent().add();
- return this;
- };
- /*\
- * Element.insertAfter
- [ method ]
- **
- * Inserts the element after the given one
- **
- - el (Element) element next to whom insert to
- = (Element) the parent element
- \*/
- elproto.insertAfter = function (el) {
- el = wrap(el);
- var parent = this.parent();
- el.node.parentNode.insertBefore(this.node, el.node.nextSibling);
- this.paper = el.paper;
- parent && parent.add();
- el.parent() && el.parent().add();
- return this;
- };
- /*\
- * Element.remove
- [ method ]
- **
- * Removes element from the DOM
- = (Element) the detached element
- \*/
- elproto.remove = function () {
- var parent = this.parent();
- this.node.parentNode && this.node.parentNode.removeChild(this.node);
- delete this.paper;
- this.removed = true;
- parent && parent.add();
- return this;
- };
- /*\
- * Element.select
- [ method ]
- **
- * Gathers the nested @Element matching the given set of CSS selectors
- **
- - query (string) CSS selector
- = (Element) result of query selection
- \*/
- elproto.select = function (query) {
- query = Str(query).replace(/([^\\]):/g, "$1\\:");
- return wrap(this.node.querySelector(query));
- };
- /*\
- * Element.selectAll
- [ method ]
- **
- * Gathers nested @Element objects matching the given set of CSS selectors
- **
- - query (string) CSS selector
- = (Set|array) result of query selection
- \*/
- elproto.selectAll = function (query) {
- var nodelist = this.node.querySelectorAll(query),
- set = (Snap.set || Array)();
- for (var i = 0; i < nodelist.length; i++) {
- set.push(wrap(nodelist[i]));
- }
- return set;
- };
- /*\
- * Element.asPX
- [ method ]
- **
- * Returns given attribute of the element as a `px` value (not %, em, etc.)
- **
- - attr (string) attribute name
- - value (string) #optional attribute value
- = (Element) result of query selection
- \*/
- elproto.asPX = function (attr, value) {
- if (value == null) {
- value = this.attr(attr);
- }
- return +unit2px(this, attr, value);
- };
- // 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.
- /*\
- * Element.use
- [ method ]
- **
- * Creates a `<use>` element linked to the current element
- **
- = (Element) the `<use>` element
- \*/
- elproto.use = function () {
- var use,
- id = this.node.id;
- if (!id) {
- id = this.id;
- $(this.node, {
- id: id
- });
- }
- if (this.type == "linearGradient" || this.type == "radialGradient" ||
- this.type == "pattern") {
- use = make(this.type, this.node.parentNode);
- } else {
- use = make("use", this.node.parentNode);
- }
- $(use.node, {
- "xlink:href": "#" + id
- });
- use.original = this;
- return use;
- };
- function fixids(el) {
- var els = el.selectAll("*"),
- it,
- url = /^\s*url\(("|'|)(.*)\1\)\s*$/,
- ids = [],
- uses = {};
- function urltest(it, name) {
- var val = $(it.node, name);
- val = val && val.match(url);
- val = val && val[2];
- if (val && val.charAt() == "#") {
- val = val.substring(1);
- } else {
- return;
- }
- if (val) {
- uses[val] = (uses[val] || []).concat(function (id) {
- var attr = {};
- attr[name] = URL(id);
- $(it.node, attr);
- });
- }
- }
- function linktest(it) {
- var val = $(it.node, "xlink:href");
- if (val && val.charAt() == "#") {
- val = val.substring(1);
- } else {
- return;
- }
- if (val) {
- uses[val] = (uses[val] || []).concat(function (id) {
- it.attr("xlink:href", "#" + id);
- });
- }
- }
- for (var i = 0, ii = els.length; i < ii; i++) {
- it = els[i];
- urltest(it, "fill");
- urltest(it, "stroke");
- urltest(it, "filter");
- urltest(it, "mask");
- urltest(it, "clip-path");
- linktest(it);
- var oldid = $(it.node, "id");
- if (oldid) {
- $(it.node, {id: it.id});
- ids.push({
- old: oldid,
- id: it.id
- });
- }
- }
- for (i = 0, ii = ids.length; i < ii; i++) {
- var fs = uses[ids[i].old];
- if (fs) {
- for (var j = 0, jj = fs.length; j < jj; j++) {
- fs[j](ids[i].id);
- }
- }
- }
- }
- /*\
- * Element.clone
- [ method ]
- **
- * Creates a clone of the element and inserts it after the element
- **
- = (Element) the clone
- \*/
- elproto.clone = function () {
- var clone = wrap(this.node.cloneNode(true));
- if ($(clone.node, "id")) {
- $(clone.node, {id: clone.id});
- }
- fixids(clone);
- clone.insertAfter(this);
- return clone;
- };
- /*\
- * Element.toDefs
- [ method ]
- **
- * Moves element to the shared `<defs>` area
- **
- = (Element) the element
- \*/
- elproto.toDefs = function () {
- var defs = getSomeDefs(this);
- defs.appendChild(this.node);
- return this;
- };
- /*\
- * Element.toPattern
- [ method ]
- **
- * Creates a `<pattern>` element from the current element
- **
- * To create a pattern you have to specify the pattern rect:
- - x (string|number)
- - y (string|number)
- - width (string|number)
- - height (string|number)
- = (Element) the `<pattern>` element
- * You can use pattern later on as an argument for `fill` attribute:
- | var p = paper.path("M10-5-10,15M15,0,0,15M0-5-20,15").attr({
- | fill: "none",
- | stroke: "#bada55",
- | strokeWidth: 5
- | }).pattern(0, 0, 10, 10),
- | c = paper.circle(200, 200, 100);
- | c.attr({
- | fill: p
- | });
- \*/
- elproto.pattern = elproto.toPattern = function (x, y, width, height) {
- var p = make("pattern", getSomeDefs(this));
- if (x == null) {
- x = this.getBBox();
- }
- if (is(x, "object") && "x" in x) {
- y = x.y;
- width = x.width;
- height = x.height;
- x = x.x;
- }
- $(p.node, {
- x: x,
- y: y,
- width: width,
- height: height,
- patternUnits: "userSpaceOnUse",
- id: p.id,
- viewBox: [x, y, width, height].join(" ")
- });
- p.node.appendChild(this.node);
- return p;
- };
- // 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.
- // 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?
- /*\
- * Element.marker
- [ method ]
- **
- * Creates a `<marker>` element from the current element
- **
- * To create a marker you have to specify the bounding rect and reference point:
- - x (number)
- - y (number)
- - width (number)
- - height (number)
- - refX (number)
- - refY (number)
- = (Element) the `<marker>` element
- * 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.
- \*/
- // TODO add usage for markers
- elproto.marker = function (x, y, width, height, refX, refY) {
- var p = make("marker", getSomeDefs(this));
- if (x == null) {
- x = this.getBBox();
- }
- if (is(x, "object") && "x" in x) {
- y = x.y;
- width = x.width;
- height = x.height;
- refX = x.refX || x.cx;
- refY = x.refY || x.cy;
- x = x.x;
- }
- $(p.node, {
- viewBox: [x, y, width, height].join(" "),
- markerWidth: width,
- markerHeight: height,
- orient: "auto",
- refX: refX || 0,
- refY: refY || 0,
- id: p.id
- });
- p.node.appendChild(this.node);
- return p;
- };
- // animation
- function slice(from, to, f) {
- return function (arr) {
- var res = arr.slice(from, to);
- if (res.length == 1) {
- res = res[0];
- }
- return f ? f(res) : res;
- };
- }
- var Animation = function (attr, ms, easing, callback) {
- if (typeof easing == "function" && !easing.length) {
- callback = easing;
- easing = mina.linear;
- }
- this.attr = attr;
- this.dur = ms;
- easing && (this.easing = easing);
- callback && (this.callback = callback);
- };
- Snap._.Animation = Animation;
- /*\
- * Snap.animation
- [ method ]
- **
- * Creates an animation object
- **
- - attr (object) attributes of final destination
- - duration (number) duration of the animation, in milliseconds
- - easing (function) #optional one of easing functions of @mina or custom one
- - callback (function) #optional callback function that fires when animation ends
- = (object) animation object
- \*/
- Snap.animation = function (attr, ms, easing, callback) {
- return new Animation(attr, ms, easing, callback);
- };
- /*\
- * Element.inAnim
- [ method ]
- **
- * Returns a set of animations that may be able to manipulate the current element
- **
- = (object) in format:
- o {
- o anim (object) animation object,
- o mina (object) @mina object,
- o curStatus (number) 0..1 — status of the animation: 0 — just started, 1 — just finished,
- o status (function) gets or sets the status of the animation,
- o stop (function) stops the animation
- o }
- \*/
- elproto.inAnim = function () {
- var el = this,
- res = [];
- for (var id in el.anims) if (el.anims[has](id)) {
- (function (a) {
- res.push({
- anim: new Animation(a._attrs, a.dur, a.easing, a._callback),
- mina: a,
- curStatus: a.status(),
- status: function (val) {
- return a.status(val);
- },
- stop: function () {
- a.stop();
- }
- });
- }(el.anims[id]));
- }
- return res;
- };
- /*\
- * Snap.animate
- [ method ]
- **
- * Runs generic animation of one number into another with a caring function
- **
- - from (number|array) number or array of numbers
- - to (number|array) number or array of numbers
- - setter (function) caring function that accepts one number argument
- - duration (number) duration, in milliseconds
- - easing (function) #optional easing function from @mina or custom
- - callback (function) #optional callback function to execute when animation ends
- = (object) animation object in @mina format
- o {
- o id (string) animation id, consider it read-only,
- o duration (function) gets or sets the duration of the animation,
- o easing (function) easing,
- o speed (function) gets or sets the speed of the animation,
- o status (function) gets or sets the status of the animation,
- o stop (function) stops the animation
- o }
- | var rect = Snap().rect(0, 0, 10, 10);
- | Snap.animate(0, 10, function (val) {
- | rect.attr({
- | x: val
- | });
- | }, 1000);
- | // in given context is equivalent to
- | rect.animate({x: 10}, 1000);
- \*/
- Snap.animate = function (from, to, setter, ms, easing, callback) {
- if (typeof easing == "function" && !easing.length) {
- callback = easing;
- easing = mina.linear;
- }
- var now = mina.time(),
- anim = mina(from, to, now, now + ms, mina.time, setter, easing);
- callback && eve.once("mina.finish." + anim.id, callback);
- return anim;
- };
- /*\
- * Element.stop
- [ method ]
- **
- * Stops all the animations for the current element
- **
- = (Element) the current element
- \*/
- elproto.stop = function () {
- var anims = this.inAnim();
- for (var i = 0, ii = anims.length; i < ii; i++) {
- anims[i].stop();
- }
- return this;
- };
- /*\
- * Element.animate
- [ method ]
- **
- * Animates the given attributes of the element
- **
- - attrs (object) key-value pairs of destination attributes
- - duration (number) duration of the animation in milliseconds
- - easing (function) #optional easing function from @mina or custom
- - callback (function) #optional callback function that executes when the animation ends
- = (Element) the current element
- \*/
- elproto.animate = function (attrs, ms, easing, callback) {
- if (typeof easing == "function" && !easing.length) {
- callback = easing;
- easing = mina.linear;
- }
- if (attrs instanceof Animation) {
- callback = attrs.callback;
- easing = attrs.easing;
- ms = easing.dur;
- attrs = attrs.attr;
- }
- var fkeys = [], tkeys = [], keys = {}, from, to, f, eq,
- el = this;
- for (var key in attrs) if (attrs[has](key)) {
- if (el.equal) {
- eq = el.equal(key, Str(attrs[key]));
- from = eq.from;
- to = eq.to;
- f = eq.f;
- } else {
- from = +el.attr(key);
- to = +attrs[key];
- }
- var len = is(from, "array") ? from.length : 1;
- keys[key] = slice(fkeys.length, fkeys.length + len, f);
- fkeys = fkeys.concat(from);
- tkeys = tkeys.concat(to);
- }
- var now = mina.time(),
- anim = mina(fkeys, tkeys, now, now + ms, mina.time, function (val) {
- var attr = {};
- for (var key in keys) if (keys[has](key)) {
- attr[key] = keys[key](val);
- }
- el.attr(attr);
- }, easing);
- el.anims[anim.id] = anim;
- anim._attrs = attrs;
- anim._callback = callback;
- eve("snap.animcreated." + el.id, anim);
- eve.once("mina.finish." + anim.id, function () {
- delete el.anims[anim.id];
- callback && callback.call(el);
- });
- eve.once("mina.stop." + anim.id, function () {
- delete el.anims[anim.id];
- });
- return el;
- };
- var eldata = {};
- /*\
- * Element.data
- [ method ]
- **
- * Adds or retrieves given value associated with given key. (Don’t confuse
- * with `data-` attributes)
- *
- * See also @Element.removeData
- - key (string) key to store data
- - value (any) #optional value to store
- = (object) @Element
- * or, if value is not specified:
- = (any) value
- > Usage
- | for (var i = 0, i < 5, i++) {
- | paper.circle(10 + 15 * i, 10, 10)
- | .attr({fill: "#000"})
- | .data("i", i)
- | .click(function () {
- | alert(this.data("i"));
- | });
- | }
- \*/
- elproto.data = function (key, value) {
- var data = eldata[this.id] = eldata[this.id] || {};
- if (arguments.length == 0){
- eve("snap.data.get." + this.id, this, data, null);
- return data;
- }
- if (arguments.length == 1) {
- if (Snap.is(key, "object")) {
- for (var i in key) if (key[has](i)) {
- this.data(i, key[i]);
- }
- return this;
- }
- eve("snap.data.get." + this.id, this, data[key], key);
- return data[key];
- }
- data[key] = value;
- eve("snap.data.set." + this.id, this, value, key);
- return this;
- };
- /*\
- * Element.removeData
- [ method ]
- **
- * Removes value associated with an element by given key.
- * If key is not provided, removes all the data of the element.
- - key (string) #optional key
- = (object) @Element
- \*/
- elproto.removeData = function (key) {
- if (key == null) {
- eldata[this.id] = {};
- } else {
- eldata[this.id] && delete eldata[this.id][key];
- }
- return this;
- };
- /*\
- * Element.outerSVG
- [ method ]
- **
- * Returns SVG code for the element, equivalent to HTML's `outerHTML`.
- *
- * See also @Element.innerSVG
- = (string) SVG code for the element
- \*/
- /*\
- * Element.toString
- [ method ]
- **
- * See @Element.outerSVG
- \*/
- elproto.outerSVG = elproto.toString = toString(1);
- /*\
- * Element.innerSVG
- [ method ]
- **
- * Returns SVG code for the element's contents, equivalent to HTML's `innerHTML`
- = (string) SVG code for the element
- \*/
- elproto.innerSVG = toString();
- function toString(type) {
- return function () {
- var res = type ? "<" + this.type : "",
- attr = this.node.attributes,
- chld = this.node.childNodes;
- if (type) {
- for (var i = 0, ii = attr.length; i < ii; i++) {
- res += " " + attr[i].name + '="' +
- attr[i].value.replace(/"/g, '\\"') + '"';
- }
- }
- if (chld.length) {
- type && (res += ">");
- for (i = 0, ii = chld.length; i < ii; i++) {
- if (chld[i].nodeType == 3) {
- res += chld[i].nodeValue;
- } else if (chld[i].nodeType == 1) {
- res += wrap(chld[i]).toString();
- }
- }
- type && (res += "</" + this.type + ">");
- } else {
- type && (res += "/>");
- }
- return res;
- };
- }
- elproto.toDataURL = function () {
- if (window && window.btoa) {
- var bb = this.getBBox(),
- 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>', {
- x: +bb.x.toFixed(3),
- y: +bb.y.toFixed(3),
- width: +bb.width.toFixed(3),
- height: +bb.height.toFixed(3),
- contents: this.outerSVG()
- });
- return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(svg)));
- }
- };
- /*\
- * Fragment.select
- [ method ]
- **
- * See @Element.select
- \*/
- Fragment.prototype.select = elproto.select;
- /*\
- * Fragment.selectAll
- [ method ]
- **
- * See @Element.selectAll
- \*/
- Fragment.prototype.selectAll = elproto.selectAll;
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
- var objectToString = Object.prototype.toString,
- Str = String,
- math = Math,
- E = "";
- function Matrix(a, b, c, d, e, f) {
- if (b == null && objectToString.call(a) == "[object SVGMatrix]") {
- this.a = a.a;
- this.b = a.b;
- this.c = a.c;
- this.d = a.d;
- this.e = a.e;
- this.f = a.f;
- return;
- }
- if (a != null) {
- this.a = +a;
- this.b = +b;
- this.c = +c;
- this.d = +d;
- this.e = +e;
- this.f = +f;
- } else {
- this.a = 1;
- this.b = 0;
- this.c = 0;
- this.d = 1;
- this.e = 0;
- this.f = 0;
- }
- }
- (function (matrixproto) {
- /*\
- * Matrix.add
- [ method ]
- **
- * Adds the given matrix to existing one
- - a (number)
- - b (number)
- - c (number)
- - d (number)
- - e (number)
- - f (number)
- * or
- - matrix (object) @Matrix
- \*/
- matrixproto.add = function (a, b, c, d, e, f) {
- var out = [[], [], []],
- m = [[this.a, this.c, this.e], [this.b, this.d, this.f], [0, 0, 1]],
- matrix = [[a, c, e], [b, d, f], [0, 0, 1]],
- x, y, z, res;
- if (a && a instanceof Matrix) {
- matrix = [[a.a, a.c, a.e], [a.b, a.d, a.f], [0, 0, 1]];
- }
- for (x = 0; x < 3; x++) {
- for (y = 0; y < 3; y++) {
- res = 0;
- for (z = 0; z < 3; z++) {
- res += m[x][z] * matrix[z][y];
- }
- out[x][y] = res;
- }
- }
- this.a = out[0][0];
- this.b = out[1][0];
- this.c = out[0][1];
- this.d = out[1][1];
- this.e = out[0][2];
- this.f = out[1][2];
- return this;
- };
- /*\
- * Matrix.invert
- [ method ]
- **
- * Returns an inverted version of the matrix
- = (object) @Matrix
- \*/
- matrixproto.invert = function () {
- var me = this,
- x = me.a * me.d - me.b * me.c;
- 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);
- };
- /*\
- * Matrix.clone
- [ method ]
- **
- * Returns a copy of the matrix
- = (object) @Matrix
- \*/
- matrixproto.clone = function () {
- return new Matrix(this.a, this.b, this.c, this.d, this.e, this.f);
- };
- /*\
- * Matrix.translate
- [ method ]
- **
- * Translate the matrix
- - x (number) horizontal offset distance
- - y (number) vertical offset distance
- \*/
- matrixproto.translate = function (x, y) {
- return this.add(1, 0, 0, 1, x, y);
- };
- /*\
- * Matrix.scale
- [ method ]
- **
- * Scales the matrix
- - x (number) amount to be scaled, with `1` resulting in no change
- - y (number) #optional amount to scale along the vertical axis. (Otherwise `x` applies to both axes.)
- - cx (number) #optional horizontal origin point from which to scale
- - cy (number) #optional vertical origin point from which to scale
- * Default cx, cy is the middle point of the element.
- \*/
- matrixproto.scale = function (x, y, cx, cy) {
- y == null && (y = x);
- (cx || cy) && this.add(1, 0, 0, 1, cx, cy);
- this.add(x, 0, 0, y, 0, 0);
- (cx || cy) && this.add(1, 0, 0, 1, -cx, -cy);
- return this;
- };
- /*\
- * Matrix.rotate
- [ method ]
- **
- * Rotates the matrix
- - a (number) angle of rotation, in degrees
- - x (number) horizontal origin point from which to rotate
- - y (number) vertical origin point from which to rotate
- \*/
- matrixproto.rotate = function (a, x, y) {
- a = Snap.rad(a);
- x = x || 0;
- y = y || 0;
- var cos = +math.cos(a).toFixed(9),
- sin = +math.sin(a).toFixed(9);
- this.add(cos, sin, -sin, cos, x, y);
- return this.add(1, 0, 0, 1, -x, -y);
- };
- /*\
- * Matrix.x
- [ method ]
- **
- * Returns x coordinate for given point after transformation described by the matrix. See also @Matrix.y
- - x (number)
- - y (number)
- = (number) x
- \*/
- matrixproto.x = function (x, y) {
- return x * this.a + y * this.c + this.e;
- };
- /*\
- * Matrix.y
- [ method ]
- **
- * Returns y coordinate for given point after transformation described by the matrix. See also @Matrix.x
- - x (number)
- - y (number)
- = (number) y
- \*/
- matrixproto.y = function (x, y) {
- return x * this.b + y * this.d + this.f;
- };
- matrixproto.get = function (i) {
- return +this[Str.fromCharCode(97 + i)].toFixed(4);
- };
- matrixproto.toString = function () {
- return "matrix(" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)].join() + ")";
- };
- matrixproto.offset = function () {
- return [this.e.toFixed(4), this.f.toFixed(4)];
- };
- function norm(a) {
- return a[0] * a[0] + a[1] * a[1];
- }
- function normalize(a) {
- var mag = math.sqrt(norm(a));
- a[0] && (a[0] /= mag);
- a[1] && (a[1] /= mag);
- }
- /*\
- * Matrix.determinant
- [ method ]
- **
- * Finds determinant of the given matrix.
- = (number) determinant
- \*/
- matrixproto.determinant = function () {
- return this.a * this.d - this.b * this.c;
- };
- /*\
- * Matrix.split
- [ method ]
- **
- * Splits matrix into primitive transformations
- = (object) in format:
- o dx (number) translation by x
- o dy (number) translation by y
- o scalex (number) scale by x
- o scaley (number) scale by y
- o shear (number) shear
- o rotate (number) rotation in deg
- o isSimple (boolean) could it be represented via simple transformations
- \*/
- matrixproto.split = function () {
- var out = {};
- // translation
- out.dx = this.e;
- out.dy = this.f;
- // scale and shear
- var row = [[this.a, this.c], [this.b, this.d]];
- out.scalex = math.sqrt(norm(row[0]));
- normalize(row[0]);
- out.shear = row[0][0] * row[1][0] + row[0][1] * row[1][1];
- row[1] = [row[1][0] - row[0][0] * out.shear, row[1][1] - row[0][1] * out.shear];
- out.scaley = math.sqrt(norm(row[1]));
- normalize(row[1]);
- out.shear /= out.scaley;
- if (this.determinant() < 0) {
- out.scalex = -out.scalex;
- }
- // rotation
- var sin = -row[0][1],
- cos = row[1][1];
- if (cos < 0) {
- out.rotate = Snap.deg(math.acos(cos));
- if (sin < 0) {
- out.rotate = 360 - out.rotate;
- }
- } else {
- out.rotate = Snap.deg(math.asin(sin));
- }
- out.isSimple = !+out.shear.toFixed(9) && (out.scalex.toFixed(9) == out.scaley.toFixed(9) || !out.rotate);
- out.isSuperSimple = !+out.shear.toFixed(9) && out.scalex.toFixed(9) == out.scaley.toFixed(9) && !out.rotate;
- out.noRotation = !+out.shear.toFixed(9) && !out.rotate;
- return out;
- };
- /*\
- * Matrix.toTransformString
- [ method ]
- **
- * Returns transform string that represents given matrix
- = (string) transform string
- \*/
- matrixproto.toTransformString = function (shorter) {
- var s = shorter || this.split();
- if (!+s.shear.toFixed(9)) {
- s.scalex = +s.scalex.toFixed(4);
- s.scaley = +s.scaley.toFixed(4);
- s.rotate = +s.rotate.toFixed(4);
- return (s.dx || s.dy ? "t" + [+s.dx.toFixed(4), +s.dy.toFixed(4)] : E) +
- (s.scalex != 1 || s.scaley != 1 ? "s" + [s.scalex, s.scaley, 0, 0] : E) +
- (s.rotate ? "r" + [+s.rotate.toFixed(4), 0, 0] : E);
- } else {
- return "m" + [this.get(0), this.get(1), this.get(2), this.get(3), this.get(4), this.get(5)];
- }
- };
- })(Matrix.prototype);
- /*\
- * Snap.Matrix
- [ method ]
- **
- * Matrix constructor, extend on your own risk.
- * To create matrices use @Snap.matrix.
- \*/
- Snap.Matrix = Matrix;
- /*\
- * Snap.matrix
- [ method ]
- **
- * Utility method
- **
- * Returns a matrix based on the given parameters
- - a (number)
- - b (number)
- - c (number)
- - d (number)
- - e (number)
- - f (number)
- * or
- - svgMatrix (SVGMatrix)
- = (object) @Matrix
- \*/
- Snap.matrix = function (a, b, c, d, e, f) {
- return new Matrix(a, b, c, d, e, f);
- };
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
- var has = "hasOwnProperty",
- make = Snap._.make,
- wrap = Snap._.wrap,
- is = Snap.is,
- getSomeDefs = Snap._.getSomeDefs,
- reURLValue = /^url\(#?([^)]+)\)$/,
- $ = Snap._.$,
- URL = Snap.url,
- Str = String,
- separator = Snap._.separator,
- E = "";
- // Attributes event handlers
- eve.on("snap.util.attr.mask", function (value) {
- if (value instanceof Element || value instanceof Fragment) {
- eve.stop();
- if (value instanceof Fragment && value.node.childNodes.length == 1) {
- value = value.node.firstChild;
- getSomeDefs(this).appendChild(value);
- value = wrap(value);
- }
- if (value.type == "mask") {
- var mask = value;
- } else {
- mask = make("mask", getSomeDefs(this));
- mask.node.appendChild(value.node);
- }
- !mask.node.id && $(mask.node, {
- id: mask.id
- });
- $(this.node, {
- mask: URL(mask.id)
- });
- }
- });
- (function (clipIt) {
- eve.on("snap.util.attr.clip", clipIt);
- eve.on("snap.util.attr.clip-path", clipIt);
- eve.on("snap.util.attr.clipPath", clipIt);
- }(function (value) {
- if (value instanceof Element || value instanceof Fragment) {
- eve.stop();
- if (value.type == "clipPath") {
- var clip = value;
- } else {
- clip = make("clipPath", getSomeDefs(this));
- clip.node.appendChild(value.node);
- !clip.node.id && $(clip.node, {
- id: clip.id
- });
- }
- $(this.node, {
- "clip-path": URL(clip.node.id || clip.id)
- });
- }
- }));
- function fillStroke(name) {
- return function (value) {
- eve.stop();
- if (value instanceof Fragment && value.node.childNodes.length == 1 &&
- (value.node.firstChild.tagName == "radialGradient" ||
- value.node.firstChild.tagName == "linearGradient" ||
- value.node.firstChild.tagName == "pattern")) {
- value = value.node.firstChild;
- getSomeDefs(this).appendChild(value);
- value = wrap(value);
- }
- if (value instanceof Element) {
- if (value.type == "radialGradient" || value.type == "linearGradient"
- || value.type == "pattern") {
- if (!value.node.id) {
- $(value.node, {
- id: value.id
- });
- }
- var fill = URL(value.node.id);
- } else {
- fill = value.attr(name);
- }
- } else {
- fill = Snap.color(value);
- if (fill.error) {
- var grad = Snap(getSomeDefs(this).ownerSVGElement).gradient(value);
- if (grad) {
- if (!grad.node.id) {
- $(grad.node, {
- id: grad.id
- });
- }
- fill = URL(grad.node.id);
- } else {
- fill = value;
- }
- } else {
- fill = Str(fill);
- }
- }
- var attrs = {};
- attrs[name] = fill;
- $(this.node, attrs);
- this.node.style[name] = E;
- };
- }
- eve.on("snap.util.attr.fill", fillStroke("fill"));
- eve.on("snap.util.attr.stroke", fillStroke("stroke"));
- var gradrg = /^([lr])(?:\(([^)]*)\))?(.*)$/i;
- eve.on("snap.util.grad.parse", function parseGrad(string) {
- string = Str(string);
- var tokens = string.match(gradrg);
- if (!tokens) {
- return null;
- }
- var type = tokens[1],
- params = tokens[2],
- stops = tokens[3];
- params = params.split(/\s*,\s*/).map(function (el) {
- return +el == el ? +el : el;
- });
- if (params.length == 1 && params[0] == 0) {
- params = [];
- }
- stops = stops.split("-");
- stops = stops.map(function (el) {
- el = el.split(":");
- var out = {
- color: el[0]
- };
- if (el[1]) {
- out.offset = parseFloat(el[1]);
- }
- return out;
- });
- return {
- type: type,
- params: params,
- stops: stops
- };
- });
- eve.on("snap.util.attr.d", function (value) {
- eve.stop();
- if (is(value, "array") && is(value[0], "array")) {
- value = Snap.path.toString.call(value);
- }
- value = Str(value);
- if (value.match(/[ruo]/i)) {
- value = Snap.path.toAbsolute(value);
- }
- $(this.node, {d: value});
- })(-1);
- eve.on("snap.util.attr.#text", function (value) {
- eve.stop();
- value = Str(value);
- var txt = glob.doc.createTextNode(value);
- while (this.node.firstChild) {
- this.node.removeChild(this.node.firstChild);
- }
- this.node.appendChild(txt);
- })(-1);
- eve.on("snap.util.attr.path", function (value) {
- eve.stop();
- this.attr({d: value});
- })(-1);
- eve.on("snap.util.attr.class", function (value) {
- eve.stop();
- this.node.className.baseVal = value;
- })(-1);
- eve.on("snap.util.attr.viewBox", function (value) {
- var vb;
- if (is(value, "object") && "x" in value) {
- vb = [value.x, value.y, value.width, value.height].join(" ");
- } else if (is(value, "array")) {
- vb = value.join(" ");
- } else {
- vb = value;
- }
- $(this.node, {
- viewBox: vb
- });
- eve.stop();
- })(-1);
- eve.on("snap.util.attr.transform", function (value) {
- this.transform(value);
- eve.stop();
- })(-1);
- eve.on("snap.util.attr.r", function (value) {
- if (this.type == "rect") {
- eve.stop();
- $(this.node, {
- rx: value,
- ry: value
- });
- }
- })(-1);
- eve.on("snap.util.attr.textpath", function (value) {
- eve.stop();
- if (this.type == "text") {
- var id, tp, node;
- if (!value && this.textPath) {
- tp = this.textPath;
- while (tp.node.firstChild) {
- this.node.appendChild(tp.node.firstChild);
- }
- tp.remove();
- delete this.textPath;
- return;
- }
- if (is(value, "string")) {
- var defs = getSomeDefs(this),
- path = wrap(defs.parentNode).path(value);
- defs.appendChild(path.node);
- id = path.id;
- path.attr({id: id});
- } else {
- value = wrap(value);
- if (value instanceof Element) {
- id = value.attr("id");
- if (!id) {
- id = value.id;
- value.attr({id: id});
- }
- }
- }
- if (id) {
- tp = this.textPath;
- node = this.node;
- if (tp) {
- tp.attr({"xlink:href": "#" + id});
- } else {
- tp = $("textPath", {
- "xlink:href": "#" + id
- });
- while (node.firstChild) {
- tp.appendChild(node.firstChild);
- }
- node.appendChild(tp);
- this.textPath = wrap(tp);
- }
- }
- }
- })(-1);
- eve.on("snap.util.attr.text", function (value) {
- if (this.type == "text") {
- var i = 0,
- node = this.node,
- tuner = function (chunk) {
- var out = $("tspan");
- if (is(chunk, "array")) {
- for (var i = 0; i < chunk.length; i++) {
- out.appendChild(tuner(chunk[i]));
- }
- } else {
- out.appendChild(glob.doc.createTextNode(chunk));
- }
- out.normalize && out.normalize();
- return out;
- };
- while (node.firstChild) {
- node.removeChild(node.firstChild);
- }
- var tuned = tuner(value);
- while (tuned.firstChild) {
- node.appendChild(tuned.firstChild);
- }
- }
- eve.stop();
- })(-1);
- function setFontSize(value) {
- eve.stop();
- if (value == +value) {
- value += "px";
- }
- this.node.style.fontSize = value;
- }
- eve.on("snap.util.attr.fontSize", setFontSize)(-1);
- eve.on("snap.util.attr.font-size", setFontSize)(-1);
- eve.on("snap.util.getattr.transform", function () {
- eve.stop();
- return this.transform();
- })(-1);
- eve.on("snap.util.getattr.textpath", function () {
- eve.stop();
- return this.textPath;
- })(-1);
- // Markers
- (function () {
- function getter(end) {
- return function () {
- eve.stop();
- var style = glob.doc.defaultView.getComputedStyle(this.node, null).getPropertyValue("marker-" + end);
- if (style == "none") {
- return style;
- } else {
- return Snap(glob.doc.getElementById(style.match(reURLValue)[1]));
- }
- };
- }
- function setter(end) {
- return function (value) {
- eve.stop();
- var name = "marker" + end.charAt(0).toUpperCase() + end.substring(1);
- if (value == "" || !value) {
- this.node.style[name] = "none";
- return;
- }
- if (value.type == "marker") {
- var id = value.node.id;
- if (!id) {
- $(value.node, {id: value.id});
- }
- this.node.style[name] = URL(id);
- return;
- }
- };
- }
- eve.on("snap.util.getattr.marker-end", getter("end"))(-1);
- eve.on("snap.util.getattr.markerEnd", getter("end"))(-1);
- eve.on("snap.util.getattr.marker-start", getter("start"))(-1);
- eve.on("snap.util.getattr.markerStart", getter("start"))(-1);
- eve.on("snap.util.getattr.marker-mid", getter("mid"))(-1);
- eve.on("snap.util.getattr.markerMid", getter("mid"))(-1);
- eve.on("snap.util.attr.marker-end", setter("end"))(-1);
- eve.on("snap.util.attr.markerEnd", setter("end"))(-1);
- eve.on("snap.util.attr.marker-start", setter("start"))(-1);
- eve.on("snap.util.attr.markerStart", setter("start"))(-1);
- eve.on("snap.util.attr.marker-mid", setter("mid"))(-1);
- eve.on("snap.util.attr.markerMid", setter("mid"))(-1);
- }());
- eve.on("snap.util.getattr.r", function () {
- if (this.type == "rect" && $(this.node, "rx") == $(this.node, "ry")) {
- eve.stop();
- return $(this.node, "rx");
- }
- })(-1);
- function textExtract(node) {
- var out = [];
- var children = node.childNodes;
- for (var i = 0, ii = children.length; i < ii; i++) {
- var chi = children[i];
- if (chi.nodeType == 3) {
- out.push(chi.nodeValue);
- }
- if (chi.tagName == "tspan") {
- if (chi.childNodes.length == 1 && chi.firstChild.nodeType == 3) {
- out.push(chi.firstChild.nodeValue);
- } else {
- out.push(textExtract(chi));
- }
- }
- }
- return out;
- }
- eve.on("snap.util.getattr.text", function () {
- if (this.type == "text" || this.type == "tspan") {
- eve.stop();
- var out = textExtract(this.node);
- return out.length == 1 ? out[0] : out;
- }
- })(-1);
- eve.on("snap.util.getattr.#text", function () {
- return this.node.textContent;
- })(-1);
- eve.on("snap.util.getattr.viewBox", function () {
- eve.stop();
- var vb = $(this.node, "viewBox");
- if (vb) {
- vb = vb.split(separator);
- return Snap._.box(+vb[0], +vb[1], +vb[2], +vb[3]);
- } else {
- return;
- }
- })(-1);
- eve.on("snap.util.getattr.points", function () {
- var p = $(this.node, "points");
- eve.stop();
- if (p) {
- return p.split(separator);
- } else {
- return;
- }
- })(-1);
- eve.on("snap.util.getattr.path", function () {
- var p = $(this.node, "d");
- eve.stop();
- return p;
- })(-1);
- eve.on("snap.util.getattr.class", function () {
- return this.node.className.baseVal;
- })(-1);
- function getFontSize() {
- eve.stop();
- return this.node.style.fontSize;
- }
- eve.on("snap.util.getattr.fontSize", getFontSize)(-1);
- eve.on("snap.util.getattr.font-size", getFontSize)(-1);
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob, Fragment) {
- var proto = Paper.prototype,
- is = Snap.is;
- /*\
- * Paper.rect
- [ method ]
- *
- * Draws a rectangle
- **
- - x (number) x coordinate of the top left corner
- - y (number) y coordinate of the top left corner
- - width (number) width
- - height (number) height
- - rx (number) #optional horizontal radius for rounded corners, default is 0
- - ry (number) #optional vertical radius for rounded corners, default is rx or 0
- = (object) the `rect` element
- **
- > Usage
- | // regular rectangle
- | var c = paper.rect(10, 10, 50, 50);
- | // rectangle with rounded corners
- | var c = paper.rect(40, 40, 50, 50, 10);
- \*/
- proto.rect = function (x, y, w, h, rx, ry) {
- var attr;
- if (ry == null) {
- ry = rx;
- }
- if (is(x, "object") && x == "[object Object]") {
- attr = x;
- } else if (x != null) {
- attr = {
- x: x,
- y: y,
- width: w,
- height: h
- };
- if (rx != null) {
- attr.rx = rx;
- attr.ry = ry;
- }
- }
- return this.el("rect", attr);
- };
- /*\
- * Paper.circle
- [ method ]
- **
- * Draws a circle
- **
- - x (number) x coordinate of the centre
- - y (number) y coordinate of the centre
- - r (number) radius
- = (object) the `circle` element
- **
- > Usage
- | var c = paper.circle(50, 50, 40);
- \*/
- proto.circle = function (cx, cy, r) {
- var attr;
- if (is(cx, "object") && cx == "[object Object]") {
- attr = cx;
- } else if (cx != null) {
- attr = {
- cx: cx,
- cy: cy,
- r: r
- };
- }
- return this.el("circle", attr);
- };
- var preload = (function () {
- function onerror() {
- this.parentNode.removeChild(this);
- }
- return function (src, f) {
- var img = glob.doc.createElement("img"),
- body = glob.doc.body;
- img.style.cssText = "position:absolute;left:-9999em;top:-9999em";
- img.onload = function () {
- f.call(img);
- img.onload = img.onerror = null;
- body.removeChild(img);
- };
- img.onerror = onerror;
- body.appendChild(img);
- img.src = src;
- };
- }());
- /*\
- * Paper.image
- [ method ]
- **
- * Places an image on the surface
- **
- - src (string) URI of the source image
- - x (number) x offset position
- - y (number) y offset position
- - width (number) width of the image
- - height (number) height of the image
- = (object) the `image` element
- * or
- = (object) Snap element object with type `image`
- **
- > Usage
- | var c = paper.image("apple.png", 10, 10, 80, 80);
- \*/
- proto.image = function (src, x, y, width, height) {
- var el = this.el("image");
- if (is(src, "object") && "src" in src) {
- el.attr(src);
- } else if (src != null) {
- var set = {
- "xlink:href": src,
- preserveAspectRatio: "none"
- };
- if (x != null && y != null) {
- set.x = x;
- set.y = y;
- }
- if (width != null && height != null) {
- set.width = width;
- set.height = height;
- } else {
- preload(src, function () {
- Snap._.$(el.node, {
- width: this.offsetWidth,
- height: this.offsetHeight
- });
- });
- }
- Snap._.$(el.node, set);
- }
- return el;
- };
- /*\
- * Paper.ellipse
- [ method ]
- **
- * Draws an ellipse
- **
- - x (number) x coordinate of the centre
- - y (number) y coordinate of the centre
- - rx (number) horizontal radius
- - ry (number) vertical radius
- = (object) the `ellipse` element
- **
- > Usage
- | var c = paper.ellipse(50, 50, 40, 20);
- \*/
- proto.ellipse = function (cx, cy, rx, ry) {
- var attr;
- if (is(cx, "object") && cx == "[object Object]") {
- attr = cx;
- } else if (cx != null) {
- attr ={
- cx: cx,
- cy: cy,
- rx: rx,
- ry: ry
- };
- }
- return this.el("ellipse", attr);
- };
- // SIERRA Paper.path(): Unclear from the link what a Catmull-Rom curveto is, and why it would make life any easier.
- /*\
- * Paper.path
- [ method ]
- **
- * Creates a `<path>` element using the given string as the path's definition
- - pathString (string) #optional path string in SVG format
- * Path string consists of one-letter commands, followed by comma seprarated arguments in numerical form. Example:
- | "M10,20L30,40"
- * 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.
- *
- # <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>
- # <table><thead><tr><th>Command</th><th>Name</th><th>Parameters</th></tr></thead><tbody>
- # <tr><td>M</td><td>moveto</td><td>(x y)+</td></tr>
- # <tr><td>Z</td><td>closepath</td><td>(none)</td></tr>
- # <tr><td>L</td><td>lineto</td><td>(x y)+</td></tr>
- # <tr><td>H</td><td>horizontal lineto</td><td>x+</td></tr>
- # <tr><td>V</td><td>vertical lineto</td><td>y+</td></tr>
- # <tr><td>C</td><td>curveto</td><td>(x1 y1 x2 y2 x y)+</td></tr>
- # <tr><td>S</td><td>smooth curveto</td><td>(x2 y2 x y)+</td></tr>
- # <tr><td>Q</td><td>quadratic Bézier curveto</td><td>(x1 y1 x y)+</td></tr>
- # <tr><td>T</td><td>smooth quadratic Bézier curveto</td><td>(x y)+</td></tr>
- # <tr><td>A</td><td>elliptical arc</td><td>(rx ry x-axis-rotation large-arc-flag sweep-flag x y)+</td></tr>
- # <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>
- * * _Catmull-Rom curveto_ is a not standard SVG command and added to make life easier.
- * 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.
- > Usage
- | var c = paper.path("M10 10L90 90");
- | // draw a diagonal line:
- | // move to 10,10, line to 90,90
- \*/
- proto.path = function (d) {
- var attr;
- if (is(d, "object") && !is(d, "array")) {
- attr = d;
- } else if (d) {
- attr = {d: d};
- }
- return this.el("path", attr);
- };
- /*\
- * Paper.g
- [ method ]
- **
- * Creates a group element
- **
- - varargs (…) #optional elements to nest within the group
- = (object) the `g` element
- **
- > Usage
- | var c1 = paper.circle(),
- | c2 = paper.rect(),
- | g = paper.g(c2, c1); // note that the order of elements is different
- * or
- | var c1 = paper.circle(),
- | c2 = paper.rect(),
- | g = paper.g();
- | g.add(c2, c1);
- \*/
- /*\
- * Paper.group
- [ method ]
- **
- * See @Paper.g
- \*/
- proto.group = proto.g = function (first) {
- var attr,
- el = this.el("g");
- if (arguments.length == 1 && first && !first.type) {
- el.attr(first);
- } else if (arguments.length) {
- el.add(Array.prototype.slice.call(arguments, 0));
- }
- return el;
- };
- /*\
- * Paper.svg
- [ method ]
- **
- * Creates a nested SVG element.
- - x (number) @optional X of the element
- - y (number) @optional Y of the element
- - width (number) @optional width of the element
- - height (number) @optional height of the element
- - vbx (number) @optional viewbox X
- - vby (number) @optional viewbox Y
- - vbw (number) @optional viewbox width
- - vbh (number) @optional viewbox height
- **
- = (object) the `svg` element
- **
- \*/
- proto.svg = function (x, y, width, height, vbx, vby, vbw, vbh) {
- var attrs = {};
- if (is(x, "object") && y == null) {
- attrs = x;
- } else {
- if (x != null) {
- attrs.x = x;
- }
- if (y != null) {
- attrs.y = y;
- }
- if (width != null) {
- attrs.width = width;
- }
- if (height != null) {
- attrs.height = height;
- }
- if (vbx != null && vby != null && vbw != null && vbh != null) {
- attrs.viewBox = [vbx, vby, vbw, vbh];
- }
- }
- return this.el("svg", attrs);
- };
- /*\
- * Paper.mask
- [ method ]
- **
- * Equivalent in behaviour to @Paper.g, except it’s a mask.
- **
- = (object) the `mask` element
- **
- \*/
- proto.mask = function (first) {
- var attr,
- el = this.el("mask");
- if (arguments.length == 1 && first && !first.type) {
- el.attr(first);
- } else if (arguments.length) {
- el.add(Array.prototype.slice.call(arguments, 0));
- }
- return el;
- };
- /*\
- * Paper.ptrn
- [ method ]
- **
- * Equivalent in behaviour to @Paper.g, except it’s a pattern.
- - x (number) @optional X of the element
- - y (number) @optional Y of the element
- - width (number) @optional width of the element
- - height (number) @optional height of the element
- - vbx (number) @optional viewbox X
- - vby (number) @optional viewbox Y
- - vbw (number) @optional viewbox width
- - vbh (number) @optional viewbox height
- **
- = (object) the `pattern` element
- **
- \*/
- proto.ptrn = function (x, y, width, height, vx, vy, vw, vh) {
- if (is(x, "object")) {
- var attr = x;
- } else {
- attr = {patternUnits: "userSpaceOnUse"};
- if (x) {
- attr.x = x;
- }
- if (y) {
- attr.y = y;
- }
- if (width != null) {
- attr.width = width;
- }
- if (height != null) {
- attr.height = height;
- }
- if (vx != null && vy != null && vw != null && vh != null) {
- attr.viewBox = [vx, vy, vw, vh];
- }
- }
- return this.el("pattern", attr);
- };
- /*\
- * Paper.use
- [ method ]
- **
- * Creates a <use> element.
- - id (string) @optional id of element to link
- * or
- - id (Element) @optional element to link
- **
- = (object) the `use` element
- **
- \*/
- proto.use = function (id) {
- if (id != null) {
- if (id instanceof Element) {
- if (!id.attr("id")) {
- id.attr({id: Snap._.id(id)});
- }
- id = id.attr("id");
- }
- if (String(id).charAt() == "#") {
- id = id.substring(1);
- }
- return this.el("use", {"xlink:href": "#" + id});
- } else {
- return Element.prototype.use.call(this);
- }
- };
- /*\
- * Paper.symbol
- [ method ]
- **
- * Creates a <symbol> element.
- - vbx (number) @optional viewbox X
- - vby (number) @optional viewbox Y
- - vbw (number) @optional viewbox width
- - vbh (number) @optional viewbox height
- = (object) the `symbol` element
- **
- \*/
- proto.symbol = function (vx, vy, vw, vh) {
- var attr = {};
- if (vx != null && vy != null && vw != null && vh != null) {
- attr.viewBox = [vx, vy, vw, vh];
- }
- return this.el("symbol", attr);
- };
- /*\
- * Paper.text
- [ method ]
- **
- * Draws a text string
- **
- - x (number) x coordinate position
- - y (number) y coordinate position
- - text (string|array) The text string to draw or array of strings to nest within separate `<tspan>` elements
- = (object) the `text` element
- **
- > Usage
- | var t1 = paper.text(50, 50, "Snap");
- | var t2 = paper.text(50, 50, ["S","n","a","p"]);
- | // Text path usage
- | t1.attr({textpath: "M10,10L100,100"});
- | // or
- | var pth = paper.path("M10,10L100,100");
- | t1.attr({textpath: pth});
- \*/
- proto.text = function (x, y, text) {
- var attr = {};
- if (is(x, "object")) {
- attr = x;
- } else if (x != null) {
- attr = {
- x: x,
- y: y,
- text: text || ""
- };
- }
- return this.el("text", attr);
- };
- /*\
- * Paper.line
- [ method ]
- **
- * Draws a line
- **
- - x1 (number) x coordinate position of the start
- - y1 (number) y coordinate position of the start
- - x2 (number) x coordinate position of the end
- - y2 (number) y coordinate position of the end
- = (object) the `line` element
- **
- > Usage
- | var t1 = paper.line(50, 50, 100, 100);
- \*/
- proto.line = function (x1, y1, x2, y2) {
- var attr = {};
- if (is(x1, "object")) {
- attr = x1;
- } else if (x1 != null) {
- attr = {
- x1: x1,
- x2: x2,
- y1: y1,
- y2: y2
- };
- }
- return this.el("line", attr);
- };
- /*\
- * Paper.polyline
- [ method ]
- **
- * Draws a polyline
- **
- - points (array) array of points
- * or
- - varargs (…) points
- = (object) the `polyline` element
- **
- > Usage
- | var p1 = paper.polyline([10, 10, 100, 100]);
- | var p2 = paper.polyline(10, 10, 100, 100);
- \*/
- proto.polyline = function (points) {
- if (arguments.length > 1) {
- points = Array.prototype.slice.call(arguments, 0);
- }
- var attr = {};
- if (is(points, "object") && !is(points, "array")) {
- attr = points;
- } else if (points != null) {
- attr = {points: points};
- }
- return this.el("polyline", attr);
- };
- /*\
- * Paper.polygon
- [ method ]
- **
- * Draws a polygon. See @Paper.polyline
- \*/
- proto.polygon = function (points) {
- if (arguments.length > 1) {
- points = Array.prototype.slice.call(arguments, 0);
- }
- var attr = {};
- if (is(points, "object") && !is(points, "array")) {
- attr = points;
- } else if (points != null) {
- attr = {points: points};
- }
- return this.el("polygon", attr);
- };
- // gradients
- (function () {
- var $ = Snap._.$;
- // gradients' helpers
- function Gstops() {
- return this.selectAll("stop");
- }
- function GaddStop(color, offset) {
- var stop = $("stop"),
- attr = {
- offset: +offset + "%"
- };
- color = Snap.color(color);
- attr["stop-color"] = color.hex;
- if (color.opacity < 1) {
- attr["stop-opacity"] = color.opacity;
- }
- $(stop, attr);
- this.node.appendChild(stop);
- return this;
- }
- function GgetBBox() {
- if (this.type == "linearGradient") {
- var x1 = $(this.node, "x1") || 0,
- x2 = $(this.node, "x2") || 1,
- y1 = $(this.node, "y1") || 0,
- y2 = $(this.node, "y2") || 0;
- return Snap._.box(x1, y1, math.abs(x2 - x1), math.abs(y2 - y1));
- } else {
- var cx = this.node.cx || .5,
- cy = this.node.cy || .5,
- r = this.node.r || 0;
- return Snap._.box(cx - r, cy - r, r * 2, r * 2);
- }
- }
- function gradient(defs, str) {
- var grad = eve("snap.util.grad.parse", null, str).firstDefined(),
- el;
- if (!grad) {
- return null;
- }
- grad.params.unshift(defs);
- if (grad.type.toLowerCase() == "l") {
- el = gradientLinear.apply(0, grad.params);
- } else {
- el = gradientRadial.apply(0, grad.params);
- }
- if (grad.type != grad.type.toLowerCase()) {
- $(el.node, {
- gradientUnits: "userSpaceOnUse"
- });
- }
- var stops = grad.stops,
- len = stops.length,
- start = 0,
- j = 0;
- function seed(i, end) {
- var step = (end - start) / (i - j);
- for (var k = j; k < i; k++) {
- stops[k].offset = +(+start + step * (k - j)).toFixed(2);
- }
- j = i;
- start = end;
- }
- len--;
- for (var i = 0; i < len; i++) if ("offset" in stops[i]) {
- seed(i, stops[i].offset);
- }
- stops[len].offset = stops[len].offset || 100;
- seed(len, stops[len].offset);
- for (i = 0; i <= len; i++) {
- var stop = stops[i];
- el.addStop(stop.color, stop.offset);
- }
- return el;
- }
- function gradientLinear(defs, x1, y1, x2, y2) {
- var el = Snap._.make("linearGradient", defs);
- el.stops = Gstops;
- el.addStop = GaddStop;
- el.getBBox = GgetBBox;
- if (x1 != null) {
- $(el.node, {
- x1: x1,
- y1: y1,
- x2: x2,
- y2: y2
- });
- }
- return el;
- }
- function gradientRadial(defs, cx, cy, r, fx, fy) {
- var el = Snap._.make("radialGradient", defs);
- el.stops = Gstops;
- el.addStop = GaddStop;
- el.getBBox = GgetBBox;
- if (cx != null) {
- $(el.node, {
- cx: cx,
- cy: cy,
- r: r
- });
- }
- if (fx != null && fy != null) {
- $(el.node, {
- fx: fx,
- fy: fy
- });
- }
- return el;
- }
- /*\
- * Paper.gradient
- [ method ]
- **
- * Creates a gradient element
- **
- - gradient (string) gradient descriptor
- > Gradient Descriptor
- * The gradient descriptor is an expression formatted as
- * follows: `<type>(<coords>)<colors>`. The `<type>` can be
- * either linear or radial. The uppercase `L` or `R` letters
- * indicate absolute coordinates offset from the SVG surface.
- * Lowercase `l` or `r` letters indicate coordinates
- * calculated relative to the element to which the gradient is
- * applied. Coordinates specify a linear gradient vector as
- * `x1`, `y1`, `x2`, `y2`, or a radial gradient as `cx`, `cy`,
- * `r` and optional `fx`, `fy` specifying a focal point away
- * from the center of the circle. Specify `<colors>` as a list
- * of dash-separated CSS color values. Each color may be
- * followed by a custom offset value, separated with a colon
- * character.
- > Examples
- * Linear gradient, relative from top-left corner to bottom-right
- * corner, from black through red to white:
- | var g = paper.gradient("l(0, 0, 1, 1)#000-#f00-#fff");
- * Linear gradient, absolute from (0, 0) to (100, 100), from black
- * through red at 25% to white:
- | var g = paper.gradient("L(0, 0, 100, 100)#000-#f00:25-#fff");
- * Radial gradient, relative from the center of the element with radius
- * half the width, from black to white:
- | var g = paper.gradient("r(0.5, 0.5, 0.5)#000-#fff");
- * To apply the gradient:
- | paper.circle(50, 50, 40).attr({
- | fill: g
- | });
- = (object) the `gradient` element
- \*/
- proto.gradient = function (str) {
- return gradient(this.defs, str);
- };
- proto.gradientLinear = function (x1, y1, x2, y2) {
- return gradientLinear(this.defs, x1, y1, x2, y2);
- };
- proto.gradientRadial = function (cx, cy, r, fx, fy) {
- return gradientRadial(this.defs, cx, cy, r, fx, fy);
- };
- /*\
- * Paper.toString
- [ method ]
- **
- * Returns SVG code for the @Paper
- = (string) SVG code for the @Paper
- \*/
- proto.toString = function () {
- var doc = this.node.ownerDocument,
- f = doc.createDocumentFragment(),
- d = doc.createElement("div"),
- svg = this.node.cloneNode(true),
- res;
- f.appendChild(d);
- d.appendChild(svg);
- Snap._.$(svg, {xmlns: "http://www.w3.org/2000/svg"});
- res = d.innerHTML;
- f.removeChild(f.firstChild);
- return res;
- };
- /*\
- * Paper.toDataURL
- [ method ]
- **
- * Returns SVG code for the @Paper as Data URI string.
- = (string) Data URI string
- \*/
- proto.toDataURL = function () {
- if (window && window.btoa) {
- return "data:image/svg+xml;base64," + btoa(unescape(encodeURIComponent(this)));
- }
- };
- /*\
- * Paper.clear
- [ method ]
- **
- * Removes all child nodes of the paper, except <defs>.
- \*/
- proto.clear = function () {
- var node = this.node.firstChild,
- next;
- while (node) {
- next = node.nextSibling;
- if (node.tagName != "defs") {
- node.parentNode.removeChild(node);
- } else {
- proto.clear.call({node: node});
- }
- node = next;
- }
- };
- }());
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob) {
- var elproto = Element.prototype,
- is = Snap.is,
- clone = Snap._.clone,
- has = "hasOwnProperty",
- p2s = /,?([a-z]),?/gi,
- toFloat = parseFloat,
- math = Math,
- PI = math.PI,
- mmin = math.min,
- mmax = math.max,
- pow = math.pow,
- abs = math.abs;
- function paths(ps) {
- var p = paths.ps = paths.ps || {};
- if (p[ps]) {
- p[ps].sleep = 100;
- } else {
- p[ps] = {
- sleep: 100
- };
- }
- setTimeout(function () {
- for (var key in p) if (p[has](key) && key != ps) {
- p[key].sleep--;
- !p[key].sleep && delete p[key];
- }
- });
- return p[ps];
- }
- function box(x, y, width, height) {
- if (x == null) {
- x = y = width = height = 0;
- }
- if (y == null) {
- y = x.y;
- width = x.width;
- height = x.height;
- x = x.x;
- }
- return {
- x: x,
- y: y,
- width: width,
- w: width,
- height: height,
- h: height,
- x2: x + width,
- y2: y + height,
- cx: x + width / 2,
- cy: y + height / 2,
- r1: math.min(width, height) / 2,
- r2: math.max(width, height) / 2,
- r0: math.sqrt(width * width + height * height) / 2,
- path: rectPath(x, y, width, height),
- vb: [x, y, width, height].join(" ")
- };
- }
- function toString() {
- return this.join(",").replace(p2s, "$1");
- }
- function pathClone(pathArray) {
- var res = clone(pathArray);
- res.toString = toString;
- return res;
- }
- function getPointAtSegmentLength(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length) {
- if (length == null) {
- return bezlen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y);
- } else {
- return findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y,
- getTotLen(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, length));
- }
- }
- function getLengthFactory(istotal, subpath) {
- function O(val) {
- return +(+val).toFixed(3);
- }
- return Snap._.cacher(function (path, length, onlystart) {
- if (path instanceof Element) {
- path = path.attr("d");
- }
- path = path2curve(path);
- var x, y, p, l, sp = "", subpaths = {}, point,
- len = 0;
- for (var i = 0, ii = path.length; i < ii; i++) {
- p = path[i];
- if (p[0] == "M") {
- x = +p[1];
- y = +p[2];
- } else {
- l = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
- if (len + l > length) {
- if (subpath && !subpaths.start) {
- point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
- sp += [
- "C" + O(point.start.x),
- O(point.start.y),
- O(point.m.x),
- O(point.m.y),
- O(point.x),
- O(point.y)
- ];
- if (onlystart) {return sp;}
- subpaths.start = sp;
- sp = [
- "M" + O(point.x),
- O(point.y) + "C" + O(point.n.x),
- O(point.n.y),
- O(point.end.x),
- O(point.end.y),
- O(p[5]),
- O(p[6])
- ].join();
- len += l;
- x = +p[5];
- y = +p[6];
- continue;
- }
- if (!istotal && !subpath) {
- point = getPointAtSegmentLength(x, y, p[1], p[2], p[3], p[4], p[5], p[6], length - len);
- return point;
- }
- }
- len += l;
- x = +p[5];
- y = +p[6];
- }
- sp += p.shift() + p;
- }
- subpaths.end = sp;
- point = istotal ? len : subpath ? subpaths : findDotsAtSegment(x, y, p[0], p[1], p[2], p[3], p[4], p[5], 1);
- return point;
- }, null, Snap._.clone);
- }
- var getTotalLength = getLengthFactory(1),
- getPointAtLength = getLengthFactory(),
- getSubpathsAtLength = getLengthFactory(0, 1);
- function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
- var t1 = 1 - t,
- t13 = pow(t1, 3),
- t12 = pow(t1, 2),
- t2 = t * t,
- t3 = t2 * t,
- x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x,
- y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y,
- mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x),
- my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y),
- nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x),
- ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y),
- ax = t1 * p1x + t * c1x,
- ay = t1 * p1y + t * c1y,
- cx = t1 * c2x + t * p2x,
- cy = t1 * c2y + t * p2y,
- alpha = (90 - math.atan2(mx - nx, my - ny) * 180 / PI);
- // (mx > nx || my < ny) && (alpha += 180);
- return {
- x: x,
- y: y,
- m: {x: mx, y: my},
- n: {x: nx, y: ny},
- start: {x: ax, y: ay},
- end: {x: cx, y: cy},
- alpha: alpha
- };
- }
- function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
- if (!Snap.is(p1x, "array")) {
- p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
- }
- var bbox = curveDim.apply(null, p1x);
- return box(
- bbox.min.x,
- bbox.min.y,
- bbox.max.x - bbox.min.x,
- bbox.max.y - bbox.min.y
- );
- }
- function isPointInsideBBox(bbox, x, y) {
- return x >= bbox.x &&
- x <= bbox.x + bbox.width &&
- y >= bbox.y &&
- y <= bbox.y + bbox.height;
- }
- function isBBoxIntersect(bbox1, bbox2) {
- bbox1 = box(bbox1);
- bbox2 = box(bbox2);
- return isPointInsideBBox(bbox2, bbox1.x, bbox1.y)
- || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y)
- || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2)
- || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2)
- || isPointInsideBBox(bbox1, bbox2.x, bbox2.y)
- || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y)
- || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2)
- || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2)
- || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x
- || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x)
- && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y
- || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
- }
- function base3(t, p1, p2, p3, p4) {
- var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4,
- t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
- return t * t2 - 3 * p1 + 3 * p2;
- }
- function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
- if (z == null) {
- z = 1;
- }
- z = z > 1 ? 1 : z < 0 ? 0 : z;
- var z2 = z / 2,
- n = 12,
- Tvalues = [-.1252,.1252,-.3678,.3678,-.5873,.5873,-.7699,.7699,-.9041,.9041,-.9816,.9816],
- 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],
- sum = 0;
- for (var i = 0; i < n; i++) {
- var ct = z2 * Tvalues[i] + z2,
- xbase = base3(ct, x1, x2, x3, x4),
- ybase = base3(ct, y1, y2, y3, y4),
- comb = xbase * xbase + ybase * ybase;
- sum += Cvalues[i] * math.sqrt(comb);
- }
- return z2 * sum;
- }
- function getTotLen(x1, y1, x2, y2, x3, y3, x4, y4, ll) {
- if (ll < 0 || bezlen(x1, y1, x2, y2, x3, y3, x4, y4) < ll) {
- return;
- }
- var t = 1,
- step = t / 2,
- t2 = t - step,
- l,
- e = .01;
- l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
- while (abs(l - ll) > e) {
- step /= 2;
- t2 += (l < ll ? 1 : -1) * step;
- l = bezlen(x1, y1, x2, y2, x3, y3, x4, y4, t2);
- }
- return t2;
- }
- function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
- if (
- mmax(x1, x2) < mmin(x3, x4) ||
- mmin(x1, x2) > mmax(x3, x4) ||
- mmax(y1, y2) < mmin(y3, y4) ||
- mmin(y1, y2) > mmax(y3, y4)
- ) {
- return;
- }
- var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4),
- ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4),
- denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
- if (!denominator) {
- return;
- }
- var px = nx / denominator,
- py = ny / denominator,
- px2 = +px.toFixed(2),
- py2 = +py.toFixed(2);
- if (
- px2 < +mmin(x1, x2).toFixed(2) ||
- px2 > +mmax(x1, x2).toFixed(2) ||
- px2 < +mmin(x3, x4).toFixed(2) ||
- px2 > +mmax(x3, x4).toFixed(2) ||
- py2 < +mmin(y1, y2).toFixed(2) ||
- py2 > +mmax(y1, y2).toFixed(2) ||
- py2 < +mmin(y3, y4).toFixed(2) ||
- py2 > +mmax(y3, y4).toFixed(2)
- ) {
- return;
- }
- return {x: px, y: py};
- }
- function inter(bez1, bez2) {
- return interHelper(bez1, bez2);
- }
- function interCount(bez1, bez2) {
- return interHelper(bez1, bez2, 1);
- }
- function interHelper(bez1, bez2, justCount) {
- var bbox1 = bezierBBox(bez1),
- bbox2 = bezierBBox(bez2);
- if (!isBBoxIntersect(bbox1, bbox2)) {
- return justCount ? 0 : [];
- }
- var l1 = bezlen.apply(0, bez1),
- l2 = bezlen.apply(0, bez2),
- n1 = ~~(l1 / 8),
- n2 = ~~(l2 / 8),
- dots1 = [],
- dots2 = [],
- xy = {},
- res = justCount ? 0 : [];
- for (var i = 0; i < n1 + 1; i++) {
- var p = findDotsAtSegment.apply(0, bez1.concat(i / n1));
- dots1.push({x: p.x, y: p.y, t: i / n1});
- }
- for (i = 0; i < n2 + 1; i++) {
- p = findDotsAtSegment.apply(0, bez2.concat(i / n2));
- dots2.push({x: p.x, y: p.y, t: i / n2});
- }
- for (i = 0; i < n1; i++) {
- for (var j = 0; j < n2; j++) {
- var di = dots1[i],
- di1 = dots1[i + 1],
- dj = dots2[j],
- dj1 = dots2[j + 1],
- ci = abs(di1.x - di.x) < .001 ? "y" : "x",
- cj = abs(dj1.x - dj.x) < .001 ? "y" : "x",
- is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
- if (is) {
- if (xy[is.x.toFixed(4)] == is.y.toFixed(4)) {
- continue;
- }
- xy[is.x.toFixed(4)] = is.y.toFixed(4);
- var t1 = di.t + abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t),
- t2 = dj.t + abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
- if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
- if (justCount) {
- res++;
- } else {
- res.push({
- x: is.x,
- y: is.y,
- t1: t1,
- t2: t2
- });
- }
- }
- }
- }
- }
- return res;
- }
- function pathIntersection(path1, path2) {
- return interPathHelper(path1, path2);
- }
- function pathIntersectionNumber(path1, path2) {
- return interPathHelper(path1, path2, 1);
- }
- function interPathHelper(path1, path2, justCount) {
- path1 = path2curve(path1);
- path2 = path2curve(path2);
- var x1, y1, x2, y2, x1m, y1m, x2m, y2m, bez1, bez2,
- res = justCount ? 0 : [];
- for (var i = 0, ii = path1.length; i < ii; i++) {
- var pi = path1[i];
- if (pi[0] == "M") {
- x1 = x1m = pi[1];
- y1 = y1m = pi[2];
- } else {
- if (pi[0] == "C") {
- bez1 = [x1, y1].concat(pi.slice(1));
- x1 = bez1[6];
- y1 = bez1[7];
- } else {
- bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
- x1 = x1m;
- y1 = y1m;
- }
- for (var j = 0, jj = path2.length; j < jj; j++) {
- var pj = path2[j];
- if (pj[0] == "M") {
- x2 = x2m = pj[1];
- y2 = y2m = pj[2];
- } else {
- if (pj[0] == "C") {
- bez2 = [x2, y2].concat(pj.slice(1));
- x2 = bez2[6];
- y2 = bez2[7];
- } else {
- bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
- x2 = x2m;
- y2 = y2m;
- }
- var intr = interHelper(bez1, bez2, justCount);
- if (justCount) {
- res += intr;
- } else {
- for (var k = 0, kk = intr.length; k < kk; k++) {
- intr[k].segment1 = i;
- intr[k].segment2 = j;
- intr[k].bez1 = bez1;
- intr[k].bez2 = bez2;
- }
- res = res.concat(intr);
- }
- }
- }
- }
- }
- return res;
- }
- function isPointInsidePath(path, x, y) {
- var bbox = pathBBox(path);
- return isPointInsideBBox(bbox, x, y) &&
- interPathHelper(path, [["M", x, y], ["H", bbox.x2 + 10]], 1) % 2 == 1;
- }
- function pathBBox(path) {
- var pth = paths(path);
- if (pth.bbox) {
- return clone(pth.bbox);
- }
- if (!path) {
- return box();
- }
- path = path2curve(path);
- var x = 0,
- y = 0,
- X = [],
- Y = [],
- p;
- for (var i = 0, ii = path.length; i < ii; i++) {
- p = path[i];
- if (p[0] == "M") {
- x = p[1];
- y = p[2];
- X.push(x);
- Y.push(y);
- } else {
- var dim = curveDim(x, y, p[1], p[2], p[3], p[4], p[5], p[6]);
- X = X.concat(dim.min.x, dim.max.x);
- Y = Y.concat(dim.min.y, dim.max.y);
- x = p[5];
- y = p[6];
- }
- }
- var xmin = mmin.apply(0, X),
- ymin = mmin.apply(0, Y),
- xmax = mmax.apply(0, X),
- ymax = mmax.apply(0, Y),
- bb = box(xmin, ymin, xmax - xmin, ymax - ymin);
- pth.bbox = clone(bb);
- return bb;
- }
- function rectPath(x, y, w, h, r) {
- if (r) {
- return [
- ["M", +x + (+r), y],
- ["l", w - r * 2, 0],
- ["a", r, r, 0, 0, 1, r, r],
- ["l", 0, h - r * 2],
- ["a", r, r, 0, 0, 1, -r, r],
- ["l", r * 2 - w, 0],
- ["a", r, r, 0, 0, 1, -r, -r],
- ["l", 0, r * 2 - h],
- ["a", r, r, 0, 0, 1, r, -r],
- ["z"]
- ];
- }
- var res = [["M", x, y], ["l", w, 0], ["l", 0, h], ["l", -w, 0], ["z"]];
- res.toString = toString;
- return res;
- }
- function ellipsePath(x, y, rx, ry, a) {
- if (a == null && ry == null) {
- ry = rx;
- }
- x = +x;
- y = +y;
- rx = +rx;
- ry = +ry;
- if (a != null) {
- var rad = Math.PI / 180,
- x1 = x + rx * Math.cos(-ry * rad),
- x2 = x + rx * Math.cos(-a * rad),
- y1 = y + rx * Math.sin(-ry * rad),
- y2 = y + rx * Math.sin(-a * rad),
- res = [["M", x1, y1], ["A", rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
- } else {
- res = [
- ["M", x, y],
- ["m", 0, -ry],
- ["a", rx, ry, 0, 1, 1, 0, 2 * ry],
- ["a", rx, ry, 0, 1, 1, 0, -2 * ry],
- ["z"]
- ];
- }
- res.toString = toString;
- return res;
- }
- var unit2px = Snap._unit2px,
- getPath = {
- path: function (el) {
- return el.attr("path");
- },
- circle: function (el) {
- var attr = unit2px(el);
- return ellipsePath(attr.cx, attr.cy, attr.r);
- },
- ellipse: function (el) {
- var attr = unit2px(el);
- return ellipsePath(attr.cx || 0, attr.cy || 0, attr.rx, attr.ry);
- },
- rect: function (el) {
- var attr = unit2px(el);
- return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height, attr.rx, attr.ry);
- },
- image: function (el) {
- var attr = unit2px(el);
- return rectPath(attr.x || 0, attr.y || 0, attr.width, attr.height);
- },
- line: function (el) {
- return "M" + [el.attr("x1") || 0, el.attr("y1") || 0, el.attr("x2"), el.attr("y2")];
- },
- polyline: function (el) {
- return "M" + el.attr("points");
- },
- polygon: function (el) {
- return "M" + el.attr("points") + "z";
- },
- deflt: function (el) {
- var bbox = el.node.getBBox();
- return rectPath(bbox.x, bbox.y, bbox.width, bbox.height);
- }
- };
- function pathToRelative(pathArray) {
- var pth = paths(pathArray),
- lowerCase = String.prototype.toLowerCase;
- if (pth.rel) {
- return pathClone(pth.rel);
- }
- if (!Snap.is(pathArray, "array") || !Snap.is(pathArray && pathArray[0], "array")) {
- pathArray = Snap.parsePathString(pathArray);
- }
- var res = [],
- x = 0,
- y = 0,
- mx = 0,
- my = 0,
- start = 0;
- if (pathArray[0][0] == "M") {
- x = pathArray[0][1];
- y = pathArray[0][2];
- mx = x;
- my = y;
- start++;
- res.push(["M", x, y]);
- }
- for (var i = start, ii = pathArray.length; i < ii; i++) {
- var r = res[i] = [],
- pa = pathArray[i];
- if (pa[0] != lowerCase.call(pa[0])) {
- r[0] = lowerCase.call(pa[0]);
- switch (r[0]) {
- case "a":
- r[1] = pa[1];
- r[2] = pa[2];
- r[3] = pa[3];
- r[4] = pa[4];
- r[5] = pa[5];
- r[6] = +(pa[6] - x).toFixed(3);
- r[7] = +(pa[7] - y).toFixed(3);
- break;
- case "v":
- r[1] = +(pa[1] - y).toFixed(3);
- break;
- case "m":
- mx = pa[1];
- my = pa[2];
- default:
- for (var j = 1, jj = pa.length; j < jj; j++) {
- r[j] = +(pa[j] - ((j % 2) ? x : y)).toFixed(3);
- }
- }
- } else {
- r = res[i] = [];
- if (pa[0] == "m") {
- mx = pa[1] + x;
- my = pa[2] + y;
- }
- for (var k = 0, kk = pa.length; k < kk; k++) {
- res[i][k] = pa[k];
- }
- }
- var len = res[i].length;
- switch (res[i][0]) {
- case "z":
- x = mx;
- y = my;
- break;
- case "h":
- x += +res[i][len - 1];
- break;
- case "v":
- y += +res[i][len - 1];
- break;
- default:
- x += +res[i][len - 2];
- y += +res[i][len - 1];
- }
- }
- res.toString = toString;
- pth.rel = pathClone(res);
- return res;
- }
- function pathToAbsolute(pathArray) {
- var pth = paths(pathArray);
- if (pth.abs) {
- return pathClone(pth.abs);
- }
- if (!is(pathArray, "array") || !is(pathArray && pathArray[0], "array")) { // rough assumption
- pathArray = Snap.parsePathString(pathArray);
- }
- if (!pathArray || !pathArray.length) {
- return [["M", 0, 0]];
- }
- var res = [],
- x = 0,
- y = 0,
- mx = 0,
- my = 0,
- start = 0,
- pa0;
- if (pathArray[0][0] == "M") {
- x = +pathArray[0][1];
- y = +pathArray[0][2];
- mx = x;
- my = y;
- start++;
- res[0] = ["M", x, y];
- }
- var crz = pathArray.length == 3 &&
- pathArray[0][0] == "M" &&
- pathArray[1][0].toUpperCase() == "R" &&
- pathArray[2][0].toUpperCase() == "Z";
- for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
- res.push(r = []);
- pa = pathArray[i];
- pa0 = pa[0];
- if (pa0 != pa0.toUpperCase()) {
- r[0] = pa0.toUpperCase();
- switch (r[0]) {
- case "A":
- r[1] = pa[1];
- r[2] = pa[2];
- r[3] = pa[3];
- r[4] = pa[4];
- r[5] = pa[5];
- r[6] = +pa[6] + x;
- r[7] = +pa[7] + y;
- break;
- case "V":
- r[1] = +pa[1] + y;
- break;
- case "H":
- r[1] = +pa[1] + x;
- break;
- case "R":
- var dots = [x, y].concat(pa.slice(1));
- for (var j = 2, jj = dots.length; j < jj; j++) {
- dots[j] = +dots[j] + x;
- dots[++j] = +dots[j] + y;
- }
- res.pop();
- res = res.concat(catmullRom2bezier(dots, crz));
- break;
- case "O":
- res.pop();
- dots = ellipsePath(x, y, pa[1], pa[2]);
- dots.push(dots[0]);
- res = res.concat(dots);
- break;
- case "U":
- res.pop();
- res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
- r = ["U"].concat(res[res.length - 1].slice(-2));
- break;
- case "M":
- mx = +pa[1] + x;
- my = +pa[2] + y;
- default:
- for (j = 1, jj = pa.length; j < jj; j++) {
- r[j] = +pa[j] + ((j % 2) ? x : y);
- }
- }
- } else if (pa0 == "R") {
- dots = [x, y].concat(pa.slice(1));
- res.pop();
- res = res.concat(catmullRom2bezier(dots, crz));
- r = ["R"].concat(pa.slice(-2));
- } else if (pa0 == "O") {
- res.pop();
- dots = ellipsePath(x, y, pa[1], pa[2]);
- dots.push(dots[0]);
- res = res.concat(dots);
- } else if (pa0 == "U") {
- res.pop();
- res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
- r = ["U"].concat(res[res.length - 1].slice(-2));
- } else {
- for (var k = 0, kk = pa.length; k < kk; k++) {
- r[k] = pa[k];
- }
- }
- pa0 = pa0.toUpperCase();
- if (pa0 != "O") {
- switch (r[0]) {
- case "Z":
- x = +mx;
- y = +my;
- break;
- case "H":
- x = r[1];
- break;
- case "V":
- y = r[1];
- break;
- case "M":
- mx = r[r.length - 2];
- my = r[r.length - 1];
- default:
- x = r[r.length - 2];
- y = r[r.length - 1];
- }
- }
- }
- res.toString = toString;
- pth.abs = pathClone(res);
- return res;
- }
- function l2c(x1, y1, x2, y2) {
- return [x1, y1, x2, y2, x2, y2];
- }
- function q2c(x1, y1, ax, ay, x2, y2) {
- var _13 = 1 / 3,
- _23 = 2 / 3;
- return [
- _13 * x1 + _23 * ax,
- _13 * y1 + _23 * ay,
- _13 * x2 + _23 * ax,
- _13 * y2 + _23 * ay,
- x2,
- y2
- ];
- }
- function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
- // for more information of where this math came from visit:
- // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
- var _120 = PI * 120 / 180,
- rad = PI / 180 * (+angle || 0),
- res = [],
- xy,
- rotate = Snap._.cacher(function (x, y, rad) {
- var X = x * math.cos(rad) - y * math.sin(rad),
- Y = x * math.sin(rad) + y * math.cos(rad);
- return {x: X, y: Y};
- });
- if (!recursive) {
- xy = rotate(x1, y1, -rad);
- x1 = xy.x;
- y1 = xy.y;
- xy = rotate(x2, y2, -rad);
- x2 = xy.x;
- y2 = xy.y;
- var cos = math.cos(PI / 180 * angle),
- sin = math.sin(PI / 180 * angle),
- x = (x1 - x2) / 2,
- y = (y1 - y2) / 2;
- var h = (x * x) / (rx * rx) + (y * y) / (ry * ry);
- if (h > 1) {
- h = math.sqrt(h);
- rx = h * rx;
- ry = h * ry;
- }
- var rx2 = rx * rx,
- ry2 = ry * ry,
- k = (large_arc_flag == sweep_flag ? -1 : 1) *
- math.sqrt(abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x))),
- cx = k * rx * y / ry + (x1 + x2) / 2,
- cy = k * -ry * x / rx + (y1 + y2) / 2,
- f1 = math.asin(((y1 - cy) / ry).toFixed(9)),
- f2 = math.asin(((y2 - cy) / ry).toFixed(9));
- f1 = x1 < cx ? PI - f1 : f1;
- f2 = x2 < cx ? PI - f2 : f2;
- f1 < 0 && (f1 = PI * 2 + f1);
- f2 < 0 && (f2 = PI * 2 + f2);
- if (sweep_flag && f1 > f2) {
- f1 = f1 - PI * 2;
- }
- if (!sweep_flag && f2 > f1) {
- f2 = f2 - PI * 2;
- }
- } else {
- f1 = recursive[0];
- f2 = recursive[1];
- cx = recursive[2];
- cy = recursive[3];
- }
- var df = f2 - f1;
- if (abs(df) > _120) {
- var f2old = f2,
- x2old = x2,
- y2old = y2;
- f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
- x2 = cx + rx * math.cos(f2);
- y2 = cy + ry * math.sin(f2);
- res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
- }
- df = f2 - f1;
- var c1 = math.cos(f1),
- s1 = math.sin(f1),
- c2 = math.cos(f2),
- s2 = math.sin(f2),
- t = math.tan(df / 4),
- hx = 4 / 3 * rx * t,
- hy = 4 / 3 * ry * t,
- m1 = [x1, y1],
- m2 = [x1 + hx * s1, y1 - hy * c1],
- m3 = [x2 + hx * s2, y2 - hy * c2],
- m4 = [x2, y2];
- m2[0] = 2 * m1[0] - m2[0];
- m2[1] = 2 * m1[1] - m2[1];
- if (recursive) {
- return [m2, m3, m4].concat(res);
- } else {
- res = [m2, m3, m4].concat(res).join().split(",");
- var newres = [];
- for (var i = 0, ii = res.length; i < ii; i++) {
- newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
- }
- return newres;
- }
- }
- function findDotAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
- var t1 = 1 - t;
- return {
- x: pow(t1, 3) * p1x + pow(t1, 2) * 3 * t * c1x + t1 * 3 * t * t * c2x + pow(t, 3) * p2x,
- y: pow(t1, 3) * p1y + pow(t1, 2) * 3 * t * c1y + t1 * 3 * t * t * c2y + pow(t, 3) * p2y
- };
- }
-
- // Returns bounding box of cubic bezier curve.
- // Source: http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
- // Original version: NISHIO Hirokazu
- // Modifications: https://github.com/timo22345
- function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
- var tvalues = [],
- bounds = [[], []],
- a, b, c, t, t1, t2, b2ac, sqrtb2ac;
- for (var i = 0; i < 2; ++i) {
- if (i == 0) {
- b = 6 * x0 - 12 * x1 + 6 * x2;
- a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
- c = 3 * x1 - 3 * x0;
- } else {
- b = 6 * y0 - 12 * y1 + 6 * y2;
- a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
- c = 3 * y1 - 3 * y0;
- }
- if (abs(a) < 1e-12) {
- if (abs(b) < 1e-12) {
- continue;
- }
- t = -c / b;
- if (0 < t && t < 1) {
- tvalues.push(t);
- }
- continue;
- }
- b2ac = b * b - 4 * c * a;
- sqrtb2ac = math.sqrt(b2ac);
- if (b2ac < 0) {
- continue;
- }
- t1 = (-b + sqrtb2ac) / (2 * a);
- if (0 < t1 && t1 < 1) {
- tvalues.push(t1);
- }
- t2 = (-b - sqrtb2ac) / (2 * a);
- if (0 < t2 && t2 < 1) {
- tvalues.push(t2);
- }
- }
- var x, y, j = tvalues.length,
- jlen = j,
- mt;
- while (j--) {
- t = tvalues[j];
- mt = 1 - t;
- bounds[0][j] = (mt * mt * mt * x0) + (3 * mt * mt * t * x1) + (3 * mt * t * t * x2) + (t * t * t * x3);
- bounds[1][j] = (mt * mt * mt * y0) + (3 * mt * mt * t * y1) + (3 * mt * t * t * y2) + (t * t * t * y3);
- }
- bounds[0][jlen] = x0;
- bounds[1][jlen] = y0;
- bounds[0][jlen + 1] = x3;
- bounds[1][jlen + 1] = y3;
- bounds[0].length = bounds[1].length = jlen + 2;
- return {
- min: {x: mmin.apply(0, bounds[0]), y: mmin.apply(0, bounds[1])},
- max: {x: mmax.apply(0, bounds[0]), y: mmax.apply(0, bounds[1])}
- };
- }
- function path2curve(path, path2) {
- var pth = !path2 && paths(path);
- if (!path2 && pth.curve) {
- return pathClone(pth.curve);
- }
- var p = pathToAbsolute(path),
- p2 = path2 && pathToAbsolute(path2),
- attrs = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
- attrs2 = {x: 0, y: 0, bx: 0, by: 0, X: 0, Y: 0, qx: null, qy: null},
- processPath = function (path, d, pcom) {
- var nx, ny;
- if (!path) {
- return ["C", d.x, d.y, d.x, d.y, d.x, d.y];
- }
- !(path[0] in {T: 1, Q: 1}) && (d.qx = d.qy = null);
- switch (path[0]) {
- case "M":
- d.X = path[1];
- d.Y = path[2];
- break;
- case "A":
- path = ["C"].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
- break;
- case "S":
- if (pcom == "C" || pcom == "S") { // In "S" case we have to take into account, if the previous command is C/S.
- nx = d.x * 2 - d.bx; // And reflect the previous
- ny = d.y * 2 - d.by; // command's control point relative to the current point.
- }
- else { // or some else or nothing
- nx = d.x;
- ny = d.y;
- }
- path = ["C", nx, ny].concat(path.slice(1));
- break;
- case "T":
- if (pcom == "Q" || pcom == "T") { // In "T" case we have to take into account, if the previous command is Q/T.
- d.qx = d.x * 2 - d.qx; // And make a reflection similar
- d.qy = d.y * 2 - d.qy; // to case "S".
- }
- else { // or something else or nothing
- d.qx = d.x;
- d.qy = d.y;
- }
- path = ["C"].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
- break;
- case "Q":
- d.qx = path[1];
- d.qy = path[2];
- path = ["C"].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
- break;
- case "L":
- path = ["C"].concat(l2c(d.x, d.y, path[1], path[2]));
- break;
- case "H":
- path = ["C"].concat(l2c(d.x, d.y, path[1], d.y));
- break;
- case "V":
- path = ["C"].concat(l2c(d.x, d.y, d.x, path[1]));
- break;
- case "Z":
- path = ["C"].concat(l2c(d.x, d.y, d.X, d.Y));
- break;
- }
- return path;
- },
- fixArc = function (pp, i) {
- if (pp[i].length > 7) {
- pp[i].shift();
- var pi = pp[i];
- while (pi.length) {
- pcoms1[i] = "A"; // if created multiple C:s, their original seg is saved
- p2 && (pcoms2[i] = "A"); // the same as above
- pp.splice(i++, 0, ["C"].concat(pi.splice(0, 6)));
- }
- pp.splice(i, 1);
- ii = mmax(p.length, p2 && p2.length || 0);
- }
- },
- fixM = function (path1, path2, a1, a2, i) {
- if (path1 && path2 && path1[i][0] == "M" && path2[i][0] != "M") {
- path2.splice(i, 0, ["M", a2.x, a2.y]);
- a1.bx = 0;
- a1.by = 0;
- a1.x = path1[i][1];
- a1.y = path1[i][2];
- ii = mmax(p.length, p2 && p2.length || 0);
- }
- },
- pcoms1 = [], // path commands of original path p
- pcoms2 = [], // path commands of original path p2
- pfirst = "", // temporary holder for original path command
- pcom = ""; // holder for previous path command of original path
- for (var i = 0, ii = mmax(p.length, p2 && p2.length || 0); i < ii; i++) {
- p[i] && (pfirst = p[i][0]); // save current path command
- if (pfirst != "C") // C is not saved yet, because it may be result of conversion
- {
- pcoms1[i] = pfirst; // Save current path command
- i && ( pcom = pcoms1[i - 1]); // Get previous path command pcom
- }
- p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
- if (pcoms1[i] != "A" && pfirst == "C") pcoms1[i] = "C"; // A is the only command
- // which may produce multiple C:s
- // so we have to make sure that C is also C in original path
- fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
- if (p2) { // the same procedures is done to p2
- p2[i] && (pfirst = p2[i][0]);
- if (pfirst != "C") {
- pcoms2[i] = pfirst;
- i && (pcom = pcoms2[i - 1]);
- }
- p2[i] = processPath(p2[i], attrs2, pcom);
- if (pcoms2[i] != "A" && pfirst == "C") {
- pcoms2[i] = "C";
- }
- fixArc(p2, i);
- }
- fixM(p, p2, attrs, attrs2, i);
- fixM(p2, p, attrs2, attrs, i);
- var seg = p[i],
- seg2 = p2 && p2[i],
- seglen = seg.length,
- seg2len = p2 && seg2.length;
- attrs.x = seg[seglen - 2];
- attrs.y = seg[seglen - 1];
- attrs.bx = toFloat(seg[seglen - 4]) || attrs.x;
- attrs.by = toFloat(seg[seglen - 3]) || attrs.y;
- attrs2.bx = p2 && (toFloat(seg2[seg2len - 4]) || attrs2.x);
- attrs2.by = p2 && (toFloat(seg2[seg2len - 3]) || attrs2.y);
- attrs2.x = p2 && seg2[seg2len - 2];
- attrs2.y = p2 && seg2[seg2len - 1];
- }
- if (!p2) {
- pth.curve = pathClone(p);
- }
- return p2 ? [p, p2] : p;
- }
- function mapPath(path, matrix) {
- if (!matrix) {
- return path;
- }
- var x, y, i, j, ii, jj, pathi;
- path = path2curve(path);
- for (i = 0, ii = path.length; i < ii; i++) {
- pathi = path[i];
- for (j = 1, jj = pathi.length; j < jj; j += 2) {
- x = matrix.x(pathi[j], pathi[j + 1]);
- y = matrix.y(pathi[j], pathi[j + 1]);
- pathi[j] = x;
- pathi[j + 1] = y;
- }
- }
- return path;
- }
- // http://schepers.cc/getting-to-the-point
- function catmullRom2bezier(crp, z) {
- var d = [];
- for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
- var p = [
- {x: +crp[i - 2], y: +crp[i - 1]},
- {x: +crp[i], y: +crp[i + 1]},
- {x: +crp[i + 2], y: +crp[i + 3]},
- {x: +crp[i + 4], y: +crp[i + 5]}
- ];
- if (z) {
- if (!i) {
- p[0] = {x: +crp[iLen - 2], y: +crp[iLen - 1]};
- } else if (iLen - 4 == i) {
- p[3] = {x: +crp[0], y: +crp[1]};
- } else if (iLen - 2 == i) {
- p[2] = {x: +crp[0], y: +crp[1]};
- p[3] = {x: +crp[2], y: +crp[3]};
- }
- } else {
- if (iLen - 4 == i) {
- p[3] = p[2];
- } else if (!i) {
- p[0] = {x: +crp[i], y: +crp[i + 1]};
- }
- }
- d.push(["C",
- (-p[0].x + 6 * p[1].x + p[2].x) / 6,
- (-p[0].y + 6 * p[1].y + p[2].y) / 6,
- (p[1].x + 6 * p[2].x - p[3].x) / 6,
- (p[1].y + 6*p[2].y - p[3].y) / 6,
- p[2].x,
- p[2].y
- ]);
- }
- return d;
- }
- // export
- Snap.path = paths;
- /*\
- * Snap.path.getTotalLength
- [ method ]
- **
- * Returns the length of the given path in pixels
- **
- - path (string) SVG path string
- **
- = (number) length
- \*/
- Snap.path.getTotalLength = getTotalLength;
- /*\
- * Snap.path.getPointAtLength
- [ method ]
- **
- * Returns the coordinates of the point located at the given length along the given path
- **
- - path (string) SVG path string
- - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
- **
- = (object) representation of the point:
- o {
- o x: (number) x coordinate,
- o y: (number) y coordinate,
- o alpha: (number) angle of derivative
- o }
- \*/
- Snap.path.getPointAtLength = getPointAtLength;
- /*\
- * Snap.path.getSubpath
- [ method ]
- **
- * Returns the subpath of a given path between given start and end lengths
- **
- - path (string) SVG path string
- - from (number) length, in pixels, from the start of the path to the start of the segment
- - to (number) length, in pixels, from the start of the path to the end of the segment
- **
- = (string) path string definition for the segment
- \*/
- Snap.path.getSubpath = function (path, from, to) {
- if (this.getTotalLength(path) - to < 1e-6) {
- return getSubpathsAtLength(path, from).end;
- }
- var a = getSubpathsAtLength(path, to, 1);
- return from ? getSubpathsAtLength(a, from).end : a;
- };
- /*\
- * Element.getTotalLength
- [ method ]
- **
- * Returns the length of the path in pixels (only works for `path` elements)
- = (number) length
- \*/
- elproto.getTotalLength = function () {
- if (this.node.getTotalLength) {
- return this.node.getTotalLength();
- }
- };
- // 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?
- /*\
- * Element.getPointAtLength
- [ method ]
- **
- * Returns coordinates of the point located at the given length on the given path (only works for `path` elements)
- **
- - length (number) length, in pixels, from the start of the path, excluding non-rendering jumps
- **
- = (object) representation of the point:
- o {
- o x: (number) x coordinate,
- o y: (number) y coordinate,
- o alpha: (number) angle of derivative
- o }
- \*/
- elproto.getPointAtLength = function (length) {
- return getPointAtLength(this.attr("d"), length);
- };
- // 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.
- /*\
- * Element.getSubpath
- [ method ]
- **
- * Returns subpath of a given element from given start and end lengths (only works for `path` elements)
- **
- - from (number) length, in pixels, from the start of the path to the start of the segment
- - to (number) length, in pixels, from the start of the path to the end of the segment
- **
- = (string) path string definition for the segment
- \*/
- elproto.getSubpath = function (from, to) {
- return Snap.path.getSubpath(this.attr("d"), from, to);
- };
- Snap._.box = box;
- /*\
- * Snap.path.findDotsAtSegment
- [ method ]
- **
- * Utility method
- **
- * Finds dot coordinates on the given cubic beziér curve at the given t
- - p1x (number) x of the first point of the curve
- - p1y (number) y of the first point of the curve
- - c1x (number) x of the first anchor of the curve
- - c1y (number) y of the first anchor of the curve
- - c2x (number) x of the second anchor of the curve
- - c2y (number) y of the second anchor of the curve
- - p2x (number) x of the second point of the curve
- - p2y (number) y of the second point of the curve
- - t (number) position on the curve (0..1)
- = (object) point information in format:
- o {
- o x: (number) x coordinate of the point,
- o y: (number) y coordinate of the point,
- o m: {
- o x: (number) x coordinate of the left anchor,
- o y: (number) y coordinate of the left anchor
- o },
- o n: {
- o x: (number) x coordinate of the right anchor,
- o y: (number) y coordinate of the right anchor
- o },
- o start: {
- o x: (number) x coordinate of the start of the curve,
- o y: (number) y coordinate of the start of the curve
- o },
- o end: {
- o x: (number) x coordinate of the end of the curve,
- o y: (number) y coordinate of the end of the curve
- o },
- o alpha: (number) angle of the curve derivative at the point
- o }
- \*/
- Snap.path.findDotsAtSegment = findDotsAtSegment;
- /*\
- * Snap.path.bezierBBox
- [ method ]
- **
- * Utility method
- **
- * Returns the bounding box of a given cubic beziér curve
- - p1x (number) x of the first point of the curve
- - p1y (number) y of the first point of the curve
- - c1x (number) x of the first anchor of the curve
- - c1y (number) y of the first anchor of the curve
- - c2x (number) x of the second anchor of the curve
- - c2y (number) y of the second anchor of the curve
- - p2x (number) x of the second point of the curve
- - p2y (number) y of the second point of the curve
- * or
- - bez (array) array of six points for beziér curve
- = (object) bounding box
- o {
- o x: (number) x coordinate of the left top point of the box,
- o y: (number) y coordinate of the left top point of the box,
- o x2: (number) x coordinate of the right bottom point of the box,
- o y2: (number) y coordinate of the right bottom point of the box,
- o width: (number) width of the box,
- o height: (number) height of the box
- o }
- \*/
- Snap.path.bezierBBox = bezierBBox;
- /*\
- * Snap.path.isPointInsideBBox
- [ method ]
- **
- * Utility method
- **
- * Returns `true` if given point is inside bounding box
- - bbox (string) bounding box
- - x (string) x coordinate of the point
- - y (string) y coordinate of the point
- = (boolean) `true` if point is inside
- \*/
- Snap.path.isPointInsideBBox = isPointInsideBBox;
- /*\
- * Snap.path.isBBoxIntersect
- [ method ]
- **
- * Utility method
- **
- * Returns `true` if two bounding boxes intersect
- - bbox1 (string) first bounding box
- - bbox2 (string) second bounding box
- = (boolean) `true` if bounding boxes intersect
- \*/
- Snap.path.isBBoxIntersect = isBBoxIntersect;
- /*\
- * Snap.path.intersection
- [ method ]
- **
- * Utility method
- **
- * Finds intersections of two paths
- - path1 (string) path string
- - path2 (string) path string
- = (array) dots of intersection
- o [
- o {
- o x: (number) x coordinate of the point,
- o y: (number) y coordinate of the point,
- o t1: (number) t value for segment of path1,
- o t2: (number) t value for segment of path2,
- o segment1: (number) order number for segment of path1,
- o segment2: (number) order number for segment of path2,
- o bez1: (array) eight coordinates representing beziér curve for the segment of path1,
- o bez2: (array) eight coordinates representing beziér curve for the segment of path2
- o }
- o ]
- \*/
- Snap.path.intersection = pathIntersection;
- Snap.path.intersectionNumber = pathIntersectionNumber;
- /*\
- * Snap.path.isPointInside
- [ method ]
- **
- * Utility method
- **
- * Returns `true` if given point is inside a given closed path.
- *
- * Note: fill mode doesn’t affect the result of this method.
- - path (string) path string
- - x (number) x of the point
- - y (number) y of the point
- = (boolean) `true` if point is inside the path
- \*/
- Snap.path.isPointInside = isPointInsidePath;
- /*\
- * Snap.path.getBBox
- [ method ]
- **
- * Utility method
- **
- * Returns the bounding box of a given path
- - path (string) path string
- = (object) bounding box
- o {
- o x: (number) x coordinate of the left top point of the box,
- o y: (number) y coordinate of the left top point of the box,
- o x2: (number) x coordinate of the right bottom point of the box,
- o y2: (number) y coordinate of the right bottom point of the box,
- o width: (number) width of the box,
- o height: (number) height of the box
- o }
- \*/
- Snap.path.getBBox = pathBBox;
- Snap.path.get = getPath;
- /*\
- * Snap.path.toRelative
- [ method ]
- **
- * Utility method
- **
- * Converts path coordinates into relative values
- - path (string) path string
- = (array) path string
- \*/
- Snap.path.toRelative = pathToRelative;
- /*\
- * Snap.path.toAbsolute
- [ method ]
- **
- * Utility method
- **
- * Converts path coordinates into absolute values
- - path (string) path string
- = (array) path string
- \*/
- Snap.path.toAbsolute = pathToAbsolute;
- /*\
- * Snap.path.toCubic
- [ method ]
- **
- * Utility method
- **
- * Converts path to a new path where all segments are cubic beziér curves
- - pathString (string|array) path string or array of segments
- = (array) array of segments
- \*/
- Snap.path.toCubic = path2curve;
- /*\
- * Snap.path.map
- [ method ]
- **
- * Transform the path string with the given matrix
- - path (string) path string
- - matrix (object) see @Matrix
- = (string) transformed path string
- \*/
- Snap.path.map = mapPath;
- Snap.path.toString = toString;
- Snap.path.clone = pathClone;
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob) {
- var elproto = Element.prototype,
- has = "hasOwnProperty",
- supportsTouch = "createTouch" in glob.doc,
- events = [
- "click", "dblclick", "mousedown", "mousemove", "mouseout",
- "mouseover", "mouseup", "touchstart", "touchmove", "touchend",
- "touchcancel"
- ],
- touchMap = {
- mousedown: "touchstart",
- mousemove: "touchmove",
- mouseup: "touchend"
- },
- getScroll = function (xy, el) {
- var name = xy == "y" ? "scrollTop" : "scrollLeft",
- doc = el && el.node ? el.node.ownerDocument : glob.doc;
- return doc[name in doc.documentElement ? "documentElement" : "body"][name];
- },
- preventDefault = function () {
- this.returnValue = false;
- },
- preventTouch = function () {
- return this.originalEvent.preventDefault();
- },
- stopPropagation = function () {
- this.cancelBubble = true;
- },
- stopTouch = function () {
- return this.originalEvent.stopPropagation();
- },
- addEvent = (function () {
- if (glob.doc.addEventListener) {
- return function (obj, type, fn, element) {
- var realName = supportsTouch && touchMap[type] ? touchMap[type] : type,
- f = function (e) {
- var scrollY = getScroll("y", element),
- scrollX = getScroll("x", element);
- if (supportsTouch && touchMap[has](type)) {
- for (var i = 0, ii = e.targetTouches && e.targetTouches.length; i < ii; i++) {
- if (e.targetTouches[i].target == obj || obj.contains(e.targetTouches[i].target)) {
- var olde = e;
- e = e.targetTouches[i];
- e.originalEvent = olde;
- e.preventDefault = preventTouch;
- e.stopPropagation = stopTouch;
- break;
- }
- }
- }
- var x = e.clientX + scrollX,
- y = e.clientY + scrollY;
- return fn.call(element, e, x, y);
- };
- if (type !== realName) {
- obj.addEventListener(type, f, false);
- }
- obj.addEventListener(realName, f, false);
- return function () {
- if (type !== realName) {
- obj.removeEventListener(type, f, false);
- }
- obj.removeEventListener(realName, f, false);
- return true;
- };
- };
- } else if (glob.doc.attachEvent) {
- return function (obj, type, fn, element) {
- var f = function (e) {
- e = e || element.node.ownerDocument.window.event;
- var scrollY = getScroll("y", element),
- scrollX = getScroll("x", element),
- x = e.clientX + scrollX,
- y = e.clientY + scrollY;
- e.preventDefault = e.preventDefault || preventDefault;
- e.stopPropagation = e.stopPropagation || stopPropagation;
- return fn.call(element, e, x, y);
- };
- obj.attachEvent("on" + type, f);
- var detacher = function () {
- obj.detachEvent("on" + type, f);
- return true;
- };
- return detacher;
- };
- }
- })(),
- drag = [],
- dragMove = function (e) {
- var x = e.clientX,
- y = e.clientY,
- scrollY = getScroll("y"),
- scrollX = getScroll("x"),
- dragi,
- j = drag.length;
- while (j--) {
- dragi = drag[j];
- if (supportsTouch) {
- var i = e.touches && e.touches.length,
- touch;
- while (i--) {
- touch = e.touches[i];
- if (touch.identifier == dragi.el._drag.id || dragi.el.node.contains(touch.target)) {
- x = touch.clientX;
- y = touch.clientY;
- (e.originalEvent ? e.originalEvent : e).preventDefault();
- break;
- }
- }
- } else {
- e.preventDefault();
- }
- var node = dragi.el.node,
- o,
- next = node.nextSibling,
- parent = node.parentNode,
- display = node.style.display;
- // glob.win.opera && parent.removeChild(node);
- // node.style.display = "none";
- // o = dragi.el.paper.getElementByPoint(x, y);
- // node.style.display = display;
- // glob.win.opera && (next ? parent.insertBefore(node, next) : parent.appendChild(node));
- // o && eve("snap.drag.over." + dragi.el.id, dragi.el, o);
- x += scrollX;
- y += scrollY;
- 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);
- }
- },
- dragUp = function (e) {
- Snap.unmousemove(dragMove).unmouseup(dragUp);
- var i = drag.length,
- dragi;
- while (i--) {
- dragi = drag[i];
- dragi.el._drag = {};
- eve("snap.drag.end." + dragi.el.id, dragi.end_scope || dragi.start_scope || dragi.move_scope || dragi.el, e);
- }
- drag = [];
- };
- /*\
- * Element.click
- [ method ]
- **
- * Adds a click event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unclick
- [ method ]
- **
- * Removes a click event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.dblclick
- [ method ]
- **
- * Adds a double click event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.undblclick
- [ method ]
- **
- * Removes a double click event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.mousedown
- [ method ]
- **
- * Adds a mousedown event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unmousedown
- [ method ]
- **
- * Removes a mousedown event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.mousemove
- [ method ]
- **
- * Adds a mousemove event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unmousemove
- [ method ]
- **
- * Removes a mousemove event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.mouseout
- [ method ]
- **
- * Adds a mouseout event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unmouseout
- [ method ]
- **
- * Removes a mouseout event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.mouseover
- [ method ]
- **
- * Adds a mouseover event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unmouseover
- [ method ]
- **
- * Removes a mouseover event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.mouseup
- [ method ]
- **
- * Adds a mouseup event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.unmouseup
- [ method ]
- **
- * Removes a mouseup event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.touchstart
- [ method ]
- **
- * Adds a touchstart event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.untouchstart
- [ method ]
- **
- * Removes a touchstart event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.touchmove
- [ method ]
- **
- * Adds a touchmove event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.untouchmove
- [ method ]
- **
- * Removes a touchmove event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.touchend
- [ method ]
- **
- * Adds a touchend event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.untouchend
- [ method ]
- **
- * Removes a touchend event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
-
- /*\
- * Element.touchcancel
- [ method ]
- **
- * Adds a touchcancel event handler to the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- /*\
- * Element.untouchcancel
- [ method ]
- **
- * Removes a touchcancel event handler from the element
- - handler (function) handler for the event
- = (object) @Element
- \*/
- for (var i = events.length; i--;) {
- (function (eventName) {
- Snap[eventName] = elproto[eventName] = function (fn, scope) {
- if (Snap.is(fn, "function")) {
- this.events = this.events || [];
- this.events.push({
- name: eventName,
- f: fn,
- unbind: addEvent(this.node || document, eventName, fn, scope || this)
- });
- }
- return this;
- };
- Snap["un" + eventName] =
- elproto["un" + eventName] = function (fn) {
- var events = this.events || [],
- l = events.length;
- while (l--) if (events[l].name == eventName &&
- (events[l].f == fn || !fn)) {
- events[l].unbind();
- events.splice(l, 1);
- !events.length && delete this.events;
- return this;
- }
- return this;
- };
- })(events[i]);
- }
- /*\
- * Element.hover
- [ method ]
- **
- * Adds hover event handlers to the element
- - f_in (function) handler for hover in
- - f_out (function) handler for hover out
- - icontext (object) #optional context for hover in handler
- - ocontext (object) #optional context for hover out handler
- = (object) @Element
- \*/
- elproto.hover = function (f_in, f_out, scope_in, scope_out) {
- return this.mouseover(f_in, scope_in).mouseout(f_out, scope_out || scope_in);
- };
- /*\
- * Element.unhover
- [ method ]
- **
- * Removes hover event handlers from the element
- - f_in (function) handler for hover in
- - f_out (function) handler for hover out
- = (object) @Element
- \*/
- elproto.unhover = function (f_in, f_out) {
- return this.unmouseover(f_in).unmouseout(f_out);
- };
- var draggable = [];
- // SIERRA unclear what _context_ refers to for starting, ending, moving the drag gesture.
- // SIERRA Element.drag(): _x position of the mouse_: Where are the x/y values offset from?
- // SIERRA Element.drag(): much of this member's doc appears to be duplicated for some reason.
- // 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?
- /*\
- * Element.drag
- [ method ]
- **
- * Adds event handlers for an element's drag gesture
- **
- - onmove (function) handler for moving
- - onstart (function) handler for drag start
- - onend (function) handler for drag end
- - mcontext (object) #optional context for moving handler
- - scontext (object) #optional context for drag start handler
- - econtext (object) #optional context for drag end handler
- * Additionaly following `drag` events are triggered: `drag.start.<id>` on start,
- * `drag.end.<id>` on end and `drag.move.<id>` on every move. When element is dragged over another element
- * `drag.over.<id>` fires as well.
- *
- * Start event and start handler are called in specified context or in context of the element with following parameters:
- o x (number) x position of the mouse
- o y (number) y position of the mouse
- o event (object) DOM event object
- * Move event and move handler are called in specified context or in context of the element with following parameters:
- o dx (number) shift by x from the start point
- o dy (number) shift by y from the start point
- o x (number) x position of the mouse
- o y (number) y position of the mouse
- o event (object) DOM event object
- * End event and end handler are called in specified context or in context of the element with following parameters:
- o event (object) DOM event object
- = (object) @Element
- \*/
- elproto.drag = function (onmove, onstart, onend, move_scope, start_scope, end_scope) {
- if (!arguments.length) {
- var origTransform;
- return this.drag(function (dx, dy) {
- this.attr({
- transform: origTransform + (origTransform ? "T" : "t") + [dx, dy]
- });
- }, function () {
- origTransform = this.transform().local;
- });
- }
- function start(e, x, y) {
- (e.originalEvent || e).preventDefault();
- this._drag.x = x;
- this._drag.y = y;
- this._drag.id = e.identifier;
- !drag.length && Snap.mousemove(dragMove).mouseup(dragUp);
- drag.push({el: this, move_scope: move_scope, start_scope: start_scope, end_scope: end_scope});
- onstart && eve.on("snap.drag.start." + this.id, onstart);
- onmove && eve.on("snap.drag.move." + this.id, onmove);
- onend && eve.on("snap.drag.end." + this.id, onend);
- eve("snap.drag.start." + this.id, start_scope || move_scope || this, x, y, e);
- }
- this._drag = {};
- draggable.push({el: this, start: start});
- this.mousedown(start);
- return this;
- };
- /*
- * Element.onDragOver
- [ method ]
- **
- * Shortcut to assign event handler for `drag.over.<id>` event, where `id` is the element's `id` (see @Element.id)
- - f (function) handler for event, first argument would be the element you are dragging over
- \*/
- // elproto.onDragOver = function (f) {
- // f ? eve.on("snap.drag.over." + this.id, f) : eve.unbind("snap.drag.over." + this.id);
- // };
- /*\
- * Element.undrag
- [ method ]
- **
- * Removes all drag event handlers from the given element
- \*/
- elproto.undrag = function () {
- var i = draggable.length;
- while (i--) if (draggable[i].el == this) {
- this.unmousedown(draggable[i].start);
- draggable.splice(i, 1);
- eve.unbind("snap.drag.*." + this.id);
- }
- !draggable.length && Snap.unmousemove(dragMove).unmouseup(dragUp);
- return this;
- };
- });
- // Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- Snap.plugin(function (Snap, Element, Paper, glob) {
- var elproto = Element.prototype,
- pproto = Paper.prototype,
- rgurl = /^\s*url\((.+)\)/,
- Str = String,
- $ = Snap._.$;
- Snap.filter = {};
- /*\
- * Paper.filter
- [ method ]
- **
- * Creates a `<filter>` element
- **
- - filstr (string) SVG fragment of filter provided as a string
- = (object) @Element
- * Note: It is recommended to use filters embedded into the page inside an empty SVG element.
- > Usage
- | var f = paper.filter('<feGaussianBlur stdDeviation="2"/>'),
- | c = paper.circle(10, 10, 10).attr({
- | filter: f
- | });
- \*/
- pproto.filter = function (filstr) {
- var paper = this;
- if (paper.type != "svg") {
- paper = paper.paper;
- }
- var f = Snap.parse(Str(filstr)),
- id = Snap._.id(),
- width = paper.node.offsetWidth,
- height = paper.node.offsetHeight,
- filter = $("filter");
- $(filter, {
- id: id,
- filterUnits: "userSpaceOnUse"
- });
- filter.appendChild(f.node);
- paper.defs.appendChild(filter);
- return new Element(filter);
- };
-
- eve.on("snap.util.getattr.filter", function () {
- eve.stop();
- var p = $(this.node, "filter");
- if (p) {
- var match = Str(p).match(rgurl);
- return match && Snap.select(match[1]);
- }
- });
- eve.on("snap.util.attr.filter", function (value) {
- if (value instanceof Element && value.type == "filter") {
- eve.stop();
- var id = value.node.id;
- if (!id) {
- $(value.node, {id: value.id});
- id = value.id;
- }
- $(this.node, {
- filter: Snap.url(id)
- });
- }
- if (!value || value == "none") {
- eve.stop();
- this.node.removeAttribute("filter");
- }
- });
- /*\
- * Snap.filter.blur
- [ method ]
- **
- * Returns an SVG markup string for the blur filter
- **
- - x (number) amount of horizontal blur, in pixels
- - y (number) #optional amount of vertical blur, in pixels
- = (string) filter representation
- > Usage
- | var f = paper.filter(Snap.filter.blur(5, 10)),
- | c = paper.circle(10, 10, 10).attr({
- | filter: f
- | });
- \*/
- Snap.filter.blur = function (x, y) {
- if (x == null) {
- x = 2;
- }
- var def = y == null ? x : [x, y];
- return Snap.format('\<feGaussianBlur stdDeviation="{def}"/>', {
- def: def
- });
- };
- Snap.filter.blur.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.shadow
- [ method ]
- **
- * Returns an SVG markup string for the shadow filter
- **
- - dx (number) #optional horizontal shift of the shadow, in pixels
- - dy (number) #optional vertical shift of the shadow, in pixels
- - blur (number) #optional amount of blur
- - color (string) #optional color of the shadow
- - opacity (number) #optional `0..1` opacity of the shadow
- * or
- - dx (number) #optional horizontal shift of the shadow, in pixels
- - dy (number) #optional vertical shift of the shadow, in pixels
- - color (string) #optional color of the shadow
- - opacity (number) #optional `0..1` opacity of the shadow
- * which makes blur default to `4`. Or
- - dx (number) #optional horizontal shift of the shadow, in pixels
- - dy (number) #optional vertical shift of the shadow, in pixels
- - opacity (number) #optional `0..1` opacity of the shadow
- = (string) filter representation
- > Usage
- | var f = paper.filter(Snap.filter.shadow(0, 2, 3)),
- | c = paper.circle(10, 10, 10).attr({
- | filter: f
- | });
- \*/
- Snap.filter.shadow = function (dx, dy, blur, color, opacity) {
- if (typeof blur == "string") {
- color = blur;
- opacity = color;
- blur = 4;
- }
- if (typeof color != "string") {
- opacity = color;
- color = "#000";
- }
- color = color || "#000";
- if (blur == null) {
- blur = 4;
- }
- if (opacity == null) {
- opacity = 1;
- }
- if (dx == null) {
- dx = 0;
- dy = 2;
- }
- if (dy == null) {
- dy = dx;
- }
- color = Snap.color(color);
- 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>', {
- color: color,
- dx: dx,
- dy: dy,
- blur: blur,
- opacity: opacity
- });
- };
- Snap.filter.shadow.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.grayscale
- [ method ]
- **
- * Returns an SVG markup string for the grayscale filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.grayscale = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- 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"/>', {
- a: 0.2126 + 0.7874 * (1 - amount),
- b: 0.7152 - 0.7152 * (1 - amount),
- c: 0.0722 - 0.0722 * (1 - amount),
- d: 0.2126 - 0.2126 * (1 - amount),
- e: 0.7152 + 0.2848 * (1 - amount),
- f: 0.0722 - 0.0722 * (1 - amount),
- g: 0.2126 - 0.2126 * (1 - amount),
- h: 0.0722 + 0.9278 * (1 - amount)
- });
- };
- Snap.filter.grayscale.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.sepia
- [ method ]
- **
- * Returns an SVG markup string for the sepia filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.sepia = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- 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"/>', {
- a: 0.393 + 0.607 * (1 - amount),
- b: 0.769 - 0.769 * (1 - amount),
- c: 0.189 - 0.189 * (1 - amount),
- d: 0.349 - 0.349 * (1 - amount),
- e: 0.686 + 0.314 * (1 - amount),
- f: 0.168 - 0.168 * (1 - amount),
- g: 0.272 - 0.272 * (1 - amount),
- h: 0.534 - 0.534 * (1 - amount),
- i: 0.131 + 0.869 * (1 - amount)
- });
- };
- Snap.filter.sepia.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.saturate
- [ method ]
- **
- * Returns an SVG markup string for the saturate filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.saturate = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- return Snap.format('<feColorMatrix type="saturate" values="{amount}"/>', {
- amount: 1 - amount
- });
- };
- Snap.filter.saturate.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.hueRotate
- [ method ]
- **
- * Returns an SVG markup string for the hue-rotate filter
- **
- - angle (number) angle of rotation
- = (string) filter representation
- \*/
- Snap.filter.hueRotate = function (angle) {
- angle = angle || 0;
- return Snap.format('<feColorMatrix type="hueRotate" values="{angle}"/>', {
- angle: angle
- });
- };
- Snap.filter.hueRotate.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.invert
- [ method ]
- **
- * Returns an SVG markup string for the invert filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.invert = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- return Snap.format('<feComponentTransfer><feFuncR type="table" tableValues="{amount} {amount2}"/><feFuncG type="table" tableValues="{amount} {amount2}"/><feFuncB type="table" tableValues="{amount} {amount2}"/></feComponentTransfer>', {
- amount: amount,
- amount2: 1 - amount
- });
- };
- Snap.filter.invert.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.brightness
- [ method ]
- **
- * Returns an SVG markup string for the brightness filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.brightness = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- return Snap.format('<feComponentTransfer><feFuncR type="linear" slope="{amount}"/><feFuncG type="linear" slope="{amount}"/><feFuncB type="linear" slope="{amount}"/></feComponentTransfer>', {
- amount: amount
- });
- };
- Snap.filter.brightness.toString = function () {
- return this();
- };
- /*\
- * Snap.filter.contrast
- [ method ]
- **
- * Returns an SVG markup string for the contrast filter
- **
- - amount (number) amount of filter (`0..1`)
- = (string) filter representation
- \*/
- Snap.filter.contrast = function (amount) {
- if (amount == null) {
- amount = 1;
- }
- 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>', {
- amount: amount,
- amount2: .5 - amount / 2
- });
- };
- Snap.filter.contrast.toString = function () {
- return this();
- };
- });
- return Snap;
- }));
- },{"197":197}],200:[function(_dereq_,module,exports){
- 'use strict';
- var snapsvg = module.exports = _dereq_(199);
- snapsvg.plugin(function(Snap, Element) {
- /*\
- * Element.children
- [ method ]
- **
- * Returns array of all the children of the element.
- = (array) array of Elements
- \*/
- Element.prototype.children = function () {
- var out = [],
- ch = this.node.childNodes;
- for (var i = 0, ii = ch.length; i < ii; i++) {
- out[i] = new Snap(ch[i]);
- }
- return out;
- };
- });
- /**
- * @class ClassPlugin
- *
- * Extends snapsvg with methods to add and remove classes
- */
- snapsvg.plugin(function (Snap, Element, Paper, global) {
- function split(str) {
- return str.split(/\s+/);
- }
- function join(array) {
- return array.join(' ');
- }
- function getClasses(e) {
- return split(e.attr('class') || '');
- }
- function setClasses(e, classes) {
- e.attr('class', join(classes));
- }
- /**
- * @method snapsvg.Element#addClass
- *
- * @example
- *
- * e.attr('class', 'selector');
- *
- * e.addClass('foo bar'); // adds classes foo and bar
- * e.attr('class'); // -> 'selector foo bar'
- *
- * e.addClass('fooBar');
- * e.attr('class'); // -> 'selector foo bar fooBar'
- *
- * @param {String} cls classes to be added to the element
- *
- * @return {snapsvg.Element} the element (this)
- */
- Element.prototype.addClass = function(cls) {
- var current = getClasses(this),
- add = split(cls),
- i, e;
- for (i = 0, e; !!(e = add[i]); i++) {
- if (current.indexOf(e) === -1) {
- current.push(e);
- }
- }
- setClasses(this, current);
- return this;
- };
- /**
- * @method snapsvg.Element#hasClass
- *
- * @param {String} cls the class to query for
- * @return {Boolean} returns true if the element has the given class
- */
- Element.prototype.hasClass = function(cls) {
- if (!cls) {
- throw new Error('[snapsvg] syntax: hasClass(clsStr)');
- }
- return getClasses(this).indexOf(cls) !== -1;
- };
- /**
- * @method snapsvg.Element#removeClass
- *
- * @example
- *
- * e.attr('class', 'foo bar');
- *
- * e.removeClass('foo');
- * e.attr('class'); // -> 'bar'
- *
- * e.removeClass('foo bar'); // removes classes foo and bar
- * e.attr('class'); // -> ''
- *
- * @param {String} cls classes to be removed from element
- *
- * @return {snapsvg.Element} the element (this)
- */
- Element.prototype.removeClass = function(cls) {
- var current = getClasses(this),
- remove = split(cls),
- i, e, idx;
- for (i = 0, e; !!(e = remove[i]); i++) {
- idx = current.indexOf(e);
- if (idx !== -1) {
- // remove element from array
- current.splice(idx, 1);
- }
- }
- setClasses(this, current);
- return this;
- };
- });
- /**
- * @class TranslatePlugin
- *
- * Extends snapsvg with methods to translate elements
- */
- snapsvg.plugin(function (Snap, Element, Paper, global) {
- /*
- * @method snapsvg.Element#translate
- *
- * @example
- *
- * e.translate(10, 20);
- *
- * // sets transform matrix to translate(10, 20)
- *
- * @param {Number} x translation
- * @param {Number} y translation
- *
- * @return {snapsvg.Element} the element (this)
- */
- Element.prototype.translate = function(x, y) {
- var matrix = new Snap.Matrix();
- matrix.translate(x, y);
- return this.transform(matrix);
- };
- });
- /**
- * @class CreatePlugin
- *
- * Create an svg element without attaching it to the dom
- */
- snapsvg.plugin(function(Snap) {
- Snap.create = function(name, attrs) {
- return Snap._.wrap(Snap._.$(name, attrs));
- };
- });
- /**
- * @class CreatSnapAtPlugin
- *
- * Extends snap.svg with a method to create a SVG element
- * at a specific position in the DOM.
- */
- snapsvg.plugin(function(Snap, Element, Paper, global) {
- /*
- * @method snapsvg.createSnapAt
- *
- * @example
- *
- * snapsvg.createSnapAt(parentNode, 200, 200);
- *
- * @param {Number} width of svg
- * @param {Number} height of svg
- * @param {Object} parentNode svg Element will be child of this
- *
- * @return {snapsvg.Element} the newly created wrapped SVG element instance
- */
- Snap.createSnapAt = function(width, height, parentNode) {
- var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
- svg.setAttribute('width', width);
- svg.setAttribute('height', height);
- if (!parentNode) {
- parentNode = document.body;
- }
- parentNode.appendChild(svg);
- return new Snap(svg);
- };
- });
- },{"199":199}],201:[function(_dereq_,module,exports){
- var isArray = function(obj) {
- return Object.prototype.toString.call(obj) === '[object Array]';
- };
- var annotate = function() {
- var args = Array.prototype.slice.call(arguments);
-
- if (args.length === 1 && isArray(args[0])) {
- args = args[0];
- }
- var fn = args.pop();
- fn.$inject = args;
- return fn;
- };
- // Current limitations:
- // - can't put into "function arg" comments
- // function /* (no parenthesis like this) */ (){}
- // function abc( /* xx (no parenthesis like this) */ a, b) {}
- //
- // Just put the comment before function or inside:
- // /* (((this is fine))) */ function(a, b) {}
- // function abc(a) { /* (((this is fine))) */}
- var FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m;
- var FN_ARG = /\/\*([^\*]*)\*\//m;
- var parse = function(fn) {
- if (typeof fn !== 'function') {
- throw new Error('Cannot annotate "' + fn + '". Expected a function!');
- }
- var match = fn.toString().match(FN_ARGS);
- return match[1] && match[1].split(',').map(function(arg) {
- match = arg.match(FN_ARG);
- return match ? match[1].trim() : arg.trim();
- }) || [];
- };
- exports.annotate = annotate;
- exports.parse = parse;
- exports.isArray = isArray;
- },{}],202:[function(_dereq_,module,exports){
- module.exports = {
- annotate: _dereq_(201).annotate,
- Module: _dereq_(204),
- Injector: _dereq_(203)
- };
- },{"201":201,"203":203,"204":204}],203:[function(_dereq_,module,exports){
- var Module = _dereq_(204);
- var autoAnnotate = _dereq_(201).parse;
- var annotate = _dereq_(201).annotate;
- var isArray = _dereq_(201).isArray;
- var Injector = function(modules, parent) {
- parent = parent || {
- get: function(name) {
- currentlyResolving.push(name);
- throw error('No provider for "' + name + '"!');
- }
- };
- var currentlyResolving = [];
- var providers = this._providers = Object.create(parent._providers || null);
- var instances = this._instances = Object.create(null);
- var self = instances.injector = this;
- var error = function(msg) {
- var stack = currentlyResolving.join(' -> ');
- currentlyResolving.length = 0;
- return new Error(stack ? msg + ' (Resolving: ' + stack + ')' : msg);
- };
- var get = function(name) {
- if (!providers[name] && name.indexOf('.') !== -1) {
- var parts = name.split('.');
- var pivot = get(parts.shift());
- while(parts.length) {
- pivot = pivot[parts.shift()];
- }
- return pivot;
- }
- if (Object.hasOwnProperty.call(instances, name)) {
- return instances[name];
- }
- if (Object.hasOwnProperty.call(providers, name)) {
- if (currentlyResolving.indexOf(name) !== -1) {
- currentlyResolving.push(name);
- throw error('Cannot resolve circular dependency!');
- }
- currentlyResolving.push(name);
- instances[name] = providers[name][0](providers[name][1]);
- currentlyResolving.pop();
- return instances[name];
- }
- return parent.get(name);
- };
- var instantiate = function(Type) {
- var instance = Object.create(Type.prototype);
- var returned = invoke(Type, instance);
- return typeof returned === 'object' ? returned : instance;
- };
- var invoke = function(fn, context) {
- if (typeof fn !== 'function') {
- if (isArray(fn)) {
- fn = annotate(fn.slice());
- } else {
- throw new Error('Cannot invoke "' + fn + '". Expected a function!');
- }
- }
- var inject = fn.$inject && fn.$inject || autoAnnotate(fn);
- var dependencies = inject.map(function(dep) {
- return get(dep);
- });
- // TODO(vojta): optimize without apply
- return fn.apply(context, dependencies);
- };
- var createPrivateInjectorFactory = function(privateChildInjector) {
- return annotate(function(key) {
- return privateChildInjector.get(key);
- });
- };
- var createChild = function(modules, forceNewInstances) {
- if (forceNewInstances && forceNewInstances.length) {
- var fromParentModule = Object.create(null);
- var matchedScopes = Object.create(null);
- var privateInjectorsCache = [];
- var privateChildInjectors = [];
- var privateChildFactories = [];
- var provider;
- var cacheIdx;
- var privateChildInjector;
- var privateChildInjectorFactory;
- for (var name in providers) {
- provider = providers[name];
- if (forceNewInstances.indexOf(name) !== -1) {
- if (provider[2] === 'private') {
- cacheIdx = privateInjectorsCache.indexOf(provider[3]);
- if (cacheIdx === -1) {
- privateChildInjector = provider[3].createChild([], forceNewInstances);
- privateChildInjectorFactory = createPrivateInjectorFactory(privateChildInjector);
- privateInjectorsCache.push(provider[3]);
- privateChildInjectors.push(privateChildInjector);
- privateChildFactories.push(privateChildInjectorFactory);
- fromParentModule[name] = [privateChildInjectorFactory, name, 'private', privateChildInjector];
- } else {
- fromParentModule[name] = [privateChildFactories[cacheIdx], name, 'private', privateChildInjectors[cacheIdx]];
- }
- } else {
- fromParentModule[name] = [provider[2], provider[1]];
- }
- matchedScopes[name] = true;
- }
- if ((provider[2] === 'factory' || provider[2] === 'type') && provider[1].$scope) {
- forceNewInstances.forEach(function(scope) {
- if (provider[1].$scope.indexOf(scope) !== -1) {
- fromParentModule[name] = [provider[2], provider[1]];
- matchedScopes[scope] = true;
- }
- });
- }
- }
- forceNewInstances.forEach(function(scope) {
- if (!matchedScopes[scope]) {
- throw new Error('No provider for "' + scope + '". Cannot use provider from the parent!');
- }
- });
- modules.unshift(fromParentModule);
- }
- return new Injector(modules, self);
- };
- var factoryMap = {
- factory: invoke,
- type: instantiate,
- value: function(value) {
- return value;
- }
- };
- modules.forEach(function(module) {
- function arrayUnwrap(type, value) {
- if (type !== 'value' && isArray(value)) {
- value = annotate(value.slice());
- }
- return value;
- }
- // TODO(vojta): handle wrong inputs (modules)
- if (module instanceof Module) {
- module.forEach(function(provider) {
- var name = provider[0];
- var type = provider[1];
- var value = provider[2];
- providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
- });
- } else if (typeof module === 'object') {
- if (module.__exports__) {
- var clonedModule = Object.keys(module).reduce(function(m, key) {
- if (key.substring(0, 2) !== '__') {
- m[key] = module[key];
- }
- return m;
- }, Object.create(null));
- var privateInjector = new Injector((module.__modules__ || []).concat([clonedModule]), self);
- var getFromPrivateInjector = annotate(function(key) {
- return privateInjector.get(key);
- });
- module.__exports__.forEach(function(key) {
- providers[key] = [getFromPrivateInjector, key, 'private', privateInjector];
- });
- } else {
- Object.keys(module).forEach(function(name) {
- if (module[name][2] === 'private') {
- providers[name] = module[name];
- return;
- }
- var type = module[name][0];
- var value = module[name][1];
- providers[name] = [factoryMap[type], arrayUnwrap(type, value), type];
- });
- }
- }
- });
- // public API
- this.get = get;
- this.invoke = invoke;
- this.instantiate = instantiate;
- this.createChild = createChild;
- };
- module.exports = Injector;
- },{"201":201,"204":204}],204:[function(_dereq_,module,exports){
- var Module = function() {
- var providers = [];
- this.factory = function(name, factory) {
- providers.push([name, 'factory', factory]);
- return this;
- };
- this.value = function(name, value) {
- providers.push([name, 'value', value]);
- return this;
- };
- this.type = function(name, type) {
- providers.push([name, 'type', type]);
- return this;
- };
- this.forEach = function(iterator) {
- providers.forEach(iterator);
- };
- };
- module.exports = Module;
- },{}],205:[function(_dereq_,module,exports){
- 'use strict';
- var hat = _dereq_(206);
- /**
- * Create a new id generator / cache instance.
- *
- * You may optionally provide a seed that is used internally.
- *
- * @param {Seed} seed
- */
- function Ids(seed) {
- seed = seed || [ 128, 36, 1 ];
- this._seed = seed.length ? hat.rack(seed[0], seed[1], seed[2]) : seed;
- }
- module.exports = Ids;
- /**
- * Generate a next id.
- *
- * @param {Object} [element] element to bind the id to
- *
- * @return {String} id
- */
- Ids.prototype.next = function(element) {
- return this._seed(element || true);
- };
- /**
- * Generate a next id with a given prefix.
- *
- * @param {Object} [element] element to bind the id to
- *
- * @return {String} id
- */
- Ids.prototype.nextPrefixed = function(prefix, element) {
- var id;
- do {
- id = prefix + this.next(true);
- } while (this.assigned(id));
- // claim {prefix}{random}
- this.claim(id, element);
- // return
- return id;
- };
- /**
- * Manually claim an existing id.
- *
- * @param {String} id
- * @param {String} [element] element the id is claimed by
- */
- Ids.prototype.claim = function(id, element) {
- this._seed.set(id, element || true);
- };
- /**
- * Returns true if the given id has already been assigned.
- *
- * @param {String} id
- * @return {Boolean}
- */
- Ids.prototype.assigned = function(id) {
- return this._seed.get(id) || false;
- };
- },{"206":206}],206:[function(_dereq_,module,exports){
- var hat = module.exports = function (bits, base) {
- if (!base) base = 16;
- if (bits === undefined) bits = 128;
- if (bits <= 0) return '0';
-
- var digits = Math.log(Math.pow(2, bits)) / Math.log(base);
- for (var i = 2; digits === Infinity; i *= 2) {
- digits = Math.log(Math.pow(2, bits / i)) / Math.log(base) * i;
- }
-
- var rem = digits - Math.floor(digits);
-
- var res = '';
-
- for (var i = 0; i < Math.floor(digits); i++) {
- var x = Math.floor(Math.random() * base).toString(base);
- res = x + res;
- }
-
- if (rem) {
- var b = Math.pow(base, rem);
- var x = Math.floor(Math.random() * b).toString(base);
- res = x + res;
- }
-
- var parsed = parseInt(res, base);
- if (parsed !== Infinity && parsed >= Math.pow(2, bits)) {
- return hat(bits, base)
- }
- else return res;
- };
- hat.rack = function (bits, base, expandBy) {
- var fn = function (data) {
- var iters = 0;
- do {
- if (iters ++ > 10) {
- if (expandBy) bits += expandBy;
- else throw new Error('too many ID collisions, use more bits')
- }
-
- var id = hat(bits, base);
- } while (Object.hasOwnProperty.call(hats, id));
-
- hats[id] = data;
- return id;
- };
- var hats = fn.hats = {};
-
- fn.get = function (id) {
- return fn.hats[id];
- };
-
- fn.set = function (id, value) {
- fn.hats[id] = value;
- return fn;
- };
-
- fn.bits = bits || 128;
- fn.base = base || 16;
- return fn;
- };
- },{}],207:[function(_dereq_,module,exports){
- if (typeof Object.create === 'function') {
- // implementation from standard node.js 'util' module
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
- };
- } else {
- // old school shim for old browsers
- module.exports = function inherits(ctor, superCtor) {
- ctor.super_ = superCtor
- var TempCtor = function () {}
- TempCtor.prototype = superCtor.prototype
- ctor.prototype = new TempCtor()
- ctor.prototype.constructor = ctor
- }
- }
- },{}],208:[function(_dereq_,module,exports){
- var baseFlatten = _dereq_(255),
- isIterateeCall = _dereq_(310);
- /**
- * Flattens a nested array. If `isDeep` is `true` the array is recursively
- * flattened, otherwise it's only flattened a single level.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
- * @param- {Object} [guard] Enables use as a callback for functions like `_.map`.
- * @returns {Array} Returns the new flattened array.
- * @example
- *
- * _.flatten([1, [2, 3, [4]]]);
- * // => [1, 2, 3, [4]]
- *
- * // using `isDeep`
- * _.flatten([1, [2, 3, [4]]], true);
- * // => [1, 2, 3, 4]
- */
- function flatten(array, isDeep, guard) {
- var length = array ? array.length : 0;
- if (guard && isIterateeCall(array, isDeep, guard)) {
- isDeep = false;
- }
- return length ? baseFlatten(array, isDeep) : [];
- }
- module.exports = flatten;
- },{"255":255,"310":310}],209:[function(_dereq_,module,exports){
- /**
- * Gets the last element of `array`.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to query.
- * @returns {*} Returns the last element of `array`.
- * @example
- *
- * _.last([1, 2, 3]);
- * // => 3
- */
- function last(array) {
- var length = array ? array.length : 0;
- return length ? array[length - 1] : undefined;
- }
- module.exports = last;
- },{}],210:[function(_dereq_,module,exports){
- var baseCallback = _dereq_(244),
- baseUniq = _dereq_(278),
- isIterateeCall = _dereq_(310),
- sortedUniq = _dereq_(325);
- /**
- * Creates a duplicate-free version of an array, using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons, in which only the first occurence of each element
- * is kept. Providing `true` for `isSorted` performs a faster search algorithm
- * for sorted arrays. If an iteratee function is provided it's invoked for
- * each element in the array to generate the criterion by which uniqueness
- * is computed. The `iteratee` is bound to `thisArg` and invoked with three
- * arguments: (value, index, array).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias unique
- * @category Array
- * @param {Array} array The array to inspect.
- * @param {boolean} [isSorted] Specify the array is sorted.
- * @param {Function|Object|string} [iteratee] The function invoked per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new duplicate-value-free array.
- * @example
- *
- * _.uniq([2, 1, 2]);
- * // => [2, 1]
- *
- * // using `isSorted`
- * _.uniq([1, 1, 2], true);
- * // => [1, 2]
- *
- * // using an iteratee function
- * _.uniq([1, 2.5, 1.5, 2], function(n) {
- * return this.floor(n);
- * }, Math);
- * // => [1, 2.5]
- *
- * // using the `_.property` callback shorthand
- * _.uniq([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
- * // => [{ 'x': 1 }, { 'x': 2 }]
- */
- function uniq(array, isSorted, iteratee, thisArg) {
- var length = array ? array.length : 0;
- if (!length) {
- return [];
- }
- if (isSorted != null && typeof isSorted != 'boolean') {
- thisArg = iteratee;
- iteratee = isIterateeCall(array, isSorted, thisArg) ? undefined : isSorted;
- isSorted = false;
- }
- iteratee = iteratee == null ? iteratee : baseCallback(iteratee, thisArg, 3);
- return (isSorted)
- ? sortedUniq(array, iteratee)
- : baseUniq(array, iteratee);
- }
- module.exports = uniq;
- },{"244":244,"278":278,"310":310,"325":325}],211:[function(_dereq_,module,exports){
- module.exports = _dereq_(210);
- },{"210":210}],212:[function(_dereq_,module,exports){
- var baseDifference = _dereq_(249),
- isArrayLike = _dereq_(308),
- restParam = _dereq_(230);
- /**
- * Creates an array excluding all provided values using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons.
- *
- * @static
- * @memberOf _
- * @category Array
- * @param {Array} array The array to filter.
- * @param {...*} [values] The values to exclude.
- * @returns {Array} Returns the new array of filtered values.
- * @example
- *
- * _.without([1, 2, 1, 3], 1, 2);
- * // => [3]
- */
- var without = restParam(function(array, values) {
- return isArrayLike(array)
- ? baseDifference(array, values)
- : [];
- });
- module.exports = without;
- },{"230":230,"249":249,"308":308}],213:[function(_dereq_,module,exports){
- var LazyWrapper = _dereq_(231),
- LodashWrapper = _dereq_(232),
- baseLodash = _dereq_(264),
- isArray = _dereq_(330),
- isObjectLike = _dereq_(314),
- wrapperClone = _dereq_(328);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Creates a `lodash` object which wraps `value` to enable implicit chaining.
- * Methods that operate on and return arrays, collections, and functions can
- * be chained together. Methods that retrieve a single value or may return a
- * primitive value will automatically end the chain returning the unwrapped
- * value. Explicit chaining may be enabled using `_.chain`. The execution of
- * chained methods is lazy, that is, execution is deferred until `_#value`
- * is implicitly or explicitly called.
- *
- * Lazy evaluation allows several methods to support shortcut fusion. Shortcut
- * fusion is an optimization strategy which merge iteratee calls; this can help
- * to avoid the creation of intermediate data structures and greatly reduce the
- * number of iteratee executions.
- *
- * Chaining is supported in custom builds as long as the `_#value` method is
- * directly or indirectly included in the build.
- *
- * In addition to lodash methods, wrappers have `Array` and `String` methods.
- *
- * The wrapper `Array` methods are:
- * `concat`, `join`, `pop`, `push`, `reverse`, `shift`, `slice`, `sort`,
- * `splice`, and `unshift`
- *
- * The wrapper `String` methods are:
- * `replace` and `split`
- *
- * The wrapper methods that support shortcut fusion are:
- * `compact`, `drop`, `dropRight`, `dropRightWhile`, `dropWhile`, `filter`,
- * `first`, `initial`, `last`, `map`, `pluck`, `reject`, `rest`, `reverse`,
- * `slice`, `take`, `takeRight`, `takeRightWhile`, `takeWhile`, `toArray`,
- * and `where`
- *
- * The chainable wrapper methods are:
- * `after`, `ary`, `assign`, `at`, `before`, `bind`, `bindAll`, `bindKey`,
- * `callback`, `chain`, `chunk`, `commit`, `compact`, `concat`, `constant`,
- * `countBy`, `create`, `curry`, `debounce`, `defaults`, `defaultsDeep`,
- * `defer`, `delay`, `difference`, `drop`, `dropRight`, `dropRightWhile`,
- * `dropWhile`, `fill`, `filter`, `flatten`, `flattenDeep`, `flow`, `flowRight`,
- * `forEach`, `forEachRight`, `forIn`, `forInRight`, `forOwn`, `forOwnRight`,
- * `functions`, `groupBy`, `indexBy`, `initial`, `intersection`, `invert`,
- * `invoke`, `keys`, `keysIn`, `map`, `mapKeys`, `mapValues`, `matches`,
- * `matchesProperty`, `memoize`, `merge`, `method`, `methodOf`, `mixin`,
- * `modArgs`, `negate`, `omit`, `once`, `pairs`, `partial`, `partialRight`,
- * `partition`, `pick`, `plant`, `pluck`, `property`, `propertyOf`, `pull`,
- * `pullAt`, `push`, `range`, `rearg`, `reject`, `remove`, `rest`, `restParam`,
- * `reverse`, `set`, `shuffle`, `slice`, `sort`, `sortBy`, `sortByAll`,
- * `sortByOrder`, `splice`, `spread`, `take`, `takeRight`, `takeRightWhile`,
- * `takeWhile`, `tap`, `throttle`, `thru`, `times`, `toArray`, `toPlainObject`,
- * `transform`, `union`, `uniq`, `unshift`, `unzip`, `unzipWith`, `values`,
- * `valuesIn`, `where`, `without`, `wrap`, `xor`, `zip`, `zipObject`, `zipWith`
- *
- * The wrapper methods that are **not** chainable by default are:
- * `add`, `attempt`, `camelCase`, `capitalize`, `ceil`, `clone`, `cloneDeep`,
- * `deburr`, `endsWith`, `escape`, `escapeRegExp`, `every`, `find`, `findIndex`,
- * `findKey`, `findLast`, `findLastIndex`, `findLastKey`, `findWhere`, `first`,
- * `floor`, `get`, `gt`, `gte`, `has`, `identity`, `includes`, `indexOf`,
- * `inRange`, `isArguments`, `isArray`, `isBoolean`, `isDate`, `isElement`,
- * `isEmpty`, `isEqual`, `isError`, `isFinite` `isFunction`, `isMatch`,
- * `isNative`, `isNaN`, `isNull`, `isNumber`, `isObject`, `isPlainObject`,
- * `isRegExp`, `isString`, `isUndefined`, `isTypedArray`, `join`, `kebabCase`,
- * `last`, `lastIndexOf`, `lt`, `lte`, `max`, `min`, `noConflict`, `noop`,
- * `now`, `pad`, `padLeft`, `padRight`, `parseInt`, `pop`, `random`, `reduce`,
- * `reduceRight`, `repeat`, `result`, `round`, `runInContext`, `shift`, `size`,
- * `snakeCase`, `some`, `sortedIndex`, `sortedLastIndex`, `startCase`,
- * `startsWith`, `sum`, `template`, `trim`, `trimLeft`, `trimRight`, `trunc`,
- * `unescape`, `uniqueId`, `value`, and `words`
- *
- * The wrapper method `sample` will return a wrapped value when `n` is provided,
- * otherwise an unwrapped value is returned.
- *
- * @name _
- * @constructor
- * @category Chain
- * @param {*} value The value to wrap in a `lodash` instance.
- * @returns {Object} Returns the new `lodash` wrapper instance.
- * @example
- *
- * var wrapped = _([1, 2, 3]);
- *
- * // returns an unwrapped value
- * wrapped.reduce(function(total, n) {
- * return total + n;
- * });
- * // => 6
- *
- * // returns a wrapped value
- * var squares = wrapped.map(function(n) {
- * return n * n;
- * });
- *
- * _.isArray(squares);
- * // => false
- *
- * _.isArray(squares.value());
- * // => true
- */
- function lodash(value) {
- if (isObjectLike(value) && !isArray(value) && !(value instanceof LazyWrapper)) {
- if (value instanceof LodashWrapper) {
- return value;
- }
- if (hasOwnProperty.call(value, '__chain__') && hasOwnProperty.call(value, '__wrapped__')) {
- return wrapperClone(value);
- }
- }
- return new LodashWrapper(value);
- }
- // Ensure wrappers are instances of `baseLodash`.
- lodash.prototype = baseLodash.prototype;
- module.exports = lodash;
- },{"231":231,"232":232,"264":264,"314":314,"328":328,"330":330}],214:[function(_dereq_,module,exports){
- module.exports = _dereq_(224);
- },{"224":224}],215:[function(_dereq_,module,exports){
- var arrayEvery = _dereq_(236),
- baseCallback = _dereq_(244),
- baseEvery = _dereq_(251),
- isArray = _dereq_(330),
- isIterateeCall = _dereq_(310);
- /**
- * Checks if `predicate` returns truthy for **all** elements of `collection`.
- * The predicate is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection).
- *
- * If a property name is provided for `predicate` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `predicate` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias all
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {boolean} Returns `true` if all elements pass the predicate check,
- * else `false`.
- * @example
- *
- * _.every([true, 1, null, 'yes'], Boolean);
- * // => false
- *
- * var users = [
- * { 'user': 'barney', 'active': false },
- * { 'user': 'fred', 'active': false }
- * ];
- *
- * // using the `_.matches` callback shorthand
- * _.every(users, { 'user': 'barney', 'active': false });
- * // => false
- *
- * // using the `_.matchesProperty` callback shorthand
- * _.every(users, 'active', false);
- * // => true
- *
- * // using the `_.property` callback shorthand
- * _.every(users, 'active');
- * // => false
- */
- function every(collection, predicate, thisArg) {
- var func = isArray(collection) ? arrayEvery : baseEvery;
- if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
- predicate = undefined;
- }
- if (typeof predicate != 'function' || thisArg !== undefined) {
- predicate = baseCallback(predicate, thisArg, 3);
- }
- return func(collection, predicate);
- }
- module.exports = every;
- },{"236":236,"244":244,"251":251,"310":310,"330":330}],216:[function(_dereq_,module,exports){
- var arrayFilter = _dereq_(237),
- baseCallback = _dereq_(244),
- baseFilter = _dereq_(252),
- isArray = _dereq_(330);
- /**
- * Iterates over elements of `collection`, returning an array of all elements
- * `predicate` returns truthy for. The predicate is bound to `thisArg` and
- * invoked with three arguments: (value, index|key, collection).
- *
- * If a property name is provided for `predicate` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `predicate` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias select
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {Array} Returns the new filtered array.
- * @example
- *
- * _.filter([4, 5, 6], function(n) {
- * return n % 2 == 0;
- * });
- * // => [4, 6]
- *
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false }
- * ];
- *
- * // using the `_.matches` callback shorthand
- * _.pluck(_.filter(users, { 'age': 36, 'active': true }), 'user');
- * // => ['barney']
- *
- * // using the `_.matchesProperty` callback shorthand
- * _.pluck(_.filter(users, 'active', false), 'user');
- * // => ['fred']
- *
- * // using the `_.property` callback shorthand
- * _.pluck(_.filter(users, 'active'), 'user');
- * // => ['barney']
- */
- function filter(collection, predicate, thisArg) {
- var func = isArray(collection) ? arrayFilter : baseFilter;
- predicate = baseCallback(predicate, thisArg, 3);
- return func(collection, predicate);
- }
- module.exports = filter;
- },{"237":237,"244":244,"252":252,"330":330}],217:[function(_dereq_,module,exports){
- var baseEach = _dereq_(250),
- createFind = _dereq_(293);
- /**
- * Iterates over elements of `collection`, returning the first element
- * `predicate` returns truthy for. The predicate is bound to `thisArg` and
- * invoked with three arguments: (value, index|key, collection).
- *
- * If a property name is provided for `predicate` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `predicate` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias detect
- * @category Collection
- * @param {Array|Object|string} collection The collection to search.
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {*} Returns the matched element, else `undefined`.
- * @example
- *
- * var users = [
- * { 'user': 'barney', 'age': 36, 'active': true },
- * { 'user': 'fred', 'age': 40, 'active': false },
- * { 'user': 'pebbles', 'age': 1, 'active': true }
- * ];
- *
- * _.result(_.find(users, function(chr) {
- * return chr.age < 40;
- * }), 'user');
- * // => 'barney'
- *
- * // using the `_.matches` callback shorthand
- * _.result(_.find(users, { 'age': 1, 'active': true }), 'user');
- * // => 'pebbles'
- *
- * // using the `_.matchesProperty` callback shorthand
- * _.result(_.find(users, 'active', false), 'user');
- * // => 'fred'
- *
- * // using the `_.property` callback shorthand
- * _.result(_.find(users, 'active'), 'user');
- * // => 'barney'
- */
- var find = createFind(baseEach);
- module.exports = find;
- },{"250":250,"293":293}],218:[function(_dereq_,module,exports){
- var arrayEach = _dereq_(235),
- baseEach = _dereq_(250),
- createForEach = _dereq_(294);
- /**
- * Iterates over elements of `collection` invoking `iteratee` for each element.
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection). Iteratee functions may exit iteration early
- * by explicitly returning `false`.
- *
- * **Note:** As with other "Collections" methods, objects with a "length" property
- * are iterated like arrays. To avoid this behavior `_.forIn` or `_.forOwn`
- * may be used for object iteration.
- *
- * @static
- * @memberOf _
- * @alias each
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array|Object|string} Returns `collection`.
- * @example
- *
- * _([1, 2]).forEach(function(n) {
- * console.log(n);
- * }).value();
- * // => logs each value from left to right and returns the array
- *
- * _.forEach({ 'a': 1, 'b': 2 }, function(n, key) {
- * console.log(n, key);
- * });
- * // => logs each value-key pair and returns the object (iteration order is not guaranteed)
- */
- var forEach = createForEach(arrayEach, baseEach);
- module.exports = forEach;
- },{"235":235,"250":250,"294":294}],219:[function(_dereq_,module,exports){
- var createAggregator = _dereq_(286);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Creates an object composed of keys generated from the results of running
- * each element of `collection` through `iteratee`. The corresponding value
- * of each key is an array of the elements responsible for generating the key.
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [iteratee=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Object} Returns the composed aggregate object.
- * @example
- *
- * _.groupBy([4.2, 6.1, 6.4], function(n) {
- * return Math.floor(n);
- * });
- * // => { '4': [4.2], '6': [6.1, 6.4] }
- *
- * _.groupBy([4.2, 6.1, 6.4], function(n) {
- * return this.floor(n);
- * }, Math);
- * // => { '4': [4.2], '6': [6.1, 6.4] }
- *
- * // using the `_.property` callback shorthand
- * _.groupBy(['one', 'two', 'three'], 'length');
- * // => { '3': ['one', 'two'], '5': ['three'] }
- */
- var groupBy = createAggregator(function(result, value, key) {
- if (hasOwnProperty.call(result, key)) {
- result[key].push(value);
- } else {
- result[key] = [value];
- }
- });
- module.exports = groupBy;
- },{"286":286}],220:[function(_dereq_,module,exports){
- var baseIndexOf = _dereq_(260),
- getLength = _dereq_(304),
- isArray = _dereq_(330),
- isIterateeCall = _dereq_(310),
- isLength = _dereq_(313),
- isString = _dereq_(336),
- values = _dereq_(347);
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Checks if `target` is in `collection` using
- * [`SameValueZero`](http://ecma-international.org/ecma-262/6.0/#sec-samevaluezero)
- * for equality comparisons. If `fromIndex` is negative, it's used as the offset
- * from the end of `collection`.
- *
- * @static
- * @memberOf _
- * @alias contains, include
- * @category Collection
- * @param {Array|Object|string} collection The collection to search.
- * @param {*} target The value to search for.
- * @param {number} [fromIndex=0] The index to search from.
- * @param- {Object} [guard] Enables use as a callback for functions like `_.reduce`.
- * @returns {boolean} Returns `true` if a matching element is found, else `false`.
- * @example
- *
- * _.includes([1, 2, 3], 1);
- * // => true
- *
- * _.includes([1, 2, 3], 1, 2);
- * // => false
- *
- * _.includes({ 'user': 'fred', 'age': 40 }, 'fred');
- * // => true
- *
- * _.includes('pebbles', 'eb');
- * // => true
- */
- function includes(collection, target, fromIndex, guard) {
- var length = collection ? getLength(collection) : 0;
- if (!isLength(length)) {
- collection = values(collection);
- length = collection.length;
- }
- if (typeof fromIndex != 'number' || (guard && isIterateeCall(target, fromIndex, guard))) {
- fromIndex = 0;
- } else {
- fromIndex = fromIndex < 0 ? nativeMax(length + fromIndex, 0) : (fromIndex || 0);
- }
- return (typeof collection == 'string' || !isArray(collection) && isString(collection))
- ? (fromIndex <= length && collection.indexOf(target, fromIndex) > -1)
- : (!!length && baseIndexOf(collection, target, fromIndex) > -1);
- }
- module.exports = includes;
- },{"260":260,"304":304,"310":310,"313":313,"330":330,"336":336,"347":347}],221:[function(_dereq_,module,exports){
- var arrayMap = _dereq_(238),
- baseCallback = _dereq_(244),
- baseMap = _dereq_(265),
- isArray = _dereq_(330);
- /**
- * Creates an array of values by running each element in `collection` through
- * `iteratee`. The `iteratee` is bound to `thisArg` and invoked with three
- * arguments: (value, index|key, collection).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * Many lodash methods are guarded to work as iteratees for methods like
- * `_.every`, `_.filter`, `_.map`, `_.mapValues`, `_.reject`, and `_.some`.
- *
- * The guarded methods are:
- * `ary`, `callback`, `chunk`, `clone`, `create`, `curry`, `curryRight`,
- * `drop`, `dropRight`, `every`, `fill`, `flatten`, `invert`, `max`, `min`,
- * `parseInt`, `slice`, `sortBy`, `take`, `takeRight`, `template`, `trim`,
- * `trimLeft`, `trimRight`, `trunc`, `random`, `range`, `sample`, `some`,
- * `sum`, `uniq`, and `words`
- *
- * @static
- * @memberOf _
- * @alias collect
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [iteratee=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new mapped array.
- * @example
- *
- * function timesThree(n) {
- * return n * 3;
- * }
- *
- * _.map([1, 2], timesThree);
- * // => [3, 6]
- *
- * _.map({ 'a': 1, 'b': 2 }, timesThree);
- * // => [3, 6] (iteration order is not guaranteed)
- *
- * var users = [
- * { 'user': 'barney' },
- * { 'user': 'fred' }
- * ];
- *
- * // using the `_.property` callback shorthand
- * _.map(users, 'user');
- * // => ['barney', 'fred']
- */
- function map(collection, iteratee, thisArg) {
- var func = isArray(collection) ? arrayMap : baseMap;
- iteratee = baseCallback(iteratee, thisArg, 3);
- return func(collection, iteratee);
- }
- module.exports = map;
- },{"238":238,"244":244,"265":265,"330":330}],222:[function(_dereq_,module,exports){
- var arrayReduce = _dereq_(240),
- baseEach = _dereq_(250),
- createReduce = _dereq_(297);
- /**
- * Reduces `collection` to a value which is the accumulated result of running
- * each element in `collection` through `iteratee`, where each successive
- * invocation is supplied the return value of the previous. If `accumulator`
- * is not provided the first element of `collection` is used as the initial
- * value. The `iteratee` is bound to `thisArg` and invoked with four arguments:
- * (accumulator, value, index|key, collection).
- *
- * Many lodash methods are guarded to work as iteratees for methods like
- * `_.reduce`, `_.reduceRight`, and `_.transform`.
- *
- * The guarded methods are:
- * `assign`, `defaults`, `defaultsDeep`, `includes`, `merge`, `sortByAll`,
- * and `sortByOrder`
- *
- * @static
- * @memberOf _
- * @alias foldl, inject
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {*} Returns the accumulated value.
- * @example
- *
- * _.reduce([1, 2], function(total, n) {
- * return total + n;
- * });
- * // => 3
- *
- * _.reduce({ 'a': 1, 'b': 2 }, function(result, n, key) {
- * result[key] = n * 3;
- * return result;
- * }, {});
- * // => { 'a': 3, 'b': 6 } (iteration order is not guaranteed)
- */
- var reduce = createReduce(arrayReduce, baseEach);
- module.exports = reduce;
- },{"240":240,"250":250,"297":297}],223:[function(_dereq_,module,exports){
- var getLength = _dereq_(304),
- isLength = _dereq_(313),
- keys = _dereq_(340);
- /**
- * Gets the size of `collection` by returning its length for array-like
- * values or the number of own enumerable properties for objects.
- *
- * @static
- * @memberOf _
- * @category Collection
- * @param {Array|Object|string} collection The collection to inspect.
- * @returns {number} Returns the size of `collection`.
- * @example
- *
- * _.size([1, 2, 3]);
- * // => 3
- *
- * _.size({ 'a': 1, 'b': 2 });
- * // => 2
- *
- * _.size('pebbles');
- * // => 7
- */
- function size(collection) {
- var length = collection ? getLength(collection) : 0;
- return isLength(length) ? length : keys(collection).length;
- }
- module.exports = size;
- },{"304":304,"313":313,"340":340}],224:[function(_dereq_,module,exports){
- var arraySome = _dereq_(241),
- baseCallback = _dereq_(244),
- baseSome = _dereq_(275),
- isArray = _dereq_(330),
- isIterateeCall = _dereq_(310);
- /**
- * Checks if `predicate` returns truthy for **any** element of `collection`.
- * The function returns as soon as it finds a passing value and does not iterate
- * over the entire collection. The predicate is bound to `thisArg` and invoked
- * with three arguments: (value, index|key, collection).
- *
- * If a property name is provided for `predicate` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `predicate` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @alias any
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [predicate=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- * @example
- *
- * _.some([null, 0, 'yes', false], Boolean);
- * // => true
- *
- * var users = [
- * { 'user': 'barney', 'active': true },
- * { 'user': 'fred', 'active': false }
- * ];
- *
- * // using the `_.matches` callback shorthand
- * _.some(users, { 'user': 'barney', 'active': false });
- * // => false
- *
- * // using the `_.matchesProperty` callback shorthand
- * _.some(users, 'active', false);
- * // => true
- *
- * // using the `_.property` callback shorthand
- * _.some(users, 'active');
- * // => true
- */
- function some(collection, predicate, thisArg) {
- var func = isArray(collection) ? arraySome : baseSome;
- if (thisArg && isIterateeCall(collection, predicate, thisArg)) {
- predicate = undefined;
- }
- if (typeof predicate != 'function' || thisArg !== undefined) {
- predicate = baseCallback(predicate, thisArg, 3);
- }
- return func(collection, predicate);
- }
- module.exports = some;
- },{"241":241,"244":244,"275":275,"310":310,"330":330}],225:[function(_dereq_,module,exports){
- var baseCallback = _dereq_(244),
- baseMap = _dereq_(265),
- baseSortBy = _dereq_(276),
- compareAscending = _dereq_(283),
- isIterateeCall = _dereq_(310);
- /**
- * Creates an array of elements, sorted in ascending order by the results of
- * running each element in a collection through `iteratee`. This method performs
- * a stable sort, that is, it preserves the original sort order of equal elements.
- * The `iteratee` is bound to `thisArg` and invoked with three arguments:
- * (value, index|key, collection).
- *
- * If a property name is provided for `iteratee` the created `_.property`
- * style callback returns the property value of the given element.
- *
- * If a value is also provided for `thisArg` the created `_.matchesProperty`
- * style callback returns `true` for elements that have a matching property
- * value, else `false`.
- *
- * If an object is provided for `iteratee` the created `_.matches` style
- * callback returns `true` for elements that have the properties of the given
- * object, else `false`.
- *
- * @static
- * @memberOf _
- * @category Collection
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function|Object|string} [iteratee=_.identity] The function invoked
- * per iteration.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {Array} Returns the new sorted array.
- * @example
- *
- * _.sortBy([1, 2, 3], function(n) {
- * return Math.sin(n);
- * });
- * // => [3, 1, 2]
- *
- * _.sortBy([1, 2, 3], function(n) {
- * return this.sin(n);
- * }, Math);
- * // => [3, 1, 2]
- *
- * var users = [
- * { 'user': 'fred' },
- * { 'user': 'pebbles' },
- * { 'user': 'barney' }
- * ];
- *
- * // using the `_.property` callback shorthand
- * _.pluck(_.sortBy(users, 'user'), 'user');
- * // => ['barney', 'fred', 'pebbles']
- */
- function sortBy(collection, iteratee, thisArg) {
- if (collection == null) {
- return [];
- }
- if (thisArg && isIterateeCall(collection, iteratee, thisArg)) {
- iteratee = undefined;
- }
- var index = -1;
- iteratee = baseCallback(iteratee, thisArg, 3);
- var result = baseMap(collection, function(value, key, collection) {
- return { 'criteria': iteratee(value, key, collection), 'index': ++index, 'value': value };
- });
- return baseSortBy(result, compareAscending);
- }
- module.exports = sortBy;
- },{"244":244,"265":265,"276":276,"283":283,"310":310}],226:[function(_dereq_,module,exports){
- var getNative = _dereq_(306);
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeNow = getNative(Date, 'now');
- /**
- * Gets the number of milliseconds that have elapsed since the Unix epoch
- * (1 January 1970 00:00:00 UTC).
- *
- * @static
- * @memberOf _
- * @category Date
- * @example
- *
- * _.defer(function(stamp) {
- * console.log(_.now() - stamp);
- * }, _.now());
- * // => logs the number of milliseconds it took for the deferred function to be invoked
- */
- var now = nativeNow || function() {
- return new Date().getTime();
- };
- module.exports = now;
- },{"306":306}],227:[function(_dereq_,module,exports){
- var createWrapper = _dereq_(298),
- replaceHolders = _dereq_(322),
- restParam = _dereq_(230);
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1,
- PARTIAL_FLAG = 32;
- /**
- * Creates a function that invokes `func` with the `this` binding of `thisArg`
- * and prepends any additional `_.bind` arguments to those provided to the
- * bound function.
- *
- * The `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
- * may be used as a placeholder for partially applied arguments.
- *
- * **Note:** Unlike native `Function#bind` this method does not set the "length"
- * property of bound functions.
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to bind.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {...*} [partials] The arguments to be partially applied.
- * @returns {Function} Returns the new bound function.
- * @example
- *
- * var greet = function(greeting, punctuation) {
- * return greeting + ' ' + this.user + punctuation;
- * };
- *
- * var object = { 'user': 'fred' };
- *
- * var bound = _.bind(greet, object, 'hi');
- * bound('!');
- * // => 'hi fred!'
- *
- * // using placeholders
- * var bound = _.bind(greet, object, _, '!');
- * bound('hi');
- * // => 'hi fred!'
- */
- var bind = restParam(function(func, thisArg, partials) {
- var bitmask = BIND_FLAG;
- if (partials.length) {
- var holders = replaceHolders(partials, bind.placeholder);
- bitmask |= PARTIAL_FLAG;
- }
- return createWrapper(func, bitmask, thisArg, partials, holders);
- });
- // Assign default placeholders.
- bind.placeholder = {};
- module.exports = bind;
- },{"230":230,"298":298,"322":322}],228:[function(_dereq_,module,exports){
- var isObject = _dereq_(334),
- now = _dereq_(226);
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a debounced function that delays invoking `func` until after `wait`
- * milliseconds have elapsed since the last time the debounced function was
- * invoked. The debounced function comes with a `cancel` method to cancel
- * delayed invocations. Provide an options object to indicate that `func`
- * should be invoked on the leading and/or trailing edge of the `wait` timeout.
- * Subsequent calls to the debounced function return the result of the last
- * `func` invocation.
- *
- * **Note:** If `leading` and `trailing` options are `true`, `func` is invoked
- * on the trailing edge of the timeout only if the the debounced function is
- * invoked more than once during the `wait` timeout.
- *
- * See [David Corbacho's article](http://drupalmotion.com/article/debounce-and-throttle-visual-explanation)
- * for details over the differences between `_.debounce` and `_.throttle`.
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to debounce.
- * @param {number} [wait=0] The number of milliseconds to delay.
- * @param {Object} [options] The options object.
- * @param {boolean} [options.leading=false] Specify invoking on the leading
- * edge of the timeout.
- * @param {number} [options.maxWait] The maximum time `func` is allowed to be
- * delayed before it's invoked.
- * @param {boolean} [options.trailing=true] Specify invoking on the trailing
- * edge of the timeout.
- * @returns {Function} Returns the new debounced function.
- * @example
- *
- * // avoid costly calculations while the window size is in flux
- * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
- *
- * // invoke `sendMail` when the click event is fired, debouncing subsequent calls
- * jQuery('#postbox').on('click', _.debounce(sendMail, 300, {
- * 'leading': true,
- * 'trailing': false
- * }));
- *
- * // ensure `batchLog` is invoked once after 1 second of debounced calls
- * var source = new EventSource('/stream');
- * jQuery(source).on('message', _.debounce(batchLog, 250, {
- * 'maxWait': 1000
- * }));
- *
- * // cancel a debounced call
- * var todoChanges = _.debounce(batchLog, 1000);
- * Object.observe(models.todo, todoChanges);
- *
- * Object.observe(models, function(changes) {
- * if (_.find(changes, { 'user': 'todo', 'type': 'delete'})) {
- * todoChanges.cancel();
- * }
- * }, ['delete']);
- *
- * // ...at some point `models.todo` is changed
- * models.todo.completed = true;
- *
- * // ...before 1 second has passed `models.todo` is deleted
- * // which cancels the debounced `todoChanges` call
- * delete models.todo;
- */
- function debounce(func, wait, options) {
- var args,
- maxTimeoutId,
- result,
- stamp,
- thisArg,
- timeoutId,
- trailingCall,
- lastCalled = 0,
- maxWait = false,
- trailing = true;
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- wait = wait < 0 ? 0 : (+wait || 0);
- if (options === true) {
- var leading = true;
- trailing = false;
- } else if (isObject(options)) {
- leading = !!options.leading;
- maxWait = 'maxWait' in options && nativeMax(+options.maxWait || 0, wait);
- trailing = 'trailing' in options ? !!options.trailing : trailing;
- }
- function cancel() {
- if (timeoutId) {
- clearTimeout(timeoutId);
- }
- if (maxTimeoutId) {
- clearTimeout(maxTimeoutId);
- }
- lastCalled = 0;
- maxTimeoutId = timeoutId = trailingCall = undefined;
- }
- function complete(isCalled, id) {
- if (id) {
- clearTimeout(id);
- }
- maxTimeoutId = timeoutId = trailingCall = undefined;
- if (isCalled) {
- lastCalled = now();
- result = func.apply(thisArg, args);
- if (!timeoutId && !maxTimeoutId) {
- args = thisArg = undefined;
- }
- }
- }
- function delayed() {
- var remaining = wait - (now() - stamp);
- if (remaining <= 0 || remaining > wait) {
- complete(trailingCall, maxTimeoutId);
- } else {
- timeoutId = setTimeout(delayed, remaining);
- }
- }
- function maxDelayed() {
- complete(trailing, timeoutId);
- }
- function debounced() {
- args = arguments;
- stamp = now();
- thisArg = this;
- trailingCall = trailing && (timeoutId || !leading);
- if (maxWait === false) {
- var leadingCall = leading && !timeoutId;
- } else {
- if (!maxTimeoutId && !leading) {
- lastCalled = stamp;
- }
- var remaining = maxWait - (stamp - lastCalled),
- isCalled = remaining <= 0 || remaining > maxWait;
- if (isCalled) {
- if (maxTimeoutId) {
- maxTimeoutId = clearTimeout(maxTimeoutId);
- }
- lastCalled = stamp;
- result = func.apply(thisArg, args);
- }
- else if (!maxTimeoutId) {
- maxTimeoutId = setTimeout(maxDelayed, remaining);
- }
- }
- if (isCalled && timeoutId) {
- timeoutId = clearTimeout(timeoutId);
- }
- else if (!timeoutId && wait !== maxWait) {
- timeoutId = setTimeout(delayed, wait);
- }
- if (leadingCall) {
- isCalled = true;
- result = func.apply(thisArg, args);
- }
- if (isCalled && !timeoutId && !maxTimeoutId) {
- args = thisArg = undefined;
- }
- return result;
- }
- debounced.cancel = cancel;
- return debounced;
- }
- module.exports = debounce;
- },{"226":226,"334":334}],229:[function(_dereq_,module,exports){
- var baseDelay = _dereq_(248),
- restParam = _dereq_(230);
- /**
- * Defers invoking the `func` until the current call stack has cleared. Any
- * additional arguments are provided to `func` when it's invoked.
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to defer.
- * @param {...*} [args] The arguments to invoke the function with.
- * @returns {number} Returns the timer id.
- * @example
- *
- * _.defer(function(text) {
- * console.log(text);
- * }, 'deferred');
- * // logs 'deferred' after one or more milliseconds
- */
- var defer = restParam(function(func, args) {
- return baseDelay(func, 1, args);
- });
- module.exports = defer;
- },{"230":230,"248":248}],230:[function(_dereq_,module,exports){
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a function that invokes `func` with the `this` binding of the
- * created function and arguments from `start` and beyond provided as an array.
- *
- * **Note:** This method is based on the [rest parameter](https://developer.mozilla.org/Web/JavaScript/Reference/Functions/rest_parameters).
- *
- * @static
- * @memberOf _
- * @category Function
- * @param {Function} func The function to apply a rest parameter to.
- * @param {number} [start=func.length-1] The start position of the rest parameter.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var say = _.restParam(function(what, names) {
- * return what + ' ' + _.initial(names).join(', ') +
- * (_.size(names) > 1 ? ', & ' : '') + _.last(names);
- * });
- *
- * say('hello', 'fred', 'barney', 'pebbles');
- * // => 'hello fred, barney, & pebbles'
- */
- function restParam(func, start) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- start = nativeMax(start === undefined ? (func.length - 1) : (+start || 0), 0);
- return function() {
- var args = arguments,
- index = -1,
- length = nativeMax(args.length - start, 0),
- rest = Array(length);
- while (++index < length) {
- rest[index] = args[start + index];
- }
- switch (start) {
- case 0: return func.call(this, rest);
- case 1: return func.call(this, args[0], rest);
- case 2: return func.call(this, args[0], args[1], rest);
- }
- var otherArgs = Array(start + 1);
- index = -1;
- while (++index < start) {
- otherArgs[index] = args[index];
- }
- otherArgs[start] = rest;
- return func.apply(this, otherArgs);
- };
- }
- module.exports = restParam;
- },{}],231:[function(_dereq_,module,exports){
- var baseCreate = _dereq_(247),
- baseLodash = _dereq_(264);
- /** Used as references for `-Infinity` and `Infinity`. */
- var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
- /**
- * Creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
- *
- * @private
- * @param {*} value The value to wrap.
- */
- function LazyWrapper(value) {
- this.__wrapped__ = value;
- this.__actions__ = [];
- this.__dir__ = 1;
- this.__filtered__ = false;
- this.__iteratees__ = [];
- this.__takeCount__ = POSITIVE_INFINITY;
- this.__views__ = [];
- }
- LazyWrapper.prototype = baseCreate(baseLodash.prototype);
- LazyWrapper.prototype.constructor = LazyWrapper;
- module.exports = LazyWrapper;
- },{"247":247,"264":264}],232:[function(_dereq_,module,exports){
- var baseCreate = _dereq_(247),
- baseLodash = _dereq_(264);
- /**
- * The base constructor for creating `lodash` wrapper objects.
- *
- * @private
- * @param {*} value The value to wrap.
- * @param {boolean} [chainAll] Enable chaining for all wrapper methods.
- * @param {Array} [actions=[]] Actions to peform to resolve the unwrapped value.
- */
- function LodashWrapper(value, chainAll, actions) {
- this.__wrapped__ = value;
- this.__actions__ = actions || [];
- this.__chain__ = !!chainAll;
- }
- LodashWrapper.prototype = baseCreate(baseLodash.prototype);
- LodashWrapper.prototype.constructor = LodashWrapper;
- module.exports = LodashWrapper;
- },{"247":247,"264":264}],233:[function(_dereq_,module,exports){
- (function (global){
- var cachePush = _dereq_(282),
- getNative = _dereq_(306);
- /** Native method references. */
- var Set = getNative(global, 'Set');
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeCreate = getNative(Object, 'create');
- /**
- *
- * Creates a cache object to store unique values.
- *
- * @private
- * @param {Array} [values] The values to cache.
- */
- function SetCache(values) {
- var length = values ? values.length : 0;
- this.data = { 'hash': nativeCreate(null), 'set': new Set };
- while (length--) {
- this.push(values[length]);
- }
- }
- // Add functions to the `Set` cache.
- SetCache.prototype.push = cachePush;
- module.exports = SetCache;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvU2V0Q2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsImZpbGUiOiJnZW5lcmF0ZWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlc0NvbnRlbnQiOlsidmFyIGNhY2hlUHVzaCA9IHJlcXVpcmUoJy4vY2FjaGVQdXNoJyksXG4gICAgZ2V0TmF0aXZlID0gcmVxdWlyZSgnLi9nZXROYXRpdmUnKTtcblxuLyoqIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcy4gKi9cbnZhciBTZXQgPSBnZXROYXRpdmUoZ2xvYmFsLCAnU2V0Jyk7XG5cbi8qIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcyBmb3IgdGhvc2Ugd2l0aCB0aGUgc2FtZSBuYW1lIGFzIG90aGVyIGBsb2Rhc2hgIG1ldGhvZHMuICovXG52YXIgbmF0aXZlQ3JlYXRlID0gZ2V0TmF0aXZlKE9iamVjdCwgJ2NyZWF0ZScpO1xuXG4vKipcbiAqXG4gKiBDcmVhdGVzIGEgY2FjaGUgb2JqZWN0IHRvIHN0b3JlIHVuaXF1ZSB2YWx1ZXMuXG4gKlxuICogQHByaXZhdGVcbiAqIEBwYXJhbSB7QXJyYXl9IFt2YWx1ZXNdIFRoZSB2YWx1ZXMgdG8gY2FjaGUuXG4gKi9cbmZ1bmN0aW9uIFNldENhY2hlKHZhbHVlcykge1xuICB2YXIgbGVuZ3RoID0gdmFsdWVzID8gdmFsdWVzLmxlbmd0aCA6IDA7XG5cbiAgdGhpcy5kYXRhID0geyAnaGFzaCc6IG5hdGl2ZUNyZWF0ZShudWxsKSwgJ3NldCc6IG5ldyBTZXQgfTtcbiAgd2hpbGUgKGxlbmd0aC0tKSB7XG4gICAgdGhpcy5wdXNoKHZhbHVlc1tsZW5ndGhdKTtcbiAgfVxufVxuXG4vLyBBZGQgZnVuY3Rpb25zIHRvIHRoZSBgU2V0YCBjYWNoZS5cblNldENhY2hlLnByb3RvdHlwZS5wdXNoID0gY2FjaGVQdXNoO1xuXG5tb2R1bGUuZXhwb3J0cyA9IFNldENhY2hlO1xuIl19
- },{"282":282,"306":306}],234:[function(_dereq_,module,exports){
- /**
- * Copies the values of `source` to `array`.
- *
- * @private
- * @param {Array} source The array to copy values from.
- * @param {Array} [array=[]] The array to copy values to.
- * @returns {Array} Returns `array`.
- */
- function arrayCopy(source, array) {
- var index = -1,
- length = source.length;
- array || (array = Array(length));
- while (++index < length) {
- array[index] = source[index];
- }
- return array;
- }
- module.exports = arrayCopy;
- },{}],235:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.forEach` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns `array`.
- */
- function arrayEach(array, iteratee) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (iteratee(array[index], index, array) === false) {
- break;
- }
- }
- return array;
- }
- module.exports = arrayEach;
- },{}],236:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.every` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if all elements pass the predicate check,
- * else `false`.
- */
- function arrayEvery(array, predicate) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (!predicate(array[index], index, array)) {
- return false;
- }
- }
- return true;
- }
- module.exports = arrayEvery;
- },{}],237:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.filter` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function arrayFilter(array, predicate) {
- var index = -1,
- length = array.length,
- resIndex = -1,
- result = [];
- while (++index < length) {
- var value = array[index];
- if (predicate(value, index, array)) {
- result[++resIndex] = value;
- }
- }
- return result;
- }
- module.exports = arrayFilter;
- },{}],238:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.map` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function arrayMap(array, iteratee) {
- var index = -1,
- length = array.length,
- result = Array(length);
- while (++index < length) {
- result[index] = iteratee(array[index], index, array);
- }
- return result;
- }
- module.exports = arrayMap;
- },{}],239:[function(_dereq_,module,exports){
- /**
- * Appends the elements of `values` to `array`.
- *
- * @private
- * @param {Array} array The array to modify.
- * @param {Array} values The values to append.
- * @returns {Array} Returns `array`.
- */
- function arrayPush(array, values) {
- var index = -1,
- length = values.length,
- offset = array.length;
- while (++index < length) {
- array[offset + index] = values[index];
- }
- return array;
- }
- module.exports = arrayPush;
- },{}],240:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.reduce` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} [accumulator] The initial value.
- * @param {boolean} [initFromArray] Specify using the first element of `array`
- * as the initial value.
- * @returns {*} Returns the accumulated value.
- */
- function arrayReduce(array, iteratee, accumulator, initFromArray) {
- var index = -1,
- length = array.length;
- if (initFromArray && length) {
- accumulator = array[++index];
- }
- while (++index < length) {
- accumulator = iteratee(accumulator, array[index], index, array);
- }
- return accumulator;
- }
- module.exports = arrayReduce;
- },{}],241:[function(_dereq_,module,exports){
- /**
- * A specialized version of `_.some` for arrays without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function arraySome(array, predicate) {
- var index = -1,
- length = array.length;
- while (++index < length) {
- if (predicate(array[index], index, array)) {
- return true;
- }
- }
- return false;
- }
- module.exports = arraySome;
- },{}],242:[function(_dereq_,module,exports){
- var keys = _dereq_(340);
- /**
- * A specialized version of `_.assign` for customizing assigned values without
- * support for argument juggling, multiple sources, and `this` binding `customizer`
- * functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {Function} customizer The function to customize assigned values.
- * @returns {Object} Returns `object`.
- */
- function assignWith(object, source, customizer) {
- var index = -1,
- props = keys(source),
- length = props.length;
- while (++index < length) {
- var key = props[index],
- value = object[key],
- result = customizer(value, source[key], key, object, source);
- if ((result === result ? (result !== value) : (value === value)) ||
- (value === undefined && !(key in object))) {
- object[key] = result;
- }
- }
- return object;
- }
- module.exports = assignWith;
- },{"340":340}],243:[function(_dereq_,module,exports){
- var baseCopy = _dereq_(246),
- keys = _dereq_(340);
- /**
- * The base implementation of `_.assign` without support for argument juggling,
- * multiple sources, and `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @returns {Object} Returns `object`.
- */
- function baseAssign(object, source) {
- return source == null
- ? object
- : baseCopy(source, keys(source), object);
- }
- module.exports = baseAssign;
- },{"246":246,"340":340}],244:[function(_dereq_,module,exports){
- var baseMatches = _dereq_(266),
- baseMatchesProperty = _dereq_(267),
- bindCallback = _dereq_(280),
- identity = _dereq_(348),
- property = _dereq_(350);
- /**
- * The base implementation of `_.callback` which supports specifying the
- * number of arguments to provide to `func`.
- *
- * @private
- * @param {*} [func=_.identity] The value to convert to a callback.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {number} [argCount] The number of arguments to provide to `func`.
- * @returns {Function} Returns the callback.
- */
- function baseCallback(func, thisArg, argCount) {
- var type = typeof func;
- if (type == 'function') {
- return thisArg === undefined
- ? func
- : bindCallback(func, thisArg, argCount);
- }
- if (func == null) {
- return identity;
- }
- if (type == 'object') {
- return baseMatches(func);
- }
- return thisArg === undefined
- ? property(func)
- : baseMatchesProperty(func, thisArg);
- }
- module.exports = baseCallback;
- },{"266":266,"267":267,"280":280,"348":348,"350":350}],245:[function(_dereq_,module,exports){
- /**
- * The base implementation of `compareAscending` which compares values and
- * sorts them in ascending order without guaranteeing a stable sort.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @returns {number} Returns the sort order indicator for `value`.
- */
- function baseCompareAscending(value, other) {
- if (value !== other) {
- var valIsNull = value === null,
- valIsUndef = value === undefined,
- valIsReflexive = value === value;
- var othIsNull = other === null,
- othIsUndef = other === undefined,
- othIsReflexive = other === other;
- if ((value > other && !othIsNull) || !valIsReflexive ||
- (valIsNull && !othIsUndef && othIsReflexive) ||
- (valIsUndef && othIsReflexive)) {
- return 1;
- }
- if ((value < other && !valIsNull) || !othIsReflexive ||
- (othIsNull && !valIsUndef && valIsReflexive) ||
- (othIsUndef && valIsReflexive)) {
- return -1;
- }
- }
- return 0;
- }
- module.exports = baseCompareAscending;
- },{}],246:[function(_dereq_,module,exports){
- /**
- * Copies properties of `source` to `object`.
- *
- * @private
- * @param {Object} source The object to copy properties from.
- * @param {Array} props The property names to copy.
- * @param {Object} [object={}] The object to copy properties to.
- * @returns {Object} Returns `object`.
- */
- function baseCopy(source, props, object) {
- object || (object = {});
- var index = -1,
- length = props.length;
- while (++index < length) {
- var key = props[index];
- object[key] = source[key];
- }
- return object;
- }
- module.exports = baseCopy;
- },{}],247:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /**
- * The base implementation of `_.create` without support for assigning
- * properties to the created object.
- *
- * @private
- * @param {Object} prototype The object to inherit from.
- * @returns {Object} Returns the new object.
- */
- var baseCreate = (function() {
- function object() {}
- return function(prototype) {
- if (isObject(prototype)) {
- object.prototype = prototype;
- var result = new object;
- object.prototype = undefined;
- }
- return result || {};
- };
- }());
- module.exports = baseCreate;
- },{"334":334}],248:[function(_dereq_,module,exports){
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /**
- * The base implementation of `_.delay` and `_.defer` which accepts an index
- * of where to slice the arguments to provide to `func`.
- *
- * @private
- * @param {Function} func The function to delay.
- * @param {number} wait The number of milliseconds to delay invocation.
- * @param {Object} args The arguments provide to `func`.
- * @returns {number} Returns the timer id.
- */
- function baseDelay(func, wait, args) {
- if (typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- return setTimeout(function() { func.apply(undefined, args); }, wait);
- }
- module.exports = baseDelay;
- },{}],249:[function(_dereq_,module,exports){
- var baseIndexOf = _dereq_(260),
- cacheIndexOf = _dereq_(281),
- createCache = _dereq_(291);
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
- /**
- * The base implementation of `_.difference` which accepts a single array
- * of values to exclude.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Array} values The values to exclude.
- * @returns {Array} Returns the new array of filtered values.
- */
- function baseDifference(array, values) {
- var length = array ? array.length : 0,
- result = [];
- if (!length) {
- return result;
- }
- var index = -1,
- indexOf = baseIndexOf,
- isCommon = true,
- cache = (isCommon && values.length >= LARGE_ARRAY_SIZE) ? createCache(values) : null,
- valuesLength = values.length;
- if (cache) {
- indexOf = cacheIndexOf;
- isCommon = false;
- values = cache;
- }
- outer:
- while (++index < length) {
- var value = array[index];
- if (isCommon && value === value) {
- var valuesIndex = valuesLength;
- while (valuesIndex--) {
- if (values[valuesIndex] === value) {
- continue outer;
- }
- }
- result.push(value);
- }
- else if (indexOf(values, value, 0) < 0) {
- result.push(value);
- }
- }
- return result;
- }
- module.exports = baseDifference;
- },{"260":260,"281":281,"291":291}],250:[function(_dereq_,module,exports){
- var baseForOwn = _dereq_(258),
- createBaseEach = _dereq_(288);
- /**
- * The base implementation of `_.forEach` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array|Object|string} Returns `collection`.
- */
- var baseEach = createBaseEach(baseForOwn);
- module.exports = baseEach;
- },{"258":258,"288":288}],251:[function(_dereq_,module,exports){
- var baseEach = _dereq_(250);
- /**
- * The base implementation of `_.every` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if all elements pass the predicate check,
- * else `false`
- */
- function baseEvery(collection, predicate) {
- var result = true;
- baseEach(collection, function(value, index, collection) {
- result = !!predicate(value, index, collection);
- return result;
- });
- return result;
- }
- module.exports = baseEvery;
- },{"250":250}],252:[function(_dereq_,module,exports){
- var baseEach = _dereq_(250);
- /**
- * The base implementation of `_.filter` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Array} Returns the new filtered array.
- */
- function baseFilter(collection, predicate) {
- var result = [];
- baseEach(collection, function(value, index, collection) {
- if (predicate(value, index, collection)) {
- result.push(value);
- }
- });
- return result;
- }
- module.exports = baseFilter;
- },{"250":250}],253:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.find`, `_.findLast`, `_.findKey`, and `_.findLastKey`,
- * without support for callback shorthands and `this` binding, which iterates
- * over `collection` using the provided `eachFunc`.
- *
- * @private
- * @param {Array|Object|string} collection The collection to search.
- * @param {Function} predicate The function invoked per iteration.
- * @param {Function} eachFunc The function to iterate over `collection`.
- * @param {boolean} [retKey] Specify returning the key of the found element
- * instead of the element itself.
- * @returns {*} Returns the found element or its key, else `undefined`.
- */
- function baseFind(collection, predicate, eachFunc, retKey) {
- var result;
- eachFunc(collection, function(value, key, collection) {
- if (predicate(value, key, collection)) {
- result = retKey ? key : value;
- return false;
- }
- });
- return result;
- }
- module.exports = baseFind;
- },{}],254:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.findIndex` and `_.findLastIndex` without
- * support for callback shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {Function} predicate The function invoked per iteration.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseFindIndex(array, predicate, fromRight) {
- var length = array.length,
- index = fromRight ? length : -1;
- while ((fromRight ? index-- : ++index < length)) {
- if (predicate(array[index], index, array)) {
- return index;
- }
- }
- return -1;
- }
- module.exports = baseFindIndex;
- },{}],255:[function(_dereq_,module,exports){
- var arrayPush = _dereq_(239),
- isArguments = _dereq_(329),
- isArray = _dereq_(330),
- isArrayLike = _dereq_(308),
- isObjectLike = _dereq_(314);
- /**
- * The base implementation of `_.flatten` with added support for restricting
- * flattening and specifying the start index.
- *
- * @private
- * @param {Array} array The array to flatten.
- * @param {boolean} [isDeep] Specify a deep flatten.
- * @param {boolean} [isStrict] Restrict flattening to arrays-like objects.
- * @param {Array} [result=[]] The initial result value.
- * @returns {Array} Returns the new flattened array.
- */
- function baseFlatten(array, isDeep, isStrict, result) {
- result || (result = []);
- var index = -1,
- length = array.length;
- while (++index < length) {
- var value = array[index];
- if (isObjectLike(value) && isArrayLike(value) &&
- (isStrict || isArray(value) || isArguments(value))) {
- if (isDeep) {
- // Recursively flatten arrays (susceptible to call stack limits).
- baseFlatten(value, isDeep, isStrict, result);
- } else {
- arrayPush(result, value);
- }
- } else if (!isStrict) {
- result[result.length] = value;
- }
- }
- return result;
- }
- module.exports = baseFlatten;
- },{"239":239,"308":308,"314":314,"329":329,"330":330}],256:[function(_dereq_,module,exports){
- var createBaseFor = _dereq_(289);
- /**
- * The base implementation of `baseForIn` and `baseForOwn` which iterates
- * over `object` properties returned by `keysFunc` invoking `iteratee` for
- * each property. Iteratee functions may exit iteration early by explicitly
- * returning `false`.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {Function} keysFunc The function to get the keys of `object`.
- * @returns {Object} Returns `object`.
- */
- var baseFor = createBaseFor();
- module.exports = baseFor;
- },{"289":289}],257:[function(_dereq_,module,exports){
- var baseFor = _dereq_(256),
- keysIn = _dereq_(341);
- /**
- * The base implementation of `_.forIn` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForIn(object, iteratee) {
- return baseFor(object, iteratee, keysIn);
- }
- module.exports = baseForIn;
- },{"256":256,"341":341}],258:[function(_dereq_,module,exports){
- var baseFor = _dereq_(256),
- keys = _dereq_(340);
- /**
- * The base implementation of `_.forOwn` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Object} Returns `object`.
- */
- function baseForOwn(object, iteratee) {
- return baseFor(object, iteratee, keys);
- }
- module.exports = baseForOwn;
- },{"256":256,"340":340}],259:[function(_dereq_,module,exports){
- var toObject = _dereq_(326);
- /**
- * The base implementation of `get` without support for string paths
- * and default values.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array} path The path of the property to get.
- * @param {string} [pathKey] The key representation of path.
- * @returns {*} Returns the resolved value.
- */
- function baseGet(object, path, pathKey) {
- if (object == null) {
- return;
- }
- if (pathKey !== undefined && pathKey in toObject(object)) {
- path = [pathKey];
- }
- var index = 0,
- length = path.length;
- while (object != null && index < length) {
- object = object[path[index++]];
- }
- return (index && index == length) ? object : undefined;
- }
- module.exports = baseGet;
- },{"326":326}],260:[function(_dereq_,module,exports){
- var indexOfNaN = _dereq_(307);
- /**
- * The base implementation of `_.indexOf` without support for binary searches.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {*} value The value to search for.
- * @param {number} fromIndex The index to search from.
- * @returns {number} Returns the index of the matched value, else `-1`.
- */
- function baseIndexOf(array, value, fromIndex) {
- if (value !== value) {
- return indexOfNaN(array, fromIndex);
- }
- var index = fromIndex - 1,
- length = array.length;
- while (++index < length) {
- if (array[index] === value) {
- return index;
- }
- }
- return -1;
- }
- module.exports = baseIndexOf;
- },{"307":307}],261:[function(_dereq_,module,exports){
- var baseIsEqualDeep = _dereq_(262),
- isObject = _dereq_(334),
- isObjectLike = _dereq_(314);
- /**
- * The base implementation of `_.isEqual` without support for `this` binding
- * `customizer` functions.
- *
- * @private
- * @param {*} value The value to compare.
- * @param {*} other The other value to compare.
- * @param {Function} [customizer] The function to customize comparing values.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
- */
- function baseIsEqual(value, other, customizer, isLoose, stackA, stackB) {
- if (value === other) {
- return true;
- }
- if (value == null || other == null || (!isObject(value) && !isObjectLike(other))) {
- return value !== value && other !== other;
- }
- return baseIsEqualDeep(value, other, baseIsEqual, customizer, isLoose, stackA, stackB);
- }
- module.exports = baseIsEqual;
- },{"262":262,"314":314,"334":334}],262:[function(_dereq_,module,exports){
- var equalArrays = _dereq_(299),
- equalByTag = _dereq_(300),
- equalObjects = _dereq_(301),
- isArray = _dereq_(330),
- isTypedArray = _dereq_(337);
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- objectTag = '[object Object]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * A specialized version of `baseIsEqual` for arrays and objects which performs
- * deep comparisons and tracks traversed objects enabling objects with circular
- * references to be compared.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing objects.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA=[]] Tracks traversed `value` objects.
- * @param {Array} [stackB=[]] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseIsEqualDeep(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var objIsArr = isArray(object),
- othIsArr = isArray(other),
- objTag = arrayTag,
- othTag = arrayTag;
- if (!objIsArr) {
- objTag = objToString.call(object);
- if (objTag == argsTag) {
- objTag = objectTag;
- } else if (objTag != objectTag) {
- objIsArr = isTypedArray(object);
- }
- }
- if (!othIsArr) {
- othTag = objToString.call(other);
- if (othTag == argsTag) {
- othTag = objectTag;
- } else if (othTag != objectTag) {
- othIsArr = isTypedArray(other);
- }
- }
- var objIsObj = objTag == objectTag,
- othIsObj = othTag == objectTag,
- isSameTag = objTag == othTag;
- if (isSameTag && !(objIsArr || objIsObj)) {
- return equalByTag(object, other, objTag);
- }
- if (!isLoose) {
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
- if (objIsWrapped || othIsWrapped) {
- return equalFunc(objIsWrapped ? object.value() : object, othIsWrapped ? other.value() : other, customizer, isLoose, stackA, stackB);
- }
- }
- if (!isSameTag) {
- return false;
- }
- // Assume cyclic values are equal.
- // For more information on detecting circular references see https://es5.github.io/#JO.
- stackA || (stackA = []);
- stackB || (stackB = []);
- var length = stackA.length;
- while (length--) {
- if (stackA[length] == object) {
- return stackB[length] == other;
- }
- }
- // Add `object` and `other` to the stack of traversed objects.
- stackA.push(object);
- stackB.push(other);
- var result = (objIsArr ? equalArrays : equalObjects)(object, other, equalFunc, customizer, isLoose, stackA, stackB);
- stackA.pop();
- stackB.pop();
- return result;
- }
- module.exports = baseIsEqualDeep;
- },{"299":299,"300":300,"301":301,"330":330,"337":337}],263:[function(_dereq_,module,exports){
- var baseIsEqual = _dereq_(261),
- toObject = _dereq_(326);
- /**
- * The base implementation of `_.isMatch` without support for callback
- * shorthands and `this` binding.
- *
- * @private
- * @param {Object} object The object to inspect.
- * @param {Array} matchData The propery names, values, and compare flags to match.
- * @param {Function} [customizer] The function to customize comparing objects.
- * @returns {boolean} Returns `true` if `object` is a match, else `false`.
- */
- function baseIsMatch(object, matchData, customizer) {
- var index = matchData.length,
- length = index,
- noCustomizer = !customizer;
- if (object == null) {
- return !length;
- }
- object = toObject(object);
- while (index--) {
- var data = matchData[index];
- if ((noCustomizer && data[2])
- ? data[1] !== object[data[0]]
- : !(data[0] in object)
- ) {
- return false;
- }
- }
- while (++index < length) {
- data = matchData[index];
- var key = data[0],
- objValue = object[key],
- srcValue = data[1];
- if (noCustomizer && data[2]) {
- if (objValue === undefined && !(key in object)) {
- return false;
- }
- } else {
- var result = customizer ? customizer(objValue, srcValue, key) : undefined;
- if (!(result === undefined ? baseIsEqual(srcValue, objValue, customizer, true) : result)) {
- return false;
- }
- }
- }
- return true;
- }
- module.exports = baseIsMatch;
- },{"261":261,"326":326}],264:[function(_dereq_,module,exports){
- /**
- * The function whose prototype all chaining wrappers inherit from.
- *
- * @private
- */
- function baseLodash() {
- // No operation performed.
- }
- module.exports = baseLodash;
- },{}],265:[function(_dereq_,module,exports){
- var baseEach = _dereq_(250),
- isArrayLike = _dereq_(308);
- /**
- * The base implementation of `_.map` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @returns {Array} Returns the new mapped array.
- */
- function baseMap(collection, iteratee) {
- var index = -1,
- result = isArrayLike(collection) ? Array(collection.length) : [];
- baseEach(collection, function(value, key, collection) {
- result[++index] = iteratee(value, key, collection);
- });
- return result;
- }
- module.exports = baseMap;
- },{"250":250,"308":308}],266:[function(_dereq_,module,exports){
- var baseIsMatch = _dereq_(263),
- getMatchData = _dereq_(305),
- toObject = _dereq_(326);
- /**
- * The base implementation of `_.matches` which does not clone `source`.
- *
- * @private
- * @param {Object} source The object of property values to match.
- * @returns {Function} Returns the new function.
- */
- function baseMatches(source) {
- var matchData = getMatchData(source);
- if (matchData.length == 1 && matchData[0][2]) {
- var key = matchData[0][0],
- value = matchData[0][1];
- return function(object) {
- if (object == null) {
- return false;
- }
- return object[key] === value && (value !== undefined || (key in toObject(object)));
- };
- }
- return function(object) {
- return baseIsMatch(object, matchData);
- };
- }
- module.exports = baseMatches;
- },{"263":263,"305":305,"326":326}],267:[function(_dereq_,module,exports){
- var baseGet = _dereq_(259),
- baseIsEqual = _dereq_(261),
- baseSlice = _dereq_(274),
- isArray = _dereq_(330),
- isKey = _dereq_(311),
- isStrictComparable = _dereq_(315),
- last = _dereq_(209),
- toObject = _dereq_(326),
- toPath = _dereq_(327);
- /**
- * The base implementation of `_.matchesProperty` which does not clone `srcValue`.
- *
- * @private
- * @param {string} path The path of the property to get.
- * @param {*} srcValue The value to compare.
- * @returns {Function} Returns the new function.
- */
- function baseMatchesProperty(path, srcValue) {
- var isArr = isArray(path),
- isCommon = isKey(path) && isStrictComparable(srcValue),
- pathKey = (path + '');
- path = toPath(path);
- return function(object) {
- if (object == null) {
- return false;
- }
- var key = pathKey;
- object = toObject(object);
- if ((isArr || !isCommon) && !(key in object)) {
- object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
- if (object == null) {
- return false;
- }
- key = last(path);
- object = toObject(object);
- }
- return object[key] === srcValue
- ? (srcValue !== undefined || (key in object))
- : baseIsEqual(srcValue, object[key], undefined, true);
- };
- }
- module.exports = baseMatchesProperty;
- },{"209":209,"259":259,"261":261,"274":274,"311":311,"315":315,"326":326,"327":327,"330":330}],268:[function(_dereq_,module,exports){
- var arrayEach = _dereq_(235),
- baseMergeDeep = _dereq_(269),
- isArray = _dereq_(330),
- isArrayLike = _dereq_(308),
- isObject = _dereq_(334),
- isObjectLike = _dereq_(314),
- isTypedArray = _dereq_(337),
- keys = _dereq_(340);
- /**
- * The base implementation of `_.merge` without support for argument juggling,
- * multiple sources, and `this` binding `customizer` functions.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {Function} [customizer] The function to customize merged values.
- * @param {Array} [stackA=[]] Tracks traversed source objects.
- * @param {Array} [stackB=[]] Associates values with source counterparts.
- * @returns {Object} Returns `object`.
- */
- function baseMerge(object, source, customizer, stackA, stackB) {
- if (!isObject(object)) {
- return object;
- }
- var isSrcArr = isArrayLike(source) && (isArray(source) || isTypedArray(source)),
- props = isSrcArr ? undefined : keys(source);
- arrayEach(props || source, function(srcValue, key) {
- if (props) {
- key = srcValue;
- srcValue = source[key];
- }
- if (isObjectLike(srcValue)) {
- stackA || (stackA = []);
- stackB || (stackB = []);
- baseMergeDeep(object, source, key, baseMerge, customizer, stackA, stackB);
- }
- else {
- var value = object[key],
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
- isCommon = result === undefined;
- if (isCommon) {
- result = srcValue;
- }
- if ((result !== undefined || (isSrcArr && !(key in object))) &&
- (isCommon || (result === result ? (result !== value) : (value === value)))) {
- object[key] = result;
- }
- }
- });
- return object;
- }
- module.exports = baseMerge;
- },{"235":235,"269":269,"308":308,"314":314,"330":330,"334":334,"337":337,"340":340}],269:[function(_dereq_,module,exports){
- var arrayCopy = _dereq_(234),
- isArguments = _dereq_(329),
- isArray = _dereq_(330),
- isArrayLike = _dereq_(308),
- isPlainObject = _dereq_(335),
- isTypedArray = _dereq_(337),
- toPlainObject = _dereq_(338);
- /**
- * A specialized version of `baseMerge` for arrays and objects which performs
- * deep merges and tracks traversed objects enabling objects with circular
- * references to be merged.
- *
- * @private
- * @param {Object} object The destination object.
- * @param {Object} source The source object.
- * @param {string} key The key of the value to merge.
- * @param {Function} mergeFunc The function to merge values.
- * @param {Function} [customizer] The function to customize merged values.
- * @param {Array} [stackA=[]] Tracks traversed source objects.
- * @param {Array} [stackB=[]] Associates values with source counterparts.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function baseMergeDeep(object, source, key, mergeFunc, customizer, stackA, stackB) {
- var length = stackA.length,
- srcValue = source[key];
- while (length--) {
- if (stackA[length] == srcValue) {
- object[key] = stackB[length];
- return;
- }
- }
- var value = object[key],
- result = customizer ? customizer(value, srcValue, key, object, source) : undefined,
- isCommon = result === undefined;
- if (isCommon) {
- result = srcValue;
- if (isArrayLike(srcValue) && (isArray(srcValue) || isTypedArray(srcValue))) {
- result = isArray(value)
- ? value
- : (isArrayLike(value) ? arrayCopy(value) : []);
- }
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
- result = isArguments(value)
- ? toPlainObject(value)
- : (isPlainObject(value) ? value : {});
- }
- else {
- isCommon = false;
- }
- }
- // Add the source value to the stack of traversed objects and associate
- // it with its merged value.
- stackA.push(srcValue);
- stackB.push(result);
- if (isCommon) {
- // Recursively merge objects and arrays (susceptible to call stack limits).
- object[key] = mergeFunc(result, srcValue, customizer, stackA, stackB);
- } else if (result === result ? (result !== value) : (value === value)) {
- object[key] = result;
- }
- }
- module.exports = baseMergeDeep;
- },{"234":234,"308":308,"329":329,"330":330,"335":335,"337":337,"338":338}],270:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.property` without support for deep paths.
- *
- * @private
- * @param {string} key The key of the property to get.
- * @returns {Function} Returns the new function.
- */
- function baseProperty(key) {
- return function(object) {
- return object == null ? undefined : object[key];
- };
- }
- module.exports = baseProperty;
- },{}],271:[function(_dereq_,module,exports){
- var baseGet = _dereq_(259),
- toPath = _dereq_(327);
- /**
- * A specialized version of `baseProperty` which supports deep paths.
- *
- * @private
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new function.
- */
- function basePropertyDeep(path) {
- var pathKey = (path + '');
- path = toPath(path);
- return function(object) {
- return baseGet(object, path, pathKey);
- };
- }
- module.exports = basePropertyDeep;
- },{"259":259,"327":327}],272:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.reduce` and `_.reduceRight` without support
- * for callback shorthands and `this` binding, which iterates over `collection`
- * using the provided `eachFunc`.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} iteratee The function invoked per iteration.
- * @param {*} accumulator The initial value.
- * @param {boolean} initFromCollection Specify using the first or last element
- * of `collection` as the initial value.
- * @param {Function} eachFunc The function to iterate over `collection`.
- * @returns {*} Returns the accumulated value.
- */
- function baseReduce(collection, iteratee, accumulator, initFromCollection, eachFunc) {
- eachFunc(collection, function(value, index, collection) {
- accumulator = initFromCollection
- ? (initFromCollection = false, value)
- : iteratee(accumulator, value, index, collection);
- });
- return accumulator;
- }
- module.exports = baseReduce;
- },{}],273:[function(_dereq_,module,exports){
- var identity = _dereq_(348),
- metaMap = _dereq_(317);
- /**
- * The base implementation of `setData` without support for hot loop detection.
- *
- * @private
- * @param {Function} func The function to associate metadata with.
- * @param {*} data The metadata.
- * @returns {Function} Returns `func`.
- */
- var baseSetData = !metaMap ? identity : function(func, data) {
- metaMap.set(func, data);
- return func;
- };
- module.exports = baseSetData;
- },{"317":317,"348":348}],274:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.slice` without an iteratee call guard.
- *
- * @private
- * @param {Array} array The array to slice.
- * @param {number} [start=0] The start position.
- * @param {number} [end=array.length] The end position.
- * @returns {Array} Returns the slice of `array`.
- */
- function baseSlice(array, start, end) {
- var index = -1,
- length = array.length;
- start = start == null ? 0 : (+start || 0);
- if (start < 0) {
- start = -start > length ? 0 : (length + start);
- }
- end = (end === undefined || end > length) ? length : (+end || 0);
- if (end < 0) {
- end += length;
- }
- length = start > end ? 0 : ((end - start) >>> 0);
- start >>>= 0;
- var result = Array(length);
- while (++index < length) {
- result[index] = array[index + start];
- }
- return result;
- }
- module.exports = baseSlice;
- },{}],275:[function(_dereq_,module,exports){
- var baseEach = _dereq_(250);
- /**
- * The base implementation of `_.some` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array|Object|string} collection The collection to iterate over.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {boolean} Returns `true` if any element passes the predicate check,
- * else `false`.
- */
- function baseSome(collection, predicate) {
- var result;
- baseEach(collection, function(value, index, collection) {
- result = predicate(value, index, collection);
- return !result;
- });
- return !!result;
- }
- module.exports = baseSome;
- },{"250":250}],276:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.sortBy` which uses `comparer` to define
- * the sort order of `array` and replaces criteria objects with their
- * corresponding values.
- *
- * @private
- * @param {Array} array The array to sort.
- * @param {Function} comparer The function to define sort order.
- * @returns {Array} Returns `array`.
- */
- function baseSortBy(array, comparer) {
- var length = array.length;
- array.sort(comparer);
- while (length--) {
- array[length] = array[length].value;
- }
- return array;
- }
- module.exports = baseSortBy;
- },{}],277:[function(_dereq_,module,exports){
- /**
- * Converts `value` to a string if it's not one. An empty string is returned
- * for `null` or `undefined` values.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {string} Returns the string.
- */
- function baseToString(value) {
- return value == null ? '' : (value + '');
- }
- module.exports = baseToString;
- },{}],278:[function(_dereq_,module,exports){
- var baseIndexOf = _dereq_(260),
- cacheIndexOf = _dereq_(281),
- createCache = _dereq_(291);
- /** Used as the size to enable large array optimizations. */
- var LARGE_ARRAY_SIZE = 200;
- /**
- * The base implementation of `_.uniq` without support for callback shorthands
- * and `this` binding.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} [iteratee] The function invoked per iteration.
- * @returns {Array} Returns the new duplicate free array.
- */
- function baseUniq(array, iteratee) {
- var index = -1,
- indexOf = baseIndexOf,
- length = array.length,
- isCommon = true,
- isLarge = isCommon && length >= LARGE_ARRAY_SIZE,
- seen = isLarge ? createCache() : null,
- result = [];
- if (seen) {
- indexOf = cacheIndexOf;
- isCommon = false;
- } else {
- isLarge = false;
- seen = iteratee ? [] : result;
- }
- outer:
- while (++index < length) {
- var value = array[index],
- computed = iteratee ? iteratee(value, index, array) : value;
- if (isCommon && value === value) {
- var seenIndex = seen.length;
- while (seenIndex--) {
- if (seen[seenIndex] === computed) {
- continue outer;
- }
- }
- if (iteratee) {
- seen.push(computed);
- }
- result.push(value);
- }
- else if (indexOf(seen, computed, 0) < 0) {
- if (iteratee || isLarge) {
- seen.push(computed);
- }
- result.push(value);
- }
- }
- return result;
- }
- module.exports = baseUniq;
- },{"260":260,"281":281,"291":291}],279:[function(_dereq_,module,exports){
- /**
- * The base implementation of `_.values` and `_.valuesIn` which creates an
- * array of `object` property values corresponding to the property names
- * of `props`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {Array} props The property names to get values for.
- * @returns {Object} Returns the array of property values.
- */
- function baseValues(object, props) {
- var index = -1,
- length = props.length,
- result = Array(length);
- while (++index < length) {
- result[index] = object[props[index]];
- }
- return result;
- }
- module.exports = baseValues;
- },{}],280:[function(_dereq_,module,exports){
- var identity = _dereq_(348);
- /**
- * A specialized version of `baseCallback` which only supports `this` binding
- * and specifying the number of arguments to provide to `func`.
- *
- * @private
- * @param {Function} func The function to bind.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {number} [argCount] The number of arguments to provide to `func`.
- * @returns {Function} Returns the callback.
- */
- function bindCallback(func, thisArg, argCount) {
- if (typeof func != 'function') {
- return identity;
- }
- if (thisArg === undefined) {
- return func;
- }
- switch (argCount) {
- case 1: return function(value) {
- return func.call(thisArg, value);
- };
- case 3: return function(value, index, collection) {
- return func.call(thisArg, value, index, collection);
- };
- case 4: return function(accumulator, value, index, collection) {
- return func.call(thisArg, accumulator, value, index, collection);
- };
- case 5: return function(value, other, key, object, source) {
- return func.call(thisArg, value, other, key, object, source);
- };
- }
- return function() {
- return func.apply(thisArg, arguments);
- };
- }
- module.exports = bindCallback;
- },{"348":348}],281:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /**
- * Checks if `value` is in `cache` mimicking the return signature of
- * `_.indexOf` by returning `0` if the value is found, else `-1`.
- *
- * @private
- * @param {Object} cache The cache to search.
- * @param {*} value The value to search for.
- * @returns {number} Returns `0` if `value` is found, else `-1`.
- */
- function cacheIndexOf(cache, value) {
- var data = cache.data,
- result = (typeof value == 'string' || isObject(value)) ? data.set.has(value) : data.hash[value];
- return result ? 0 : -1;
- }
- module.exports = cacheIndexOf;
- },{"334":334}],282:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /**
- * Adds `value` to the cache.
- *
- * @private
- * @name push
- * @memberOf SetCache
- * @param {*} value The value to cache.
- */
- function cachePush(value) {
- var data = this.data;
- if (typeof value == 'string' || isObject(value)) {
- data.set.add(value);
- } else {
- data.hash[value] = true;
- }
- }
- module.exports = cachePush;
- },{"334":334}],283:[function(_dereq_,module,exports){
- var baseCompareAscending = _dereq_(245);
- /**
- * Used by `_.sortBy` to compare transformed elements of a collection and stable
- * sort them in ascending order.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @returns {number} Returns the sort order indicator for `object`.
- */
- function compareAscending(object, other) {
- return baseCompareAscending(object.criteria, other.criteria) || (object.index - other.index);
- }
- module.exports = compareAscending;
- },{"245":245}],284:[function(_dereq_,module,exports){
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates an array that is the composition of partially applied arguments,
- * placeholders, and provided arguments into a single array of arguments.
- *
- * @private
- * @param {Array|Object} args The provided arguments.
- * @param {Array} partials The arguments to prepend to those provided.
- * @param {Array} holders The `partials` placeholder indexes.
- * @returns {Array} Returns the new array of composed arguments.
- */
- function composeArgs(args, partials, holders) {
- var holdersLength = holders.length,
- argsIndex = -1,
- argsLength = nativeMax(args.length - holdersLength, 0),
- leftIndex = -1,
- leftLength = partials.length,
- result = Array(leftLength + argsLength);
- while (++leftIndex < leftLength) {
- result[leftIndex] = partials[leftIndex];
- }
- while (++argsIndex < holdersLength) {
- result[holders[argsIndex]] = args[argsIndex];
- }
- while (argsLength--) {
- result[leftIndex++] = args[argsIndex++];
- }
- return result;
- }
- module.exports = composeArgs;
- },{}],285:[function(_dereq_,module,exports){
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * This function is like `composeArgs` except that the arguments composition
- * is tailored for `_.partialRight`.
- *
- * @private
- * @param {Array|Object} args The provided arguments.
- * @param {Array} partials The arguments to append to those provided.
- * @param {Array} holders The `partials` placeholder indexes.
- * @returns {Array} Returns the new array of composed arguments.
- */
- function composeArgsRight(args, partials, holders) {
- var holdersIndex = -1,
- holdersLength = holders.length,
- argsIndex = -1,
- argsLength = nativeMax(args.length - holdersLength, 0),
- rightIndex = -1,
- rightLength = partials.length,
- result = Array(argsLength + rightLength);
- while (++argsIndex < argsLength) {
- result[argsIndex] = args[argsIndex];
- }
- var offset = argsIndex;
- while (++rightIndex < rightLength) {
- result[offset + rightIndex] = partials[rightIndex];
- }
- while (++holdersIndex < holdersLength) {
- result[offset + holders[holdersIndex]] = args[argsIndex++];
- }
- return result;
- }
- module.exports = composeArgsRight;
- },{}],286:[function(_dereq_,module,exports){
- var baseCallback = _dereq_(244),
- baseEach = _dereq_(250),
- isArray = _dereq_(330);
- /**
- * Creates a `_.countBy`, `_.groupBy`, `_.indexBy`, or `_.partition` function.
- *
- * @private
- * @param {Function} setter The function to set keys and values of the accumulator object.
- * @param {Function} [initializer] The function to initialize the accumulator object.
- * @returns {Function} Returns the new aggregator function.
- */
- function createAggregator(setter, initializer) {
- return function(collection, iteratee, thisArg) {
- var result = initializer ? initializer() : {};
- iteratee = baseCallback(iteratee, thisArg, 3);
- if (isArray(collection)) {
- var index = -1,
- length = collection.length;
- while (++index < length) {
- var value = collection[index];
- setter(result, value, iteratee(value, index, collection), collection);
- }
- } else {
- baseEach(collection, function(value, key, collection) {
- setter(result, value, iteratee(value, key, collection), collection);
- });
- }
- return result;
- };
- }
- module.exports = createAggregator;
- },{"244":244,"250":250,"330":330}],287:[function(_dereq_,module,exports){
- var bindCallback = _dereq_(280),
- isIterateeCall = _dereq_(310),
- restParam = _dereq_(230);
- /**
- * Creates a `_.assign`, `_.defaults`, or `_.merge` function.
- *
- * @private
- * @param {Function} assigner The function to assign values.
- * @returns {Function} Returns the new assigner function.
- */
- function createAssigner(assigner) {
- return restParam(function(object, sources) {
- var index = -1,
- length = object == null ? 0 : sources.length,
- customizer = length > 2 ? sources[length - 2] : undefined,
- guard = length > 2 ? sources[2] : undefined,
- thisArg = length > 1 ? sources[length - 1] : undefined;
- if (typeof customizer == 'function') {
- customizer = bindCallback(customizer, thisArg, 5);
- length -= 2;
- } else {
- customizer = typeof thisArg == 'function' ? thisArg : undefined;
- length -= (customizer ? 1 : 0);
- }
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
- customizer = length < 3 ? undefined : customizer;
- length = 1;
- }
- while (++index < length) {
- var source = sources[index];
- if (source) {
- assigner(object, source, customizer);
- }
- }
- return object;
- });
- }
- module.exports = createAssigner;
- },{"230":230,"280":280,"310":310}],288:[function(_dereq_,module,exports){
- var getLength = _dereq_(304),
- isLength = _dereq_(313),
- toObject = _dereq_(326);
- /**
- * Creates a `baseEach` or `baseEachRight` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseEach(eachFunc, fromRight) {
- return function(collection, iteratee) {
- var length = collection ? getLength(collection) : 0;
- if (!isLength(length)) {
- return eachFunc(collection, iteratee);
- }
- var index = fromRight ? length : -1,
- iterable = toObject(collection);
- while ((fromRight ? index-- : ++index < length)) {
- if (iteratee(iterable[index], index, iterable) === false) {
- break;
- }
- }
- return collection;
- };
- }
- module.exports = createBaseEach;
- },{"304":304,"313":313,"326":326}],289:[function(_dereq_,module,exports){
- var toObject = _dereq_(326);
- /**
- * Creates a base function for `_.forIn` or `_.forInRight`.
- *
- * @private
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new base function.
- */
- function createBaseFor(fromRight) {
- return function(object, iteratee, keysFunc) {
- var iterable = toObject(object),
- props = keysFunc(object),
- length = props.length,
- index = fromRight ? length : -1;
- while ((fromRight ? index-- : ++index < length)) {
- var key = props[index];
- if (iteratee(iterable[key], key, iterable) === false) {
- break;
- }
- }
- return object;
- };
- }
- module.exports = createBaseFor;
- },{"326":326}],290:[function(_dereq_,module,exports){
- (function (global){
- var createCtorWrapper = _dereq_(292);
- /**
- * Creates a function that wraps `func` and invokes it with the `this`
- * binding of `thisArg`.
- *
- * @private
- * @param {Function} func The function to bind.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @returns {Function} Returns the new bound function.
- */
- function createBindWrapper(func, thisArg) {
- var Ctor = createCtorWrapper(func);
- function wrapper() {
- var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
- return fn.apply(thisArg, arguments);
- }
- return wrapper;
- }
- module.exports = createBindWrapper;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlQmluZFdyYXBwZXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbInZhciBjcmVhdGVDdG9yV3JhcHBlciA9IHJlcXVpcmUoJy4vY3JlYXRlQ3RvcldyYXBwZXInKTtcblxuLyoqXG4gKiBDcmVhdGVzIGEgZnVuY3Rpb24gdGhhdCB3cmFwcyBgZnVuY2AgYW5kIGludm9rZXMgaXQgd2l0aCB0aGUgYHRoaXNgXG4gKiBiaW5kaW5nIG9mIGB0aGlzQXJnYC5cbiAqXG4gKiBAcHJpdmF0ZVxuICogQHBhcmFtIHtGdW5jdGlvbn0gZnVuYyBUaGUgZnVuY3Rpb24gdG8gYmluZC5cbiAqIEBwYXJhbSB7Kn0gW3RoaXNBcmddIFRoZSBgdGhpc2AgYmluZGluZyBvZiBgZnVuY2AuXG4gKiBAcmV0dXJucyB7RnVuY3Rpb259IFJldHVybnMgdGhlIG5ldyBib3VuZCBmdW5jdGlvbi5cbiAqL1xuZnVuY3Rpb24gY3JlYXRlQmluZFdyYXBwZXIoZnVuYywgdGhpc0FyZykge1xuICB2YXIgQ3RvciA9IGNyZWF0ZUN0b3JXcmFwcGVyKGZ1bmMpO1xuXG4gIGZ1bmN0aW9uIHdyYXBwZXIoKSB7XG4gICAgdmFyIGZuID0gKHRoaXMgJiYgdGhpcyAhPT0gZ2xvYmFsICYmIHRoaXMgaW5zdGFuY2VvZiB3cmFwcGVyKSA/IEN0b3IgOiBmdW5jO1xuICAgIHJldHVybiBmbi5hcHBseSh0aGlzQXJnLCBhcmd1bWVudHMpO1xuICB9XG4gIHJldHVybiB3cmFwcGVyO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IGNyZWF0ZUJpbmRXcmFwcGVyO1xuIl19
- },{"292":292}],291:[function(_dereq_,module,exports){
- (function (global){
- var SetCache = _dereq_(233),
- getNative = _dereq_(306);
- /** Native method references. */
- var Set = getNative(global, 'Set');
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeCreate = getNative(Object, 'create');
- /**
- * Creates a `Set` cache object to optimize linear searches of large arrays.
- *
- * @private
- * @param {Array} [values] The values to cache.
- * @returns {null|Object} Returns the new cache object if `Set` is supported, else `null`.
- */
- function createCache(values) {
- return (nativeCreate && Set) ? new SetCache(values) : null;
- }
- module.exports = createCache;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlQ2FjaGUuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwiZmlsZSI6ImdlbmVyYXRlZC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzQ29udGVudCI6WyJ2YXIgU2V0Q2FjaGUgPSByZXF1aXJlKCcuL1NldENhY2hlJyksXG4gICAgZ2V0TmF0aXZlID0gcmVxdWlyZSgnLi9nZXROYXRpdmUnKTtcblxuLyoqIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcy4gKi9cbnZhciBTZXQgPSBnZXROYXRpdmUoZ2xvYmFsLCAnU2V0Jyk7XG5cbi8qIE5hdGl2ZSBtZXRob2QgcmVmZXJlbmNlcyBmb3IgdGhvc2Ugd2l0aCB0aGUgc2FtZSBuYW1lIGFzIG90aGVyIGBsb2Rhc2hgIG1ldGhvZHMuICovXG52YXIgbmF0aXZlQ3JlYXRlID0gZ2V0TmF0aXZlKE9iamVjdCwgJ2NyZWF0ZScpO1xuXG4vKipcbiAqIENyZWF0ZXMgYSBgU2V0YCBjYWNoZSBvYmplY3QgdG8gb3B0aW1pemUgbGluZWFyIHNlYXJjaGVzIG9mIGxhcmdlIGFycmF5cy5cbiAqXG4gKiBAcHJpdmF0ZVxuICogQHBhcmFtIHtBcnJheX0gW3ZhbHVlc10gVGhlIHZhbHVlcyB0byBjYWNoZS5cbiAqIEByZXR1cm5zIHtudWxsfE9iamVjdH0gUmV0dXJucyB0aGUgbmV3IGNhY2hlIG9iamVjdCBpZiBgU2V0YCBpcyBzdXBwb3J0ZWQsIGVsc2UgYG51bGxgLlxuICovXG5mdW5jdGlvbiBjcmVhdGVDYWNoZSh2YWx1ZXMpIHtcbiAgcmV0dXJuIChuYXRpdmVDcmVhdGUgJiYgU2V0KSA/IG5ldyBTZXRDYWNoZSh2YWx1ZXMpIDogbnVsbDtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBjcmVhdGVDYWNoZTtcbiJdfQ==
- },{"233":233,"306":306}],292:[function(_dereq_,module,exports){
- var baseCreate = _dereq_(247),
- isObject = _dereq_(334);
- /**
- * Creates a function that produces an instance of `Ctor` regardless of
- * whether it was invoked as part of a `new` expression or by `call` or `apply`.
- *
- * @private
- * @param {Function} Ctor The constructor to wrap.
- * @returns {Function} Returns the new wrapped function.
- */
- function createCtorWrapper(Ctor) {
- return function() {
- // Use a `switch` statement to work with class constructors.
- // See http://ecma-international.org/ecma-262/6.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
- // for more details.
- var args = arguments;
- switch (args.length) {
- case 0: return new Ctor;
- case 1: return new Ctor(args[0]);
- case 2: return new Ctor(args[0], args[1]);
- case 3: return new Ctor(args[0], args[1], args[2]);
- case 4: return new Ctor(args[0], args[1], args[2], args[3]);
- case 5: return new Ctor(args[0], args[1], args[2], args[3], args[4]);
- case 6: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
- case 7: return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
- }
- var thisBinding = baseCreate(Ctor.prototype),
- result = Ctor.apply(thisBinding, args);
- // Mimic the constructor's `return` behavior.
- // See https://es5.github.io/#x13.2.2 for more details.
- return isObject(result) ? result : thisBinding;
- };
- }
- module.exports = createCtorWrapper;
- },{"247":247,"334":334}],293:[function(_dereq_,module,exports){
- var baseCallback = _dereq_(244),
- baseFind = _dereq_(253),
- baseFindIndex = _dereq_(254),
- isArray = _dereq_(330);
- /**
- * Creates a `_.find` or `_.findLast` function.
- *
- * @private
- * @param {Function} eachFunc The function to iterate over a collection.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {Function} Returns the new find function.
- */
- function createFind(eachFunc, fromRight) {
- return function(collection, predicate, thisArg) {
- predicate = baseCallback(predicate, thisArg, 3);
- if (isArray(collection)) {
- var index = baseFindIndex(collection, predicate, fromRight);
- return index > -1 ? collection[index] : undefined;
- }
- return baseFind(collection, predicate, eachFunc);
- };
- }
- module.exports = createFind;
- },{"244":244,"253":253,"254":254,"330":330}],294:[function(_dereq_,module,exports){
- var bindCallback = _dereq_(280),
- isArray = _dereq_(330);
- /**
- * Creates a function for `_.forEach` or `_.forEachRight`.
- *
- * @private
- * @param {Function} arrayFunc The function to iterate over an array.
- * @param {Function} eachFunc The function to iterate over a collection.
- * @returns {Function} Returns the new each function.
- */
- function createForEach(arrayFunc, eachFunc) {
- return function(collection, iteratee, thisArg) {
- return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
- ? arrayFunc(collection, iteratee)
- : eachFunc(collection, bindCallback(iteratee, thisArg, 3));
- };
- }
- module.exports = createForEach;
- },{"280":280,"330":330}],295:[function(_dereq_,module,exports){
- (function (global){
- var arrayCopy = _dereq_(234),
- composeArgs = _dereq_(284),
- composeArgsRight = _dereq_(285),
- createCtorWrapper = _dereq_(292),
- isLaziable = _dereq_(312),
- reorder = _dereq_(321),
- replaceHolders = _dereq_(322),
- setData = _dereq_(323);
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1,
- BIND_KEY_FLAG = 2,
- CURRY_BOUND_FLAG = 4,
- CURRY_FLAG = 8,
- CURRY_RIGHT_FLAG = 16,
- PARTIAL_FLAG = 32,
- PARTIAL_RIGHT_FLAG = 64,
- ARY_FLAG = 128;
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a function that wraps `func` and invokes it with optional `this`
- * binding of, partial application, and currying.
- *
- * @private
- * @param {Function|string} func The function or method name to reference.
- * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {Array} [partials] The arguments to prepend to those provided to the new function.
- * @param {Array} [holders] The `partials` placeholder indexes.
- * @param {Array} [partialsRight] The arguments to append to those provided to the new function.
- * @param {Array} [holdersRight] The `partialsRight` placeholder indexes.
- * @param {Array} [argPos] The argument positions of the new function.
- * @param {number} [ary] The arity cap of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createHybridWrapper(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity) {
- var isAry = bitmask & ARY_FLAG,
- isBind = bitmask & BIND_FLAG,
- isBindKey = bitmask & BIND_KEY_FLAG,
- isCurry = bitmask & CURRY_FLAG,
- isCurryBound = bitmask & CURRY_BOUND_FLAG,
- isCurryRight = bitmask & CURRY_RIGHT_FLAG,
- Ctor = isBindKey ? undefined : createCtorWrapper(func);
- function wrapper() {
- // Avoid `arguments` object use disqualifying optimizations by
- // converting it to an array before providing it to other functions.
- var length = arguments.length,
- index = length,
- args = Array(length);
- while (index--) {
- args[index] = arguments[index];
- }
- if (partials) {
- args = composeArgs(args, partials, holders);
- }
- if (partialsRight) {
- args = composeArgsRight(args, partialsRight, holdersRight);
- }
- if (isCurry || isCurryRight) {
- var placeholder = wrapper.placeholder,
- argsHolders = replaceHolders(args, placeholder);
- length -= argsHolders.length;
- if (length < arity) {
- var newArgPos = argPos ? arrayCopy(argPos) : undefined,
- newArity = nativeMax(arity - length, 0),
- newsHolders = isCurry ? argsHolders : undefined,
- newHoldersRight = isCurry ? undefined : argsHolders,
- newPartials = isCurry ? args : undefined,
- newPartialsRight = isCurry ? undefined : args;
- bitmask |= (isCurry ? PARTIAL_FLAG : PARTIAL_RIGHT_FLAG);
- bitmask &= ~(isCurry ? PARTIAL_RIGHT_FLAG : PARTIAL_FLAG);
- if (!isCurryBound) {
- bitmask &= ~(BIND_FLAG | BIND_KEY_FLAG);
- }
- var newData = [func, bitmask, thisArg, newPartials, newsHolders, newPartialsRight, newHoldersRight, newArgPos, ary, newArity],
- result = createHybridWrapper.apply(undefined, newData);
- if (isLaziable(func)) {
- setData(result, newData);
- }
- result.placeholder = placeholder;
- return result;
- }
- }
- var thisBinding = isBind ? thisArg : this,
- fn = isBindKey ? thisBinding[func] : func;
- if (argPos) {
- args = reorder(args, argPos);
- }
- if (isAry && ary < args.length) {
- args.length = ary;
- }
- if (this && this !== global && this instanceof wrapper) {
- fn = Ctor || createCtorWrapper(func);
- }
- return fn.apply(thisBinding, args);
- }
- return wrapper;
- }
- module.exports = createHybridWrapper;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlSHlicmlkV3JhcHBlci5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbInZhciBhcnJheUNvcHkgPSByZXF1aXJlKCcuL2FycmF5Q29weScpLFxuICAgIGNvbXBvc2VBcmdzID0gcmVxdWlyZSgnLi9jb21wb3NlQXJncycpLFxuICAgIGNvbXBvc2VBcmdzUmlnaHQgPSByZXF1aXJlKCcuL2NvbXBvc2VBcmdzUmlnaHQnKSxcbiAgICBjcmVhdGVDdG9yV3JhcHBlciA9IHJlcXVpcmUoJy4vY3JlYXRlQ3RvcldyYXBwZXInKSxcbiAgICBpc0xhemlhYmxlID0gcmVxdWlyZSgnLi9pc0xhemlhYmxlJyksXG4gICAgcmVvcmRlciA9IHJlcXVpcmUoJy4vcmVvcmRlcicpLFxuICAgIHJlcGxhY2VIb2xkZXJzID0gcmVxdWlyZSgnLi9yZXBsYWNlSG9sZGVycycpLFxuICAgIHNldERhdGEgPSByZXF1aXJlKCcuL3NldERhdGEnKTtcblxuLyoqIFVzZWQgdG8gY29tcG9zZSBiaXRtYXNrcyBmb3Igd3JhcHBlciBtZXRhZGF0YS4gKi9cbnZhciBCSU5EX0ZMQUcgPSAxLFxuICAgIEJJTkRfS0VZX0ZMQUcgPSAyLFxuICAgIENVUlJZX0JPVU5EX0ZMQUcgPSA0LFxuICAgIENVUlJZX0ZMQUcgPSA4LFxuICAgIENVUlJZX1JJR0hUX0ZMQUcgPSAxNixcbiAgICBQQVJUSUFMX0ZMQUcgPSAzMixcbiAgICBQQVJUSUFMX1JJR0hUX0ZMQUcgPSA2NCxcbiAgICBBUllfRkxBRyA9IDEyODtcblxuLyogTmF0aXZlIG1ldGhvZCByZWZlcmVuY2VzIGZvciB0aG9zZSB3aXRoIHRoZSBzYW1lIG5hbWUgYXMgb3RoZXIgYGxvZGFzaGAgbWV0aG9kcy4gKi9cbnZhciBuYXRpdmVNYXggPSBNYXRoLm1heDtcblxuLyoqXG4gKiBDcmVhdGVzIGEgZnVuY3Rpb24gdGhhdCB3cmFwcyBgZnVuY2AgYW5kIGludm9rZXMgaXQgd2l0aCBvcHRpb25hbCBgdGhpc2BcbiAqIGJpbmRpbmcgb2YsIHBhcnRpYWwgYXBwbGljYXRpb24sIGFuZCBjdXJyeWluZy5cbiAqXG4gKiBAcHJpdmF0ZVxuICogQHBhcmFtIHtGdW5jdGlvbnxzdHJpbmd9IGZ1bmMgVGhlIGZ1bmN0aW9uIG9yIG1ldGhvZCBuYW1lIHRvIHJlZmVyZW5jZS5cbiAqIEBwYXJhbSB7bnVtYmVyfSBiaXRtYXNrIFRoZSBiaXRtYXNrIG9mIGZsYWdzLiBTZWUgYGNyZWF0ZVdyYXBwZXJgIGZvciBtb3JlIGRldGFpbHMuXG4gKiBAcGFyYW0geyp9IFt0aGlzQXJnXSBUaGUgYHRoaXNgIGJpbmRpbmcgb2YgYGZ1bmNgLlxuICogQHBhcmFtIHtBcnJheX0gW3BhcnRpYWxzXSBUaGUgYXJndW1lbnRzIHRvIHByZXBlbmQgdG8gdGhvc2UgcHJvdmlkZWQgdG8gdGhlIG5ldyBmdW5jdGlvbi5cbiAqIEBwYXJhbSB7QXJyYXl9IFtob2xkZXJzXSBUaGUgYHBhcnRpYWxzYCBwbGFjZWhvbGRlciBpbmRleGVzLlxuICogQHBhcmFtIHtBcnJheX0gW3BhcnRpYWxzUmlnaHRdIFRoZSBhcmd1bWVudHMgdG8gYXBwZW5kIHRvIHRob3NlIHByb3ZpZGVkIHRvIHRoZSBuZXcgZnVuY3Rpb24uXG4gKiBAcGFyYW0ge0FycmF5fSBbaG9sZGVyc1JpZ2h0XSBUaGUgYHBhcnRpYWxzUmlnaHRgIHBsYWNlaG9sZGVyIGluZGV4ZXMuXG4gKiBAcGFyYW0ge0FycmF5fSBbYXJnUG9zXSBUaGUgYXJndW1lbnQgcG9zaXRpb25zIG9mIHRoZSBuZXcgZnVuY3Rpb24uXG4gKiBAcGFyYW0ge251bWJlcn0gW2FyeV0gVGhlIGFyaXR5IGNhcCBvZiBgZnVuY2AuXG4gKiBAcGFyYW0ge251bWJlcn0gW2FyaXR5XSBUaGUgYXJpdHkgb2YgYGZ1bmNgLlxuICogQHJldHVybnMge0Z1bmN0aW9ufSBSZXR1cm5zIHRoZSBuZXcgd3JhcHBlZCBmdW5jdGlvbi5cbiAqL1xuZnVuY3Rpb24gY3JlYXRlSHlicmlkV3JhcHBlcihmdW5jLCBiaXRtYXNrLCB0aGlzQXJnLCBwYXJ0aWFscywgaG9sZGVycywgcGFydGlhbHNSaWdodCwgaG9sZGVyc1JpZ2h0LCBhcmdQb3MsIGFyeSwgYXJpdHkpIHtcbiAgdmFyIGlzQXJ5ID0gYml0bWFzayAmIEFSWV9GTEFHLFxuICAgICAgaXNCaW5kID0gYml0bWFzayAmIEJJTkRfRkxBRyxcbiAgICAgIGlzQmluZEtleSA9IGJpdG1hc2sgJiBCSU5EX0tFWV9GTEFHLFxuICAgICAgaXNDdXJyeSA9IGJpdG1hc2sgJiBDVVJSWV9GTEFHLFxuICAgICAgaXNDdXJyeUJvdW5kID0gYml0bWFzayAmIENVUlJZX0JPVU5EX0ZMQUcsXG4gICAgICBpc0N1cnJ5UmlnaHQgPSBiaXRtYXNrICYgQ1VSUllfUklHSFRfRkxBRyxcbiAgICAgIEN0b3IgPSBpc0JpbmRLZXkgPyB1bmRlZmluZWQgOiBjcmVhdGVDdG9yV3JhcHBlcihmdW5jKTtcblxuICBmdW5jdGlvbiB3cmFwcGVyKCkge1xuICAgIC8vIEF2b2lkIGBhcmd1bWVudHNgIG9iamVjdCB1c2UgZGlzcXVhbGlmeWluZyBvcHRpbWl6YXRpb25zIGJ5XG4gICAgLy8gY29udmVydGluZyBpdCB0byBhbiBhcnJheSBiZWZvcmUgcHJvdmlkaW5nIGl0IHRvIG90aGVyIGZ1bmN0aW9ucy5cbiAgICB2YXIgbGVuZ3RoID0gYXJndW1lbnRzLmxlbmd0aCxcbiAgICAgICAgaW5kZXggPSBsZW5ndGgsXG4gICAgICAgIGFyZ3MgPSBBcnJheShsZW5ndGgpO1xuXG4gICAgd2hpbGUgKGluZGV4LS0pIHtcbiAgICAgIGFyZ3NbaW5kZXhdID0gYXJndW1lbnRzW2luZGV4XTtcbiAgICB9XG4gICAgaWYgKHBhcnRpYWxzKSB7XG4gICAgICBhcmdzID0gY29tcG9zZUFyZ3MoYXJncywgcGFydGlhbHMsIGhvbGRlcnMpO1xuICAgIH1cbiAgICBpZiAocGFydGlhbHNSaWdodCkge1xuICAgICAgYXJncyA9IGNvbXBvc2VBcmdzUmlnaHQoYXJncywgcGFydGlhbHNSaWdodCwgaG9sZGVyc1JpZ2h0KTtcbiAgICB9XG4gICAgaWYgKGlzQ3VycnkgfHwgaXNDdXJyeVJpZ2h0KSB7XG4gICAgICB2YXIgcGxhY2Vob2xkZXIgPSB3cmFwcGVyLnBsYWNlaG9sZGVyLFxuICAgICAgICAgIGFyZ3NIb2xkZXJzID0gcmVwbGFjZUhvbGRlcnMoYXJncywgcGxhY2Vob2xkZXIpO1xuXG4gICAgICBsZW5ndGggLT0gYXJnc0hvbGRlcnMubGVuZ3RoO1xuICAgICAgaWYgKGxlbmd0aCA8IGFyaXR5KSB7XG4gICAgICAgIHZhciBuZXdBcmdQb3MgPSBhcmdQb3MgPyBhcnJheUNvcHkoYXJnUG9zKSA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIG5ld0FyaXR5ID0gbmF0aXZlTWF4KGFyaXR5IC0gbGVuZ3RoLCAwKSxcbiAgICAgICAgICAgIG5ld3NIb2xkZXJzID0gaXNDdXJyeSA/IGFyZ3NIb2xkZXJzIDogdW5kZWZpbmVkLFxuICAgICAgICAgICAgbmV3SG9sZGVyc1JpZ2h0ID0gaXNDdXJyeSA/IHVuZGVmaW5lZCA6IGFyZ3NIb2xkZXJzLFxuICAgICAgICAgICAgbmV3UGFydGlhbHMgPSBpc0N1cnJ5ID8gYXJncyA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIG5ld1BhcnRpYWxzUmlnaHQgPSBpc0N1cnJ5ID8gdW5kZWZpbmVkIDogYXJncztcblxuICAgICAgICBiaXRtYXNrIHw9IChpc0N1cnJ5ID8gUEFSVElBTF9GTEFHIDogUEFSVElBTF9SSUdIVF9GTEFHKTtcbiAgICAgICAgYml0bWFzayAmPSB+KGlzQ3VycnkgPyBQQVJUSUFMX1JJR0hUX0ZMQUcgOiBQQVJUSUFMX0ZMQUcpO1xuXG4gICAgICAgIGlmICghaXNDdXJyeUJvdW5kKSB7XG4gICAgICAgICAgYml0bWFzayAmPSB+KEJJTkRfRkxBRyB8IEJJTkRfS0VZX0ZMQUcpO1xuICAgICAgICB9XG4gICAgICAgIHZhciBuZXdEYXRhID0gW2Z1bmMsIGJpdG1hc2ssIHRoaXNBcmcsIG5ld1BhcnRpYWxzLCBuZXdzSG9sZGVycywgbmV3UGFydGlhbHNSaWdodCwgbmV3SG9sZGVyc1JpZ2h0LCBuZXdBcmdQb3MsIGFyeSwgbmV3QXJpdHldLFxuICAgICAgICAgICAgcmVzdWx0ID0gY3JlYXRlSHlicmlkV3JhcHBlci5hcHBseSh1bmRlZmluZWQsIG5ld0RhdGEpO1xuXG4gICAgICAgIGlmIChpc0xhemlhYmxlKGZ1bmMpKSB7XG4gICAgICAgICAgc2V0RGF0YShyZXN1bHQsIG5ld0RhdGEpO1xuICAgICAgICB9XG4gICAgICAgIHJlc3VsdC5wbGFjZWhvbGRlciA9IHBsYWNlaG9sZGVyO1xuICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgfVxuICAgIH1cbiAgICB2YXIgdGhpc0JpbmRpbmcgPSBpc0JpbmQgPyB0aGlzQXJnIDogdGhpcyxcbiAgICAgICAgZm4gPSBpc0JpbmRLZXkgPyB0aGlzQmluZGluZ1tmdW5jXSA6IGZ1bmM7XG5cbiAgICBpZiAoYXJnUG9zKSB7XG4gICAgICBhcmdzID0gcmVvcmRlcihhcmdzLCBhcmdQb3MpO1xuICAgIH1cbiAgICBpZiAoaXNBcnkgJiYgYXJ5IDwgYXJncy5sZW5ndGgpIHtcbiAgICAgIGFyZ3MubGVuZ3RoID0gYXJ5O1xuICAgIH1cbiAgICBpZiAodGhpcyAmJiB0aGlzICE9PSBnbG9iYWwgJiYgdGhpcyBpbnN0YW5jZW9mIHdyYXBwZXIpIHtcbiAgICAgIGZuID0gQ3RvciB8fCBjcmVhdGVDdG9yV3JhcHBlcihmdW5jKTtcbiAgICB9XG4gICAgcmV0dXJuIGZuLmFwcGx5KHRoaXNCaW5kaW5nLCBhcmdzKTtcbiAgfVxuICByZXR1cm4gd3JhcHBlcjtcbn1cblxubW9kdWxlLmV4cG9ydHMgPSBjcmVhdGVIeWJyaWRXcmFwcGVyO1xuIl19
- },{"234":234,"284":284,"285":285,"292":292,"312":312,"321":321,"322":322,"323":323}],296:[function(_dereq_,module,exports){
- (function (global){
- var createCtorWrapper = _dereq_(292);
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1;
- /**
- * Creates a function that wraps `func` and invokes it with the optional `this`
- * binding of `thisArg` and the `partials` prepended to those provided to
- * the wrapper.
- *
- * @private
- * @param {Function} func The function to partially apply arguments to.
- * @param {number} bitmask The bitmask of flags. See `createWrapper` for more details.
- * @param {*} thisArg The `this` binding of `func`.
- * @param {Array} partials The arguments to prepend to those provided to the new function.
- * @returns {Function} Returns the new bound function.
- */
- function createPartialWrapper(func, bitmask, thisArg, partials) {
- var isBind = bitmask & BIND_FLAG,
- Ctor = createCtorWrapper(func);
- function wrapper() {
- // Avoid `arguments` object use disqualifying optimizations by
- // converting it to an array before providing it `func`.
- var argsIndex = -1,
- argsLength = arguments.length,
- leftIndex = -1,
- leftLength = partials.length,
- args = Array(leftLength + argsLength);
- while (++leftIndex < leftLength) {
- args[leftIndex] = partials[leftIndex];
- }
- while (argsLength--) {
- args[leftIndex++] = arguments[++argsIndex];
- }
- var fn = (this && this !== global && this instanceof wrapper) ? Ctor : func;
- return fn.apply(isBind ? thisArg : this, args);
- }
- return wrapper;
- }
- module.exports = createPartialWrapper;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvY3JlYXRlUGFydGlhbFdyYXBwZXIuanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbInZhciBjcmVhdGVDdG9yV3JhcHBlciA9IHJlcXVpcmUoJy4vY3JlYXRlQ3RvcldyYXBwZXInKTtcblxuLyoqIFVzZWQgdG8gY29tcG9zZSBiaXRtYXNrcyBmb3Igd3JhcHBlciBtZXRhZGF0YS4gKi9cbnZhciBCSU5EX0ZMQUcgPSAxO1xuXG4vKipcbiAqIENyZWF0ZXMgYSBmdW5jdGlvbiB0aGF0IHdyYXBzIGBmdW5jYCBhbmQgaW52b2tlcyBpdCB3aXRoIHRoZSBvcHRpb25hbCBgdGhpc2BcbiAqIGJpbmRpbmcgb2YgYHRoaXNBcmdgIGFuZCB0aGUgYHBhcnRpYWxzYCBwcmVwZW5kZWQgdG8gdGhvc2UgcHJvdmlkZWQgdG9cbiAqIHRoZSB3cmFwcGVyLlxuICpcbiAqIEBwcml2YXRlXG4gKiBAcGFyYW0ge0Z1bmN0aW9ufSBmdW5jIFRoZSBmdW5jdGlvbiB0byBwYXJ0aWFsbHkgYXBwbHkgYXJndW1lbnRzIHRvLlxuICogQHBhcmFtIHtudW1iZXJ9IGJpdG1hc2sgVGhlIGJpdG1hc2sgb2YgZmxhZ3MuIFNlZSBgY3JlYXRlV3JhcHBlcmAgZm9yIG1vcmUgZGV0YWlscy5cbiAqIEBwYXJhbSB7Kn0gdGhpc0FyZyBUaGUgYHRoaXNgIGJpbmRpbmcgb2YgYGZ1bmNgLlxuICogQHBhcmFtIHtBcnJheX0gcGFydGlhbHMgVGhlIGFyZ3VtZW50cyB0byBwcmVwZW5kIHRvIHRob3NlIHByb3ZpZGVkIHRvIHRoZSBuZXcgZnVuY3Rpb24uXG4gKiBAcmV0dXJucyB7RnVuY3Rpb259IFJldHVybnMgdGhlIG5ldyBib3VuZCBmdW5jdGlvbi5cbiAqL1xuZnVuY3Rpb24gY3JlYXRlUGFydGlhbFdyYXBwZXIoZnVuYywgYml0bWFzaywgdGhpc0FyZywgcGFydGlhbHMpIHtcbiAgdmFyIGlzQmluZCA9IGJpdG1hc2sgJiBCSU5EX0ZMQUcsXG4gICAgICBDdG9yID0gY3JlYXRlQ3RvcldyYXBwZXIoZnVuYyk7XG5cbiAgZnVuY3Rpb24gd3JhcHBlcigpIHtcbiAgICAvLyBBdm9pZCBgYXJndW1lbnRzYCBvYmplY3QgdXNlIGRpc3F1YWxpZnlpbmcgb3B0aW1pemF0aW9ucyBieVxuICAgIC8vIGNvbnZlcnRpbmcgaXQgdG8gYW4gYXJyYXkgYmVmb3JlIHByb3ZpZGluZyBpdCBgZnVuY2AuXG4gICAgdmFyIGFyZ3NJbmRleCA9IC0xLFxuICAgICAgICBhcmdzTGVuZ3RoID0gYXJndW1lbnRzLmxlbmd0aCxcbiAgICAgICAgbGVmdEluZGV4ID0gLTEsXG4gICAgICAgIGxlZnRMZW5ndGggPSBwYXJ0aWFscy5sZW5ndGgsXG4gICAgICAgIGFyZ3MgPSBBcnJheShsZWZ0TGVuZ3RoICsgYXJnc0xlbmd0aCk7XG5cbiAgICB3aGlsZSAoKytsZWZ0SW5kZXggPCBsZWZ0TGVuZ3RoKSB7XG4gICAgICBhcmdzW2xlZnRJbmRleF0gPSBwYXJ0aWFsc1tsZWZ0SW5kZXhdO1xuICAgIH1cbiAgICB3aGlsZSAoYXJnc0xlbmd0aC0tKSB7XG4gICAgICBhcmdzW2xlZnRJbmRleCsrXSA9IGFyZ3VtZW50c1srK2FyZ3NJbmRleF07XG4gICAgfVxuICAgIHZhciBmbiA9ICh0aGlzICYmIHRoaXMgIT09IGdsb2JhbCAmJiB0aGlzIGluc3RhbmNlb2Ygd3JhcHBlcikgPyBDdG9yIDogZnVuYztcbiAgICByZXR1cm4gZm4uYXBwbHkoaXNCaW5kID8gdGhpc0FyZyA6IHRoaXMsIGFyZ3MpO1xuICB9XG4gIHJldHVybiB3cmFwcGVyO1xufVxuXG5tb2R1bGUuZXhwb3J0cyA9IGNyZWF0ZVBhcnRpYWxXcmFwcGVyO1xuIl19
- },{"292":292}],297:[function(_dereq_,module,exports){
- var baseCallback = _dereq_(244),
- baseReduce = _dereq_(272),
- isArray = _dereq_(330);
- /**
- * Creates a function for `_.reduce` or `_.reduceRight`.
- *
- * @private
- * @param {Function} arrayFunc The function to iterate over an array.
- * @param {Function} eachFunc The function to iterate over a collection.
- * @returns {Function} Returns the new each function.
- */
- function createReduce(arrayFunc, eachFunc) {
- return function(collection, iteratee, accumulator, thisArg) {
- var initFromArray = arguments.length < 3;
- return (typeof iteratee == 'function' && thisArg === undefined && isArray(collection))
- ? arrayFunc(collection, iteratee, accumulator, initFromArray)
- : baseReduce(collection, baseCallback(iteratee, thisArg, 4), accumulator, initFromArray, eachFunc);
- };
- }
- module.exports = createReduce;
- },{"244":244,"272":272,"330":330}],298:[function(_dereq_,module,exports){
- var baseSetData = _dereq_(273),
- createBindWrapper = _dereq_(290),
- createHybridWrapper = _dereq_(295),
- createPartialWrapper = _dereq_(296),
- getData = _dereq_(302),
- mergeData = _dereq_(316),
- setData = _dereq_(323);
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1,
- BIND_KEY_FLAG = 2,
- PARTIAL_FLAG = 32,
- PARTIAL_RIGHT_FLAG = 64;
- /** Used as the `TypeError` message for "Functions" methods. */
- var FUNC_ERROR_TEXT = 'Expected a function';
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMax = Math.max;
- /**
- * Creates a function that either curries or invokes `func` with optional
- * `this` binding and partially applied arguments.
- *
- * @private
- * @param {Function|string} func The function or method name to reference.
- * @param {number} bitmask The bitmask of flags.
- * The bitmask may be composed of the following flags:
- * 1 - `_.bind`
- * 2 - `_.bindKey`
- * 4 - `_.curry` or `_.curryRight` of a bound function
- * 8 - `_.curry`
- * 16 - `_.curryRight`
- * 32 - `_.partial`
- * 64 - `_.partialRight`
- * 128 - `_.rearg`
- * 256 - `_.ary`
- * @param {*} [thisArg] The `this` binding of `func`.
- * @param {Array} [partials] The arguments to be partially applied.
- * @param {Array} [holders] The `partials` placeholder indexes.
- * @param {Array} [argPos] The argument positions of the new function.
- * @param {number} [ary] The arity cap of `func`.
- * @param {number} [arity] The arity of `func`.
- * @returns {Function} Returns the new wrapped function.
- */
- function createWrapper(func, bitmask, thisArg, partials, holders, argPos, ary, arity) {
- var isBindKey = bitmask & BIND_KEY_FLAG;
- if (!isBindKey && typeof func != 'function') {
- throw new TypeError(FUNC_ERROR_TEXT);
- }
- var length = partials ? partials.length : 0;
- if (!length) {
- bitmask &= ~(PARTIAL_FLAG | PARTIAL_RIGHT_FLAG);
- partials = holders = undefined;
- }
- length -= (holders ? holders.length : 0);
- if (bitmask & PARTIAL_RIGHT_FLAG) {
- var partialsRight = partials,
- holdersRight = holders;
- partials = holders = undefined;
- }
- var data = isBindKey ? undefined : getData(func),
- newData = [func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary, arity];
- if (data) {
- mergeData(newData, data);
- bitmask = newData[1];
- arity = newData[9];
- }
- newData[9] = arity == null
- ? (isBindKey ? 0 : func.length)
- : (nativeMax(arity - length, 0) || 0);
- if (bitmask == BIND_FLAG) {
- var result = createBindWrapper(newData[0], newData[2]);
- } else if ((bitmask == PARTIAL_FLAG || bitmask == (BIND_FLAG | PARTIAL_FLAG)) && !newData[4].length) {
- result = createPartialWrapper.apply(undefined, newData);
- } else {
- result = createHybridWrapper.apply(undefined, newData);
- }
- var setter = data ? baseSetData : setData;
- return setter(result, newData);
- }
- module.exports = createWrapper;
- },{"273":273,"290":290,"295":295,"296":296,"302":302,"316":316,"323":323}],299:[function(_dereq_,module,exports){
- var arraySome = _dereq_(241);
- /**
- * A specialized version of `baseIsEqualDeep` for arrays with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Array} array The array to compare.
- * @param {Array} other The other array to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing arrays.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
- */
- function equalArrays(array, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var index = -1,
- arrLength = array.length,
- othLength = other.length;
- if (arrLength != othLength && !(isLoose && othLength > arrLength)) {
- return false;
- }
- // Ignore non-index properties.
- while (++index < arrLength) {
- var arrValue = array[index],
- othValue = other[index],
- result = customizer ? customizer(isLoose ? othValue : arrValue, isLoose ? arrValue : othValue, index) : undefined;
- if (result !== undefined) {
- if (result) {
- continue;
- }
- return false;
- }
- // Recursively compare arrays (susceptible to call stack limits).
- if (isLoose) {
- if (!arraySome(other, function(othValue) {
- return arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB);
- })) {
- return false;
- }
- } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, customizer, isLoose, stackA, stackB))) {
- return false;
- }
- }
- return true;
- }
- module.exports = equalArrays;
- },{"241":241}],300:[function(_dereq_,module,exports){
- /** `Object#toString` result references. */
- var boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- numberTag = '[object Number]',
- regexpTag = '[object RegExp]',
- stringTag = '[object String]';
- /**
- * A specialized version of `baseIsEqualDeep` for comparing objects of
- * the same `toStringTag`.
- *
- * **Note:** This function only supports comparing values with tags of
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {string} tag The `toStringTag` of the objects to compare.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalByTag(object, other, tag) {
- switch (tag) {
- case boolTag:
- case dateTag:
- // Coerce dates and booleans to numbers, dates to milliseconds and booleans
- // to `1` or `0` treating invalid dates coerced to `NaN` as not equal.
- return +object == +other;
- case errorTag:
- return object.name == other.name && object.message == other.message;
- case numberTag:
- // Treat `NaN` vs. `NaN` as equal.
- return (object != +object)
- ? other != +other
- : object == +other;
- case regexpTag:
- case stringTag:
- // Coerce regexes to strings and treat strings primitives and string
- // objects as equal. See https://es5.github.io/#x15.10.6.4 for more details.
- return object == (other + '');
- }
- return false;
- }
- module.exports = equalByTag;
- },{}],301:[function(_dereq_,module,exports){
- var keys = _dereq_(340);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * A specialized version of `baseIsEqualDeep` for objects with support for
- * partial deep comparisons.
- *
- * @private
- * @param {Object} object The object to compare.
- * @param {Object} other The other object to compare.
- * @param {Function} equalFunc The function to determine equivalents of values.
- * @param {Function} [customizer] The function to customize comparing values.
- * @param {boolean} [isLoose] Specify performing partial comparisons.
- * @param {Array} [stackA] Tracks traversed `value` objects.
- * @param {Array} [stackB] Tracks traversed `other` objects.
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
- */
- function equalObjects(object, other, equalFunc, customizer, isLoose, stackA, stackB) {
- var objProps = keys(object),
- objLength = objProps.length,
- othProps = keys(other),
- othLength = othProps.length;
- if (objLength != othLength && !isLoose) {
- return false;
- }
- var index = objLength;
- while (index--) {
- var key = objProps[index];
- if (!(isLoose ? key in other : hasOwnProperty.call(other, key))) {
- return false;
- }
- }
- var skipCtor = isLoose;
- while (++index < objLength) {
- key = objProps[index];
- var objValue = object[key],
- othValue = other[key],
- result = customizer ? customizer(isLoose ? othValue : objValue, isLoose? objValue : othValue, key) : undefined;
- // Recursively compare objects (susceptible to call stack limits).
- if (!(result === undefined ? equalFunc(objValue, othValue, customizer, isLoose, stackA, stackB) : result)) {
- return false;
- }
- skipCtor || (skipCtor = key == 'constructor');
- }
- if (!skipCtor) {
- var objCtor = object.constructor,
- othCtor = other.constructor;
- // Non `Object` object instances with different constructors are not equal.
- if (objCtor != othCtor &&
- ('constructor' in object && 'constructor' in other) &&
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
- return false;
- }
- }
- return true;
- }
- module.exports = equalObjects;
- },{"340":340}],302:[function(_dereq_,module,exports){
- var metaMap = _dereq_(317),
- noop = _dereq_(349);
- /**
- * Gets metadata for `func`.
- *
- * @private
- * @param {Function} func The function to query.
- * @returns {*} Returns the metadata for `func`.
- */
- var getData = !metaMap ? noop : function(func) {
- return metaMap.get(func);
- };
- module.exports = getData;
- },{"317":317,"349":349}],303:[function(_dereq_,module,exports){
- var realNames = _dereq_(320);
- /**
- * Gets the name of `func`.
- *
- * @private
- * @param {Function} func The function to query.
- * @returns {string} Returns the function name.
- */
- function getFuncName(func) {
- var result = (func.name + ''),
- array = realNames[result],
- length = array ? array.length : 0;
- while (length--) {
- var data = array[length],
- otherFunc = data.func;
- if (otherFunc == null || otherFunc == func) {
- return data.name;
- }
- }
- return result;
- }
- module.exports = getFuncName;
- },{"320":320}],304:[function(_dereq_,module,exports){
- var baseProperty = _dereq_(270);
- /**
- * Gets the "length" property value of `object`.
- *
- * **Note:** This function is used to avoid a [JIT bug](https://bugs.webkit.org/show_bug.cgi?id=142792)
- * that affects Safari on at least iOS 8.1-8.3 ARM64.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {*} Returns the "length" value.
- */
- var getLength = baseProperty('length');
- module.exports = getLength;
- },{"270":270}],305:[function(_dereq_,module,exports){
- var isStrictComparable = _dereq_(315),
- pairs = _dereq_(344);
- /**
- * Gets the propery names, values, and compare flags of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the match data of `object`.
- */
- function getMatchData(object) {
- var result = pairs(object),
- length = result.length;
- while (length--) {
- result[length][2] = isStrictComparable(result[length][1]);
- }
- return result;
- }
- module.exports = getMatchData;
- },{"315":315,"344":344}],306:[function(_dereq_,module,exports){
- var isNative = _dereq_(332);
- /**
- * Gets the native function at `key` of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @param {string} key The key of the method to get.
- * @returns {*} Returns the function if it's native, else `undefined`.
- */
- function getNative(object, key) {
- var value = object == null ? undefined : object[key];
- return isNative(value) ? value : undefined;
- }
- module.exports = getNative;
- },{"332":332}],307:[function(_dereq_,module,exports){
- /**
- * Gets the index at which the first occurrence of `NaN` is found in `array`.
- *
- * @private
- * @param {Array} array The array to search.
- * @param {number} fromIndex The index to search from.
- * @param {boolean} [fromRight] Specify iterating from right to left.
- * @returns {number} Returns the index of the matched `NaN`, else `-1`.
- */
- function indexOfNaN(array, fromIndex, fromRight) {
- var length = array.length,
- index = fromIndex + (fromRight ? 0 : -1);
- while ((fromRight ? index-- : ++index < length)) {
- var other = array[index];
- if (other !== other) {
- return index;
- }
- }
- return -1;
- }
- module.exports = indexOfNaN;
- },{}],308:[function(_dereq_,module,exports){
- var getLength = _dereq_(304),
- isLength = _dereq_(313);
- /**
- * Checks if `value` is array-like.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
- */
- function isArrayLike(value) {
- return value != null && isLength(getLength(value));
- }
- module.exports = isArrayLike;
- },{"304":304,"313":313}],309:[function(_dereq_,module,exports){
- /** Used to detect unsigned integer values. */
- var reIsUint = /^\d+$/;
- /**
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
- * of an array-like value.
- */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * Checks if `value` is a valid array-like index.
- *
- * @private
- * @param {*} value The value to check.
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
- */
- function isIndex(value, length) {
- value = (typeof value == 'number' || reIsUint.test(value)) ? +value : -1;
- length = length == null ? MAX_SAFE_INTEGER : length;
- return value > -1 && value % 1 == 0 && value < length;
- }
- module.exports = isIndex;
- },{}],310:[function(_dereq_,module,exports){
- var isArrayLike = _dereq_(308),
- isIndex = _dereq_(309),
- isObject = _dereq_(334);
- /**
- * Checks if the provided arguments are from an iteratee call.
- *
- * @private
- * @param {*} value The potential iteratee value argument.
- * @param {*} index The potential iteratee index or key argument.
- * @param {*} object The potential iteratee object argument.
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call, else `false`.
- */
- function isIterateeCall(value, index, object) {
- if (!isObject(object)) {
- return false;
- }
- var type = typeof index;
- if (type == 'number'
- ? (isArrayLike(object) && isIndex(index, object.length))
- : (type == 'string' && index in object)) {
- var other = object[index];
- return value === value ? (value === other) : (other !== other);
- }
- return false;
- }
- module.exports = isIterateeCall;
- },{"308":308,"309":309,"334":334}],311:[function(_dereq_,module,exports){
- var isArray = _dereq_(330),
- toObject = _dereq_(326);
- /** Used to match property names within property paths. */
- var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\n\\]|\\.)*?\1)\]/,
- reIsPlainProp = /^\w*$/;
- /**
- * Checks if `value` is a property name and not a property path.
- *
- * @private
- * @param {*} value The value to check.
- * @param {Object} [object] The object to query keys on.
- * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
- */
- function isKey(value, object) {
- var type = typeof value;
- if ((type == 'string' && reIsPlainProp.test(value)) || type == 'number') {
- return true;
- }
- if (isArray(value)) {
- return false;
- }
- var result = !reIsDeepProp.test(value);
- return result || (object != null && value in toObject(object));
- }
- module.exports = isKey;
- },{"326":326,"330":330}],312:[function(_dereq_,module,exports){
- var LazyWrapper = _dereq_(231),
- getData = _dereq_(302),
- getFuncName = _dereq_(303),
- lodash = _dereq_(213);
- /**
- * Checks if `func` has a lazy counterpart.
- *
- * @private
- * @param {Function} func The function to check.
- * @returns {boolean} Returns `true` if `func` has a lazy counterpart, else `false`.
- */
- function isLaziable(func) {
- var funcName = getFuncName(func),
- other = lodash[funcName];
- if (typeof other != 'function' || !(funcName in LazyWrapper.prototype)) {
- return false;
- }
- if (func === other) {
- return true;
- }
- var data = getData(other);
- return !!data && func === data[0];
- }
- module.exports = isLaziable;
- },{"213":213,"231":231,"302":302,"303":303}],313:[function(_dereq_,module,exports){
- /**
- * Used as the [maximum length](http://ecma-international.org/ecma-262/6.0/#sec-number.max_safe_integer)
- * of an array-like value.
- */
- var MAX_SAFE_INTEGER = 9007199254740991;
- /**
- * Checks if `value` is a valid array-like length.
- *
- * **Note:** This function is based on [`ToLength`](http://ecma-international.org/ecma-262/6.0/#sec-tolength).
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
- */
- function isLength(value) {
- return typeof value == 'number' && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
- }
- module.exports = isLength;
- },{}],314:[function(_dereq_,module,exports){
- /**
- * Checks if `value` is object-like.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
- */
- function isObjectLike(value) {
- return !!value && typeof value == 'object';
- }
- module.exports = isObjectLike;
- },{}],315:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /**
- * Checks if `value` is suitable for strict equality comparisons, i.e. `===`.
- *
- * @private
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` if suitable for strict
- * equality comparisons, else `false`.
- */
- function isStrictComparable(value) {
- return value === value && !isObject(value);
- }
- module.exports = isStrictComparable;
- },{"334":334}],316:[function(_dereq_,module,exports){
- var arrayCopy = _dereq_(234),
- composeArgs = _dereq_(284),
- composeArgsRight = _dereq_(285),
- replaceHolders = _dereq_(322);
- /** Used to compose bitmasks for wrapper metadata. */
- var BIND_FLAG = 1,
- CURRY_BOUND_FLAG = 4,
- CURRY_FLAG = 8,
- ARY_FLAG = 128,
- REARG_FLAG = 256;
- /** Used as the internal argument placeholder. */
- var PLACEHOLDER = '__lodash_placeholder__';
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMin = Math.min;
- /**
- * Merges the function metadata of `source` into `data`.
- *
- * Merging metadata reduces the number of wrappers required to invoke a function.
- * This is possible because methods like `_.bind`, `_.curry`, and `_.partial`
- * may be applied regardless of execution order. Methods like `_.ary` and `_.rearg`
- * augment function arguments, making the order in which they are executed important,
- * preventing the merging of metadata. However, we make an exception for a safe
- * common case where curried functions have `_.ary` and or `_.rearg` applied.
- *
- * @private
- * @param {Array} data The destination metadata.
- * @param {Array} source The source metadata.
- * @returns {Array} Returns `data`.
- */
- function mergeData(data, source) {
- var bitmask = data[1],
- srcBitmask = source[1],
- newBitmask = bitmask | srcBitmask,
- isCommon = newBitmask < ARY_FLAG;
- var isCombo =
- (srcBitmask == ARY_FLAG && bitmask == CURRY_FLAG) ||
- (srcBitmask == ARY_FLAG && bitmask == REARG_FLAG && data[7].length <= source[8]) ||
- (srcBitmask == (ARY_FLAG | REARG_FLAG) && bitmask == CURRY_FLAG);
- // Exit early if metadata can't be merged.
- if (!(isCommon || isCombo)) {
- return data;
- }
- // Use source `thisArg` if available.
- if (srcBitmask & BIND_FLAG) {
- data[2] = source[2];
- // Set when currying a bound function.
- newBitmask |= (bitmask & BIND_FLAG) ? 0 : CURRY_BOUND_FLAG;
- }
- // Compose partial arguments.
- var value = source[3];
- if (value) {
- var partials = data[3];
- data[3] = partials ? composeArgs(partials, value, source[4]) : arrayCopy(value);
- data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : arrayCopy(source[4]);
- }
- // Compose partial right arguments.
- value = source[5];
- if (value) {
- partials = data[5];
- data[5] = partials ? composeArgsRight(partials, value, source[6]) : arrayCopy(value);
- data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : arrayCopy(source[6]);
- }
- // Use source `argPos` if available.
- value = source[7];
- if (value) {
- data[7] = arrayCopy(value);
- }
- // Use source `ary` if it's smaller.
- if (srcBitmask & ARY_FLAG) {
- data[8] = data[8] == null ? source[8] : nativeMin(data[8], source[8]);
- }
- // Use source `arity` if one is not provided.
- if (data[9] == null) {
- data[9] = source[9];
- }
- // Use source `func` and merge bitmasks.
- data[0] = source[0];
- data[1] = newBitmask;
- return data;
- }
- module.exports = mergeData;
- },{"234":234,"284":284,"285":285,"322":322}],317:[function(_dereq_,module,exports){
- (function (global){
- var getNative = _dereq_(306);
- /** Native method references. */
- var WeakMap = getNative(global, 'WeakMap');
- /** Used to store function metadata. */
- var metaMap = WeakMap && new WeakMap;
- module.exports = metaMap;
- }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
- //# sourceMappingURL=data:application/json;charset:utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm5vZGVfbW9kdWxlcy9sb2Rhc2gvaW50ZXJuYWwvbWV0YU1hcC5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0EiLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXNDb250ZW50IjpbInZhciBnZXROYXRpdmUgPSByZXF1aXJlKCcuL2dldE5hdGl2ZScpO1xuXG4vKiogTmF0aXZlIG1ldGhvZCByZWZlcmVuY2VzLiAqL1xudmFyIFdlYWtNYXAgPSBnZXROYXRpdmUoZ2xvYmFsLCAnV2Vha01hcCcpO1xuXG4vKiogVXNlZCB0byBzdG9yZSBmdW5jdGlvbiBtZXRhZGF0YS4gKi9cbnZhciBtZXRhTWFwID0gV2Vha01hcCAmJiBuZXcgV2Vha01hcDtcblxubW9kdWxlLmV4cG9ydHMgPSBtZXRhTWFwO1xuIl19
- },{"306":306}],318:[function(_dereq_,module,exports){
- var toObject = _dereq_(326);
- /**
- * A specialized version of `_.pick` which picks `object` properties specified
- * by `props`.
- *
- * @private
- * @param {Object} object The source object.
- * @param {string[]} props The property names to pick.
- * @returns {Object} Returns the new object.
- */
- function pickByArray(object, props) {
- object = toObject(object);
- var index = -1,
- length = props.length,
- result = {};
- while (++index < length) {
- var key = props[index];
- if (key in object) {
- result[key] = object[key];
- }
- }
- return result;
- }
- module.exports = pickByArray;
- },{"326":326}],319:[function(_dereq_,module,exports){
- var baseForIn = _dereq_(257);
- /**
- * A specialized version of `_.pick` which picks `object` properties `predicate`
- * returns truthy for.
- *
- * @private
- * @param {Object} object The source object.
- * @param {Function} predicate The function invoked per iteration.
- * @returns {Object} Returns the new object.
- */
- function pickByCallback(object, predicate) {
- var result = {};
- baseForIn(object, function(value, key, object) {
- if (predicate(value, key, object)) {
- result[key] = value;
- }
- });
- return result;
- }
- module.exports = pickByCallback;
- },{"257":257}],320:[function(_dereq_,module,exports){
- /** Used to lookup unminified function names. */
- var realNames = {};
- module.exports = realNames;
- },{}],321:[function(_dereq_,module,exports){
- var arrayCopy = _dereq_(234),
- isIndex = _dereq_(309);
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeMin = Math.min;
- /**
- * Reorder `array` according to the specified indexes where the element at
- * the first index is assigned as the first element, the element at
- * the second index is assigned as the second element, and so on.
- *
- * @private
- * @param {Array} array The array to reorder.
- * @param {Array} indexes The arranged array indexes.
- * @returns {Array} Returns `array`.
- */
- function reorder(array, indexes) {
- var arrLength = array.length,
- length = nativeMin(indexes.length, arrLength),
- oldArray = arrayCopy(array);
- while (length--) {
- var index = indexes[length];
- array[length] = isIndex(index, arrLength) ? oldArray[index] : undefined;
- }
- return array;
- }
- module.exports = reorder;
- },{"234":234,"309":309}],322:[function(_dereq_,module,exports){
- /** Used as the internal argument placeholder. */
- var PLACEHOLDER = '__lodash_placeholder__';
- /**
- * Replaces all `placeholder` elements in `array` with an internal placeholder
- * and returns an array of their indexes.
- *
- * @private
- * @param {Array} array The array to modify.
- * @param {*} placeholder The placeholder to replace.
- * @returns {Array} Returns the new array of placeholder indexes.
- */
- function replaceHolders(array, placeholder) {
- var index = -1,
- length = array.length,
- resIndex = -1,
- result = [];
- while (++index < length) {
- if (array[index] === placeholder) {
- array[index] = PLACEHOLDER;
- result[++resIndex] = index;
- }
- }
- return result;
- }
- module.exports = replaceHolders;
- },{}],323:[function(_dereq_,module,exports){
- var baseSetData = _dereq_(273),
- now = _dereq_(226);
- /** Used to detect when a function becomes hot. */
- var HOT_COUNT = 150,
- HOT_SPAN = 16;
- /**
- * Sets metadata for `func`.
- *
- * **Note:** If this function becomes hot, i.e. is invoked a lot in a short
- * period of time, it will trip its breaker and transition to an identity function
- * to avoid garbage collection pauses in V8. See [V8 issue 2070](https://code.google.com/p/v8/issues/detail?id=2070)
- * for more details.
- *
- * @private
- * @param {Function} func The function to associate metadata with.
- * @param {*} data The metadata.
- * @returns {Function} Returns `func`.
- */
- var setData = (function() {
- var count = 0,
- lastCalled = 0;
- return function(key, value) {
- var stamp = now(),
- remaining = HOT_SPAN - (stamp - lastCalled);
- lastCalled = stamp;
- if (remaining > 0) {
- if (++count >= HOT_COUNT) {
- return key;
- }
- } else {
- count = 0;
- }
- return baseSetData(key, value);
- };
- }());
- module.exports = setData;
- },{"226":226,"273":273}],324:[function(_dereq_,module,exports){
- var isArguments = _dereq_(329),
- isArray = _dereq_(330),
- isIndex = _dereq_(309),
- isLength = _dereq_(313),
- keysIn = _dereq_(341);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * A fallback implementation of `Object.keys` which creates an array of the
- * own enumerable property names of `object`.
- *
- * @private
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- */
- function shimKeys(object) {
- var props = keysIn(object),
- propsLength = props.length,
- length = propsLength && object.length;
- var allowIndexes = !!length && isLength(length) &&
- (isArray(object) || isArguments(object));
- var index = -1,
- result = [];
- while (++index < propsLength) {
- var key = props[index];
- if ((allowIndexes && isIndex(key, length)) || hasOwnProperty.call(object, key)) {
- result.push(key);
- }
- }
- return result;
- }
- module.exports = shimKeys;
- },{"309":309,"313":313,"329":329,"330":330,"341":341}],325:[function(_dereq_,module,exports){
- /**
- * An implementation of `_.uniq` optimized for sorted arrays without support
- * for callback shorthands and `this` binding.
- *
- * @private
- * @param {Array} array The array to inspect.
- * @param {Function} [iteratee] The function invoked per iteration.
- * @returns {Array} Returns the new duplicate free array.
- */
- function sortedUniq(array, iteratee) {
- var seen,
- index = -1,
- length = array.length,
- resIndex = -1,
- result = [];
- while (++index < length) {
- var value = array[index],
- computed = iteratee ? iteratee(value, index, array) : value;
- if (!index || seen !== computed) {
- seen = computed;
- result[++resIndex] = value;
- }
- }
- return result;
- }
- module.exports = sortedUniq;
- },{}],326:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /**
- * Converts `value` to an object if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Object} Returns the object.
- */
- function toObject(value) {
- return isObject(value) ? value : Object(value);
- }
- module.exports = toObject;
- },{"334":334}],327:[function(_dereq_,module,exports){
- var baseToString = _dereq_(277),
- isArray = _dereq_(330);
- /** Used to match property names within property paths. */
- var rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\n\\]|\\.)*?)\2)\]/g;
- /** Used to match backslashes in property paths. */
- var reEscapeChar = /\\(\\)?/g;
- /**
- * Converts `value` to property path array if it's not one.
- *
- * @private
- * @param {*} value The value to process.
- * @returns {Array} Returns the property path array.
- */
- function toPath(value) {
- if (isArray(value)) {
- return value;
- }
- var result = [];
- baseToString(value).replace(rePropName, function(match, number, quote, string) {
- result.push(quote ? string.replace(reEscapeChar, '$1') : (number || match));
- });
- return result;
- }
- module.exports = toPath;
- },{"277":277,"330":330}],328:[function(_dereq_,module,exports){
- var LazyWrapper = _dereq_(231),
- LodashWrapper = _dereq_(232),
- arrayCopy = _dereq_(234);
- /**
- * Creates a clone of `wrapper`.
- *
- * @private
- * @param {Object} wrapper The wrapper to clone.
- * @returns {Object} Returns the cloned wrapper.
- */
- function wrapperClone(wrapper) {
- return wrapper instanceof LazyWrapper
- ? wrapper.clone()
- : new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__, arrayCopy(wrapper.__actions__));
- }
- module.exports = wrapperClone;
- },{"231":231,"232":232,"234":234}],329:[function(_dereq_,module,exports){
- var isArrayLike = _dereq_(308),
- isObjectLike = _dereq_(314);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /** Native method references. */
- var propertyIsEnumerable = objectProto.propertyIsEnumerable;
- /**
- * Checks if `value` is classified as an `arguments` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isArguments(function() { return arguments; }());
- * // => true
- *
- * _.isArguments([1, 2, 3]);
- * // => false
- */
- function isArguments(value) {
- return isObjectLike(value) && isArrayLike(value) &&
- hasOwnProperty.call(value, 'callee') && !propertyIsEnumerable.call(value, 'callee');
- }
- module.exports = isArguments;
- },{"308":308,"314":314}],330:[function(_dereq_,module,exports){
- var getNative = _dereq_(306),
- isLength = _dereq_(313),
- isObjectLike = _dereq_(314);
- /** `Object#toString` result references. */
- var arrayTag = '[object Array]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeIsArray = getNative(Array, 'isArray');
- /**
- * Checks if `value` is classified as an `Array` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isArray([1, 2, 3]);
- * // => true
- *
- * _.isArray(function() { return arguments; }());
- * // => false
- */
- var isArray = nativeIsArray || function(value) {
- return isObjectLike(value) && isLength(value.length) && objToString.call(value) == arrayTag;
- };
- module.exports = isArray;
- },{"306":306,"313":313,"314":314}],331:[function(_dereq_,module,exports){
- var isObject = _dereq_(334);
- /** `Object#toString` result references. */
- var funcTag = '[object Function]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `Function` object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isFunction(_);
- * // => true
- *
- * _.isFunction(/abc/);
- * // => false
- */
- function isFunction(value) {
- // The use of `Object#toString` avoids issues with the `typeof` operator
- // in older versions of Chrome and Safari which return 'function' for regexes
- // and Safari 8 which returns 'object' for typed array constructors.
- return isObject(value) && objToString.call(value) == funcTag;
- }
- module.exports = isFunction;
- },{"334":334}],332:[function(_dereq_,module,exports){
- var isFunction = _dereq_(331),
- isObjectLike = _dereq_(314);
- /** Used to detect host constructors (Safari > 5). */
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to resolve the decompiled source of functions. */
- var fnToString = Function.prototype.toString;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /** Used to detect if a method is native. */
- var reIsNative = RegExp('^' +
- fnToString.call(hasOwnProperty).replace(/[\\^$.*+?()[\]{}|]/g, '\\$&')
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
- );
- /**
- * Checks if `value` is a native function.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a native function, else `false`.
- * @example
- *
- * _.isNative(Array.prototype.push);
- * // => true
- *
- * _.isNative(_);
- * // => false
- */
- function isNative(value) {
- if (value == null) {
- return false;
- }
- if (isFunction(value)) {
- return reIsNative.test(fnToString.call(value));
- }
- return isObjectLike(value) && reIsHostCtor.test(value);
- }
- module.exports = isNative;
- },{"314":314,"331":331}],333:[function(_dereq_,module,exports){
- var isObjectLike = _dereq_(314);
- /** `Object#toString` result references. */
- var numberTag = '[object Number]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `Number` primitive or object.
- *
- * **Note:** To exclude `Infinity`, `-Infinity`, and `NaN`, which are classified
- * as numbers, use the `_.isFinite` method.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isNumber(8.4);
- * // => true
- *
- * _.isNumber(NaN);
- * // => true
- *
- * _.isNumber('8.4');
- * // => false
- */
- function isNumber(value) {
- return typeof value == 'number' || (isObjectLike(value) && objToString.call(value) == numberTag);
- }
- module.exports = isNumber;
- },{"314":314}],334:[function(_dereq_,module,exports){
- /**
- * Checks if `value` is the [language type](https://es5.github.io/#x8) of `Object`.
- * (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
- * @example
- *
- * _.isObject({});
- * // => true
- *
- * _.isObject([1, 2, 3]);
- * // => true
- *
- * _.isObject(1);
- * // => false
- */
- function isObject(value) {
- // Avoid a V8 JIT bug in Chrome 19-20.
- // See https://code.google.com/p/v8/issues/detail?id=2291 for more details.
- var type = typeof value;
- return !!value && (type == 'object' || type == 'function');
- }
- module.exports = isObject;
- },{}],335:[function(_dereq_,module,exports){
- var baseForIn = _dereq_(257),
- isArguments = _dereq_(329),
- isObjectLike = _dereq_(314);
- /** `Object#toString` result references. */
- var objectTag = '[object Object]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is a plain object, that is, an object created by the
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
- *
- * **Note:** This method assumes objects created by the `Object` constructor
- * have no inherited enumerable properties.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * }
- *
- * _.isPlainObject(new Foo);
- * // => false
- *
- * _.isPlainObject([1, 2, 3]);
- * // => false
- *
- * _.isPlainObject({ 'x': 0, 'y': 0 });
- * // => true
- *
- * _.isPlainObject(Object.create(null));
- * // => true
- */
- function isPlainObject(value) {
- var Ctor;
- // Exit early for non `Object` objects.
- if (!(isObjectLike(value) && objToString.call(value) == objectTag && !isArguments(value)) ||
- (!hasOwnProperty.call(value, 'constructor') && (Ctor = value.constructor, typeof Ctor == 'function' && !(Ctor instanceof Ctor)))) {
- return false;
- }
- // IE < 9 iterates inherited properties before own properties. If the first
- // iterated property is an object's own property then there are no inherited
- // enumerable properties.
- var result;
- // In most environments an object's own properties are iterated before
- // its inherited properties. If the last iterated property is an object's
- // own property then there are no inherited enumerable properties.
- baseForIn(value, function(subValue, key) {
- result = key;
- });
- return result === undefined || hasOwnProperty.call(value, result);
- }
- module.exports = isPlainObject;
- },{"257":257,"314":314,"329":329}],336:[function(_dereq_,module,exports){
- var isObjectLike = _dereq_(314);
- /** `Object#toString` result references. */
- var stringTag = '[object String]';
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a `String` primitive or object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isString('abc');
- * // => true
- *
- * _.isString(1);
- * // => false
- */
- function isString(value) {
- return typeof value == 'string' || (isObjectLike(value) && objToString.call(value) == stringTag);
- }
- module.exports = isString;
- },{"314":314}],337:[function(_dereq_,module,exports){
- var isLength = _dereq_(313),
- isObjectLike = _dereq_(314);
- /** `Object#toString` result references. */
- var argsTag = '[object Arguments]',
- arrayTag = '[object Array]',
- boolTag = '[object Boolean]',
- dateTag = '[object Date]',
- errorTag = '[object Error]',
- funcTag = '[object Function]',
- mapTag = '[object Map]',
- numberTag = '[object Number]',
- objectTag = '[object Object]',
- regexpTag = '[object RegExp]',
- setTag = '[object Set]',
- stringTag = '[object String]',
- weakMapTag = '[object WeakMap]';
- var arrayBufferTag = '[object ArrayBuffer]',
- float32Tag = '[object Float32Array]',
- float64Tag = '[object Float64Array]',
- int8Tag = '[object Int8Array]',
- int16Tag = '[object Int16Array]',
- int32Tag = '[object Int32Array]',
- uint8Tag = '[object Uint8Array]',
- uint8ClampedTag = '[object Uint8ClampedArray]',
- uint16Tag = '[object Uint16Array]',
- uint32Tag = '[object Uint32Array]';
- /** Used to identify `toStringTag` values of typed arrays. */
- var typedArrayTags = {};
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
- typedArrayTags[uint32Tag] = true;
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
- typedArrayTags[dateTag] = typedArrayTags[errorTag] =
- typedArrayTags[funcTag] = typedArrayTags[mapTag] =
- typedArrayTags[numberTag] = typedArrayTags[objectTag] =
- typedArrayTags[regexpTag] = typedArrayTags[setTag] =
- typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /**
- * Used to resolve the [`toStringTag`](http://ecma-international.org/ecma-262/6.0/#sec-object.prototype.tostring)
- * of values.
- */
- var objToString = objectProto.toString;
- /**
- * Checks if `value` is classified as a typed array.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to check.
- * @returns {boolean} Returns `true` if `value` is correctly classified, else `false`.
- * @example
- *
- * _.isTypedArray(new Uint8Array);
- * // => true
- *
- * _.isTypedArray([]);
- * // => false
- */
- function isTypedArray(value) {
- return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[objToString.call(value)];
- }
- module.exports = isTypedArray;
- },{"313":313,"314":314}],338:[function(_dereq_,module,exports){
- var baseCopy = _dereq_(246),
- keysIn = _dereq_(341);
- /**
- * Converts `value` to a plain object flattening inherited enumerable
- * properties of `value` to own properties of the plain object.
- *
- * @static
- * @memberOf _
- * @category Lang
- * @param {*} value The value to convert.
- * @returns {Object} Returns the converted plain object.
- * @example
- *
- * function Foo() {
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.assign({ 'a': 1 }, new Foo);
- * // => { 'a': 1, 'b': 2 }
- *
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
- * // => { 'a': 1, 'b': 2, 'c': 3 }
- */
- function toPlainObject(value) {
- return baseCopy(value, keysIn(value));
- }
- module.exports = toPlainObject;
- },{"246":246,"341":341}],339:[function(_dereq_,module,exports){
- var assignWith = _dereq_(242),
- baseAssign = _dereq_(243),
- createAssigner = _dereq_(287);
- /**
- * Assigns own enumerable properties of source object(s) to the destination
- * object. Subsequent sources overwrite property assignments of previous sources.
- * If `customizer` is provided it's invoked to produce the assigned values.
- * The `customizer` is bound to `thisArg` and invoked with five arguments:
- * (objectValue, sourceValue, key, object, source).
- *
- * **Note:** This method mutates `object` and is based on
- * [`Object.assign`](http://ecma-international.org/ecma-262/6.0/#sec-object.assign).
- *
- * @static
- * @memberOf _
- * @alias extend
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} [sources] The source objects.
- * @param {Function} [customizer] The function to customize assigned values.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * _.assign({ 'user': 'barney' }, { 'age': 40 }, { 'user': 'fred' });
- * // => { 'user': 'fred', 'age': 40 }
- *
- * // using a customizer callback
- * var defaults = _.partialRight(_.assign, function(value, other) {
- * return _.isUndefined(value) ? other : value;
- * });
- *
- * defaults({ 'user': 'barney' }, { 'age': 36 }, { 'user': 'fred' });
- * // => { 'user': 'barney', 'age': 36 }
- */
- var assign = createAssigner(function(object, source, customizer) {
- return customizer
- ? assignWith(object, source, customizer)
- : baseAssign(object, source);
- });
- module.exports = assign;
- },{"242":242,"243":243,"287":287}],340:[function(_dereq_,module,exports){
- var getNative = _dereq_(306),
- isArrayLike = _dereq_(308),
- isObject = _dereq_(334),
- shimKeys = _dereq_(324);
- /* Native method references for those with the same name as other `lodash` methods. */
- var nativeKeys = getNative(Object, 'keys');
- /**
- * Creates an array of the own enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects. See the
- * [ES spec](http://ecma-international.org/ecma-262/6.0/#sec-object.keys)
- * for more details.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keys(new Foo);
- * // => ['a', 'b'] (iteration order is not guaranteed)
- *
- * _.keys('hi');
- * // => ['0', '1']
- */
- var keys = !nativeKeys ? shimKeys : function(object) {
- var Ctor = object == null ? undefined : object.constructor;
- if ((typeof Ctor == 'function' && Ctor.prototype === object) ||
- (typeof object != 'function' && isArrayLike(object))) {
- return shimKeys(object);
- }
- return isObject(object) ? nativeKeys(object) : [];
- };
- module.exports = keys;
- },{"306":306,"308":308,"324":324,"334":334}],341:[function(_dereq_,module,exports){
- var isArguments = _dereq_(329),
- isArray = _dereq_(330),
- isIndex = _dereq_(309),
- isLength = _dereq_(313),
- isObject = _dereq_(334);
- /** Used for native method references. */
- var objectProto = Object.prototype;
- /** Used to check objects for own properties. */
- var hasOwnProperty = objectProto.hasOwnProperty;
- /**
- * Creates an array of the own and inherited enumerable property names of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property names.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.keysIn(new Foo);
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
- */
- function keysIn(object) {
- if (object == null) {
- return [];
- }
- if (!isObject(object)) {
- object = Object(object);
- }
- var length = object.length;
- length = (length && isLength(length) &&
- (isArray(object) || isArguments(object)) && length) || 0;
- var Ctor = object.constructor,
- index = -1,
- isProto = typeof Ctor == 'function' && Ctor.prototype === object,
- result = Array(length),
- skipIndexes = length > 0;
- while (++index < length) {
- result[index] = (index + '');
- }
- for (var key in object) {
- if (!(skipIndexes && isIndex(key, length)) &&
- !(key == 'constructor' && (isProto || !hasOwnProperty.call(object, key)))) {
- result.push(key);
- }
- }
- return result;
- }
- module.exports = keysIn;
- },{"309":309,"313":313,"329":329,"330":330,"334":334}],342:[function(_dereq_,module,exports){
- var baseMerge = _dereq_(268),
- createAssigner = _dereq_(287);
- /**
- * Recursively merges own enumerable properties of the source object(s), that
- * don't resolve to `undefined` into the destination object. Subsequent sources
- * overwrite property assignments of previous sources. If `customizer` is
- * provided it's invoked to produce the merged values of the destination and
- * source properties. If `customizer` returns `undefined` merging is handled
- * by the method instead. The `customizer` is bound to `thisArg` and invoked
- * with five arguments: (objectValue, sourceValue, key, object, source).
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The destination object.
- * @param {...Object} [sources] The source objects.
- * @param {Function} [customizer] The function to customize assigned values.
- * @param {*} [thisArg] The `this` binding of `customizer`.
- * @returns {Object} Returns `object`.
- * @example
- *
- * var users = {
- * 'data': [{ 'user': 'barney' }, { 'user': 'fred' }]
- * };
- *
- * var ages = {
- * 'data': [{ 'age': 36 }, { 'age': 40 }]
- * };
- *
- * _.merge(users, ages);
- * // => { 'data': [{ 'user': 'barney', 'age': 36 }, { 'user': 'fred', 'age': 40 }] }
- *
- * // using a customizer callback
- * var object = {
- * 'fruits': ['apple'],
- * 'vegetables': ['beet']
- * };
- *
- * var other = {
- * 'fruits': ['banana'],
- * 'vegetables': ['carrot']
- * };
- *
- * _.merge(object, other, function(a, b) {
- * if (_.isArray(a)) {
- * return a.concat(b);
- * }
- * });
- * // => { 'fruits': ['apple', 'banana'], 'vegetables': ['beet', 'carrot'] }
- */
- var merge = createAssigner(baseMerge);
- module.exports = merge;
- },{"268":268,"287":287}],343:[function(_dereq_,module,exports){
- var arrayMap = _dereq_(238),
- baseDifference = _dereq_(249),
- baseFlatten = _dereq_(255),
- bindCallback = _dereq_(280),
- keysIn = _dereq_(341),
- pickByArray = _dereq_(318),
- pickByCallback = _dereq_(319),
- restParam = _dereq_(230);
- /**
- * The opposite of `_.pick`; this method creates an object composed of the
- * own and inherited enumerable properties of `object` that are not omitted.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The source object.
- * @param {Function|...(string|string[])} [predicate] The function invoked per
- * iteration or property names to omit, specified as individual property
- * names or arrays of property names.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {Object} Returns the new object.
- * @example
- *
- * var object = { 'user': 'fred', 'age': 40 };
- *
- * _.omit(object, 'age');
- * // => { 'user': 'fred' }
- *
- * _.omit(object, _.isNumber);
- * // => { 'user': 'fred' }
- */
- var omit = restParam(function(object, props) {
- if (object == null) {
- return {};
- }
- if (typeof props[0] != 'function') {
- var props = arrayMap(baseFlatten(props), String);
- return pickByArray(object, baseDifference(keysIn(object), props));
- }
- var predicate = bindCallback(props[0], props[1], 3);
- return pickByCallback(object, function(value, key, object) {
- return !predicate(value, key, object);
- });
- });
- module.exports = omit;
- },{"230":230,"238":238,"249":249,"255":255,"280":280,"318":318,"319":319,"341":341}],344:[function(_dereq_,module,exports){
- var keys = _dereq_(340),
- toObject = _dereq_(326);
- /**
- * Creates a two dimensional array of the key-value pairs for `object`,
- * e.g. `[[key1, value1], [key2, value2]]`.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the new array of key-value pairs.
- * @example
- *
- * _.pairs({ 'barney': 36, 'fred': 40 });
- * // => [['barney', 36], ['fred', 40]] (iteration order is not guaranteed)
- */
- function pairs(object) {
- object = toObject(object);
- var index = -1,
- props = keys(object),
- length = props.length,
- result = Array(length);
- while (++index < length) {
- var key = props[index];
- result[index] = [key, object[key]];
- }
- return result;
- }
- module.exports = pairs;
- },{"326":326,"340":340}],345:[function(_dereq_,module,exports){
- var baseFlatten = _dereq_(255),
- bindCallback = _dereq_(280),
- pickByArray = _dereq_(318),
- pickByCallback = _dereq_(319),
- restParam = _dereq_(230);
- /**
- * Creates an object composed of the picked `object` properties. Property
- * names may be specified as individual arguments or as arrays of property
- * names. If `predicate` is provided it's invoked for each property of `object`
- * picking the properties `predicate` returns truthy for. The predicate is
- * bound to `thisArg` and invoked with three arguments: (value, key, object).
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The source object.
- * @param {Function|...(string|string[])} [predicate] The function invoked per
- * iteration or property names to pick, specified as individual property
- * names or arrays of property names.
- * @param {*} [thisArg] The `this` binding of `predicate`.
- * @returns {Object} Returns the new object.
- * @example
- *
- * var object = { 'user': 'fred', 'age': 40 };
- *
- * _.pick(object, 'user');
- * // => { 'user': 'fred' }
- *
- * _.pick(object, _.isString);
- * // => { 'user': 'fred' }
- */
- var pick = restParam(function(object, props) {
- if (object == null) {
- return {};
- }
- return typeof props[0] == 'function'
- ? pickByCallback(object, bindCallback(props[0], props[1], 3))
- : pickByArray(object, baseFlatten(props));
- });
- module.exports = pick;
- },{"230":230,"255":255,"280":280,"318":318,"319":319}],346:[function(_dereq_,module,exports){
- var arrayEach = _dereq_(235),
- baseCallback = _dereq_(244),
- baseCreate = _dereq_(247),
- baseForOwn = _dereq_(258),
- isArray = _dereq_(330),
- isFunction = _dereq_(331),
- isObject = _dereq_(334),
- isTypedArray = _dereq_(337);
- /**
- * An alternative to `_.reduce`; this method transforms `object` to a new
- * `accumulator` object which is the result of running each of its own enumerable
- * properties through `iteratee`, with each invocation potentially mutating
- * the `accumulator` object. The `iteratee` is bound to `thisArg` and invoked
- * with four arguments: (accumulator, value, key, object). Iteratee functions
- * may exit iteration early by explicitly returning `false`.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Array|Object} object The object to iterate over.
- * @param {Function} [iteratee=_.identity] The function invoked per iteration.
- * @param {*} [accumulator] The custom accumulator value.
- * @param {*} [thisArg] The `this` binding of `iteratee`.
- * @returns {*} Returns the accumulated value.
- * @example
- *
- * _.transform([2, 3, 4], function(result, n) {
- * result.push(n *= n);
- * return n % 2 == 0;
- * });
- * // => [4, 9]
- *
- * _.transform({ 'a': 1, 'b': 2 }, function(result, n, key) {
- * result[key] = n * 3;
- * });
- * // => { 'a': 3, 'b': 6 }
- */
- function transform(object, iteratee, accumulator, thisArg) {
- var isArr = isArray(object) || isTypedArray(object);
- iteratee = baseCallback(iteratee, thisArg, 4);
- if (accumulator == null) {
- if (isArr || isObject(object)) {
- var Ctor = object.constructor;
- if (isArr) {
- accumulator = isArray(object) ? new Ctor : [];
- } else {
- accumulator = baseCreate(isFunction(Ctor) ? Ctor.prototype : undefined);
- }
- } else {
- accumulator = {};
- }
- }
- (isArr ? arrayEach : baseForOwn)(object, function(value, index, object) {
- return iteratee(accumulator, value, index, object);
- });
- return accumulator;
- }
- module.exports = transform;
- },{"235":235,"244":244,"247":247,"258":258,"330":330,"331":331,"334":334,"337":337}],347:[function(_dereq_,module,exports){
- var baseValues = _dereq_(279),
- keys = _dereq_(340);
- /**
- * Creates an array of the own enumerable property values of `object`.
- *
- * **Note:** Non-object values are coerced to objects.
- *
- * @static
- * @memberOf _
- * @category Object
- * @param {Object} object The object to query.
- * @returns {Array} Returns the array of property values.
- * @example
- *
- * function Foo() {
- * this.a = 1;
- * this.b = 2;
- * }
- *
- * Foo.prototype.c = 3;
- *
- * _.values(new Foo);
- * // => [1, 2] (iteration order is not guaranteed)
- *
- * _.values('hi');
- * // => ['h', 'i']
- */
- function values(object) {
- return baseValues(object, keys(object));
- }
- module.exports = values;
- },{"279":279,"340":340}],348:[function(_dereq_,module,exports){
- /**
- * This method returns the first argument provided to it.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {*} value Any value.
- * @returns {*} Returns `value`.
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.identity(object) === object;
- * // => true
- */
- function identity(value) {
- return value;
- }
- module.exports = identity;
- },{}],349:[function(_dereq_,module,exports){
- /**
- * A no-operation function that returns `undefined` regardless of the
- * arguments it receives.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @example
- *
- * var object = { 'user': 'fred' };
- *
- * _.noop(object) === undefined;
- * // => true
- */
- function noop() {
- // No operation performed.
- }
- module.exports = noop;
- },{}],350:[function(_dereq_,module,exports){
- var baseProperty = _dereq_(270),
- basePropertyDeep = _dereq_(271),
- isKey = _dereq_(311);
- /**
- * Creates a function that returns the property value at `path` on a
- * given object.
- *
- * @static
- * @memberOf _
- * @category Utility
- * @param {Array|string} path The path of the property to get.
- * @returns {Function} Returns the new function.
- * @example
- *
- * var objects = [
- * { 'a': { 'b': { 'c': 2 } } },
- * { 'a': { 'b': { 'c': 1 } } }
- * ];
- *
- * _.map(objects, _.property('a.b.c'));
- * // => [2, 1]
- *
- * _.pluck(_.sortBy(objects, _.property(['a', 'b', 'c'])), 'a.b.c');
- * // => [1, 2]
- */
- function property(path) {
- return isKey(path) ? baseProperty(path) : basePropertyDeep(path);
- }
- module.exports = property;
- },{"270":270,"271":271,"311":311}],351:[function(_dereq_,module,exports){
- /**
- * Set attribute `name` to `val`, or get attr `name`.
- *
- * @param {Element} el
- * @param {String} name
- * @param {String} [val]
- * @api public
- */
- module.exports = function(el, name, val) {
- // get
- if (arguments.length == 2) {
- return el.getAttribute(name);
- }
- // remove
- if (val === null) {
- return el.removeAttribute(name);
- }
- // set
- el.setAttribute(name, val);
- return el;
- };
- },{}],352:[function(_dereq_,module,exports){
- module.exports = _dereq_(361);
- },{"361":361}],353:[function(_dereq_,module,exports){
- module.exports = function(el) {
- var c;
- while (el.childNodes.length) {
- c = el.childNodes[0];
- el.removeChild(c);
- }
- return el;
- };
- },{}],354:[function(_dereq_,module,exports){
- module.exports = _dereq_(363);
- },{"363":363}],355:[function(_dereq_,module,exports){
- module.exports = _dereq_(364);
- },{"364":364}],356:[function(_dereq_,module,exports){
- module.exports = _dereq_(368);
- },{"368":368}],357:[function(_dereq_,module,exports){
- module.exports = _dereq_(365);
- },{"365":365}],358:[function(_dereq_,module,exports){
- module.exports = _dereq_(366);
- },{"366":366}],359:[function(_dereq_,module,exports){
- module.exports = _dereq_(367);
- },{"367":367}],360:[function(_dereq_,module,exports){
- module.exports = function(el) {
- el.parentNode && el.parentNode.removeChild(el);
- };
- },{}],361:[function(_dereq_,module,exports){
- /**
- * Module dependencies.
- */
- var index = _dereq_(362);
- /**
- * Whitespace regexp.
- */
- var re = /\s+/;
- /**
- * toString reference.
- */
- var toString = Object.prototype.toString;
- /**
- * Wrap `el` in a `ClassList`.
- *
- * @param {Element} el
- * @return {ClassList}
- * @api public
- */
- module.exports = function(el){
- return new ClassList(el);
- };
- /**
- * Initialize a new ClassList for `el`.
- *
- * @param {Element} el
- * @api private
- */
- function ClassList(el) {
- if (!el || !el.nodeType) {
- throw new Error('A DOM element reference is required');
- }
- this.el = el;
- this.list = el.classList;
- }
- /**
- * Add class `name` if not already present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.add = function(name){
- // classList
- if (this.list) {
- this.list.add(name);
- return this;
- }
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (!~i) arr.push(name);
- this.el.className = arr.join(' ');
- return this;
- };
- /**
- * Remove class `name` when present, or
- * pass a regular expression to remove
- * any which match.
- *
- * @param {String|RegExp} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.remove = function(name){
- if ('[object RegExp]' == toString.call(name)) {
- return this.removeMatching(name);
- }
- // classList
- if (this.list) {
- this.list.remove(name);
- return this;
- }
- // fallback
- var arr = this.array();
- var i = index(arr, name);
- if (~i) arr.splice(i, 1);
- this.el.className = arr.join(' ');
- return this;
- };
- /**
- * Remove all classes matching `re`.
- *
- * @param {RegExp} re
- * @return {ClassList}
- * @api private
- */
- ClassList.prototype.removeMatching = function(re){
- var arr = this.array();
- for (var i = 0; i < arr.length; i++) {
- if (re.test(arr[i])) {
- this.remove(arr[i]);
- }
- }
- return this;
- };
- /**
- * Toggle class `name`, can force state via `force`.
- *
- * For browsers that support classList, but do not support `force` yet,
- * the mistake will be detected and corrected.
- *
- * @param {String} name
- * @param {Boolean} force
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.toggle = function(name, force){
- // classList
- if (this.list) {
- if ("undefined" !== typeof force) {
- if (force !== this.list.toggle(name, force)) {
- this.list.toggle(name); // toggle again to correct
- }
- } else {
- this.list.toggle(name);
- }
- return this;
- }
- // fallback
- if ("undefined" !== typeof force) {
- if (!force) {
- this.remove(name);
- } else {
- this.add(name);
- }
- } else {
- if (this.has(name)) {
- this.remove(name);
- } else {
- this.add(name);
- }
- }
- return this;
- };
- /**
- * Return an array of classes.
- *
- * @return {Array}
- * @api public
- */
- ClassList.prototype.array = function(){
- var className = this.el.getAttribute('class') || '';
- var str = className.replace(/^\s+|\s+$/g, '');
- var arr = str.split(re);
- if ('' === arr[0]) arr.shift();
- return arr;
- };
- /**
- * Check if class `name` is present.
- *
- * @param {String} name
- * @return {ClassList}
- * @api public
- */
- ClassList.prototype.has =
- ClassList.prototype.contains = function(name){
- return this.list
- ? this.list.contains(name)
- : !! ~index(this.array(), name);
- };
- },{"362":362}],362:[function(_dereq_,module,exports){
- module.exports = function(arr, obj){
- if (arr.indexOf) return arr.indexOf(obj);
- for (var i = 0; i < arr.length; ++i) {
- if (arr[i] === obj) return i;
- }
- return -1;
- };
- },{}],363:[function(_dereq_,module,exports){
- var matches = _dereq_(366)
- module.exports = function (element, selector, checkYoSelf, root) {
- element = checkYoSelf ? {parentNode: element} : element
- root = root || document
- // Make sure `element !== document` and `element != null`
- // otherwise we get an illegal invocation
- while ((element = element.parentNode) && element !== document) {
- if (matches(element, selector))
- return element
- // After `matches` on the edge case that
- // the selector matches the root
- // (when the root is not the document)
- if (element === root)
- return
- }
- }
- },{"366":366}],364:[function(_dereq_,module,exports){
- /**
- * Module dependencies.
- */
- var closest = _dereq_(363)
- , event = _dereq_(365);
- /**
- * Delegate event `type` to `selector`
- * and invoke `fn(e)`. A callback function
- * is returned which may be passed to `.unbind()`.
- *
- * @param {Element} el
- * @param {String} selector
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.bind = function(el, selector, type, fn, capture){
- return event.bind(el, type, function(e){
- var target = e.target || e.srcElement;
- e.delegateTarget = closest(target, selector, true, el);
- if (e.delegateTarget) fn.call(el, e);
- }, capture);
- };
- /**
- * Unbind event `type`'s callback `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @api public
- */
- exports.unbind = function(el, type, fn, capture){
- event.unbind(el, type, fn, capture);
- };
- },{"363":363,"365":365}],365:[function(_dereq_,module,exports){
- var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
- unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
- prefix = bind !== 'addEventListener' ? 'on' : '';
- /**
- * Bind `el` event `type` to `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.bind = function(el, type, fn, capture){
- el[bind](prefix + type, fn, capture || false);
- return fn;
- };
- /**
- * Unbind `el` event `type`'s callback `fn`.
- *
- * @param {Element} el
- * @param {String} type
- * @param {Function} fn
- * @param {Boolean} capture
- * @return {Function}
- * @api public
- */
- exports.unbind = function(el, type, fn, capture){
- el[unbind](prefix + type, fn, capture || false);
- return fn;
- };
- },{}],366:[function(_dereq_,module,exports){
- /**
- * Module dependencies.
- */
- var query = _dereq_(367);
- /**
- * Element prototype.
- */
- var proto = Element.prototype;
- /**
- * Vendor function.
- */
- var vendor = proto.matches
- || proto.webkitMatchesSelector
- || proto.mozMatchesSelector
- || proto.msMatchesSelector
- || proto.oMatchesSelector;
- /**
- * Expose `match()`.
- */
- module.exports = match;
- /**
- * Match `el` to `selector`.
- *
- * @param {Element} el
- * @param {String} selector
- * @return {Boolean}
- * @api public
- */
- function match(el, selector) {
- if (!el || el.nodeType !== 1) return false;
- if (vendor) return vendor.call(el, selector);
- var nodes = query.all(selector, el.parentNode);
- for (var i = 0; i < nodes.length; ++i) {
- if (nodes[i] == el) return true;
- }
- return false;
- }
- },{"367":367}],367:[function(_dereq_,module,exports){
- function one(selector, el) {
- return el.querySelector(selector);
- }
- exports = module.exports = function(selector, el){
- el = el || document;
- return one(selector, el);
- };
- exports.all = function(selector, el){
- el = el || document;
- return el.querySelectorAll(selector);
- };
- exports.engine = function(obj){
- if (!obj.one) throw new Error('.one callback required');
- if (!obj.all) throw new Error('.all callback required');
- one = obj.one;
- exports.all = obj.all;
- return exports;
- };
- },{}],368:[function(_dereq_,module,exports){
- /**
- * Expose `parse`.
- */
- module.exports = parse;
- /**
- * Tests for browser support.
- */
- var div = document.createElement('div');
- // Setup
- div.innerHTML = ' <link/><table></table><a href="/a">a</a><input type="checkbox"/>';
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- var innerHTMLBug = !div.getElementsByTagName('link').length;
- div = undefined;
- /**
- * Wrap map from jquery.
- */
- var map = {
- legend: [1, '<fieldset>', '</fieldset>'],
- tr: [2, '<table><tbody>', '</tbody></table>'],
- col: [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
- // for script/link/style tags to work in IE6-8, you have to wrap
- // in a div with a non-whitespace character in front, ha!
- _default: innerHTMLBug ? [1, 'X<div>', '</div>'] : [0, '', '']
- };
- map.td =
- map.th = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
- map.option =
- map.optgroup = [1, '<select multiple="multiple">', '</select>'];
- map.thead =
- map.tbody =
- map.colgroup =
- map.caption =
- map.tfoot = [1, '<table>', '</table>'];
- map.polyline =
- map.ellipse =
- map.polygon =
- map.circle =
- map.text =
- map.line =
- map.path =
- map.rect =
- map.g = [1, '<svg xmlns="http://www.w3.org/2000/svg" version="1.1">','</svg>'];
- /**
- * Parse `html` and return a DOM Node instance, which could be a TextNode,
- * HTML DOM Node of some kind (<div> for example), or a DocumentFragment
- * instance, depending on the contents of the `html` string.
- *
- * @param {String} html - HTML string to "domify"
- * @param {Document} doc - The `document` instance to create the Node for
- * @return {DOMNode} the TextNode, DOM Node, or DocumentFragment instance
- * @api private
- */
- function parse(html, doc) {
- if ('string' != typeof html) throw new TypeError('String expected');
- // default to the global `document` object
- if (!doc) doc = document;
- // tag name
- var m = /<([\w:]+)/.exec(html);
- if (!m) return doc.createTextNode(html);
- html = html.replace(/^\s+|\s+$/g, ''); // Remove leading/trailing whitespace
- var tag = m[1];
- // body support
- if (tag == 'body') {
- var el = doc.createElement('html');
- el.innerHTML = html;
- return el.removeChild(el.lastChild);
- }
- // wrap map
- var wrap = map[tag] || map._default;
- var depth = wrap[0];
- var prefix = wrap[1];
- var suffix = wrap[2];
- var el = doc.createElement('div');
- el.innerHTML = prefix + html + suffix;
- while (depth--) el = el.lastChild;
- // one element
- if (el.firstChild == el.lastChild) {
- return el.removeChild(el.firstChild);
- }
- // several elements
- var fragment = doc.createDocumentFragment();
- while (el.firstChild) {
- fragment.appendChild(el.removeChild(el.firstChild));
- }
- return fragment;
- }
- },{}],369:[function(_dereq_,module,exports){
- module.exports = _dereq_(371);
- module.exports.Collection = _dereq_(370);
- },{"370":370,"371":371}],370:[function(_dereq_,module,exports){
- 'use strict';
- /**
- * An empty collection stub. Use {@link RefsCollection.extend} to extend a
- * collection with ref semantics.
- *
- * @classdesc A change and inverse-reference aware collection with set semantics.
- *
- * @class RefsCollection
- */
- function RefsCollection() { }
- /**
- * Extends a collection with {@link Refs} aware methods
- *
- * @memberof RefsCollection
- * @static
- *
- * @param {Array<Object>} collection
- * @param {Refs} refs instance
- * @param {Object} property represented by the collection
- * @param {Object} target object the collection is attached to
- *
- * @return {RefsCollection<Object>} the extended array
- */
- function extend(collection, refs, property, target) {
- var inverseProperty = property.inverse;
- /**
- * Removes the given element from the array and returns it.
- *
- * @method RefsCollection#remove
- *
- * @param {Object} element the element to remove
- */
- collection.remove = function(element) {
- var idx = this.indexOf(element);
- if (idx !== -1) {
- this.splice(idx, 1);
- // unset inverse
- refs.unset(element, inverseProperty, target);
- }
- return element;
- };
- /**
- * Returns true if the collection contains the given element
- *
- * @method RefsCollection#contains
- *
- * @param {Object} element the element to check for
- */
- collection.contains = function(element) {
- return this.indexOf(element) !== -1;
- };
- /**
- * Adds an element to the array, unless it exists already (set semantics).
- *
- * @method RefsCollection#add
- *
- * @param {Object} element the element to add
- */
- collection.add = function(element) {
- if (!this.contains(element)) {
- this.push(element);
- // set inverse
- refs.set(element, inverseProperty, target);
- }
- };
- return collection;
- }
- module.exports.extend = extend;
- },{}],371:[function(_dereq_,module,exports){
- 'use strict';
- var Collection = _dereq_(370);
- function hasOwnProperty(e, property) {
- return Object.prototype.hasOwnProperty.call(e, property.name || property);
- }
- function defineCollectionProperty(ref, property, target) {
- Object.defineProperty(target, property.name, {
- enumerable: property.enumerable,
- value: Collection.extend(target[property.name] || [], ref, property, target)
- });
- }
- function defineProperty(ref, property, target) {
- var inverseProperty = property.inverse;
- var _value = target[property.name];
- Object.defineProperty(target, property.name, {
- enumerable: property.enumerable,
- get: function() {
- return _value;
- },
- set: function(value) {
- // return if we already performed all changes
- if (value === _value) {
- return;
- }
- var old = _value;
- // temporary set null
- _value = null;
- if (old) {
- ref.unset(old, inverseProperty, target);
- }
- // set new value
- _value = value;
- // set inverse value
- ref.set(_value, inverseProperty, target);
- }
- });
- }
- /**
- * Creates a new references object defining two inversly related
- * attribute descriptors a and b.
- *
- * <p>
- * When bound to an object using {@link Refs#bind} the references
- * get activated and ensure that add and remove operations are applied
- * reversely, too.
- * </p>
- *
- * <p>
- * For attributes represented as collections {@link Refs} provides the
- * {@link RefsCollection#add}, {@link RefsCollection#remove} and {@link RefsCollection#contains} extensions
- * that must be used to properly hook into the inverse change mechanism.
- * </p>
- *
- * @class Refs
- *
- * @classdesc A bi-directional reference between two attributes.
- *
- * @param {Refs.AttributeDescriptor} a property descriptor
- * @param {Refs.AttributeDescriptor} b property descriptor
- *
- * @example
- *
- * var refs = Refs({ name: 'wheels', collection: true, enumerable: true }, { name: 'car' });
- *
- * var car = { name: 'toyota' };
- * var wheels = [{ pos: 'front-left' }, { pos: 'front-right' }];
- *
- * refs.bind(car, 'wheels');
- *
- * car.wheels // []
- * car.wheels.add(wheels[0]);
- * car.wheels.add(wheels[1]);
- *
- * car.wheels // [{ pos: 'front-left' }, { pos: 'front-right' }]
- *
- * wheels[0].car // { name: 'toyota' };
- * car.wheels.remove(wheels[0]);
- *
- * wheels[0].car // undefined
- */
- function Refs(a, b) {
- if (!(this instanceof Refs)) {
- return new Refs(a, b);
- }
- // link
- a.inverse = b;
- b.inverse = a;
- this.props = {};
- this.props[a.name] = a;
- this.props[b.name] = b;
- }
- /**
- * Binds one side of a bi-directional reference to a
- * target object.
- *
- * @memberOf Refs
- *
- * @param {Object} target
- * @param {String} property
- */
- Refs.prototype.bind = function(target, property) {
- if (typeof property === 'string') {
- if (!this.props[property]) {
- throw new Error('no property <' + property + '> in ref');
- }
- property = this.props[property];
- }
- if (property.collection) {
- defineCollectionProperty(this, property, target);
- } else {
- defineProperty(this, property, target);
- }
- };
- Refs.prototype.ensureBound = function(target, property) {
- if (!hasOwnProperty(target, property)) {
- this.bind(target, property);
- }
- };
- Refs.prototype.unset = function(target, property, value) {
- if (target) {
- this.ensureBound(target, property);
- if (property.collection) {
- target[property.name].remove(value);
- } else {
- target[property.name] = undefined;
- }
- }
- };
- Refs.prototype.set = function(target, property, value) {
- if (target) {
- this.ensureBound(target, property);
- if (property.collection) {
- target[property.name].add(value);
- } else {
- target[property.name] = value;
- }
- }
- };
- module.exports = Refs;
- /**
- * An attribute descriptor to be used specify an attribute in a {@link Refs} instance
- *
- * @typedef {Object} Refs.AttributeDescriptor
- * @property {String} name
- * @property {boolean} [collection=false]
- * @property {boolean} [enumerable=false]
- */
- },{"370":370}]},{},[1])(1)
- });
- //# sourceMappingURL=bpmn-modeler.js.map
|