// // Copyright 2020 FoxyUtils ehf. All rights reserved. // // This is a commercial product and requires a license to operate. // A trial license can be obtained at https://unidoc.io // // DO NOT EDIT: generated by unitwist Go source code obfuscator. // // Use of this source code is governed by the UniDoc End User License Agreement // terms that can be accessed at https://unidoc.io/eula/ package jbig2 ;import (_fa "github.com/unidoc/unipdf/v3/internal/bitwise";_d "github.com/unidoc/unipdf/v3/internal/jbig2/decoder";_dd "github.com/unidoc/unipdf/v3/internal/jbig2/document";_fe "github.com/unidoc/unipdf/v3/internal/jbig2/document/segments";_ad "github.com/unidoc/unipdf/v3/internal/jbig2/errors";_a "sort";);func DecodeBytes (encoded []byte ,parameters _d .Parameters ,globals ...Globals )([]byte ,error ){var _e Globals ;if len (globals )> 0{_e =globals [0];};_g ,_eg :=_d .Decode (encoded ,parameters ,_e .ToDocumentGlobals ());if _eg !=nil {return nil ,_eg ;};return _g .DecodeNextPage ();};func (_feb Globals )ToDocumentGlobals ()*_dd .Globals {if _feb ==nil {return nil ;};_ee :=[]*_fe .Header {};for _ ,_dec :=range _feb {_ee =append (_ee ,_dec );};_a .Slice (_ee ,func (_bf ,_dc int )bool {return _ee [_bf ].SegmentNumber < _ee [_dc ].SegmentNumber });return &_dd .Globals {Segments :_ee };};type Globals map[int ]*_fe .Header ;func DecodeGlobals (encoded []byte )(Globals ,error ){const _ega ="\u0044\u0065\u0063\u006f\u0064\u0065\u0047\u006c\u006f\u0062\u0061\u006c\u0073";_ge :=_fa .NewReader (encoded );_ga ,_adg :=_dd .DecodeDocument (_ge ,nil );if _adg !=nil {return nil ,_ad .Wrap (_adg ,_ega ,"");};if _ga .GlobalSegments ==nil ||(_ga .GlobalSegments .Segments ==nil ){return nil ,_ad .Error (_ega ,"\u006eo\u0020\u0067\u006c\u006f\u0062\u0061\u006c\u0020\u0073\u0065\u0067m\u0065\u006e\u0074\u0073\u0020\u0066\u006f\u0075\u006e\u0064");};_de :=Globals {};for _ ,_aa :=range _ga .GlobalSegments .Segments {_de [int (_aa .SegmentNumber )]=_aa ;};return _de ,nil ;};