template.js 168 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924
  1. /**
  2. * @licstart The following is the entire license notice for the
  3. * Javascript code in this page
  4. *
  5. * Copyright 2021 Mozilla Foundation
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. * @licend The above is the entire license notice for the
  20. * Javascript code in this page
  21. */
  22. "use strict";
  23. Object.defineProperty(exports, "__esModule", {
  24. value: true
  25. });
  26. exports.Value = exports.Text = exports.TemplateNamespace = exports.Template = exports.SetProperty = exports.Items = exports.Field = exports.BindItems = void 0;
  27. var _xfa_object = require("./xfa_object.js");
  28. var _namespaces = require("./namespaces.js");
  29. var _layout = require("./layout.js");
  30. var _html_utils = require("./html_utils.js");
  31. var _utils = require("./utils.js");
  32. var _util = require("../../shared/util.js");
  33. var _fonts = require("./fonts.js");
  34. var _core_utils = require("../core_utils.js");
  35. var _som = require("./som.js");
  36. const TEMPLATE_NS_ID = _namespaces.NamespaceIds.template.id;
  37. const SVG_NS = "http://www.w3.org/2000/svg";
  38. const MAX_ATTEMPTS_FOR_LRTB_LAYOUT = 2;
  39. const MAX_EMPTY_PAGES = 3;
  40. const DEFAULT_TAB_INDEX = 5000;
  41. const HEADING_PATTERN = /^H(\d+)$/;
  42. const MIMES = new Set(["image/gif", "image/jpeg", "image/jpg", "image/pjpeg", "image/png", "image/apng", "image/x-png", "image/bmp", "image/x-ms-bmp", "image/tiff", "image/tif"]);
  43. const IMAGES_HEADERS = [[[0x42, 0x4d], "image/bmp"], [[0xff, 0xd8, 0xff], "image/jpeg"], [[0x49, 0x49, 0x2a, 0x00], "image/tiff"], [[0x4d, 0x4d, 0x00, 0x2a], "image/tiff"], [[0x47, 0x49, 0x46, 0x38, 0x39, 0x61], "image/gif"], [[0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a], "image/png"]];
  44. function getBorderDims(node) {
  45. if (!node || !node.border) {
  46. return {
  47. w: 0,
  48. h: 0
  49. };
  50. }
  51. const borderExtra = node.border[_xfa_object.$getExtra]();
  52. if (!borderExtra) {
  53. return {
  54. w: 0,
  55. h: 0
  56. };
  57. }
  58. return {
  59. w: borderExtra.widths[0] + borderExtra.widths[2] + borderExtra.insets[0] + borderExtra.insets[2],
  60. h: borderExtra.widths[1] + borderExtra.widths[3] + borderExtra.insets[1] + borderExtra.insets[3]
  61. };
  62. }
  63. function hasMargin(node) {
  64. return node.margin && (node.margin.topInset || node.margin.rightInset || node.margin.bottomInset || node.margin.leftInset);
  65. }
  66. function _setValue(templateNode, value) {
  67. if (!templateNode.value) {
  68. const nodeValue = new Value({});
  69. templateNode[_xfa_object.$appendChild](nodeValue);
  70. templateNode.value = nodeValue;
  71. }
  72. templateNode.value[_xfa_object.$setValue](value);
  73. }
  74. function* getContainedChildren(node) {
  75. for (const child of node[_xfa_object.$getChildren]()) {
  76. if (child instanceof SubformSet) {
  77. yield* child[_xfa_object.$getContainedChildren]();
  78. continue;
  79. }
  80. yield child;
  81. }
  82. }
  83. function setTabIndex(node) {
  84. while (node) {
  85. if (!node.traversal) {
  86. node[_xfa_object.$tabIndex] = node[_xfa_object.$getParent]()[_xfa_object.$tabIndex];
  87. return;
  88. }
  89. if (node[_xfa_object.$tabIndex]) {
  90. return;
  91. }
  92. let next = null;
  93. for (const child of node.traversal[_xfa_object.$getChildren]()) {
  94. if (child.operation === "next") {
  95. next = child;
  96. break;
  97. }
  98. }
  99. if (!next || !next.ref) {
  100. node[_xfa_object.$tabIndex] = node[_xfa_object.$getParent]()[_xfa_object.$tabIndex];
  101. return;
  102. }
  103. const root = node[_xfa_object.$getTemplateRoot]();
  104. node[_xfa_object.$tabIndex] = ++root[_xfa_object.$tabIndex];
  105. const ref = root[_xfa_object.$searchNode](next.ref, node);
  106. if (!ref) {
  107. return;
  108. }
  109. node = ref[0];
  110. }
  111. }
  112. function applyAssist(obj, attributes) {
  113. const assist = obj.assist;
  114. if (assist) {
  115. const assistTitle = assist[_xfa_object.$toHTML]();
  116. if (assistTitle) {
  117. attributes.title = assistTitle;
  118. }
  119. const role = assist.role;
  120. const match = role.match(HEADING_PATTERN);
  121. if (match) {
  122. const ariaRole = "heading";
  123. const ariaLevel = match[1];
  124. attributes.role = ariaRole;
  125. attributes["aria-level"] = ariaLevel;
  126. }
  127. }
  128. if (obj.layout === "table") {
  129. attributes.role = "table";
  130. } else if (obj.layout === "row") {
  131. attributes.role = "row";
  132. } else {
  133. const parent = obj[_xfa_object.$getParent]();
  134. if (parent.layout === "row") {
  135. if (parent.assist && parent.assist.role === "TH") {
  136. attributes.role = "columnheader";
  137. } else {
  138. attributes.role = "cell";
  139. }
  140. }
  141. }
  142. }
  143. function ariaLabel(obj) {
  144. if (!obj.assist) {
  145. return null;
  146. }
  147. const assist = obj.assist;
  148. if (assist.speak && assist.speak[_xfa_object.$content] !== "") {
  149. return assist.speak[_xfa_object.$content];
  150. }
  151. if (assist.toolTip) {
  152. return assist.toolTip[_xfa_object.$content];
  153. }
  154. return null;
  155. }
  156. function valueToHtml(value) {
  157. return _utils.HTMLResult.success({
  158. name: "div",
  159. attributes: {
  160. class: ["xfaRich"],
  161. style: Object.create(null)
  162. },
  163. children: [{
  164. name: "span",
  165. attributes: {
  166. style: Object.create(null)
  167. },
  168. value
  169. }]
  170. });
  171. }
  172. function setFirstUnsplittable(node) {
  173. const root = node[_xfa_object.$getTemplateRoot]();
  174. if (root[_xfa_object.$extra].firstUnsplittable === null) {
  175. root[_xfa_object.$extra].firstUnsplittable = node;
  176. root[_xfa_object.$extra].noLayoutFailure = true;
  177. }
  178. }
  179. function unsetFirstUnsplittable(node) {
  180. const root = node[_xfa_object.$getTemplateRoot]();
  181. if (root[_xfa_object.$extra].firstUnsplittable === node) {
  182. root[_xfa_object.$extra].noLayoutFailure = false;
  183. }
  184. }
  185. function handleBreak(node) {
  186. if (node[_xfa_object.$extra]) {
  187. return false;
  188. }
  189. node[_xfa_object.$extra] = Object.create(null);
  190. if (node.targetType === "auto") {
  191. return false;
  192. }
  193. const root = node[_xfa_object.$getTemplateRoot]();
  194. let target = null;
  195. if (node.target) {
  196. target = root[_xfa_object.$searchNode](node.target, node[_xfa_object.$getParent]());
  197. if (!target) {
  198. return false;
  199. }
  200. target = target[0];
  201. }
  202. const {
  203. currentPageArea,
  204. currentContentArea
  205. } = root[_xfa_object.$extra];
  206. if (node.targetType === "pageArea") {
  207. if (!(target instanceof PageArea)) {
  208. target = null;
  209. }
  210. if (node.startNew) {
  211. node[_xfa_object.$extra].target = target || currentPageArea;
  212. return true;
  213. } else if (target && target !== currentPageArea) {
  214. node[_xfa_object.$extra].target = target;
  215. return true;
  216. }
  217. return false;
  218. }
  219. if (!(target instanceof ContentArea)) {
  220. target = null;
  221. }
  222. const pageArea = target && target[_xfa_object.$getParent]();
  223. let index;
  224. if (node.startNew) {
  225. if (target) {
  226. const contentAreas = pageArea.contentArea.children;
  227. index = contentAreas.findIndex(e => e === target) - 1;
  228. } else {
  229. index = currentPageArea.contentArea.children.findIndex(e => e === currentContentArea);
  230. }
  231. } else if (target && target !== currentContentArea) {
  232. const contentAreas = pageArea.contentArea.children;
  233. index = contentAreas.findIndex(e => e === target) - 1;
  234. } else {
  235. return false;
  236. }
  237. node[_xfa_object.$extra].target = pageArea === currentPageArea ? null : pageArea;
  238. node[_xfa_object.$extra].index = index;
  239. return true;
  240. }
  241. function handleOverflow(node, extraNode, space) {
  242. const root = node[_xfa_object.$getTemplateRoot]();
  243. const saved = root[_xfa_object.$extra].noLayoutFailure;
  244. const savedMethod = extraNode[_xfa_object.$getSubformParent];
  245. extraNode[_xfa_object.$getSubformParent] = () => node;
  246. root[_xfa_object.$extra].noLayoutFailure = true;
  247. const res = extraNode[_xfa_object.$toHTML](space);
  248. node[_xfa_object.$addHTML](res.html, res.bbox);
  249. root[_xfa_object.$extra].noLayoutFailure = saved;
  250. extraNode[_xfa_object.$getSubformParent] = savedMethod;
  251. }
  252. class AppearanceFilter extends _xfa_object.StringObject {
  253. constructor(attributes) {
  254. super(TEMPLATE_NS_ID, "appearanceFilter");
  255. this.id = attributes.id || "";
  256. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  257. this.use = attributes.use || "";
  258. this.usehref = attributes.usehref || "";
  259. }
  260. }
  261. class Arc extends _xfa_object.XFAObject {
  262. constructor(attributes) {
  263. super(TEMPLATE_NS_ID, "arc", true);
  264. this.circular = (0, _utils.getInteger)({
  265. data: attributes.circular,
  266. defaultValue: 0,
  267. validate: x => x === 1
  268. });
  269. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  270. this.id = attributes.id || "";
  271. this.startAngle = (0, _utils.getFloat)({
  272. data: attributes.startAngle,
  273. defaultValue: 0,
  274. validate: x => true
  275. });
  276. this.sweepAngle = (0, _utils.getFloat)({
  277. data: attributes.sweepAngle,
  278. defaultValue: 360,
  279. validate: x => true
  280. });
  281. this.use = attributes.use || "";
  282. this.usehref = attributes.usehref || "";
  283. this.edge = null;
  284. this.fill = null;
  285. }
  286. [_xfa_object.$toHTML]() {
  287. const edge = this.edge ? this.edge : new Edge({});
  288. const edgeStyle = edge[_xfa_object.$toStyle]();
  289. const style = Object.create(null);
  290. if (this.fill && this.fill.presence === "visible") {
  291. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  292. } else {
  293. style.fill = "transparent";
  294. }
  295. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  296. style.stroke = edgeStyle.color;
  297. let arc;
  298. const attributes = {
  299. xmlns: SVG_NS,
  300. style: {
  301. width: "100%",
  302. height: "100%",
  303. overflow: "visible"
  304. }
  305. };
  306. if (this.startAngle === 0 && this.sweepAngle === 360) {
  307. arc = {
  308. name: "ellipse",
  309. attributes: {
  310. xmlns: SVG_NS,
  311. cx: "50%",
  312. cy: "50%",
  313. rx: "50%",
  314. ry: "50%",
  315. style
  316. }
  317. };
  318. } else {
  319. const startAngle = this.startAngle * Math.PI / 180;
  320. const sweepAngle = this.sweepAngle * Math.PI / 180;
  321. const largeArc = this.sweepAngle - this.startAngle > 180 ? 1 : 0;
  322. const [x1, y1, x2, y2] = [50 * (1 + Math.cos(startAngle)), 50 * (1 - Math.sin(startAngle)), 50 * (1 + Math.cos(sweepAngle)), 50 * (1 - Math.sin(sweepAngle))];
  323. arc = {
  324. name: "path",
  325. attributes: {
  326. xmlns: SVG_NS,
  327. d: `M ${x1} ${y1} A 50 50 0 ${largeArc} 0 ${x2} ${y2}`,
  328. vectorEffect: "non-scaling-stroke",
  329. style
  330. }
  331. };
  332. Object.assign(attributes, {
  333. viewBox: "0 0 100 100",
  334. preserveAspectRatio: "none"
  335. });
  336. }
  337. const svg = {
  338. name: "svg",
  339. children: [arc],
  340. attributes
  341. };
  342. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  343. if (hasMargin(parent)) {
  344. return _utils.HTMLResult.success({
  345. name: "div",
  346. attributes: {
  347. style: {
  348. display: "inline",
  349. width: "100%",
  350. height: "100%"
  351. }
  352. },
  353. children: [svg]
  354. });
  355. }
  356. svg.attributes.style.position = "absolute";
  357. return _utils.HTMLResult.success(svg);
  358. }
  359. }
  360. class Area extends _xfa_object.XFAObject {
  361. constructor(attributes) {
  362. super(TEMPLATE_NS_ID, "area", true);
  363. this.colSpan = (0, _utils.getInteger)({
  364. data: attributes.colSpan,
  365. defaultValue: 1,
  366. validate: n => n >= 1 || n === -1
  367. });
  368. this.id = attributes.id || "";
  369. this.name = attributes.name || "";
  370. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  371. this.use = attributes.use || "";
  372. this.usehref = attributes.usehref || "";
  373. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  374. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  375. this.desc = null;
  376. this.extras = null;
  377. this.area = new _xfa_object.XFAObjectArray();
  378. this.draw = new _xfa_object.XFAObjectArray();
  379. this.exObject = new _xfa_object.XFAObjectArray();
  380. this.exclGroup = new _xfa_object.XFAObjectArray();
  381. this.field = new _xfa_object.XFAObjectArray();
  382. this.subform = new _xfa_object.XFAObjectArray();
  383. this.subformSet = new _xfa_object.XFAObjectArray();
  384. }
  385. *[_xfa_object.$getContainedChildren]() {
  386. yield* getContainedChildren(this);
  387. }
  388. [_xfa_object.$isTransparent]() {
  389. return true;
  390. }
  391. [_xfa_object.$isBindable]() {
  392. return true;
  393. }
  394. [_xfa_object.$addHTML](html, bbox) {
  395. const [x, y, w, h] = bbox;
  396. this[_xfa_object.$extra].width = Math.max(this[_xfa_object.$extra].width, x + w);
  397. this[_xfa_object.$extra].height = Math.max(this[_xfa_object.$extra].height, y + h);
  398. this[_xfa_object.$extra].children.push(html);
  399. }
  400. [_xfa_object.$getAvailableSpace]() {
  401. return this[_xfa_object.$extra].availableSpace;
  402. }
  403. [_xfa_object.$toHTML](availableSpace) {
  404. const style = (0, _html_utils.toStyle)(this, "position");
  405. const attributes = {
  406. style,
  407. id: this[_xfa_object.$uid],
  408. class: ["xfaArea"]
  409. };
  410. if ((0, _html_utils.isPrintOnly)(this)) {
  411. attributes.class.push("xfaPrintOnly");
  412. }
  413. if (this.name) {
  414. attributes.xfaName = this.name;
  415. }
  416. const children = [];
  417. this[_xfa_object.$extra] = {
  418. children,
  419. width: 0,
  420. height: 0,
  421. availableSpace
  422. };
  423. const result = this[_xfa_object.$childrenToHTML]({
  424. filter: new Set(["area", "draw", "field", "exclGroup", "subform", "subformSet"]),
  425. include: true
  426. });
  427. if (!result.success) {
  428. if (result.isBreak()) {
  429. return result;
  430. }
  431. delete this[_xfa_object.$extra];
  432. return _utils.HTMLResult.FAILURE;
  433. }
  434. style.width = (0, _html_utils.measureToString)(this[_xfa_object.$extra].width);
  435. style.height = (0, _html_utils.measureToString)(this[_xfa_object.$extra].height);
  436. const html = {
  437. name: "div",
  438. attributes,
  439. children
  440. };
  441. const bbox = [this.x, this.y, this[_xfa_object.$extra].width, this[_xfa_object.$extra].height];
  442. delete this[_xfa_object.$extra];
  443. return _utils.HTMLResult.success(html, bbox);
  444. }
  445. }
  446. class Assist extends _xfa_object.XFAObject {
  447. constructor(attributes) {
  448. super(TEMPLATE_NS_ID, "assist", true);
  449. this.id = attributes.id || "";
  450. this.role = attributes.role || "";
  451. this.use = attributes.use || "";
  452. this.usehref = attributes.usehref || "";
  453. this.speak = null;
  454. this.toolTip = null;
  455. }
  456. [_xfa_object.$toHTML]() {
  457. return this.toolTip && this.toolTip[_xfa_object.$content] ? this.toolTip[_xfa_object.$content] : null;
  458. }
  459. }
  460. class Barcode extends _xfa_object.XFAObject {
  461. constructor(attributes) {
  462. super(TEMPLATE_NS_ID, "barcode", true);
  463. this.charEncoding = (0, _utils.getKeyword)({
  464. data: attributes.charEncoding ? attributes.charEncoding.toLowerCase() : "",
  465. defaultValue: "",
  466. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  467. });
  468. this.checksum = (0, _utils.getStringOption)(attributes.checksum, ["none", "1mod10", "1mod10_1mod11", "2mod10", "auto"]);
  469. this.dataColumnCount = (0, _utils.getInteger)({
  470. data: attributes.dataColumnCount,
  471. defaultValue: -1,
  472. validate: x => x >= 0
  473. });
  474. this.dataLength = (0, _utils.getInteger)({
  475. data: attributes.dataLength,
  476. defaultValue: -1,
  477. validate: x => x >= 0
  478. });
  479. this.dataPrep = (0, _utils.getStringOption)(attributes.dataPrep, ["none", "flateCompress"]);
  480. this.dataRowCount = (0, _utils.getInteger)({
  481. data: attributes.dataRowCount,
  482. defaultValue: -1,
  483. validate: x => x >= 0
  484. });
  485. this.endChar = attributes.endChar || "";
  486. this.errorCorrectionLevel = (0, _utils.getInteger)({
  487. data: attributes.errorCorrectionLevel,
  488. defaultValue: -1,
  489. validate: x => x >= 0 && x <= 8
  490. });
  491. this.id = attributes.id || "";
  492. this.moduleHeight = (0, _utils.getMeasurement)(attributes.moduleHeight, "5mm");
  493. this.moduleWidth = (0, _utils.getMeasurement)(attributes.moduleWidth, "0.25mm");
  494. this.printCheckDigit = (0, _utils.getInteger)({
  495. data: attributes.printCheckDigit,
  496. defaultValue: 0,
  497. validate: x => x === 1
  498. });
  499. this.rowColumnRatio = (0, _utils.getRatio)(attributes.rowColumnRatio);
  500. this.startChar = attributes.startChar || "";
  501. this.textLocation = (0, _utils.getStringOption)(attributes.textLocation, ["below", "above", "aboveEmbedded", "belowEmbedded", "none"]);
  502. this.truncate = (0, _utils.getInteger)({
  503. data: attributes.truncate,
  504. defaultValue: 0,
  505. validate: x => x === 1
  506. });
  507. this.type = (0, _utils.getStringOption)(attributes.type ? attributes.type.toLowerCase() : "", ["aztec", "codabar", "code2of5industrial", "code2of5interleaved", "code2of5matrix", "code2of5standard", "code3of9", "code3of9extended", "code11", "code49", "code93", "code128", "code128a", "code128b", "code128c", "code128sscc", "datamatrix", "ean8", "ean8add2", "ean8add5", "ean13", "ean13add2", "ean13add5", "ean13pwcd", "fim", "logmars", "maxicode", "msi", "pdf417", "pdf417macro", "plessey", "postauscust2", "postauscust3", "postausreplypaid", "postausstandard", "postukrm4scc", "postusdpbc", "postusimb", "postusstandard", "postus5zip", "qrcode", "rfid", "rss14", "rss14expanded", "rss14limited", "rss14stacked", "rss14stackedomni", "rss14truncated", "telepen", "ucc128", "ucc128random", "ucc128sscc", "upca", "upcaadd2", "upcaadd5", "upcapwcd", "upce", "upceadd2", "upceadd5", "upcean2", "upcean5", "upsmaxicode"]);
  508. this.upsMode = (0, _utils.getStringOption)(attributes.upsMode, ["usCarrier", "internationalCarrier", "secureSymbol", "standardSymbol"]);
  509. this.use = attributes.use || "";
  510. this.usehref = attributes.usehref || "";
  511. this.wideNarrowRatio = (0, _utils.getRatio)(attributes.wideNarrowRatio);
  512. this.encrypt = null;
  513. this.extras = null;
  514. }
  515. }
  516. class Bind extends _xfa_object.XFAObject {
  517. constructor(attributes) {
  518. super(TEMPLATE_NS_ID, "bind", true);
  519. this.match = (0, _utils.getStringOption)(attributes.match, ["once", "dataRef", "global", "none"]);
  520. this.ref = attributes.ref || "";
  521. this.picture = null;
  522. }
  523. }
  524. class BindItems extends _xfa_object.XFAObject {
  525. constructor(attributes) {
  526. super(TEMPLATE_NS_ID, "bindItems");
  527. this.connection = attributes.connection || "";
  528. this.labelRef = attributes.labelRef || "";
  529. this.ref = attributes.ref || "";
  530. this.valueRef = attributes.valueRef || "";
  531. }
  532. }
  533. exports.BindItems = BindItems;
  534. class Bookend extends _xfa_object.XFAObject {
  535. constructor(attributes) {
  536. super(TEMPLATE_NS_ID, "bookend");
  537. this.id = attributes.id || "";
  538. this.leader = attributes.leader || "";
  539. this.trailer = attributes.trailer || "";
  540. this.use = attributes.use || "";
  541. this.usehref = attributes.usehref || "";
  542. }
  543. }
  544. class BooleanElement extends _xfa_object.Option01 {
  545. constructor(attributes) {
  546. super(TEMPLATE_NS_ID, "boolean");
  547. this.id = attributes.id || "";
  548. this.name = attributes.name || "";
  549. this.use = attributes.use || "";
  550. this.usehref = attributes.usehref || "";
  551. }
  552. [_xfa_object.$toHTML](availableSpace) {
  553. return valueToHtml(this[_xfa_object.$content] === 1 ? "1" : "0");
  554. }
  555. }
  556. class Border extends _xfa_object.XFAObject {
  557. constructor(attributes) {
  558. super(TEMPLATE_NS_ID, "border", true);
  559. this.break = (0, _utils.getStringOption)(attributes.break, ["close", "open"]);
  560. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  561. this.id = attributes.id || "";
  562. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  563. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  564. this.use = attributes.use || "";
  565. this.usehref = attributes.usehref || "";
  566. this.corner = new _xfa_object.XFAObjectArray(4);
  567. this.edge = new _xfa_object.XFAObjectArray(4);
  568. this.extras = null;
  569. this.fill = null;
  570. this.margin = null;
  571. }
  572. [_xfa_object.$getExtra]() {
  573. if (!this[_xfa_object.$extra]) {
  574. const edges = this.edge.children.slice();
  575. if (edges.length < 4) {
  576. const defaultEdge = edges[edges.length - 1] || new Edge({});
  577. for (let i = edges.length; i < 4; i++) {
  578. edges.push(defaultEdge);
  579. }
  580. }
  581. const widths = edges.map(edge => edge.thickness);
  582. const insets = [0, 0, 0, 0];
  583. if (this.margin) {
  584. insets[0] = this.margin.topInset;
  585. insets[1] = this.margin.rightInset;
  586. insets[2] = this.margin.bottomInset;
  587. insets[3] = this.margin.leftInset;
  588. }
  589. this[_xfa_object.$extra] = {
  590. widths,
  591. insets,
  592. edges
  593. };
  594. }
  595. return this[_xfa_object.$extra];
  596. }
  597. [_xfa_object.$toStyle]() {
  598. const {
  599. edges
  600. } = this[_xfa_object.$getExtra]();
  601. const edgeStyles = edges.map(node => {
  602. const style = node[_xfa_object.$toStyle]();
  603. style.color = style.color || "#000000";
  604. return style;
  605. });
  606. const style = Object.create(null);
  607. if (this.margin) {
  608. Object.assign(style, this.margin[_xfa_object.$toStyle]());
  609. }
  610. if (this.fill && this.fill.presence === "visible") {
  611. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  612. }
  613. if (this.corner.children.some(node => node.radius !== 0)) {
  614. const cornerStyles = this.corner.children.map(node => node[_xfa_object.$toStyle]());
  615. if (cornerStyles.length === 2 || cornerStyles.length === 3) {
  616. const last = cornerStyles[cornerStyles.length - 1];
  617. for (let i = cornerStyles.length; i < 4; i++) {
  618. cornerStyles.push(last);
  619. }
  620. }
  621. style.borderRadius = cornerStyles.map(s => s.radius).join(" ");
  622. }
  623. switch (this.presence) {
  624. case "invisible":
  625. case "hidden":
  626. style.borderStyle = "";
  627. break;
  628. case "inactive":
  629. style.borderStyle = "none";
  630. break;
  631. default:
  632. style.borderStyle = edgeStyles.map(s => s.style).join(" ");
  633. break;
  634. }
  635. style.borderWidth = edgeStyles.map(s => s.width).join(" ");
  636. style.borderColor = edgeStyles.map(s => s.color).join(" ");
  637. return style;
  638. }
  639. }
  640. class Break extends _xfa_object.XFAObject {
  641. constructor(attributes) {
  642. super(TEMPLATE_NS_ID, "break", true);
  643. this.after = (0, _utils.getStringOption)(attributes.after, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  644. this.afterTarget = attributes.afterTarget || "";
  645. this.before = (0, _utils.getStringOption)(attributes.before, ["auto", "contentArea", "pageArea", "pageEven", "pageOdd"]);
  646. this.beforeTarget = attributes.beforeTarget || "";
  647. this.bookendLeader = attributes.bookendLeader || "";
  648. this.bookendTrailer = attributes.bookendTrailer || "";
  649. this.id = attributes.id || "";
  650. this.overflowLeader = attributes.overflowLeader || "";
  651. this.overflowTarget = attributes.overflowTarget || "";
  652. this.overflowTrailer = attributes.overflowTrailer || "";
  653. this.startNew = (0, _utils.getInteger)({
  654. data: attributes.startNew,
  655. defaultValue: 0,
  656. validate: x => x === 1
  657. });
  658. this.use = attributes.use || "";
  659. this.usehref = attributes.usehref || "";
  660. this.extras = null;
  661. }
  662. }
  663. class BreakAfter extends _xfa_object.XFAObject {
  664. constructor(attributes) {
  665. super(TEMPLATE_NS_ID, "breakAfter", true);
  666. this.id = attributes.id || "";
  667. this.leader = attributes.leader || "";
  668. this.startNew = (0, _utils.getInteger)({
  669. data: attributes.startNew,
  670. defaultValue: 0,
  671. validate: x => x === 1
  672. });
  673. this.target = attributes.target || "";
  674. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  675. this.trailer = attributes.trailer || "";
  676. this.use = attributes.use || "";
  677. this.usehref = attributes.usehref || "";
  678. this.script = null;
  679. }
  680. }
  681. class BreakBefore extends _xfa_object.XFAObject {
  682. constructor(attributes) {
  683. super(TEMPLATE_NS_ID, "breakBefore", true);
  684. this.id = attributes.id || "";
  685. this.leader = attributes.leader || "";
  686. this.startNew = (0, _utils.getInteger)({
  687. data: attributes.startNew,
  688. defaultValue: 0,
  689. validate: x => x === 1
  690. });
  691. this.target = attributes.target || "";
  692. this.targetType = (0, _utils.getStringOption)(attributes.targetType, ["auto", "contentArea", "pageArea"]);
  693. this.trailer = attributes.trailer || "";
  694. this.use = attributes.use || "";
  695. this.usehref = attributes.usehref || "";
  696. this.script = null;
  697. }
  698. [_xfa_object.$toHTML](availableSpace) {
  699. this[_xfa_object.$extra] = {};
  700. return _utils.HTMLResult.FAILURE;
  701. }
  702. }
  703. class Button extends _xfa_object.XFAObject {
  704. constructor(attributes) {
  705. super(TEMPLATE_NS_ID, "button", true);
  706. this.highlight = (0, _utils.getStringOption)(attributes.highlight, ["inverted", "none", "outline", "push"]);
  707. this.id = attributes.id || "";
  708. this.use = attributes.use || "";
  709. this.usehref = attributes.usehref || "";
  710. this.extras = null;
  711. }
  712. [_xfa_object.$toHTML](availableSpace) {
  713. const parent = this[_xfa_object.$getParent]();
  714. const grandpa = parent[_xfa_object.$getParent]();
  715. const htmlButton = {
  716. name: "button",
  717. attributes: {
  718. id: this[_xfa_object.$uid],
  719. class: ["xfaButton"],
  720. style: {}
  721. },
  722. children: []
  723. };
  724. for (const event of grandpa.event.children) {
  725. if (event.activity !== "click" || !event.script) {
  726. continue;
  727. }
  728. const jsURL = (0, _core_utils.recoverJsURL)(event.script[_xfa_object.$content]);
  729. if (!jsURL) {
  730. continue;
  731. }
  732. const href = (0, _html_utils.fixURL)(jsURL.url);
  733. if (!href) {
  734. continue;
  735. }
  736. htmlButton.children.push({
  737. name: "a",
  738. attributes: {
  739. id: "link" + this[_xfa_object.$uid],
  740. href,
  741. newWindow: jsURL.newWindow,
  742. class: ["xfaLink"],
  743. style: {}
  744. },
  745. children: []
  746. });
  747. }
  748. return _utils.HTMLResult.success(htmlButton);
  749. }
  750. }
  751. class Calculate extends _xfa_object.XFAObject {
  752. constructor(attributes) {
  753. super(TEMPLATE_NS_ID, "calculate", true);
  754. this.id = attributes.id || "";
  755. this.override = (0, _utils.getStringOption)(attributes.override, ["disabled", "error", "ignore", "warning"]);
  756. this.use = attributes.use || "";
  757. this.usehref = attributes.usehref || "";
  758. this.extras = null;
  759. this.message = null;
  760. this.script = null;
  761. }
  762. }
  763. class Caption extends _xfa_object.XFAObject {
  764. constructor(attributes) {
  765. super(TEMPLATE_NS_ID, "caption", true);
  766. this.id = attributes.id || "";
  767. this.placement = (0, _utils.getStringOption)(attributes.placement, ["left", "bottom", "inline", "right", "top"]);
  768. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  769. this.reserve = Math.ceil((0, _utils.getMeasurement)(attributes.reserve));
  770. this.use = attributes.use || "";
  771. this.usehref = attributes.usehref || "";
  772. this.extras = null;
  773. this.font = null;
  774. this.margin = null;
  775. this.para = null;
  776. this.value = null;
  777. }
  778. [_xfa_object.$setValue](value) {
  779. _setValue(this, value);
  780. }
  781. [_xfa_object.$getExtra](availableSpace) {
  782. if (!this[_xfa_object.$extra]) {
  783. let {
  784. width,
  785. height
  786. } = availableSpace;
  787. switch (this.placement) {
  788. case "left":
  789. case "right":
  790. case "inline":
  791. width = this.reserve <= 0 ? width : this.reserve;
  792. break;
  793. case "top":
  794. case "bottom":
  795. height = this.reserve <= 0 ? height : this.reserve;
  796. break;
  797. }
  798. this[_xfa_object.$extra] = (0, _html_utils.layoutNode)(this, {
  799. width,
  800. height
  801. });
  802. }
  803. return this[_xfa_object.$extra];
  804. }
  805. [_xfa_object.$toHTML](availableSpace) {
  806. if (!this.value) {
  807. return _utils.HTMLResult.EMPTY;
  808. }
  809. this[_xfa_object.$pushPara]();
  810. const value = this.value[_xfa_object.$toHTML](availableSpace).html;
  811. if (!value) {
  812. this[_xfa_object.$popPara]();
  813. return _utils.HTMLResult.EMPTY;
  814. }
  815. const savedReserve = this.reserve;
  816. if (this.reserve <= 0) {
  817. const {
  818. w,
  819. h
  820. } = this[_xfa_object.$getExtra](availableSpace);
  821. switch (this.placement) {
  822. case "left":
  823. case "right":
  824. case "inline":
  825. this.reserve = w;
  826. break;
  827. case "top":
  828. case "bottom":
  829. this.reserve = h;
  830. break;
  831. }
  832. }
  833. const children = [];
  834. if (typeof value === "string") {
  835. children.push({
  836. name: "#text",
  837. value
  838. });
  839. } else {
  840. children.push(value);
  841. }
  842. const style = (0, _html_utils.toStyle)(this, "font", "margin", "visibility");
  843. switch (this.placement) {
  844. case "left":
  845. case "right":
  846. if (this.reserve > 0) {
  847. style.width = (0, _html_utils.measureToString)(this.reserve);
  848. }
  849. break;
  850. case "top":
  851. case "bottom":
  852. if (this.reserve > 0) {
  853. style.height = (0, _html_utils.measureToString)(this.reserve);
  854. }
  855. break;
  856. }
  857. (0, _html_utils.setPara)(this, null, value);
  858. this[_xfa_object.$popPara]();
  859. this.reserve = savedReserve;
  860. return _utils.HTMLResult.success({
  861. name: "div",
  862. attributes: {
  863. style,
  864. class: ["xfaCaption"]
  865. },
  866. children
  867. });
  868. }
  869. }
  870. class Certificate extends _xfa_object.StringObject {
  871. constructor(attributes) {
  872. super(TEMPLATE_NS_ID, "certificate");
  873. this.id = attributes.id || "";
  874. this.name = attributes.name || "";
  875. this.use = attributes.use || "";
  876. this.usehref = attributes.usehref || "";
  877. }
  878. }
  879. class Certificates extends _xfa_object.XFAObject {
  880. constructor(attributes) {
  881. super(TEMPLATE_NS_ID, "certificates", true);
  882. this.credentialServerPolicy = (0, _utils.getStringOption)(attributes.credentialServerPolicy, ["optional", "required"]);
  883. this.id = attributes.id || "";
  884. this.url = attributes.url || "";
  885. this.urlPolicy = attributes.urlPolicy || "";
  886. this.use = attributes.use || "";
  887. this.usehref = attributes.usehref || "";
  888. this.encryption = null;
  889. this.issuers = null;
  890. this.keyUsage = null;
  891. this.oids = null;
  892. this.signing = null;
  893. this.subjectDNs = null;
  894. }
  895. }
  896. class CheckButton extends _xfa_object.XFAObject {
  897. constructor(attributes) {
  898. super(TEMPLATE_NS_ID, "checkButton", true);
  899. this.id = attributes.id || "";
  900. this.mark = (0, _utils.getStringOption)(attributes.mark, ["default", "check", "circle", "cross", "diamond", "square", "star"]);
  901. this.shape = (0, _utils.getStringOption)(attributes.shape, ["square", "round"]);
  902. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  903. this.use = attributes.use || "";
  904. this.usehref = attributes.usehref || "";
  905. this.border = null;
  906. this.extras = null;
  907. this.margin = null;
  908. }
  909. [_xfa_object.$toHTML](availableSpace) {
  910. const style = (0, _html_utils.toStyle)("margin");
  911. const size = (0, _html_utils.measureToString)(this.size);
  912. style.width = style.height = size;
  913. let type;
  914. let className;
  915. let groupId;
  916. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  917. const items = field.items.children.length && field.items.children[0][_xfa_object.$toHTML]().html || [];
  918. const exportedValue = {
  919. on: (items[0] !== undefined ? items[0] : "on").toString(),
  920. off: (items[1] !== undefined ? items[1] : "off").toString()
  921. };
  922. const value = field.value && field.value[_xfa_object.$text]() || "off";
  923. const checked = value === exportedValue.on || undefined;
  924. const container = field[_xfa_object.$getSubformParent]();
  925. const fieldId = field[_xfa_object.$uid];
  926. let dataId;
  927. if (container instanceof ExclGroup) {
  928. groupId = container[_xfa_object.$uid];
  929. type = "radio";
  930. className = "xfaRadio";
  931. dataId = container[_xfa_object.$data] && container[_xfa_object.$data][_xfa_object.$uid] || container[_xfa_object.$uid];
  932. } else {
  933. type = "checkbox";
  934. className = "xfaCheckbox";
  935. dataId = field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid];
  936. }
  937. const input = {
  938. name: "input",
  939. attributes: {
  940. class: [className],
  941. style,
  942. fieldId,
  943. dataId,
  944. type,
  945. checked,
  946. xfaOn: exportedValue.on,
  947. xfaOff: exportedValue.off,
  948. "aria-label": ariaLabel(field)
  949. }
  950. };
  951. if (groupId) {
  952. input.attributes.name = groupId;
  953. }
  954. return _utils.HTMLResult.success({
  955. name: "label",
  956. attributes: {
  957. class: ["xfaLabel"]
  958. },
  959. children: [input]
  960. });
  961. }
  962. }
  963. class ChoiceList extends _xfa_object.XFAObject {
  964. constructor(attributes) {
  965. super(TEMPLATE_NS_ID, "choiceList", true);
  966. this.commitOn = (0, _utils.getStringOption)(attributes.commitOn, ["select", "exit"]);
  967. this.id = attributes.id || "";
  968. this.open = (0, _utils.getStringOption)(attributes.open, ["userControl", "always", "multiSelect", "onEntry"]);
  969. this.textEntry = (0, _utils.getInteger)({
  970. data: attributes.textEntry,
  971. defaultValue: 0,
  972. validate: x => x === 1
  973. });
  974. this.use = attributes.use || "";
  975. this.usehref = attributes.usehref || "";
  976. this.border = null;
  977. this.extras = null;
  978. this.margin = null;
  979. }
  980. [_xfa_object.$toHTML](availableSpace) {
  981. const style = (0, _html_utils.toStyle)(this, "border", "margin");
  982. const ui = this[_xfa_object.$getParent]();
  983. const field = ui[_xfa_object.$getParent]();
  984. const fontSize = field.font && field.font.size || 10;
  985. const optionStyle = {
  986. fontSize: `calc(${fontSize}px * var(--zoom-factor))`
  987. };
  988. const children = [];
  989. if (field.items.children.length > 0) {
  990. const items = field.items;
  991. let displayedIndex = 0;
  992. let saveIndex = 0;
  993. if (items.children.length === 2) {
  994. displayedIndex = items.children[0].save;
  995. saveIndex = 1 - displayedIndex;
  996. }
  997. const displayed = items.children[displayedIndex][_xfa_object.$toHTML]().html;
  998. const values = items.children[saveIndex][_xfa_object.$toHTML]().html;
  999. let selected = false;
  1000. const value = field.value && field.value[_xfa_object.$text]() || "";
  1001. for (let i = 0, ii = displayed.length; i < ii; i++) {
  1002. const option = {
  1003. name: "option",
  1004. attributes: {
  1005. value: values[i] || displayed[i],
  1006. style: optionStyle
  1007. },
  1008. value: displayed[i]
  1009. };
  1010. if (values[i] === value) {
  1011. option.attributes.selected = selected = true;
  1012. }
  1013. children.push(option);
  1014. }
  1015. if (!selected) {
  1016. children.splice(0, 0, {
  1017. name: "option",
  1018. attributes: {
  1019. hidden: true,
  1020. selected: true
  1021. },
  1022. value: " "
  1023. });
  1024. }
  1025. }
  1026. const selectAttributes = {
  1027. class: ["xfaSelect"],
  1028. fieldId: field[_xfa_object.$uid],
  1029. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  1030. style,
  1031. "aria-label": ariaLabel(field)
  1032. };
  1033. if (this.open === "multiSelect") {
  1034. selectAttributes.multiple = true;
  1035. }
  1036. return _utils.HTMLResult.success({
  1037. name: "label",
  1038. attributes: {
  1039. class: ["xfaLabel"]
  1040. },
  1041. children: [{
  1042. name: "select",
  1043. children,
  1044. attributes: selectAttributes
  1045. }]
  1046. });
  1047. }
  1048. }
  1049. class Color extends _xfa_object.XFAObject {
  1050. constructor(attributes) {
  1051. super(TEMPLATE_NS_ID, "color", true);
  1052. this.cSpace = (0, _utils.getStringOption)(attributes.cSpace, ["SRGB"]);
  1053. this.id = attributes.id || "";
  1054. this.use = attributes.use || "";
  1055. this.usehref = attributes.usehref || "";
  1056. this.value = attributes.value ? (0, _utils.getColor)(attributes.value) : "";
  1057. this.extras = null;
  1058. }
  1059. [_xfa_object.$hasSettableValue]() {
  1060. return false;
  1061. }
  1062. [_xfa_object.$toStyle]() {
  1063. return this.value ? _util.Util.makeHexColor(this.value.r, this.value.g, this.value.b) : null;
  1064. }
  1065. }
  1066. class Comb extends _xfa_object.XFAObject {
  1067. constructor(attributes) {
  1068. super(TEMPLATE_NS_ID, "comb");
  1069. this.id = attributes.id || "";
  1070. this.numberOfCells = (0, _utils.getInteger)({
  1071. data: attributes.numberOfCells,
  1072. defaultValue: 0,
  1073. validate: x => x >= 0
  1074. });
  1075. this.use = attributes.use || "";
  1076. this.usehref = attributes.usehref || "";
  1077. }
  1078. }
  1079. class Connect extends _xfa_object.XFAObject {
  1080. constructor(attributes) {
  1081. super(TEMPLATE_NS_ID, "connect", true);
  1082. this.connection = attributes.connection || "";
  1083. this.id = attributes.id || "";
  1084. this.ref = attributes.ref || "";
  1085. this.usage = (0, _utils.getStringOption)(attributes.usage, ["exportAndImport", "exportOnly", "importOnly"]);
  1086. this.use = attributes.use || "";
  1087. this.usehref = attributes.usehref || "";
  1088. this.picture = null;
  1089. }
  1090. }
  1091. class ContentArea extends _xfa_object.XFAObject {
  1092. constructor(attributes) {
  1093. super(TEMPLATE_NS_ID, "contentArea", true);
  1094. this.h = (0, _utils.getMeasurement)(attributes.h);
  1095. this.id = attributes.id || "";
  1096. this.name = attributes.name || "";
  1097. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1098. this.use = attributes.use || "";
  1099. this.usehref = attributes.usehref || "";
  1100. this.w = (0, _utils.getMeasurement)(attributes.w);
  1101. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1102. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1103. this.desc = null;
  1104. this.extras = null;
  1105. }
  1106. [_xfa_object.$toHTML](availableSpace) {
  1107. const left = (0, _html_utils.measureToString)(this.x);
  1108. const top = (0, _html_utils.measureToString)(this.y);
  1109. const style = {
  1110. left,
  1111. top,
  1112. width: (0, _html_utils.measureToString)(this.w),
  1113. height: (0, _html_utils.measureToString)(this.h)
  1114. };
  1115. const classNames = ["xfaContentarea"];
  1116. if ((0, _html_utils.isPrintOnly)(this)) {
  1117. classNames.push("xfaPrintOnly");
  1118. }
  1119. return _utils.HTMLResult.success({
  1120. name: "div",
  1121. children: [],
  1122. attributes: {
  1123. style,
  1124. class: classNames,
  1125. id: this[_xfa_object.$uid]
  1126. }
  1127. });
  1128. }
  1129. }
  1130. class Corner extends _xfa_object.XFAObject {
  1131. constructor(attributes) {
  1132. super(TEMPLATE_NS_ID, "corner", true);
  1133. this.id = attributes.id || "";
  1134. this.inverted = (0, _utils.getInteger)({
  1135. data: attributes.inverted,
  1136. defaultValue: 0,
  1137. validate: x => x === 1
  1138. });
  1139. this.join = (0, _utils.getStringOption)(attributes.join, ["square", "round"]);
  1140. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1141. this.radius = (0, _utils.getMeasurement)(attributes.radius);
  1142. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  1143. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  1144. this.use = attributes.use || "";
  1145. this.usehref = attributes.usehref || "";
  1146. this.color = null;
  1147. this.extras = null;
  1148. }
  1149. [_xfa_object.$toStyle]() {
  1150. const style = (0, _html_utils.toStyle)(this, "visibility");
  1151. style.radius = (0, _html_utils.measureToString)(this.join === "square" ? 0 : this.radius);
  1152. return style;
  1153. }
  1154. }
  1155. class DateElement extends _xfa_object.ContentObject {
  1156. constructor(attributes) {
  1157. super(TEMPLATE_NS_ID, "date");
  1158. this.id = attributes.id || "";
  1159. this.name = attributes.name || "";
  1160. this.use = attributes.use || "";
  1161. this.usehref = attributes.usehref || "";
  1162. }
  1163. [_xfa_object.$finalize]() {
  1164. const date = this[_xfa_object.$content].trim();
  1165. this[_xfa_object.$content] = date ? new Date(date) : null;
  1166. }
  1167. [_xfa_object.$toHTML](availableSpace) {
  1168. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  1169. }
  1170. }
  1171. class DateTime extends _xfa_object.ContentObject {
  1172. constructor(attributes) {
  1173. super(TEMPLATE_NS_ID, "dateTime");
  1174. this.id = attributes.id || "";
  1175. this.name = attributes.name || "";
  1176. this.use = attributes.use || "";
  1177. this.usehref = attributes.usehref || "";
  1178. }
  1179. [_xfa_object.$finalize]() {
  1180. const date = this[_xfa_object.$content].trim();
  1181. this[_xfa_object.$content] = date ? new Date(date) : null;
  1182. }
  1183. [_xfa_object.$toHTML](availableSpace) {
  1184. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  1185. }
  1186. }
  1187. class DateTimeEdit extends _xfa_object.XFAObject {
  1188. constructor(attributes) {
  1189. super(TEMPLATE_NS_ID, "dateTimeEdit", true);
  1190. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  1191. this.id = attributes.id || "";
  1192. this.picker = (0, _utils.getStringOption)(attributes.picker, ["host", "none"]);
  1193. this.use = attributes.use || "";
  1194. this.usehref = attributes.usehref || "";
  1195. this.border = null;
  1196. this.comb = null;
  1197. this.extras = null;
  1198. this.margin = null;
  1199. }
  1200. [_xfa_object.$toHTML](availableSpace) {
  1201. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  1202. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  1203. const html = {
  1204. name: "input",
  1205. attributes: {
  1206. type: "text",
  1207. fieldId: field[_xfa_object.$uid],
  1208. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  1209. class: ["xfaTextfield"],
  1210. style,
  1211. "aria-label": ariaLabel(field)
  1212. }
  1213. };
  1214. return _utils.HTMLResult.success({
  1215. name: "label",
  1216. attributes: {
  1217. class: ["xfaLabel"]
  1218. },
  1219. children: [html]
  1220. });
  1221. }
  1222. }
  1223. class Decimal extends _xfa_object.ContentObject {
  1224. constructor(attributes) {
  1225. super(TEMPLATE_NS_ID, "decimal");
  1226. this.fracDigits = (0, _utils.getInteger)({
  1227. data: attributes.fracDigits,
  1228. defaultValue: 2,
  1229. validate: x => true
  1230. });
  1231. this.id = attributes.id || "";
  1232. this.leadDigits = (0, _utils.getInteger)({
  1233. data: attributes.leadDigits,
  1234. defaultValue: -1,
  1235. validate: x => true
  1236. });
  1237. this.name = attributes.name || "";
  1238. this.use = attributes.use || "";
  1239. this.usehref = attributes.usehref || "";
  1240. }
  1241. [_xfa_object.$finalize]() {
  1242. const number = parseFloat(this[_xfa_object.$content].trim());
  1243. this[_xfa_object.$content] = isNaN(number) ? null : number;
  1244. }
  1245. [_xfa_object.$toHTML](availableSpace) {
  1246. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  1247. }
  1248. }
  1249. class DefaultUi extends _xfa_object.XFAObject {
  1250. constructor(attributes) {
  1251. super(TEMPLATE_NS_ID, "defaultUi", true);
  1252. this.id = attributes.id || "";
  1253. this.use = attributes.use || "";
  1254. this.usehref = attributes.usehref || "";
  1255. this.extras = null;
  1256. }
  1257. }
  1258. class Desc extends _xfa_object.XFAObject {
  1259. constructor(attributes) {
  1260. super(TEMPLATE_NS_ID, "desc", true);
  1261. this.id = attributes.id || "";
  1262. this.use = attributes.use || "";
  1263. this.usehref = attributes.usehref || "";
  1264. this.boolean = new _xfa_object.XFAObjectArray();
  1265. this.date = new _xfa_object.XFAObjectArray();
  1266. this.dateTime = new _xfa_object.XFAObjectArray();
  1267. this.decimal = new _xfa_object.XFAObjectArray();
  1268. this.exData = new _xfa_object.XFAObjectArray();
  1269. this.float = new _xfa_object.XFAObjectArray();
  1270. this.image = new _xfa_object.XFAObjectArray();
  1271. this.integer = new _xfa_object.XFAObjectArray();
  1272. this.text = new _xfa_object.XFAObjectArray();
  1273. this.time = new _xfa_object.XFAObjectArray();
  1274. }
  1275. }
  1276. class DigestMethod extends _xfa_object.OptionObject {
  1277. constructor(attributes) {
  1278. super(TEMPLATE_NS_ID, "digestMethod", ["", "SHA1", "SHA256", "SHA512", "RIPEMD160"]);
  1279. this.id = attributes.id || "";
  1280. this.use = attributes.use || "";
  1281. this.usehref = attributes.usehref || "";
  1282. }
  1283. }
  1284. class DigestMethods extends _xfa_object.XFAObject {
  1285. constructor(attributes) {
  1286. super(TEMPLATE_NS_ID, "digestMethods", true);
  1287. this.id = attributes.id || "";
  1288. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1289. this.use = attributes.use || "";
  1290. this.usehref = attributes.usehref || "";
  1291. this.digestMethod = new _xfa_object.XFAObjectArray();
  1292. }
  1293. }
  1294. class Draw extends _xfa_object.XFAObject {
  1295. constructor(attributes) {
  1296. super(TEMPLATE_NS_ID, "draw", true);
  1297. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1298. this.colSpan = (0, _utils.getInteger)({
  1299. data: attributes.colSpan,
  1300. defaultValue: 1,
  1301. validate: n => n >= 1 || n === -1
  1302. });
  1303. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1304. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1305. this.id = attributes.id || "";
  1306. this.locale = attributes.locale || "";
  1307. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1308. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1309. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1310. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1311. this.name = attributes.name || "";
  1312. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1313. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1314. this.rotate = (0, _utils.getInteger)({
  1315. data: attributes.rotate,
  1316. defaultValue: 0,
  1317. validate: x => x % 90 === 0
  1318. });
  1319. this.use = attributes.use || "";
  1320. this.usehref = attributes.usehref || "";
  1321. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1322. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1323. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1324. this.assist = null;
  1325. this.border = null;
  1326. this.caption = null;
  1327. this.desc = null;
  1328. this.extras = null;
  1329. this.font = null;
  1330. this.keep = null;
  1331. this.margin = null;
  1332. this.para = null;
  1333. this.traversal = null;
  1334. this.ui = null;
  1335. this.value = null;
  1336. this.setProperty = new _xfa_object.XFAObjectArray();
  1337. }
  1338. [_xfa_object.$setValue](value) {
  1339. _setValue(this, value);
  1340. }
  1341. [_xfa_object.$toHTML](availableSpace) {
  1342. setTabIndex(this);
  1343. if (this.presence === "hidden" || this.presence === "inactive") {
  1344. return _utils.HTMLResult.EMPTY;
  1345. }
  1346. (0, _html_utils.fixDimensions)(this);
  1347. this[_xfa_object.$pushPara]();
  1348. const savedW = this.w;
  1349. const savedH = this.h;
  1350. const {
  1351. w,
  1352. h,
  1353. isBroken
  1354. } = (0, _html_utils.layoutNode)(this, availableSpace);
  1355. if (w && this.w === "") {
  1356. if (isBroken && this[_xfa_object.$getSubformParent]()[_xfa_object.$isThereMoreWidth]()) {
  1357. this[_xfa_object.$popPara]();
  1358. return _utils.HTMLResult.FAILURE;
  1359. }
  1360. this.w = w;
  1361. }
  1362. if (h && this.h === "") {
  1363. this.h = h;
  1364. }
  1365. setFirstUnsplittable(this);
  1366. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  1367. this.w = savedW;
  1368. this.h = savedH;
  1369. this[_xfa_object.$popPara]();
  1370. return _utils.HTMLResult.FAILURE;
  1371. }
  1372. unsetFirstUnsplittable(this);
  1373. const style = (0, _html_utils.toStyle)(this, "font", "hAlign", "dimensions", "position", "presence", "rotate", "anchorType", "border", "margin");
  1374. (0, _html_utils.setMinMaxDimensions)(this, style);
  1375. if (style.margin) {
  1376. style.padding = style.margin;
  1377. delete style.margin;
  1378. }
  1379. const classNames = ["xfaDraw"];
  1380. if (this.font) {
  1381. classNames.push("xfaFont");
  1382. }
  1383. if ((0, _html_utils.isPrintOnly)(this)) {
  1384. classNames.push("xfaPrintOnly");
  1385. }
  1386. const attributes = {
  1387. style,
  1388. id: this[_xfa_object.$uid],
  1389. class: classNames
  1390. };
  1391. if (this.name) {
  1392. attributes.xfaName = this.name;
  1393. }
  1394. const html = {
  1395. name: "div",
  1396. attributes,
  1397. children: []
  1398. };
  1399. applyAssist(this, attributes);
  1400. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  1401. const value = this.value ? this.value[_xfa_object.$toHTML](availableSpace).html : null;
  1402. if (value === null) {
  1403. this.w = savedW;
  1404. this.h = savedH;
  1405. this[_xfa_object.$popPara]();
  1406. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1407. }
  1408. html.children.push(value);
  1409. (0, _html_utils.setPara)(this, style, value);
  1410. this.w = savedW;
  1411. this.h = savedH;
  1412. this[_xfa_object.$popPara]();
  1413. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1414. }
  1415. }
  1416. class Edge extends _xfa_object.XFAObject {
  1417. constructor(attributes) {
  1418. super(TEMPLATE_NS_ID, "edge", true);
  1419. this.cap = (0, _utils.getStringOption)(attributes.cap, ["square", "butt", "round"]);
  1420. this.id = attributes.id || "";
  1421. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1422. this.stroke = (0, _utils.getStringOption)(attributes.stroke, ["solid", "dashDot", "dashDotDot", "dashed", "dotted", "embossed", "etched", "lowered", "raised"]);
  1423. this.thickness = (0, _utils.getMeasurement)(attributes.thickness, "0.5pt");
  1424. this.use = attributes.use || "";
  1425. this.usehref = attributes.usehref || "";
  1426. this.color = null;
  1427. this.extras = null;
  1428. }
  1429. [_xfa_object.$toStyle]() {
  1430. const style = (0, _html_utils.toStyle)(this, "visibility");
  1431. Object.assign(style, {
  1432. linecap: this.cap,
  1433. width: (0, _html_utils.measureToString)(this.thickness),
  1434. color: this.color ? this.color[_xfa_object.$toStyle]() : "#000000",
  1435. style: ""
  1436. });
  1437. if (this.presence !== "visible") {
  1438. style.style = "none";
  1439. } else {
  1440. switch (this.stroke) {
  1441. case "solid":
  1442. style.style = "solid";
  1443. break;
  1444. case "dashDot":
  1445. style.style = "dashed";
  1446. break;
  1447. case "dashDotDot":
  1448. style.style = "dashed";
  1449. break;
  1450. case "dashed":
  1451. style.style = "dashed";
  1452. break;
  1453. case "dotted":
  1454. style.style = "dotted";
  1455. break;
  1456. case "embossed":
  1457. style.style = "ridge";
  1458. break;
  1459. case "etched":
  1460. style.style = "groove";
  1461. break;
  1462. case "lowered":
  1463. style.style = "inset";
  1464. break;
  1465. case "raised":
  1466. style.style = "outset";
  1467. break;
  1468. }
  1469. }
  1470. return style;
  1471. }
  1472. }
  1473. class Encoding extends _xfa_object.OptionObject {
  1474. constructor(attributes) {
  1475. super(TEMPLATE_NS_ID, "encoding", ["adbe.x509.rsa_sha1", "adbe.pkcs7.detached", "adbe.pkcs7.sha1"]);
  1476. this.id = attributes.id || "";
  1477. this.use = attributes.use || "";
  1478. this.usehref = attributes.usehref || "";
  1479. }
  1480. }
  1481. class Encodings extends _xfa_object.XFAObject {
  1482. constructor(attributes) {
  1483. super(TEMPLATE_NS_ID, "encodings", true);
  1484. this.id = attributes.id || "";
  1485. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1486. this.use = attributes.use || "";
  1487. this.usehref = attributes.usehref || "";
  1488. this.encoding = new _xfa_object.XFAObjectArray();
  1489. }
  1490. }
  1491. class Encrypt extends _xfa_object.XFAObject {
  1492. constructor(attributes) {
  1493. super(TEMPLATE_NS_ID, "encrypt", true);
  1494. this.id = attributes.id || "";
  1495. this.use = attributes.use || "";
  1496. this.usehref = attributes.usehref || "";
  1497. this.certificate = null;
  1498. }
  1499. }
  1500. class EncryptData extends _xfa_object.XFAObject {
  1501. constructor(attributes) {
  1502. super(TEMPLATE_NS_ID, "encryptData", true);
  1503. this.id = attributes.id || "";
  1504. this.operation = (0, _utils.getStringOption)(attributes.operation, ["encrypt", "decrypt"]);
  1505. this.target = attributes.target || "";
  1506. this.use = attributes.use || "";
  1507. this.usehref = attributes.usehref || "";
  1508. this.filter = null;
  1509. this.manifest = null;
  1510. }
  1511. }
  1512. class Encryption extends _xfa_object.XFAObject {
  1513. constructor(attributes) {
  1514. super(TEMPLATE_NS_ID, "encryption", true);
  1515. this.id = attributes.id || "";
  1516. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1517. this.use = attributes.use || "";
  1518. this.usehref = attributes.usehref || "";
  1519. this.certificate = new _xfa_object.XFAObjectArray();
  1520. }
  1521. }
  1522. class EncryptionMethod extends _xfa_object.OptionObject {
  1523. constructor(attributes) {
  1524. super(TEMPLATE_NS_ID, "encryptionMethod", ["", "AES256-CBC", "TRIPLEDES-CBC", "AES128-CBC", "AES192-CBC"]);
  1525. this.id = attributes.id || "";
  1526. this.use = attributes.use || "";
  1527. this.usehref = attributes.usehref || "";
  1528. }
  1529. }
  1530. class EncryptionMethods extends _xfa_object.XFAObject {
  1531. constructor(attributes) {
  1532. super(TEMPLATE_NS_ID, "encryptionMethods", true);
  1533. this.id = attributes.id || "";
  1534. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  1535. this.use = attributes.use || "";
  1536. this.usehref = attributes.usehref || "";
  1537. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  1538. }
  1539. }
  1540. class Event extends _xfa_object.XFAObject {
  1541. constructor(attributes) {
  1542. super(TEMPLATE_NS_ID, "event", true);
  1543. this.activity = (0, _utils.getStringOption)(attributes.activity, ["click", "change", "docClose", "docReady", "enter", "exit", "full", "indexChange", "initialize", "mouseDown", "mouseEnter", "mouseExit", "mouseUp", "postExecute", "postOpen", "postPrint", "postSave", "postSign", "postSubmit", "preExecute", "preOpen", "prePrint", "preSave", "preSign", "preSubmit", "ready", "validationState"]);
  1544. this.id = attributes.id || "";
  1545. this.listen = (0, _utils.getStringOption)(attributes.listen, ["refOnly", "refAndDescendents"]);
  1546. this.name = attributes.name || "";
  1547. this.ref = attributes.ref || "";
  1548. this.use = attributes.use || "";
  1549. this.usehref = attributes.usehref || "";
  1550. this.extras = null;
  1551. this.encryptData = null;
  1552. this.execute = null;
  1553. this.script = null;
  1554. this.signData = null;
  1555. this.submit = null;
  1556. }
  1557. }
  1558. class ExData extends _xfa_object.ContentObject {
  1559. constructor(attributes) {
  1560. super(TEMPLATE_NS_ID, "exData");
  1561. this.contentType = attributes.contentType || "";
  1562. this.href = attributes.href || "";
  1563. this.id = attributes.id || "";
  1564. this.maxLength = (0, _utils.getInteger)({
  1565. data: attributes.maxLength,
  1566. defaultValue: -1,
  1567. validate: x => x >= -1
  1568. });
  1569. this.name = attributes.name || "";
  1570. this.rid = attributes.rid || "";
  1571. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["none", "base64", "package"]);
  1572. this.use = attributes.use || "";
  1573. this.usehref = attributes.usehref || "";
  1574. }
  1575. [_xfa_object.$isCDATAXml]() {
  1576. return this.contentType === "text/html";
  1577. }
  1578. [_xfa_object.$onChild](child) {
  1579. if (this.contentType === "text/html" && child[_xfa_object.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  1580. this[_xfa_object.$content] = child;
  1581. return true;
  1582. }
  1583. if (this.contentType === "text/xml") {
  1584. this[_xfa_object.$content] = child;
  1585. return true;
  1586. }
  1587. return false;
  1588. }
  1589. [_xfa_object.$toHTML](availableSpace) {
  1590. if (this.contentType !== "text/html" || !this[_xfa_object.$content]) {
  1591. return _utils.HTMLResult.EMPTY;
  1592. }
  1593. return this[_xfa_object.$content][_xfa_object.$toHTML](availableSpace);
  1594. }
  1595. }
  1596. class ExObject extends _xfa_object.XFAObject {
  1597. constructor(attributes) {
  1598. super(TEMPLATE_NS_ID, "exObject", true);
  1599. this.archive = attributes.archive || "";
  1600. this.classId = attributes.classId || "";
  1601. this.codeBase = attributes.codeBase || "";
  1602. this.codeType = attributes.codeType || "";
  1603. this.id = attributes.id || "";
  1604. this.name = attributes.name || "";
  1605. this.use = attributes.use || "";
  1606. this.usehref = attributes.usehref || "";
  1607. this.extras = null;
  1608. this.boolean = new _xfa_object.XFAObjectArray();
  1609. this.date = new _xfa_object.XFAObjectArray();
  1610. this.dateTime = new _xfa_object.XFAObjectArray();
  1611. this.decimal = new _xfa_object.XFAObjectArray();
  1612. this.exData = new _xfa_object.XFAObjectArray();
  1613. this.exObject = new _xfa_object.XFAObjectArray();
  1614. this.float = new _xfa_object.XFAObjectArray();
  1615. this.image = new _xfa_object.XFAObjectArray();
  1616. this.integer = new _xfa_object.XFAObjectArray();
  1617. this.text = new _xfa_object.XFAObjectArray();
  1618. this.time = new _xfa_object.XFAObjectArray();
  1619. }
  1620. }
  1621. class ExclGroup extends _xfa_object.XFAObject {
  1622. constructor(attributes) {
  1623. super(TEMPLATE_NS_ID, "exclGroup", true);
  1624. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  1625. this.accessKey = attributes.accessKey || "";
  1626. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1627. this.colSpan = (0, _utils.getInteger)({
  1628. data: attributes.colSpan,
  1629. defaultValue: 1,
  1630. validate: n => n >= 1 || n === -1
  1631. });
  1632. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1633. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1634. this.id = attributes.id || "";
  1635. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  1636. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1637. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1638. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1639. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1640. this.name = attributes.name || "";
  1641. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1642. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1643. this.use = attributes.use || "";
  1644. this.usehref = attributes.usehref || "";
  1645. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1646. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1647. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1648. this.assist = null;
  1649. this.bind = null;
  1650. this.border = null;
  1651. this.calculate = null;
  1652. this.caption = null;
  1653. this.desc = null;
  1654. this.extras = null;
  1655. this.margin = null;
  1656. this.para = null;
  1657. this.traversal = null;
  1658. this.validate = null;
  1659. this.connect = new _xfa_object.XFAObjectArray();
  1660. this.event = new _xfa_object.XFAObjectArray();
  1661. this.field = new _xfa_object.XFAObjectArray();
  1662. this.setProperty = new _xfa_object.XFAObjectArray();
  1663. }
  1664. [_xfa_object.$isBindable]() {
  1665. return true;
  1666. }
  1667. [_xfa_object.$hasSettableValue]() {
  1668. return true;
  1669. }
  1670. [_xfa_object.$setValue](value) {
  1671. for (const field of this.field.children) {
  1672. if (!field.value) {
  1673. const nodeValue = new Value({});
  1674. field[_xfa_object.$appendChild](nodeValue);
  1675. field.value = nodeValue;
  1676. }
  1677. field.value[_xfa_object.$setValue](value);
  1678. }
  1679. }
  1680. [_xfa_object.$isThereMoreWidth]() {
  1681. return this.layout.endsWith("-tb") && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine > 0 || this[_xfa_object.$getParent]()[_xfa_object.$isThereMoreWidth]();
  1682. }
  1683. [_xfa_object.$isSplittable]() {
  1684. const parent = this[_xfa_object.$getSubformParent]();
  1685. if (!parent[_xfa_object.$isSplittable]()) {
  1686. return false;
  1687. }
  1688. if (this[_xfa_object.$extra]._isSplittable !== undefined) {
  1689. return this[_xfa_object.$extra]._isSplittable;
  1690. }
  1691. if (this.layout === "position" || this.layout.includes("row")) {
  1692. this[_xfa_object.$extra]._isSplittable = false;
  1693. return false;
  1694. }
  1695. if (parent.layout && parent.layout.endsWith("-tb") && parent[_xfa_object.$extra].numberInLine !== 0) {
  1696. return false;
  1697. }
  1698. this[_xfa_object.$extra]._isSplittable = true;
  1699. return true;
  1700. }
  1701. [_xfa_object.$flushHTML]() {
  1702. return (0, _layout.flushHTML)(this);
  1703. }
  1704. [_xfa_object.$addHTML](html, bbox) {
  1705. (0, _layout.addHTML)(this, html, bbox);
  1706. }
  1707. [_xfa_object.$getAvailableSpace]() {
  1708. return (0, _layout.getAvailableSpace)(this);
  1709. }
  1710. [_xfa_object.$toHTML](availableSpace) {
  1711. setTabIndex(this);
  1712. if (this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  1713. return _utils.HTMLResult.EMPTY;
  1714. }
  1715. (0, _html_utils.fixDimensions)(this);
  1716. const children = [];
  1717. const attributes = {
  1718. id: this[_xfa_object.$uid],
  1719. class: []
  1720. };
  1721. (0, _html_utils.setAccess)(this, attributes.class);
  1722. if (!this[_xfa_object.$extra]) {
  1723. this[_xfa_object.$extra] = Object.create(null);
  1724. }
  1725. Object.assign(this[_xfa_object.$extra], {
  1726. children,
  1727. attributes,
  1728. attempt: 0,
  1729. line: null,
  1730. numberInLine: 0,
  1731. availableSpace: {
  1732. width: Math.min(this.w || Infinity, availableSpace.width),
  1733. height: Math.min(this.h || Infinity, availableSpace.height)
  1734. },
  1735. width: 0,
  1736. height: 0,
  1737. prevHeight: 0,
  1738. currentWidth: 0
  1739. });
  1740. const isSplittable = this[_xfa_object.$isSplittable]();
  1741. if (!isSplittable) {
  1742. setFirstUnsplittable(this);
  1743. }
  1744. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  1745. return _utils.HTMLResult.FAILURE;
  1746. }
  1747. const filter = new Set(["field"]);
  1748. if (this.layout.includes("row")) {
  1749. const columnWidths = this[_xfa_object.$getSubformParent]().columnWidths;
  1750. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  1751. this[_xfa_object.$extra].columnWidths = columnWidths;
  1752. this[_xfa_object.$extra].currentColumn = 0;
  1753. }
  1754. }
  1755. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  1756. const classNames = ["xfaExclgroup"];
  1757. const cl = (0, _html_utils.layoutClass)(this);
  1758. if (cl) {
  1759. classNames.push(cl);
  1760. }
  1761. if ((0, _html_utils.isPrintOnly)(this)) {
  1762. classNames.push("xfaPrintOnly");
  1763. }
  1764. attributes.style = style;
  1765. attributes.class = classNames;
  1766. if (this.name) {
  1767. attributes.xfaName = this.name;
  1768. }
  1769. this[_xfa_object.$pushPara]();
  1770. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  1771. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  1772. for (; this[_xfa_object.$extra].attempt < maxRun; this[_xfa_object.$extra].attempt++) {
  1773. if (isLrTb && this[_xfa_object.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  1774. this[_xfa_object.$extra].numberInLine = 0;
  1775. }
  1776. const result = this[_xfa_object.$childrenToHTML]({
  1777. filter,
  1778. include: true
  1779. });
  1780. if (result.success) {
  1781. break;
  1782. }
  1783. if (result.isBreak()) {
  1784. this[_xfa_object.$popPara]();
  1785. return result;
  1786. }
  1787. if (isLrTb && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine === 0 && !this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].noLayoutFailure) {
  1788. this[_xfa_object.$extra].attempt = maxRun;
  1789. break;
  1790. }
  1791. }
  1792. this[_xfa_object.$popPara]();
  1793. if (!isSplittable) {
  1794. unsetFirstUnsplittable(this);
  1795. }
  1796. if (this[_xfa_object.$extra].attempt === maxRun) {
  1797. if (!isSplittable) {
  1798. delete this[_xfa_object.$extra];
  1799. }
  1800. return _utils.HTMLResult.FAILURE;
  1801. }
  1802. let marginH = 0;
  1803. let marginV = 0;
  1804. if (this.margin) {
  1805. marginH = this.margin.leftInset + this.margin.rightInset;
  1806. marginV = this.margin.topInset + this.margin.bottomInset;
  1807. }
  1808. const width = Math.max(this[_xfa_object.$extra].width + marginH, this.w || 0);
  1809. const height = Math.max(this[_xfa_object.$extra].height + marginV, this.h || 0);
  1810. const bbox = [this.x, this.y, width, height];
  1811. if (this.w === "") {
  1812. style.width = (0, _html_utils.measureToString)(width);
  1813. }
  1814. if (this.h === "") {
  1815. style.height = (0, _html_utils.measureToString)(height);
  1816. }
  1817. const html = {
  1818. name: "div",
  1819. attributes,
  1820. children
  1821. };
  1822. applyAssist(this, attributes);
  1823. delete this[_xfa_object.$extra];
  1824. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  1825. }
  1826. }
  1827. class Execute extends _xfa_object.XFAObject {
  1828. constructor(attributes) {
  1829. super(TEMPLATE_NS_ID, "execute");
  1830. this.connection = attributes.connection || "";
  1831. this.executeType = (0, _utils.getStringOption)(attributes.executeType, ["import", "remerge"]);
  1832. this.id = attributes.id || "";
  1833. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  1834. this.use = attributes.use || "";
  1835. this.usehref = attributes.usehref || "";
  1836. }
  1837. }
  1838. class Extras extends _xfa_object.XFAObject {
  1839. constructor(attributes) {
  1840. super(TEMPLATE_NS_ID, "extras", true);
  1841. this.id = attributes.id || "";
  1842. this.name = attributes.name || "";
  1843. this.use = attributes.use || "";
  1844. this.usehref = attributes.usehref || "";
  1845. this.boolean = new _xfa_object.XFAObjectArray();
  1846. this.date = new _xfa_object.XFAObjectArray();
  1847. this.dateTime = new _xfa_object.XFAObjectArray();
  1848. this.decimal = new _xfa_object.XFAObjectArray();
  1849. this.exData = new _xfa_object.XFAObjectArray();
  1850. this.extras = new _xfa_object.XFAObjectArray();
  1851. this.float = new _xfa_object.XFAObjectArray();
  1852. this.image = new _xfa_object.XFAObjectArray();
  1853. this.integer = new _xfa_object.XFAObjectArray();
  1854. this.text = new _xfa_object.XFAObjectArray();
  1855. this.time = new _xfa_object.XFAObjectArray();
  1856. }
  1857. }
  1858. class Field extends _xfa_object.XFAObject {
  1859. constructor(attributes) {
  1860. super(TEMPLATE_NS_ID, "field", true);
  1861. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  1862. this.accessKey = attributes.accessKey || "";
  1863. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  1864. this.colSpan = (0, _utils.getInteger)({
  1865. data: attributes.colSpan,
  1866. defaultValue: 1,
  1867. validate: n => n >= 1 || n === -1
  1868. });
  1869. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  1870. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  1871. this.id = attributes.id || "";
  1872. this.locale = attributes.locale || "";
  1873. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  1874. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  1875. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  1876. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  1877. this.name = attributes.name || "";
  1878. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  1879. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  1880. this.rotate = (0, _utils.getInteger)({
  1881. data: attributes.rotate,
  1882. defaultValue: 0,
  1883. validate: x => x % 90 === 0
  1884. });
  1885. this.use = attributes.use || "";
  1886. this.usehref = attributes.usehref || "";
  1887. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  1888. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  1889. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  1890. this.assist = null;
  1891. this.bind = null;
  1892. this.border = null;
  1893. this.calculate = null;
  1894. this.caption = null;
  1895. this.desc = null;
  1896. this.extras = null;
  1897. this.font = null;
  1898. this.format = null;
  1899. this.items = new _xfa_object.XFAObjectArray(2);
  1900. this.keep = null;
  1901. this.margin = null;
  1902. this.para = null;
  1903. this.traversal = null;
  1904. this.ui = null;
  1905. this.validate = null;
  1906. this.value = null;
  1907. this.bindItems = new _xfa_object.XFAObjectArray();
  1908. this.connect = new _xfa_object.XFAObjectArray();
  1909. this.event = new _xfa_object.XFAObjectArray();
  1910. this.setProperty = new _xfa_object.XFAObjectArray();
  1911. }
  1912. [_xfa_object.$isBindable]() {
  1913. return true;
  1914. }
  1915. [_xfa_object.$setValue](value) {
  1916. _setValue(this, value);
  1917. }
  1918. [_xfa_object.$toHTML](availableSpace) {
  1919. setTabIndex(this);
  1920. if (!this.ui) {
  1921. this.ui = new Ui({});
  1922. this.ui[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  1923. this[_xfa_object.$appendChild](this.ui);
  1924. let node;
  1925. switch (this.items.children.length) {
  1926. case 0:
  1927. node = new TextEdit({});
  1928. this.ui.textEdit = node;
  1929. break;
  1930. case 1:
  1931. node = new CheckButton({});
  1932. this.ui.checkButton = node;
  1933. break;
  1934. case 2:
  1935. node = new ChoiceList({});
  1936. this.ui.choiceList = node;
  1937. break;
  1938. }
  1939. this.ui[_xfa_object.$appendChild](node);
  1940. }
  1941. if (!this.ui || this.presence === "hidden" || this.presence === "inactive" || this.h === 0 || this.w === 0) {
  1942. return _utils.HTMLResult.EMPTY;
  1943. }
  1944. if (this.caption) {
  1945. delete this.caption[_xfa_object.$extra];
  1946. }
  1947. this[_xfa_object.$pushPara]();
  1948. const caption = this.caption ? this.caption[_xfa_object.$toHTML](availableSpace).html : null;
  1949. const savedW = this.w;
  1950. const savedH = this.h;
  1951. let marginH = 0;
  1952. let marginV = 0;
  1953. if (this.margin) {
  1954. marginH = this.margin.leftInset + this.margin.rightInset;
  1955. marginV = this.margin.topInset + this.margin.bottomInset;
  1956. }
  1957. let borderDims = null;
  1958. if (this.w === "" || this.h === "") {
  1959. let width = null;
  1960. let height = null;
  1961. let uiW = 0;
  1962. let uiH = 0;
  1963. if (this.ui.checkButton) {
  1964. uiW = uiH = this.ui.checkButton.size;
  1965. } else {
  1966. const {
  1967. w,
  1968. h
  1969. } = (0, _html_utils.layoutNode)(this, availableSpace);
  1970. if (w !== null) {
  1971. uiW = w;
  1972. uiH = h;
  1973. } else {
  1974. uiH = (0, _fonts.getMetrics)(this.font, true).lineNoGap;
  1975. }
  1976. }
  1977. borderDims = getBorderDims(this.ui[_xfa_object.$getExtra]());
  1978. uiW += borderDims.w;
  1979. uiH += borderDims.h;
  1980. if (this.caption) {
  1981. const {
  1982. w,
  1983. h,
  1984. isBroken
  1985. } = this.caption[_xfa_object.$getExtra](availableSpace);
  1986. if (isBroken && this[_xfa_object.$getSubformParent]()[_xfa_object.$isThereMoreWidth]()) {
  1987. this[_xfa_object.$popPara]();
  1988. return _utils.HTMLResult.FAILURE;
  1989. }
  1990. width = w;
  1991. height = h;
  1992. switch (this.caption.placement) {
  1993. case "left":
  1994. case "right":
  1995. case "inline":
  1996. width += uiW;
  1997. break;
  1998. case "top":
  1999. case "bottom":
  2000. height += uiH;
  2001. break;
  2002. }
  2003. } else {
  2004. width = uiW;
  2005. height = uiH;
  2006. }
  2007. if (width && this.w === "") {
  2008. width += marginH;
  2009. this.w = Math.min(this.maxW <= 0 ? Infinity : this.maxW, this.minW + 1 < width ? width : this.minW);
  2010. }
  2011. if (height && this.h === "") {
  2012. height += marginV;
  2013. this.h = Math.min(this.maxH <= 0 ? Infinity : this.maxH, this.minH + 1 < height ? height : this.minH);
  2014. }
  2015. }
  2016. this[_xfa_object.$popPara]();
  2017. (0, _html_utils.fixDimensions)(this);
  2018. setFirstUnsplittable(this);
  2019. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  2020. this.w = savedW;
  2021. this.h = savedH;
  2022. this[_xfa_object.$popPara]();
  2023. return _utils.HTMLResult.FAILURE;
  2024. }
  2025. unsetFirstUnsplittable(this);
  2026. const style = (0, _html_utils.toStyle)(this, "font", "dimensions", "position", "rotate", "anchorType", "presence", "margin", "hAlign");
  2027. (0, _html_utils.setMinMaxDimensions)(this, style);
  2028. const classNames = ["xfaField"];
  2029. if (this.font) {
  2030. classNames.push("xfaFont");
  2031. }
  2032. if ((0, _html_utils.isPrintOnly)(this)) {
  2033. classNames.push("xfaPrintOnly");
  2034. }
  2035. const attributes = {
  2036. style,
  2037. id: this[_xfa_object.$uid],
  2038. class: classNames
  2039. };
  2040. if (style.margin) {
  2041. style.padding = style.margin;
  2042. delete style.margin;
  2043. }
  2044. (0, _html_utils.setAccess)(this, classNames);
  2045. if (this.name) {
  2046. attributes.xfaName = this.name;
  2047. }
  2048. const children = [];
  2049. const html = {
  2050. name: "div",
  2051. attributes,
  2052. children
  2053. };
  2054. applyAssist(this, attributes);
  2055. const borderStyle = this.border ? this.border[_xfa_object.$toStyle]() : null;
  2056. const bbox = (0, _html_utils.computeBbox)(this, html, availableSpace);
  2057. const ui = this.ui[_xfa_object.$toHTML]().html;
  2058. if (!ui) {
  2059. Object.assign(style, borderStyle);
  2060. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2061. }
  2062. if (this[_xfa_object.$tabIndex]) {
  2063. if (ui.children && ui.children[0]) {
  2064. ui.children[0].attributes.tabindex = this[_xfa_object.$tabIndex];
  2065. } else {
  2066. ui.attributes.tabindex = this[_xfa_object.$tabIndex];
  2067. }
  2068. }
  2069. if (!ui.attributes.style) {
  2070. ui.attributes.style = Object.create(null);
  2071. }
  2072. let aElement = null;
  2073. if (this.ui.button) {
  2074. if (ui.children.length === 1) {
  2075. [aElement] = ui.children.splice(0, 1);
  2076. }
  2077. Object.assign(ui.attributes.style, borderStyle);
  2078. } else {
  2079. Object.assign(style, borderStyle);
  2080. }
  2081. children.push(ui);
  2082. if (this.value) {
  2083. if (this.ui.imageEdit) {
  2084. ui.children.push(this.value[_xfa_object.$toHTML]().html);
  2085. } else if (!this.ui.button) {
  2086. let value = "";
  2087. if (this.value.exData) {
  2088. value = this.value.exData[_xfa_object.$text]();
  2089. } else if (this.value.text) {
  2090. value = this.value.text[_xfa_object.$getExtra]();
  2091. } else {
  2092. const htmlValue = this.value[_xfa_object.$toHTML]().html;
  2093. if (htmlValue !== null) {
  2094. value = htmlValue.children[0].value;
  2095. }
  2096. }
  2097. if (this.ui.textEdit && this.value.text && this.value.text.maxChars) {
  2098. ui.children[0].attributes.maxLength = this.value.text.maxChars;
  2099. }
  2100. if (value) {
  2101. if (this.ui.numericEdit) {
  2102. value = parseFloat(value);
  2103. value = isNaN(value) ? "" : value.toString();
  2104. }
  2105. if (ui.children[0].name === "textarea") {
  2106. ui.children[0].attributes.textContent = value;
  2107. } else {
  2108. ui.children[0].attributes.value = value;
  2109. }
  2110. }
  2111. }
  2112. }
  2113. if (!this.ui.imageEdit && ui.children && ui.children[0] && this.h) {
  2114. borderDims = borderDims || getBorderDims(this.ui[_xfa_object.$getExtra]());
  2115. let captionHeight = 0;
  2116. if (this.caption && ["top", "bottom"].includes(this.caption.placement)) {
  2117. captionHeight = this.caption.reserve;
  2118. if (captionHeight <= 0) {
  2119. captionHeight = this.caption[_xfa_object.$getExtra](availableSpace).h;
  2120. }
  2121. const inputHeight = this.h - captionHeight - marginV - borderDims.h;
  2122. ui.children[0].attributes.style.height = (0, _html_utils.measureToString)(inputHeight);
  2123. } else {
  2124. ui.children[0].attributes.style.height = "100%";
  2125. }
  2126. }
  2127. if (aElement) {
  2128. ui.children.push(aElement);
  2129. }
  2130. if (!caption) {
  2131. if (ui.attributes.class) {
  2132. ui.attributes.class.push("xfaLeft");
  2133. }
  2134. this.w = savedW;
  2135. this.h = savedH;
  2136. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2137. }
  2138. if (this.ui.button) {
  2139. if (style.padding) {
  2140. delete style.padding;
  2141. }
  2142. if (caption.name === "div") {
  2143. caption.name = "span";
  2144. }
  2145. ui.children.push(caption);
  2146. return _utils.HTMLResult.success(html, bbox);
  2147. } else if (this.ui.checkButton) {
  2148. caption.attributes.class[0] = "xfaCaptionForCheckButton";
  2149. }
  2150. if (!ui.attributes.class) {
  2151. ui.attributes.class = [];
  2152. }
  2153. ui.children.splice(0, 0, caption);
  2154. switch (this.caption.placement) {
  2155. case "left":
  2156. ui.attributes.class.push("xfaLeft");
  2157. break;
  2158. case "right":
  2159. ui.attributes.class.push("xfaRight");
  2160. break;
  2161. case "top":
  2162. ui.attributes.class.push("xfaTop");
  2163. break;
  2164. case "bottom":
  2165. ui.attributes.class.push("xfaBottom");
  2166. break;
  2167. case "inline":
  2168. ui.attributes.class.push("xfaLeft");
  2169. break;
  2170. }
  2171. this.w = savedW;
  2172. this.h = savedH;
  2173. return _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  2174. }
  2175. }
  2176. exports.Field = Field;
  2177. class Fill extends _xfa_object.XFAObject {
  2178. constructor(attributes) {
  2179. super(TEMPLATE_NS_ID, "fill", true);
  2180. this.id = attributes.id || "";
  2181. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  2182. this.use = attributes.use || "";
  2183. this.usehref = attributes.usehref || "";
  2184. this.color = null;
  2185. this.extras = null;
  2186. this.linear = null;
  2187. this.pattern = null;
  2188. this.radial = null;
  2189. this.solid = null;
  2190. this.stipple = null;
  2191. }
  2192. [_xfa_object.$toStyle]() {
  2193. const parent = this[_xfa_object.$getParent]();
  2194. const grandpa = parent[_xfa_object.$getParent]();
  2195. const ggrandpa = grandpa[_xfa_object.$getParent]();
  2196. const style = Object.create(null);
  2197. let propName = "color";
  2198. let altPropName = propName;
  2199. if (parent instanceof Border) {
  2200. propName = "background-color";
  2201. altPropName = "background";
  2202. if (ggrandpa instanceof Ui) {
  2203. style.backgroundColor = "white";
  2204. }
  2205. }
  2206. if (parent instanceof Rectangle || parent instanceof Arc) {
  2207. propName = altPropName = "fill";
  2208. style.fill = "white";
  2209. }
  2210. for (const name of Object.getOwnPropertyNames(this)) {
  2211. if (name === "extras" || name === "color") {
  2212. continue;
  2213. }
  2214. const obj = this[name];
  2215. if (!(obj instanceof _xfa_object.XFAObject)) {
  2216. continue;
  2217. }
  2218. const color = obj[_xfa_object.$toStyle](this.color);
  2219. if (color) {
  2220. style[color.startsWith("#") ? propName : altPropName] = color;
  2221. }
  2222. return style;
  2223. }
  2224. if (this.color && this.color.value) {
  2225. const color = this.color[_xfa_object.$toStyle]();
  2226. style[color.startsWith("#") ? propName : altPropName] = color;
  2227. }
  2228. return style;
  2229. }
  2230. }
  2231. class Filter extends _xfa_object.XFAObject {
  2232. constructor(attributes) {
  2233. super(TEMPLATE_NS_ID, "filter", true);
  2234. this.addRevocationInfo = (0, _utils.getStringOption)(attributes.addRevocationInfo, ["", "required", "optional", "none"]);
  2235. this.id = attributes.id || "";
  2236. this.name = attributes.name || "";
  2237. this.use = attributes.use || "";
  2238. this.usehref = attributes.usehref || "";
  2239. this.version = (0, _utils.getInteger)({
  2240. data: this.version,
  2241. defaultValue: 5,
  2242. validate: x => x >= 1 && x <= 5
  2243. });
  2244. this.appearanceFilter = null;
  2245. this.certificates = null;
  2246. this.digestMethods = null;
  2247. this.encodings = null;
  2248. this.encryptionMethods = null;
  2249. this.handler = null;
  2250. this.lockDocument = null;
  2251. this.mdp = null;
  2252. this.reasons = null;
  2253. this.timeStamp = null;
  2254. }
  2255. }
  2256. class Float extends _xfa_object.ContentObject {
  2257. constructor(attributes) {
  2258. super(TEMPLATE_NS_ID, "float");
  2259. this.id = attributes.id || "";
  2260. this.name = attributes.name || "";
  2261. this.use = attributes.use || "";
  2262. this.usehref = attributes.usehref || "";
  2263. }
  2264. [_xfa_object.$finalize]() {
  2265. const number = parseFloat(this[_xfa_object.$content].trim());
  2266. this[_xfa_object.$content] = isNaN(number) ? null : number;
  2267. }
  2268. [_xfa_object.$toHTML](availableSpace) {
  2269. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  2270. }
  2271. }
  2272. class Font extends _xfa_object.XFAObject {
  2273. constructor(attributes) {
  2274. super(TEMPLATE_NS_ID, "font", true);
  2275. this.baselineShift = (0, _utils.getMeasurement)(attributes.baselineShift);
  2276. this.fontHorizontalScale = (0, _utils.getFloat)({
  2277. data: attributes.fontHorizontalScale,
  2278. defaultValue: 100,
  2279. validate: x => x >= 0
  2280. });
  2281. this.fontVerticalScale = (0, _utils.getFloat)({
  2282. data: attributes.fontVerticalScale,
  2283. defaultValue: 100,
  2284. validate: x => x >= 0
  2285. });
  2286. this.id = attributes.id || "";
  2287. this.kerningMode = (0, _utils.getStringOption)(attributes.kerningMode, ["none", "pair"]);
  2288. this.letterSpacing = (0, _utils.getMeasurement)(attributes.letterSpacing, "0");
  2289. this.lineThrough = (0, _utils.getInteger)({
  2290. data: attributes.lineThrough,
  2291. defaultValue: 0,
  2292. validate: x => x === 1 || x === 2
  2293. });
  2294. this.lineThroughPeriod = (0, _utils.getStringOption)(attributes.lineThroughPeriod, ["all", "word"]);
  2295. this.overline = (0, _utils.getInteger)({
  2296. data: attributes.overline,
  2297. defaultValue: 0,
  2298. validate: x => x === 1 || x === 2
  2299. });
  2300. this.overlinePeriod = (0, _utils.getStringOption)(attributes.overlinePeriod, ["all", "word"]);
  2301. this.posture = (0, _utils.getStringOption)(attributes.posture, ["normal", "italic"]);
  2302. this.size = (0, _utils.getMeasurement)(attributes.size, "10pt");
  2303. this.typeface = attributes.typeface || "Courier";
  2304. this.underline = (0, _utils.getInteger)({
  2305. data: attributes.underline,
  2306. defaultValue: 0,
  2307. validate: x => x === 1 || x === 2
  2308. });
  2309. this.underlinePeriod = (0, _utils.getStringOption)(attributes.underlinePeriod, ["all", "word"]);
  2310. this.use = attributes.use || "";
  2311. this.usehref = attributes.usehref || "";
  2312. this.weight = (0, _utils.getStringOption)(attributes.weight, ["normal", "bold"]);
  2313. this.extras = null;
  2314. this.fill = null;
  2315. }
  2316. [_xfa_object.$clean](builder) {
  2317. super[_xfa_object.$clean](builder);
  2318. this[_xfa_object.$globalData].usedTypefaces.add(this.typeface);
  2319. }
  2320. [_xfa_object.$toStyle]() {
  2321. const style = (0, _html_utils.toStyle)(this, "fill");
  2322. const color = style.color;
  2323. if (color) {
  2324. if (color === "#000000") {
  2325. delete style.color;
  2326. } else if (!color.startsWith("#")) {
  2327. style.background = color;
  2328. style.backgroundClip = "text";
  2329. style.color = "transparent";
  2330. }
  2331. }
  2332. if (this.baselineShift) {
  2333. style.verticalAlign = (0, _html_utils.measureToString)(this.baselineShift);
  2334. }
  2335. style.fontKerning = this.kerningMode === "none" ? "none" : "normal";
  2336. style.letterSpacing = (0, _html_utils.measureToString)(this.letterSpacing);
  2337. if (this.lineThrough !== 0) {
  2338. style.textDecoration = "line-through";
  2339. if (this.lineThrough === 2) {
  2340. style.textDecorationStyle = "double";
  2341. }
  2342. }
  2343. if (this.overline !== 0) {
  2344. style.textDecoration = "overline";
  2345. if (this.overline === 2) {
  2346. style.textDecorationStyle = "double";
  2347. }
  2348. }
  2349. style.fontStyle = this.posture;
  2350. style.fontSize = (0, _html_utils.measureToString)(0.99 * this.size);
  2351. (0, _html_utils.setFontFamily)(this, this, this[_xfa_object.$globalData].fontFinder, style);
  2352. if (this.underline !== 0) {
  2353. style.textDecoration = "underline";
  2354. if (this.underline === 2) {
  2355. style.textDecorationStyle = "double";
  2356. }
  2357. }
  2358. style.fontWeight = this.weight;
  2359. return style;
  2360. }
  2361. }
  2362. class Format extends _xfa_object.XFAObject {
  2363. constructor(attributes) {
  2364. super(TEMPLATE_NS_ID, "format", true);
  2365. this.id = attributes.id || "";
  2366. this.use = attributes.use || "";
  2367. this.usehref = attributes.usehref || "";
  2368. this.extras = null;
  2369. this.picture = null;
  2370. }
  2371. }
  2372. class Handler extends _xfa_object.StringObject {
  2373. constructor(attributes) {
  2374. super(TEMPLATE_NS_ID, "handler");
  2375. this.id = attributes.id || "";
  2376. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2377. this.use = attributes.use || "";
  2378. this.usehref = attributes.usehref || "";
  2379. }
  2380. }
  2381. class Hyphenation extends _xfa_object.XFAObject {
  2382. constructor(attributes) {
  2383. super(TEMPLATE_NS_ID, "hyphenation");
  2384. this.excludeAllCaps = (0, _utils.getInteger)({
  2385. data: attributes.excludeAllCaps,
  2386. defaultValue: 0,
  2387. validate: x => x === 1
  2388. });
  2389. this.excludeInitialCap = (0, _utils.getInteger)({
  2390. data: attributes.excludeInitialCap,
  2391. defaultValue: 0,
  2392. validate: x => x === 1
  2393. });
  2394. this.hyphenate = (0, _utils.getInteger)({
  2395. data: attributes.hyphenate,
  2396. defaultValue: 0,
  2397. validate: x => x === 1
  2398. });
  2399. this.id = attributes.id || "";
  2400. this.pushCharacterCount = (0, _utils.getInteger)({
  2401. data: attributes.pushCharacterCount,
  2402. defaultValue: 3,
  2403. validate: x => x >= 0
  2404. });
  2405. this.remainCharacterCount = (0, _utils.getInteger)({
  2406. data: attributes.remainCharacterCount,
  2407. defaultValue: 3,
  2408. validate: x => x >= 0
  2409. });
  2410. this.use = attributes.use || "";
  2411. this.usehref = attributes.usehref || "";
  2412. this.wordCharacterCount = (0, _utils.getInteger)({
  2413. data: attributes.wordCharacterCount,
  2414. defaultValue: 7,
  2415. validate: x => x >= 0
  2416. });
  2417. }
  2418. }
  2419. class Image extends _xfa_object.StringObject {
  2420. constructor(attributes) {
  2421. super(TEMPLATE_NS_ID, "image");
  2422. this.aspect = (0, _utils.getStringOption)(attributes.aspect, ["fit", "actual", "height", "none", "width"]);
  2423. this.contentType = attributes.contentType || "";
  2424. this.href = attributes.href || "";
  2425. this.id = attributes.id || "";
  2426. this.name = attributes.name || "";
  2427. this.transferEncoding = (0, _utils.getStringOption)(attributes.transferEncoding, ["base64", "none", "package"]);
  2428. this.use = attributes.use || "";
  2429. this.usehref = attributes.usehref || "";
  2430. }
  2431. [_xfa_object.$toHTML]() {
  2432. if (this.contentType && !MIMES.has(this.contentType.toLowerCase())) {
  2433. return _utils.HTMLResult.EMPTY;
  2434. }
  2435. let buffer = this[_xfa_object.$globalData].images && this[_xfa_object.$globalData].images.get(this.href);
  2436. if (!buffer && (this.href || !this[_xfa_object.$content])) {
  2437. return _utils.HTMLResult.EMPTY;
  2438. }
  2439. if (!buffer && this.transferEncoding === "base64") {
  2440. buffer = (0, _util.stringToBytes)(atob(this[_xfa_object.$content]));
  2441. }
  2442. if (!buffer) {
  2443. return _utils.HTMLResult.EMPTY;
  2444. }
  2445. if (!this.contentType) {
  2446. for (const [header, type] of IMAGES_HEADERS) {
  2447. if (buffer.length > header.length && header.every((x, i) => x === buffer[i])) {
  2448. this.contentType = type;
  2449. break;
  2450. }
  2451. }
  2452. if (!this.contentType) {
  2453. return _utils.HTMLResult.EMPTY;
  2454. }
  2455. }
  2456. const blob = new Blob([buffer], {
  2457. type: this.contentType
  2458. });
  2459. let style;
  2460. switch (this.aspect) {
  2461. case "fit":
  2462. case "actual":
  2463. break;
  2464. case "height":
  2465. style = {
  2466. height: "100%",
  2467. objectFit: "fill"
  2468. };
  2469. break;
  2470. case "none":
  2471. style = {
  2472. width: "100%",
  2473. height: "100%",
  2474. objectFit: "fill"
  2475. };
  2476. break;
  2477. case "width":
  2478. style = {
  2479. width: "100%",
  2480. objectFit: "fill"
  2481. };
  2482. break;
  2483. }
  2484. const parent = this[_xfa_object.$getParent]();
  2485. return _utils.HTMLResult.success({
  2486. name: "img",
  2487. attributes: {
  2488. class: ["xfaImage"],
  2489. style,
  2490. src: URL.createObjectURL(blob),
  2491. alt: parent ? ariaLabel(parent[_xfa_object.$getParent]()) : null
  2492. }
  2493. });
  2494. }
  2495. }
  2496. class ImageEdit extends _xfa_object.XFAObject {
  2497. constructor(attributes) {
  2498. super(TEMPLATE_NS_ID, "imageEdit", true);
  2499. this.data = (0, _utils.getStringOption)(attributes.data, ["link", "embed"]);
  2500. this.id = attributes.id || "";
  2501. this.use = attributes.use || "";
  2502. this.usehref = attributes.usehref || "";
  2503. this.border = null;
  2504. this.extras = null;
  2505. this.margin = null;
  2506. }
  2507. [_xfa_object.$toHTML](availableSpace) {
  2508. if (this.data === "embed") {
  2509. return _utils.HTMLResult.success({
  2510. name: "div",
  2511. children: [],
  2512. attributes: {}
  2513. });
  2514. }
  2515. return _utils.HTMLResult.EMPTY;
  2516. }
  2517. }
  2518. class Integer extends _xfa_object.ContentObject {
  2519. constructor(attributes) {
  2520. super(TEMPLATE_NS_ID, "integer");
  2521. this.id = attributes.id || "";
  2522. this.name = attributes.name || "";
  2523. this.use = attributes.use || "";
  2524. this.usehref = attributes.usehref || "";
  2525. }
  2526. [_xfa_object.$finalize]() {
  2527. const number = parseInt(this[_xfa_object.$content].trim(), 10);
  2528. this[_xfa_object.$content] = isNaN(number) ? null : number;
  2529. }
  2530. [_xfa_object.$toHTML](availableSpace) {
  2531. return valueToHtml(this[_xfa_object.$content] !== null ? this[_xfa_object.$content].toString() : "");
  2532. }
  2533. }
  2534. class Issuers extends _xfa_object.XFAObject {
  2535. constructor(attributes) {
  2536. super(TEMPLATE_NS_ID, "issuers", true);
  2537. this.id = attributes.id || "";
  2538. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2539. this.use = attributes.use || "";
  2540. this.usehref = attributes.usehref || "";
  2541. this.certificate = new _xfa_object.XFAObjectArray();
  2542. }
  2543. }
  2544. class Items extends _xfa_object.XFAObject {
  2545. constructor(attributes) {
  2546. super(TEMPLATE_NS_ID, "items", true);
  2547. this.id = attributes.id || "";
  2548. this.name = attributes.name || "";
  2549. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  2550. this.ref = attributes.ref || "";
  2551. this.save = (0, _utils.getInteger)({
  2552. data: attributes.save,
  2553. defaultValue: 0,
  2554. validate: x => x === 1
  2555. });
  2556. this.use = attributes.use || "";
  2557. this.usehref = attributes.usehref || "";
  2558. this.boolean = new _xfa_object.XFAObjectArray();
  2559. this.date = new _xfa_object.XFAObjectArray();
  2560. this.dateTime = new _xfa_object.XFAObjectArray();
  2561. this.decimal = new _xfa_object.XFAObjectArray();
  2562. this.exData = new _xfa_object.XFAObjectArray();
  2563. this.float = new _xfa_object.XFAObjectArray();
  2564. this.image = new _xfa_object.XFAObjectArray();
  2565. this.integer = new _xfa_object.XFAObjectArray();
  2566. this.text = new _xfa_object.XFAObjectArray();
  2567. this.time = new _xfa_object.XFAObjectArray();
  2568. }
  2569. [_xfa_object.$toHTML]() {
  2570. const output = [];
  2571. for (const child of this[_xfa_object.$getChildren]()) {
  2572. output.push(child[_xfa_object.$text]());
  2573. }
  2574. return _utils.HTMLResult.success(output);
  2575. }
  2576. }
  2577. exports.Items = Items;
  2578. class Keep extends _xfa_object.XFAObject {
  2579. constructor(attributes) {
  2580. super(TEMPLATE_NS_ID, "keep", true);
  2581. this.id = attributes.id || "";
  2582. const options = ["none", "contentArea", "pageArea"];
  2583. this.intact = (0, _utils.getStringOption)(attributes.intact, options);
  2584. this.next = (0, _utils.getStringOption)(attributes.next, options);
  2585. this.previous = (0, _utils.getStringOption)(attributes.previous, options);
  2586. this.use = attributes.use || "";
  2587. this.usehref = attributes.usehref || "";
  2588. this.extras = null;
  2589. }
  2590. }
  2591. class KeyUsage extends _xfa_object.XFAObject {
  2592. constructor(attributes) {
  2593. super(TEMPLATE_NS_ID, "keyUsage");
  2594. const options = ["", "yes", "no"];
  2595. this.crlSign = (0, _utils.getStringOption)(attributes.crlSign, options);
  2596. this.dataEncipherment = (0, _utils.getStringOption)(attributes.dataEncipherment, options);
  2597. this.decipherOnly = (0, _utils.getStringOption)(attributes.decipherOnly, options);
  2598. this.digitalSignature = (0, _utils.getStringOption)(attributes.digitalSignature, options);
  2599. this.encipherOnly = (0, _utils.getStringOption)(attributes.encipherOnly, options);
  2600. this.id = attributes.id || "";
  2601. this.keyAgreement = (0, _utils.getStringOption)(attributes.keyAgreement, options);
  2602. this.keyCertSign = (0, _utils.getStringOption)(attributes.keyCertSign, options);
  2603. this.keyEncipherment = (0, _utils.getStringOption)(attributes.keyEncipherment, options);
  2604. this.nonRepudiation = (0, _utils.getStringOption)(attributes.nonRepudiation, options);
  2605. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2606. this.use = attributes.use || "";
  2607. this.usehref = attributes.usehref || "";
  2608. }
  2609. }
  2610. class Line extends _xfa_object.XFAObject {
  2611. constructor(attributes) {
  2612. super(TEMPLATE_NS_ID, "line", true);
  2613. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  2614. this.id = attributes.id || "";
  2615. this.slope = (0, _utils.getStringOption)(attributes.slope, ["\\", "/"]);
  2616. this.use = attributes.use || "";
  2617. this.usehref = attributes.usehref || "";
  2618. this.edge = null;
  2619. }
  2620. [_xfa_object.$toHTML]() {
  2621. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  2622. const edge = this.edge ? this.edge : new Edge({});
  2623. const edgeStyle = edge[_xfa_object.$toStyle]();
  2624. const style = Object.create(null);
  2625. const thickness = edge.presence === "visible" ? edge.thickness : 0;
  2626. style.strokeWidth = (0, _html_utils.measureToString)(thickness);
  2627. style.stroke = edgeStyle.color;
  2628. let x1, y1, x2, y2;
  2629. let width = "100%";
  2630. let height = "100%";
  2631. if (parent.w <= thickness) {
  2632. [x1, y1, x2, y2] = ["50%", 0, "50%", "100%"];
  2633. width = style.strokeWidth;
  2634. } else if (parent.h <= thickness) {
  2635. [x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
  2636. height = style.strokeWidth;
  2637. } else {
  2638. if (this.slope === "\\") {
  2639. [x1, y1, x2, y2] = [0, 0, "100%", "100%"];
  2640. } else {
  2641. [x1, y1, x2, y2] = [0, "100%", "100%", 0];
  2642. }
  2643. }
  2644. const line = {
  2645. name: "line",
  2646. attributes: {
  2647. xmlns: SVG_NS,
  2648. x1,
  2649. y1,
  2650. x2,
  2651. y2,
  2652. style
  2653. }
  2654. };
  2655. const svg = {
  2656. name: "svg",
  2657. children: [line],
  2658. attributes: {
  2659. xmlns: SVG_NS,
  2660. width,
  2661. height,
  2662. style: {
  2663. overflow: "visible"
  2664. }
  2665. }
  2666. };
  2667. if (hasMargin(parent)) {
  2668. return _utils.HTMLResult.success({
  2669. name: "div",
  2670. attributes: {
  2671. style: {
  2672. display: "inline",
  2673. width: "100%",
  2674. height: "100%"
  2675. }
  2676. },
  2677. children: [svg]
  2678. });
  2679. }
  2680. svg.attributes.style.position = "absolute";
  2681. return _utils.HTMLResult.success(svg);
  2682. }
  2683. }
  2684. class Linear extends _xfa_object.XFAObject {
  2685. constructor(attributes) {
  2686. super(TEMPLATE_NS_ID, "linear", true);
  2687. this.id = attributes.id || "";
  2688. this.type = (0, _utils.getStringOption)(attributes.type, ["toRight", "toBottom", "toLeft", "toTop"]);
  2689. this.use = attributes.use || "";
  2690. this.usehref = attributes.usehref || "";
  2691. this.color = null;
  2692. this.extras = null;
  2693. }
  2694. [_xfa_object.$toStyle](startColor) {
  2695. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  2696. const transf = this.type.replace(/([RBLT])/, " $1").toLowerCase();
  2697. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  2698. return `linear-gradient(${transf}, ${startColor}, ${endColor})`;
  2699. }
  2700. }
  2701. class LockDocument extends _xfa_object.ContentObject {
  2702. constructor(attributes) {
  2703. super(TEMPLATE_NS_ID, "lockDocument");
  2704. this.id = attributes.id || "";
  2705. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2706. this.use = attributes.use || "";
  2707. this.usehref = attributes.usehref || "";
  2708. }
  2709. [_xfa_object.$finalize]() {
  2710. this[_xfa_object.$content] = (0, _utils.getStringOption)(this[_xfa_object.$content], ["auto", "0", "1"]);
  2711. }
  2712. }
  2713. class Manifest extends _xfa_object.XFAObject {
  2714. constructor(attributes) {
  2715. super(TEMPLATE_NS_ID, "manifest", true);
  2716. this.action = (0, _utils.getStringOption)(attributes.action, ["include", "all", "exclude"]);
  2717. this.id = attributes.id || "";
  2718. this.name = attributes.name || "";
  2719. this.use = attributes.use || "";
  2720. this.usehref = attributes.usehref || "";
  2721. this.extras = null;
  2722. this.ref = new _xfa_object.XFAObjectArray();
  2723. }
  2724. }
  2725. class Margin extends _xfa_object.XFAObject {
  2726. constructor(attributes) {
  2727. super(TEMPLATE_NS_ID, "margin", true);
  2728. this.bottomInset = (0, _utils.getMeasurement)(attributes.bottomInset, "0");
  2729. this.id = attributes.id || "";
  2730. this.leftInset = (0, _utils.getMeasurement)(attributes.leftInset, "0");
  2731. this.rightInset = (0, _utils.getMeasurement)(attributes.rightInset, "0");
  2732. this.topInset = (0, _utils.getMeasurement)(attributes.topInset, "0");
  2733. this.use = attributes.use || "";
  2734. this.usehref = attributes.usehref || "";
  2735. this.extras = null;
  2736. }
  2737. [_xfa_object.$toStyle]() {
  2738. return {
  2739. margin: (0, _html_utils.measureToString)(this.topInset) + " " + (0, _html_utils.measureToString)(this.rightInset) + " " + (0, _html_utils.measureToString)(this.bottomInset) + " " + (0, _html_utils.measureToString)(this.leftInset)
  2740. };
  2741. }
  2742. }
  2743. class Mdp extends _xfa_object.XFAObject {
  2744. constructor(attributes) {
  2745. super(TEMPLATE_NS_ID, "mdp");
  2746. this.id = attributes.id || "";
  2747. this.permissions = (0, _utils.getInteger)({
  2748. data: attributes.permissions,
  2749. defaultValue: 2,
  2750. validate: x => x === 1 || x === 3
  2751. });
  2752. this.signatureType = (0, _utils.getStringOption)(attributes.signatureType, ["filler", "author"]);
  2753. this.use = attributes.use || "";
  2754. this.usehref = attributes.usehref || "";
  2755. }
  2756. }
  2757. class Medium extends _xfa_object.XFAObject {
  2758. constructor(attributes) {
  2759. super(TEMPLATE_NS_ID, "medium");
  2760. this.id = attributes.id || "";
  2761. this.imagingBBox = (0, _utils.getBBox)(attributes.imagingBBox);
  2762. this.long = (0, _utils.getMeasurement)(attributes.long);
  2763. this.orientation = (0, _utils.getStringOption)(attributes.orientation, ["portrait", "landscape"]);
  2764. this.short = (0, _utils.getMeasurement)(attributes.short);
  2765. this.stock = attributes.stock || "";
  2766. this.trayIn = (0, _utils.getStringOption)(attributes.trayIn, ["auto", "delegate", "pageFront"]);
  2767. this.trayOut = (0, _utils.getStringOption)(attributes.trayOut, ["auto", "delegate"]);
  2768. this.use = attributes.use || "";
  2769. this.usehref = attributes.usehref || "";
  2770. }
  2771. }
  2772. class Message extends _xfa_object.XFAObject {
  2773. constructor(attributes) {
  2774. super(TEMPLATE_NS_ID, "message", true);
  2775. this.id = attributes.id || "";
  2776. this.use = attributes.use || "";
  2777. this.usehref = attributes.usehref || "";
  2778. this.text = new _xfa_object.XFAObjectArray();
  2779. }
  2780. }
  2781. class NumericEdit extends _xfa_object.XFAObject {
  2782. constructor(attributes) {
  2783. super(TEMPLATE_NS_ID, "numericEdit", true);
  2784. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  2785. this.id = attributes.id || "";
  2786. this.use = attributes.use || "";
  2787. this.usehref = attributes.usehref || "";
  2788. this.border = null;
  2789. this.comb = null;
  2790. this.extras = null;
  2791. this.margin = null;
  2792. }
  2793. [_xfa_object.$toHTML](availableSpace) {
  2794. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  2795. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  2796. const html = {
  2797. name: "input",
  2798. attributes: {
  2799. type: "text",
  2800. fieldId: field[_xfa_object.$uid],
  2801. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  2802. class: ["xfaTextfield"],
  2803. style,
  2804. "aria-label": ariaLabel(field)
  2805. }
  2806. };
  2807. return _utils.HTMLResult.success({
  2808. name: "label",
  2809. attributes: {
  2810. class: ["xfaLabel"]
  2811. },
  2812. children: [html]
  2813. });
  2814. }
  2815. }
  2816. class Occur extends _xfa_object.XFAObject {
  2817. constructor(attributes) {
  2818. super(TEMPLATE_NS_ID, "occur", true);
  2819. this.id = attributes.id || "";
  2820. this.initial = attributes.initial !== "" ? (0, _utils.getInteger)({
  2821. data: attributes.initial,
  2822. defaultValue: "",
  2823. validate: x => true
  2824. }) : "";
  2825. this.max = attributes.max !== "" ? (0, _utils.getInteger)({
  2826. data: attributes.max,
  2827. defaultValue: 1,
  2828. validate: x => true
  2829. }) : "";
  2830. this.min = attributes.min !== "" ? (0, _utils.getInteger)({
  2831. data: attributes.min,
  2832. defaultValue: 1,
  2833. validate: x => true
  2834. }) : "";
  2835. this.use = attributes.use || "";
  2836. this.usehref = attributes.usehref || "";
  2837. this.extras = null;
  2838. }
  2839. [_xfa_object.$clean]() {
  2840. const parent = this[_xfa_object.$getParent]();
  2841. const originalMin = this.min;
  2842. if (this.min === "") {
  2843. this.min = parent instanceof PageArea || parent instanceof PageSet ? 0 : 1;
  2844. }
  2845. if (this.max === "") {
  2846. if (originalMin === "") {
  2847. this.max = parent instanceof PageArea || parent instanceof PageSet ? -1 : 1;
  2848. } else {
  2849. this.max = this.min;
  2850. }
  2851. }
  2852. if (this.max !== -1 && this.max < this.min) {
  2853. this.max = this.min;
  2854. }
  2855. if (this.initial === "") {
  2856. this.initial = parent instanceof Template ? 1 : this.min;
  2857. }
  2858. }
  2859. }
  2860. class Oid extends _xfa_object.StringObject {
  2861. constructor(attributes) {
  2862. super(TEMPLATE_NS_ID, "oid");
  2863. this.id = attributes.id || "";
  2864. this.name = attributes.name || "";
  2865. this.use = attributes.use || "";
  2866. this.usehref = attributes.usehref || "";
  2867. }
  2868. }
  2869. class Oids extends _xfa_object.XFAObject {
  2870. constructor(attributes) {
  2871. super(TEMPLATE_NS_ID, "oids", true);
  2872. this.id = attributes.id || "";
  2873. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  2874. this.use = attributes.use || "";
  2875. this.usehref = attributes.usehref || "";
  2876. this.oid = new _xfa_object.XFAObjectArray();
  2877. }
  2878. }
  2879. class Overflow extends _xfa_object.XFAObject {
  2880. constructor(attributes) {
  2881. super(TEMPLATE_NS_ID, "overflow");
  2882. this.id = attributes.id || "";
  2883. this.leader = attributes.leader || "";
  2884. this.target = attributes.target || "";
  2885. this.trailer = attributes.trailer || "";
  2886. this.use = attributes.use || "";
  2887. this.usehref = attributes.usehref || "";
  2888. }
  2889. [_xfa_object.$getExtra]() {
  2890. if (!this[_xfa_object.$extra]) {
  2891. const parent = this[_xfa_object.$getParent]();
  2892. const root = this[_xfa_object.$getTemplateRoot]();
  2893. const target = root[_xfa_object.$searchNode](this.target, parent);
  2894. const leader = root[_xfa_object.$searchNode](this.leader, parent);
  2895. const trailer = root[_xfa_object.$searchNode](this.trailer, parent);
  2896. this[_xfa_object.$extra] = {
  2897. target: target && target[0] || null,
  2898. leader: leader && leader[0] || null,
  2899. trailer: trailer && trailer[0] || null,
  2900. addLeader: false,
  2901. addTrailer: false
  2902. };
  2903. }
  2904. return this[_xfa_object.$extra];
  2905. }
  2906. }
  2907. class PageArea extends _xfa_object.XFAObject {
  2908. constructor(attributes) {
  2909. super(TEMPLATE_NS_ID, "pageArea", true);
  2910. this.blankOrNotBlank = (0, _utils.getStringOption)(attributes.blankOrNotBlank, ["any", "blank", "notBlank"]);
  2911. this.id = attributes.id || "";
  2912. this.initialNumber = (0, _utils.getInteger)({
  2913. data: attributes.initialNumber,
  2914. defaultValue: 1,
  2915. validate: x => true
  2916. });
  2917. this.name = attributes.name || "";
  2918. this.numbered = (0, _utils.getInteger)({
  2919. data: attributes.numbered,
  2920. defaultValue: 1,
  2921. validate: x => true
  2922. });
  2923. this.oddOrEven = (0, _utils.getStringOption)(attributes.oddOrEven, ["any", "even", "odd"]);
  2924. this.pagePosition = (0, _utils.getStringOption)(attributes.pagePosition, ["any", "first", "last", "only", "rest"]);
  2925. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  2926. this.use = attributes.use || "";
  2927. this.usehref = attributes.usehref || "";
  2928. this.desc = null;
  2929. this.extras = null;
  2930. this.medium = null;
  2931. this.occur = null;
  2932. this.area = new _xfa_object.XFAObjectArray();
  2933. this.contentArea = new _xfa_object.XFAObjectArray();
  2934. this.draw = new _xfa_object.XFAObjectArray();
  2935. this.exclGroup = new _xfa_object.XFAObjectArray();
  2936. this.field = new _xfa_object.XFAObjectArray();
  2937. this.subform = new _xfa_object.XFAObjectArray();
  2938. }
  2939. [_xfa_object.$isUsable]() {
  2940. if (!this[_xfa_object.$extra]) {
  2941. this[_xfa_object.$extra] = {
  2942. numberOfUse: 0
  2943. };
  2944. return true;
  2945. }
  2946. return !this.occur || this.occur.max === -1 || this[_xfa_object.$extra].numberOfUse < this.occur.max;
  2947. }
  2948. [_xfa_object.$cleanPage]() {
  2949. delete this[_xfa_object.$extra];
  2950. }
  2951. [_xfa_object.$getNextPage]() {
  2952. if (!this[_xfa_object.$extra]) {
  2953. this[_xfa_object.$extra] = {
  2954. numberOfUse: 0
  2955. };
  2956. }
  2957. const parent = this[_xfa_object.$getParent]();
  2958. if (parent.relation === "orderedOccurrence") {
  2959. if (this[_xfa_object.$isUsable]()) {
  2960. this[_xfa_object.$extra].numberOfUse += 1;
  2961. return this;
  2962. }
  2963. }
  2964. return parent[_xfa_object.$getNextPage]();
  2965. }
  2966. [_xfa_object.$getAvailableSpace]() {
  2967. return this[_xfa_object.$extra].space || {
  2968. width: 0,
  2969. height: 0
  2970. };
  2971. }
  2972. [_xfa_object.$toHTML]() {
  2973. if (!this[_xfa_object.$extra]) {
  2974. this[_xfa_object.$extra] = {
  2975. numberOfUse: 1
  2976. };
  2977. }
  2978. const children = [];
  2979. this[_xfa_object.$extra].children = children;
  2980. const style = Object.create(null);
  2981. if (this.medium && this.medium.short && this.medium.long) {
  2982. style.width = (0, _html_utils.measureToString)(this.medium.short);
  2983. style.height = (0, _html_utils.measureToString)(this.medium.long);
  2984. this[_xfa_object.$extra].space = {
  2985. width: this.medium.short,
  2986. height: this.medium.long
  2987. };
  2988. if (this.medium.orientation === "landscape") {
  2989. const x = style.width;
  2990. style.width = style.height;
  2991. style.height = x;
  2992. this[_xfa_object.$extra].space = {
  2993. width: this.medium.long,
  2994. height: this.medium.short
  2995. };
  2996. }
  2997. } else {
  2998. (0, _util.warn)("XFA - No medium specified in pageArea: please file a bug.");
  2999. }
  3000. this[_xfa_object.$childrenToHTML]({
  3001. filter: new Set(["area", "draw", "field", "subform"]),
  3002. include: true
  3003. });
  3004. this[_xfa_object.$childrenToHTML]({
  3005. filter: new Set(["contentArea"]),
  3006. include: true
  3007. });
  3008. return _utils.HTMLResult.success({
  3009. name: "div",
  3010. children,
  3011. attributes: {
  3012. class: ["xfaPage"],
  3013. id: this[_xfa_object.$uid],
  3014. style,
  3015. xfaName: this.name
  3016. }
  3017. });
  3018. }
  3019. }
  3020. class PageSet extends _xfa_object.XFAObject {
  3021. constructor(attributes) {
  3022. super(TEMPLATE_NS_ID, "pageSet", true);
  3023. this.duplexImposition = (0, _utils.getStringOption)(attributes.duplexImposition, ["longEdge", "shortEdge"]);
  3024. this.id = attributes.id || "";
  3025. this.name = attributes.name || "";
  3026. this.relation = (0, _utils.getStringOption)(attributes.relation, ["orderedOccurrence", "duplexPaginated", "simplexPaginated"]);
  3027. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3028. this.use = attributes.use || "";
  3029. this.usehref = attributes.usehref || "";
  3030. this.extras = null;
  3031. this.occur = null;
  3032. this.pageArea = new _xfa_object.XFAObjectArray();
  3033. this.pageSet = new _xfa_object.XFAObjectArray();
  3034. }
  3035. [_xfa_object.$cleanPage]() {
  3036. for (const page of this.pageArea.children) {
  3037. page[_xfa_object.$cleanPage]();
  3038. }
  3039. for (const page of this.pageSet.children) {
  3040. page[_xfa_object.$cleanPage]();
  3041. }
  3042. }
  3043. [_xfa_object.$isUsable]() {
  3044. return !this.occur || this.occur.max === -1 || this[_xfa_object.$extra].numberOfUse < this.occur.max;
  3045. }
  3046. [_xfa_object.$getNextPage]() {
  3047. if (!this[_xfa_object.$extra]) {
  3048. this[_xfa_object.$extra] = {
  3049. numberOfUse: 1,
  3050. pageIndex: -1,
  3051. pageSetIndex: -1
  3052. };
  3053. }
  3054. if (this.relation === "orderedOccurrence") {
  3055. if (this[_xfa_object.$extra].pageIndex + 1 < this.pageArea.children.length) {
  3056. this[_xfa_object.$extra].pageIndex += 1;
  3057. const pageArea = this.pageArea.children[this[_xfa_object.$extra].pageIndex];
  3058. return pageArea[_xfa_object.$getNextPage]();
  3059. }
  3060. if (this[_xfa_object.$extra].pageSetIndex + 1 < this.pageSet.children.length) {
  3061. this[_xfa_object.$extra].pageSetIndex += 1;
  3062. return this.pageSet.children[this[_xfa_object.$extra].pageSetIndex][_xfa_object.$getNextPage]();
  3063. }
  3064. if (this[_xfa_object.$isUsable]()) {
  3065. this[_xfa_object.$extra].numberOfUse += 1;
  3066. this[_xfa_object.$extra].pageIndex = -1;
  3067. this[_xfa_object.$extra].pageSetIndex = -1;
  3068. return this[_xfa_object.$getNextPage]();
  3069. }
  3070. const parent = this[_xfa_object.$getParent]();
  3071. if (parent instanceof PageSet) {
  3072. return parent[_xfa_object.$getNextPage]();
  3073. }
  3074. this[_xfa_object.$cleanPage]();
  3075. return this[_xfa_object.$getNextPage]();
  3076. }
  3077. const pageNumber = this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].pageNumber;
  3078. const parity = pageNumber % 2 === 0 ? "even" : "odd";
  3079. const position = pageNumber === 0 ? "first" : "rest";
  3080. let page = this.pageArea.children.find(p => p.oddOrEven === parity && p.pagePosition === position);
  3081. if (page) {
  3082. return page;
  3083. }
  3084. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === position);
  3085. if (page) {
  3086. return page;
  3087. }
  3088. page = this.pageArea.children.find(p => p.oddOrEven === "any" && p.pagePosition === "any");
  3089. if (page) {
  3090. return page;
  3091. }
  3092. return this.pageArea.children[0];
  3093. }
  3094. }
  3095. class Para extends _xfa_object.XFAObject {
  3096. constructor(attributes) {
  3097. super(TEMPLATE_NS_ID, "para", true);
  3098. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  3099. this.id = attributes.id || "";
  3100. this.lineHeight = attributes.lineHeight ? (0, _utils.getMeasurement)(attributes.lineHeight, "0pt") : "";
  3101. this.marginLeft = attributes.marginLeft ? (0, _utils.getMeasurement)(attributes.marginLeft, "0pt") : "";
  3102. this.marginRight = attributes.marginRight ? (0, _utils.getMeasurement)(attributes.marginRight, "0pt") : "";
  3103. this.orphans = (0, _utils.getInteger)({
  3104. data: attributes.orphans,
  3105. defaultValue: 0,
  3106. validate: x => x >= 0
  3107. });
  3108. this.preserve = attributes.preserve || "";
  3109. this.radixOffset = attributes.radixOffset ? (0, _utils.getMeasurement)(attributes.radixOffset, "0pt") : "";
  3110. this.spaceAbove = attributes.spaceAbove ? (0, _utils.getMeasurement)(attributes.spaceAbove, "0pt") : "";
  3111. this.spaceBelow = attributes.spaceBelow ? (0, _utils.getMeasurement)(attributes.spaceBelow, "0pt") : "";
  3112. this.tabDefault = attributes.tabDefault ? (0, _utils.getMeasurement)(this.tabDefault) : "";
  3113. this.tabStops = (attributes.tabStops || "").trim().split(/\s+/).map((x, i) => i % 2 === 1 ? (0, _utils.getMeasurement)(x) : x);
  3114. this.textIndent = attributes.textIndent ? (0, _utils.getMeasurement)(attributes.textIndent, "0pt") : "";
  3115. this.use = attributes.use || "";
  3116. this.usehref = attributes.usehref || "";
  3117. this.vAlign = (0, _utils.getStringOption)(attributes.vAlign, ["top", "bottom", "middle"]);
  3118. this.widows = (0, _utils.getInteger)({
  3119. data: attributes.widows,
  3120. defaultValue: 0,
  3121. validate: x => x >= 0
  3122. });
  3123. this.hyphenation = null;
  3124. }
  3125. [_xfa_object.$toStyle]() {
  3126. const style = (0, _html_utils.toStyle)(this, "hAlign");
  3127. if (this.marginLeft !== "") {
  3128. style.paddingLeft = (0, _html_utils.measureToString)(this.marginLeft);
  3129. }
  3130. if (this.marginRight !== "") {
  3131. style.paddingight = (0, _html_utils.measureToString)(this.marginRight);
  3132. }
  3133. if (this.spaceAbove !== "") {
  3134. style.paddingTop = (0, _html_utils.measureToString)(this.spaceAbove);
  3135. }
  3136. if (this.spaceBelow !== "") {
  3137. style.paddingBottom = (0, _html_utils.measureToString)(this.spaceBelow);
  3138. }
  3139. if (this.textIndent !== "") {
  3140. style.textIndent = (0, _html_utils.measureToString)(this.textIndent);
  3141. (0, _html_utils.fixTextIndent)(style);
  3142. }
  3143. if (this.lineHeight > 0) {
  3144. style.lineHeight = (0, _html_utils.measureToString)(this.lineHeight);
  3145. }
  3146. if (this.tabDefault !== "") {
  3147. style.tabSize = (0, _html_utils.measureToString)(this.tabDefault);
  3148. }
  3149. if (this.tabStops.length > 0) {}
  3150. if (this.hyphenatation) {
  3151. Object.assign(style, this.hyphenatation[_xfa_object.$toStyle]());
  3152. }
  3153. return style;
  3154. }
  3155. }
  3156. class PasswordEdit extends _xfa_object.XFAObject {
  3157. constructor(attributes) {
  3158. super(TEMPLATE_NS_ID, "passwordEdit", true);
  3159. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  3160. this.id = attributes.id || "";
  3161. this.passwordChar = attributes.passwordChar || "*";
  3162. this.use = attributes.use || "";
  3163. this.usehref = attributes.usehref || "";
  3164. this.border = null;
  3165. this.extras = null;
  3166. this.margin = null;
  3167. }
  3168. }
  3169. class Pattern extends _xfa_object.XFAObject {
  3170. constructor(attributes) {
  3171. super(TEMPLATE_NS_ID, "pattern", true);
  3172. this.id = attributes.id || "";
  3173. this.type = (0, _utils.getStringOption)(attributes.type, ["crossHatch", "crossDiagonal", "diagonalLeft", "diagonalRight", "horizontal", "vertical"]);
  3174. this.use = attributes.use || "";
  3175. this.usehref = attributes.usehref || "";
  3176. this.color = null;
  3177. this.extras = null;
  3178. }
  3179. [_xfa_object.$toStyle](startColor) {
  3180. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3181. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  3182. const width = 5;
  3183. const cmd = "repeating-linear-gradient";
  3184. const colors = `${startColor},${startColor} ${width}px,${endColor} ${width}px,${endColor} ${2 * width}px`;
  3185. switch (this.type) {
  3186. case "crossHatch":
  3187. return `${cmd}(to top,${colors}) ${cmd}(to right,${colors})`;
  3188. case "crossDiagonal":
  3189. return `${cmd}(45deg,${colors}) ${cmd}(-45deg,${colors})`;
  3190. case "diagonalLeft":
  3191. return `${cmd}(45deg,${colors})`;
  3192. case "diagonalRight":
  3193. return `${cmd}(-45deg,${colors})`;
  3194. case "horizontal":
  3195. return `${cmd}(to top,${colors})`;
  3196. case "vertical":
  3197. return `${cmd}(to right,${colors})`;
  3198. }
  3199. return "";
  3200. }
  3201. }
  3202. class Picture extends _xfa_object.StringObject {
  3203. constructor(attributes) {
  3204. super(TEMPLATE_NS_ID, "picture");
  3205. this.id = attributes.id || "";
  3206. this.use = attributes.use || "";
  3207. this.usehref = attributes.usehref || "";
  3208. }
  3209. }
  3210. class Proto extends _xfa_object.XFAObject {
  3211. constructor(attributes) {
  3212. super(TEMPLATE_NS_ID, "proto", true);
  3213. this.appearanceFilter = new _xfa_object.XFAObjectArray();
  3214. this.arc = new _xfa_object.XFAObjectArray();
  3215. this.area = new _xfa_object.XFAObjectArray();
  3216. this.assist = new _xfa_object.XFAObjectArray();
  3217. this.barcode = new _xfa_object.XFAObjectArray();
  3218. this.bindItems = new _xfa_object.XFAObjectArray();
  3219. this.bookend = new _xfa_object.XFAObjectArray();
  3220. this.boolean = new _xfa_object.XFAObjectArray();
  3221. this.border = new _xfa_object.XFAObjectArray();
  3222. this.break = new _xfa_object.XFAObjectArray();
  3223. this.breakAfter = new _xfa_object.XFAObjectArray();
  3224. this.breakBefore = new _xfa_object.XFAObjectArray();
  3225. this.button = new _xfa_object.XFAObjectArray();
  3226. this.calculate = new _xfa_object.XFAObjectArray();
  3227. this.caption = new _xfa_object.XFAObjectArray();
  3228. this.certificate = new _xfa_object.XFAObjectArray();
  3229. this.certificates = new _xfa_object.XFAObjectArray();
  3230. this.checkButton = new _xfa_object.XFAObjectArray();
  3231. this.choiceList = new _xfa_object.XFAObjectArray();
  3232. this.color = new _xfa_object.XFAObjectArray();
  3233. this.comb = new _xfa_object.XFAObjectArray();
  3234. this.connect = new _xfa_object.XFAObjectArray();
  3235. this.contentArea = new _xfa_object.XFAObjectArray();
  3236. this.corner = new _xfa_object.XFAObjectArray();
  3237. this.date = new _xfa_object.XFAObjectArray();
  3238. this.dateTime = new _xfa_object.XFAObjectArray();
  3239. this.dateTimeEdit = new _xfa_object.XFAObjectArray();
  3240. this.decimal = new _xfa_object.XFAObjectArray();
  3241. this.defaultUi = new _xfa_object.XFAObjectArray();
  3242. this.desc = new _xfa_object.XFAObjectArray();
  3243. this.digestMethod = new _xfa_object.XFAObjectArray();
  3244. this.digestMethods = new _xfa_object.XFAObjectArray();
  3245. this.draw = new _xfa_object.XFAObjectArray();
  3246. this.edge = new _xfa_object.XFAObjectArray();
  3247. this.encoding = new _xfa_object.XFAObjectArray();
  3248. this.encodings = new _xfa_object.XFAObjectArray();
  3249. this.encrypt = new _xfa_object.XFAObjectArray();
  3250. this.encryptData = new _xfa_object.XFAObjectArray();
  3251. this.encryption = new _xfa_object.XFAObjectArray();
  3252. this.encryptionMethod = new _xfa_object.XFAObjectArray();
  3253. this.encryptionMethods = new _xfa_object.XFAObjectArray();
  3254. this.event = new _xfa_object.XFAObjectArray();
  3255. this.exData = new _xfa_object.XFAObjectArray();
  3256. this.exObject = new _xfa_object.XFAObjectArray();
  3257. this.exclGroup = new _xfa_object.XFAObjectArray();
  3258. this.execute = new _xfa_object.XFAObjectArray();
  3259. this.extras = new _xfa_object.XFAObjectArray();
  3260. this.field = new _xfa_object.XFAObjectArray();
  3261. this.fill = new _xfa_object.XFAObjectArray();
  3262. this.filter = new _xfa_object.XFAObjectArray();
  3263. this.float = new _xfa_object.XFAObjectArray();
  3264. this.font = new _xfa_object.XFAObjectArray();
  3265. this.format = new _xfa_object.XFAObjectArray();
  3266. this.handler = new _xfa_object.XFAObjectArray();
  3267. this.hyphenation = new _xfa_object.XFAObjectArray();
  3268. this.image = new _xfa_object.XFAObjectArray();
  3269. this.imageEdit = new _xfa_object.XFAObjectArray();
  3270. this.integer = new _xfa_object.XFAObjectArray();
  3271. this.issuers = new _xfa_object.XFAObjectArray();
  3272. this.items = new _xfa_object.XFAObjectArray();
  3273. this.keep = new _xfa_object.XFAObjectArray();
  3274. this.keyUsage = new _xfa_object.XFAObjectArray();
  3275. this.line = new _xfa_object.XFAObjectArray();
  3276. this.linear = new _xfa_object.XFAObjectArray();
  3277. this.lockDocument = new _xfa_object.XFAObjectArray();
  3278. this.manifest = new _xfa_object.XFAObjectArray();
  3279. this.margin = new _xfa_object.XFAObjectArray();
  3280. this.mdp = new _xfa_object.XFAObjectArray();
  3281. this.medium = new _xfa_object.XFAObjectArray();
  3282. this.message = new _xfa_object.XFAObjectArray();
  3283. this.numericEdit = new _xfa_object.XFAObjectArray();
  3284. this.occur = new _xfa_object.XFAObjectArray();
  3285. this.oid = new _xfa_object.XFAObjectArray();
  3286. this.oids = new _xfa_object.XFAObjectArray();
  3287. this.overflow = new _xfa_object.XFAObjectArray();
  3288. this.pageArea = new _xfa_object.XFAObjectArray();
  3289. this.pageSet = new _xfa_object.XFAObjectArray();
  3290. this.para = new _xfa_object.XFAObjectArray();
  3291. this.passwordEdit = new _xfa_object.XFAObjectArray();
  3292. this.pattern = new _xfa_object.XFAObjectArray();
  3293. this.picture = new _xfa_object.XFAObjectArray();
  3294. this.radial = new _xfa_object.XFAObjectArray();
  3295. this.reason = new _xfa_object.XFAObjectArray();
  3296. this.reasons = new _xfa_object.XFAObjectArray();
  3297. this.rectangle = new _xfa_object.XFAObjectArray();
  3298. this.ref = new _xfa_object.XFAObjectArray();
  3299. this.script = new _xfa_object.XFAObjectArray();
  3300. this.setProperty = new _xfa_object.XFAObjectArray();
  3301. this.signData = new _xfa_object.XFAObjectArray();
  3302. this.signature = new _xfa_object.XFAObjectArray();
  3303. this.signing = new _xfa_object.XFAObjectArray();
  3304. this.solid = new _xfa_object.XFAObjectArray();
  3305. this.speak = new _xfa_object.XFAObjectArray();
  3306. this.stipple = new _xfa_object.XFAObjectArray();
  3307. this.subform = new _xfa_object.XFAObjectArray();
  3308. this.subformSet = new _xfa_object.XFAObjectArray();
  3309. this.subjectDN = new _xfa_object.XFAObjectArray();
  3310. this.subjectDNs = new _xfa_object.XFAObjectArray();
  3311. this.submit = new _xfa_object.XFAObjectArray();
  3312. this.text = new _xfa_object.XFAObjectArray();
  3313. this.textEdit = new _xfa_object.XFAObjectArray();
  3314. this.time = new _xfa_object.XFAObjectArray();
  3315. this.timeStamp = new _xfa_object.XFAObjectArray();
  3316. this.toolTip = new _xfa_object.XFAObjectArray();
  3317. this.traversal = new _xfa_object.XFAObjectArray();
  3318. this.traverse = new _xfa_object.XFAObjectArray();
  3319. this.ui = new _xfa_object.XFAObjectArray();
  3320. this.validate = new _xfa_object.XFAObjectArray();
  3321. this.value = new _xfa_object.XFAObjectArray();
  3322. this.variables = new _xfa_object.XFAObjectArray();
  3323. }
  3324. }
  3325. class Radial extends _xfa_object.XFAObject {
  3326. constructor(attributes) {
  3327. super(TEMPLATE_NS_ID, "radial", true);
  3328. this.id = attributes.id || "";
  3329. this.type = (0, _utils.getStringOption)(attributes.type, ["toEdge", "toCenter"]);
  3330. this.use = attributes.use || "";
  3331. this.usehref = attributes.usehref || "";
  3332. this.color = null;
  3333. this.extras = null;
  3334. }
  3335. [_xfa_object.$toStyle](startColor) {
  3336. startColor = startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3337. const endColor = this.color ? this.color[_xfa_object.$toStyle]() : "#000000";
  3338. const colors = this.type === "toEdge" ? `${startColor},${endColor}` : `${endColor},${startColor}`;
  3339. return `radial-gradient(circle at center, ${colors})`;
  3340. }
  3341. }
  3342. class Reason extends _xfa_object.StringObject {
  3343. constructor(attributes) {
  3344. super(TEMPLATE_NS_ID, "reason");
  3345. this.id = attributes.id || "";
  3346. this.name = attributes.name || "";
  3347. this.use = attributes.use || "";
  3348. this.usehref = attributes.usehref || "";
  3349. }
  3350. }
  3351. class Reasons extends _xfa_object.XFAObject {
  3352. constructor(attributes) {
  3353. super(TEMPLATE_NS_ID, "reasons", true);
  3354. this.id = attributes.id || "";
  3355. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3356. this.use = attributes.use || "";
  3357. this.usehref = attributes.usehref || "";
  3358. this.reason = new _xfa_object.XFAObjectArray();
  3359. }
  3360. }
  3361. class Rectangle extends _xfa_object.XFAObject {
  3362. constructor(attributes) {
  3363. super(TEMPLATE_NS_ID, "rectangle", true);
  3364. this.hand = (0, _utils.getStringOption)(attributes.hand, ["even", "left", "right"]);
  3365. this.id = attributes.id || "";
  3366. this.use = attributes.use || "";
  3367. this.usehref = attributes.usehref || "";
  3368. this.corner = new _xfa_object.XFAObjectArray(4);
  3369. this.edge = new _xfa_object.XFAObjectArray(4);
  3370. this.fill = null;
  3371. }
  3372. [_xfa_object.$toHTML]() {
  3373. const edge = this.edge.children.length ? this.edge.children[0] : new Edge({});
  3374. const edgeStyle = edge[_xfa_object.$toStyle]();
  3375. const style = Object.create(null);
  3376. if (this.fill && this.fill.presence === "visible") {
  3377. Object.assign(style, this.fill[_xfa_object.$toStyle]());
  3378. } else {
  3379. style.fill = "transparent";
  3380. }
  3381. style.strokeWidth = (0, _html_utils.measureToString)(edge.presence === "visible" ? edge.thickness : 0);
  3382. style.stroke = edgeStyle.color;
  3383. const corner = this.corner.children.length ? this.corner.children[0] : new Corner({});
  3384. const cornerStyle = corner[_xfa_object.$toStyle]();
  3385. const rect = {
  3386. name: "rect",
  3387. attributes: {
  3388. xmlns: SVG_NS,
  3389. width: "100%",
  3390. height: "100%",
  3391. x: 0,
  3392. y: 0,
  3393. rx: cornerStyle.radius,
  3394. ry: cornerStyle.radius,
  3395. style
  3396. }
  3397. };
  3398. const svg = {
  3399. name: "svg",
  3400. children: [rect],
  3401. attributes: {
  3402. xmlns: SVG_NS,
  3403. style: {
  3404. overflow: "visible"
  3405. },
  3406. width: "100%",
  3407. height: "100%"
  3408. }
  3409. };
  3410. const parent = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  3411. if (hasMargin(parent)) {
  3412. return _utils.HTMLResult.success({
  3413. name: "div",
  3414. attributes: {
  3415. style: {
  3416. display: "inline",
  3417. width: "100%",
  3418. height: "100%"
  3419. }
  3420. },
  3421. children: [svg]
  3422. });
  3423. }
  3424. svg.attributes.style.position = "absolute";
  3425. return _utils.HTMLResult.success(svg);
  3426. }
  3427. }
  3428. class RefElement extends _xfa_object.StringObject {
  3429. constructor(attributes) {
  3430. super(TEMPLATE_NS_ID, "ref");
  3431. this.id = attributes.id || "";
  3432. this.use = attributes.use || "";
  3433. this.usehref = attributes.usehref || "";
  3434. }
  3435. }
  3436. class Script extends _xfa_object.StringObject {
  3437. constructor(attributes) {
  3438. super(TEMPLATE_NS_ID, "script");
  3439. this.binding = attributes.binding || "";
  3440. this.contentType = attributes.contentType || "";
  3441. this.id = attributes.id || "";
  3442. this.name = attributes.name || "";
  3443. this.runAt = (0, _utils.getStringOption)(attributes.runAt, ["client", "both", "server"]);
  3444. this.use = attributes.use || "";
  3445. this.usehref = attributes.usehref || "";
  3446. }
  3447. }
  3448. class SetProperty extends _xfa_object.XFAObject {
  3449. constructor(attributes) {
  3450. super(TEMPLATE_NS_ID, "setProperty");
  3451. this.connection = attributes.connection || "";
  3452. this.ref = attributes.ref || "";
  3453. this.target = attributes.target || "";
  3454. }
  3455. }
  3456. exports.SetProperty = SetProperty;
  3457. class SignData extends _xfa_object.XFAObject {
  3458. constructor(attributes) {
  3459. super(TEMPLATE_NS_ID, "signData", true);
  3460. this.id = attributes.id || "";
  3461. this.operation = (0, _utils.getStringOption)(attributes.operation, ["sign", "clear", "verify"]);
  3462. this.ref = attributes.ref || "";
  3463. this.target = attributes.target || "";
  3464. this.use = attributes.use || "";
  3465. this.usehref = attributes.usehref || "";
  3466. this.filter = null;
  3467. this.manifest = null;
  3468. }
  3469. }
  3470. class Signature extends _xfa_object.XFAObject {
  3471. constructor(attributes) {
  3472. super(TEMPLATE_NS_ID, "signature", true);
  3473. this.id = attributes.id || "";
  3474. this.type = (0, _utils.getStringOption)(attributes.type, ["PDF1.3", "PDF1.6"]);
  3475. this.use = attributes.use || "";
  3476. this.usehref = attributes.usehref || "";
  3477. this.border = null;
  3478. this.extras = null;
  3479. this.filter = null;
  3480. this.manifest = null;
  3481. this.margin = null;
  3482. }
  3483. }
  3484. class Signing extends _xfa_object.XFAObject {
  3485. constructor(attributes) {
  3486. super(TEMPLATE_NS_ID, "signing", true);
  3487. this.id = attributes.id || "";
  3488. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3489. this.use = attributes.use || "";
  3490. this.usehref = attributes.usehref || "";
  3491. this.certificate = new _xfa_object.XFAObjectArray();
  3492. }
  3493. }
  3494. class Solid extends _xfa_object.XFAObject {
  3495. constructor(attributes) {
  3496. super(TEMPLATE_NS_ID, "solid", true);
  3497. this.id = attributes.id || "";
  3498. this.use = attributes.use || "";
  3499. this.usehref = attributes.usehref || "";
  3500. this.extras = null;
  3501. }
  3502. [_xfa_object.$toStyle](startColor) {
  3503. return startColor ? startColor[_xfa_object.$toStyle]() : "#FFFFFF";
  3504. }
  3505. }
  3506. class Speak extends _xfa_object.StringObject {
  3507. constructor(attributes) {
  3508. super(TEMPLATE_NS_ID, "speak");
  3509. this.disable = (0, _utils.getInteger)({
  3510. data: attributes.disable,
  3511. defaultValue: 0,
  3512. validate: x => x === 1
  3513. });
  3514. this.id = attributes.id || "";
  3515. this.priority = (0, _utils.getStringOption)(attributes.priority, ["custom", "caption", "name", "toolTip"]);
  3516. this.rid = attributes.rid || "";
  3517. this.use = attributes.use || "";
  3518. this.usehref = attributes.usehref || "";
  3519. }
  3520. }
  3521. class Stipple extends _xfa_object.XFAObject {
  3522. constructor(attributes) {
  3523. super(TEMPLATE_NS_ID, "stipple", true);
  3524. this.id = attributes.id || "";
  3525. this.rate = (0, _utils.getInteger)({
  3526. data: attributes.rate,
  3527. defaultValue: 50,
  3528. validate: x => x >= 0 && x <= 100
  3529. });
  3530. this.use = attributes.use || "";
  3531. this.usehref = attributes.usehref || "";
  3532. this.color = null;
  3533. this.extras = null;
  3534. }
  3535. [_xfa_object.$toStyle](bgColor) {
  3536. const alpha = this.rate / 100;
  3537. return _util.Util.makeHexColor(Math.round(bgColor.value.r * (1 - alpha) + this.value.r * alpha), Math.round(bgColor.value.g * (1 - alpha) + this.value.g * alpha), Math.round(bgColor.value.b * (1 - alpha) + this.value.b * alpha));
  3538. }
  3539. }
  3540. class Subform extends _xfa_object.XFAObject {
  3541. constructor(attributes) {
  3542. super(TEMPLATE_NS_ID, "subform", true);
  3543. this.access = (0, _utils.getStringOption)(attributes.access, ["open", "nonInteractive", "protected", "readOnly"]);
  3544. this.allowMacro = (0, _utils.getInteger)({
  3545. data: attributes.allowMacro,
  3546. defaultValue: 0,
  3547. validate: x => x === 1
  3548. });
  3549. this.anchorType = (0, _utils.getStringOption)(attributes.anchorType, ["topLeft", "bottomCenter", "bottomLeft", "bottomRight", "middleCenter", "middleLeft", "middleRight", "topCenter", "topRight"]);
  3550. this.colSpan = (0, _utils.getInteger)({
  3551. data: attributes.colSpan,
  3552. defaultValue: 1,
  3553. validate: n => n >= 1 || n === -1
  3554. });
  3555. this.columnWidths = (attributes.columnWidths || "").trim().split(/\s+/).map(x => x === "-1" ? -1 : (0, _utils.getMeasurement)(x));
  3556. this.h = attributes.h ? (0, _utils.getMeasurement)(attributes.h) : "";
  3557. this.hAlign = (0, _utils.getStringOption)(attributes.hAlign, ["left", "center", "justify", "justifyAll", "radix", "right"]);
  3558. this.id = attributes.id || "";
  3559. this.layout = (0, _utils.getStringOption)(attributes.layout, ["position", "lr-tb", "rl-row", "rl-tb", "row", "table", "tb"]);
  3560. this.locale = attributes.locale || "";
  3561. this.maxH = (0, _utils.getMeasurement)(attributes.maxH, "0pt");
  3562. this.maxW = (0, _utils.getMeasurement)(attributes.maxW, "0pt");
  3563. this.mergeMode = (0, _utils.getStringOption)(attributes.mergeMode, ["consumeData", "matchTemplate"]);
  3564. this.minH = (0, _utils.getMeasurement)(attributes.minH, "0pt");
  3565. this.minW = (0, _utils.getMeasurement)(attributes.minW, "0pt");
  3566. this.name = attributes.name || "";
  3567. this.presence = (0, _utils.getStringOption)(attributes.presence, ["visible", "hidden", "inactive", "invisible"]);
  3568. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3569. this.restoreState = (0, _utils.getStringOption)(attributes.restoreState, ["manual", "auto"]);
  3570. this.scope = (0, _utils.getStringOption)(attributes.scope, ["name", "none"]);
  3571. this.use = attributes.use || "";
  3572. this.usehref = attributes.usehref || "";
  3573. this.w = attributes.w ? (0, _utils.getMeasurement)(attributes.w) : "";
  3574. this.x = (0, _utils.getMeasurement)(attributes.x, "0pt");
  3575. this.y = (0, _utils.getMeasurement)(attributes.y, "0pt");
  3576. this.assist = null;
  3577. this.bind = null;
  3578. this.bookend = null;
  3579. this.border = null;
  3580. this.break = null;
  3581. this.calculate = null;
  3582. this.desc = null;
  3583. this.extras = null;
  3584. this.keep = null;
  3585. this.margin = null;
  3586. this.occur = null;
  3587. this.overflow = null;
  3588. this.pageSet = null;
  3589. this.para = null;
  3590. this.traversal = null;
  3591. this.validate = null;
  3592. this.variables = null;
  3593. this.area = new _xfa_object.XFAObjectArray();
  3594. this.breakAfter = new _xfa_object.XFAObjectArray();
  3595. this.breakBefore = new _xfa_object.XFAObjectArray();
  3596. this.connect = new _xfa_object.XFAObjectArray();
  3597. this.draw = new _xfa_object.XFAObjectArray();
  3598. this.event = new _xfa_object.XFAObjectArray();
  3599. this.exObject = new _xfa_object.XFAObjectArray();
  3600. this.exclGroup = new _xfa_object.XFAObjectArray();
  3601. this.field = new _xfa_object.XFAObjectArray();
  3602. this.proto = new _xfa_object.XFAObjectArray();
  3603. this.setProperty = new _xfa_object.XFAObjectArray();
  3604. this.subform = new _xfa_object.XFAObjectArray();
  3605. this.subformSet = new _xfa_object.XFAObjectArray();
  3606. }
  3607. [_xfa_object.$getSubformParent]() {
  3608. const parent = this[_xfa_object.$getParent]();
  3609. if (parent instanceof SubformSet) {
  3610. return parent[_xfa_object.$getSubformParent]();
  3611. }
  3612. return parent;
  3613. }
  3614. [_xfa_object.$isBindable]() {
  3615. return true;
  3616. }
  3617. [_xfa_object.$isThereMoreWidth]() {
  3618. return this.layout.endsWith("-tb") && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine > 0 || this[_xfa_object.$getParent]()[_xfa_object.$isThereMoreWidth]();
  3619. }
  3620. *[_xfa_object.$getContainedChildren]() {
  3621. yield* getContainedChildren(this);
  3622. }
  3623. [_xfa_object.$flushHTML]() {
  3624. return (0, _layout.flushHTML)(this);
  3625. }
  3626. [_xfa_object.$addHTML](html, bbox) {
  3627. (0, _layout.addHTML)(this, html, bbox);
  3628. }
  3629. [_xfa_object.$getAvailableSpace]() {
  3630. return (0, _layout.getAvailableSpace)(this);
  3631. }
  3632. [_xfa_object.$isSplittable]() {
  3633. const parent = this[_xfa_object.$getSubformParent]();
  3634. if (!parent[_xfa_object.$isSplittable]()) {
  3635. return false;
  3636. }
  3637. if (this[_xfa_object.$extra]._isSplittable !== undefined) {
  3638. return this[_xfa_object.$extra]._isSplittable;
  3639. }
  3640. if (this.layout === "position" || this.layout.includes("row")) {
  3641. this[_xfa_object.$extra]._isSplittable = false;
  3642. return false;
  3643. }
  3644. if (this.keep && this.keep.intact !== "none") {
  3645. this[_xfa_object.$extra]._isSplittable = false;
  3646. return false;
  3647. }
  3648. if (parent.layout && parent.layout.endsWith("-tb") && parent[_xfa_object.$extra].numberInLine !== 0) {
  3649. return false;
  3650. }
  3651. this[_xfa_object.$extra]._isSplittable = true;
  3652. return true;
  3653. }
  3654. [_xfa_object.$toHTML](availableSpace) {
  3655. setTabIndex(this);
  3656. if (this.break) {
  3657. if (this.break.after !== "auto" || this.break.afterTarget !== "") {
  3658. const node = new BreakAfter({
  3659. targetType: this.break.after,
  3660. target: this.break.afterTarget,
  3661. startNew: this.break.startNew.toString()
  3662. });
  3663. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3664. this[_xfa_object.$appendChild](node);
  3665. this.breakAfter.push(node);
  3666. }
  3667. if (this.break.before !== "auto" || this.break.beforeTarget !== "") {
  3668. const node = new BreakBefore({
  3669. targetType: this.break.before,
  3670. target: this.break.beforeTarget,
  3671. startNew: this.break.startNew.toString()
  3672. });
  3673. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3674. this[_xfa_object.$appendChild](node);
  3675. this.breakBefore.push(node);
  3676. }
  3677. if (this.break.overflowTarget !== "") {
  3678. const node = new Overflow({
  3679. target: this.break.overflowTarget,
  3680. leader: this.break.overflowLeader,
  3681. trailer: this.break.overflowTrailer
  3682. });
  3683. node[_xfa_object.$globalData] = this[_xfa_object.$globalData];
  3684. this[_xfa_object.$appendChild](node);
  3685. this.overflow.push(node);
  3686. }
  3687. this[_xfa_object.$removeChild](this.break);
  3688. this.break = null;
  3689. }
  3690. if (this.presence === "hidden" || this.presence === "inactive") {
  3691. return _utils.HTMLResult.EMPTY;
  3692. }
  3693. if (this.breakBefore.children.length > 1 || this.breakAfter.children.length > 1) {
  3694. (0, _util.warn)("XFA - Several breakBefore or breakAfter in subforms: please file a bug.");
  3695. }
  3696. if (this.breakBefore.children.length >= 1) {
  3697. const breakBefore = this.breakBefore.children[0];
  3698. if (handleBreak(breakBefore)) {
  3699. return _utils.HTMLResult.breakNode(breakBefore);
  3700. }
  3701. }
  3702. if (this[_xfa_object.$extra] && this[_xfa_object.$extra].afterBreakAfter) {
  3703. return _utils.HTMLResult.EMPTY;
  3704. }
  3705. (0, _html_utils.fixDimensions)(this);
  3706. const children = [];
  3707. const attributes = {
  3708. id: this[_xfa_object.$uid],
  3709. class: []
  3710. };
  3711. (0, _html_utils.setAccess)(this, attributes.class);
  3712. if (!this[_xfa_object.$extra]) {
  3713. this[_xfa_object.$extra] = Object.create(null);
  3714. }
  3715. Object.assign(this[_xfa_object.$extra], {
  3716. children,
  3717. line: null,
  3718. attributes,
  3719. attempt: 0,
  3720. numberInLine: 0,
  3721. availableSpace: {
  3722. width: Math.min(this.w || Infinity, availableSpace.width),
  3723. height: Math.min(this.h || Infinity, availableSpace.height)
  3724. },
  3725. width: 0,
  3726. height: 0,
  3727. prevHeight: 0,
  3728. currentWidth: 0
  3729. });
  3730. const root = this[_xfa_object.$getTemplateRoot]();
  3731. const savedNoLayoutFailure = root[_xfa_object.$extra].noLayoutFailure;
  3732. const isSplittable = this[_xfa_object.$isSplittable]();
  3733. if (!isSplittable) {
  3734. setFirstUnsplittable(this);
  3735. }
  3736. if (!(0, _layout.checkDimensions)(this, availableSpace)) {
  3737. return _utils.HTMLResult.FAILURE;
  3738. }
  3739. const filter = new Set(["area", "draw", "exclGroup", "field", "subform", "subformSet"]);
  3740. if (this.layout.includes("row")) {
  3741. const columnWidths = this[_xfa_object.$getSubformParent]().columnWidths;
  3742. if (Array.isArray(columnWidths) && columnWidths.length > 0) {
  3743. this[_xfa_object.$extra].columnWidths = columnWidths;
  3744. this[_xfa_object.$extra].currentColumn = 0;
  3745. }
  3746. }
  3747. const style = (0, _html_utils.toStyle)(this, "anchorType", "dimensions", "position", "presence", "border", "margin", "hAlign");
  3748. const classNames = ["xfaSubform"];
  3749. const cl = (0, _html_utils.layoutClass)(this);
  3750. if (cl) {
  3751. classNames.push(cl);
  3752. }
  3753. attributes.style = style;
  3754. attributes.class = classNames;
  3755. if (this.name) {
  3756. attributes.xfaName = this.name;
  3757. }
  3758. if (this.overflow) {
  3759. const overflowExtra = this.overflow[_xfa_object.$getExtra]();
  3760. if (overflowExtra.addLeader) {
  3761. overflowExtra.addLeader = false;
  3762. handleOverflow(this, overflowExtra.leader, availableSpace);
  3763. }
  3764. }
  3765. this[_xfa_object.$pushPara]();
  3766. const isLrTb = this.layout === "lr-tb" || this.layout === "rl-tb";
  3767. const maxRun = isLrTb ? MAX_ATTEMPTS_FOR_LRTB_LAYOUT : 1;
  3768. for (; this[_xfa_object.$extra].attempt < maxRun; this[_xfa_object.$extra].attempt++) {
  3769. if (isLrTb && this[_xfa_object.$extra].attempt === MAX_ATTEMPTS_FOR_LRTB_LAYOUT - 1) {
  3770. this[_xfa_object.$extra].numberInLine = 0;
  3771. }
  3772. const result = this[_xfa_object.$childrenToHTML]({
  3773. filter,
  3774. include: true
  3775. });
  3776. if (result.success) {
  3777. break;
  3778. }
  3779. if (result.isBreak()) {
  3780. this[_xfa_object.$popPara]();
  3781. return result;
  3782. }
  3783. if (isLrTb && this[_xfa_object.$extra].attempt === 0 && this[_xfa_object.$extra].numberInLine === 0 && !root[_xfa_object.$extra].noLayoutFailure) {
  3784. this[_xfa_object.$extra].attempt = maxRun;
  3785. break;
  3786. }
  3787. }
  3788. this[_xfa_object.$popPara]();
  3789. if (!isSplittable) {
  3790. unsetFirstUnsplittable(this);
  3791. }
  3792. root[_xfa_object.$extra].noLayoutFailure = savedNoLayoutFailure;
  3793. if (this[_xfa_object.$extra].attempt === maxRun) {
  3794. if (this.overflow) {
  3795. this[_xfa_object.$getTemplateRoot]()[_xfa_object.$extra].overflowNode = this.overflow;
  3796. }
  3797. if (!isSplittable) {
  3798. delete this[_xfa_object.$extra];
  3799. }
  3800. return _utils.HTMLResult.FAILURE;
  3801. }
  3802. if (this.overflow) {
  3803. const overflowExtra = this.overflow[_xfa_object.$getExtra]();
  3804. if (overflowExtra.addTrailer) {
  3805. overflowExtra.addTrailer = false;
  3806. handleOverflow(this, overflowExtra.trailer, availableSpace);
  3807. }
  3808. }
  3809. let marginH = 0;
  3810. let marginV = 0;
  3811. if (this.margin) {
  3812. marginH = this.margin.leftInset + this.margin.rightInset;
  3813. marginV = this.margin.topInset + this.margin.bottomInset;
  3814. }
  3815. const width = Math.max(this[_xfa_object.$extra].width + marginH, this.w || 0);
  3816. const height = Math.max(this[_xfa_object.$extra].height + marginV, this.h || 0);
  3817. const bbox = [this.x, this.y, width, height];
  3818. if (this.w === "") {
  3819. style.width = (0, _html_utils.measureToString)(width);
  3820. }
  3821. if (this.h === "") {
  3822. style.height = (0, _html_utils.measureToString)(height);
  3823. }
  3824. const html = {
  3825. name: "div",
  3826. attributes,
  3827. children
  3828. };
  3829. applyAssist(this, attributes);
  3830. const result = _utils.HTMLResult.success((0, _html_utils.createWrapper)(this, html), bbox);
  3831. if (this.breakAfter.children.length >= 1) {
  3832. const breakAfter = this.breakAfter.children[0];
  3833. if (handleBreak(breakAfter)) {
  3834. this[_xfa_object.$extra].afterBreakAfter = result;
  3835. return _utils.HTMLResult.breakNode(breakAfter);
  3836. }
  3837. }
  3838. delete this[_xfa_object.$extra];
  3839. return result;
  3840. }
  3841. }
  3842. class SubformSet extends _xfa_object.XFAObject {
  3843. constructor(attributes) {
  3844. super(TEMPLATE_NS_ID, "subformSet", true);
  3845. this.id = attributes.id || "";
  3846. this.name = attributes.name || "";
  3847. this.relation = (0, _utils.getStringOption)(attributes.relation, ["ordered", "choice", "unordered"]);
  3848. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  3849. this.use = attributes.use || "";
  3850. this.usehref = attributes.usehref || "";
  3851. this.bookend = null;
  3852. this.break = null;
  3853. this.desc = null;
  3854. this.extras = null;
  3855. this.occur = null;
  3856. this.overflow = null;
  3857. this.breakAfter = new _xfa_object.XFAObjectArray();
  3858. this.breakBefore = new _xfa_object.XFAObjectArray();
  3859. this.subform = new _xfa_object.XFAObjectArray();
  3860. this.subformSet = new _xfa_object.XFAObjectArray();
  3861. }
  3862. *[_xfa_object.$getContainedChildren]() {
  3863. yield* getContainedChildren(this);
  3864. }
  3865. [_xfa_object.$getSubformParent]() {
  3866. let parent = this[_xfa_object.$getParent]();
  3867. while (!(parent instanceof Subform)) {
  3868. parent = parent[_xfa_object.$getParent]();
  3869. }
  3870. return parent;
  3871. }
  3872. [_xfa_object.$isBindable]() {
  3873. return true;
  3874. }
  3875. }
  3876. class SubjectDN extends _xfa_object.ContentObject {
  3877. constructor(attributes) {
  3878. super(TEMPLATE_NS_ID, "subjectDN");
  3879. this.delimiter = attributes.delimiter || ",";
  3880. this.id = attributes.id || "";
  3881. this.name = attributes.name || "";
  3882. this.use = attributes.use || "";
  3883. this.usehref = attributes.usehref || "";
  3884. }
  3885. [_xfa_object.$finalize]() {
  3886. this[_xfa_object.$content] = new Map(this[_xfa_object.$content].split(this.delimiter).map(kv => {
  3887. kv = kv.split("=", 2);
  3888. kv[0] = kv[0].trim();
  3889. return kv;
  3890. }));
  3891. }
  3892. }
  3893. class SubjectDNs extends _xfa_object.XFAObject {
  3894. constructor(attributes) {
  3895. super(TEMPLATE_NS_ID, "subjectDNs", true);
  3896. this.id = attributes.id || "";
  3897. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  3898. this.use = attributes.use || "";
  3899. this.usehref = attributes.usehref || "";
  3900. this.subjectDN = new _xfa_object.XFAObjectArray();
  3901. }
  3902. }
  3903. class Submit extends _xfa_object.XFAObject {
  3904. constructor(attributes) {
  3905. super(TEMPLATE_NS_ID, "submit", true);
  3906. this.embedPDF = (0, _utils.getInteger)({
  3907. data: attributes.embedPDF,
  3908. defaultValue: 0,
  3909. validate: x => x === 1
  3910. });
  3911. this.format = (0, _utils.getStringOption)(attributes.format, ["xdp", "formdata", "pdf", "urlencoded", "xfd", "xml"]);
  3912. this.id = attributes.id || "";
  3913. this.target = attributes.target || "";
  3914. this.textEncoding = (0, _utils.getKeyword)({
  3915. data: attributes.textEncoding ? attributes.textEncoding.toLowerCase() : "",
  3916. defaultValue: "",
  3917. validate: k => ["utf-8", "big-five", "fontspecific", "gbk", "gb-18030", "gb-2312", "ksc-5601", "none", "shift-jis", "ucs-2", "utf-16"].includes(k) || k.match(/iso-8859-\d{2}/)
  3918. });
  3919. this.use = attributes.use || "";
  3920. this.usehref = attributes.usehref || "";
  3921. this.xdpContent = attributes.xdpContent || "";
  3922. this.encrypt = null;
  3923. this.encryptData = new _xfa_object.XFAObjectArray();
  3924. this.signData = new _xfa_object.XFAObjectArray();
  3925. }
  3926. }
  3927. class Template extends _xfa_object.XFAObject {
  3928. constructor(attributes) {
  3929. super(TEMPLATE_NS_ID, "template", true);
  3930. this.baseProfile = (0, _utils.getStringOption)(attributes.baseProfile, ["full", "interactiveForms"]);
  3931. this.extras = null;
  3932. this.subform = new _xfa_object.XFAObjectArray();
  3933. }
  3934. [_xfa_object.$finalize]() {
  3935. if (this.subform.children.length === 0) {
  3936. (0, _util.warn)("XFA - No subforms in template node.");
  3937. }
  3938. if (this.subform.children.length >= 2) {
  3939. (0, _util.warn)("XFA - Several subforms in template node: please file a bug.");
  3940. }
  3941. this[_xfa_object.$tabIndex] = DEFAULT_TAB_INDEX;
  3942. }
  3943. [_xfa_object.$isSplittable]() {
  3944. return true;
  3945. }
  3946. [_xfa_object.$searchNode](expr, container) {
  3947. if (expr.startsWith("#")) {
  3948. return [this[_xfa_object.$ids].get(expr.slice(1))];
  3949. }
  3950. return (0, _som.searchNode)(this, container, expr, true, true);
  3951. }
  3952. [_xfa_object.$toHTML]() {
  3953. if (!this.subform.children.length) {
  3954. return _utils.HTMLResult.success({
  3955. name: "div",
  3956. children: []
  3957. });
  3958. }
  3959. this[_xfa_object.$extra] = {
  3960. overflowNode: null,
  3961. firstUnsplittable: null,
  3962. currentContentArea: null,
  3963. currentPageArea: null,
  3964. noLayoutFailure: false,
  3965. pageNumber: 1,
  3966. pagePosition: "first",
  3967. oddOrEven: "odd",
  3968. blankOrNotBlank: "nonBlank",
  3969. paraStack: []
  3970. };
  3971. const root = this.subform.children[0];
  3972. root.pageSet[_xfa_object.$cleanPage]();
  3973. const pageAreas = root.pageSet.pageArea.children;
  3974. const mainHtml = {
  3975. name: "div",
  3976. children: []
  3977. };
  3978. let pageArea = null;
  3979. let breakBefore = null;
  3980. let breakBeforeTarget = null;
  3981. if (root.breakBefore.children.length >= 1) {
  3982. breakBefore = root.breakBefore.children[0];
  3983. breakBeforeTarget = breakBefore.target;
  3984. } else if (root.subform.children.length >= 1 && root.subform.children[0].breakBefore.children.length >= 1) {
  3985. breakBefore = root.subform.children[0].breakBefore.children[0];
  3986. breakBeforeTarget = breakBefore.target;
  3987. } else if (root.break && root.break.beforeTarget) {
  3988. breakBefore = root.break;
  3989. breakBeforeTarget = breakBefore.beforeTarget;
  3990. } else if (root.subform.children.length >= 1 && root.subform.children[0].break && root.subform.children[0].break.beforeTarget) {
  3991. breakBefore = root.subform.children[0].break;
  3992. breakBeforeTarget = breakBefore.beforeTarget;
  3993. }
  3994. if (breakBefore) {
  3995. const target = this[_xfa_object.$searchNode](breakBeforeTarget, breakBefore[_xfa_object.$getParent]());
  3996. if (target instanceof PageArea) {
  3997. pageArea = target;
  3998. breakBefore[_xfa_object.$extra] = {};
  3999. }
  4000. }
  4001. if (!pageArea) {
  4002. pageArea = pageAreas[0];
  4003. }
  4004. pageArea[_xfa_object.$extra] = {
  4005. numberOfUse: 1
  4006. };
  4007. const pageAreaParent = pageArea[_xfa_object.$getParent]();
  4008. pageAreaParent[_xfa_object.$extra] = {
  4009. numberOfUse: 1,
  4010. pageIndex: pageAreaParent.pageArea.children.indexOf(pageArea),
  4011. pageSetIndex: 0
  4012. };
  4013. let targetPageArea;
  4014. let leader = null;
  4015. let trailer = null;
  4016. let hasSomething = true;
  4017. let hasSomethingCounter = 0;
  4018. let startIndex = 0;
  4019. while (true) {
  4020. if (!hasSomething) {
  4021. mainHtml.children.pop();
  4022. if (++hasSomethingCounter === MAX_EMPTY_PAGES) {
  4023. (0, _util.warn)("XFA - Something goes wrong: please file a bug.");
  4024. return mainHtml;
  4025. }
  4026. } else {
  4027. hasSomethingCounter = 0;
  4028. }
  4029. targetPageArea = null;
  4030. this[_xfa_object.$extra].currentPageArea = pageArea;
  4031. const page = pageArea[_xfa_object.$toHTML]().html;
  4032. mainHtml.children.push(page);
  4033. if (leader) {
  4034. this[_xfa_object.$extra].noLayoutFailure = true;
  4035. page.children.push(leader[_xfa_object.$toHTML](pageArea[_xfa_object.$extra].space).html);
  4036. leader = null;
  4037. }
  4038. if (trailer) {
  4039. this[_xfa_object.$extra].noLayoutFailure = true;
  4040. page.children.push(trailer[_xfa_object.$toHTML](pageArea[_xfa_object.$extra].space).html);
  4041. trailer = null;
  4042. }
  4043. const contentAreas = pageArea.contentArea.children;
  4044. const htmlContentAreas = page.children.filter(node => node.attributes.class.includes("xfaContentarea"));
  4045. hasSomething = false;
  4046. this[_xfa_object.$extra].firstUnsplittable = null;
  4047. this[_xfa_object.$extra].noLayoutFailure = false;
  4048. const flush = index => {
  4049. const html = root[_xfa_object.$flushHTML]();
  4050. if (html) {
  4051. hasSomething = hasSomething || html.children && html.children.length !== 0;
  4052. htmlContentAreas[index].children.push(html);
  4053. }
  4054. };
  4055. for (let i = startIndex, ii = contentAreas.length; i < ii; i++) {
  4056. const contentArea = this[_xfa_object.$extra].currentContentArea = contentAreas[i];
  4057. const space = {
  4058. width: contentArea.w,
  4059. height: contentArea.h
  4060. };
  4061. startIndex = 0;
  4062. if (leader) {
  4063. htmlContentAreas[i].children.push(leader[_xfa_object.$toHTML](space).html);
  4064. leader = null;
  4065. }
  4066. if (trailer) {
  4067. htmlContentAreas[i].children.push(trailer[_xfa_object.$toHTML](space).html);
  4068. trailer = null;
  4069. }
  4070. const html = root[_xfa_object.$toHTML](space);
  4071. if (html.success) {
  4072. if (html.html) {
  4073. hasSomething = hasSomething || html.html.children && html.html.children.length !== 0;
  4074. htmlContentAreas[i].children.push(html.html);
  4075. } else if (!hasSomething) {
  4076. mainHtml.children.pop();
  4077. }
  4078. return mainHtml;
  4079. }
  4080. if (html.isBreak()) {
  4081. const node = html.breakNode;
  4082. flush(i);
  4083. if (node.targetType === "auto") {
  4084. continue;
  4085. }
  4086. if (node.leader) {
  4087. leader = this[_xfa_object.$searchNode](node.leader, node[_xfa_object.$getParent]());
  4088. leader = leader ? leader[0] : null;
  4089. }
  4090. if (node.trailer) {
  4091. trailer = this[_xfa_object.$searchNode](node.trailer, node[_xfa_object.$getParent]());
  4092. trailer = trailer ? trailer[0] : null;
  4093. }
  4094. if (node.targetType === "pageArea") {
  4095. targetPageArea = node[_xfa_object.$extra].target;
  4096. i = Infinity;
  4097. } else if (!node[_xfa_object.$extra].target) {
  4098. i = node[_xfa_object.$extra].index;
  4099. } else {
  4100. targetPageArea = node[_xfa_object.$extra].target;
  4101. startIndex = node[_xfa_object.$extra].index + 1;
  4102. i = Infinity;
  4103. }
  4104. continue;
  4105. }
  4106. if (this[_xfa_object.$extra].overflowNode) {
  4107. const node = this[_xfa_object.$extra].overflowNode;
  4108. this[_xfa_object.$extra].overflowNode = null;
  4109. const overflowExtra = node[_xfa_object.$getExtra]();
  4110. const target = overflowExtra.target;
  4111. overflowExtra.addLeader = overflowExtra.leader !== null;
  4112. overflowExtra.addTrailer = overflowExtra.trailer !== null;
  4113. flush(i);
  4114. const currentIndex = i;
  4115. i = Infinity;
  4116. if (target instanceof PageArea) {
  4117. targetPageArea = target;
  4118. } else if (target instanceof ContentArea) {
  4119. const index = contentAreas.findIndex(e => e === target);
  4120. if (index !== -1) {
  4121. if (index > currentIndex) {
  4122. i = index - 1;
  4123. } else {
  4124. startIndex = index;
  4125. }
  4126. } else {
  4127. targetPageArea = target[_xfa_object.$getParent]();
  4128. startIndex = targetPageArea.contentArea.children.findIndex(e => e === target);
  4129. }
  4130. }
  4131. continue;
  4132. }
  4133. flush(i);
  4134. }
  4135. this[_xfa_object.$extra].pageNumber += 1;
  4136. if (targetPageArea) {
  4137. if (targetPageArea[_xfa_object.$isUsable]()) {
  4138. targetPageArea[_xfa_object.$extra].numberOfUse += 1;
  4139. } else {
  4140. targetPageArea = null;
  4141. }
  4142. }
  4143. pageArea = targetPageArea || pageArea[_xfa_object.$getNextPage]();
  4144. }
  4145. }
  4146. }
  4147. exports.Template = Template;
  4148. class Text extends _xfa_object.ContentObject {
  4149. constructor(attributes) {
  4150. super(TEMPLATE_NS_ID, "text");
  4151. this.id = attributes.id || "";
  4152. this.maxChars = (0, _utils.getInteger)({
  4153. data: attributes.maxChars,
  4154. defaultValue: 0,
  4155. validate: x => x >= 0
  4156. });
  4157. this.name = attributes.name || "";
  4158. this.rid = attributes.rid || "";
  4159. this.use = attributes.use || "";
  4160. this.usehref = attributes.usehref || "";
  4161. }
  4162. [_xfa_object.$acceptWhitespace]() {
  4163. return true;
  4164. }
  4165. [_xfa_object.$onChild](child) {
  4166. if (child[_xfa_object.$namespaceId] === _namespaces.NamespaceIds.xhtml.id) {
  4167. this[_xfa_object.$content] = child;
  4168. return true;
  4169. }
  4170. (0, _util.warn)(`XFA - Invalid content in Text: ${child[_xfa_object.$nodeName]}.`);
  4171. return false;
  4172. }
  4173. [_xfa_object.$onText](str) {
  4174. if (this[_xfa_object.$content] instanceof _xfa_object.XFAObject) {
  4175. return;
  4176. }
  4177. super[_xfa_object.$onText](str);
  4178. }
  4179. [_xfa_object.$finalize]() {
  4180. if (typeof this[_xfa_object.$content] === "string") {
  4181. this[_xfa_object.$content] = this[_xfa_object.$content].replace(/\r\n/g, "\n");
  4182. }
  4183. }
  4184. [_xfa_object.$getExtra]() {
  4185. if (typeof this[_xfa_object.$content] === "string") {
  4186. return this[_xfa_object.$content].split(/[\u2029\u2028\n]/).reduce((acc, line) => {
  4187. if (line) {
  4188. acc.push(line);
  4189. }
  4190. return acc;
  4191. }, []).join("\n");
  4192. }
  4193. return this[_xfa_object.$content][_xfa_object.$text]();
  4194. }
  4195. [_xfa_object.$toHTML](availableSpace) {
  4196. if (typeof this[_xfa_object.$content] === "string") {
  4197. const html = valueToHtml(this[_xfa_object.$content]).html;
  4198. if (this[_xfa_object.$content].includes("\u2029")) {
  4199. html.name = "div";
  4200. html.children = [];
  4201. this[_xfa_object.$content].split("\u2029").map(para => para.split(/[\u2028\n]/).reduce((acc, line) => {
  4202. acc.push({
  4203. name: "span",
  4204. value: line
  4205. }, {
  4206. name: "br"
  4207. });
  4208. return acc;
  4209. }, [])).forEach(lines => {
  4210. html.children.push({
  4211. name: "p",
  4212. children: lines
  4213. });
  4214. });
  4215. } else if (/[\u2028\n]/.test(this[_xfa_object.$content])) {
  4216. html.name = "div";
  4217. html.children = [];
  4218. this[_xfa_object.$content].split(/[\u2028\n]/).forEach(line => {
  4219. html.children.push({
  4220. name: "span",
  4221. value: line
  4222. }, {
  4223. name: "br"
  4224. });
  4225. });
  4226. }
  4227. return _utils.HTMLResult.success(html);
  4228. }
  4229. return this[_xfa_object.$content][_xfa_object.$toHTML](availableSpace);
  4230. }
  4231. }
  4232. exports.Text = Text;
  4233. class TextEdit extends _xfa_object.XFAObject {
  4234. constructor(attributes) {
  4235. super(TEMPLATE_NS_ID, "textEdit", true);
  4236. this.allowRichText = (0, _utils.getInteger)({
  4237. data: attributes.allowRichText,
  4238. defaultValue: 0,
  4239. validate: x => x === 1
  4240. });
  4241. this.hScrollPolicy = (0, _utils.getStringOption)(attributes.hScrollPolicy, ["auto", "off", "on"]);
  4242. this.id = attributes.id || "";
  4243. this.multiLine = (0, _utils.getInteger)({
  4244. data: attributes.multiLine,
  4245. defaultValue: "",
  4246. validate: x => x === 0 || x === 1
  4247. });
  4248. this.use = attributes.use || "";
  4249. this.usehref = attributes.usehref || "";
  4250. this.vScrollPolicy = (0, _utils.getStringOption)(attributes.vScrollPolicy, ["auto", "off", "on"]);
  4251. this.border = null;
  4252. this.comb = null;
  4253. this.extras = null;
  4254. this.margin = null;
  4255. }
  4256. [_xfa_object.$toHTML](availableSpace) {
  4257. const style = (0, _html_utils.toStyle)(this, "border", "font", "margin");
  4258. let html;
  4259. const field = this[_xfa_object.$getParent]()[_xfa_object.$getParent]();
  4260. if (this.multiLine === "") {
  4261. this.multiLine = field instanceof Draw ? 1 : 0;
  4262. }
  4263. if (this.multiLine === 1) {
  4264. html = {
  4265. name: "textarea",
  4266. attributes: {
  4267. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  4268. fieldId: field[_xfa_object.$uid],
  4269. class: ["xfaTextfield"],
  4270. style,
  4271. "aria-label": ariaLabel(field)
  4272. }
  4273. };
  4274. } else {
  4275. html = {
  4276. name: "input",
  4277. attributes: {
  4278. type: "text",
  4279. dataId: field[_xfa_object.$data] && field[_xfa_object.$data][_xfa_object.$uid] || field[_xfa_object.$uid],
  4280. fieldId: field[_xfa_object.$uid],
  4281. class: ["xfaTextfield"],
  4282. style,
  4283. "aria-label": ariaLabel(field)
  4284. }
  4285. };
  4286. }
  4287. return _utils.HTMLResult.success({
  4288. name: "label",
  4289. attributes: {
  4290. class: ["xfaLabel"]
  4291. },
  4292. children: [html]
  4293. });
  4294. }
  4295. }
  4296. class Time extends _xfa_object.StringObject {
  4297. constructor(attributes) {
  4298. super(TEMPLATE_NS_ID, "time");
  4299. this.id = attributes.id || "";
  4300. this.name = attributes.name || "";
  4301. this.use = attributes.use || "";
  4302. this.usehref = attributes.usehref || "";
  4303. }
  4304. [_xfa_object.$finalize]() {
  4305. const date = this[_xfa_object.$content].trim();
  4306. this[_xfa_object.$content] = date ? new Date(date) : null;
  4307. }
  4308. [_xfa_object.$toHTML](availableSpace) {
  4309. return valueToHtml(this[_xfa_object.$content] ? this[_xfa_object.$content].toString() : "");
  4310. }
  4311. }
  4312. class TimeStamp extends _xfa_object.XFAObject {
  4313. constructor(attributes) {
  4314. super(TEMPLATE_NS_ID, "timeStamp");
  4315. this.id = attributes.id || "";
  4316. this.server = attributes.server || "";
  4317. this.type = (0, _utils.getStringOption)(attributes.type, ["optional", "required"]);
  4318. this.use = attributes.use || "";
  4319. this.usehref = attributes.usehref || "";
  4320. }
  4321. }
  4322. class ToolTip extends _xfa_object.StringObject {
  4323. constructor(attributes) {
  4324. super(TEMPLATE_NS_ID, "toolTip");
  4325. this.id = attributes.id || "";
  4326. this.rid = attributes.rid || "";
  4327. this.use = attributes.use || "";
  4328. this.usehref = attributes.usehref || "";
  4329. }
  4330. }
  4331. class Traversal extends _xfa_object.XFAObject {
  4332. constructor(attributes) {
  4333. super(TEMPLATE_NS_ID, "traversal", true);
  4334. this.id = attributes.id || "";
  4335. this.use = attributes.use || "";
  4336. this.usehref = attributes.usehref || "";
  4337. this.extras = null;
  4338. this.traverse = new _xfa_object.XFAObjectArray();
  4339. }
  4340. }
  4341. class Traverse extends _xfa_object.XFAObject {
  4342. constructor(attributes) {
  4343. super(TEMPLATE_NS_ID, "traverse", true);
  4344. this.id = attributes.id || "";
  4345. this.operation = (0, _utils.getStringOption)(attributes.operation, ["next", "back", "down", "first", "left", "right", "up"]);
  4346. this.ref = attributes.ref || "";
  4347. this.use = attributes.use || "";
  4348. this.usehref = attributes.usehref || "";
  4349. this.extras = null;
  4350. this.script = null;
  4351. }
  4352. get name() {
  4353. return this.operation;
  4354. }
  4355. [_xfa_object.$isTransparent]() {
  4356. return false;
  4357. }
  4358. }
  4359. class Ui extends _xfa_object.XFAObject {
  4360. constructor(attributes) {
  4361. super(TEMPLATE_NS_ID, "ui", true);
  4362. this.id = attributes.id || "";
  4363. this.use = attributes.use || "";
  4364. this.usehref = attributes.usehref || "";
  4365. this.extras = null;
  4366. this.picture = null;
  4367. this.barcode = null;
  4368. this.button = null;
  4369. this.checkButton = null;
  4370. this.choiceList = null;
  4371. this.dateTimeEdit = null;
  4372. this.defaultUi = null;
  4373. this.imageEdit = null;
  4374. this.numericEdit = null;
  4375. this.passwordEdit = null;
  4376. this.signature = null;
  4377. this.textEdit = null;
  4378. }
  4379. [_xfa_object.$getExtra]() {
  4380. if (this[_xfa_object.$extra] === undefined) {
  4381. for (const name of Object.getOwnPropertyNames(this)) {
  4382. if (name === "extras" || name === "picture") {
  4383. continue;
  4384. }
  4385. const obj = this[name];
  4386. if (!(obj instanceof _xfa_object.XFAObject)) {
  4387. continue;
  4388. }
  4389. this[_xfa_object.$extra] = obj;
  4390. return obj;
  4391. }
  4392. this[_xfa_object.$extra] = null;
  4393. }
  4394. return this[_xfa_object.$extra];
  4395. }
  4396. [_xfa_object.$toHTML](availableSpace) {
  4397. const obj = this[_xfa_object.$getExtra]();
  4398. if (obj) {
  4399. return obj[_xfa_object.$toHTML](availableSpace);
  4400. }
  4401. return _utils.HTMLResult.EMPTY;
  4402. }
  4403. }
  4404. class Validate extends _xfa_object.XFAObject {
  4405. constructor(attributes) {
  4406. super(TEMPLATE_NS_ID, "validate", true);
  4407. this.formatTest = (0, _utils.getStringOption)(attributes.formatTest, ["warning", "disabled", "error"]);
  4408. this.id = attributes.id || "";
  4409. this.nullTest = (0, _utils.getStringOption)(attributes.nullTest, ["disabled", "error", "warning"]);
  4410. this.scriptTest = (0, _utils.getStringOption)(attributes.scriptTest, ["error", "disabled", "warning"]);
  4411. this.use = attributes.use || "";
  4412. this.usehref = attributes.usehref || "";
  4413. this.extras = null;
  4414. this.message = null;
  4415. this.picture = null;
  4416. this.script = null;
  4417. }
  4418. }
  4419. class Value extends _xfa_object.XFAObject {
  4420. constructor(attributes) {
  4421. super(TEMPLATE_NS_ID, "value", true);
  4422. this.id = attributes.id || "";
  4423. this.override = (0, _utils.getInteger)({
  4424. data: attributes.override,
  4425. defaultValue: 0,
  4426. validate: x => x === 1
  4427. });
  4428. this.relevant = (0, _utils.getRelevant)(attributes.relevant);
  4429. this.use = attributes.use || "";
  4430. this.usehref = attributes.usehref || "";
  4431. this.arc = null;
  4432. this.boolean = null;
  4433. this.date = null;
  4434. this.dateTime = null;
  4435. this.decimal = null;
  4436. this.exData = null;
  4437. this.float = null;
  4438. this.image = null;
  4439. this.integer = null;
  4440. this.line = null;
  4441. this.rectangle = null;
  4442. this.text = null;
  4443. this.time = null;
  4444. }
  4445. [_xfa_object.$setValue](value) {
  4446. const parent = this[_xfa_object.$getParent]();
  4447. if (parent instanceof Field) {
  4448. if (parent.ui && parent.ui.imageEdit) {
  4449. if (!this.image) {
  4450. this.image = new Image({});
  4451. this[_xfa_object.$appendChild](this.image);
  4452. }
  4453. this.image[_xfa_object.$content] = value[_xfa_object.$content];
  4454. return;
  4455. }
  4456. }
  4457. const valueName = value[_xfa_object.$nodeName];
  4458. if (this[valueName] !== null) {
  4459. this[valueName][_xfa_object.$content] = value[_xfa_object.$content];
  4460. return;
  4461. }
  4462. for (const name of Object.getOwnPropertyNames(this)) {
  4463. const obj = this[name];
  4464. if (obj instanceof _xfa_object.XFAObject) {
  4465. this[name] = null;
  4466. this[_xfa_object.$removeChild](obj);
  4467. }
  4468. }
  4469. this[value[_xfa_object.$nodeName]] = value;
  4470. this[_xfa_object.$appendChild](value);
  4471. }
  4472. [_xfa_object.$text]() {
  4473. if (this.exData) {
  4474. if (typeof this.exData[_xfa_object.$content] === "string") {
  4475. return this.exData[_xfa_object.$content].trim();
  4476. }
  4477. return this.exData[_xfa_object.$content][_xfa_object.$text]().trim();
  4478. }
  4479. for (const name of Object.getOwnPropertyNames(this)) {
  4480. if (name === "image") {
  4481. continue;
  4482. }
  4483. const obj = this[name];
  4484. if (obj instanceof _xfa_object.XFAObject) {
  4485. return (obj[_xfa_object.$content] || "").toString().trim();
  4486. }
  4487. }
  4488. return null;
  4489. }
  4490. [_xfa_object.$toHTML](availableSpace) {
  4491. for (const name of Object.getOwnPropertyNames(this)) {
  4492. const obj = this[name];
  4493. if (!(obj instanceof _xfa_object.XFAObject)) {
  4494. continue;
  4495. }
  4496. return obj[_xfa_object.$toHTML](availableSpace);
  4497. }
  4498. return _utils.HTMLResult.EMPTY;
  4499. }
  4500. }
  4501. exports.Value = Value;
  4502. class Variables extends _xfa_object.XFAObject {
  4503. constructor(attributes) {
  4504. super(TEMPLATE_NS_ID, "variables", true);
  4505. this.id = attributes.id || "";
  4506. this.use = attributes.use || "";
  4507. this.usehref = attributes.usehref || "";
  4508. this.boolean = new _xfa_object.XFAObjectArray();
  4509. this.date = new _xfa_object.XFAObjectArray();
  4510. this.dateTime = new _xfa_object.XFAObjectArray();
  4511. this.decimal = new _xfa_object.XFAObjectArray();
  4512. this.exData = new _xfa_object.XFAObjectArray();
  4513. this.float = new _xfa_object.XFAObjectArray();
  4514. this.image = new _xfa_object.XFAObjectArray();
  4515. this.integer = new _xfa_object.XFAObjectArray();
  4516. this.manifest = new _xfa_object.XFAObjectArray();
  4517. this.script = new _xfa_object.XFAObjectArray();
  4518. this.text = new _xfa_object.XFAObjectArray();
  4519. this.time = new _xfa_object.XFAObjectArray();
  4520. }
  4521. [_xfa_object.$isTransparent]() {
  4522. return true;
  4523. }
  4524. }
  4525. class TemplateNamespace {
  4526. static [_namespaces.$buildXFAObject](name, attributes) {
  4527. if (TemplateNamespace.hasOwnProperty(name)) {
  4528. const node = TemplateNamespace[name](attributes);
  4529. node[_xfa_object.$setSetAttributes](attributes);
  4530. return node;
  4531. }
  4532. return undefined;
  4533. }
  4534. static appearanceFilter(attrs) {
  4535. return new AppearanceFilter(attrs);
  4536. }
  4537. static arc(attrs) {
  4538. return new Arc(attrs);
  4539. }
  4540. static area(attrs) {
  4541. return new Area(attrs);
  4542. }
  4543. static assist(attrs) {
  4544. return new Assist(attrs);
  4545. }
  4546. static barcode(attrs) {
  4547. return new Barcode(attrs);
  4548. }
  4549. static bind(attrs) {
  4550. return new Bind(attrs);
  4551. }
  4552. static bindItems(attrs) {
  4553. return new BindItems(attrs);
  4554. }
  4555. static bookend(attrs) {
  4556. return new Bookend(attrs);
  4557. }
  4558. static boolean(attrs) {
  4559. return new BooleanElement(attrs);
  4560. }
  4561. static border(attrs) {
  4562. return new Border(attrs);
  4563. }
  4564. static break(attrs) {
  4565. return new Break(attrs);
  4566. }
  4567. static breakAfter(attrs) {
  4568. return new BreakAfter(attrs);
  4569. }
  4570. static breakBefore(attrs) {
  4571. return new BreakBefore(attrs);
  4572. }
  4573. static button(attrs) {
  4574. return new Button(attrs);
  4575. }
  4576. static calculate(attrs) {
  4577. return new Calculate(attrs);
  4578. }
  4579. static caption(attrs) {
  4580. return new Caption(attrs);
  4581. }
  4582. static certificate(attrs) {
  4583. return new Certificate(attrs);
  4584. }
  4585. static certificates(attrs) {
  4586. return new Certificates(attrs);
  4587. }
  4588. static checkButton(attrs) {
  4589. return new CheckButton(attrs);
  4590. }
  4591. static choiceList(attrs) {
  4592. return new ChoiceList(attrs);
  4593. }
  4594. static color(attrs) {
  4595. return new Color(attrs);
  4596. }
  4597. static comb(attrs) {
  4598. return new Comb(attrs);
  4599. }
  4600. static connect(attrs) {
  4601. return new Connect(attrs);
  4602. }
  4603. static contentArea(attrs) {
  4604. return new ContentArea(attrs);
  4605. }
  4606. static corner(attrs) {
  4607. return new Corner(attrs);
  4608. }
  4609. static date(attrs) {
  4610. return new DateElement(attrs);
  4611. }
  4612. static dateTime(attrs) {
  4613. return new DateTime(attrs);
  4614. }
  4615. static dateTimeEdit(attrs) {
  4616. return new DateTimeEdit(attrs);
  4617. }
  4618. static decimal(attrs) {
  4619. return new Decimal(attrs);
  4620. }
  4621. static defaultUi(attrs) {
  4622. return new DefaultUi(attrs);
  4623. }
  4624. static desc(attrs) {
  4625. return new Desc(attrs);
  4626. }
  4627. static digestMethod(attrs) {
  4628. return new DigestMethod(attrs);
  4629. }
  4630. static digestMethods(attrs) {
  4631. return new DigestMethods(attrs);
  4632. }
  4633. static draw(attrs) {
  4634. return new Draw(attrs);
  4635. }
  4636. static edge(attrs) {
  4637. return new Edge(attrs);
  4638. }
  4639. static encoding(attrs) {
  4640. return new Encoding(attrs);
  4641. }
  4642. static encodings(attrs) {
  4643. return new Encodings(attrs);
  4644. }
  4645. static encrypt(attrs) {
  4646. return new Encrypt(attrs);
  4647. }
  4648. static encryptData(attrs) {
  4649. return new EncryptData(attrs);
  4650. }
  4651. static encryption(attrs) {
  4652. return new Encryption(attrs);
  4653. }
  4654. static encryptionMethod(attrs) {
  4655. return new EncryptionMethod(attrs);
  4656. }
  4657. static encryptionMethods(attrs) {
  4658. return new EncryptionMethods(attrs);
  4659. }
  4660. static event(attrs) {
  4661. return new Event(attrs);
  4662. }
  4663. static exData(attrs) {
  4664. return new ExData(attrs);
  4665. }
  4666. static exObject(attrs) {
  4667. return new ExObject(attrs);
  4668. }
  4669. static exclGroup(attrs) {
  4670. return new ExclGroup(attrs);
  4671. }
  4672. static execute(attrs) {
  4673. return new Execute(attrs);
  4674. }
  4675. static extras(attrs) {
  4676. return new Extras(attrs);
  4677. }
  4678. static field(attrs) {
  4679. return new Field(attrs);
  4680. }
  4681. static fill(attrs) {
  4682. return new Fill(attrs);
  4683. }
  4684. static filter(attrs) {
  4685. return new Filter(attrs);
  4686. }
  4687. static float(attrs) {
  4688. return new Float(attrs);
  4689. }
  4690. static font(attrs) {
  4691. return new Font(attrs);
  4692. }
  4693. static format(attrs) {
  4694. return new Format(attrs);
  4695. }
  4696. static handler(attrs) {
  4697. return new Handler(attrs);
  4698. }
  4699. static hyphenation(attrs) {
  4700. return new Hyphenation(attrs);
  4701. }
  4702. static image(attrs) {
  4703. return new Image(attrs);
  4704. }
  4705. static imageEdit(attrs) {
  4706. return new ImageEdit(attrs);
  4707. }
  4708. static integer(attrs) {
  4709. return new Integer(attrs);
  4710. }
  4711. static issuers(attrs) {
  4712. return new Issuers(attrs);
  4713. }
  4714. static items(attrs) {
  4715. return new Items(attrs);
  4716. }
  4717. static keep(attrs) {
  4718. return new Keep(attrs);
  4719. }
  4720. static keyUsage(attrs) {
  4721. return new KeyUsage(attrs);
  4722. }
  4723. static line(attrs) {
  4724. return new Line(attrs);
  4725. }
  4726. static linear(attrs) {
  4727. return new Linear(attrs);
  4728. }
  4729. static lockDocument(attrs) {
  4730. return new LockDocument(attrs);
  4731. }
  4732. static manifest(attrs) {
  4733. return new Manifest(attrs);
  4734. }
  4735. static margin(attrs) {
  4736. return new Margin(attrs);
  4737. }
  4738. static mdp(attrs) {
  4739. return new Mdp(attrs);
  4740. }
  4741. static medium(attrs) {
  4742. return new Medium(attrs);
  4743. }
  4744. static message(attrs) {
  4745. return new Message(attrs);
  4746. }
  4747. static numericEdit(attrs) {
  4748. return new NumericEdit(attrs);
  4749. }
  4750. static occur(attrs) {
  4751. return new Occur(attrs);
  4752. }
  4753. static oid(attrs) {
  4754. return new Oid(attrs);
  4755. }
  4756. static oids(attrs) {
  4757. return new Oids(attrs);
  4758. }
  4759. static overflow(attrs) {
  4760. return new Overflow(attrs);
  4761. }
  4762. static pageArea(attrs) {
  4763. return new PageArea(attrs);
  4764. }
  4765. static pageSet(attrs) {
  4766. return new PageSet(attrs);
  4767. }
  4768. static para(attrs) {
  4769. return new Para(attrs);
  4770. }
  4771. static passwordEdit(attrs) {
  4772. return new PasswordEdit(attrs);
  4773. }
  4774. static pattern(attrs) {
  4775. return new Pattern(attrs);
  4776. }
  4777. static picture(attrs) {
  4778. return new Picture(attrs);
  4779. }
  4780. static proto(attrs) {
  4781. return new Proto(attrs);
  4782. }
  4783. static radial(attrs) {
  4784. return new Radial(attrs);
  4785. }
  4786. static reason(attrs) {
  4787. return new Reason(attrs);
  4788. }
  4789. static reasons(attrs) {
  4790. return new Reasons(attrs);
  4791. }
  4792. static rectangle(attrs) {
  4793. return new Rectangle(attrs);
  4794. }
  4795. static ref(attrs) {
  4796. return new RefElement(attrs);
  4797. }
  4798. static script(attrs) {
  4799. return new Script(attrs);
  4800. }
  4801. static setProperty(attrs) {
  4802. return new SetProperty(attrs);
  4803. }
  4804. static signData(attrs) {
  4805. return new SignData(attrs);
  4806. }
  4807. static signature(attrs) {
  4808. return new Signature(attrs);
  4809. }
  4810. static signing(attrs) {
  4811. return new Signing(attrs);
  4812. }
  4813. static solid(attrs) {
  4814. return new Solid(attrs);
  4815. }
  4816. static speak(attrs) {
  4817. return new Speak(attrs);
  4818. }
  4819. static stipple(attrs) {
  4820. return new Stipple(attrs);
  4821. }
  4822. static subform(attrs) {
  4823. return new Subform(attrs);
  4824. }
  4825. static subformSet(attrs) {
  4826. return new SubformSet(attrs);
  4827. }
  4828. static subjectDN(attrs) {
  4829. return new SubjectDN(attrs);
  4830. }
  4831. static subjectDNs(attrs) {
  4832. return new SubjectDNs(attrs);
  4833. }
  4834. static submit(attrs) {
  4835. return new Submit(attrs);
  4836. }
  4837. static template(attrs) {
  4838. return new Template(attrs);
  4839. }
  4840. static text(attrs) {
  4841. return new Text(attrs);
  4842. }
  4843. static textEdit(attrs) {
  4844. return new TextEdit(attrs);
  4845. }
  4846. static time(attrs) {
  4847. return new Time(attrs);
  4848. }
  4849. static timeStamp(attrs) {
  4850. return new TimeStamp(attrs);
  4851. }
  4852. static toolTip(attrs) {
  4853. return new ToolTip(attrs);
  4854. }
  4855. static traversal(attrs) {
  4856. return new Traversal(attrs);
  4857. }
  4858. static traverse(attrs) {
  4859. return new Traverse(attrs);
  4860. }
  4861. static ui(attrs) {
  4862. return new Ui(attrs);
  4863. }
  4864. static validate(attrs) {
  4865. return new Validate(attrs);
  4866. }
  4867. static value(attrs) {
  4868. return new Value(attrs);
  4869. }
  4870. static variables(attrs) {
  4871. return new Variables(attrs);
  4872. }
  4873. }
  4874. exports.TemplateNamespace = TemplateNamespace;