@dxos/shell 0.6.1-main.92dcbbe → 0.6.1-main.fac53f5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle/shell.mjs +11 -11
- package/dist/bundle/shell.mjs.map +1 -1
- package/dist/bundle/shell.umd.js +2 -2
- package/dist/bundle/shell.umd.js.map +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/react.mjs +1 -1
- package/dist/lib/browser/react.mjs.map +2 -2
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js +1 -1
- package/dist/types/src/panels/IdentityPanel/steps/IdentityActionChooser.js.map +1 -1
- package/package.json +23 -23
- package/src/panels/IdentityPanel/steps/IdentityActionChooser.tsx +1 -1
package/dist/bundle/shell.umd.js
CHANGED
|
@@ -843,7 +843,7 @@ button {
|
|
|
843
843
|
background-color: #61493f;
|
|
844
844
|
}
|
|
845
845
|
|
|
846
|
-
`;function $e5534fc185f7111e$export$2e2bcd8739ae039(_){const $=React.useRef(null),I=React.useRef(null);return I.current&&I.current.update(_),React.useEffect(()=>(I.current=new $efa000751917694d$export$2e2bcd8739ae039({..._,ref:$}),()=>{I.current=null}),[]),React.createElement("div",{ref:$})}const EmojiPickerToolbarButton=({disabled:_,defaultEmoji:$,emoji:I,onChangeEmoji:j,classNames:U})=>{const{t:q}=useTranslation("os"),{themeMode:G}=useThemeContext(),[K,Y]=$71cd76cc60e0454e$export$6f32135080cb4c3({prop:I,onChange:j,defaultProp:$}),[J,X]=React.useState(!1),Z=React.useRef(!1),[Q,ee]=React.useState(!1);return React.createElement(Tooltip.Root,{open:Q,onOpenChange:ne=>{Z.current?(ee(!1),Z.current=!1):ee(ne)}},React.createElement(Popover.Root,{open:J,onOpenChange:ne=>{X(ne),Z.current=!0}},React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Popover.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:["gap-2 text-2xl plb-1",U],disabled:_},React.createElement("span",{className:"sr-only"},q("select emoji label")),React.createElement(react.UserCircle,{className:getSize(5)})))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},q("select emoji label"),React.createElement(Tooltip.Arrow,null))),React.createElement(Popover.Content,{side:"bottom",onKeyDownCapture:ne=>{ne.key==="Escape"&&(ne.stopPropagation(),X(!1),Z.current=!0)}},React.createElement($e5534fc185f7111e$export$2e2bcd8739ae039,{data:emojiData,onEmojiSelect:({native:ne})=>{ne&&(Y(ne),X(!1))},autoFocus:!0,maxFrequentRows:0,noCountryFlags:!0,theme:G}),React.createElement(Popover.Arrow,null))))},HuePreview=({hue:_})=>{const{tx:$}=useThemeContext(),I=20;return React.createElement("svg",{width:I,height:I,viewBox:`0 0 ${I} ${I}`},React.createElement("rect",{x:0,y:0,width:I,height:I,className:$("hue.fill","select--hue__preview",{hue:_})}))},hueTokens=Object.keys(hueTokenThemes).slice(0,16),HuePickerToolbarButton=({disabled:_,hue:$,onChangeHue:I,classNames:j,defaultHue:U})=>{const{t:q}=useTranslation("os"),[G,K]=$71cd76cc60e0454e$export$6f32135080cb4c3({prop:$,onChange:I,defaultProp:U}),[Y,J]=React.useState(!1),X=React.useRef(!1),[Z,Q]=React.useState(!1);return React.createElement(Tooltip.Root,{open:Z,onOpenChange:ee=>{X.current?(Q(!1),X.current=!1):Q(ee)}},React.createElement(DropdownMenu2.Root,{modal:!1,open:Y,onOpenChange:ee=>{J(ee),X.current=!0}},React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(DropdownMenu2.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:mx("gap-2 plb-1",j),disabled:_},React.createElement("span",{className:"sr-only"},q("select hue label")),React.createElement(react.Palette,{className:getSize(5)})))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},q("select hue label"),React.createElement(Tooltip.Arrow,null))),React.createElement(DropdownMenu2.Content,{side:"bottom",classNames:"!w-40"},React.createElement(DropdownMenu2.Viewport,{classNames:"grid grid-cols-4"},hueTokens.map(ee=>React.createElement(DropdownMenu2.CheckboxItem,{key:ee,checked:ee===G,onCheckedChange:()=>K(ee),classNames:"px-0 py-2 items-center justify-center"},React.createElement(HuePreview,{hue:ee})))))))};var data={adjectives:["abundant","accessible","accomplished","accurate","achievable","adaptable","adaptive","adequate","adjustable","admirable","admiring","adorable","adored","adoring","adroit","adulatory","advanced","advantageous","adventurous","affable","affectionate","affirmative","affluent","affordable","agile","agreeable","alluring","altruistic","amazed","amazing","ambitious","amenable","amiable","amicable","ample","amusing","angelic","appealing","appreciable","appreciated","appreciative","appropriate","ardent","articulate","artistic","assuring","astonished","astonishing","astounded","astounding","athletic","attentive","attractive","audible","auspicious","authentic","autonomous","available","avid","awed","awesome","awestruck","beauteous","beautiful","believable","beloved","beneficent","beneficial","benevolent","blameless","blissful","blithe","bonny","booming","boundless","bountiful","brainiest","brainy","brave","breathtaking","bright","brighter","brightest","brilliant","brisk","brotherly","bullish","buoyant","calm","calming","capable","captivating","carefree","catchy","celebrated","celebratory","champion","charismatic","charitable","charming","chaste","cheaper","cheapest","cheerful","cheery","cherished","chivalrous","classic","classy","clean","cleaner","cleanest","cleanly","clear","cleared","clearer","clever","coherent","cohesive","colorful","comely","comfortable","comforting","comfy","commendable","commodious","compact","compatible","competitive","compliant","conciliatory","concise","confident","congenial","considerate","consistent","constructive","consummate","contrasty","convenient","convincing","cool","coolest","cooperative","correct","courageous","courteous","courtly","cozy","creative","credible","crisp","crisper","cushy","cute","daring","darling","dashing","dauntless","dazzled","dazzling","decent","decisive","dedicated","defeated","deft","delectable","delicate","delicious","delighted","delightful","dependable","deserving","desirable","desirous","detachable","devout","dexterous","dextrous","dignified","diligent","diplomatic","distinctive","diversified","divine","dominated","dumbfounded","durable","dynamic","eager","earnest","eased","easy","easygoing","ebullient","economical","ecstatic","educated","effective","efficacious","efficient","effortless","effusive","elated","elegant","elite","eloquent","eminent","enchanted","enchanting","encouraging","endearing","endorsed","energetic","engaging","engrossing","enhanced","enjoyable","enraptured","enterprising","entertaining","enthralled","enthusiastic","enticing","entranced","entrancing","enviable","envious","equitable","erudite","ethical","euphoric","evaluative","eventful","everlasting","evocative","exalted","exalting","exceeding","excellent","exceptional","excited","exciting","exemplary","exhilarating","expansive","exquisite","exuberant","exultant","fabulous","fair","faithful","famed","famous","fancier","fancy","fantastic","fascinating","fashionable","fast","faster","fastest","faultless","favorable","favored","favorite","fearless","feasible","feisty","felicitous","fertile","fervent","fervid","festive","fiery","fine","finer","finest","firmer","flashy","flatter","flattering","flawless","flexible","flourishing","fluent","fond","foolproof","foremost","formidable","fortuitous","fortunate","fragrant","free","freed","fresh","fresher","freshest","friendly","frugal","fruitful","fun","funny","futuristic","gainful","gallant","galore","generous","genial","gentle","gentlest","genuine","gifted","glad","glamorous","gleeful","glimmering","glistening","glorious","glowing","godlike","gold","golden","good","goodly","gorgeous","graceful","gracious","grand","grateful","gratified","gratifying","great","greatest","guiltless","gutsy","halcyon","hale","hallowed","handier","handsome","handy","happier","happy","hardier","hardy","harmless","harmonious","healthful","healthy","heartening","heartfelt","heartwarming","heavenly","helpful","heroic","hilarious","holy","honest","honorable","honored","hopeful","hospitable","hot","hottest","humane","humble","humorous","humourous","ideal","idolized","idyllic","illuminating","illustrious","imaginative","immaculate","immense","impartial","impassioned","impeccable","important","impressed","impressive","improved","improving","incredible","indebted","indulgent","industrious","inestimable","inexpensive","infallible","influential","ingenious","ingenuous","innocuous","innovative","insightful","inspiring","instructive","instrumental","intelligent","intelligible","interesting","intimate","intricate","intriguing","intuitive","invaluable","inventive","invigorating","invincible","inviolable","inviolate","invulnerable","irresistible","jolly","jovial","joyful","joyous","jubilant","judicious","keen","kindly","laudable","lavish","lawful","leading","lean","legendary","lighter","likable","like","liked","lionhearted","lively","logical","lovable","loved","lovely","loving","loyal","lucid","luckier","luckiest","lucky","lucrative","luminous","lush","lustrous","luxuriant","luxurious","luxury","lyrical","magic","magical","magnanimous","magnificent","majestic","manageable","marvellous","marvelous","masterful","matchless","mature","meaningful","memorable","merciful","meritorious","merry","mesmerized","mesmerizing","meticulous","mighty","miraculous","modern","modest","momentous","monumental","motivated","navigable","neat","neatest","nice","nifty","nimble","noble","noiseless","noteworthy","nourishing","observant","obtainable","optimal","optimistic","opulent","orderly","organized","outstanding","overjoyed","painless","palatial","pampered","panoramic","paramount","passionate","patient","patri","peaceable","peaceful","peerless","peppy","perfect","permissible","personalized","phenomenal","picturesque","playful","pleasant","pleased","pleasing","pleasurable","plentiful","plush","poetic","poignant","poised","polished","polite","popular","portable","posh","positive","powerful","praiseworthy","praising","precious","precise","preeminent","preferable","premier","prestigious","pretty","priceless","principled","privileged","prize","proactive","prodigious","productive","proficient","profound","progressive","prolific","prominent","promised","promising","prompt","proper","propitious","prosperous","protective","proud","proven","prudent","punctual","pure","purposeful","quaint","qualified","quicker","quiet","quieter","radiant","rapid","rapt","rapturous","rational","reachable","readable","ready","realistic","realizable","reasonable","reasoned","receptive","recommended","redeeming","refined","reformed","refreshed","refreshing","regal","rejoicing","relaxed","reliable","remarkable","renewed","renowned","replaceable","reputable","resilient","resolute","resounding","resourceful","respectable","respectful","resplendent","responsive","restful","restored","retractable","reverent","rewarding","rich","righteous","rightful","robust","romantic","roomier","rosy","safe","saintly","salutary","sane","satisfactory","satisfied","satisfying","scenic","seamless","seasoned","secure","selective","sensational","sensible","sensitive","serene","sexy","sharp","sharper","sharpest","shiny","significant","silent","simpler","simplest","simplified","sincere","skilled","skillful","sleek","slick","smart","smarter","smartest","smelly","smiling","smitten","smooth","smoother","smoothest","snappy","snazzy","sociable","soft","softer","solid","soulful","spacious","sparkling","spectacular","speedy","spellbinding","spellbound","spirited","spiritual","splendid","spontaneous","sporty","spotless","sprightly","stable","stainless","stately","statuesque","staunch","steadfast","steadiest","steady","stellar","stimulating","stimulative","streamlined","striking","strong","stronger","strongest","stunned","stunning","stupendous","sturdier","sturdy","stylish","stylized","suave","sublime","subsidized","substantive","succeeding","successful","sufficient","suitable","sumptuous","super","superb","superior","supple","supportive","supreme","surreal","sustainable","swankier","swankiest","swanky","sweeping","sweet","sweetheart","swift","talented","tantalizing","tempting","tenacious","tender","terrific","thankful","thinner","thoughtful","thrifty","thrilled","thrilling","thriving","tidy","timely","titillating","tolerable","top","topnotch","tough","tougher","toughest","tranquil","transparent","trendy","triumphal","triumphant","trusted","trusting","trustworthy","trusty","truthful","twinkly","unabashed","unaffected","unassailable","unbeatable","unbiased","unbound","undamaged","undaunted","undisputable","undisputed","unencumbered","unequivocal","unfettered","unlimited","unmatched","unparalleled","unreal","unrestricted","unrivaled","unselfish","unwavering","upbeat","upscale","usable","useful","valiant","valuable","verifiable","veritable","versatile","vibrant","victorious","viewable","vigilant","virtuous","visionary","vivacious","vivid","warm","warmer","warmhearted","wealthy","welcome","wholesome","wieldy","winning","wise","witty","wonderful","wondrous","workable","worth","worthwhile","worthy","young","youthful","zippy"],animals:["aardvark","albatross","alligator","angelfish","angora","ant","anteater","antelope","armadillo","avocet","baboon","badger","bandicoot","barnacle","barracuda","bat","beagle","bear","beaver","bee","beetle","bird","bison","bloodhound","boar","bobcat","bonobo","buffalo","bulldog","bullfrog","butterfly","buzzard","camel","cat","caterpillar","catfish","cattle","centipede","chameleon","cheetah","chicken","chihuahua","chimpanzee","chin","chinchilla","chipmunk","civet","clam","cockroach","coon","coral","corgi","cougar","cow","coyote","crab","crane","cuttlefish","dachshund","dalmatian","dane","deer","devil","dingo","dodo","dog","dogfish","dollar","dolphin","donkey","dormouse","dragon","dragonfly","duck","dugong","eagle","earwig","eel","elephant","emperor","emu","falcon","ferret","fish","flamingo","flounder","fly","forest","fowl","fox","foxhound","frog","gar","gecko","gerbil","gharial","gibbon","giraffe","goat","goose","gopher","gorilla","grasshopper","greyhound","grouse","guppy","hamster","hare","hedgehog","heron","hippopotamus","hornet","horse","hound","hummingbird","husky","hyena","hyrax","ibis","iguana","impala","insect","jackal","jaguar","jellyfish","kangaroo","kingfisher","kiwi","koala","kudu","labradoodle","ladybird","lemming","lemur","leopard","liger","lion","lionfish","lizard","llama","lobster","lynx","macaque","macaw","magpie","malamute","maltese","mammoth","manatee","mandrill","markhor","marmoset","mastiff","mayfly","meerkat","millipede","mole","mongoose","monkey","monster","moorhen","moose","moth","mouse","mule","newt","nightingale","ocelot","octopus","okapi","orangutan","ostrich","otter","owl","oyster","panda","panther","parrot","peacock","pelican","penguin","pheasant","pig","pike","piranha","platypus","pointer","poodle","porcupine","possum","prawn","puffin","pug","puma","quail","rabbit","raccoon","rat","rattlesnake","ray","reindeer","retriever","rhinoceros","robin","rottweiler","russel","salamander","scorpion","seahorse","seal","shark","sheep","sheepdog","shrew","shrimp","skater","skunk","sloth","slug","snail","snake","snowshoe","spaniel","sparrow","spider","sponge","squid","squirrel","squirt","starfish","stingray","stoat","swan","tapir","tarantula","termite","terrier","tiger","toad","tortoise","toucan","tuatara","turkey","turtle","uakari","urchin","vole","vulture","wallaby","walrus","warthog","wasp","weasel","whale","whippet","wildebeest","wolf","wolfhound","wolverine","wombat","woodlouse","woodpecker","worm","yak","zebra","zebu","zonkey","zorse"]},capitalize=_=>_.charAt(0).toUpperCase()+_.slice(1),generateName=_=>{const $=_.length*2/3,I=_.substring(0,$),j=_.substring($),U=capitalize(data.adjectives[parseInt(I,16)%data.adjectives.length]),q=capitalize(data.animals[parseInt(j,16)%data.animals.length]);return`${U} ${q}`};const IdentityListItem=React.forwardRef(({identity:_,presence:$,onClick:I,classNames:j,...U},q)=>{var J,X,Z,Q,ee;const G=keyToFallback(_.identityKey),K=useId("identityListItem__label"),Y=((J=_.profile)==null?void 0:J.displayName)??generateName(_.identityKey.toHex());return React.createElement(ListItem.Root,{...U,classNames:mx("flex gap-2 pis-3 pie-1 items-center",I&&"cursor-pointer",j),onClick:()=>I==null?void 0:I(),"data-testid":"identity-list-item",labelId:K,ref:q},React.createElement(Avatar.Root,{status:$===echo.SpaceMember.PresenceState.ONLINE?"active":"inactive",labelId:K,hue:((Z=(X=_.profile)==null?void 0:X.data)==null?void 0:Z.hue)||G.hue},React.createElement(Avatar.Frame,{classNames:"place-self-center"},React.createElement(Avatar.Fallback,{text:((ee=(Q=_.profile)==null?void 0:Q.data)==null?void 0:ee.emoji)||G.emoji})),React.createElement(Avatar.Label,{classNames:"text-sm truncate pli-2"},Y)))}),SpaceMemberList=({spaceKey:_,includeSelf:$,onSelect:I})=>{const j=reactClient.useClient(),U=echo.useMembers(_),q=React.useMemo(()=>$?U.sort(G=>G.identity.identityKey.equals(j.halo.identity.get().identityKey)?-1:1):U.filter(G=>!G.identity.identityKey.equals(j.halo.identity.get().identityKey)),[U]);return React.createElement(SpaceMemberListImpl,{members:q,onSelect:I})},SpaceMemberListImpl=({members:_,onSelect:$})=>{const{t:I}=useTranslation("os"),j=_.filter(U=>U.identity);return j.length>0?React.createElement(List,{classNames:"flex flex-col gap-2","data-testid":"space-members-list"},j.map(U=>React.createElement(IdentityListItem,{key:U.identity.identityKey.toHex(),identity:U.identity,presence:U.presence,onClick:$&&(()=>$(U))}))):React.createElement("div",{role:"none",className:"grow flex items-center p-2"},React.createElement("p",{className:mx(descriptionText,"text-center is-full mlb-2")},I("empty space members message")))},iconProps={weight:"duotone",width:24,height:24,x:8,y:8},DeviceListItem=React.forwardRef(({device:_,onClickAdd:$,onClickEdit:I,onClickReset:j,onClickJoinExisting:U,classNames:q,connectionState:G,onAgentDestroy:K,...Y},J)=>{var ie,oe;const{t:X}=useTranslation("os"),Z=keyToFallback(_.deviceKey),Q=useId("identityListItem__label"),ee=_.profile?X("device name placeholder",{os:_.profile.os,platform:_.profile.platform}):generateName(_.deviceKey.toHex()),ne=_.kind===halo.DeviceKind.CURRENT;return React.createElement(ListItem.Root,{...Y,classNames:["flex gap-2 items-center mlb-2",q],"data-testid":`device-list-item${ne?"-current":""}`,labelId:Q,ref:J},React.createElement(Avatar.Root,{status:ne&&G===mesh.ConnectionState.OFFLINE?"error":_.presence===halo.Device.PresenceState.ONLINE?"active":"inactive",labelId:Q,hue:Z.hue,variant:"square"},React.createElement(Avatar.Frame,{classNames:"place-self-center"},(ie=_.profile)!=null&&ie.type?_.profile.type===halo.DeviceType.AGENT_MANAGED?React.createElement(react.Database,{...iconProps}):_.profile.type===halo.DeviceType.BROWSER?React.createElement(react.Compass,{...iconProps}):_.profile.type===halo.DeviceType.NATIVE?React.createElement(react.Desktop,{...iconProps}):[halo.DeviceType.AGENT,halo.DeviceType.AGENT_MANAGED].includes(_.profile.type)?React.createElement(react.Robot,{...iconProps}):_.profile.type===halo.DeviceType.MOBILE?React.createElement(react.DeviceMobile,{...iconProps}):React.createElement(react.Devices,{...iconProps}):React.createElement(Avatar.Fallback,{text:Z.emoji})),React.createElement(Avatar.Label,{classNames:"flex-1 text-sm truncate"},ee),ne&&React.createElement(Tag,{color:"primary"},X("current device tag label")),((oe=_.profile)==null?void 0:oe.type)===halo.DeviceType.AGENT_MANAGED?React.createElement(Tooltip.Root,null,React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Button,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":"agent.destroy",onClick:K},React.createElement("span",{className:"sr-only"},X("destroy agent label")),React.createElement(react.Power,{className:getSize(5)}))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},X("destroy agent label")))):_.kind===halo.DeviceKind.CURRENT&&React.createElement(DropdownMenu2.Root,null,React.createElement(DropdownMenu2.Trigger,{asChild:!0},React.createElement(Button,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":`device-list-item${ne?"-current":""}.options`},React.createElement("span",{className:"sr-only"},X("more options label")),React.createElement(react.DotsThree,{className:getSize(5)}))),React.createElement(DropdownMenu2.Content,null,React.createElement(DropdownMenu2.Viewport,null,React.createElement(DropdownMenu2.Item,{"data-testid":"device-list-item-current.join-existing",onClick:U},React.createElement(react.ShareFat,{className:getSize(5)}),X("choose join new identity label")),React.createElement(DropdownMenu2.Item,{"data-testid":"device-list-item-current.reset",onClick:j},React.createElement(react.Power,{className:getSize(5)}),X("reset device label")))))))}),DeviceList=({devices:_,connectionState:$,onClickAdd:I,onClickEdit:j,onClickReset:U,onClickJoinExisting:q,onAgentDestroy:G})=>{const{t:K}=useTranslation("os");return React.createElement(React.Fragment,null,React.createElement("h2",{className:mx(descriptionText,"text-center mbs-4")},K("devices heading")),_.length>0&&React.createElement(List,null,_.map(Y=>React.createElement(DeviceListItem,{key:Y.deviceKey.toHex(),device:Y,onClickEdit:()=>j==null?void 0:j(Y),onClickReset:U,onClickJoinExisting:q,connectionState:$,onAgentDestroy:G}))),React.createElement(Button,{variant:"ghost",classNames:"justify-start gap-2 !pis-0 !pie-3 is-full","data-testid":"devices-panel.create-invitation",onClick:I},React.createElement("div",{role:"img",className:mx(getSize(8),"m-1 rounded-sm surface-input grid place-items-center")},React.createElement(react.Plus,{weight:"light",className:getSize(6)})),React.createElement("span",{className:"grow font-medium text-start"},K("choose add device label")),React.createElement(react.CaretRight,{weight:"bold",className:getSize(4)})))},minutesInMonth=43200,minutesInDay=1440;function getTimezoneOffsetInMilliseconds(_){const $=toDate(_),I=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate(),$.getHours(),$.getMinutes(),$.getSeconds(),$.getMilliseconds()));return I.setUTCFullYear($.getFullYear()),+_-+I}function compareAsc(_,$){const I=toDate(_),j=toDate($),U=I.getTime()-j.getTime();return U<0?-1:U>0?1:U}function differenceInCalendarMonths(_,$){const I=toDate(_),j=toDate($),U=I.getFullYear()-j.getFullYear(),q=I.getMonth()-j.getMonth();return U*12+q}function getRoundingMethod(_){return $=>{const j=(_?Math[_]:Math.trunc)($);return j===0?0:j}}function differenceInMilliseconds(_,$){return+toDate(_)-+toDate($)}function endOfDay(_){const $=toDate(_);return $.setHours(23,59,59,999),$}function endOfMonth(_){const $=toDate(_),I=$.getMonth();return $.setFullYear($.getFullYear(),I+1,0),$.setHours(23,59,59,999),$}function isLastDayOfMonth(_){const $=toDate(_);return+endOfDay($)==+endOfMonth($)}function differenceInMonths(_,$){const I=toDate(_),j=toDate($),U=compareAsc(I,j),q=Math.abs(differenceInCalendarMonths(I,j));let G;if(q<1)G=0;else{I.getMonth()===1&&I.getDate()>27&&I.setDate(30),I.setMonth(I.getMonth()-U*q);let K=compareAsc(I,j)===-U;isLastDayOfMonth(toDate(_))&&q===1&&compareAsc(_,j)===1&&(K=!1),G=U*(q-Number(K))}return G===0?0:G}function differenceInSeconds(_,$,I){const j=differenceInMilliseconds(_,$)/1e3;return getRoundingMethod(I==null?void 0:I.roundingMethod)(j)}function formatDistance(_,$,I){const j=getDefaultOptions(),U=(I==null?void 0:I.locale)??j.locale??enUS$1,q=2520,G=compareAsc(_,$);if(isNaN(G))throw new RangeError("Invalid time value");const K=Object.assign({},I,{addSuffix:I==null?void 0:I.addSuffix,comparison:G});let Y,J;G>0?(Y=toDate($),J=toDate(_)):(Y=toDate(_),J=toDate($));const X=differenceInSeconds(J,Y),Z=(getTimezoneOffsetInMilliseconds(J)-getTimezoneOffsetInMilliseconds(Y))/1e3,Q=Math.round((X-Z)/60);let ee;if(Q<2)return I!=null&&I.includeSeconds?X<5?U.formatDistance("lessThanXSeconds",5,K):X<10?U.formatDistance("lessThanXSeconds",10,K):X<20?U.formatDistance("lessThanXSeconds",20,K):X<40?U.formatDistance("halfAMinute",0,K):X<60?U.formatDistance("lessThanXMinutes",1,K):U.formatDistance("xMinutes",1,K):Q===0?U.formatDistance("lessThanXMinutes",1,K):U.formatDistance("xMinutes",Q,K);if(Q<45)return U.formatDistance("xMinutes",Q,K);if(Q<90)return U.formatDistance("aboutXHours",1,K);if(Q<minutesInDay){const ne=Math.round(Q/60);return U.formatDistance("aboutXHours",ne,K)}else{if(Q<q)return U.formatDistance("xDays",1,K);if(Q<minutesInMonth){const ne=Math.round(Q/minutesInDay);return U.formatDistance("xDays",ne,K)}else if(Q<minutesInMonth*2)return ee=Math.round(Q/minutesInMonth),U.formatDistance("aboutXMonths",ee,K)}if(ee=differenceInMonths(J,Y),ee<12){const ne=Math.round(Q/minutesInMonth);return U.formatDistance("xMonths",ne,K)}else{const ne=ee%12,ie=Math.trunc(ee/12);return ne<3?U.formatDistance("aboutXYears",ie,K):ne<9?U.formatDistance("overXYears",ie,K):U.formatDistance("almostXYears",ie+1,K)}}function formatDistanceToNow(_,$){return formatDistance(_,Date.now(),$)}var LogLevel;(function(_){_[_.TRACE=5]="TRACE",_[_.DEBUG=10]="DEBUG",_[_.INFO=11]="INFO",_[_.WARN=12]="WARN",_[_.ERROR=13]="ERROR"})(LogLevel||(LogLevel={}));var QueryLogsRequest;(function(_){(function($){$[$.INCLUSIVE=1]="INCLUSIVE",$[$.EXPLICIT=2]="EXPLICIT"})(_.MatchingOptions||(_.MatchingOptions={}))})(QueryLogsRequest||(QueryLogsRequest={}));var SystemStatus;(function(_){_[_.ACTIVE=0]="ACTIVE",_[_.INACTIVE=1]="INACTIVE"})(SystemStatus||(SystemStatus={}));var GetDiagnosticsRequest;(function(_){(function($){$[$.NONE=0]="NONE",$[$.TRUNCATE=1]="TRUNCATE",$[$.HUMANIZE=2]="HUMANIZE"})(_.KEY_OPTION||(_.KEY_OPTION={}))})(GetDiagnosticsRequest||(GetDiagnosticsRequest={}));var Platform;(function(_){(function($){$[$.BROWSER=0]="BROWSER",$[$.SHARED_WORKER=1]="SHARED_WORKER",$[$.NODE=2]="NODE"})(_.PLATFORM_TYPE||(_.PLATFORM_TYPE={}))})(Platform||(Platform={}));var DeviceKind;(function(_){_[_.CURRENT=0]="CURRENT",_[_.TRUSTED=1]="TRUSTED"})(DeviceKind||(DeviceKind={}));var Device;(function(_){(function($){$[$.OFFLINE=0]="OFFLINE",$[$.ONLINE=1]="ONLINE",$[$.REMOVED=2]="REMOVED"})(_.PresenceState||(_.PresenceState={}))})(Device||(Device={}));var SpaceMember;(function(_){(function($){$[$.OFFLINE=0]="OFFLINE",$[$.ONLINE=1]="ONLINE"})(_.PresenceState||(_.PresenceState={}))})(SpaceMember||(SpaceMember={}));var SpaceState;(function(_){_[_.INACTIVE=2]="INACTIVE",_[_.ACTIVE=6]="ACTIVE",_[_.CLOSED=1]="CLOSED",_[_.CONTROL_ONLY=7]="CONTROL_ONLY",_[_.INITIALIZING=4]="INITIALIZING",_[_.READY=3]="READY",_[_.ERROR=5]="ERROR",_[_.REQUIRES_MIGRATION=8]="REQUIRES_MIGRATION"})(SpaceState||(SpaceState={}));var CreateEpochRequest;(function(_){(function($){$[$.NONE=0]="NONE",$[$.INIT_AUTOMERGE=1]="INIT_AUTOMERGE",$[$.PRUNE_AUTOMERGE_ROOT_HISTORY=2]="PRUNE_AUTOMERGE_ROOT_HISTORY",$[$.FRAGMENT_AUTOMERGE_ROOT=3]="FRAGMENT_AUTOMERGE_ROOT",$[$.REPLACE_AUTOMERGE_ROOT=4]="REPLACE_AUTOMERGE_ROOT",$[$.MIGRATE_REFERENCES_TO_DXN=5]="MIGRATE_REFERENCES_TO_DXN"})(_.Migration||(_.Migration={}))})(CreateEpochRequest||(CreateEpochRequest={}));var Invitation;(function(_){(function($){$[$.INTERACTIVE=0]="INTERACTIVE",$[$.DELEGATED=1]="DELEGATED",$[$.MULTIUSE=2]="MULTIUSE"})(_.Type||(_.Type={})),function($){$[$.DEVICE=0]="DEVICE",$[$.SPACE=1]="SPACE"}(_.Kind||(_.Kind={})),function($){$[$.NONE=0]="NONE",$[$.SHARED_SECRET=1]="SHARED_SECRET",$[$.KNOWN_PUBLIC_KEY=2]="KNOWN_PUBLIC_KEY"}(_.AuthMethod||(_.AuthMethod={})),function($){$[$.INIT=0]="INIT",$[$.CONNECTING=1]="CONNECTING",$[$.CONNECTED=2]="CONNECTED",$[$.READY_FOR_AUTHENTICATION=3]="READY_FOR_AUTHENTICATION",$[$.AUTHENTICATING=4]="AUTHENTICATING",$[$.SUCCESS=5]="SUCCESS",$[$.CANCELLED=6]="CANCELLED",$[$.TIMEOUT=7]="TIMEOUT",$[$.ERROR=8]="ERROR",$[$.EXPIRED=9]="EXPIRED"}(_.State||(_.State={}))})(Invitation||(Invitation={}));var QueryInvitationsResponse;(function(_){(function($){$[$.ADDED=0]="ADDED",$[$.REMOVED=1]="REMOVED",$[$.SAVED=2]="SAVED",$[$.LOAD_COMPLETE=3]="LOAD_COMPLETE"})(_.Action||(_.Action={})),function($){$[$.CREATED=0]="CREATED",$[$.ACCEPTED=1]="ACCEPTED"}(_.Type||(_.Type={}))})(QueryInvitationsResponse||(QueryInvitationsResponse={}));var ConnectionState;(function(_){_[_.OFFLINE=0]="OFFLINE",_[_.ONLINE=1]="ONLINE"})(ConnectionState||(ConnectionState={}));var ContextDisposedError=class extends Error{constructor(){super("Context disposed.")}};function _ts_decorate$1(_,$,I,j){var U=arguments.length,q=U<3?$:j===null?j=Object.getOwnPropertyDescriptor($,I):j,G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(_,$,I,j);else for(var K=_.length-1;K>=0;K--)(G=_[K])&&(q=(U<3?G(q):U>3?G($,I,q):G($,I))||q);return U>3&&q&&Object.defineProperty($,I,q),q}var __dxlog_file$4="/home/runner/work/dxos/dxos/packages/common/context/src/context.ts",MAX_SAFE_DISPOSE_CALLBACKS=300,DEFAULT_ERROR_HANDLER=(_,$)=>{if(!(_ instanceof ContextDisposedError))throw $.dispose(),_},_a$1,_b,Context=(un=class{constructor($={},I){nn(this,wt,void 0);nn(this,Ct,void 0);nn(this,Mt,void 0);nn(this,Yt,void 0);nn(this,xn,void 0);nn(this,Jt,void 0);nn(this,rn,void 0);qt(this,wt,[]),qt(this,Ct,void 0),qt(this,Mt,void 0),qt(this,Jt,!1),qt(this,rn,void 0),this.maxSafeDisposeCallbacks=MAX_SAFE_DISPOSE_CALLBACKS,this[_a$1]="Context",this[_b]=()=>this.toString(),qt(this,Ct,getContextName($,I)),qt(this,Mt,$.parent),qt(this,Yt,$.attributes??{}),qt(this,xn,$.onError??DEFAULT_ERROR_HANDLER)}static default(){return new un}get disposed(){return Ot(this,Jt)}get disposeCallbacksLength(){return Ot(this,wt).length}onDispose($){return Ot(this,Jt)&&(async()=>{try{await $()}catch(I){log$2.catch(I,{context:Ot(this,Ct)},{F:__dxlog_file$4,L:90,S:this,C:(j,U)=>j(...U)})}})(),Ot(this,wt).push($),Ot(this,wt).length>this.maxSafeDisposeCallbacks&&log$2.warn("Context has a large number of dispose callbacks (this might be a memory leak).",{context:Ot(this,Ct),count:Ot(this,wt).length},{F:__dxlog_file$4,L:97,S:this,C:(I,j)=>I(...j)}),()=>{const I=Ot(this,wt).indexOf($);I!==-1&&Ot(this,wt).splice(I,1)}}async dispose($=!1){if(Ot(this,rn))return Ot(this,rn);qt(this,Jt,!0);let I;const j=new Promise(Y=>{I=Y});qt(this,rn,j);const U=Array.from(Ot(this,wt)).reverse();Ot(this,wt).length=0;let q=0,G=!0;const K=[];for(const Y of U)try{await Y(),q++}catch(J){G=!1,$?K.push(J):log$2.catch(J,{context:Ot(this,Ct),callback:q,count:U.length},{F:__dxlog_file$4,L:156,S:this,C:(X,Z)=>X(...Z)})}if(K.length>0)throw new AggregateError(K);return I(G),G}raise($){if(!Ot(this,Jt))try{Ot(this,xn).call(this,$,this)}catch(I){Promise.reject(I)}}derive({onError:$,attributes:I}={}){const j=new un({onError:async q=>{if(!$)this.raise(q);else try{await $(q,this)}catch{this.raise(q)}},attributes:I}),U=this.onDispose(()=>j.dispose());return j.onDispose(U),j}getAttribute($){if($ in Ot(this,Yt))return Ot(this,Yt)[$];if(Ot(this,Mt))return Ot(this,Mt).getAttribute($)}toString(){return`Context(${Ot(this,Jt)?"disposed":"active"})`}async[(_a$1=Symbol.toStringTag,_b=export_inspect.custom,Symbol.asyncDispose)](){await this.dispose()}},wt=new WeakMap,Ct=new WeakMap,Mt=new WeakMap,Yt=new WeakMap,xn=new WeakMap,Jt=new WeakMap,rn=new WeakMap,un);Context=_ts_decorate$1([safeInstanceof("Context")],Context);var getContextName=(_,$)=>{var I;if(_.name)return _.name;if((I=$==null?void 0:$.F)!=null&&I.length){const j=$==null?void 0:$.F.split("/");return`${j[j.length-1]}#${($==null?void 0:$.L)??0}`}},LifecycleState;(function(_){_.CLOSED="CLOSED",_.OPEN="OPEN",_.ERROR="ERROR"})(LifecycleState||(LifecycleState={}));var Observable$2={};Object.defineProperty(Observable$2,"__esModule",{value:!0}),Observable$2.Observable=void 0;const hasSymbol=_=>!!Symbol[_],getSymbol=_=>hasSymbol(_)?Symbol[_]:"@@"+_,SymbolIterator=getSymbol("iterator"),SymbolObservable=getSymbol("observable"),SymbolSpecies=getSymbol("species");function getMethod(_,$){let I=_[$];if(I!=null){if(typeof I!="function")throw new TypeError(I+" is not a function");return I}}function getSpecies(_){let $=_.constructor;return $!==void 0&&($=$[SymbolSpecies],$===null&&($=void 0)),$!==void 0?$:Observable$1}function isObservable$1(_){return _ instanceof Observable$1}function hostReportError(_){hostReportError.log?hostReportError.log(_):setTimeout(()=>{throw _})}function enqueue(_){Promise.resolve().then(()=>{try{_()}catch($){hostReportError($)}})}function cleanupSubscription(_){let $=_._cleanup;if($!==void 0&&(_._cleanup=void 0,!!$))try{if(typeof $=="function")$();else{let I=getMethod($,"unsubscribe");I&&I.call($)}}catch(I){hostReportError(I)}}function closeSubscription(_){_._observer=void 0,_._queue=void 0,_._state="closed"}function flushSubscription(_){let $=_._queue;if($){_._queue=void 0,_._state="ready";for(let I=0;I<$.length&&(notifySubscription(_,$[I].type,$[I].value),_._state!=="closed");++I);}}function notifySubscription(_,$,I){_._state="running";let j=_._observer;try{let U=getMethod(j,$);switch($){case"next":U&&U.call(j,I);break;case"error":if(closeSubscription(_),U)U.call(j,I);else throw I;break;case"complete":closeSubscription(_),U&&U.call(j);break}}catch(U){hostReportError(U)}_._state==="closed"?cleanupSubscription(_):_._state==="running"&&(_._state="ready")}function onNotify(_,$,I){if(_._state!=="closed"){if(_._state==="buffering"){_._queue.push({type:$,value:I});return}if(_._state!=="ready"){_._state="buffering",_._queue=[{type:$,value:I}],enqueue(()=>flushSubscription(_));return}notifySubscription(_,$,I)}}class Subscription{constructor($,I){this._cleanup=void 0,this._observer=$,this._queue=void 0,this._state="initializing";let j=this,U={get closed(){return j._state==="closed"},next(q){onNotify(j,"next",q)},error(q){onNotify(j,"error",q)},complete(){onNotify(j,"complete")}};try{this._cleanup=I.call(void 0,U)}catch(q){U.error(q)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(closeSubscription(this),cleanupSubscription(this))}}let Observable$1=class Kn{constructor($){if(!(this instanceof Kn))throw new TypeError("Observable cannot be called as a function");if(typeof $!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=$}subscribe($){return(typeof $!="object"||$===null)&&($={next:$,error:arguments[1],complete:arguments[2]}),new Subscription($,this._subscriber)}forEach($){return new Promise((I,j)=>{if(typeof $!="function"){j(new TypeError($+" is not a function"));return}function U(){q.unsubscribe(),I()}let q=this.subscribe({next(G){try{$(G,U)}catch(K){j(K),q.unsubscribe()}},error:j,complete:I})})}map($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>this.subscribe({next(U){try{U=$(U)}catch(q){return j.error(q)}j.next(U)},error(U){j.error(U)},complete(){j.complete()}}))}filter($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>this.subscribe({next(U){try{if(!$(U))return}catch(q){return j.error(q)}j.next(U)},error(U){j.error(U)},complete(){j.complete()}}))}reduce($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this),j=arguments.length>1,U=!1,G=arguments[1];return new I(K=>this.subscribe({next(Y){let J=!U;if(U=!0,!J||j)try{G=$(G,Y)}catch(X){return K.error(X)}else G=Y},error(Y){K.error(Y)},complete(){if(!U&&!j)return K.error(new TypeError("Cannot reduce an empty sequence"));K.next(G),K.complete()}}))}async all(){let $=[];return await this.forEach(I=>$.push(I)),$}concat(...$){let I=getSpecies(this);return new I(j=>{let U,q=0;function G(K){U=K.subscribe({next(Y){j.next(Y)},error(Y){j.error(Y)},complete(){q===$.length?(U=void 0,j.complete()):G(I.from($[q++]))}})}return G(this),()=>{U&&(U.unsubscribe(),U=void 0)}})}flatMap($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>{let U=[],q=this.subscribe({next(K){if($)try{K=$(K)}catch(J){return j.error(J)}let Y=I.from(K).subscribe({next(J){j.next(J)},error(J){j.error(J)},complete(){let J=U.indexOf(Y);J>=0&&U.splice(J,1),G()}});U.push(Y)},error(K){j.error(K)},complete(){G()}});function G(){q.closed&&U.length===0&&j.complete()}return()=>{U.forEach(K=>K.unsubscribe()),q.unsubscribe()}})}[SymbolObservable](){return this}static from($){let I=typeof this=="function"?this:Kn;if($==null)throw new TypeError($+" is not an object");let j=getMethod($,SymbolObservable);if(j){let U=j.call($);if(Object(U)!==U)throw new TypeError(U+" is not an object");return isObservable$1(U)&&U.constructor===I?U:new I(q=>U.subscribe(q))}if(hasSymbol("iterator")&&(j=getMethod($,SymbolIterator),j))return new I(U=>{enqueue(()=>{if(!U.closed){for(let q of j.call($))if(U.next(q),U.closed)return;U.complete()}})});if(Array.isArray($))return new I(U=>{enqueue(()=>{if(!U.closed){for(let q=0;q<$.length;++q)if(U.next($[q]),U.closed)return;U.complete()}})});throw new TypeError($+" is not observable")}static of(...$){let I=typeof this=="function"?this:Kn;return new I(j=>{enqueue(()=>{if(!j.closed){for(let U=0;U<$.length;++U)if(j.next($[U]),j.closed)return;j.complete()}})})}static get[SymbolSpecies](){return this}};Observable$2.Observable=Observable$1,Object.defineProperty(Observable$1,Symbol("extensions"),{value:{symbol:SymbolObservable,hostReportError},configurable:!0});var zenObservable=Observable$2.Observable;const Observable=getDefaultExportFromCjs(zenObservable);var readableBrowser={exports:{}},events={exports:{}},R=typeof Reflect=="object"?Reflect:null,ReflectApply=R&&typeof R.apply=="function"?R.apply:function($,I,j){return Function.prototype.apply.call($,I,j)},ReflectOwnKeys;R&&typeof R.ownKeys=="function"?ReflectOwnKeys=R.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function($){return Object.getOwnPropertyNames($).concat(Object.getOwnPropertySymbols($))}:ReflectOwnKeys=function($){return Object.getOwnPropertyNames($)};function ProcessEmitWarning(_){console&&console.warn&&console.warn(_)}var NumberIsNaN=Number.isNaN||function($){return $!==$};function EventEmitter$1(){EventEmitter$1.init.call(this)}events.exports=EventEmitter$1,events.exports.once=once$2,EventEmitter$1.EventEmitter=EventEmitter$1,EventEmitter$1.prototype._events=void 0,EventEmitter$1.prototype._eventsCount=0,EventEmitter$1.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(EventEmitter$1,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(_){if(typeof _!="number"||_<0||NumberIsNaN(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");defaultMaxListeners=_}}),EventEmitter$1.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter$1.prototype.setMaxListeners=function($){if(typeof $!="number"||$<0||NumberIsNaN($))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+$+".");return this._maxListeners=$,this};function _getMaxListeners(_){return _._maxListeners===void 0?EventEmitter$1.defaultMaxListeners:_._maxListeners}EventEmitter$1.prototype.getMaxListeners=function(){return _getMaxListeners(this)},EventEmitter$1.prototype.emit=function($){for(var I=[],j=1;j<arguments.length;j++)I.push(arguments[j]);var U=$==="error",q=this._events;if(q!==void 0)U=U&&q.error===void 0;else if(!U)return!1;if(U){var G;if(I.length>0&&(G=I[0]),G instanceof Error)throw G;var K=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw K.context=G,K}var Y=q[$];if(Y===void 0)return!1;if(typeof Y=="function")ReflectApply(Y,this,I);else for(var J=Y.length,X=arrayClone(Y,J),j=0;j<J;++j)ReflectApply(X[j],this,I);return!0};function _addListener(_,$,I,j){var U,q,G;if(checkListener(I),q=_._events,q===void 0?(q=_._events=Object.create(null),_._eventsCount=0):(q.newListener!==void 0&&(_.emit("newListener",$,I.listener?I.listener:I),q=_._events),G=q[$]),G===void 0)G=q[$]=I,++_._eventsCount;else if(typeof G=="function"?G=q[$]=j?[I,G]:[G,I]:j?G.unshift(I):G.push(I),U=_getMaxListeners(_),U>0&&G.length>U&&!G.warned){G.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String($)+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=_,K.type=$,K.count=G.length,ProcessEmitWarning(K)}return _}EventEmitter$1.prototype.addListener=function($,I){return _addListener(this,$,I,!1)},EventEmitter$1.prototype.on=EventEmitter$1.prototype.addListener,EventEmitter$1.prototype.prependListener=function($,I){return _addListener(this,$,I,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(_,$,I){var j={fired:!1,wrapFn:void 0,target:_,type:$,listener:I},U=onceWrapper.bind(j);return U.listener=I,j.wrapFn=U,U}EventEmitter$1.prototype.once=function($,I){return checkListener(I),this.on($,_onceWrap(this,$,I)),this},EventEmitter$1.prototype.prependOnceListener=function($,I){return checkListener(I),this.prependListener($,_onceWrap(this,$,I)),this},EventEmitter$1.prototype.removeListener=function($,I){var j,U,q,G,K;if(checkListener(I),U=this._events,U===void 0)return this;if(j=U[$],j===void 0)return this;if(j===I||j.listener===I)--this._eventsCount===0?this._events=Object.create(null):(delete U[$],U.removeListener&&this.emit("removeListener",$,j.listener||I));else if(typeof j!="function"){for(q=-1,G=j.length-1;G>=0;G--)if(j[G]===I||j[G].listener===I){K=j[G].listener,q=G;break}if(q<0)return this;q===0?j.shift():spliceOne(j,q),j.length===1&&(U[$]=j[0]),U.removeListener!==void 0&&this.emit("removeListener",$,K||I)}return this},EventEmitter$1.prototype.off=EventEmitter$1.prototype.removeListener,EventEmitter$1.prototype.removeAllListeners=function($){var I,j,U;if(j=this._events,j===void 0)return this;if(j.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):j[$]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete j[$]),this;if(arguments.length===0){var q=Object.keys(j),G;for(U=0;U<q.length;++U)G=q[U],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=j[$],typeof I=="function")this.removeListener($,I);else if(I!==void 0)for(U=I.length-1;U>=0;U--)this.removeListener($,I[U]);return this};function _listeners(_,$,I){var j=_._events;if(j===void 0)return[];var U=j[$];return U===void 0?[]:typeof U=="function"?I?[U.listener||U]:[U]:I?unwrapListeners(U):arrayClone(U,U.length)}EventEmitter$1.prototype.listeners=function($){return _listeners(this,$,!0)},EventEmitter$1.prototype.rawListeners=function($){return _listeners(this,$,!1)},EventEmitter$1.listenerCount=function(_,$){return typeof _.listenerCount=="function"?_.listenerCount($):listenerCount.call(_,$)},EventEmitter$1.prototype.listenerCount=listenerCount;function listenerCount(_){var $=this._events;if($!==void 0){var I=$[_];if(typeof I=="function")return 1;if(I!==void 0)return I.length}return 0}EventEmitter$1.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(_,$){for(var I=new Array($),j=0;j<$;++j)I[j]=_[j];return I}function spliceOne(_,$){for(;$+1<_.length;$++)_[$]=_[$+1];_.pop()}function unwrapListeners(_){for(var $=new Array(_.length),I=0;I<$.length;++I)$[I]=_[I].listener||_[I];return $}function once$2(_,$){return new Promise(function(I,j){function U(G){_.removeListener($,q),j(G)}function q(){typeof _.removeListener=="function"&&_.removeListener("error",U),I([].slice.call(arguments))}eventTargetAgnosticAddListener(_,$,q,{once:!0}),$!=="error"&&addErrorHandlerIfEventEmitter(_,U,{once:!0})})}function addErrorHandlerIfEventEmitter(_,$,I){typeof _.on=="function"&&eventTargetAgnosticAddListener(_,"error",$,I)}function eventTargetAgnosticAddListener(_,$,I,j){if(typeof _.on=="function")j.once?_.once($,I):_.on($,I);else if(typeof _.addEventListener=="function")_.addEventListener($,function U(q){j.once&&_.removeEventListener($,U),I(q)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}var eventsExports=events.exports,streamBrowser=eventsExports.EventEmitter,buffer={},base64Js={};base64Js.byteLength=byteLength,base64Js.toByteArray=toByteArray,base64Js.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i$1=0,len=code.length;i$1<len;++i$1)lookup[i$1]=code[i$1],revLookup[code.charCodeAt(i$1)]=i$1;revLookup[45]=62,revLookup[95]=63;function getLens(_){var $=_.length;if($%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=_.indexOf("=");I===-1&&(I=$);var j=I===$?0:4-I%4;return[I,j]}function byteLength(_){var $=getLens(_),I=$[0],j=$[1];return(I+j)*3/4-j}function _byteLength(_,$,I){return($+I)*3/4-I}function toByteArray(_){var $,I=getLens(_),j=I[0],U=I[1],q=new Arr(_byteLength(_,j,U)),G=0,K=U>0?j-4:j,Y;for(Y=0;Y<K;Y+=4)$=revLookup[_.charCodeAt(Y)]<<18|revLookup[_.charCodeAt(Y+1)]<<12|revLookup[_.charCodeAt(Y+2)]<<6|revLookup[_.charCodeAt(Y+3)],q[G++]=$>>16&255,q[G++]=$>>8&255,q[G++]=$&255;return U===2&&($=revLookup[_.charCodeAt(Y)]<<2|revLookup[_.charCodeAt(Y+1)]>>4,q[G++]=$&255),U===1&&($=revLookup[_.charCodeAt(Y)]<<10|revLookup[_.charCodeAt(Y+1)]<<4|revLookup[_.charCodeAt(Y+2)]>>2,q[G++]=$>>8&255,q[G++]=$&255),q}function tripletToBase64(_){return lookup[_>>18&63]+lookup[_>>12&63]+lookup[_>>6&63]+lookup[_&63]}function encodeChunk(_,$,I){for(var j,U=[],q=$;q<I;q+=3)j=(_[q]<<16&16711680)+(_[q+1]<<8&65280)+(_[q+2]&255),U.push(tripletToBase64(j));return U.join("")}function fromByteArray(_){for(var $,I=_.length,j=I%3,U=[],q=16383,G=0,K=I-j;G<K;G+=q)U.push(encodeChunk(_,G,G+q>K?K:G+q));return j===1?($=_[I-1],U.push(lookup[$>>2]+lookup[$<<4&63]+"==")):j===2&&($=(_[I-2]<<8)+_[I-1],U.push(lookup[$>>10]+lookup[$>>4&63]+lookup[$<<2&63]+"=")),U.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ieee754.read=function(_,$,I,j,U){var q,G,K=U*8-j-1,Y=(1<<K)-1,J=Y>>1,X=-7,Z=I?U-1:0,Q=I?-1:1,ee=_[$+Z];for(Z+=Q,q=ee&(1<<-X)-1,ee>>=-X,X+=K;X>0;q=q*256+_[$+Z],Z+=Q,X-=8);for(G=q&(1<<-X)-1,q>>=-X,X+=j;X>0;G=G*256+_[$+Z],Z+=Q,X-=8);if(q===0)q=1-J;else{if(q===Y)return G?NaN:(ee?-1:1)*(1/0);G=G+Math.pow(2,j),q=q-J}return(ee?-1:1)*G*Math.pow(2,q-j)},ieee754.write=function(_,$,I,j,U,q){var G,K,Y,J=q*8-U-1,X=(1<<J)-1,Z=X>>1,Q=U===23?Math.pow(2,-24)-Math.pow(2,-77):0,ee=j?0:q-1,ne=j?1:-1,ie=$<0||$===0&&1/$<0?1:0;for($=Math.abs($),isNaN($)||$===1/0?(K=isNaN($)?1:0,G=X):(G=Math.floor(Math.log($)/Math.LN2),$*(Y=Math.pow(2,-G))<1&&(G--,Y*=2),G+Z>=1?$+=Q/Y:$+=Q*Math.pow(2,1-Z),$*Y>=2&&(G++,Y/=2),G+Z>=X?(K=0,G=X):G+Z>=1?(K=($*Y-1)*Math.pow(2,U),G=G+Z):(K=$*Math.pow(2,Z-1)*Math.pow(2,U),G=0));U>=8;_[I+ee]=K&255,ee+=ne,K/=256,U-=8);for(G=G<<U|K,J+=U;J>0;_[I+ee]=G&255,ee+=ne,G/=256,J-=8);_[I+ee-ne]|=ie*128};/*!
|
|
846
|
+
`;function $e5534fc185f7111e$export$2e2bcd8739ae039(_){const $=React.useRef(null),I=React.useRef(null);return I.current&&I.current.update(_),React.useEffect(()=>(I.current=new $efa000751917694d$export$2e2bcd8739ae039({..._,ref:$}),()=>{I.current=null}),[]),React.createElement("div",{ref:$})}const EmojiPickerToolbarButton=({disabled:_,defaultEmoji:$,emoji:I,onChangeEmoji:j,classNames:U})=>{const{t:q}=useTranslation("os"),{themeMode:G}=useThemeContext(),[K,Y]=$71cd76cc60e0454e$export$6f32135080cb4c3({prop:I,onChange:j,defaultProp:$}),[J,X]=React.useState(!1),Z=React.useRef(!1),[Q,ee]=React.useState(!1);return React.createElement(Tooltip.Root,{open:Q,onOpenChange:ne=>{Z.current?(ee(!1),Z.current=!1):ee(ne)}},React.createElement(Popover.Root,{open:J,onOpenChange:ne=>{X(ne),Z.current=!0}},React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Popover.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:["gap-2 text-2xl plb-1",U],disabled:_},React.createElement("span",{className:"sr-only"},q("select emoji label")),React.createElement(react.UserCircle,{className:getSize(5)})))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},q("select emoji label"),React.createElement(Tooltip.Arrow,null))),React.createElement(Popover.Content,{side:"bottom",onKeyDownCapture:ne=>{ne.key==="Escape"&&(ne.stopPropagation(),X(!1),Z.current=!0)}},React.createElement($e5534fc185f7111e$export$2e2bcd8739ae039,{data:emojiData,onEmojiSelect:({native:ne})=>{ne&&(Y(ne),X(!1))},autoFocus:!0,maxFrequentRows:0,noCountryFlags:!0,theme:G}),React.createElement(Popover.Arrow,null))))},HuePreview=({hue:_})=>{const{tx:$}=useThemeContext(),I=20;return React.createElement("svg",{width:I,height:I,viewBox:`0 0 ${I} ${I}`},React.createElement("rect",{x:0,y:0,width:I,height:I,className:$("hue.fill","select--hue__preview",{hue:_})}))},hueTokens=Object.keys(hueTokenThemes).slice(0,16),HuePickerToolbarButton=({disabled:_,hue:$,onChangeHue:I,classNames:j,defaultHue:U})=>{const{t:q}=useTranslation("os"),[G,K]=$71cd76cc60e0454e$export$6f32135080cb4c3({prop:$,onChange:I,defaultProp:U}),[Y,J]=React.useState(!1),X=React.useRef(!1),[Z,Q]=React.useState(!1);return React.createElement(Tooltip.Root,{open:Z,onOpenChange:ee=>{X.current?(Q(!1),X.current=!1):Q(ee)}},React.createElement(DropdownMenu2.Root,{modal:!1,open:Y,onOpenChange:ee=>{J(ee),X.current=!0}},React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(DropdownMenu2.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:mx("gap-2 plb-1",j),disabled:_},React.createElement("span",{className:"sr-only"},q("select hue label")),React.createElement(react.Palette,{className:getSize(5)})))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},q("select hue label"),React.createElement(Tooltip.Arrow,null))),React.createElement(DropdownMenu2.Content,{side:"bottom",classNames:"!w-40"},React.createElement(DropdownMenu2.Viewport,{classNames:"grid grid-cols-4"},hueTokens.map(ee=>React.createElement(DropdownMenu2.CheckboxItem,{key:ee,checked:ee===G,onCheckedChange:()=>K(ee),classNames:"px-0 py-2 items-center justify-center"},React.createElement(HuePreview,{hue:ee})))))))};var data={adjectives:["abundant","accessible","accomplished","accurate","achievable","adaptable","adaptive","adequate","adjustable","admirable","admiring","adorable","adored","adoring","adroit","adulatory","advanced","advantageous","adventurous","affable","affectionate","affirmative","affluent","affordable","agile","agreeable","alluring","altruistic","amazed","amazing","ambitious","amenable","amiable","amicable","ample","amusing","angelic","appealing","appreciable","appreciated","appreciative","appropriate","ardent","articulate","artistic","assuring","astonished","astonishing","astounded","astounding","athletic","attentive","attractive","audible","auspicious","authentic","autonomous","available","avid","awed","awesome","awestruck","beauteous","beautiful","believable","beloved","beneficent","beneficial","benevolent","blameless","blissful","blithe","bonny","booming","boundless","bountiful","brainiest","brainy","brave","breathtaking","bright","brighter","brightest","brilliant","brisk","brotherly","bullish","buoyant","calm","calming","capable","captivating","carefree","catchy","celebrated","celebratory","champion","charismatic","charitable","charming","chaste","cheaper","cheapest","cheerful","cheery","cherished","chivalrous","classic","classy","clean","cleaner","cleanest","cleanly","clear","cleared","clearer","clever","coherent","cohesive","colorful","comely","comfortable","comforting","comfy","commendable","commodious","compact","compatible","competitive","compliant","conciliatory","concise","confident","congenial","considerate","consistent","constructive","consummate","contrasty","convenient","convincing","cool","coolest","cooperative","correct","courageous","courteous","courtly","cozy","creative","credible","crisp","crisper","cushy","cute","daring","darling","dashing","dauntless","dazzled","dazzling","decent","decisive","dedicated","defeated","deft","delectable","delicate","delicious","delighted","delightful","dependable","deserving","desirable","desirous","detachable","devout","dexterous","dextrous","dignified","diligent","diplomatic","distinctive","diversified","divine","dominated","dumbfounded","durable","dynamic","eager","earnest","eased","easy","easygoing","ebullient","economical","ecstatic","educated","effective","efficacious","efficient","effortless","effusive","elated","elegant","elite","eloquent","eminent","enchanted","enchanting","encouraging","endearing","endorsed","energetic","engaging","engrossing","enhanced","enjoyable","enraptured","enterprising","entertaining","enthralled","enthusiastic","enticing","entranced","entrancing","enviable","envious","equitable","erudite","ethical","euphoric","evaluative","eventful","everlasting","evocative","exalted","exalting","exceeding","excellent","exceptional","excited","exciting","exemplary","exhilarating","expansive","exquisite","exuberant","exultant","fabulous","fair","faithful","famed","famous","fancier","fancy","fantastic","fascinating","fashionable","fast","faster","fastest","faultless","favorable","favored","favorite","fearless","feasible","feisty","felicitous","fertile","fervent","fervid","festive","fiery","fine","finer","finest","firmer","flashy","flatter","flattering","flawless","flexible","flourishing","fluent","fond","foolproof","foremost","formidable","fortuitous","fortunate","fragrant","free","freed","fresh","fresher","freshest","friendly","frugal","fruitful","fun","funny","futuristic","gainful","gallant","galore","generous","genial","gentle","gentlest","genuine","gifted","glad","glamorous","gleeful","glimmering","glistening","glorious","glowing","godlike","gold","golden","good","goodly","gorgeous","graceful","gracious","grand","grateful","gratified","gratifying","great","greatest","guiltless","gutsy","halcyon","hale","hallowed","handier","handsome","handy","happier","happy","hardier","hardy","harmless","harmonious","healthful","healthy","heartening","heartfelt","heartwarming","heavenly","helpful","heroic","hilarious","holy","honest","honorable","honored","hopeful","hospitable","hot","hottest","humane","humble","humorous","humourous","ideal","idolized","idyllic","illuminating","illustrious","imaginative","immaculate","immense","impartial","impassioned","impeccable","important","impressed","impressive","improved","improving","incredible","indebted","indulgent","industrious","inestimable","inexpensive","infallible","influential","ingenious","ingenuous","innocuous","innovative","insightful","inspiring","instructive","instrumental","intelligent","intelligible","interesting","intimate","intricate","intriguing","intuitive","invaluable","inventive","invigorating","invincible","inviolable","inviolate","invulnerable","irresistible","jolly","jovial","joyful","joyous","jubilant","judicious","keen","kindly","laudable","lavish","lawful","leading","lean","legendary","lighter","likable","like","liked","lionhearted","lively","logical","lovable","loved","lovely","loving","loyal","lucid","luckier","luckiest","lucky","lucrative","luminous","lush","lustrous","luxuriant","luxurious","luxury","lyrical","magic","magical","magnanimous","magnificent","majestic","manageable","marvellous","marvelous","masterful","matchless","mature","meaningful","memorable","merciful","meritorious","merry","mesmerized","mesmerizing","meticulous","mighty","miraculous","modern","modest","momentous","monumental","motivated","navigable","neat","neatest","nice","nifty","nimble","noble","noiseless","noteworthy","nourishing","observant","obtainable","optimal","optimistic","opulent","orderly","organized","outstanding","overjoyed","painless","palatial","pampered","panoramic","paramount","passionate","patient","patri","peaceable","peaceful","peerless","peppy","perfect","permissible","personalized","phenomenal","picturesque","playful","pleasant","pleased","pleasing","pleasurable","plentiful","plush","poetic","poignant","poised","polished","polite","popular","portable","posh","positive","powerful","praiseworthy","praising","precious","precise","preeminent","preferable","premier","prestigious","pretty","priceless","principled","privileged","prize","proactive","prodigious","productive","proficient","profound","progressive","prolific","prominent","promised","promising","prompt","proper","propitious","prosperous","protective","proud","proven","prudent","punctual","pure","purposeful","quaint","qualified","quicker","quiet","quieter","radiant","rapid","rapt","rapturous","rational","reachable","readable","ready","realistic","realizable","reasonable","reasoned","receptive","recommended","redeeming","refined","reformed","refreshed","refreshing","regal","rejoicing","relaxed","reliable","remarkable","renewed","renowned","replaceable","reputable","resilient","resolute","resounding","resourceful","respectable","respectful","resplendent","responsive","restful","restored","retractable","reverent","rewarding","rich","righteous","rightful","robust","romantic","roomier","rosy","safe","saintly","salutary","sane","satisfactory","satisfied","satisfying","scenic","seamless","seasoned","secure","selective","sensational","sensible","sensitive","serene","sexy","sharp","sharper","sharpest","shiny","significant","silent","simpler","simplest","simplified","sincere","skilled","skillful","sleek","slick","smart","smarter","smartest","smelly","smiling","smitten","smooth","smoother","smoothest","snappy","snazzy","sociable","soft","softer","solid","soulful","spacious","sparkling","spectacular","speedy","spellbinding","spellbound","spirited","spiritual","splendid","spontaneous","sporty","spotless","sprightly","stable","stainless","stately","statuesque","staunch","steadfast","steadiest","steady","stellar","stimulating","stimulative","streamlined","striking","strong","stronger","strongest","stunned","stunning","stupendous","sturdier","sturdy","stylish","stylized","suave","sublime","subsidized","substantive","succeeding","successful","sufficient","suitable","sumptuous","super","superb","superior","supple","supportive","supreme","surreal","sustainable","swankier","swankiest","swanky","sweeping","sweet","sweetheart","swift","talented","tantalizing","tempting","tenacious","tender","terrific","thankful","thinner","thoughtful","thrifty","thrilled","thrilling","thriving","tidy","timely","titillating","tolerable","top","topnotch","tough","tougher","toughest","tranquil","transparent","trendy","triumphal","triumphant","trusted","trusting","trustworthy","trusty","truthful","twinkly","unabashed","unaffected","unassailable","unbeatable","unbiased","unbound","undamaged","undaunted","undisputable","undisputed","unencumbered","unequivocal","unfettered","unlimited","unmatched","unparalleled","unreal","unrestricted","unrivaled","unselfish","unwavering","upbeat","upscale","usable","useful","valiant","valuable","verifiable","veritable","versatile","vibrant","victorious","viewable","vigilant","virtuous","visionary","vivacious","vivid","warm","warmer","warmhearted","wealthy","welcome","wholesome","wieldy","winning","wise","witty","wonderful","wondrous","workable","worth","worthwhile","worthy","young","youthful","zippy"],animals:["aardvark","albatross","alligator","angelfish","angora","ant","anteater","antelope","armadillo","avocet","baboon","badger","bandicoot","barnacle","barracuda","bat","beagle","bear","beaver","bee","beetle","bird","bison","bloodhound","boar","bobcat","bonobo","buffalo","bulldog","bullfrog","butterfly","buzzard","camel","cat","caterpillar","catfish","cattle","centipede","chameleon","cheetah","chicken","chihuahua","chimpanzee","chin","chinchilla","chipmunk","civet","clam","cockroach","coon","coral","corgi","cougar","cow","coyote","crab","crane","cuttlefish","dachshund","dalmatian","dane","deer","devil","dingo","dodo","dog","dogfish","dollar","dolphin","donkey","dormouse","dragon","dragonfly","duck","dugong","eagle","earwig","eel","elephant","emperor","emu","falcon","ferret","fish","flamingo","flounder","fly","forest","fowl","fox","foxhound","frog","gar","gecko","gerbil","gharial","gibbon","giraffe","goat","goose","gopher","gorilla","grasshopper","greyhound","grouse","guppy","hamster","hare","hedgehog","heron","hippopotamus","hornet","horse","hound","hummingbird","husky","hyena","hyrax","ibis","iguana","impala","insect","jackal","jaguar","jellyfish","kangaroo","kingfisher","kiwi","koala","kudu","labradoodle","ladybird","lemming","lemur","leopard","liger","lion","lionfish","lizard","llama","lobster","lynx","macaque","macaw","magpie","malamute","maltese","mammoth","manatee","mandrill","markhor","marmoset","mastiff","mayfly","meerkat","millipede","mole","mongoose","monkey","monster","moorhen","moose","moth","mouse","mule","newt","nightingale","ocelot","octopus","okapi","orangutan","ostrich","otter","owl","oyster","panda","panther","parrot","peacock","pelican","penguin","pheasant","pig","pike","piranha","platypus","pointer","poodle","porcupine","possum","prawn","puffin","pug","puma","quail","rabbit","raccoon","rat","rattlesnake","ray","reindeer","retriever","rhinoceros","robin","rottweiler","russel","salamander","scorpion","seahorse","seal","shark","sheep","sheepdog","shrew","shrimp","skater","skunk","sloth","slug","snail","snake","snowshoe","spaniel","sparrow","spider","sponge","squid","squirrel","squirt","starfish","stingray","stoat","swan","tapir","tarantula","termite","terrier","tiger","toad","tortoise","toucan","tuatara","turkey","turtle","uakari","urchin","vole","vulture","wallaby","walrus","warthog","wasp","weasel","whale","whippet","wildebeest","wolf","wolfhound","wolverine","wombat","woodlouse","woodpecker","worm","yak","zebra","zebu","zonkey","zorse"]},capitalize=_=>_.charAt(0).toUpperCase()+_.slice(1),generateName=_=>{const $=_.length*2/3,I=_.substring(0,$),j=_.substring($),U=capitalize(data.adjectives[parseInt(I,16)%data.adjectives.length]),q=capitalize(data.animals[parseInt(j,16)%data.animals.length]);return`${U} ${q}`};const IdentityListItem=React.forwardRef(({identity:_,presence:$,onClick:I,classNames:j,...U},q)=>{var J,X,Z,Q,ee;const G=keyToFallback(_.identityKey),K=useId("identityListItem__label"),Y=((J=_.profile)==null?void 0:J.displayName)??generateName(_.identityKey.toHex());return React.createElement(ListItem.Root,{...U,classNames:mx("flex gap-2 pis-3 pie-1 items-center",I&&"cursor-pointer",j),onClick:()=>I==null?void 0:I(),"data-testid":"identity-list-item",labelId:K,ref:q},React.createElement(Avatar.Root,{status:$===echo.SpaceMember.PresenceState.ONLINE?"active":"inactive",labelId:K,hue:((Z=(X=_.profile)==null?void 0:X.data)==null?void 0:Z.hue)||G.hue},React.createElement(Avatar.Frame,{classNames:"place-self-center"},React.createElement(Avatar.Fallback,{text:((ee=(Q=_.profile)==null?void 0:Q.data)==null?void 0:ee.emoji)||G.emoji})),React.createElement(Avatar.Label,{classNames:"text-sm truncate pli-2"},Y)))}),SpaceMemberList=({spaceKey:_,includeSelf:$,onSelect:I})=>{const j=reactClient.useClient(),U=echo.useMembers(_),q=React.useMemo(()=>$?U.sort(G=>G.identity.identityKey.equals(j.halo.identity.get().identityKey)?-1:1):U.filter(G=>!G.identity.identityKey.equals(j.halo.identity.get().identityKey)),[U]);return React.createElement(SpaceMemberListImpl,{members:q,onSelect:I})},SpaceMemberListImpl=({members:_,onSelect:$})=>{const{t:I}=useTranslation("os"),j=_.filter(U=>U.identity);return j.length>0?React.createElement(List,{classNames:"flex flex-col gap-2","data-testid":"space-members-list"},j.map(U=>React.createElement(IdentityListItem,{key:U.identity.identityKey.toHex(),identity:U.identity,presence:U.presence,onClick:$&&(()=>$(U))}))):React.createElement("div",{role:"none",className:"grow flex items-center p-2"},React.createElement("p",{className:mx(descriptionText,"text-center is-full mlb-2")},I("empty space members message")))},iconProps={weight:"duotone",width:24,height:24,x:8,y:8},DeviceListItem=React.forwardRef(({device:_,onClickAdd:$,onClickEdit:I,onClickReset:j,onClickJoinExisting:U,classNames:q,connectionState:G,onAgentDestroy:K,...Y},J)=>{var ie,oe;const{t:X}=useTranslation("os"),Z=keyToFallback(_.deviceKey),Q=useId("identityListItem__label"),ee=_.profile?X("device name placeholder",{os:_.profile.os,platform:_.profile.platform}):generateName(_.deviceKey.toHex()),ne=_.kind===halo.DeviceKind.CURRENT;return React.createElement(ListItem.Root,{...Y,classNames:["flex gap-2 items-center mlb-2",q],"data-testid":`device-list-item${ne?"-current":""}`,labelId:Q,ref:J},React.createElement(Avatar.Root,{status:ne&&G===mesh.ConnectionState.OFFLINE?"error":_.presence===halo.Device.PresenceState.ONLINE?"active":"inactive",labelId:Q,hue:Z.hue,variant:"square"},React.createElement(Avatar.Frame,{classNames:"place-self-center"},(ie=_.profile)!=null&&ie.type?_.profile.type===halo.DeviceType.AGENT_MANAGED?React.createElement(react.Database,{...iconProps}):_.profile.type===halo.DeviceType.BROWSER?React.createElement(react.Compass,{...iconProps}):_.profile.type===halo.DeviceType.NATIVE?React.createElement(react.Desktop,{...iconProps}):[halo.DeviceType.AGENT,halo.DeviceType.AGENT_MANAGED].includes(_.profile.type)?React.createElement(react.Robot,{...iconProps}):_.profile.type===halo.DeviceType.MOBILE?React.createElement(react.DeviceMobile,{...iconProps}):React.createElement(react.Devices,{...iconProps}):React.createElement(Avatar.Fallback,{text:Z.emoji})),React.createElement(Avatar.Label,{classNames:"flex-1 text-sm truncate"},ee),ne&&React.createElement(Tag,{color:"primary"},X("current device tag label")),((oe=_.profile)==null?void 0:oe.type)===halo.DeviceType.AGENT_MANAGED?React.createElement(Tooltip.Root,null,React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Button,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":"agent.destroy",onClick:K},React.createElement("span",{className:"sr-only"},X("destroy agent label")),React.createElement(react.Power,{className:getSize(5)}))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},X("destroy agent label")))):_.kind===halo.DeviceKind.CURRENT&&React.createElement(DropdownMenu2.Root,null,React.createElement(DropdownMenu2.Trigger,{asChild:!0},React.createElement(Button,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":`device-list-item${ne?"-current":""}.options`},React.createElement("span",{className:"sr-only"},X("more options label")),React.createElement(react.DotsThree,{className:getSize(5)}))),React.createElement(DropdownMenu2.Content,null,React.createElement(DropdownMenu2.Viewport,null,React.createElement(DropdownMenu2.Item,{"data-testid":"device-list-item-current.join-existing",onClick:U},React.createElement(react.ShareFat,{className:getSize(5)}),X("choose join new identity label")),React.createElement(DropdownMenu2.Item,{"data-testid":"device-list-item-current.reset",onClick:j},React.createElement(react.Power,{className:getSize(5)}),X("reset device label")))))))}),DeviceList=({devices:_,connectionState:$,onClickAdd:I,onClickEdit:j,onClickReset:U,onClickJoinExisting:q,onAgentDestroy:G})=>{const{t:K}=useTranslation("os");return React.createElement(React.Fragment,null,React.createElement("h2",{className:mx(descriptionText,"text-center mbs-4")},K("devices heading")),_.length>0&&React.createElement(List,null,_.map(Y=>React.createElement(DeviceListItem,{key:Y.deviceKey.toHex(),device:Y,onClickEdit:()=>j==null?void 0:j(Y),onClickReset:U,onClickJoinExisting:q,connectionState:$,onAgentDestroy:G}))),React.createElement(Button,{variant:"ghost",classNames:"justify-start gap-2 !pis-0 !pie-3 is-full","data-testid":"devices-panel.create-invitation",onClick:I},React.createElement("div",{role:"img",className:mx(getSize(8),"m-1 rounded-sm surface-input grid place-items-center")},React.createElement(react.Plus,{weight:"light",className:getSize(6)})),React.createElement("span",{className:"grow font-medium text-start"},K("choose add device label")),React.createElement(react.CaretRight,{weight:"bold",className:getSize(4)})))},minutesInMonth=43200,minutesInDay=1440;function getTimezoneOffsetInMilliseconds(_){const $=toDate(_),I=new Date(Date.UTC($.getFullYear(),$.getMonth(),$.getDate(),$.getHours(),$.getMinutes(),$.getSeconds(),$.getMilliseconds()));return I.setUTCFullYear($.getFullYear()),+_-+I}function compareAsc(_,$){const I=toDate(_),j=toDate($),U=I.getTime()-j.getTime();return U<0?-1:U>0?1:U}function differenceInCalendarMonths(_,$){const I=toDate(_),j=toDate($),U=I.getFullYear()-j.getFullYear(),q=I.getMonth()-j.getMonth();return U*12+q}function getRoundingMethod(_){return $=>{const j=(_?Math[_]:Math.trunc)($);return j===0?0:j}}function differenceInMilliseconds(_,$){return+toDate(_)-+toDate($)}function endOfDay(_){const $=toDate(_);return $.setHours(23,59,59,999),$}function endOfMonth(_){const $=toDate(_),I=$.getMonth();return $.setFullYear($.getFullYear(),I+1,0),$.setHours(23,59,59,999),$}function isLastDayOfMonth(_){const $=toDate(_);return+endOfDay($)==+endOfMonth($)}function differenceInMonths(_,$){const I=toDate(_),j=toDate($),U=compareAsc(I,j),q=Math.abs(differenceInCalendarMonths(I,j));let G;if(q<1)G=0;else{I.getMonth()===1&&I.getDate()>27&&I.setDate(30),I.setMonth(I.getMonth()-U*q);let K=compareAsc(I,j)===-U;isLastDayOfMonth(toDate(_))&&q===1&&compareAsc(_,j)===1&&(K=!1),G=U*(q-Number(K))}return G===0?0:G}function differenceInSeconds(_,$,I){const j=differenceInMilliseconds(_,$)/1e3;return getRoundingMethod(I==null?void 0:I.roundingMethod)(j)}function formatDistance(_,$,I){const j=getDefaultOptions(),U=(I==null?void 0:I.locale)??j.locale??enUS$1,q=2520,G=compareAsc(_,$);if(isNaN(G))throw new RangeError("Invalid time value");const K=Object.assign({},I,{addSuffix:I==null?void 0:I.addSuffix,comparison:G});let Y,J;G>0?(Y=toDate($),J=toDate(_)):(Y=toDate(_),J=toDate($));const X=differenceInSeconds(J,Y),Z=(getTimezoneOffsetInMilliseconds(J)-getTimezoneOffsetInMilliseconds(Y))/1e3,Q=Math.round((X-Z)/60);let ee;if(Q<2)return I!=null&&I.includeSeconds?X<5?U.formatDistance("lessThanXSeconds",5,K):X<10?U.formatDistance("lessThanXSeconds",10,K):X<20?U.formatDistance("lessThanXSeconds",20,K):X<40?U.formatDistance("halfAMinute",0,K):X<60?U.formatDistance("lessThanXMinutes",1,K):U.formatDistance("xMinutes",1,K):Q===0?U.formatDistance("lessThanXMinutes",1,K):U.formatDistance("xMinutes",Q,K);if(Q<45)return U.formatDistance("xMinutes",Q,K);if(Q<90)return U.formatDistance("aboutXHours",1,K);if(Q<minutesInDay){const ne=Math.round(Q/60);return U.formatDistance("aboutXHours",ne,K)}else{if(Q<q)return U.formatDistance("xDays",1,K);if(Q<minutesInMonth){const ne=Math.round(Q/minutesInDay);return U.formatDistance("xDays",ne,K)}else if(Q<minutesInMonth*2)return ee=Math.round(Q/minutesInMonth),U.formatDistance("aboutXMonths",ee,K)}if(ee=differenceInMonths(J,Y),ee<12){const ne=Math.round(Q/minutesInMonth);return U.formatDistance("xMonths",ne,K)}else{const ne=ee%12,ie=Math.trunc(ee/12);return ne<3?U.formatDistance("aboutXYears",ie,K):ne<9?U.formatDistance("overXYears",ie,K):U.formatDistance("almostXYears",ie+1,K)}}function formatDistanceToNow(_,$){return formatDistance(_,Date.now(),$)}var SystemStatus;(function(_){_[_.ACTIVE=0]="ACTIVE",_[_.INACTIVE=1]="INACTIVE"})(SystemStatus||(SystemStatus={}));var GetDiagnosticsRequest;(function(_){(function($){$[$.NONE=0]="NONE",$[$.TRUNCATE=1]="TRUNCATE",$[$.HUMANIZE=2]="HUMANIZE"})(_.KEY_OPTION||(_.KEY_OPTION={}))})(GetDiagnosticsRequest||(GetDiagnosticsRequest={}));var Platform;(function(_){(function($){$[$.BROWSER=0]="BROWSER",$[$.SHARED_WORKER=1]="SHARED_WORKER",$[$.NODE=2]="NODE"})(_.PLATFORM_TYPE||(_.PLATFORM_TYPE={}))})(Platform||(Platform={}));var DeviceKind;(function(_){_[_.CURRENT=0]="CURRENT",_[_.TRUSTED=1]="TRUSTED"})(DeviceKind||(DeviceKind={}));var Device;(function(_){(function($){$[$.OFFLINE=0]="OFFLINE",$[$.ONLINE=1]="ONLINE",$[$.REMOVED=2]="REMOVED"})(_.PresenceState||(_.PresenceState={}))})(Device||(Device={}));var SpaceMember;(function(_){(function($){$[$.OFFLINE=0]="OFFLINE",$[$.ONLINE=1]="ONLINE"})(_.PresenceState||(_.PresenceState={}))})(SpaceMember||(SpaceMember={}));var SpaceState;(function(_){_[_.INACTIVE=2]="INACTIVE",_[_.ACTIVE=6]="ACTIVE",_[_.CLOSED=1]="CLOSED",_[_.CONTROL_ONLY=7]="CONTROL_ONLY",_[_.INITIALIZING=4]="INITIALIZING",_[_.READY=3]="READY",_[_.ERROR=5]="ERROR",_[_.REQUIRES_MIGRATION=8]="REQUIRES_MIGRATION"})(SpaceState||(SpaceState={}));var CreateEpochRequest;(function(_){(function($){$[$.NONE=0]="NONE",$[$.INIT_AUTOMERGE=1]="INIT_AUTOMERGE",$[$.PRUNE_AUTOMERGE_ROOT_HISTORY=2]="PRUNE_AUTOMERGE_ROOT_HISTORY",$[$.FRAGMENT_AUTOMERGE_ROOT=3]="FRAGMENT_AUTOMERGE_ROOT",$[$.REPLACE_AUTOMERGE_ROOT=4]="REPLACE_AUTOMERGE_ROOT",$[$.MIGRATE_REFERENCES_TO_DXN=5]="MIGRATE_REFERENCES_TO_DXN"})(_.Migration||(_.Migration={}))})(CreateEpochRequest||(CreateEpochRequest={}));var Invitation;(function(_){(function($){$[$.INTERACTIVE=0]="INTERACTIVE",$[$.DELEGATED=1]="DELEGATED",$[$.MULTIUSE=2]="MULTIUSE"})(_.Type||(_.Type={})),function($){$[$.DEVICE=0]="DEVICE",$[$.SPACE=1]="SPACE"}(_.Kind||(_.Kind={})),function($){$[$.NONE=0]="NONE",$[$.SHARED_SECRET=1]="SHARED_SECRET",$[$.KNOWN_PUBLIC_KEY=2]="KNOWN_PUBLIC_KEY"}(_.AuthMethod||(_.AuthMethod={})),function($){$[$.INIT=0]="INIT",$[$.CONNECTING=1]="CONNECTING",$[$.CONNECTED=2]="CONNECTED",$[$.READY_FOR_AUTHENTICATION=3]="READY_FOR_AUTHENTICATION",$[$.AUTHENTICATING=4]="AUTHENTICATING",$[$.SUCCESS=5]="SUCCESS",$[$.CANCELLED=6]="CANCELLED",$[$.TIMEOUT=7]="TIMEOUT",$[$.ERROR=8]="ERROR",$[$.EXPIRED=9]="EXPIRED"}(_.State||(_.State={}))})(Invitation||(Invitation={}));var QueryInvitationsResponse;(function(_){(function($){$[$.ADDED=0]="ADDED",$[$.REMOVED=1]="REMOVED",$[$.SAVED=2]="SAVED",$[$.LOAD_COMPLETE=3]="LOAD_COMPLETE"})(_.Action||(_.Action={})),function($){$[$.CREATED=0]="CREATED",$[$.ACCEPTED=1]="ACCEPTED"}(_.Type||(_.Type={}))})(QueryInvitationsResponse||(QueryInvitationsResponse={}));var ConnectionState;(function(_){_[_.OFFLINE=0]="OFFLINE",_[_.ONLINE=1]="ONLINE"})(ConnectionState||(ConnectionState={}));var LogLevel;(function(_){_[_.TRACE=5]="TRACE",_[_.DEBUG=10]="DEBUG",_[_.INFO=11]="INFO",_[_.WARN=12]="WARN",_[_.ERROR=13]="ERROR"})(LogLevel||(LogLevel={}));var QueryLogsRequest;(function(_){(function($){$[$.INCLUSIVE=1]="INCLUSIVE",$[$.EXPLICIT=2]="EXPLICIT"})(_.MatchingOptions||(_.MatchingOptions={}))})(QueryLogsRequest||(QueryLogsRequest={}));var ContextDisposedError=class extends Error{constructor(){super("Context disposed.")}};function _ts_decorate$1(_,$,I,j){var U=arguments.length,q=U<3?$:j===null?j=Object.getOwnPropertyDescriptor($,I):j,G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")q=Reflect.decorate(_,$,I,j);else for(var K=_.length-1;K>=0;K--)(G=_[K])&&(q=(U<3?G(q):U>3?G($,I,q):G($,I))||q);return U>3&&q&&Object.defineProperty($,I,q),q}var __dxlog_file$4="/home/runner/work/dxos/dxos/packages/common/context/src/context.ts",MAX_SAFE_DISPOSE_CALLBACKS=300,DEFAULT_ERROR_HANDLER=(_,$)=>{if(!(_ instanceof ContextDisposedError))throw $.dispose(),_},_a$1,_b,Context=(un=class{constructor($={},I){nn(this,wt,void 0);nn(this,Ct,void 0);nn(this,Mt,void 0);nn(this,Yt,void 0);nn(this,xn,void 0);nn(this,Jt,void 0);nn(this,rn,void 0);qt(this,wt,[]),qt(this,Ct,void 0),qt(this,Mt,void 0),qt(this,Jt,!1),qt(this,rn,void 0),this.maxSafeDisposeCallbacks=MAX_SAFE_DISPOSE_CALLBACKS,this[_a$1]="Context",this[_b]=()=>this.toString(),qt(this,Ct,getContextName($,I)),qt(this,Mt,$.parent),qt(this,Yt,$.attributes??{}),qt(this,xn,$.onError??DEFAULT_ERROR_HANDLER)}static default(){return new un}get disposed(){return Ot(this,Jt)}get disposeCallbacksLength(){return Ot(this,wt).length}onDispose($){return Ot(this,Jt)&&(async()=>{try{await $()}catch(I){log$2.catch(I,{context:Ot(this,Ct)},{F:__dxlog_file$4,L:90,S:this,C:(j,U)=>j(...U)})}})(),Ot(this,wt).push($),Ot(this,wt).length>this.maxSafeDisposeCallbacks&&log$2.warn("Context has a large number of dispose callbacks (this might be a memory leak).",{context:Ot(this,Ct),count:Ot(this,wt).length},{F:__dxlog_file$4,L:97,S:this,C:(I,j)=>I(...j)}),()=>{const I=Ot(this,wt).indexOf($);I!==-1&&Ot(this,wt).splice(I,1)}}async dispose($=!1){if(Ot(this,rn))return Ot(this,rn);qt(this,Jt,!0);let I;const j=new Promise(Y=>{I=Y});qt(this,rn,j);const U=Array.from(Ot(this,wt)).reverse();Ot(this,wt).length=0;let q=0,G=!0;const K=[];for(const Y of U)try{await Y(),q++}catch(J){G=!1,$?K.push(J):log$2.catch(J,{context:Ot(this,Ct),callback:q,count:U.length},{F:__dxlog_file$4,L:156,S:this,C:(X,Z)=>X(...Z)})}if(K.length>0)throw new AggregateError(K);return I(G),G}raise($){if(!Ot(this,Jt))try{Ot(this,xn).call(this,$,this)}catch(I){Promise.reject(I)}}derive({onError:$,attributes:I}={}){const j=new un({onError:async q=>{if(!$)this.raise(q);else try{await $(q,this)}catch{this.raise(q)}},attributes:I}),U=this.onDispose(()=>j.dispose());return j.onDispose(U),j}getAttribute($){if($ in Ot(this,Yt))return Ot(this,Yt)[$];if(Ot(this,Mt))return Ot(this,Mt).getAttribute($)}toString(){return`Context(${Ot(this,Jt)?"disposed":"active"})`}async[(_a$1=Symbol.toStringTag,_b=export_inspect.custom,Symbol.asyncDispose)](){await this.dispose()}},wt=new WeakMap,Ct=new WeakMap,Mt=new WeakMap,Yt=new WeakMap,xn=new WeakMap,Jt=new WeakMap,rn=new WeakMap,un);Context=_ts_decorate$1([safeInstanceof("Context")],Context);var getContextName=(_,$)=>{var I;if(_.name)return _.name;if((I=$==null?void 0:$.F)!=null&&I.length){const j=$==null?void 0:$.F.split("/");return`${j[j.length-1]}#${($==null?void 0:$.L)??0}`}},LifecycleState;(function(_){_.CLOSED="CLOSED",_.OPEN="OPEN",_.ERROR="ERROR"})(LifecycleState||(LifecycleState={}));var Observable$2={};Object.defineProperty(Observable$2,"__esModule",{value:!0}),Observable$2.Observable=void 0;const hasSymbol=_=>!!Symbol[_],getSymbol=_=>hasSymbol(_)?Symbol[_]:"@@"+_,SymbolIterator=getSymbol("iterator"),SymbolObservable=getSymbol("observable"),SymbolSpecies=getSymbol("species");function getMethod(_,$){let I=_[$];if(I!=null){if(typeof I!="function")throw new TypeError(I+" is not a function");return I}}function getSpecies(_){let $=_.constructor;return $!==void 0&&($=$[SymbolSpecies],$===null&&($=void 0)),$!==void 0?$:Observable$1}function isObservable$1(_){return _ instanceof Observable$1}function hostReportError(_){hostReportError.log?hostReportError.log(_):setTimeout(()=>{throw _})}function enqueue(_){Promise.resolve().then(()=>{try{_()}catch($){hostReportError($)}})}function cleanupSubscription(_){let $=_._cleanup;if($!==void 0&&(_._cleanup=void 0,!!$))try{if(typeof $=="function")$();else{let I=getMethod($,"unsubscribe");I&&I.call($)}}catch(I){hostReportError(I)}}function closeSubscription(_){_._observer=void 0,_._queue=void 0,_._state="closed"}function flushSubscription(_){let $=_._queue;if($){_._queue=void 0,_._state="ready";for(let I=0;I<$.length&&(notifySubscription(_,$[I].type,$[I].value),_._state!=="closed");++I);}}function notifySubscription(_,$,I){_._state="running";let j=_._observer;try{let U=getMethod(j,$);switch($){case"next":U&&U.call(j,I);break;case"error":if(closeSubscription(_),U)U.call(j,I);else throw I;break;case"complete":closeSubscription(_),U&&U.call(j);break}}catch(U){hostReportError(U)}_._state==="closed"?cleanupSubscription(_):_._state==="running"&&(_._state="ready")}function onNotify(_,$,I){if(_._state!=="closed"){if(_._state==="buffering"){_._queue.push({type:$,value:I});return}if(_._state!=="ready"){_._state="buffering",_._queue=[{type:$,value:I}],enqueue(()=>flushSubscription(_));return}notifySubscription(_,$,I)}}class Subscription{constructor($,I){this._cleanup=void 0,this._observer=$,this._queue=void 0,this._state="initializing";let j=this,U={get closed(){return j._state==="closed"},next(q){onNotify(j,"next",q)},error(q){onNotify(j,"error",q)},complete(){onNotify(j,"complete")}};try{this._cleanup=I.call(void 0,U)}catch(q){U.error(q)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(closeSubscription(this),cleanupSubscription(this))}}let Observable$1=class Kn{constructor($){if(!(this instanceof Kn))throw new TypeError("Observable cannot be called as a function");if(typeof $!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=$}subscribe($){return(typeof $!="object"||$===null)&&($={next:$,error:arguments[1],complete:arguments[2]}),new Subscription($,this._subscriber)}forEach($){return new Promise((I,j)=>{if(typeof $!="function"){j(new TypeError($+" is not a function"));return}function U(){q.unsubscribe(),I()}let q=this.subscribe({next(G){try{$(G,U)}catch(K){j(K),q.unsubscribe()}},error:j,complete:I})})}map($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>this.subscribe({next(U){try{U=$(U)}catch(q){return j.error(q)}j.next(U)},error(U){j.error(U)},complete(){j.complete()}}))}filter($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>this.subscribe({next(U){try{if(!$(U))return}catch(q){return j.error(q)}j.next(U)},error(U){j.error(U)},complete(){j.complete()}}))}reduce($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this),j=arguments.length>1,U=!1,G=arguments[1];return new I(K=>this.subscribe({next(Y){let J=!U;if(U=!0,!J||j)try{G=$(G,Y)}catch(X){return K.error(X)}else G=Y},error(Y){K.error(Y)},complete(){if(!U&&!j)return K.error(new TypeError("Cannot reduce an empty sequence"));K.next(G),K.complete()}}))}async all(){let $=[];return await this.forEach(I=>$.push(I)),$}concat(...$){let I=getSpecies(this);return new I(j=>{let U,q=0;function G(K){U=K.subscribe({next(Y){j.next(Y)},error(Y){j.error(Y)},complete(){q===$.length?(U=void 0,j.complete()):G(I.from($[q++]))}})}return G(this),()=>{U&&(U.unsubscribe(),U=void 0)}})}flatMap($){if(typeof $!="function")throw new TypeError($+" is not a function");let I=getSpecies(this);return new I(j=>{let U=[],q=this.subscribe({next(K){if($)try{K=$(K)}catch(J){return j.error(J)}let Y=I.from(K).subscribe({next(J){j.next(J)},error(J){j.error(J)},complete(){let J=U.indexOf(Y);J>=0&&U.splice(J,1),G()}});U.push(Y)},error(K){j.error(K)},complete(){G()}});function G(){q.closed&&U.length===0&&j.complete()}return()=>{U.forEach(K=>K.unsubscribe()),q.unsubscribe()}})}[SymbolObservable](){return this}static from($){let I=typeof this=="function"?this:Kn;if($==null)throw new TypeError($+" is not an object");let j=getMethod($,SymbolObservable);if(j){let U=j.call($);if(Object(U)!==U)throw new TypeError(U+" is not an object");return isObservable$1(U)&&U.constructor===I?U:new I(q=>U.subscribe(q))}if(hasSymbol("iterator")&&(j=getMethod($,SymbolIterator),j))return new I(U=>{enqueue(()=>{if(!U.closed){for(let q of j.call($))if(U.next(q),U.closed)return;U.complete()}})});if(Array.isArray($))return new I(U=>{enqueue(()=>{if(!U.closed){for(let q=0;q<$.length;++q)if(U.next($[q]),U.closed)return;U.complete()}})});throw new TypeError($+" is not observable")}static of(...$){let I=typeof this=="function"?this:Kn;return new I(j=>{enqueue(()=>{if(!j.closed){for(let U=0;U<$.length;++U)if(j.next($[U]),j.closed)return;j.complete()}})})}static get[SymbolSpecies](){return this}};Observable$2.Observable=Observable$1,Object.defineProperty(Observable$1,Symbol("extensions"),{value:{symbol:SymbolObservable,hostReportError},configurable:!0});var zenObservable=Observable$2.Observable;const Observable=getDefaultExportFromCjs(zenObservable);var readableBrowser={exports:{}},events={exports:{}},R=typeof Reflect=="object"?Reflect:null,ReflectApply=R&&typeof R.apply=="function"?R.apply:function($,I,j){return Function.prototype.apply.call($,I,j)},ReflectOwnKeys;R&&typeof R.ownKeys=="function"?ReflectOwnKeys=R.ownKeys:Object.getOwnPropertySymbols?ReflectOwnKeys=function($){return Object.getOwnPropertyNames($).concat(Object.getOwnPropertySymbols($))}:ReflectOwnKeys=function($){return Object.getOwnPropertyNames($)};function ProcessEmitWarning(_){console&&console.warn&&console.warn(_)}var NumberIsNaN=Number.isNaN||function($){return $!==$};function EventEmitter$1(){EventEmitter$1.init.call(this)}events.exports=EventEmitter$1,events.exports.once=once$2,EventEmitter$1.EventEmitter=EventEmitter$1,EventEmitter$1.prototype._events=void 0,EventEmitter$1.prototype._eventsCount=0,EventEmitter$1.prototype._maxListeners=void 0;var defaultMaxListeners=10;function checkListener(_){if(typeof _!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof _)}Object.defineProperty(EventEmitter$1,"defaultMaxListeners",{enumerable:!0,get:function(){return defaultMaxListeners},set:function(_){if(typeof _!="number"||_<0||NumberIsNaN(_))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+_+".");defaultMaxListeners=_}}),EventEmitter$1.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},EventEmitter$1.prototype.setMaxListeners=function($){if(typeof $!="number"||$<0||NumberIsNaN($))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+$+".");return this._maxListeners=$,this};function _getMaxListeners(_){return _._maxListeners===void 0?EventEmitter$1.defaultMaxListeners:_._maxListeners}EventEmitter$1.prototype.getMaxListeners=function(){return _getMaxListeners(this)},EventEmitter$1.prototype.emit=function($){for(var I=[],j=1;j<arguments.length;j++)I.push(arguments[j]);var U=$==="error",q=this._events;if(q!==void 0)U=U&&q.error===void 0;else if(!U)return!1;if(U){var G;if(I.length>0&&(G=I[0]),G instanceof Error)throw G;var K=new Error("Unhandled error."+(G?" ("+G.message+")":""));throw K.context=G,K}var Y=q[$];if(Y===void 0)return!1;if(typeof Y=="function")ReflectApply(Y,this,I);else for(var J=Y.length,X=arrayClone(Y,J),j=0;j<J;++j)ReflectApply(X[j],this,I);return!0};function _addListener(_,$,I,j){var U,q,G;if(checkListener(I),q=_._events,q===void 0?(q=_._events=Object.create(null),_._eventsCount=0):(q.newListener!==void 0&&(_.emit("newListener",$,I.listener?I.listener:I),q=_._events),G=q[$]),G===void 0)G=q[$]=I,++_._eventsCount;else if(typeof G=="function"?G=q[$]=j?[I,G]:[G,I]:j?G.unshift(I):G.push(I),U=_getMaxListeners(_),U>0&&G.length>U&&!G.warned){G.warned=!0;var K=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+String($)+" listeners added. Use emitter.setMaxListeners() to increase limit");K.name="MaxListenersExceededWarning",K.emitter=_,K.type=$,K.count=G.length,ProcessEmitWarning(K)}return _}EventEmitter$1.prototype.addListener=function($,I){return _addListener(this,$,I,!1)},EventEmitter$1.prototype.on=EventEmitter$1.prototype.addListener,EventEmitter$1.prototype.prependListener=function($,I){return _addListener(this,$,I,!0)};function onceWrapper(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function _onceWrap(_,$,I){var j={fired:!1,wrapFn:void 0,target:_,type:$,listener:I},U=onceWrapper.bind(j);return U.listener=I,j.wrapFn=U,U}EventEmitter$1.prototype.once=function($,I){return checkListener(I),this.on($,_onceWrap(this,$,I)),this},EventEmitter$1.prototype.prependOnceListener=function($,I){return checkListener(I),this.prependListener($,_onceWrap(this,$,I)),this},EventEmitter$1.prototype.removeListener=function($,I){var j,U,q,G,K;if(checkListener(I),U=this._events,U===void 0)return this;if(j=U[$],j===void 0)return this;if(j===I||j.listener===I)--this._eventsCount===0?this._events=Object.create(null):(delete U[$],U.removeListener&&this.emit("removeListener",$,j.listener||I));else if(typeof j!="function"){for(q=-1,G=j.length-1;G>=0;G--)if(j[G]===I||j[G].listener===I){K=j[G].listener,q=G;break}if(q<0)return this;q===0?j.shift():spliceOne(j,q),j.length===1&&(U[$]=j[0]),U.removeListener!==void 0&&this.emit("removeListener",$,K||I)}return this},EventEmitter$1.prototype.off=EventEmitter$1.prototype.removeListener,EventEmitter$1.prototype.removeAllListeners=function($){var I,j,U;if(j=this._events,j===void 0)return this;if(j.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):j[$]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete j[$]),this;if(arguments.length===0){var q=Object.keys(j),G;for(U=0;U<q.length;++U)G=q[U],G!=="removeListener"&&this.removeAllListeners(G);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=j[$],typeof I=="function")this.removeListener($,I);else if(I!==void 0)for(U=I.length-1;U>=0;U--)this.removeListener($,I[U]);return this};function _listeners(_,$,I){var j=_._events;if(j===void 0)return[];var U=j[$];return U===void 0?[]:typeof U=="function"?I?[U.listener||U]:[U]:I?unwrapListeners(U):arrayClone(U,U.length)}EventEmitter$1.prototype.listeners=function($){return _listeners(this,$,!0)},EventEmitter$1.prototype.rawListeners=function($){return _listeners(this,$,!1)},EventEmitter$1.listenerCount=function(_,$){return typeof _.listenerCount=="function"?_.listenerCount($):listenerCount.call(_,$)},EventEmitter$1.prototype.listenerCount=listenerCount;function listenerCount(_){var $=this._events;if($!==void 0){var I=$[_];if(typeof I=="function")return 1;if(I!==void 0)return I.length}return 0}EventEmitter$1.prototype.eventNames=function(){return this._eventsCount>0?ReflectOwnKeys(this._events):[]};function arrayClone(_,$){for(var I=new Array($),j=0;j<$;++j)I[j]=_[j];return I}function spliceOne(_,$){for(;$+1<_.length;$++)_[$]=_[$+1];_.pop()}function unwrapListeners(_){for(var $=new Array(_.length),I=0;I<$.length;++I)$[I]=_[I].listener||_[I];return $}function once$2(_,$){return new Promise(function(I,j){function U(G){_.removeListener($,q),j(G)}function q(){typeof _.removeListener=="function"&&_.removeListener("error",U),I([].slice.call(arguments))}eventTargetAgnosticAddListener(_,$,q,{once:!0}),$!=="error"&&addErrorHandlerIfEventEmitter(_,U,{once:!0})})}function addErrorHandlerIfEventEmitter(_,$,I){typeof _.on=="function"&&eventTargetAgnosticAddListener(_,"error",$,I)}function eventTargetAgnosticAddListener(_,$,I,j){if(typeof _.on=="function")j.once?_.once($,I):_.on($,I);else if(typeof _.addEventListener=="function")_.addEventListener($,function U(q){j.once&&_.removeEventListener($,U),I(q)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof _)}var eventsExports=events.exports,streamBrowser=eventsExports.EventEmitter,buffer={},base64Js={};base64Js.byteLength=byteLength,base64Js.toByteArray=toByteArray,base64Js.fromByteArray=fromByteArray;for(var lookup=[],revLookup=[],Arr=typeof Uint8Array<"u"?Uint8Array:Array,code="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i$1=0,len=code.length;i$1<len;++i$1)lookup[i$1]=code[i$1],revLookup[code.charCodeAt(i$1)]=i$1;revLookup[45]=62,revLookup[95]=63;function getLens(_){var $=_.length;if($%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var I=_.indexOf("=");I===-1&&(I=$);var j=I===$?0:4-I%4;return[I,j]}function byteLength(_){var $=getLens(_),I=$[0],j=$[1];return(I+j)*3/4-j}function _byteLength(_,$,I){return($+I)*3/4-I}function toByteArray(_){var $,I=getLens(_),j=I[0],U=I[1],q=new Arr(_byteLength(_,j,U)),G=0,K=U>0?j-4:j,Y;for(Y=0;Y<K;Y+=4)$=revLookup[_.charCodeAt(Y)]<<18|revLookup[_.charCodeAt(Y+1)]<<12|revLookup[_.charCodeAt(Y+2)]<<6|revLookup[_.charCodeAt(Y+3)],q[G++]=$>>16&255,q[G++]=$>>8&255,q[G++]=$&255;return U===2&&($=revLookup[_.charCodeAt(Y)]<<2|revLookup[_.charCodeAt(Y+1)]>>4,q[G++]=$&255),U===1&&($=revLookup[_.charCodeAt(Y)]<<10|revLookup[_.charCodeAt(Y+1)]<<4|revLookup[_.charCodeAt(Y+2)]>>2,q[G++]=$>>8&255,q[G++]=$&255),q}function tripletToBase64(_){return lookup[_>>18&63]+lookup[_>>12&63]+lookup[_>>6&63]+lookup[_&63]}function encodeChunk(_,$,I){for(var j,U=[],q=$;q<I;q+=3)j=(_[q]<<16&16711680)+(_[q+1]<<8&65280)+(_[q+2]&255),U.push(tripletToBase64(j));return U.join("")}function fromByteArray(_){for(var $,I=_.length,j=I%3,U=[],q=16383,G=0,K=I-j;G<K;G+=q)U.push(encodeChunk(_,G,G+q>K?K:G+q));return j===1?($=_[I-1],U.push(lookup[$>>2]+lookup[$<<4&63]+"==")):j===2&&($=(_[I-2]<<8)+_[I-1],U.push(lookup[$>>10]+lookup[$>>4&63]+lookup[$<<2&63]+"=")),U.join("")}var ieee754={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */ieee754.read=function(_,$,I,j,U){var q,G,K=U*8-j-1,Y=(1<<K)-1,J=Y>>1,X=-7,Z=I?U-1:0,Q=I?-1:1,ee=_[$+Z];for(Z+=Q,q=ee&(1<<-X)-1,ee>>=-X,X+=K;X>0;q=q*256+_[$+Z],Z+=Q,X-=8);for(G=q&(1<<-X)-1,q>>=-X,X+=j;X>0;G=G*256+_[$+Z],Z+=Q,X-=8);if(q===0)q=1-J;else{if(q===Y)return G?NaN:(ee?-1:1)*(1/0);G=G+Math.pow(2,j),q=q-J}return(ee?-1:1)*G*Math.pow(2,q-j)},ieee754.write=function(_,$,I,j,U,q){var G,K,Y,J=q*8-U-1,X=(1<<J)-1,Z=X>>1,Q=U===23?Math.pow(2,-24)-Math.pow(2,-77):0,ee=j?0:q-1,ne=j?1:-1,ie=$<0||$===0&&1/$<0?1:0;for($=Math.abs($),isNaN($)||$===1/0?(K=isNaN($)?1:0,G=X):(G=Math.floor(Math.log($)/Math.LN2),$*(Y=Math.pow(2,-G))<1&&(G--,Y*=2),G+Z>=1?$+=Q/Y:$+=Q*Math.pow(2,1-Z),$*Y>=2&&(G++,Y/=2),G+Z>=X?(K=0,G=X):G+Z>=1?(K=($*Y-1)*Math.pow(2,U),G=G+Z):(K=$*Math.pow(2,Z-1)*Math.pow(2,U),G=0));U>=8;_[I+ee]=K&255,ee+=ne,K/=256,U-=8);for(G=G<<U|K,J+=U;J>0;_[I+ee]=G&255,ee+=ne,G/=256,J-=8);_[I+ee-ne]|=ie*128};/*!
|
|
847
847
|
* The buffer module from node.js, for the browser.
|
|
848
848
|
*
|
|
849
849
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
@@ -944,7 +944,7 @@ Event: `).concat(JSON.stringify(Q.data))),j.state;if(j.status!==InterpreterStatu
|
|
|
944
944
|
Event: `).concat(JSON.stringify(Q.data)));return j.scheduler.schedule(function(){j.forward(Q);var ee=j._nextState(Q);j.update(ee,Q)}),j._state},this.sendTo=function(X,Z,Q){var ee=j.parent&&(Z===SpecialTargets.Parent||j.parent.id===Z),ne=ee?j.parent:isString(Z)?Z===SpecialTargets.Internal?j:j.children.get(Z)||registry.get(Z):isActor$1(Z)?Z:void 0;if(!ne){if(!ee)throw new Error("Unable to send event to child '".concat(Z,"' from service '").concat(j.id,"'."));IS_PRODUCTION||warn(!1,"Service '".concat(j.id,"' has no parent: unable to send event ").concat(X.type));return}if("machine"in ne){if(j.status!==InterpreterStatus.Stopped||j.parent!==ne||j.state.done){var ie=__assign$1(__assign$1({},X),{name:X.name===error$1?"".concat(error(j.id)):X.name,origin:j.sessionId});!Q&&j.machine.config.predictableActionArguments?j._outgoingQueue.push([ne,ie]):ne.send(ie)}}else!Q&&j.machine.config.predictableActionArguments?j._outgoingQueue.push([ne,X.data]):ne.send(X.data)},this._exec=function(X,Z,Q,ee){ee===void 0&&(ee=j.machine.options.actions);var ne=X.exec||getActionFunction(X.type,ee),ie=isFunction(ne)?ne:ne?ne.exec:X.exec;if(ie)try{return ie(Z,Q.data,j.machine.config.predictableActionArguments?{action:X,_event:Q}:{action:X,state:j.state,_event:Q})}catch(Ie){throw j.parent&&j.parent.send({type:"xstate.error",data:Ie}),Ie}switch(X.type){case raise$1:{var oe=X;j.defer(oe);break}case send$1:var se=X;if(typeof se.delay=="number"){j.defer(se);return}else se.to?j.sendTo(se._event,se.to,Q===initEvent):j.send(se._event);break;case cancel$1:j.cancel(X.sendId);break;case start$1:{if(j.status!==InterpreterStatus.Running)return;var ae=X.activity;if(!j.machine.config.predictableActionArguments&&!j.state.activities[ae.id||ae.type])break;if(ae.type===ActionTypes.Invoke){var fe=toInvokeSource$1(ae.src),le=j.machine.options.services?j.machine.options.services[fe.type]:void 0,pe=ae.id,ue=ae.data;IS_PRODUCTION||warn(!("forward"in ae),"`forward` property is deprecated (found in invocation of '".concat(ae.src,"' in in machine '").concat(j.machine.id,"'). ")+"Please use `autoForward` instead.");var ve="autoForward"in ae?ae.autoForward:!!ae.forward;if(!le){IS_PRODUCTION||warn(!1,"No service found for invocation '".concat(ae.src,"' in machine '").concat(j.machine.id,"'."));return}var ge=ue?mapContext(ue,Z,Q):void 0;if(typeof le=="string")return;var be=isFunction(le)?le(Z,Q.data,{data:ge,src:fe,meta:ae.meta}):le;if(!be)return;var Re=void 0;isMachine(be)&&(be=ge?be.withContext(ge):be,Re={autoForward:ve}),j.spawn(be,pe,Re)}else j.spawnActivity(ae);break}case stop$1:{j.stopChild(X.activity.id);break}case log:var we=X,$e=we.label,Me=we.value;$e?j.logger($e,Me):j.logger(Me);break;default:IS_PRODUCTION||warn(!1,"No implementation found for action type '".concat(X.type,"'"));break}};var U=__assign$1(__assign$1({},_.defaultOptions),I),q=U.clock,G=U.logger,K=U.parent,Y=U.id,J=Y!==void 0?Y:$.id;this.id=J,this.logger=G,this.clock=q,this.parent=K,this.options=U,this.scheduler=new Scheduler({deferEvents:this.options.deferEvents}),this.sessionId=registry.bookId()}return Object.defineProperty(_.prototype,"initialState",{get:function(){var $=this;return this._initialState?this._initialState:provide(this,function(){return $._initialState=$.machine.initialState,$._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"state",{get:function(){return IS_PRODUCTION||warn(this.status!==InterpreterStatus.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),_.prototype.execute=function($,I){var j,U;try{for(var q=__values($.actions),G=q.next();!G.done;G=q.next()){var K=G.value;this.exec(K,$,I)}}catch(Y){j={error:Y}}finally{try{G&&!G.done&&(U=q.return)&&U.call(q)}finally{if(j)throw j.error}}},_.prototype.update=function($,I){var j,U,q,G,K,Y,J,X,Z=this;if($._sessionid=this.sessionId,this._state=$,(!this.machine.config.predictableActionArguments||I===initEvent)&&this.options.execute)this.execute(this.state);else for(var Q=void 0;Q=this._outgoingQueue.shift();)Q[0].send(Q[1]);if(this.children.forEach(function(be){Z.state.children[be.id]=be}),this.devTools&&this.devTools.send(I.data,$),$.event)try{for(var ee=__values(this.eventListeners),ne=ee.next();!ne.done;ne=ee.next()){var ie=ne.value;ie($.event)}}catch(be){j={error:be}}finally{try{ne&&!ne.done&&(U=ee.return)&&U.call(ee)}finally{if(j)throw j.error}}try{for(var oe=__values(this.listeners),se=oe.next();!se.done;se=oe.next()){var ie=se.value;ie($,$.event)}}catch(be){q={error:be}}finally{try{se&&!se.done&&(G=oe.return)&&G.call(oe)}finally{if(q)throw q.error}}try{for(var ae=__values(this.contextListeners),fe=ae.next();!fe.done;fe=ae.next()){var le=fe.value;le(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(be){K={error:be}}finally{try{fe&&!fe.done&&(Y=ae.return)&&Y.call(ae)}finally{if(K)throw K.error}}if(this.state.done){var pe=$.configuration.find(function(be){return be.type==="final"&&be.parent===Z.machine}),ue=pe&&pe.doneData?mapContext(pe.doneData,$.context,I):void 0;this._doneEvent=doneInvoke(this.id,ue);try{for(var ve=__values(this.doneListeners),ge=ve.next();!ge.done;ge=ve.next()){var ie=ge.value;ie(this._doneEvent)}}catch(be){J={error:be}}finally{try{ge&&!ge.done&&(X=ve.return)&&X.call(ve)}finally{if(J)throw J.error}}this._stop(),this._stopChildren(),registry.free(this.sessionId)}},_.prototype.onTransition=function($){return this.listeners.add($),this.status===InterpreterStatus.Running&&$(this.state,this.state.event),this},_.prototype.subscribe=function($,I,j){var U=this,q=toObserver($,I,j);this.listeners.add(q.next),this.status!==InterpreterStatus.NotStarted&&q.next(this.state);var G=function(){U.doneListeners.delete(G),U.stopListeners.delete(G),q.complete()};return this.status===InterpreterStatus.Stopped?q.complete():(this.onDone(G),this.onStop(G)),{unsubscribe:function(){U.listeners.delete(q.next),U.doneListeners.delete(G),U.stopListeners.delete(G)}}},_.prototype.onEvent=function($){return this.eventListeners.add($),this},_.prototype.onSend=function($){return this.sendListeners.add($),this},_.prototype.onChange=function($){return this.contextListeners.add($),this},_.prototype.onStop=function($){return this.stopListeners.add($),this},_.prototype.onDone=function($){return this.status===InterpreterStatus.Stopped&&this._doneEvent?$(this._doneEvent):this.doneListeners.add($),this},_.prototype.off=function($){return this.listeners.delete($),this.eventListeners.delete($),this.sendListeners.delete($),this.stopListeners.delete($),this.doneListeners.delete($),this.contextListeners.delete($),this},_.prototype.start=function($){var I=this;if(this.status===InterpreterStatus.Running)return this;this.machine._init(),registry.register(this.sessionId,this),this.initialized=!0,this.status=InterpreterStatus.Running;var j=$===void 0?this.initialState:provide(this,function(){return isStateConfig($)?I.machine.resolveState($):I.machine.resolveState(State$1.from($,I.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){I.update(j,initEvent)}),this},_.prototype._stopChildren=function(){this.children.forEach(function($){isFunction($.stop)&&$.stop()}),this.children.clear()},_.prototype._stop=function(){var $,I,j,U,q,G,K,Y,J,X;try{for(var Z=__values(this.listeners),Q=Z.next();!Q.done;Q=Z.next()){var ee=Q.value;this.listeners.delete(ee)}}catch(ve){$={error:ve}}finally{try{Q&&!Q.done&&(I=Z.return)&&I.call(Z)}finally{if($)throw $.error}}try{for(var ne=__values(this.stopListeners),ie=ne.next();!ie.done;ie=ne.next()){var ee=ie.value;ee(),this.stopListeners.delete(ee)}}catch(ve){j={error:ve}}finally{try{ie&&!ie.done&&(U=ne.return)&&U.call(ne)}finally{if(j)throw j.error}}try{for(var oe=__values(this.contextListeners),se=oe.next();!se.done;se=oe.next()){var ee=se.value;this.contextListeners.delete(ee)}}catch(ve){q={error:ve}}finally{try{se&&!se.done&&(G=oe.return)&&G.call(oe)}finally{if(q)throw q.error}}try{for(var ae=__values(this.doneListeners),fe=ae.next();!fe.done;fe=ae.next()){var ee=fe.value;this.doneListeners.delete(ee)}}catch(ve){K={error:ve}}finally{try{fe&&!fe.done&&(Y=ae.return)&&Y.call(ae)}finally{if(K)throw K.error}}if(!this.initialized)return this;this.initialized=!1,this.status=InterpreterStatus.Stopped,this._initialState=void 0;try{for(var le=__values(Object.keys(this.delayedEventsMap)),pe=le.next();!pe.done;pe=le.next()){var ue=pe.value;this.clock.clearTimeout(this.delayedEventsMap[ue])}}catch(ve){J={error:ve}}finally{try{pe&&!pe.done&&(X=le.return)&&X.call(le)}finally{if(J)throw J.error}}this.scheduler.clear(),this.scheduler=new Scheduler({deferEvents:this.options.deferEvents})},_.prototype.stop=function(){var $=this,I=this.scheduler;return this._stop(),I.schedule(function(){var j=toSCXMLEvent({type:"xstate.stop"}),U=provide($,function(){var q=flatten(__spreadArray([],__read$2($.state.configuration),!1).sort(function(X,Z){return Z.order-X.order}).map(function(X){return toActionObjects(X.onExit,$.machine.options.actions)})),G=__read$2(resolveActions($.machine,$.state,$.state.context,j,[{type:"exit",actions:q}],$.machine.config.predictableActionArguments?$._exec:void 0,$.machine.config.predictableActionArguments||$.machine.config.preserveActionOrder),2),K=G[0],Y=G[1],J=new State$1({value:$.state.value,context:Y,_event:j,_sessionid:$.sessionId,historyValue:void 0,history:$.state,actions:K.filter(function(X){return!isRaisableAction(X)}),activities:{},events:[],configuration:[],transitions:[],children:{},done:$.state.done,tags:$.state.tags,machine:$.machine});return J.changed=!0,J});$.update(U,j),$._stopChildren(),registry.free($.sessionId)}),this},_.prototype.batch=function($){var I=this;if(this.status===InterpreterStatus.NotStarted&&this.options.deferEvents)IS_PRODUCTION||warn(!1,"".concat($.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
|
|
945
945
|
Event: `).concat(JSON.stringify(event)));else if(this.status!==InterpreterStatus.Running)throw new Error("".concat($.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));if($.length){var j=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var U,q,G=I.state,K=!1,Y=[],J=function(ee){var ne=toSCXMLEvent(ee);I.forward(ne),G=provide(I,function(){return I.machine.transition(G,ne,void 0,j||void 0)}),Y.push.apply(Y,__spreadArray([],__read$2(I.machine.config.predictableActionArguments?G.actions:G.actions.map(function(ie){return bindActionToState(ie,G)})),!1)),K=K||!!G.changed};try{for(var X=__values($),Z=X.next();!Z.done;Z=X.next()){var Q=Z.value;J(Q)}}catch(ee){U={error:ee}}finally{try{Z&&!Z.done&&(q=X.return)&&q.call(X)}finally{if(U)throw U.error}}G.changed=K,G.actions=Y,I.update(G,toSCXMLEvent($[$.length-1]))})}},_.prototype.sender=function($){return this.send.bind(this,$)},_.prototype._nextState=function($,I){var j=this;I===void 0&&(I=!!this.machine.config.predictableActionArguments&&this._exec);var U=toSCXMLEvent($);if(U.name.indexOf(errorPlatform)===0&&!this.state.nextEvents.some(function(G){return G.indexOf(errorPlatform)===0}))throw U.data.data;var q=provide(this,function(){return j.machine.transition(j.state,U,void 0,I||void 0)});return q},_.prototype.nextState=function($){return this._nextState($,!1)},_.prototype.forward=function($){var I,j;try{for(var U=__values(this.forwardTo),q=U.next();!q.done;q=U.next()){var G=q.value,K=this.children.get(G);if(!K)throw new Error("Unable to forward event '".concat($,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(G,"'."));K.send($)}}catch(Y){I={error:Y}}finally{try{q&&!q.done&&(j=U.return)&&j.call(U)}finally{if(I)throw I.error}}},_.prototype.defer=function($){var I=this,j=this.clock.setTimeout(function(){"to"in $&&$.to?I.sendTo($._event,$.to,!0):I.send($._event)},$.delay);$.id&&(this.delayedEventsMap[$.id]=j)},_.prototype.cancel=function($){this.clock.clearTimeout(this.delayedEventsMap[$]),delete this.delayedEventsMap[$]},_.prototype.exec=function($,I,j){j===void 0&&(j=this.machine.options.actions),this._exec($,I.context,I._event,j)},_.prototype.removeChild=function($){var I;this.children.delete($),this.forwardTo.delete($),(I=this.state)===null||I===void 0||delete I.children[$]},_.prototype.stopChild=function($){var I=this.children.get($);I&&(this.removeChild($),isFunction(I.stop)&&I.stop())},_.prototype.spawn=function($,I,j){if(this.status!==InterpreterStatus.Running)return createDeferredActor($,I);if(isPromiseLike($))return this.spawnPromise(Promise.resolve($),I);if(isFunction($))return this.spawnCallback($,I);if(isSpawnedActor($))return this.spawnActor($,I);if(isObservable($))return this.spawnObservable($,I);if(isMachine($))return this.spawnMachine($,__assign$1(__assign$1({},j),{id:I}));if(isBehavior($))return this.spawnBehavior($,I);throw new Error('Unable to spawn entity "'.concat(I,'" of type "').concat(typeof $,'".'))},_.prototype.spawnMachine=function($,I){var j=this;I===void 0&&(I={});var U=new _($,__assign$1(__assign$1({},this.options),{parent:this,id:I.id||$.id})),q=__assign$1(__assign$1({},DEFAULT_SPAWN_OPTIONS),I);q.sync&&U.onTransition(function(K){j.send(update,{state:K,id:U.id})});var G=U;return this.children.set(U.id,G),q.autoForward&&this.forwardTo.add(U.id),U.onDone(function(K){j.removeChild(U.id),j.send(toSCXMLEvent(K,{origin:U.id}))}).start(),G},_.prototype.spawnBehavior=function($,I){var j=spawnBehavior($,{id:I,parent:this});return this.children.set(I,j),j},_.prototype.spawnPromise=function($,I){var j,U=this,q=!1,G;$.then(function(Y){q||(G=Y,U.removeChild(I),U.send(toSCXMLEvent(doneInvoke(I,Y),{origin:I})))},function(Y){if(!q){U.removeChild(I);var J=error(I,Y);try{U.send(toSCXMLEvent(J,{origin:I}))}catch(X){reportUnhandledExceptionOnInvocation(Y,X,I),U.devTools&&U.devTools.send(J,U.state),U.machine.strict&&U.stop()}}});var K=(j={id:I,send:function(){},subscribe:function(Y,J,X){var Z=toObserver(Y,J,X),Q=!1;return $.then(function(ee){Q||(Z.next(ee),!Q&&Z.complete())},function(ee){Q||Z.error(ee)}),{unsubscribe:function(){return Q=!0}}},stop:function(){q=!0},toJSON:function(){return{id:I}},getSnapshot:function(){return G}},j[symbolObservable]=function(){return this},j);return this.children.set(I,K),K},_.prototype.spawnCallback=function($,I){var j,U=this,q=!1,G=new Set,K=new Set,Y,J=function(Q){Y=Q,K.forEach(function(ee){return ee(Q)}),!q&&U.send(toSCXMLEvent(Q,{origin:I}))},X;try{X=$(J,function(Q){G.add(Q)})}catch(Q){this.send(error(I,Q))}if(isPromiseLike(X))return this.spawnPromise(X,I);var Z=(j={id:I,send:function(Q){return G.forEach(function(ee){return ee(Q)})},subscribe:function(Q){var ee=toObserver(Q);return K.add(ee.next),{unsubscribe:function(){K.delete(ee.next)}}},stop:function(){q=!0,isFunction(X)&&X()},toJSON:function(){return{id:I}},getSnapshot:function(){return Y}},j[symbolObservable]=function(){return this},j);return this.children.set(I,Z),Z},_.prototype.spawnObservable=function($,I){var j,U=this,q,G=$.subscribe(function(Y){q=Y,U.send(toSCXMLEvent(Y,{origin:I}))},function(Y){U.removeChild(I),U.send(toSCXMLEvent(error(I,Y),{origin:I}))},function(){U.removeChild(I),U.send(toSCXMLEvent(doneInvoke(I),{origin:I}))}),K=(j={id:I,send:function(){},subscribe:function(Y,J,X){return $.subscribe(Y,J,X)},stop:function(){return G.unsubscribe()},getSnapshot:function(){return q},toJSON:function(){return{id:I}}},j[symbolObservable]=function(){return this},j);return this.children.set(I,K),K},_.prototype.spawnActor=function($,I){return this.children.set(I,$),$},_.prototype.spawnActivity=function($){var I=this.machine.options&&this.machine.options.activities?this.machine.options.activities[$.type]:void 0;if(!I){IS_PRODUCTION||warn(!1,"No implementation found for activity '".concat($.type,"'"));return}var j=I(this.state.context,$);this.spawnEffect($.id,j)},_.prototype.spawnEffect=function($,I){var j;this.children.set($,(j={id:$,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:I||void 0,getSnapshot:function(){},toJSON:function(){return{id:$}}},j[symbolObservable]=function(){return this},j))},_.prototype.attachDev=function(){var $=getGlobal();if(this.options.devTools&&$){if($.__REDUX_DEVTOOLS_EXTENSION__){var I=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=$.__REDUX_DEVTOOLS_EXTENSION__.connect(__assign$1(__assign$1({name:this.id,autoPause:!0,stateSanitizer:function(j){return{value:j.value,context:j.context,actions:j.actions}}},I),{features:__assign$1({jump:!1,skip:!1},I?I.features:void 0)}),this.machine),this.devTools.init(this.state)}registerService(this)}},_.prototype.toJSON=function(){return{id:this.id}},_.prototype[symbolObservable]=function(){return this},_.prototype.getSnapshot=function(){return this.status===InterpreterStatus.NotStarted?this.initialState:this._state},_.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function($,I){return setTimeout($,I)},clearTimeout:function($){return clearTimeout($)}},logger:console.log.bind(console),devTools:!1},_.interpret=interpret,_}();function interpret(_,$){var I=new Interpreter(_,$);return I}function toInvokeSource(_){if(typeof _=="string"){var $={type:_};return $.toString=function(){return _},$}return _}function toInvokeDefinition(_){return __assign$1(__assign$1({type:invoke},_),{toJSON:function(){_.onDone,_.onError;var $=__rest$1(_,["onDone","onError"]);return __assign$1(__assign$1({},$),{type:invoke,src:toInvokeSource(_.src)})}})}var NULL_EVENT="",STATE_IDENTIFIER="#",WILDCARD="*",EMPTY_OBJECT={},isStateId=function(_){return _[0]===STATE_IDENTIFIER},createDefaultOptions=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},validateArrayifiedTransitions=function(_,$,I){var j=I.slice(0,-1).some(function(q){return!("cond"in q)&&!("in"in q)&&(isString(q.target)||isMachine(q.target))}),U=$===NULL_EVENT?"the transient event":"event '".concat($,"'");warn(!j,"One or more transitions for ".concat(U," on state '").concat(_.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},StateNode=function(){function _($,I,j,U){j===void 0&&(j="context"in $?$.context:void 0);var q=this,G;this.config=$,this._context=j,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(createDefaultOptions(),I),this.parent=U==null?void 0:U.parent,this.key=this.config.key||(U==null?void 0:U.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:STATE_DELIMITER),this.id=this.config.id||__spreadArray([this.machine.key],__read$2(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(G=this.config.schema)!==null&&G!==void 0?G:{},this.description=this.config.description,IS_PRODUCTION||warn(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?mapValues(this.config.states,function(J,X){var Z,Q=new _(J,{},void 0,{parent:q,key:X});return Object.assign(q.idMap,__assign$1((Z={},Z[Q.id]=Q,Z),Q.idMap)),Q}):EMPTY_OBJECT;var K=0;function Y(J){var X,Z;J.order=K++;try{for(var Q=__values(getAllChildren(J)),ee=Q.next();!ee.done;ee=Q.next()){var ne=ee.value;Y(ne)}}catch(ie){X={error:ie}}finally{try{ee&&!ee.done&&(Z=Q.return)&&Z.call(Q)}finally{if(X)throw X.error}}}Y(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(J){var X=J.event;return X===NULL_EVENT}):NULL_EVENT in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=toArray(this.config.entry||this.config.onEntry).map(function(J){return toActionObject(J)}),this.onExit=toArray(this.config.exit||this.config.onExit).map(function(J){return toActionObject(J)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=toArray(this.config.invoke).map(function(J,X){var Z,Q;if(isMachine(J)){var ee=createInvokeId(q.id,X);return q.machine.options.services=__assign$1((Z={},Z[ee]=J,Z),q.machine.options.services),toInvokeDefinition({src:ee,id:ee})}else if(isString(J.src)){var ee=J.id||createInvokeId(q.id,X);return toInvokeDefinition(__assign$1(__assign$1({},J),{id:ee,src:J.src}))}else if(isMachine(J.src)||isFunction(J.src)){var ee=J.id||createInvokeId(q.id,X);return q.machine.options.services=__assign$1((Q={},Q[ee]=J.src,Q),q.machine.options.services),toInvokeDefinition(__assign$1(__assign$1({id:ee},J),{src:ee}))}else{var ne=J.src;return toInvokeDefinition(__assign$1(__assign$1({id:createInvokeId(q.id,X)},J),{src:ne}))}}),this.activities=toArray(this.config.activities).concat(this.invoke).map(function(J){return toActivityDefinition(J)}),this.transition=this.transition.bind(this),this.tags=toArray(this.config.tags)}return _.prototype._init=function(){this.__cache.transitions||getAllStateNodes(this).forEach(function($){return $.on})},_.prototype.withConfig=function($,I){var j=this.options,U=j.actions,q=j.activities,G=j.guards,K=j.services,Y=j.delays;return new _(this.config,{actions:__assign$1(__assign$1({},U),$.actions),activities:__assign$1(__assign$1({},q),$.activities),guards:__assign$1(__assign$1({},G),$.guards),services:__assign$1(__assign$1({},K),$.services),delays:__assign$1(__assign$1({},Y),$.delays)},I??this.context)},_.prototype.withContext=function($){return new _(this.config,this.options,$)},Object.defineProperty(_.prototype,"context",{get:function(){return isFunction(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:mapValues(this.states,function($){return $.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),_.prototype.toJSON=function(){return this.definition},Object.defineProperty(_.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var $=this.transitions;return this.__cache.on=$.reduce(function(I,j){return I[j.eventType]=I[j.eventType]||[],I[j.eventType].push(j),I},{})},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),_.prototype.getCandidates=function($){if(this.__cache.candidates[$])return this.__cache.candidates[$];var I=$===NULL_EVENT,j=this.transitions.filter(function(U){var q=U.eventType===$;return I?q:q||U.eventType===WILDCARD});return this.__cache.candidates[$]=j,j},_.prototype.getDelayedTransitions=function(){var $=this,I=this.config.after;if(!I)return[];var j=function(q,G){var K=isFunction(q)?"".concat($.id,":delay[").concat(G,"]"):q,Y=after(K,$.id);return $.onEntry.push(send(Y,{delay:q})),$.onExit.push(cancel(Y)),Y},U=isArray(I)?I.map(function(q,G){var K=j(q.delay,G);return __assign$1(__assign$1({},q),{event:K})}):flatten(Object.keys(I).map(function(q,G){var K=I[q],Y=isString(K)?{target:K}:K,J=isNaN(+q)?q:+q,X=j(J,G);return toArray(Y).map(function(Z){return __assign$1(__assign$1({},Z),{event:X,delay:J})})}));return U.map(function(q){var G=q.delay;return __assign$1(__assign$1({},$.formatTransition(q)),{delay:G})})},_.prototype.getStateNodes=function($){var I,j=this;if(!$)return[];var U=$ instanceof State$1?$.value:toStateValue($,this.delimiter);if(isString(U)){var q=this.getStateNode(U).initial;return q!==void 0?this.getStateNodes((I={},I[U]=q,I)):[this,this.states[U]]}var G=Object.keys(U),K=[this];return K.push.apply(K,__spreadArray([],__read$2(flatten(G.map(function(Y){return j.getStateNode(Y).getStateNodes(U[Y])}))),!1)),K},_.prototype.handles=function($){var I=getEventType($);return this.events.includes(I)},_.prototype.resolveState=function($){var I=$ instanceof State$1?$:State$1.create($),j=Array.from(getConfiguration([],this.getStateNodes(I.value)));return new State$1(__assign$1(__assign$1({},I),{value:this.resolve(I.value),configuration:j,done:isInFinalState(j,this),tags:getTagsFromConfiguration(j),machine:this.machine}))},_.prototype.transitionLeafNode=function($,I,j){var U=this.getStateNode($),q=U.next(I,j);return!q||!q.transitions.length?this.next(I,j):q},_.prototype.transitionCompoundNode=function($,I,j){var U=Object.keys($),q=this.getStateNode(U[0]),G=q._transition($[U[0]],I,j);return!G||!G.transitions.length?this.next(I,j):G},_.prototype.transitionParallelNode=function($,I,j){var U,q,G={};try{for(var K=__values(Object.keys($)),Y=K.next();!Y.done;Y=K.next()){var J=Y.value,X=$[J];if(X){var Z=this.getStateNode(J),Q=Z._transition(X,I,j);Q&&(G[J]=Q)}}}catch(se){U={error:se}}finally{try{Y&&!Y.done&&(q=K.return)&&q.call(K)}finally{if(U)throw U.error}}var ee=Object.keys(G).map(function(se){return G[se]}),ne=flatten(ee.map(function(se){return se.transitions})),ie=ee.some(function(se){return se.transitions.length>0});if(!ie)return this.next(I,j);var oe=flatten(Object.keys(G).map(function(se){return G[se].configuration}));return{transitions:ne,exitSet:flatten(ee.map(function(se){return se.exitSet})),configuration:oe,source:I,actions:flatten(Object.keys(G).map(function(se){return G[se].actions}))}},_.prototype._transition=function($,I,j){return isString($)?this.transitionLeafNode($,I,j):Object.keys($).length===1?this.transitionCompoundNode($,I,j):this.transitionParallelNode($,I,j)},_.prototype.getTransitionData=function($,I){return this._transition($.value,$,toSCXMLEvent(I))},_.prototype.next=function($,I){var j,U,q=this,G=I.name,K=[],Y=[],J;try{for(var X=__values(this.getCandidates(G)),Z=X.next();!Z.done;Z=X.next()){var Q=Z.value,ee=Q.cond,ne=Q.in,ie=$.context,oe=ne?isString(ne)&&isStateId(ne)?$.matches(toStateValue(this.getStateNodeById(ne).path,this.delimiter)):matchesState(toStateValue(ne,this.delimiter),path$1(this.path.slice(0,-2))($.value)):!0,se=!1;try{se=!ee||evaluateGuard(this.machine,ee,ie,I,$)}catch(le){throw new Error("Unable to evaluate guard '".concat(ee.name||ee.type,"' in transition for event '").concat(G,"' in state node '").concat(this.id,`':
|
|
946
946
|
`).concat(le.message))}if(se&&oe){Q.target!==void 0&&(Y=Q.target),K.push.apply(K,__spreadArray([],__read$2(Q.actions),!1)),J=Q;break}}}catch(le){j={error:le}}finally{try{Z&&!Z.done&&(U=X.return)&&U.call(X)}finally{if(j)throw j.error}}if(J){if(!Y.length)return{transitions:[J],exitSet:[],configuration:$.value?[this]:[],source:$,actions:K};var ae=flatten(Y.map(function(le){return q.getRelativeStateNodes(le,$.historyValue)})),fe=!!J.internal;return{transitions:[J],exitSet:fe?[]:flatten(Y.map(function(le){return q.getPotentiallyReenteringNodes(le)})),configuration:ae,source:$,actions:K}}},_.prototype.getPotentiallyReenteringNodes=function($){if(this.order<$.order)return[this];for(var I=[],j=this,U=$;j&&j!==U;)I.push(j),j=j.parent;return j!==U?[]:(I.push(U),I)},_.prototype.getActions=function($,I,j,U,q,G,K){var Y,J,X,Z,Q=this,ee=G?getConfiguration([],this.getStateNodes(G.value)):[],ne=new Set;try{for(var ie=__values(Array.from($).sort(function(we,$e){return we.order-$e.order})),oe=ie.next();!oe.done;oe=ie.next()){var se=oe.value;(!has(ee,se)||has(j.exitSet,se)||se.parent&&ne.has(se.parent))&&ne.add(se)}}catch(we){Y={error:we}}finally{try{oe&&!oe.done&&(J=ie.return)&&J.call(ie)}finally{if(Y)throw Y.error}}try{for(var ae=__values(ee),fe=ae.next();!fe.done;fe=ae.next()){var se=fe.value;(!has($,se)||has(j.exitSet,se.parent))&&j.exitSet.push(se)}}catch(we){X={error:we}}finally{try{fe&&!fe.done&&(Z=ae.return)&&Z.call(ae)}finally{if(X)throw X.error}}j.exitSet.sort(function(we,$e){return $e.order-we.order});var le=Array.from(ne).sort(function(we,$e){return we.order-$e.order}),pe=new Set(j.exitSet),ue=flatten(le.map(function(we){var $e=[];if(we.type!=="final")return $e;var Me=we.parent;if(!Me.parent)return $e;$e.push(done(we.id,we.doneData),done(Me.id,we.doneData?mapContext(we.doneData,U,q):void 0));var Ie=Me.parent;return Ie.type==="parallel"&&getChildren(Ie).every(function(Be){return isInFinalState(j.configuration,Be)})&&$e.push(done(Ie.id)),$e})),ve=le.map(function(we){var $e=we.onEntry,Me=we.activities.map(function(Ie){return start(Ie)});return{type:"entry",actions:toActionObjects(K?__spreadArray(__spreadArray([],__read$2($e),!1),__read$2(Me),!1):__spreadArray(__spreadArray([],__read$2(Me),!1),__read$2($e),!1),Q.machine.options.actions)}}).concat({type:"state_done",actions:ue.map(function(we){return raise(we)})}),ge=Array.from(pe).map(function(we){return{type:"exit",actions:toActionObjects(__spreadArray(__spreadArray([],__read$2(we.onExit),!1),__read$2(we.activities.map(function($e){return stop($e)})),!1),Q.machine.options.actions)}}),be=ge.concat({type:"transition",actions:toActionObjects(j.actions,this.machine.options.actions)}).concat(ve);if(I){var Re=toActionObjects(flatten(__spreadArray([],__read$2($),!1).sort(function(we,$e){return $e.order-we.order}).map(function(we){return we.onExit})),this.machine.options.actions).filter(function(we){return!isRaisableAction(we)});return be.concat({type:"stop",actions:Re})}return be},_.prototype.transition=function($,I,j,U){$===void 0&&($=this.initialState);var q=toSCXMLEvent(I),G;if($ instanceof State$1)G=j===void 0?$:this.resolveState(State$1.from($,j));else{var K=isString($)?this.resolve(pathToStateValue(this.getResolvedPath($))):this.resolve($),Y=j??this.machine.context;G=this.resolveState(State$1.from(K,Y))}if(!IS_PRODUCTION&&q.name===WILDCARD)throw new Error("An event cannot have the wildcard type ('".concat(WILDCARD,"')"));if(this.strict&&!this.events.includes(q.name)&&!isBuiltInEvent(q.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(q.name,"'"));var J=this._transition(G.value,G,q)||{transitions:[],configuration:[],exitSet:[],source:G,actions:[]},X=getConfiguration([],this.getStateNodes(G.value)),Z=J.configuration.length?getConfiguration(X,J.configuration):X;return J.configuration=__spreadArray([],__read$2(Z),!1),this.resolveTransition(J,G,G.context,U,q)},_.prototype.resolveRaisedTransition=function($,I,j,U){var q,G=$.actions;return $=this.transition($,I,void 0,U),$._event=j,$.event=j.data,(q=$.actions).unshift.apply(q,__spreadArray([],__read$2(G),!1)),$},_.prototype.resolveTransition=function($,I,j,U,q){var G,K,Y,J,X=this;q===void 0&&(q=initEvent);var Z=$.configuration,Q=!I||$.transitions.length>0,ee=Q?$.configuration:I?I.configuration:[],ne=isInFinalState(ee,this),ie=Q?getValue(this.machine,Z):void 0,oe=I?I.historyValue?I.historyValue:$.source?this.machine.historyValue(I.value):void 0:void 0,se=this.getActions(new Set(ee),ne,$,j,q,I,U),ae=I?__assign$1({},I.activities):{};try{for(var fe=__values(se),le=fe.next();!le.done;le=fe.next()){var pe=le.value;try{for(var ue=(Y=void 0,__values(pe.actions)),ve=ue.next();!ve.done;ve=ue.next()){var ge=ve.value;ge.type===start$1?ae[ge.activity.id||ge.activity.type]=ge:ge.type===stop$1&&(ae[ge.activity.id||ge.activity.type]=!1)}}catch(He){Y={error:He}}finally{try{ve&&!ve.done&&(J=ue.return)&&J.call(ue)}finally{if(Y)throw Y.error}}}}catch(He){G={error:He}}finally{try{le&&!le.done&&(K=fe.return)&&K.call(fe)}finally{if(G)throw G.error}}var be=__read$2(resolveActions(this,I,j,q,se,U,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),Re=be[0],we=be[1],$e=__read$2(partition(Re,isRaisableAction),2),Me=$e[0],Ie=$e[1],Be=Re.filter(function(He){var tt;return He.type===start$1&&((tt=He.activity)===null||tt===void 0?void 0:tt.type)===invoke}),We=Be.reduce(function(He,tt){return He[tt.activity.id]=createInvocableActor(tt.activity,X.machine,we,q),He},I?__assign$1({},I.children):{}),Ke=new State$1({value:ie||I.value,context:we,_event:q,_sessionid:I?I._sessionid:null,historyValue:ie?oe?updateHistoryValue(oe,ie):void 0:I?I.historyValue:void 0,history:!ie||$.source?I:void 0,actions:ie?Ie:[],activities:ie?ae:I?I.activities:{},events:[],configuration:ee,transitions:$.transitions,children:We,done:ne,tags:getTagsFromConfiguration(ee),machine:this}),Je=j!==we;Ke.changed=q.name===update||Je;var qe=Ke.history;qe&&delete qe.history;var Ze=!ne&&(this._transient||Z.some(function(He){return He._transient}));if(!Q&&(!Ze||q.name===NULL_EVENT))return Ke;var Ge=Ke;if(!ne)for(Ze&&(Ge=this.resolveRaisedTransition(Ge,{type:nullEvent},q,U));Me.length;){var Ne=Me.shift();Ge=this.resolveRaisedTransition(Ge,Ne._event,q,U)}var De=Ge.changed||(qe?!!Ge.actions.length||Je||typeof qe.value!=typeof Ge.value||!stateValuesEqual(Ge.value,qe.value):void 0);return Ge.changed=De,Ge.history=qe,Ge},_.prototype.getStateNode=function($){if(isStateId($))return this.machine.getStateNodeById($);if(!this.states)throw new Error("Unable to retrieve child state '".concat($,"' from '").concat(this.id,"'; no child states exist."));var I=this.states[$];if(!I)throw new Error("Child state '".concat($,"' does not exist on '").concat(this.id,"'"));return I},_.prototype.getStateNodeById=function($){var I=isStateId($)?$.slice(STATE_IDENTIFIER.length):$;if(I===this.id)return this;var j=this.machine.idMap[I];if(!j)throw new Error("Child state node '#".concat(I,"' does not exist on machine '").concat(this.id,"'"));return j},_.prototype.getStateNodeByPath=function($){if(typeof $=="string"&&isStateId($))try{return this.getStateNodeById($.slice(1))}catch{}for(var I=toStatePath($,this.delimiter).slice(),j=this;I.length;){var U=I.shift();if(!U.length)break;j=j.getStateNode(U)}return j},_.prototype.resolve=function($){var I,j=this;if(!$)return this.initialStateValue||EMPTY_OBJECT;switch(this.type){case"parallel":return mapValues(this.initialStateValue,function(q,G){return q?j.getStateNode(G).resolve($[G]||q):EMPTY_OBJECT});case"compound":if(isString($)){var U=this.getStateNode($);return U.type==="parallel"||U.type==="compound"?(I={},I[$]=U.initialStateValue,I):$}return Object.keys($).length?mapValues($,function(q,G){return q?j.getStateNode(G).resolve(q):EMPTY_OBJECT}):this.initialStateValue||{};default:return $||EMPTY_OBJECT}},_.prototype.getResolvedPath=function($){if(isStateId($)){var I=this.machine.idMap[$.slice(STATE_IDENTIFIER.length)];if(!I)throw new Error("Unable to find state node '".concat($,"'"));return I.path}return toStatePath($,this.delimiter)},Object.defineProperty(_.prototype,"initialStateValue",{get:function(){var $;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var I;if(this.type==="parallel")I=mapFilterValues(this.states,function(j){return j.initialStateValue||EMPTY_OBJECT},function(j){return j.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));I=isLeafNode(this.states[this.initial])?this.initial:($={},$[this.initial]=this.states[this.initial].initialStateValue,$)}else I={};return this.__cache.initialStateValue=I,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),_.prototype.getInitialState=function($,I){this._init();var j=this.getStateNodes($);return this.resolveTransition({configuration:j,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,I??this.machine.context,void 0)},Object.defineProperty(_.prototype,"initialState",{get:function(){var $=this.initialStateValue;if(!$)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState($)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"target",{get:function(){var $;if(this.type==="history"){var I=this.config;isString(I.target)?$=isStateId(I.target)?pathToStateValue(this.machine.getStateNodeById(I.target).path.slice(this.path.length-1)):I.target:$=I.target}return $},enumerable:!1,configurable:!0}),_.prototype.getRelativeStateNodes=function($,I,j){return j===void 0&&(j=!0),j?$.type==="history"?$.resolveHistory(I):$.initialStateNodes:[$]},Object.defineProperty(_.prototype,"initialStateNodes",{get:function(){var $=this;if(isLeafNode(this))return[this];if(this.type==="compound"&&!this.initial)return IS_PRODUCTION||warn(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var I=toStatePaths(this.initialStateValue);return flatten(I.map(function(j){return $.getFromRelativePath(j)}))},enumerable:!1,configurable:!0}),_.prototype.getFromRelativePath=function($){if(!$.length)return[this];var I=__read$2($),j=I[0],U=I.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(j,"' from node with no states"));var q=this.getStateNode(j);if(q.type==="history")return q.resolveHistory();if(!this.states[j])throw new Error("Child state '".concat(j,"' does not exist on '").concat(this.id,"'"));return this.states[j].getFromRelativePath(U)},_.prototype.historyValue=function($){if(Object.keys(this.states).length)return{current:$||this.initialStateValue,states:mapFilterValues(this.states,function(I,j){if(!$)return I.historyValue();var U=isString($)?void 0:$[j];return I.historyValue(U||I.initialStateValue)},function(I){return!I.history})}},_.prototype.resolveHistory=function($){var I=this;if(this.type!=="history")return[this];var j=this.parent;if(!$){var U=this.target;return U?flatten(toStatePaths(U).map(function(G){return j.getFromRelativePath(G)})):j.initialStateNodes}var q=nestedPath(j.path,"states")($).current;return isString(q)?[j.getStateNode(q)]:flatten(toStatePaths(q).map(function(G){return I.history==="deep"?j.getFromRelativePath(G):[j.states[G[0]]]}))},Object.defineProperty(_.prototype,"stateIds",{get:function(){var $=this,I=flatten(Object.keys(this.states).map(function(j){return $.states[j].stateIds}));return[this.id].concat(I)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"events",{get:function(){var $,I,j,U;if(this.__cache.events)return this.__cache.events;var q=this.states,G=new Set(this.ownEvents);if(q)try{for(var K=__values(Object.keys(q)),Y=K.next();!Y.done;Y=K.next()){var J=Y.value,X=q[J];if(X.states)try{for(var Z=(j=void 0,__values(X.events)),Q=Z.next();!Q.done;Q=Z.next()){var ee=Q.value;G.add("".concat(ee))}}catch(ne){j={error:ne}}finally{try{Q&&!Q.done&&(U=Z.return)&&U.call(Z)}finally{if(j)throw j.error}}}}catch(ne){$={error:ne}}finally{try{Y&&!Y.done&&(I=K.return)&&I.call(K)}finally{if($)throw $.error}}return this.__cache.events=Array.from(G)},enumerable:!1,configurable:!0}),Object.defineProperty(_.prototype,"ownEvents",{get:function(){var $=new Set(this.transitions.filter(function(I){return!(!I.target&&!I.actions.length&&I.internal)}).map(function(I){return I.eventType}));return Array.from($)},enumerable:!1,configurable:!0}),_.prototype.resolveTarget=function($){var I=this;if($!==void 0)return $.map(function(j){if(!isString(j))return j;var U=j[0]===I.delimiter;if(U&&!I.parent)return I.getStateNodeByPath(j.slice(1));var q=U?I.key+j:j;if(I.parent)try{var G=I.parent.getStateNodeByPath(q);return G}catch(K){throw new Error("Invalid transition definition for state node '".concat(I.id,`':
|
|
947
|
-
`).concat(K.message))}else return I.getStateNodeByPath(q)})},_.prototype.formatTransition=function($){var I=this,j=normalizeTarget($.target),U="internal"in $?$.internal:j?j.some(function(Y){return isString(Y)&&Y[0]===I.delimiter}):!0,q=this.machine.options.guards,G=this.resolveTarget(j),K=__assign$1(__assign$1({},$),{actions:toActionObjects(toArray($.actions)),cond:toGuard($.cond,q),target:G,source:this,internal:U,eventType:$.event,toJSON:function(){return __assign$1(__assign$1({},K),{target:K.target?K.target.map(function(Y){return"#".concat(Y.id)}):void 0,source:"#".concat(I.id)})}});return K},_.prototype.formatTransitions=function(){var $,I,j=this,U;if(!this.config.on)U=[];else if(Array.isArray(this.config.on))U=this.config.on;else{var q=this.config.on,G=WILDCARD,K=q[G],Y=K===void 0?[]:K,J=__rest$1(q,[typeof G=="symbol"?G:G+""]);U=flatten(Object.keys(J).map(function(ae){!IS_PRODUCTION&&ae===NULL_EVENT&&warn(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(j.id,'".'));var fe=toTransitionConfigArray(ae,J[ae]);return IS_PRODUCTION||validateArrayifiedTransitions(j,ae,fe),fe}).concat(toTransitionConfigArray(WILDCARD,Y)))}var X=this.config.always?toTransitionConfigArray("",this.config.always):[],Z=this.config.onDone?toTransitionConfigArray(String(done(this.id)),this.config.onDone):[];IS_PRODUCTION||warn(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var Q=flatten(this.invoke.map(function(ae){var fe=[];return ae.onDone&&fe.push.apply(fe,__spreadArray([],__read$2(toTransitionConfigArray(String(doneInvoke(ae.id)),ae.onDone)),!1)),ae.onError&&fe.push.apply(fe,__spreadArray([],__read$2(toTransitionConfigArray(String(error(ae.id)),ae.onError)),!1)),fe})),ee=this.after,ne=flatten(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],__read$2(Z),!1),__read$2(Q),!1),__read$2(U),!1),__read$2(X),!1).map(function(ae){return toArray(ae).map(function(fe){return j.formatTransition(fe)})}));try{for(var ie=__values(ee),oe=ie.next();!oe.done;oe=ie.next()){var se=oe.value;ne.push(se)}}catch(ae){$={error:ae}}finally{try{oe&&!oe.done&&(I=ie.return)&&I.call(ie)}finally{if($)throw $.error}}return ne},_}(),warned=!1;function createMachine(_,$){return!IS_PRODUCTION&&!("predictableActionArguments"in _)&&!warned&&(warned=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new StateNode(_,$)}var assign=assign$1,index=React.useLayoutEffect;function useConstant(_){var $=React__namespace.useRef();return $.current||($.current={v:_()}),$.current.v}var __assign=function(){return __assign=Object.assign||function(_){for(var $,I=1,j=arguments.length;I<j;I++){$=arguments[I];for(var U in $)Object.prototype.hasOwnProperty.call($,U)&&(_[U]=$[U])}return _},__assign.apply(this,arguments)},__rest=function(_,$){var I={};for(var j in _)Object.prototype.hasOwnProperty.call(_,j)&&$.indexOf(j)<0&&(I[j]=_[j]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var U=0,j=Object.getOwnPropertySymbols(_);U<j.length;U++)$.indexOf(j[U])<0&&Object.prototype.propertyIsEnumerable.call(_,j[U])&&(I[j[U]]=_[j[U]]);return I},__read$1=function(_,$){var I=typeof Symbol=="function"&&_[Symbol.iterator];if(!I)return _;var j=I.call(_),U,q=[],G;try{for(;($===void 0||$-- >0)&&!(U=j.next()).done;)q.push(U.value)}catch(K){G={error:K}}finally{try{U&&!U.done&&(I=j.return)&&I.call(j)}finally{if(G)throw G.error}}return q};function useIdleInterpreter(_,$){var I=useConstant(function(){return typeof _=="function"?_():_});if(process.env.NODE_ENV!=="production"&&typeof _!="function"){var j=__read$1(React.useState(I),1),U=j[0];_!==U&&console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.")}var q=$.context,G=$.guards,K=$.actions,Y=$.activities,J=$.services,X=$.delays;$.state;var Z=__rest($,["context","guards","actions","activities","services","delays","state"]),Q=useConstant(function(){var ee={context:q,guards:G,actions:K,activities:Y,services:J,delays:X},ne=I.withConfig(ee,function(){return __assign(__assign({},I.context),q)});return interpret(ne,Z)});return index(function(){Object.assign(Q.machine.options.actions,K),Object.assign(Q.machine.options.guards,G),Object.assign(Q.machine.options.activities,Y),Object.assign(Q.machine.options.services,J),Object.assign(Q.machine.options.delays,X)},[K,G,Y,J,X]),Q}function isInterpreterStateEqual(_,$,I){if(_.status===InterpreterStatus.NotStarted)return!0;var j=I.changed===void 0&&(Object.keys(I.children).length>0||typeof $.changed=="boolean");return!(I.changed||j)}var __read=function(_,$){var I=typeof Symbol=="function"&&_[Symbol.iterator];if(!I)return _;var j=I.call(_),U,q=[],G;try{for(;($===void 0||$-- >0)&&!(U=j.next()).done;)q.push(U.value)}catch(K){G={error:K}}finally{try{U&&!U.done&&(I=j.return)&&I.call(j)}finally{if(G)throw G.error}}return q};function identity(_){return _}function useMachine(_){for(var $=[],I=1;I<arguments.length;I++)$[I-1]=arguments[I];var j=__read($,1),U=j[0],q=U===void 0?{}:U,G=useIdleInterpreter(_,q),K=React.useCallback(function(){return G.status===InterpreterStatus.NotStarted?q.state?State$1.create(q.state):G.machine.initialState:G.getSnapshot()},[G]),Y=React.useCallback(function(Z,Q){return isInterpreterStateEqual(G,Z,Q)},[G]),J=React.useCallback(function(Z){var Q=G.subscribe(Z).unsubscribe;return Q},[G]),X=withSelectorExports.useSyncExternalStoreWithSelector(J,K,K,identity,Y);return React.useEffect(function(){var Z=q.state;return G.start(Z?State$1.create(Z):void 0),function(){G.stop(),G.status=InterpreterStatus.NotStarted}},[]),[X,G.send,G]}const identityMachine=createMachine({id:"identity",predictableActionArguments:!0,context:{identity:null,identitySubscribable:null},initial:"choosingAction",invoke:{src:_=>_.identitySubscribable},states:{unknown:{always:[{cond:"initiallyManagingDeviceInvitation",target:"managingDeviceInvitation",actions:"log"},{target:"choosingAction",actions:"log"}]},choosingAction:{},managingDeviceInvitation:{},confirmingResetStorage:{},confirmingJoinNewIdentity:{}},on:{unchooseAction:{target:".choosingAction",actions:["unsetInvitation","log"]},deselectInvitation:{target:".choosingAction",actions:["unsetInvitation","log"]},selectInvitation:{target:".managingDeviceInvitation",actions:["setInvitation","log"]},chooseJoinNewIdentity:{target:".confirmingJoinNewIdentity",actions:"log"},chooseResetStorage:{target:".confirmingResetStorage",actions:"log"}}},{guards:{initiallyManagingDeviceInvitation:({initialDisposition:_},$)=>_==="manage-device-invitation"},actions:{setIdentity:assign({identity:(_,$)=>($==null?void 0:$.identity)??null}),setInvitation:assign({invitation:(_,$)=>($==null?void 0:$.invitation)??null}),unsetInvitation:assign({invitation:()=>{}}),log:(_,$)=>{log$2("[transition]",{event:$,context:_})}}}),useIdentityMachine=(_,$)=>useMachine(identityMachine,{...$,context:{...$==null?void 0:$.context,identity:_.halo.identity.get(),identitySubscribable:_.halo.identity.map(I=>({type:"setIdentity",identity:I}))}}),IdentityActionChooser=_=>{const{send:$}=_,I=reactClient.useClient(),j=halo.useHaloInvitations(),U=React.useCallback(G=>{const K=clientProtocol.InvitationEncoder.encode(G);G.state===Invitation.State.CONNECTING&&log$2.info(JSON.stringify({invitationCode:K,authCode:G.authCode}))},[]),q=()=>{j.forEach(K=>K.cancel());const G=I.halo.share();process.env.NODE_ENV!=="production"&&G.subscribe(U),$==null||$({type:"selectInvitation",invitation:G})};return React.createElement(IdentityActionChooserImpl,{..._,onCreateInvitationClick:q})},IdentityActionChooserImpl=({send:_,onCreateInvitationClick:$,devices:I,connectionState:j,agentHostingEnabled:U,...q})=>{const G=I.find(K=>{var Y;return((Y=K.profile)==null?void 0:Y.type)===halo.DeviceType.AGENT_MANAGED});return React.createElement("div",{role:"none",className:"bs-40 grow overflow-y-auto overflow-x-hidden"},React.createElement(DeviceList,{devices:I,connectionState:j,onClickAdd:$,onClickJoinExisting:()=>_==null?void 0:_({type:"chooseJoinNewIdentity"}),onClickReset:()=>_==null?void 0:_({type:"chooseResetStorage"}),onAgentDestroy:q.onAgentDestroy}),!G&&React.createElement(AgentConfig,{...q}))},useAgentHandlers=({invitations:_,identity:$})=>{const[I,j]=React.useState(""),[U,q]=React.useState("getting"),G=reactClient.useAgentHostingClient(),K=reactClient.useClient(),Y=async()=>{if(G){q("getting");try{const ne=await(G==null?void 0:G.getAgent(($==null?void 0:$.identityKey.truncate())??"never"));q(ne?"created":"creatable")}catch(ne){q("error"),j(`Couldn’t check agent status: ${ne.message}`)}}else q("error"),j("No agent provider configured.")},J=async ne=>{if(invariant($,"Identity not found"),G){q("creating"),j("");try{await(G==null?void 0:G.createAgent(ne,$.identityKey.truncate()))?q("created"):(q("creatable"),j("Error creating agent."))}catch(ie){return j(`Error creating agent: ${ie.message}`),Y()}}else q("error"),j("No agent provider configured.")},X=async()=>{if(invariant($,"Identity not found"),G){q("destroying"),j("");try{await(G==null?void 0:G.destroyAgent($.identityKey.truncate())),q("creatable")}catch(ne){return j(`Error destroying agent: ${ne.message}`),Y()}}else q("error"),j("No agent provider configured.")};React.useEffect(()=>{Y()},[]);const Z=React.useCallback(async ne=>{const ie=clientProtocol.InvitationEncoder.encode(ne);if(ne.state===Invitation.State.CONNECTING)return log$2.info(JSON.stringify({invitationCode:ie,authCode:ne.authCode})),J(ie)},[]);return{onAgentCreate:async()=>{_.forEach(ie=>ie.cancel()),K.halo.share({type:Invitation.Type.INTERACTIVE,authMethod:Invitation.AuthMethod.NONE,multiUse:!0}).subscribe(Z)},onAgentDestroy:X,onAgentRefresh:async()=>{j(""),await Y()},validationMessage:I,agentStatus:U,agentHostingEnabled:!!G}};var qrcode={exports:{}};(function(_,$){var I=function(){var j=function(pe,ue){var ve=236,ge=17,be=pe,Re=q[ue],we=null,$e=0,Me=null,Ie=[],Be={},We=function(Se,xe){$e=be*4+17,we=function(Ee){for(var he=new Array(Ee),me=0;me<Ee;me+=1){he[me]=new Array(Ee);for(var Ae=0;Ae<Ee;Ae+=1)he[me][Ae]=null}return he}($e),Ke(0,0),Ke($e-7,0),Ke(0,$e-7),Ze(),qe(),Ne(Se,xe),be>=7&&Ge(Se),Me==null&&(Me=tt(be,Re,Ie)),De(Me,xe)},Ke=function(Se,xe){for(var Ee=-1;Ee<=7;Ee+=1)if(!(Se+Ee<=-1||$e<=Se+Ee))for(var he=-1;he<=7;he+=1)xe+he<=-1||$e<=xe+he||(0<=Ee&&Ee<=6&&(he==0||he==6)||0<=he&&he<=6&&(Ee==0||Ee==6)||2<=Ee&&Ee<=4&&2<=he&&he<=4?we[Se+Ee][xe+he]=!0:we[Se+Ee][xe+he]=!1)},Je=function(){for(var Se=0,xe=0,Ee=0;Ee<8;Ee+=1){We(!0,Ee);var he=K.getLostPoint(Be);(Ee==0||Se>he)&&(Se=he,xe=Ee)}return xe},qe=function(){for(var Se=8;Se<$e-8;Se+=1)we[Se][6]==null&&(we[Se][6]=Se%2==0);for(var xe=8;xe<$e-8;xe+=1)we[6][xe]==null&&(we[6][xe]=xe%2==0)},Ze=function(){for(var Se=K.getPatternPosition(be),xe=0;xe<Se.length;xe+=1)for(var Ee=0;Ee<Se.length;Ee+=1){var he=Se[xe],me=Se[Ee];if(we[he][me]==null)for(var Ae=-2;Ae<=2;Ae+=1)for(var Ue=-2;Ue<=2;Ue+=1)Ae==-2||Ae==2||Ue==-2||Ue==2||Ae==0&&Ue==0?we[he+Ae][me+Ue]=!0:we[he+Ae][me+Ue]=!1}},Ge=function(Se){for(var xe=K.getBCHTypeNumber(be),Ee=0;Ee<18;Ee+=1){var he=!Se&&(xe>>Ee&1)==1;we[Math.floor(Ee/3)][Ee%3+$e-8-3]=he}for(var Ee=0;Ee<18;Ee+=1){var he=!Se&&(xe>>Ee&1)==1;we[Ee%3+$e-8-3][Math.floor(Ee/3)]=he}},Ne=function(Se,xe){for(var Ee=Re<<3|xe,he=K.getBCHTypeInfo(Ee),me=0;me<15;me+=1){var Ae=!Se&&(he>>me&1)==1;me<6?we[me][8]=Ae:me<8?we[me+1][8]=Ae:we[$e-15+me][8]=Ae}for(var me=0;me<15;me+=1){var Ae=!Se&&(he>>me&1)==1;me<8?we[8][$e-me-1]=Ae:me<9?we[8][15-me-1+1]=Ae:we[8][15-me-1]=Ae}we[$e-8][8]=!Se},De=function(Se,xe){for(var Ee=-1,he=$e-1,me=7,Ae=0,Ue=K.getMaskFunction(xe),Ye=$e-1;Ye>0;Ye-=2)for(Ye==6&&(Ye-=1);;){for(var Qe=0;Qe<2;Qe+=1)if(we[he][Ye-Qe]==null){var nt=!1;Ae<Se.length&&(nt=(Se[Ae]>>>me&1)==1);var it=Ue(he,Ye-Qe);it&&(nt=!nt),we[he][Ye-Qe]=nt,me-=1,me==-1&&(Ae+=1,me=7)}if(he+=Ee,he<0||$e<=he){he-=Ee,Ee=-Ee;break}}},He=function(Se,xe){for(var Ee=0,he=0,me=0,Ae=new Array(xe.length),Ue=new Array(xe.length),Ye=0;Ye<xe.length;Ye+=1){var Qe=xe[Ye].dataCount,nt=xe[Ye].totalCount-Qe;he=Math.max(he,Qe),me=Math.max(me,nt),Ae[Ye]=new Array(Qe);for(var it=0;it<Ae[Ye].length;it+=1)Ae[Ye][it]=255&Se.getBuffer()[it+Ee];Ee+=Qe;var Ve=K.getErrorCorrectPolynomial(nt),ht=J(Ae[Ye],Ve.getLength()-1),Et=ht.mod(Ve);Ue[Ye]=new Array(Ve.getLength()-1);for(var it=0;it<Ue[Ye].length;it+=1){var lt=it+Et.getLength()-Ue[Ye].length;Ue[Ye][it]=lt>=0?Et.getAt(lt):0}}for(var yt=0,it=0;it<xe.length;it+=1)yt+=xe[it].totalCount;for(var St=new Array(yt),ot=0,it=0;it<he;it+=1)for(var Ye=0;Ye<xe.length;Ye+=1)it<Ae[Ye].length&&(St[ot]=Ae[Ye][it],ot+=1);for(var it=0;it<me;it+=1)for(var Ye=0;Ye<xe.length;Ye+=1)it<Ue[Ye].length&&(St[ot]=Ue[Ye][it],ot+=1);return St},tt=function(Se,xe,Ee){for(var he=X.getRSBlocks(Se,xe),me=Z(),Ae=0;Ae<Ee.length;Ae+=1){var Ue=Ee[Ae];me.put(Ue.getMode(),4),me.put(Ue.getLength(),K.getLengthInBits(Ue.getMode(),Se)),Ue.write(me)}for(var Ye=0,Ae=0;Ae<he.length;Ae+=1)Ye+=he[Ae].dataCount;if(me.getLengthInBits()>Ye*8)throw"code length overflow. ("+me.getLengthInBits()+">"+Ye*8+")";for(me.getLengthInBits()+4<=Ye*8&&me.put(0,4);me.getLengthInBits()%8!=0;)me.putBit(!1);for(;!(me.getLengthInBits()>=Ye*8||(me.put(ve,8),me.getLengthInBits()>=Ye*8));)me.put(ge,8);return He(me,he)};Be.addData=function(Se,xe){xe=xe||"Byte";var Ee=null;switch(xe){case"Numeric":Ee=Q(Se);break;case"Alphanumeric":Ee=ee(Se);break;case"Byte":Ee=ne(Se);break;case"Kanji":Ee=ie(Se);break;default:throw"mode:"+xe}Ie.push(Ee),Me=null},Be.isDark=function(Se,xe){if(Se<0||$e<=Se||xe<0||$e<=xe)throw Se+","+xe;return we[Se][xe]},Be.getModuleCount=function(){return $e},Be.make=function(){if(be<1){for(var Se=1;Se<40;Se++){for(var xe=X.getRSBlocks(Se,Re),Ee=Z(),he=0;he<Ie.length;he++){var me=Ie[he];Ee.put(me.getMode(),4),Ee.put(me.getLength(),K.getLengthInBits(me.getMode(),Se)),me.write(Ee)}for(var Ae=0,he=0;he<xe.length;he++)Ae+=xe[he].dataCount;if(Ee.getLengthInBits()<=Ae*8)break}be=Se}We(!1,Je())},Be.createTableTag=function(Se,xe){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var Ee="";Ee+='<table style="',Ee+=" border-width: 0px; border-style: none;",Ee+=" border-collapse: collapse;",Ee+=" padding: 0px; margin: "+xe+"px;",Ee+='">',Ee+="<tbody>";for(var he=0;he<Be.getModuleCount();he+=1){Ee+="<tr>";for(var me=0;me<Be.getModuleCount();me+=1)Ee+='<td style="',Ee+=" border-width: 0px; border-style: none;",Ee+=" border-collapse: collapse;",Ee+=" padding: 0px; margin: 0px;",Ee+=" width: "+Se+"px;",Ee+=" height: "+Se+"px;",Ee+=" background-color: ",Ee+=Be.isDark(he,me)?"#000000":"#ffffff",Ee+=";",Ee+='"/>';Ee+="</tr>"}return Ee+="</tbody>",Ee+="</table>",Ee},Be.createSvgTag=function(Se,xe,Ee,he){var me={};typeof arguments[0]=="object"&&(me=arguments[0],Se=me.cellSize,xe=me.margin,Ee=me.alt,he=me.title),Se=Se||2,xe=typeof xe>"u"?Se*4:xe,Ee=typeof Ee=="string"?{text:Ee}:Ee||{},Ee.text=Ee.text||null,Ee.id=Ee.text?Ee.id||"qrcode-description":null,he=typeof he=="string"?{text:he}:he||{},he.text=he.text||null,he.id=he.text?he.id||"qrcode-title":null;var Ae=Be.getModuleCount()*Se+xe*2,Ue,Ye,Qe,nt,it="",Ve;for(Ve="l"+Se+",0 0,"+Se+" -"+Se+",0 0,-"+Se+"z ",it+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',it+=me.scalable?"":' width="'+Ae+'px" height="'+Ae+'px"',it+=' viewBox="0 0 '+Ae+" "+Ae+'" ',it+=' preserveAspectRatio="xMinYMin meet"',it+=he.text||Ee.text?' role="img" aria-labelledby="'+Pe([he.id,Ee.id].join(" ").trim())+'"':"",it+=">",it+=he.text?'<title id="'+Pe(he.id)+'">'+Pe(he.text)+"</title>":"",it+=Ee.text?'<description id="'+Pe(Ee.id)+'">'+Pe(Ee.text)+"</description>":"",it+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',it+='<path d="',Qe=0;Qe<Be.getModuleCount();Qe+=1)for(nt=Qe*Se+xe,Ue=0;Ue<Be.getModuleCount();Ue+=1)Be.isDark(Qe,Ue)&&(Ye=Ue*Se+xe,it+="M"+Ye+","+nt+Ve);return it+='" stroke="transparent" fill="black"/>',it+="</svg>",it},Be.createDataURL=function(Se,xe){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var Ee=Be.getModuleCount()*Se+xe*2,he=xe,me=Ee-xe;return le(Ee,Ee,function(Ae,Ue){if(he<=Ae&&Ae<me&&he<=Ue&&Ue<me){var Ye=Math.floor((Ae-he)/Se),Qe=Math.floor((Ue-he)/Se);return Be.isDark(Qe,Ye)?0:1}else return 1})},Be.createImgTag=function(Se,xe,Ee){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var he=Be.getModuleCount()*Se+xe*2,me="";return me+="<img",me+=' src="',me+=Be.createDataURL(Se,xe),me+='"',me+=' width="',me+=he,me+='"',me+=' height="',me+=he,me+='"',Ee&&(me+=' alt="',me+=Pe(Ee),me+='"'),me+="/>",me};var Pe=function(Se){for(var xe="",Ee=0;Ee<Se.length;Ee+=1){var he=Se.charAt(Ee);switch(he){case"<":xe+="<";break;case">":xe+=">";break;case"&":xe+="&";break;case'"':xe+=""";break;default:xe+=he;break}}return xe},Le=function(Se){var xe=1;Se=typeof Se>"u"?xe*2:Se;var Ee=Be.getModuleCount()*xe+Se*2,he=Se,me=Ee-Se,Ae,Ue,Ye,Qe,nt,it={"██":"█","█ ":"▀"," █":"▄"," ":" "},Ve={"██":"▀","█ ":"▀"," █":" "," ":" "},ht="";for(Ae=0;Ae<Ee;Ae+=2){for(Ye=Math.floor((Ae-he)/xe),Qe=Math.floor((Ae+1-he)/xe),Ue=0;Ue<Ee;Ue+=1)nt="█",he<=Ue&&Ue<me&&he<=Ae&&Ae<me&&Be.isDark(Ye,Math.floor((Ue-he)/xe))&&(nt=" "),he<=Ue&&Ue<me&&he<=Ae+1&&Ae+1<me&&Be.isDark(Qe,Math.floor((Ue-he)/xe))?nt+=" ":nt+="█",ht+=Se<1&&Ae+1>=me?Ve[nt]:it[nt];ht+=`
|
|
947
|
+
`).concat(K.message))}else return I.getStateNodeByPath(q)})},_.prototype.formatTransition=function($){var I=this,j=normalizeTarget($.target),U="internal"in $?$.internal:j?j.some(function(Y){return isString(Y)&&Y[0]===I.delimiter}):!0,q=this.machine.options.guards,G=this.resolveTarget(j),K=__assign$1(__assign$1({},$),{actions:toActionObjects(toArray($.actions)),cond:toGuard($.cond,q),target:G,source:this,internal:U,eventType:$.event,toJSON:function(){return __assign$1(__assign$1({},K),{target:K.target?K.target.map(function(Y){return"#".concat(Y.id)}):void 0,source:"#".concat(I.id)})}});return K},_.prototype.formatTransitions=function(){var $,I,j=this,U;if(!this.config.on)U=[];else if(Array.isArray(this.config.on))U=this.config.on;else{var q=this.config.on,G=WILDCARD,K=q[G],Y=K===void 0?[]:K,J=__rest$1(q,[typeof G=="symbol"?G:G+""]);U=flatten(Object.keys(J).map(function(ae){!IS_PRODUCTION&&ae===NULL_EVENT&&warn(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(j.id,'".'));var fe=toTransitionConfigArray(ae,J[ae]);return IS_PRODUCTION||validateArrayifiedTransitions(j,ae,fe),fe}).concat(toTransitionConfigArray(WILDCARD,Y)))}var X=this.config.always?toTransitionConfigArray("",this.config.always):[],Z=this.config.onDone?toTransitionConfigArray(String(done(this.id)),this.config.onDone):[];IS_PRODUCTION||warn(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var Q=flatten(this.invoke.map(function(ae){var fe=[];return ae.onDone&&fe.push.apply(fe,__spreadArray([],__read$2(toTransitionConfigArray(String(doneInvoke(ae.id)),ae.onDone)),!1)),ae.onError&&fe.push.apply(fe,__spreadArray([],__read$2(toTransitionConfigArray(String(error(ae.id)),ae.onError)),!1)),fe})),ee=this.after,ne=flatten(__spreadArray(__spreadArray(__spreadArray(__spreadArray([],__read$2(Z),!1),__read$2(Q),!1),__read$2(U),!1),__read$2(X),!1).map(function(ae){return toArray(ae).map(function(fe){return j.formatTransition(fe)})}));try{for(var ie=__values(ee),oe=ie.next();!oe.done;oe=ie.next()){var se=oe.value;ne.push(se)}}catch(ae){$={error:ae}}finally{try{oe&&!oe.done&&(I=ie.return)&&I.call(ie)}finally{if($)throw $.error}}return ne},_}(),warned=!1;function createMachine(_,$){return!IS_PRODUCTION&&!("predictableActionArguments"in _)&&!warned&&(warned=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new StateNode(_,$)}var assign=assign$1,index=React.useLayoutEffect;function useConstant(_){var $=React__namespace.useRef();return $.current||($.current={v:_()}),$.current.v}var __assign=function(){return __assign=Object.assign||function(_){for(var $,I=1,j=arguments.length;I<j;I++){$=arguments[I];for(var U in $)Object.prototype.hasOwnProperty.call($,U)&&(_[U]=$[U])}return _},__assign.apply(this,arguments)},__rest=function(_,$){var I={};for(var j in _)Object.prototype.hasOwnProperty.call(_,j)&&$.indexOf(j)<0&&(I[j]=_[j]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var U=0,j=Object.getOwnPropertySymbols(_);U<j.length;U++)$.indexOf(j[U])<0&&Object.prototype.propertyIsEnumerable.call(_,j[U])&&(I[j[U]]=_[j[U]]);return I},__read$1=function(_,$){var I=typeof Symbol=="function"&&_[Symbol.iterator];if(!I)return _;var j=I.call(_),U,q=[],G;try{for(;($===void 0||$-- >0)&&!(U=j.next()).done;)q.push(U.value)}catch(K){G={error:K}}finally{try{U&&!U.done&&(I=j.return)&&I.call(j)}finally{if(G)throw G.error}}return q};function useIdleInterpreter(_,$){var I=useConstant(function(){return typeof _=="function"?_():_});if(process.env.NODE_ENV!=="production"&&typeof _!="function"){var j=__read$1(React.useState(I),1),U=j[0];_!==U&&console.warn("Machine given to `useMachine` has changed between renders. This is not supported and might lead to unexpected results.\nPlease make sure that you pass the same Machine as argument each time.")}var q=$.context,G=$.guards,K=$.actions,Y=$.activities,J=$.services,X=$.delays;$.state;var Z=__rest($,["context","guards","actions","activities","services","delays","state"]),Q=useConstant(function(){var ee={context:q,guards:G,actions:K,activities:Y,services:J,delays:X},ne=I.withConfig(ee,function(){return __assign(__assign({},I.context),q)});return interpret(ne,Z)});return index(function(){Object.assign(Q.machine.options.actions,K),Object.assign(Q.machine.options.guards,G),Object.assign(Q.machine.options.activities,Y),Object.assign(Q.machine.options.services,J),Object.assign(Q.machine.options.delays,X)},[K,G,Y,J,X]),Q}function isInterpreterStateEqual(_,$,I){if(_.status===InterpreterStatus.NotStarted)return!0;var j=I.changed===void 0&&(Object.keys(I.children).length>0||typeof $.changed=="boolean");return!(I.changed||j)}var __read=function(_,$){var I=typeof Symbol=="function"&&_[Symbol.iterator];if(!I)return _;var j=I.call(_),U,q=[],G;try{for(;($===void 0||$-- >0)&&!(U=j.next()).done;)q.push(U.value)}catch(K){G={error:K}}finally{try{U&&!U.done&&(I=j.return)&&I.call(j)}finally{if(G)throw G.error}}return q};function identity(_){return _}function useMachine(_){for(var $=[],I=1;I<arguments.length;I++)$[I-1]=arguments[I];var j=__read($,1),U=j[0],q=U===void 0?{}:U,G=useIdleInterpreter(_,q),K=React.useCallback(function(){return G.status===InterpreterStatus.NotStarted?q.state?State$1.create(q.state):G.machine.initialState:G.getSnapshot()},[G]),Y=React.useCallback(function(Z,Q){return isInterpreterStateEqual(G,Z,Q)},[G]),J=React.useCallback(function(Z){var Q=G.subscribe(Z).unsubscribe;return Q},[G]),X=withSelectorExports.useSyncExternalStoreWithSelector(J,K,K,identity,Y);return React.useEffect(function(){var Z=q.state;return G.start(Z?State$1.create(Z):void 0),function(){G.stop(),G.status=InterpreterStatus.NotStarted}},[]),[X,G.send,G]}const identityMachine=createMachine({id:"identity",predictableActionArguments:!0,context:{identity:null,identitySubscribable:null},initial:"choosingAction",invoke:{src:_=>_.identitySubscribable},states:{unknown:{always:[{cond:"initiallyManagingDeviceInvitation",target:"managingDeviceInvitation",actions:"log"},{target:"choosingAction",actions:"log"}]},choosingAction:{},managingDeviceInvitation:{},confirmingResetStorage:{},confirmingJoinNewIdentity:{}},on:{unchooseAction:{target:".choosingAction",actions:["unsetInvitation","log"]},deselectInvitation:{target:".choosingAction",actions:["unsetInvitation","log"]},selectInvitation:{target:".managingDeviceInvitation",actions:["setInvitation","log"]},chooseJoinNewIdentity:{target:".confirmingJoinNewIdentity",actions:"log"},chooseResetStorage:{target:".confirmingResetStorage",actions:"log"}}},{guards:{initiallyManagingDeviceInvitation:({initialDisposition:_},$)=>_==="manage-device-invitation"},actions:{setIdentity:assign({identity:(_,$)=>($==null?void 0:$.identity)??null}),setInvitation:assign({invitation:(_,$)=>($==null?void 0:$.invitation)??null}),unsetInvitation:assign({invitation:()=>{}}),log:(_,$)=>{log$2("[transition]",{event:$,context:_})}}}),useIdentityMachine=(_,$)=>useMachine(identityMachine,{...$,context:{...$==null?void 0:$.context,identity:_.halo.identity.get(),identitySubscribable:_.halo.identity.map(I=>({type:"setIdentity",identity:I}))}}),IdentityActionChooser=_=>{const{send:$}=_,I=reactClient.useClient(),j=halo.useHaloInvitations(),U=React.useCallback(G=>{const K=clientProtocol.InvitationEncoder.encode(G);G.state===Invitation.State.CONNECTING&&log$2.info(JSON.stringify({invitationCode:K,authCode:G.authCode}))},[]),q=()=>{j.forEach(K=>K.cancel());const G=I.halo.share();process.env.NODE_ENV!=="production"&&G.subscribe(U),$==null||$({type:"selectInvitation",invitation:G})};return React.createElement(IdentityActionChooserImpl,{..._,onCreateInvitationClick:q})},IdentityActionChooserImpl=({send:_,onCreateInvitationClick:$,devices:I,connectionState:j,agentHostingEnabled:U,...q})=>{const G=I.find(K=>{var Y;return((Y=K.profile)==null?void 0:Y.type)===halo.DeviceType.AGENT_MANAGED});return React.createElement("div",{role:"none",className:"bs-40 grow overflow-y-auto overflow-x-hidden"},React.createElement(DeviceList,{devices:I,connectionState:j,onClickAdd:$,onClickJoinExisting:()=>_==null?void 0:_({type:"chooseJoinNewIdentity"}),onClickReset:()=>_==null?void 0:_({type:"chooseResetStorage"}),onAgentDestroy:q.onAgentDestroy}),!G&&U&&React.createElement(AgentConfig,{...q}))},useAgentHandlers=({invitations:_,identity:$})=>{const[I,j]=React.useState(""),[U,q]=React.useState("getting"),G=reactClient.useAgentHostingClient(),K=reactClient.useClient(),Y=async()=>{if(G){q("getting");try{const ne=await(G==null?void 0:G.getAgent(($==null?void 0:$.identityKey.truncate())??"never"));q(ne?"created":"creatable")}catch(ne){q("error"),j(`Couldn’t check agent status: ${ne.message}`)}}else q("error"),j("No agent provider configured.")},J=async ne=>{if(invariant($,"Identity not found"),G){q("creating"),j("");try{await(G==null?void 0:G.createAgent(ne,$.identityKey.truncate()))?q("created"):(q("creatable"),j("Error creating agent."))}catch(ie){return j(`Error creating agent: ${ie.message}`),Y()}}else q("error"),j("No agent provider configured.")},X=async()=>{if(invariant($,"Identity not found"),G){q("destroying"),j("");try{await(G==null?void 0:G.destroyAgent($.identityKey.truncate())),q("creatable")}catch(ne){return j(`Error destroying agent: ${ne.message}`),Y()}}else q("error"),j("No agent provider configured.")};React.useEffect(()=>{Y()},[]);const Z=React.useCallback(async ne=>{const ie=clientProtocol.InvitationEncoder.encode(ne);if(ne.state===Invitation.State.CONNECTING)return log$2.info(JSON.stringify({invitationCode:ie,authCode:ne.authCode})),J(ie)},[]);return{onAgentCreate:async()=>{_.forEach(ie=>ie.cancel()),K.halo.share({type:Invitation.Type.INTERACTIVE,authMethod:Invitation.AuthMethod.NONE,multiUse:!0}).subscribe(Z)},onAgentDestroy:X,onAgentRefresh:async()=>{j(""),await Y()},validationMessage:I,agentStatus:U,agentHostingEnabled:!!G}};var qrcode={exports:{}};(function(_,$){var I=function(){var j=function(pe,ue){var ve=236,ge=17,be=pe,Re=q[ue],we=null,$e=0,Me=null,Ie=[],Be={},We=function(Se,xe){$e=be*4+17,we=function(Ee){for(var he=new Array(Ee),me=0;me<Ee;me+=1){he[me]=new Array(Ee);for(var Ae=0;Ae<Ee;Ae+=1)he[me][Ae]=null}return he}($e),Ke(0,0),Ke($e-7,0),Ke(0,$e-7),Ze(),qe(),Ne(Se,xe),be>=7&&Ge(Se),Me==null&&(Me=tt(be,Re,Ie)),De(Me,xe)},Ke=function(Se,xe){for(var Ee=-1;Ee<=7;Ee+=1)if(!(Se+Ee<=-1||$e<=Se+Ee))for(var he=-1;he<=7;he+=1)xe+he<=-1||$e<=xe+he||(0<=Ee&&Ee<=6&&(he==0||he==6)||0<=he&&he<=6&&(Ee==0||Ee==6)||2<=Ee&&Ee<=4&&2<=he&&he<=4?we[Se+Ee][xe+he]=!0:we[Se+Ee][xe+he]=!1)},Je=function(){for(var Se=0,xe=0,Ee=0;Ee<8;Ee+=1){We(!0,Ee);var he=K.getLostPoint(Be);(Ee==0||Se>he)&&(Se=he,xe=Ee)}return xe},qe=function(){for(var Se=8;Se<$e-8;Se+=1)we[Se][6]==null&&(we[Se][6]=Se%2==0);for(var xe=8;xe<$e-8;xe+=1)we[6][xe]==null&&(we[6][xe]=xe%2==0)},Ze=function(){for(var Se=K.getPatternPosition(be),xe=0;xe<Se.length;xe+=1)for(var Ee=0;Ee<Se.length;Ee+=1){var he=Se[xe],me=Se[Ee];if(we[he][me]==null)for(var Ae=-2;Ae<=2;Ae+=1)for(var Ue=-2;Ue<=2;Ue+=1)Ae==-2||Ae==2||Ue==-2||Ue==2||Ae==0&&Ue==0?we[he+Ae][me+Ue]=!0:we[he+Ae][me+Ue]=!1}},Ge=function(Se){for(var xe=K.getBCHTypeNumber(be),Ee=0;Ee<18;Ee+=1){var he=!Se&&(xe>>Ee&1)==1;we[Math.floor(Ee/3)][Ee%3+$e-8-3]=he}for(var Ee=0;Ee<18;Ee+=1){var he=!Se&&(xe>>Ee&1)==1;we[Ee%3+$e-8-3][Math.floor(Ee/3)]=he}},Ne=function(Se,xe){for(var Ee=Re<<3|xe,he=K.getBCHTypeInfo(Ee),me=0;me<15;me+=1){var Ae=!Se&&(he>>me&1)==1;me<6?we[me][8]=Ae:me<8?we[me+1][8]=Ae:we[$e-15+me][8]=Ae}for(var me=0;me<15;me+=1){var Ae=!Se&&(he>>me&1)==1;me<8?we[8][$e-me-1]=Ae:me<9?we[8][15-me-1+1]=Ae:we[8][15-me-1]=Ae}we[$e-8][8]=!Se},De=function(Se,xe){for(var Ee=-1,he=$e-1,me=7,Ae=0,Ue=K.getMaskFunction(xe),Ye=$e-1;Ye>0;Ye-=2)for(Ye==6&&(Ye-=1);;){for(var Qe=0;Qe<2;Qe+=1)if(we[he][Ye-Qe]==null){var nt=!1;Ae<Se.length&&(nt=(Se[Ae]>>>me&1)==1);var it=Ue(he,Ye-Qe);it&&(nt=!nt),we[he][Ye-Qe]=nt,me-=1,me==-1&&(Ae+=1,me=7)}if(he+=Ee,he<0||$e<=he){he-=Ee,Ee=-Ee;break}}},He=function(Se,xe){for(var Ee=0,he=0,me=0,Ae=new Array(xe.length),Ue=new Array(xe.length),Ye=0;Ye<xe.length;Ye+=1){var Qe=xe[Ye].dataCount,nt=xe[Ye].totalCount-Qe;he=Math.max(he,Qe),me=Math.max(me,nt),Ae[Ye]=new Array(Qe);for(var it=0;it<Ae[Ye].length;it+=1)Ae[Ye][it]=255&Se.getBuffer()[it+Ee];Ee+=Qe;var Ve=K.getErrorCorrectPolynomial(nt),ht=J(Ae[Ye],Ve.getLength()-1),Et=ht.mod(Ve);Ue[Ye]=new Array(Ve.getLength()-1);for(var it=0;it<Ue[Ye].length;it+=1){var lt=it+Et.getLength()-Ue[Ye].length;Ue[Ye][it]=lt>=0?Et.getAt(lt):0}}for(var yt=0,it=0;it<xe.length;it+=1)yt+=xe[it].totalCount;for(var St=new Array(yt),ot=0,it=0;it<he;it+=1)for(var Ye=0;Ye<xe.length;Ye+=1)it<Ae[Ye].length&&(St[ot]=Ae[Ye][it],ot+=1);for(var it=0;it<me;it+=1)for(var Ye=0;Ye<xe.length;Ye+=1)it<Ue[Ye].length&&(St[ot]=Ue[Ye][it],ot+=1);return St},tt=function(Se,xe,Ee){for(var he=X.getRSBlocks(Se,xe),me=Z(),Ae=0;Ae<Ee.length;Ae+=1){var Ue=Ee[Ae];me.put(Ue.getMode(),4),me.put(Ue.getLength(),K.getLengthInBits(Ue.getMode(),Se)),Ue.write(me)}for(var Ye=0,Ae=0;Ae<he.length;Ae+=1)Ye+=he[Ae].dataCount;if(me.getLengthInBits()>Ye*8)throw"code length overflow. ("+me.getLengthInBits()+">"+Ye*8+")";for(me.getLengthInBits()+4<=Ye*8&&me.put(0,4);me.getLengthInBits()%8!=0;)me.putBit(!1);for(;!(me.getLengthInBits()>=Ye*8||(me.put(ve,8),me.getLengthInBits()>=Ye*8));)me.put(ge,8);return He(me,he)};Be.addData=function(Se,xe){xe=xe||"Byte";var Ee=null;switch(xe){case"Numeric":Ee=Q(Se);break;case"Alphanumeric":Ee=ee(Se);break;case"Byte":Ee=ne(Se);break;case"Kanji":Ee=ie(Se);break;default:throw"mode:"+xe}Ie.push(Ee),Me=null},Be.isDark=function(Se,xe){if(Se<0||$e<=Se||xe<0||$e<=xe)throw Se+","+xe;return we[Se][xe]},Be.getModuleCount=function(){return $e},Be.make=function(){if(be<1){for(var Se=1;Se<40;Se++){for(var xe=X.getRSBlocks(Se,Re),Ee=Z(),he=0;he<Ie.length;he++){var me=Ie[he];Ee.put(me.getMode(),4),Ee.put(me.getLength(),K.getLengthInBits(me.getMode(),Se)),me.write(Ee)}for(var Ae=0,he=0;he<xe.length;he++)Ae+=xe[he].dataCount;if(Ee.getLengthInBits()<=Ae*8)break}be=Se}We(!1,Je())},Be.createTableTag=function(Se,xe){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var Ee="";Ee+='<table style="',Ee+=" border-width: 0px; border-style: none;",Ee+=" border-collapse: collapse;",Ee+=" padding: 0px; margin: "+xe+"px;",Ee+='">',Ee+="<tbody>";for(var he=0;he<Be.getModuleCount();he+=1){Ee+="<tr>";for(var me=0;me<Be.getModuleCount();me+=1)Ee+='<td style="',Ee+=" border-width: 0px; border-style: none;",Ee+=" border-collapse: collapse;",Ee+=" padding: 0px; margin: 0px;",Ee+=" width: "+Se+"px;",Ee+=" height: "+Se+"px;",Ee+=" background-color: ",Ee+=Be.isDark(he,me)?"#000000":"#ffffff",Ee+=";",Ee+='"/>';Ee+="</tr>"}return Ee+="</tbody>",Ee+="</table>",Ee},Be.createSvgTag=function(Se,xe,Ee,he){var me={};typeof arguments[0]=="object"&&(me=arguments[0],Se=me.cellSize,xe=me.margin,Ee=me.alt,he=me.title),Se=Se||2,xe=typeof xe>"u"?Se*4:xe,Ee=typeof Ee=="string"?{text:Ee}:Ee||{},Ee.text=Ee.text||null,Ee.id=Ee.text?Ee.id||"qrcode-description":null,he=typeof he=="string"?{text:he}:he||{},he.text=he.text||null,he.id=he.text?he.id||"qrcode-title":null;var Ae=Be.getModuleCount()*Se+xe*2,Ue,Ye,Qe,nt,it="",Ve;for(Ve="l"+Se+",0 0,"+Se+" -"+Se+",0 0,-"+Se+"z ",it+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',it+=me.scalable?"":' width="'+Ae+'px" height="'+Ae+'px"',it+=' viewBox="0 0 '+Ae+" "+Ae+'" ',it+=' preserveAspectRatio="xMinYMin meet"',it+=he.text||Ee.text?' role="img" aria-labelledby="'+Pe([he.id,Ee.id].join(" ").trim())+'"':"",it+=">",it+=he.text?'<title id="'+Pe(he.id)+'">'+Pe(he.text)+"</title>":"",it+=Ee.text?'<description id="'+Pe(Ee.id)+'">'+Pe(Ee.text)+"</description>":"",it+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',it+='<path d="',Qe=0;Qe<Be.getModuleCount();Qe+=1)for(nt=Qe*Se+xe,Ue=0;Ue<Be.getModuleCount();Ue+=1)Be.isDark(Qe,Ue)&&(Ye=Ue*Se+xe,it+="M"+Ye+","+nt+Ve);return it+='" stroke="transparent" fill="black"/>',it+="</svg>",it},Be.createDataURL=function(Se,xe){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var Ee=Be.getModuleCount()*Se+xe*2,he=xe,me=Ee-xe;return le(Ee,Ee,function(Ae,Ue){if(he<=Ae&&Ae<me&&he<=Ue&&Ue<me){var Ye=Math.floor((Ae-he)/Se),Qe=Math.floor((Ue-he)/Se);return Be.isDark(Qe,Ye)?0:1}else return 1})},Be.createImgTag=function(Se,xe,Ee){Se=Se||2,xe=typeof xe>"u"?Se*4:xe;var he=Be.getModuleCount()*Se+xe*2,me="";return me+="<img",me+=' src="',me+=Be.createDataURL(Se,xe),me+='"',me+=' width="',me+=he,me+='"',me+=' height="',me+=he,me+='"',Ee&&(me+=' alt="',me+=Pe(Ee),me+='"'),me+="/>",me};var Pe=function(Se){for(var xe="",Ee=0;Ee<Se.length;Ee+=1){var he=Se.charAt(Ee);switch(he){case"<":xe+="<";break;case">":xe+=">";break;case"&":xe+="&";break;case'"':xe+=""";break;default:xe+=he;break}}return xe},Le=function(Se){var xe=1;Se=typeof Se>"u"?xe*2:Se;var Ee=Be.getModuleCount()*xe+Se*2,he=Se,me=Ee-Se,Ae,Ue,Ye,Qe,nt,it={"██":"█","█ ":"▀"," █":"▄"," ":" "},Ve={"██":"▀","█ ":"▀"," █":" "," ":" "},ht="";for(Ae=0;Ae<Ee;Ae+=2){for(Ye=Math.floor((Ae-he)/xe),Qe=Math.floor((Ae+1-he)/xe),Ue=0;Ue<Ee;Ue+=1)nt="█",he<=Ue&&Ue<me&&he<=Ae&&Ae<me&&Be.isDark(Ye,Math.floor((Ue-he)/xe))&&(nt=" "),he<=Ue&&Ue<me&&he<=Ae+1&&Ae+1<me&&Be.isDark(Qe,Math.floor((Ue-he)/xe))?nt+=" ":nt+="█",ht+=Se<1&&Ae+1>=me?Ve[nt]:it[nt];ht+=`
|
|
948
948
|
`}return Ee%2&&Se>0?ht.substring(0,ht.length-Ee-1)+Array(Ee+1).join("▀"):ht.substring(0,ht.length-1)};return Be.createASCII=function(Se,xe){if(Se=Se||1,Se<2)return Le(xe);Se-=1,xe=typeof xe>"u"?Se*2:xe;var Ee=Be.getModuleCount()*Se+xe*2,he=xe,me=Ee-xe,Ae,Ue,Ye,Qe,nt=Array(Se+1).join("██"),it=Array(Se+1).join(" "),Ve="",ht="";for(Ae=0;Ae<Ee;Ae+=1){for(Ye=Math.floor((Ae-he)/Se),ht="",Ue=0;Ue<Ee;Ue+=1)Qe=1,he<=Ue&&Ue<me&&he<=Ae&&Ae<me&&Be.isDark(Ye,Math.floor((Ue-he)/Se))&&(Qe=0),ht+=Qe?nt:it;for(Ye=0;Ye<Se;Ye+=1)Ve+=ht+`
|
|
949
949
|
`}return Ve.substring(0,Ve.length-1)},Be.renderTo2dContext=function(Se,xe){xe=xe||2;for(var Ee=Be.getModuleCount(),he=0;he<Ee;he++)for(var me=0;me<Ee;me++)Se.fillStyle=Be.isDark(he,me)?"black":"white",Se.fillRect(he*xe,me*xe,xe,xe)},Be};j.stringToBytesFuncs={default:function(pe){for(var ue=[],ve=0;ve<pe.length;ve+=1){var ge=pe.charCodeAt(ve);ue.push(ge&255)}return ue}},j.stringToBytes=j.stringToBytesFuncs.default,j.createStringToBytes=function(pe,ue){var ve=function(){for(var be=ae(pe),Re=function(){var qe=be.read();if(qe==-1)throw"eof";return qe},we=0,$e={};;){var Me=be.read();if(Me==-1)break;var Ie=Re(),Be=Re(),We=Re(),Ke=String.fromCharCode(Me<<8|Ie),Je=Be<<8|We;$e[Ke]=Je,we+=1}if(we!=ue)throw we+" != "+ue;return $e}(),ge=63;return function(be){for(var Re=[],we=0;we<be.length;we+=1){var $e=be.charCodeAt(we);if($e<128)Re.push($e);else{var Me=ve[be.charAt(we)];typeof Me=="number"?(Me&255)==Me?Re.push(Me):(Re.push(Me>>>8),Re.push(Me&255)):Re.push(ge)}}return Re}};var U={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},q={L:1,M:0,Q:3,H:2},G={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},K=function(){var pe=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],ue=1335,ve=7973,ge=21522,be={},Re=function(we){for(var $e=0;we!=0;)$e+=1,we>>>=1;return $e};return be.getBCHTypeInfo=function(we){for(var $e=we<<10;Re($e)-Re(ue)>=0;)$e^=ue<<Re($e)-Re(ue);return(we<<10|$e)^ge},be.getBCHTypeNumber=function(we){for(var $e=we<<12;Re($e)-Re(ve)>=0;)$e^=ve<<Re($e)-Re(ve);return we<<12|$e},be.getPatternPosition=function(we){return pe[we-1]},be.getMaskFunction=function(we){switch(we){case G.PATTERN000:return function($e,Me){return($e+Me)%2==0};case G.PATTERN001:return function($e,Me){return $e%2==0};case G.PATTERN010:return function($e,Me){return Me%3==0};case G.PATTERN011:return function($e,Me){return($e+Me)%3==0};case G.PATTERN100:return function($e,Me){return(Math.floor($e/2)+Math.floor(Me/3))%2==0};case G.PATTERN101:return function($e,Me){return $e*Me%2+$e*Me%3==0};case G.PATTERN110:return function($e,Me){return($e*Me%2+$e*Me%3)%2==0};case G.PATTERN111:return function($e,Me){return($e*Me%3+($e+Me)%2)%2==0};default:throw"bad maskPattern:"+we}},be.getErrorCorrectPolynomial=function(we){for(var $e=J([1],0),Me=0;Me<we;Me+=1)$e=$e.multiply(J([1,Y.gexp(Me)],0));return $e},be.getLengthInBits=function(we,$e){if(1<=$e&&$e<10)switch(we){case U.MODE_NUMBER:return 10;case U.MODE_ALPHA_NUM:return 9;case U.MODE_8BIT_BYTE:return 8;case U.MODE_KANJI:return 8;default:throw"mode:"+we}else if($e<27)switch(we){case U.MODE_NUMBER:return 12;case U.MODE_ALPHA_NUM:return 11;case U.MODE_8BIT_BYTE:return 16;case U.MODE_KANJI:return 10;default:throw"mode:"+we}else if($e<41)switch(we){case U.MODE_NUMBER:return 14;case U.MODE_ALPHA_NUM:return 13;case U.MODE_8BIT_BYTE:return 16;case U.MODE_KANJI:return 12;default:throw"mode:"+we}else throw"type:"+$e},be.getLostPoint=function(we){for(var $e=we.getModuleCount(),Me=0,Ie=0;Ie<$e;Ie+=1)for(var Be=0;Be<$e;Be+=1){for(var We=0,Ke=we.isDark(Ie,Be),Je=-1;Je<=1;Je+=1)if(!(Ie+Je<0||$e<=Ie+Je))for(var qe=-1;qe<=1;qe+=1)Be+qe<0||$e<=Be+qe||Je==0&&qe==0||Ke==we.isDark(Ie+Je,Be+qe)&&(We+=1);We>5&&(Me+=3+We-5)}for(var Ie=0;Ie<$e-1;Ie+=1)for(var Be=0;Be<$e-1;Be+=1){var Ze=0;we.isDark(Ie,Be)&&(Ze+=1),we.isDark(Ie+1,Be)&&(Ze+=1),we.isDark(Ie,Be+1)&&(Ze+=1),we.isDark(Ie+1,Be+1)&&(Ze+=1),(Ze==0||Ze==4)&&(Me+=3)}for(var Ie=0;Ie<$e;Ie+=1)for(var Be=0;Be<$e-6;Be+=1)we.isDark(Ie,Be)&&!we.isDark(Ie,Be+1)&&we.isDark(Ie,Be+2)&&we.isDark(Ie,Be+3)&&we.isDark(Ie,Be+4)&&!we.isDark(Ie,Be+5)&&we.isDark(Ie,Be+6)&&(Me+=40);for(var Be=0;Be<$e;Be+=1)for(var Ie=0;Ie<$e-6;Ie+=1)we.isDark(Ie,Be)&&!we.isDark(Ie+1,Be)&&we.isDark(Ie+2,Be)&&we.isDark(Ie+3,Be)&&we.isDark(Ie+4,Be)&&!we.isDark(Ie+5,Be)&&we.isDark(Ie+6,Be)&&(Me+=40);for(var Ge=0,Be=0;Be<$e;Be+=1)for(var Ie=0;Ie<$e;Ie+=1)we.isDark(Ie,Be)&&(Ge+=1);var Ne=Math.abs(100*Ge/$e/$e-50)/5;return Me+=Ne*10,Me},be}(),Y=function(){for(var pe=new Array(256),ue=new Array(256),ve=0;ve<8;ve+=1)pe[ve]=1<<ve;for(var ve=8;ve<256;ve+=1)pe[ve]=pe[ve-4]^pe[ve-5]^pe[ve-6]^pe[ve-8];for(var ve=0;ve<255;ve+=1)ue[pe[ve]]=ve;var ge={};return ge.glog=function(be){if(be<1)throw"glog("+be+")";return ue[be]},ge.gexp=function(be){for(;be<0;)be+=255;for(;be>=256;)be-=255;return pe[be]},ge}();function J(pe,ue){if(typeof pe.length>"u")throw pe.length+"/"+ue;var ve=function(){for(var be=0;be<pe.length&&pe[be]==0;)be+=1;for(var Re=new Array(pe.length-be+ue),we=0;we<pe.length-be;we+=1)Re[we]=pe[we+be];return Re}(),ge={};return ge.getAt=function(be){return ve[be]},ge.getLength=function(){return ve.length},ge.multiply=function(be){for(var Re=new Array(ge.getLength()+be.getLength()-1),we=0;we<ge.getLength();we+=1)for(var $e=0;$e<be.getLength();$e+=1)Re[we+$e]^=Y.gexp(Y.glog(ge.getAt(we))+Y.glog(be.getAt($e)));return J(Re,0)},ge.mod=function(be){if(ge.getLength()-be.getLength()<0)return ge;for(var Re=Y.glog(ge.getAt(0))-Y.glog(be.getAt(0)),we=new Array(ge.getLength()),$e=0;$e<ge.getLength();$e+=1)we[$e]=ge.getAt($e);for(var $e=0;$e<be.getLength();$e+=1)we[$e]^=Y.gexp(Y.glog(be.getAt($e))+Re);return J(we,0).mod(be)},ge}var X=function(){var pe=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],ue=function(be,Re){var we={};return we.totalCount=be,we.dataCount=Re,we},ve={},ge=function(be,Re){switch(Re){case q.L:return pe[(be-1)*4+0];case q.M:return pe[(be-1)*4+1];case q.Q:return pe[(be-1)*4+2];case q.H:return pe[(be-1)*4+3];default:return}};return ve.getRSBlocks=function(be,Re){var we=ge(be,Re);if(typeof we>"u")throw"bad rs block @ typeNumber:"+be+"/errorCorrectionLevel:"+Re;for(var $e=we.length/3,Me=[],Ie=0;Ie<$e;Ie+=1)for(var Be=we[Ie*3+0],We=we[Ie*3+1],Ke=we[Ie*3+2],Je=0;Je<Be;Je+=1)Me.push(ue(We,Ke));return Me},ve}(),Z=function(){var pe=[],ue=0,ve={};return ve.getBuffer=function(){return pe},ve.getAt=function(ge){var be=Math.floor(ge/8);return(pe[be]>>>7-ge%8&1)==1},ve.put=function(ge,be){for(var Re=0;Re<be;Re+=1)ve.putBit((ge>>>be-Re-1&1)==1)},ve.getLengthInBits=function(){return ue},ve.putBit=function(ge){var be=Math.floor(ue/8);pe.length<=be&&pe.push(0),ge&&(pe[be]|=128>>>ue%8),ue+=1},ve},Q=function(pe){var ue=U.MODE_NUMBER,ve=pe,ge={};ge.getMode=function(){return ue},ge.getLength=function(we){return ve.length},ge.write=function(we){for(var $e=ve,Me=0;Me+2<$e.length;)we.put(be($e.substring(Me,Me+3)),10),Me+=3;Me<$e.length&&($e.length-Me==1?we.put(be($e.substring(Me,Me+1)),4):$e.length-Me==2&&we.put(be($e.substring(Me,Me+2)),7))};var be=function(we){for(var $e=0,Me=0;Me<we.length;Me+=1)$e=$e*10+Re(we.charAt(Me));return $e},Re=function(we){if("0"<=we&&we<="9")return we.charCodeAt(0)-48;throw"illegal char :"+we};return ge},ee=function(pe){var ue=U.MODE_ALPHA_NUM,ve=pe,ge={};ge.getMode=function(){return ue},ge.getLength=function(Re){return ve.length},ge.write=function(Re){for(var we=ve,$e=0;$e+1<we.length;)Re.put(be(we.charAt($e))*45+be(we.charAt($e+1)),11),$e+=2;$e<we.length&&Re.put(be(we.charAt($e)),6)};var be=function(Re){if("0"<=Re&&Re<="9")return Re.charCodeAt(0)-48;if("A"<=Re&&Re<="Z")return Re.charCodeAt(0)-65+10;switch(Re){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+Re}};return ge},ne=function(pe){var ue=U.MODE_8BIT_BYTE,ve=j.stringToBytes(pe),ge={};return ge.getMode=function(){return ue},ge.getLength=function(be){return ve.length},ge.write=function(be){for(var Re=0;Re<ve.length;Re+=1)be.put(ve[Re],8)},ge},ie=function(pe){var ue=U.MODE_KANJI,ve=j.stringToBytesFuncs.SJIS;if(!ve)throw"sjis not supported.";(function(Re,we){var $e=ve(Re);if($e.length!=2||($e[0]<<8|$e[1])!=we)throw"sjis not supported."})("友",38726);var ge=ve(pe),be={};return be.getMode=function(){return ue},be.getLength=function(Re){return~~(ge.length/2)},be.write=function(Re){for(var we=ge,$e=0;$e+1<we.length;){var Me=(255&we[$e])<<8|255&we[$e+1];if(33088<=Me&&Me<=40956)Me-=33088;else if(57408<=Me&&Me<=60351)Me-=49472;else throw"illegal char at "+($e+1)+"/"+Me;Me=(Me>>>8&255)*192+(Me&255),Re.put(Me,13),$e+=2}if($e<we.length)throw"illegal char at "+($e+1)},be},oe=function(){var pe=[],ue={};return ue.writeByte=function(ve){pe.push(ve&255)},ue.writeShort=function(ve){ue.writeByte(ve),ue.writeByte(ve>>>8)},ue.writeBytes=function(ve,ge,be){ge=ge||0,be=be||ve.length;for(var Re=0;Re<be;Re+=1)ue.writeByte(ve[Re+ge])},ue.writeString=function(ve){for(var ge=0;ge<ve.length;ge+=1)ue.writeByte(ve.charCodeAt(ge))},ue.toByteArray=function(){return pe},ue.toString=function(){var ve="";ve+="[";for(var ge=0;ge<pe.length;ge+=1)ge>0&&(ve+=","),ve+=pe[ge];return ve+="]",ve},ue},se=function(){var pe=0,ue=0,ve=0,ge="",be={},Re=function($e){ge+=String.fromCharCode(we($e&63))},we=function($e){if(!($e<0)){if($e<26)return 65+$e;if($e<52)return 97+($e-26);if($e<62)return 48+($e-52);if($e==62)return 43;if($e==63)return 47}throw"n:"+$e};return be.writeByte=function($e){for(pe=pe<<8|$e&255,ue+=8,ve+=1;ue>=6;)Re(pe>>>ue-6),ue-=6},be.flush=function(){if(ue>0&&(Re(pe<<6-ue),pe=0,ue=0),ve%3!=0)for(var $e=3-ve%3,Me=0;Me<$e;Me+=1)ge+="="},be.toString=function(){return ge},be},ae=function(pe){var ue=pe,ve=0,ge=0,be=0,Re={};Re.read=function(){for(;be<8;){if(ve>=ue.length){if(be==0)return-1;throw"unexpected end of file./"+be}var $e=ue.charAt(ve);if(ve+=1,$e=="=")return be=0,-1;if($e.match(/^\s$/))continue;ge=ge<<6|we($e.charCodeAt(0)),be+=6}var Me=ge>>>be-8&255;return be-=8,Me};var we=function($e){if(65<=$e&&$e<=90)return $e-65;if(97<=$e&&$e<=122)return $e-97+26;if(48<=$e&&$e<=57)return $e-48+52;if($e==43)return 62;if($e==47)return 63;throw"c:"+$e};return Re},fe=function(pe,ue){var ve=pe,ge=ue,be=new Array(pe*ue),Re={};Re.setPixel=function(Ie,Be,We){be[Be*ve+Ie]=We},Re.write=function(Ie){Ie.writeString("GIF87a"),Ie.writeShort(ve),Ie.writeShort(ge),Ie.writeByte(128),Ie.writeByte(0),Ie.writeByte(0),Ie.writeByte(0),Ie.writeByte(0),Ie.writeByte(0),Ie.writeByte(255),Ie.writeByte(255),Ie.writeByte(255),Ie.writeString(","),Ie.writeShort(0),Ie.writeShort(0),Ie.writeShort(ve),Ie.writeShort(ge),Ie.writeByte(0);var Be=2,We=$e(Be);Ie.writeByte(Be);for(var Ke=0;We.length-Ke>255;)Ie.writeByte(255),Ie.writeBytes(We,Ke,255),Ke+=255;Ie.writeByte(We.length-Ke),Ie.writeBytes(We,Ke,We.length-Ke),Ie.writeByte(0),Ie.writeString(";")};var we=function(Ie){var Be=Ie,We=0,Ke=0,Je={};return Je.write=function(qe,Ze){if(qe>>>Ze)throw"length over";for(;We+Ze>=8;)Be.writeByte(255&(qe<<We|Ke)),Ze-=8-We,qe>>>=8-We,Ke=0,We=0;Ke=qe<<We|Ke,We=We+Ze},Je.flush=function(){We>0&&Be.writeByte(Ke)},Je},$e=function(Ie){for(var Be=1<<Ie,We=(1<<Ie)+1,Ke=Ie+1,Je=Me(),qe=0;qe<Be;qe+=1)Je.add(String.fromCharCode(qe));Je.add(String.fromCharCode(Be)),Je.add(String.fromCharCode(We));var Ze=oe(),Ge=we(Ze);Ge.write(Be,Ke);var Ne=0,De=String.fromCharCode(be[Ne]);for(Ne+=1;Ne<be.length;){var He=String.fromCharCode(be[Ne]);Ne+=1,Je.contains(De+He)?De=De+He:(Ge.write(Je.indexOf(De),Ke),Je.size()<4095&&(Je.size()==1<<Ke&&(Ke+=1),Je.add(De+He)),De=He)}return Ge.write(Je.indexOf(De),Ke),Ge.write(We,Ke),Ge.flush(),Ze.toByteArray()},Me=function(){var Ie={},Be=0,We={};return We.add=function(Ke){if(We.contains(Ke))throw"dup key:"+Ke;Ie[Ke]=Be,Be+=1},We.size=function(){return Be},We.indexOf=function(Ke){return Ie[Ke]},We.contains=function(Ke){return typeof Ie[Ke]<"u"},We};return Re},le=function(pe,ue,ve){for(var ge=fe(pe,ue),be=0;be<ue;be+=1)for(var Re=0;Re<pe;Re+=1)ge.setPixel(Re,be,ve(Re,be));var we=oe();ge.write(we);for(var $e=se(),Me=we.toByteArray(),Ie=0;Ie<Me.length;Ie+=1)$e.writeByte(Me[Ie]);return $e.flush(),"data:image/gif;base64,"+$e};return j}();(function(){I.stringToBytesFuncs["UTF-8"]=function(j){function U(q){for(var G=[],K=0;K<q.length;K++){var Y=q.charCodeAt(K);Y<128?G.push(Y):Y<2048?G.push(192|Y>>6,128|Y&63):Y<55296||Y>=57344?G.push(224|Y>>12,128|Y>>6&63,128|Y&63):(K++,Y=65536+((Y&1023)<<10|q.charCodeAt(K)&1023),G.push(240|Y>>18,128|Y>>12&63,128|Y>>6&63,128|Y&63))}return G}return U(j)}})(),function(j){_.exports=j()}(function(){return I})})(qrcode);var qrcodeExports=qrcode.exports;const qrGenerator=getDefaultExportFromCjs(qrcodeExports);var __defProp=Object.defineProperty,__getOwnPropSymbols=Object.getOwnPropertySymbols,__hasOwnProp=Object.prototype.hasOwnProperty,__propIsEnum=Object.prototype.propertyIsEnumerable,__defNormalProp=(_,$,I)=>$ in _?__defProp(_,$,{enumerable:!0,configurable:!0,writable:!0,value:I}):_[$]=I,__spreadValues=(_,$)=>{for(var I in $||($={}))__hasOwnProp.call($,I)&&__defNormalProp(_,I,$[I]);if(__getOwnPropSymbols)for(var I of __getOwnPropSymbols($))__propIsEnum.call($,I)&&__defNormalProp(_,I,$[I]);return _},__objRest=(_,$)=>{var I={};for(var j in _)__hasOwnProp.call(_,j)&&$.indexOf(j)<0&&(I[j]=_[j]);if(_!=null&&__getOwnPropSymbols)for(var j of __getOwnPropSymbols(_))$.indexOf(j)<0&&__propIsEnum.call(_,j)&&(I[j]=_[j]);return I},VIEWPORT_SIZE=1e3,RE_CODE_LENGTH_OVERFLOW=/code length overflow/i;qrGenerator.stringToBytes=qrGenerator.stringToBytesFuncs["UTF-8"];var createQrCode=(_,$,I)=>{I=Math.max(1,I);for(let j=I;j<=40;j+=1)try{const U=qrGenerator(j,$);U.addData(_),U.make();const q=U.getModuleCount();return{text:_,level:$,version:j,moduleCount:q,isDark:(K,Y)=>K>=0&&K<q&&Y>=0&&Y<q&&U.isDark(K,Y)}}catch(U){if(!(j<40&&RE_CODE_LENGTH_OVERFLOW.test(String(U))))throw U}return null},round=Math.round,drawM=(_,$)=>`M ${round(_)} ${round($)}`,drawL=(_,$)=>`L ${round(_)} ${round($)}`,drawA=(_,$,I)=>`A ${round(I)} ${round(I)} 0 0 1 ${round(_)} ${round($)}`,drawDark=(_,$,I,j,U,q,G,K,Y)=>{const J=[];return q?J.push(drawM(_+U,$)):J.push(drawM(_,$)),G?J.push(drawL(I-U,$),drawA(I,$+U,U)):J.push(drawL(I,$)),K?J.push(drawL(I,j-U),drawA(I-U,j,U)):J.push(drawL(I,j)),Y?J.push(drawL(_+U,j),drawA(_,j-U,U)):J.push(drawL(_,j)),q?J.push(drawL(_,$+U),drawA(_+U,$,U)):J.push(drawL(_,$)),J.join(" ")},drawLight=(_,$,I,j,U,q,G,K,Y)=>{const J=[];return q&&J.push(drawM(_+U,$),drawL(_,$),drawL(_,$+U),drawA(_+U,$,U)),G&&J.push(drawM(I,$+U),drawL(I,$),drawL(I-U,$),drawA(I,$+U,U)),K&&J.push(drawM(I-U,j),drawL(I,j),drawL(I,j-U),drawA(I-U,j,U)),Y&&J.push(drawM(_,j-U),drawL(_,j),drawL(_+U,j),drawA(_,j-U,U)),J.join(" ")},drawMod=(_,$,I,j,U)=>{const q=U*I,G=j*I,K=q+I,Y=G+I,J=$*.005*I,X=_.isDark,Z=j-1,Q=j+1,ee=U-1,ne=U+1,ie=X(j,U),oe=X(Z,ee),se=X(Z,U),ae=X(Z,ne),fe=X(j,ne),le=X(Q,ne),pe=X(Q,U),ue=X(Q,ee),ve=X(j,ee);return ie?drawDark(q,G,K,Y,J,!se&&!ve,!se&&!fe,!pe&&!fe,!pe&&!ve):drawLight(q,G,K,Y,J,se&&ve&&oe,se&&fe&&ae,pe&&fe&&le,pe&&ve&&ue)},createPath=(_,$)=>{if(!_)return"";const I=_.moduleCount,j=VIEWPORT_SIZE/I,U=[];for(let q=0;q<I;q+=1)for(let G=0;G<I;G+=1)U.push(drawMod(_,$,j,q,G));return U.join(" ")},QR=_=>{var $=_,{color:I="#000",backgroundColor:j,cutout:U=!1,cutoutElement:q,errorCorrectionLevel:G="Q",rounding:K=0,children:Y}=$,J=__objRest($,["color","backgroundColor","cutout","cutoutElement","errorCorrectionLevel","rounding","children"]),X,Z;const Q=React.useMemo(()=>createQrCode(Y,G,1),[Y,G]);if(!Q)return null;const ee=(X=Q==null?void 0:Q.moduleCount)!=null?X:1,ie=VIEWPORT_SIZE/((Z=Q==null?void 0:Q.moduleCount)!=null?Z:1)*(Math.floor(ee*.18)*2-1)+2,oe=(VIEWPORT_SIZE-ie)/2;return React__namespace.createElement("svg",__spreadValues({xmlns:"http://www.w3.org/2000/svg",viewBox:`0 0 ${VIEWPORT_SIZE} ${VIEWPORT_SIZE}`},J),U?React__namespace.createElement("mask",{id:"react-qr-rounded__mask"},React__namespace.createElement("rect",{x:"0",y:"0",width:VIEWPORT_SIZE,height:VIEWPORT_SIZE,fill:"#fff"}),React__namespace.createElement("rect",{x:oe,y:oe,width:ie,height:ie,rx:K,ry:K,fill:"#000"})):null,j?React__namespace.createElement("rect",{x:"0",y:"0",width:VIEWPORT_SIZE,height:VIEWPORT_SIZE,fill:j}):null,React__namespace.createElement("path",{fill:I,d:createPath(Q,K),mask:U?"url(#react-qr-rounded__mask)":void 0}),q?React__namespace.createElement("foreignObject",{x:oe,y:oe,width:ie,height:ie},React__namespace.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",width:"100%",overflow:"hidden",borderRadius:K}},q)):null)};const invitationStatusValue=new Map([[Invitation.State.ERROR,-3],[Invitation.State.TIMEOUT,-2],[Invitation.State.CANCELLED,-1],[Invitation.State.INIT,0],[Invitation.State.CONNECTING,1],[Invitation.State.CONNECTED,2],[Invitation.State.READY_FOR_AUTHENTICATION,3],[Invitation.State.AUTHENTICATING,4],[Invitation.State.SUCCESS,5]]),InvitationManagerView=({children:_,...$})=>React.createElement(Viewport.View,{...$,classNames:"grow flex flex-col justify-around items-center"},_),InvitationManager=({invitationUrl:_,active:$,send:I,status:j,multiUse:U,authCode:q,id:G="0"})=>{const{t:K}=useTranslation("os"),Y=useId("invitation-manager__qr-code"),J=U?0:invitationStatusValue.get(j)??0,X=J===3,Z=hexToEmoji(G),Q=React.useMemo(()=>{if(U)return"showing qr";switch(!0){case J===5:case J<0:return"showing final";case J===3:return"showing auth code";default:return"showing qr"}},[J]);return React.createElement(React.Fragment,null,React.createElement(Viewport.Root,{activeView:Q,classNames:"grow plb-1"},React.createElement(Viewport.Views,null,React.createElement(InvitationManagerView,{id:"showing qr",emoji:Z},React.createElement("p",{className:"text-sm mlb-1 font-normal text-center"},K(U?"invite many qr label":"invite one qr label")),React.createElement("div",{role:"none",className:mx(descriptionText,"is-full max-is-[14rem] relative")},React.createElement(QR,{rounding:100,backgroundColor:"transparent",color:"currentColor",className:mx("is-full bs-full p-2",X&&"invisible"),"aria-labelledby":Y,errorCorrectionLevel:"Q",cutout:!0},_??"never"),React.createElement(Centered,null,React.createElement(Emoji,{text:Z}))),React.createElement("span",{id:Y,className:"sr-only"},K("qr label")),React.createElement(CopyButton,{variant:"ghost",value:_??"never"})),React.createElement(InvitationManagerView,{id:"showing auth code"},React.createElement(Label,null,K("auth code message")),React.createElement(AuthCode,{code:q,large:!0,classNames:"text-black dark:text-white"}),React.createElement(Label,null,K("auth other device emoji message")),Z&&React.createElement(Emoji,{text:Z})),React.createElement(InvitationManagerView,{id:"showing final"},J>0?React.createElement(react.Check,{className:mx("m-1.5",getSize(6))}):React.createElement(react.X,{className:mx("m-1.5",getSize(6))})))),React.createElement(Actions,{classNames:"mbs-4"},React.createElement(Action,{disabled:!$,onClick:()=>I==null?void 0:I({type:"deselectInvitation"})},K("back label"))))},ConfirmReset=({active:_,onCancel:$,onConfirm:I,mode:j})=>{const{t:U}=useTranslation("os"),[q,G]=React.useState(""),[K,Y]=React.useState(!1),J=async()=>(Y(!0),I==null?void 0:I().then(()=>Y(!1),X=>{log$2.catch(X),G(U("failed to reset identity message")),Y(!1)}));return React.createElement(ConfirmResetImpl,{disabled:!_,pending:K,validationMessage:q,onConfirm:J,onCancel:$,mode:j})},ConfirmResetImpl=({disabled:_,pending:$,validationMessage:I,onConfirm:j,onCancel:U,mode:q})=>{const{t:G}=useTranslation("os"),K=G("confirmation value"),[Y,J]=React.useState(""),X=q==="join new identity"?"join-new-identity":"reset-storage";return React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col gap-2 justify-center"},React.createElement(Message$1.Root,{valence:"error"},React.createElement(Message$1.Title,null,React.createElement(react.Warning,{className:mx(getSize(6),"inline mie-2")}),G("sign out chooser title")),React.createElement(Message$1.Body,null,G("sign out chooser message"))),React.createElement(Input,{validationMessage:I,label:React.createElement(StepHeading,{className:"text-start mlb-2"},G(q==="join new identity"?"join new identity input label":"reset storage input label",{confirmationValue:K})),disabled:_,"data-testid":`${X}.reset-identity-input`,placeholder:G("confirmation placeholder",{confirmationValue:K}),onChange:({target:{value:Z}})=>J(Z)})),React.createElement(Actions,null,U&&React.createElement(Action,{disabled:_,onClick:U,"data-testid":`${X}.reset-identity-cancel`},G("cancel label")),j&&React.createElement(Action,{variant:"destructive",disabled:_||$||Y!==K,onClick:j,"data-testid":`${X}.reset-identity-confirm`},G($?"reset in progress label":"reset device label"))))},viewStyles="pbs-1 pbe-3 pli-3",getHueValue=_=>{var $,I;return((I=($=_==null?void 0:_.profile)==null?void 0:$.data)==null?void 0:I.hue)||hexToHue((_==null?void 0:_.identityKey.toHex())??"0")},getEmojiValue=_=>{var $,I;return((I=($=_==null?void 0:_.profile)==null?void 0:$.data)==null?void 0:I.emoji)||hexToEmoji((_==null?void 0:_.identityKey.toHex())??"0")},IdentityHeading=({titleId:_,title:$,identity:I,onDone:j,onUpdateProfile:U,connectionState:q,onChangeConnectionState:G})=>{var ue,ve;const K=keyToFallback(I.identityKey),{t:Y}=useTranslation("os"),[J,X]=React.useState(((ue=I.profile)==null?void 0:ue.displayName)??""),[Z,Q]=React.useState(getEmojiValue(I)),[ee,ne]=React.useState(getHueValue(I)),{textValue:ie,setTextValue:oe}=useClipboardContext(),se=I.identityKey.toHex(),ae=ie===se,fe=ge=>{var be;Q(ge),U==null||U({...I.profile,data:{...(be=I.profile)==null?void 0:be.data,emoji:ge}})},le=ge=>{var be;ne(ge),U==null||U({...I.profile,data:{...(be=I.profile)==null?void 0:be.data,hue:ge}})},pe=q===mesh.ConnectionState.ONLINE;return React.createElement(Heading,{titleId:_,title:$,corner:React.createElement(CloseButton,{onDone:j})},React.createElement(Avatar.Root,{size:16,variant:"circle",status:pe?"active":"error",hue:ee||K.hue},React.createElement(Toolbar.Root,{classNames:"flex justify-center"},React.createElement(Avatar.Frame,{classNames:"relative z-[2] -mli-4 chromatic-ignore"},React.createElement(Avatar.Fallback,{text:Z||K.emoji}))),React.createElement(Avatar.Label,{classNames:"sr-only","data-testid":"identityHeading.displayName"},((ve=I.profile)==null?void 0:ve.displayName)??generateName(I.identityKey.toHex())),React.createElement(Input$1.Root,null,React.createElement(Input$1.Label,{srOnly:!0},Y("display name input label")),React.createElement(Input$1.TextInput,{variant:"subdued","data-testid":"display-name-input",placeholder:Y("display name input placeholder"),classNames:"mbs-2 text-center font-light text-xl",value:J,onChange:({target:{value:ge}})=>X(ge),onBlur:({target:{value:ge}})=>U==null?void 0:U({...I.profile,displayName:ge})})),React.createElement(Toolbar.Root,{classNames:"flex justify-center items-center gap-1 pt-3"},React.createElement(EmojiPickerToolbarButton,{emoji:Z,onChangeEmoji:fe,classNames:"bs-[--rail-action]"}),React.createElement(HuePickerToolbarButton,{hue:ee,onChangeHue:le,classNames:"bs-[--rail-action]"}),React.createElement(React.Fragment,null,React.createElement(Tooltip.Root,null,React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:"bs-[--rail-action]","data-testid":"update-profile-form-copy-key",onClick:()=>oe(se)},React.createElement("span",{className:"sr-only"},Y(ae?"copy success label":"copy self public key label")),React.createElement(react.Key,{className:getSize(5)}))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},Y(ae?"copy success label":"copy self public key label"),React.createElement(Tooltip.Arrow,null))),React.createElement(Tooltip.Root,null,React.createElement(Tooltip.Trigger,{asChild:!0},React.createElement(Toolbar.Button,{classNames:["bs-[--rail-action]",!pe&&"text-error-500"],onClick:()=>G==null?void 0:G(pe?mesh.ConnectionState.OFFLINE:mesh.ConnectionState.ONLINE)},React.createElement("span",{className:"sr-only"},Y(pe?"disconnect label":"connect label")),pe?React.createElement(react.PlugsConnected,{className:getSize(5)}):React.createElement(react.Plugs,{className:getSize(5)}))),React.createElement(Tooltip.Portal,null,React.createElement(Tooltip.Content,{side:"bottom",classNames:"z-50"},Y(pe?"disconnect label":"connect label"),React.createElement(Tooltip.Arrow,null)))))))))},IdentityPanelImpl=_=>{const{identity:$,titleId:I,activeView:j,onUpdateProfile:U,onResetStorage:q,onJoinNewIdentity:G,IdentityActionChooser:K=IdentityActionChooser,InvitationManager:Y=InvitationManager,connectionState:J,onChangeConnectionState:X,onDone:Z,...Q}=_,{t:ee}=useTranslation("os"),ne=React.useMemo(()=>{switch(j){case"device invitation manager":return ee("choose add device label");default:return ee("identity heading")}},[j,ee]),ie=()=>{var oe;return(oe=Q.send)==null?void 0:oe.call(Q,"unchooseAction")};return React.createElement(DensityProvider,{density:"fine"},React.createElement(IdentityHeading,{identity:$,titleId:I,title:ne,onDone:Z,onUpdateProfile:U,connectionState:J,onChangeConnectionState:X}),React.createElement(Viewport.Root,{activeView:j},React.createElement(Viewport.Views,null,React.createElement(Viewport.View,{id:"identity action chooser",classNames:viewStyles},React.createElement(K,{active:j==="identity action chooser",...Q,connectionState:J})),React.createElement(Viewport.View,{id:"device invitation manager",classNames:viewStyles},React.createElement(Y,{active:j==="device invitation manager",...Q,invitationUrl:Q.createInvitationUrl(Q.invitationCode)})),React.createElement(Viewport.View,{classNames:viewStyles,id:"confirm join new identity"},React.createElement(ConfirmReset,{active:j==="confirm join new identity",...Q,mode:"join new identity",onConfirm:G,onCancel:ie})),React.createElement(Viewport.View,{classNames:viewStyles,id:"confirm reset storage"},React.createElement(ConfirmReset,{active:j==="confirm reset storage",...Q,mode:"reset storage",onConfirm:q,onCancel:ie})))))},IdentityPanelWithInvitationImpl=({invitation:_,...$})=>{const I=useInvitationStatus(_);return React.createElement(IdentityPanelImpl,{...$,...I})},IdentityPanel=({titleId:_,createInvitationUrl:$=U=>U,initialDisposition:I="default",...j})=>{const U=useId("identityPanel__heading",_),q=reactClient.useClient(),G=halo.useDevices(),K=halo.useIdentity(),Y=halo.useHaloInvitations(),J=useAgentHandlers({identity:K,invitations:Y});if(!K)return log$2.error("IdentityPanel rendered with no active identity."),null;const[X,Z,Q]=useIdentityMachine(q,{context:{initialDisposition:I}}),{swarm:ee}=mesh.useNetworkStatus(),ne=async ae=>q==null?void 0:q.mesh.updateConfig(ae);React.useEffect(()=>Q.subscribe(fe=>{log$2("[state]",fe)}).unsubscribe,[Q]);const ie=React.useMemo(()=>{switch(!0){case X.matches("choosingAction"):return"identity action chooser";case X.matches("managingDeviceInvitation"):return"device invitation manager";case X.matches("confirmingResetStorage"):return"confirm reset storage";case X.matches("confirmingJoinNewIdentity"):return"confirm join new identity";default:return"identity action chooser"}},[X]),se={...j,identity:K,devices:G,activeView:ie,send:Z,titleId:U,createInvitationUrl:$,onUpdateProfile:async ae=>{Z({type:"updateProfile"}),await q.halo.updateProfile(ae)},connectionState:ee,onChangeConnectionState:ne,...J};return X.context.invitation?React.createElement(IdentityPanelWithInvitationImpl,{...se,invitation:X.context.invitation}):React.createElement(IdentityPanelImpl,{...se})},JoinHeading=React.forwardRef(({mode:_,titleId:$,exitActionParent:I,onExit:j},U)=>{const{t:q}=useTranslation("os"),G=React.createElement(Button,{variant:"ghost",...j&&{onClick:j},classNames:mx(descriptionText,"plb-0 pli-2 absolute block-start-0 inline-end-0 z-[1]"),"data-testid":"join-exit"},React.createElement(react.X,{weight:"bold",className:getSize(4)}),React.createElement("span",{className:"sr-only"},q("exit label")));return React.createElement(Heading,{ref:U,titleId:$,title:q(_==="halo-only"?"selecting identity heading":"joining space heading"),..._==="halo-only"?{titleSrOnly:!0}:{corner:I?React.cloneElement(I,{},G):G},titleSrOnly:_==="halo-only"})}),getInvitationSubscribable=(_,$)=>(log$2("[subscribing to invitation]",$),{subscribe:(I,j,U)=>$.subscribe(q=>{switch(q.state){case Invitation.State.CONNECTING:return log$2("[invitation connecting]",{Kind:_,invitation:q}),I({type:`connecting${_}Invitation`,invitation:q});case Invitation.State.CONNECTED:return log$2("[invitation connected]",{Kind:_,invitation:q}),I({type:`connected${_}Invitation`,invitation:q});case Invitation.State.READY_FOR_AUTHENTICATION:return log$2("[invitation ready for authentication]",{Kind:_,invitation:q}),I({type:`readyForAuthentication${_}Invitation`,invitation:q});case Invitation.State.AUTHENTICATING:return log$2("[invitation authenticating]",{Kind:_,invitation:q}),I({type:`authenticating${_}Invitation`,invitation:q});case Invitation.State.SUCCESS:return log$2("[invitation success]",{Kind:_,invitation:q}),I({type:`success${_}Invitation`,invitation:q}),U==null?void 0:U();case Invitation.State.CANCELLED:return log$2.warn("[invitation cancelled]",{Kind:_}),I({type:`fail${_}Invitation`,reason:"cancelled"});case Invitation.State.TIMEOUT:return log$2.error("[invitation timeout]",{Kind:_}),I({type:`fail${_}Invitation`,reason:"timeout"})}},q=>q instanceof reactClient.AlreadyJoinedError?(log$2("[already joined]",{Kind:_,error:q}),I({type:`success${_}Invitation`,invitation:$.get()}),U==null?void 0:U()):(log$2.error("[invitation errored]",{Kind:_,error:q}),I({type:`fail${_}Invitation`,reason:"error"}),j==null?void 0:j(q)))}),acceptingInvitationTemplate=(_,$)=>({initial:`unknown${_}`,states:{[`unknown${_}`]:{always:[{cond:({mode:j})=>j==="halo-only"&&_==="Space",target:"#join.finishingJoiningHalo"},{cond:j=>!!j[_.toLowerCase()].unredeemedCode,target:`acceptingRedeemed${_}Invitation`,actions:[`redeem${_}InvitationCode`,`invalidate${_}InvitationCode`,"log"]},{target:`inputting${_}InvitationCode`,actions:"log"}]},[`inputting${_}InvitationCode`]:{},[`acceptingRedeemed${_}Invitation`]:{invoke:{src:j=>j[_.toLowerCase()].invitationSubscribable},initial:`unknown${_}Invitation`,states:{[`unknown${_}Invitation`]:{always:[{cond:j=>{var U,q;if(_!=="Space")return!1;{const G=(q=(U=j.space.invitation)==null?void 0:U.spaceKey)==null?void 0:q.toHex(),K=j.space.succeededKeys;return G?!!(K!=null&&K.has(G)):!1}},target:$,actions:"log"},{cond:j=>{const U=j[_.toLowerCase()].invitation;return!U||(U==null?void 0:U.state)===Invitation.State.CONNECTING},target:`connecting${_}Invitation`,actions:"log"},{target:`inputting${_}VerificationCode`,actions:"log"}]},[`connecting${_}Invitation`]:{},[`inputting${_}VerificationCode`]:{},[`authenticating${_}VerificationCode`]:{on:{[`readyForAuthentication${_}Invitation`]:{target:`authenticationFailing${_}VerificationCode`,actions:["setInvitation","log"]}}},[`authenticationFailing${_}VerificationCode`]:{},[`failing${_}Invitation`]:{},[`success${_}Invitation`]:{}},on:{[`reset${_}Invitation`]:{target:`#join${_==="Halo"?".choosingIdentity":""}.accepting${_}Invitation.unknown${_}`,actions:["resetInvitation","log"]},[`connecting${_}Invitation`]:{target:`.connecting${_}Invitation`,actions:["setInvitation","log"]},[`connected${_}Invitation`]:{target:`.connecting${_}Invitation`,actions:["setInvitation","log"]},[`readyForAuthentication${_}Invitation`]:{target:`.inputting${_}VerificationCode`,actions:["setInvitation","log"]},[`authenticating${_}Invitation`]:{target:`.authenticating${_}VerificationCode`,actions:["setInvitation","log"]},[`success${_}Invitation`]:{target:$,actions:["setInvitation","log"]},[`fail${_}Invitation`]:{target:`.failing${_}Invitation`,actions:[assign({[_.toLowerCase()]:(j,U)=>({...j[_.toLowerCase()],failReason:U.reason})}),"log"]}}}},on:{[`set${_}InvitationCode`]:{target:`.acceptingRedeemed${_}Invitation`,actions:[assign({[_.toLowerCase()]:(j,U)=>({...j[_.toLowerCase()],unredeemedCode:U.code,succeededKeys:U.succeededKeys})}),`redeem${_}InvitationCode`,`invalidate${_}InvitationCode`,"log"]}}}),joinMachine=createMachine({id:"join",predictableActionArguments:!0,context:{initialDisposition:"default",mode:"default",identity:null,halo:{},space:{}},initial:"unknown",states:{unknown:{always:[{cond:"existingIdentity",target:"resettingIdentity",actions:"log"},{cond:"initiallyAcceptingHaloInvitation",target:"#join.choosingIdentity.acceptingHaloInvitation",actions:"log"},{cond:"noSelectedIdentity",target:"choosingIdentity",actions:"log"},{target:"acceptingSpaceInvitation",actions:"log"}]},choosingIdentity:{initial:"unknownAuthMethod",states:{unknownAuthMethod:{always:[{cond:"hasHaloUnredeemedCode",target:"acceptingHaloInvitation",actions:"log"},{target:"choosingAuthMethod",actions:"log"}]},choosingAuthMethod:{},recoveringIdentity:{},creatingIdentity:{},acceptingHaloInvitation:acceptingInvitationTemplate("Halo","#join.acceptingSpaceInvitation"),confirmingAddedIdentity:{}},on:{recoverIdentity:{target:".recoveringIdentity",actions:"log"},createIdentity:{target:".creatingIdentity",actions:"log"},acceptHaloInvitation:{target:".acceptingHaloInvitation",actions:"log"},addIdentity:{target:".confirmingAddedIdentity",actions:"log"},selectIdentity:{target:"acceptingSpaceInvitation",actions:["setIdentity","log"]},deselectAuthMethod:{target:".choosingAuthMethod",actions:"log"}}},resettingIdentity:{},acceptingSpaceInvitation:acceptingInvitationTemplate("Space","#join.finishingJoiningSpace"),finishingJoiningSpace:{type:"final"},finishingJoiningHalo:{type:"final"}},on:{resetIdentity:{target:"choosingIdentity",actions:"unsetIdentity"}}},{guards:{existingIdentity:({identity:_,mode:$},I)=>$==="halo-only"&&!!_,noSelectedIdentity:({identity:_},$)=>!_,initiallyAcceptingHaloInvitation:({identity:_,initialDisposition:$},I)=>!_&&$==="accept-halo-invitation",hasHaloUnredeemedCode:({halo:_},$)=>!!_.unredeemedCode,noSpaceInvitation:({space:_},$)=>!_.invitation&&!_.unredeemedCode},actions:{setIdentity:assign({identity:(_,$)=>$.identity}),unsetIdentity:assign({identity:()=>null}),resetInvitation:assign({halo:(_,$)=>$.type!=="resetHaloInvitation"?_.halo:(_.halo.invitationObservable&&_.halo.invitationObservable.cancel(),{..._.halo,invitation:void 0,invitationObservable:void 0,invitationSubscribable:void 0}),space:(_,$)=>$.type!=="resetSpaceInvitation"?_.space:(_.space.invitationObservable&&_.space.invitationObservable.cancel(),{..._.space,invitation:void 0,invitationObservable:void 0,invitationSubscribable:void 0})}),setInvitation:assign({halo:(_,$)=>$.type.includes("Halo")?{..._.halo,invitation:$.invitation}:_.halo,space:(_,$)=>$.type.includes("Space")?{..._.space,invitation:$.invitation}:_.space}),log:(_,$)=>{log$2("[transition]",{event:$,haloInvitation:_.halo.invitation,spaceInvitation:_.space.invitation})}}}),defaultCodeFromUrl=(_,$)=>{try{const I=new URLSearchParams($.substring($.lastIndexOf("?")));return I.get(`${_}InvitationCode`)??I.get(`${_}Invitation`)??I.get("invitationCode")??I.get("invitation")??$}catch(I){return log$2.catch(I),$}},useJoinMachine=(_,$)=>{const I=React.useCallback(({halo:G})=>{if(G.unredeemedCode)try{const K=clientProtocol.InvitationEncoder.decode(defaultCodeFromUrl("halo",G.unredeemedCode)),Y=_.halo.join(K);return{...G,invitationObservable:Y,invitationSubscribable:getInvitationSubscribable("Halo",Y)}}catch(K){return log$2.error("Could not redeem device invitation code",K),G}else return G},[_]),j=React.useCallback(({space:G})=>{if(G.unredeemedCode)try{const K=clientProtocol.InvitationEncoder.decode(defaultCodeFromUrl("space",G.unredeemedCode)),Y=_.spaces.join(K);return{...G,invitationObservable:Y,invitationSubscribable:getInvitationSubscribable("Space",Y)}}catch(K){return log$2.error("Could not redeem space invitation code",K),G}else return G},[_]),U=React.useCallback(({halo:G})=>{var K;return G.unredeemedCode?((K=$==null?void 0:$.onInvalidateInvitationCode)==null||K.call($,G.unredeemedCode),{...G,unredeemedCode:void 0}):G},[$==null?void 0:$.onInvalidateInvitationCode]),q=React.useCallback(({space:G})=>{var K;return G.unredeemedCode?((K=$==null?void 0:$.onInvalidateInvitationCode)==null||K.call($,G.unredeemedCode),{...G,unredeemedCode:void 0}):G},[$==null?void 0:$.onInvalidateInvitationCode]);return useMachine(joinMachine,{...$,actions:{...$==null?void 0:$.actions,redeemHaloInvitationCode:assign({halo:I}),redeemSpaceInvitationCode:assign({space:j}),invalidateHaloInvitationCode:assign({halo:U}),invalidateSpaceInvitationCode:assign({space:q})}})},AdditionMethodChooser=_=>{const $=!_.active,{send:I}=_,{t:j}=useTranslation("os"),U={disabled:$,after:React.createElement(react.CaretRight,{className:getSize(4),weight:"bold"}),slots:{label:{className:"text-sm"}}};return React.createElement(React.Fragment,null,React.createElement(StepHeading,null,j("addition method chooser title")),React.createElement("div",{role:"none",className:"flex flex-col gap-1 grow"},React.createElement(CompoundButton,{...U,description:j("create identity description"),before:React.createElement(react.Plus,{className:getSize(6)}),onClick:()=>I({type:"createIdentity"}),"data-autofocus":"choosingAuthMethod","data-testid":"identity-chooser.create-identity"},j("create identity label")),React.createElement(CompoundButton,{...U,description:j("join identity description"),before:React.createElement(react.QrCode,{className:getSize(6)}),onClick:()=>I({type:"acceptHaloInvitation"}),"data-testid":"identity-chooser.join-identity"},j("join identity label")),React.createElement(CompoundButton,{...U,disabled:!0,description:j("recover identity description"),before:React.createElement(react.Textbox,{className:getSize(6)}),onClick:()=>I({type:"recoverIdentity"}),"data-testid":"identity-chooser.recover-identity"},j("recover identity label"))))},IdentityAdded=_=>{var ne,ie,oe,se,ae,fe;const{mode:$,addedIdentity:I,active:j,send:U,onDone:q,doneActionParent:G}=_,K=!j,{t:Y}=useTranslation("os"),J=(I==null?void 0:I.identityKey.toHex())??"0",X=hexToFallback(J),Z=useId("identityListItem__label"),Q=((ne=I==null?void 0:I.profile)==null?void 0:ne.displayName)??(I&&generateName(J)),ee=React.createElement(Action,{...q&&{onClick:()=>q(null)},disabled:K,"data-autofocus":"confirmingAddedIdentity","data-testid":"identity-added-done"},React.createElement("span",null,Y("done label")));return React.createElement(React.Fragment,null,React.createElement(StepHeading,null,Y("identity added label")),React.createElement("div",{role:"none",className:"grow flex flex-col items-center justify-center text-center gap-2"},React.createElement(Avatar.Root,{status:"active",labelId:Z,hue:((oe=(ie=I==null?void 0:I.profile)==null?void 0:ie.data)==null?void 0:oe.hue)||X.hue},React.createElement(Avatar.Frame,null,React.createElement(Avatar.Fallback,{text:((ae=(se=I==null?void 0:I.profile)==null?void 0:se.data)==null?void 0:ae.emoji)||X.emoji})),React.createElement(Avatar.Label,{classNames:mx("text-lg truncate",!((fe=I==null?void 0:I.profile)!=null&&fe.displayName)&&"font-mono")},Q))),React.createElement(Actions,null,$==="halo-only"?G?React.cloneElement(G,{},ee):ee:React.createElement(Action,{variant:"primary",disabled:K||!I,onClick:()=>I&&U({type:"selectIdentity",identity:I}),"data-autofocus":"confirmingAddedIdentity"},Y("continue label"))))},IdentityInput=_=>{const{send:$,method:I}=_,j=I==="recover identity",U=reactClient.useClient(),{t:q}=useTranslation("os"),[G,K]=React.useState(""),Y=J=>{U.halo.createIdentity({[j?"seedphrase":"displayName"]:J}).then(X=>{$==null||$({type:"selectIdentity",identity:X})},X=>{log$2.catch(X),K(q(j?"failed to recover identity message":"failed to create identity message"))})};return React.createElement(IdentityInputImpl,{..._,onDisplayNameConfirm:Y,validationMessage:G})},IdentityInputImpl=_=>{const{method:$,send:I,active:j,onDisplayNameConfirm:U,validationMessage:q}=_,G=!j,{t:K}=useTranslation("os"),[Y,J]=React.useState(""),X=$==="recover identity";return React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col justify-center"},React.createElement(Input,{validationMessage:q,label:React.createElement(StepHeading,null,K(X?"recover identity input label":"new identity input label")),disabled:G,"data-testid":"identity-input",placeholder:X?"Type your recovery phrase":"Type a display name",onChange:({target:{value:Z}})=>J(Z)})),React.createElement(Actions,null,React.createElement(Action,{variant:"ghost",disabled:G,onClick:()=>I==null?void 0:I({type:"deselectAuthMethod"}),"data-testid":`${$==="recover identity"?"recover":"create"}-identity-input-back`},K("back label")),React.createElement(Action,{variant:"primary",disabled:G,onClick:()=>U==null?void 0:U(Y),"data-testid":`${$==="recover identity"?"recover":"create"}-identity-input-continue`},K("continue label"))))},InvitationAccepted=_=>{const{active:$,Kind:I,doneActionParent:j,onDone:U}=_,q=!$,{t:G}=useTranslation("os"),K=React.createElement(Action,{variant:"primary",onClick:U,disabled:q,"data-autofocus":`success${I}Invitation finishingJoining${I}`,"data-testid":`${I.toLowerCase()}-invitation-accepted-done`},G("done label"));return React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col justify-center"},React.createElement("p",{className:"text-center text-sm font-normal"},G("welcome message"))),React.createElement(Actions,null,j?React.cloneElement(j,{},K):K))},invitationCodeFromUrl=_=>{try{const $=new URLSearchParams(_.substring(_.lastIndexOf("?")));return $.get("spaceInvitationCode")??$.get("deviceInvitationCode")??_}catch($){return log$2.catch($),_}},InvitationInput=_=>{const{Kind:$,active:I,send:j,unredeemedCode:U,onExit:q,exitActionParent:G,onDone:K,doneActionParent:Y,succeededKeys:J}=_,X=!I,{t:Z}=useTranslation("os"),[Q,ee]=React.useState(U??"");React.useEffect(()=>{U&&ee(U??"")},[U]);const ne=()=>{Q.trim().length!==0&&j({type:`set${$}InvitationCode`,code:invitationCodeFromUrl(Q),...$==="Space"&&{succeededKeys:J}})},ie=React.createElement(Action,{variant:"ghost",disabled:X,...q?{onClick:()=>q()}:{onClick:()=>K==null?void 0:K(null)},"data-testid":"join-exit"},Z("cancel label"));return React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col justify-center"},React.createElement(Input,{label:React.createElement(StepHeading,null,Z("invitation input label")),placeholder:"Type an invitation code",disabled:X,value:Q,onChange:({target:{value:oe}})=>ee(oe),"data-autofocus":`inputting${$}InvitationCode`,"data-testid":`${$.toLowerCase()}-invitation-input`,onKeyUp:({key:oe})=>oe==="Enter"&&ne()})),React.createElement(Actions,null,$==="Halo"?React.createElement(Action,{variant:"ghost",disabled:X,onClick:()=>j({type:"deselectAuthMethod"}),"data-testid":`${$.toLowerCase()}-invitation-input-back`},Z("back label")):G?React.cloneElement(G,{},ie):Y?React.cloneElement(Y,{},ie):ie,React.createElement(Action,{variant:"primary",disabled:X,onClick:ne,"data-testid":`${$.toLowerCase()}-invitation-input-continue`},Z("continue label"))))},InvitationActions=({invitationState:_,onInvitationCancel:$,active:I,send:j,Kind:U,failReason:q})=>{const{t:G}=useTranslation("os");return q?React.createElement(React.Fragment,null,React.createElement(StepHeading,{className:descriptionText},G(q==="timeout"?"timeout status label":q==="cancelled"?"cancelled status label":"error status label")),React.createElement("div",{role:"none",className:"grow"}),React.createElement(Actions,null,React.createElement(Action,{disabled:!I,onClick:()=>j({type:`reset${U}Invitation`}),"data-testid":"invitation-rescuer-reset"},G("reset label")))):React.createElement(React.Fragment,null,React.createElement(StepHeading,{className:descriptionText},G("connecting status label")),React.createElement("div",{role:"none",className:"grow"}),React.createElement(Actions,null,React.createElement(Action,{disabled:!0,classNames:"order-2","data-testid":"next"},G("next label")),React.createElement(Action,{disabled:!I,onClick:$,"data-testid":"invitation-rescuer-cancel"},G("cancel label"))))},InvitationRescuer=_=>{const{Kind:$,invitationState:I,active:j,send:U}=_,{t:q}=useTranslation("os");return React.createElement(React.Fragment,null,typeof I>"u"?React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col justify-center"},React.createElement(StepHeading,{className:descriptionText},"There was a problem joining the space")),React.createElement(Actions,null,React.createElement(Action,{disabled:!j,"data-testid":"invitation-rescuer-blank-reset",onClick:()=>U({type:`reset${$}Invitation`})},q("reset label")))):React.createElement(InvitationActions,{..._}))},pinLength=6,InvitationAuthenticator=({failed:_,Kind:$,active:I,pending:j,invitationId:U,onInvitationAuthenticate:q,onInvitationCancel:G})=>{const K=!I||j,{t:Y}=useTranslation("os"),J=$.toLowerCase(),[X,Z]=React.useState(""),Q=({target:{value:ee}})=>{var ne;Z(ee),ee.length===pinLength&&((ne=document.querySelector(`[data-autofocus-pinlength="${J}"]`))==null||ne.focus())};return React.createElement(React.Fragment,null,React.createElement("div",{role:"none",className:"grow flex flex-col justify-center gap-4"},React.createElement(Input$1.Root,{..._&&{validationValence:"error"}},React.createElement(Input$1.Label,{asChild:!0},React.createElement(StepHeading,null,Y("auth code input label"))),React.createElement(Input$1.PinInput,{disabled:K,length:pinLength,onChange:Q,inputMode:"numeric",autoComplete:"off",pattern:"\\d*","data-autofocus":`connecting${$}Invitation inputting${$}VerificationCode authenticationFailing${$}VerificationCode authenticating${$}VerificationCode`,"data-prevent-ios-autofocus":!0,"data-testid":`${J}-auth-code-input`,"data-1p-ignore":!0}),_&&React.createElement(Input$1.DescriptionAndValidation,{classNames:"text-center"},React.createElement(Input$1.Validation,null,Y("failed to authenticate message")))),U&&React.createElement(React.Fragment,null,React.createElement(Label,null,Y("auth other device emoji message")),React.createElement("div",{className:"flex justify-center"},React.createElement(Emoji,{text:hexToEmoji(U)})))),React.createElement(Actions,null,React.createElement(Action,{variant:"ghost",disabled:K,onClick:()=>G==null?void 0:G(),"data-testid":`${J}-invitation-authenticator-cancel`},Y("cancel label")),React.createElement(Action,{variant:"primary",disabled:K,onClick:()=>q==null?void 0:q(X),"data-autofocus-pinlength":J,"data-testid":`${J}-invitation-authenticator-next`},Y("next label"))))},stepStyles="pbs-1 pbe-3 pli-3",JoinPanelImpl=_=>{const{titleId:$,send:I,activeView:j,failed:U,mode:q,unredeemedCodes:G,invitationIds:K,invitationStates:Y,succeededKeys:J,failReasons:X,onExit:Z,onHaloDone:Q,onSpaceDone:ee,exitActionParent:ne,doneActionParent:ie,onHaloInvitationCancel:oe,onSpaceInvitationCancel:se,onHaloInvitationAuthenticate:ae,onSpaceInvitationAuthenticate:fe,onCancelResetStorage:le,onConfirmResetStorage:pe,IdentityInput:ue=IdentityInput,ConfirmReset:ve=ConfirmReset}=_;return React.createElement(DensityProvider,{density:"fine"},q!=="halo-only"&&React.createElement(JoinHeading,{titleId:$,mode:q,onExit:Z,exitActionParent:ne}),React.createElement(Viewport.Root,{focusManaged:!0,activeView:j},React.createElement(Viewport.Views,null,React.createElement(Viewport.View,{classNames:stepStyles,id:"addition method chooser"},React.createElement(AdditionMethodChooser,{send:I,active:j==="addition method chooser"})),React.createElement(Viewport.View,{classNames:stepStyles,id:"reset storage confirmation"},React.createElement(ve,{send:I,active:j==="reset storage confirmation",onCancel:le,onConfirm:pe})),React.createElement(Viewport.View,{classNames:stepStyles,id:"create identity input"},React.createElement(ue,{send:I,method:"create identity",active:j==="create identity input"})),React.createElement(Viewport.View,{classNames:stepStyles,id:"recover identity input"},React.createElement(ue,{send:I,method:"recover identity",active:j==="recover identity input"})),React.createElement(Viewport.View,{classNames:stepStyles,id:"halo invitation input"},React.createElement(InvitationInput,{send:I,Kind:"Halo",active:j==="halo invitation input",...(G==null?void 0:G.Halo)&&{unredeemedCode:G.Halo},...(J==null?void 0:J.Halo)&&{succeededKeys:J.Halo}})),React.createElement(Viewport.View,{classNames:stepStyles,id:"halo invitation rescuer"},React.createElement(InvitationRescuer,{send:I,Kind:"Halo",active:j==="halo invitation rescuer",invitationState:Y==null?void 0:Y.Halo,onInvitationCancel:oe,failReason:X==null?void 0:X.Halo})),React.createElement(Viewport.View,{classNames:stepStyles,id:"halo invitation authenticator"},React.createElement(InvitationAuthenticator,{send:I,Kind:"Halo",invitationId:K==null?void 0:K.Halo,active:j==="halo invitation authenticator",onInvitationCancel:oe,onInvitationAuthenticate:ae,...U.has("Halo")&&{failed:!0}})),React.createElement(Viewport.View,{classNames:stepStyles,id:"halo invitation accepted"},React.createElement(InvitationAccepted,{send:I,Kind:"Halo",active:j==="halo invitation accepted",doneActionParent:ie,onDone:Q})),React.createElement(Viewport.View,{classNames:stepStyles,id:"identity added"},React.createElement(IdentityAdded,{send:I,mode:q,active:j==="identity added",doneActionParent:ie,onDone:Q})),React.createElement(Viewport.View,{classNames:stepStyles,id:"space invitation input"},React.createElement(InvitationInput,{send:I,Kind:"Space",active:j==="space invitation input",...(G==null?void 0:G.Space)&&{unredeemedCode:G.Space},...(J==null?void 0:J.Space)&&{succeededKeys:J.Space},onExit:Z,exitActionParent:ne})),React.createElement(Viewport.View,{classNames:stepStyles,id:"space invitation rescuer"},React.createElement(InvitationRescuer,{send:I,Kind:"Space",active:j==="space invitation rescuer",invitationState:Y==null?void 0:Y.Space,onInvitationCancel:se,failReason:X==null?void 0:X.Space})),React.createElement(Viewport.View,{classNames:stepStyles,id:"space invitation authenticator"},React.createElement(InvitationAuthenticator,{send:I,Kind:"Space",invitationId:K==null?void 0:K.Space,active:j==="space invitation authenticator",onInvitationCancel:se,onInvitationAuthenticate:fe,...U.has("Space")&&{failed:!0}})),React.createElement(Viewport.View,{classNames:stepStyles,id:"space invitation accepted"},React.createElement(InvitationAccepted,{send:I,Kind:"Space",active:j==="space invitation accepted",doneActionParent:ie,onDone:ee})))))},JoinPanel=({titleId:_,mode:$="default",initialDisposition:I="default",initialInvitationCode:j,exitActionParent:U,onExit:q,doneActionParent:G,onDone:K,onCancelResetStorage:Y})=>{const J=reactClient.useClient(),X=halo.useIdentity(),{hasIosKeyboard:Z}=useThemeContext(),Q=useId("joinPanel__heading",_),[ee,ne,ie]=useJoinMachine(J,{context:{mode:$,initialDisposition:I,identity:X,...j&&{[$==="halo-only"?"halo":"space"]:{unredeemedCode:j}}}});React.useEffect(()=>ie.subscribe($e=>{log$2("[state]",$e)}).unsubscribe,[ie]),React.useEffect(()=>{const we=ee.configuration[0].id.split("."),$e=we[we.length-1],Me=$e==="finishingJoining"?"successSpaceInvitation":$e,Ie=document.querySelector(`[data-autofocus~="${Me}"]`);Ie&&!(Z&&Ie.hasAttribute("data-prevent-ios-autofocus"))&&Ie.focus()},[ee.value,Z]);const oe=React.useMemo(()=>{switch(!0){case ee.matches({choosingIdentity:"choosingAuthMethod"}):return"addition method chooser";case ee.matches("resettingIdentity"):return"reset storage confirmation";case ee.matches({choosingIdentity:"creatingIdentity"}):return"create identity input";case ee.matches({choosingIdentity:"recoveringIdentity"}):return"recover identity input";case ee.matches({choosingIdentity:{acceptingHaloInvitation:"inputtingHaloInvitationCode"}}):return"halo invitation input";case[{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"connectingHaloInvitation"}}},{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"failingHaloInvitation"}}}].some(ee.matches):return"halo invitation rescuer";case[{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"inputtingHaloVerificationCode"}}},{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"authenticatingHaloVerificationCode"}}},{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"authenticationFailingHaloVerificationCode"}}}].some(ee.matches):return"halo invitation authenticator";case[{choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"successHaloInvitation"}}},"finishingJoiningHalo"].some(ee.matches):return"halo invitation accepted";case ee.matches({choosingIdentity:"confirmingAddedIdentity"}):return"identity added";case ee.matches({acceptingSpaceInvitation:"inputtingSpaceInvitationCode"}):return"space invitation input";case[{acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"connectingSpaceInvitation"}},{acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"failingSpaceInvitation"}}].some(ee.matches):return"space invitation rescuer";case[{acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"inputtingSpaceVerificationCode"}},{acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"authenticatingSpaceVerificationCode"}},{acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"authenticationFailingSpaceVerificationCode"}}].some(ee.matches):return"space invitation authenticator";case ee.matches("finishingJoiningSpace"):return"space invitation accepted";default:return"never"}},[ee]),se=React.useMemo(()=>{const we=new Set;switch(!0){case ee.matches({choosingIdentity:{acceptingHaloInvitation:{acceptingRedeemedHaloInvitation:"authenticationFailingHaloVerificationCode"}}}):we.add("Halo");break;case ee.matches({acceptingSpaceInvitation:{acceptingRedeemedSpaceInvitation:"authenticationFailingSpaceVerificationCode"}}):we.add("Space");break}return we},[ee]),ae=React.useMemo(()=>({Halo:ee.context.halo.unredeemedCode,Space:ee.context.space.unredeemedCode}),[ee]),fe=reactClient.useMulticastObservable(J.spaces),le=React.useMemo(()=>({Space:fe?new Set(fe.map(({key:we})=>we.toHex())):void 0}),[fe]),pe=React.useMemo(()=>{var we,$e;return{Halo:(we=ee.context.halo.invitationObservable)==null?void 0:we.get().state,Space:($e=ee.context.space.invitationObservable)==null?void 0:$e.get().state}},[ee]),ue=React.useMemo(()=>{var we,$e;return{Halo:(we=ee.context.halo.invitationObservable)==null?void 0:we.get().invitationId,Space:($e=ee.context.space.invitationObservable)==null?void 0:$e.get().invitationId}},[ee]),ve=React.useMemo(()=>({Halo:ee.context.halo.failReason,Space:ee.context.space.failReason}),[ee]),ge=React.useCallback(()=>{var we,$e,Me,Ie;K==null||K({identityKey:((we=ee.context.halo.invitation)==null?void 0:we.identityKey)??null,swarmKey:(($e=ee.context.halo.invitation)==null?void 0:$e.swarmKey)??null,spaceKey:((Me=ee.context.halo.invitation)==null?void 0:Me.spaceKey)??null,target:((Ie=ee.context.halo.invitation)==null?void 0:Ie.target)??null})},[ee,K]),be=React.useCallback(()=>{var we,$e,Me,Ie;K==null||K({identityKey:((we=ee.context.space.invitation)==null?void 0:we.identityKey)??null,swarmKey:(($e=ee.context.space.invitation)==null?void 0:$e.swarmKey)??null,spaceKey:((Me=ee.context.space.invitation)==null?void 0:Me.spaceKey)??null,target:((Ie=ee.context.space.invitation)==null?void 0:Ie.target)??null})},[ee,K]),Re=React.useCallback(()=>J.reset().then(()=>{ne({type:"resetIdentity"})}),[J,ne]);return React.createElement(JoinPanelImpl,{titleId:Q,mode:$,send:ne,activeView:oe,failed:se,failReasons:ve,pending:["connecting","authenticating"].some(we=>ee==null?void 0:ee.configuration[0].id.includes(we)),unredeemedCodes:ae,invitationIds:ue,invitationStates:pe,succeededKeys:le,identity:X,onExit:q,exitActionParent:U,doneActionParent:G,onHaloDone:ge,onSpaceDone:be,onHaloInvitationCancel:()=>{var we;return(we=ee.context.halo.invitationObservable)==null?void 0:we.cancel()},onSpaceInvitationCancel:()=>{var we;return(we=ee.context.space.invitationObservable)==null?void 0:we.cancel()},onHaloInvitationAuthenticate:we=>{var $e;return ne({type:"authenticateHaloVerificationCode"}),($e=ee.context.halo.invitationObservable)==null?void 0:$e.authenticate(we)},onSpaceInvitationAuthenticate:we=>{var $e;return ne({type:"authenticateSpaceVerificationCode"}),($e=ee.context.space.invitationObservable)==null?void 0:$e.authenticate(we)},onConfirmResetStorage:Re,onCancelResetStorage:Y})},spaceMachine=createMachine({id:"space",predictableActionArguments:!0,context:{space:null},initial:"managingSpace",states:{managingSpace:{},managingSpaceInvitation:{}},on:{deselectInvitation:{target:".managingSpace",actions:["unsetInvitation","log"]},selectInvitation:{target:".managingSpaceInvitation",actions:["setInvitation","log"]}}},{actions:{setInvitation:assign({invitation:(_,$)=>($==null?void 0:$.invitation)??null}),unsetInvitation:assign({invitation:()=>{}}),log:(_,$)=>{log$2("[transition]",{event:$,context:_})}}}),useSpaceMachine=_=>useMachine(spaceMachine,{..._,context:{..._==null?void 0:_.context}}),activeActionKey="dxos:react-shell/space-manager/active-action",SpaceManager=_=>{const{space:$,target:I}=_,{t:j}=useTranslation("os"),U=reactClient.useConfig(),q=echo.useSpaceInvitations($==null?void 0:$.key),G=React.useCallback(Y=>{const J=clientProtocol.InvitationEncoder.encode(Y);Y.state===Invitation.State.CONNECTING&&log$2.info(JSON.stringify({invitationCode:J,authCode:Y.authCode}))},[]),K={inviteOne:{label:j("invite one label"),description:j("invite one description"),icon:react.UserPlus,onClick:React.useCallback(()=>{var J,X,Z,Q;const Y=(J=$.share)==null?void 0:J.call($,{type:Invitation.Type.INTERACTIVE,authMethod:Invitation.AuthMethod.SHARED_SECRET,multiUse:!1,target:I});Y&&((Q=(Z=(X=U.values.runtime)==null?void 0:X.app)==null?void 0:Z.env)==null?void 0:Q.DX_ENVIRONMENT)!=="production"&&Y.subscribe(G)},[$])},inviteMany:{label:j("invite many label"),description:j("invite many description"),icon:react.UsersThree,onClick:React.useCallback(()=>{var J,X,Z,Q;const Y=(J=$.share)==null?void 0:J.call($,{type:Invitation.Type.DELEGATED,authMethod:Invitation.AuthMethod.KNOWN_PUBLIC_KEY,multiUse:!0,target:I});Y&&((Q=(Z=(X=U.values.runtime)==null?void 0:X.app)==null?void 0:Z.env)==null?void 0:Q.DX_ENVIRONMENT)!=="production"&&Y.subscribe(G)},[$])}};return React.createElement(SpaceManagerImpl,{..._,invitations:q,inviteActions:K})},headingFragment="pis-3 pie-1 plb-1 mbe-1 font-medium",SpaceManagerImpl=_=>{const{active:$,space:I,createInvitationUrl:j,send:U,inviteActions:q,invitations:G,showInactiveInvitations:K,SpaceMemberList:Y=SpaceMemberList,InvitationList:J=InvitationList}=_,{t:X}=useTranslation("os"),Z=q??{noopInvite:{label:X("create space invitation label"),description:"",icon:react.Placeholder,onClick:()=>{}}},[Q,ee]=React.useState(localStorage.getItem(activeActionKey)??"inviteOne"),ne=oe=>{ee(oe),localStorage.setItem(activeActionKey,oe)},ie=K?G:G==null?void 0:G.filter(oe=>![Invitation.State.CANCELLED].includes(oe.get().state));return React.createElement(React.Fragment,null,React.createElement(ScrollArea.Root,{classNames:"grow shrink basis-28 -mli-2"},React.createElement(ScrollArea.Viewport,{classNames:"is-full pie-2"},!!(ie!=null&&ie.length)&&React.createElement(React.Fragment,null,React.createElement("h3",{className:mx(headingFragment,descriptionText)},X("invitation list heading")),React.createElement(J,{className:"mb-2",send:U,invitations:ie??[],onClickRemove:oe=>oe.cancel(),createInvitationUrl:j}),React.createElement("h3",{className:mx(headingFragment,descriptionText,"mbs-2")},X("space member list heading"))),React.createElement(Y,{spaceKey:I.key,includeSelf:!0})),React.createElement(ScrollArea.Scrollbar,{orientation:"vertical"},React.createElement(ScrollArea.Thumb,null))),React.createElement(Actions,null,React.createElement(BifurcatedAction,{disabled:!$,actions:Z,activeAction:Q,onChangeActiveAction:ne,"data-testid":"spaces-panel.create-invitation"})))},SpacePanelHeading=({titleId:_,space:$,onDone:I})=>{const{t:j}=useTranslation("os"),U=$.properties.name;return React.createElement(Heading,{titleId:_,title:j("space panel heading"),corner:React.createElement(CloseButton,{"data-testid":"identity-panel-done",onDone:I})},React.createElement("div",{role:"none",className:"flex gap-4 items-center justify-center mlb-4"},React.createElement(react.Planet,{size:32,weight:"light"}),React.createElement("div",{className:"block text-start font-light text-xl"},U??$.key.truncate())))},SpacePanelImpl=_=>{const{titleId:$,activeView:I,space:j,target:U,SpaceManager:q=SpaceManager,InvitationManager:G=InvitationManager,...K}=_;return React.createElement(DensityProvider,{density:"fine"},React.createElement(SpacePanelHeading,{...K,titleId:$,space:j}),React.createElement(Viewport.Root,{activeView:I},React.createElement(Viewport.Views,null,React.createElement(Viewport.View,{id:"space manager",classNames:stepStyles},React.createElement(q,{active:I==="space manager",space:j,target:U,...K})),React.createElement(Viewport.View,{id:"space invitation manager",classNames:stepStyles},React.createElement(G,{active:I==="space invitation manager",...K,invitationUrl:_.invitationUrl})))))},SpacePanelWithInvitationImpl=({invitation:_,...$})=>{const I=useInvitationStatus(_);return React.createElement(SpacePanelImpl,{...$,...I,invitationUrl:$.createInvitationUrl(I.invitationCode)})},SpacePanel=({titleId:_,createInvitationUrl:$=j=>j,...I})=>{const j=useId("spacePanel__heading",_),[U,q,G]=useSpaceMachine({context:{space:I.space}});React.useEffect(()=>G.subscribe(X=>{log$2("[state]",X)}).unsubscribe,[G]);const K=React.useMemo(()=>{switch(!0){case U.matches("managingSpace"):return"space manager";case U.matches("managingSpaceInvitation"):return"space invitation manager";default:return"never"}},[U]),Y={...I,activeView:K,send:q,titleId:j,createInvitationUrl:$};return U.context.invitation?React.createElement(SpacePanelWithInvitationImpl,{...Y,invitation:U.context.invitation}):React.createElement(SpacePanelImpl,{...Y})},StatusPanel=({titleId:_})=>{const{t:$}=useTranslation("os");return React.createElement("div",{className:"grid place-items-center p-2 gap-2"},React.createElement("p",{id:_,className:"font-medium text-center"},$("resetting message")),React.createElement(Status,{indeterminate:!0},$("resetting message")))},IdentityDialog=_=>{const $=useId("identityDialog__title",_.title);return React.createElement(Dialog.Root,{defaultOpen:!0,onOpenChange:I=>{var j;return I||((j=_.onDone)==null?void 0:j.call(_))}},React.createElement(Dialog.Portal,null,React.createElement(Dialog.Overlay,null,React.createElement(Dialog.Content,{"aria-labelledby":$,onOpenAutoFocus:I=>I.preventDefault()},React.createElement(ClipboardProvider,null,React.createElement(IdentityPanel,{..._,titleId:$,doneActionParent:React.createElement(Dialog.Close,{asChild:!0})}))))))},JoinDialog=_=>{const $=useId("joinDialog__title"),{height:I}=useVisualViewport();return React.createElement(AlertDialog.Root,{defaultOpen:!0,onOpenChange:j=>{var U;return j||(_.onExit?_.onExit():(U=_.onDone)==null?void 0:U.call(_,null))}},React.createElement(AlertDialog.Portal,null,React.createElement(AlertDialog.Overlay,{classNames:"backdrop-blur",...I&&{style:{blockSize:`${I}px`}}},React.createElement(AlertDialog.Content,{"aria-labelledby":$},React.createElement(JoinPanel,{..._,titleId:$,exitActionParent:React.createElement(AlertDialog.Cancel,{asChild:!0}),doneActionParent:React.createElement(AlertDialog.Action,{asChild:!0})})))))};var createRoot,m=$7SXl2$reactdom;if(process.env.NODE_ENV==="production")createRoot=m.createRoot,m.hydrateRoot;else{var i=m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;createRoot=function(_,$){i.usingClientEntryPoint=!0;try{return m.createRoot(_,$)}finally{i.usingClientEntryPoint=!1}}}var uaParser={exports:{}};(function(_,$){(function(I,j){var U="1.0.35",q="",G="?",K="function",Y="undefined",J="object",X="string",Z="major",Q="model",ee="name",ne="type",ie="vendor",oe="version",se="architecture",ae="console",fe="mobile",le="tablet",pe="smarttv",ue="wearable",ve="embedded",ge=350,be="Amazon",Re="Apple",we="ASUS",$e="BlackBerry",Me="Browser",Ie="Chrome",Be="Edge",We="Firefox",Ke="Google",Je="Huawei",qe="LG",Ze="Microsoft",Ge="Motorola",Ne="Opera",De="Samsung",He="Sharp",tt="Sony",Pe="Xiaomi",Le="Zebra",Se="Facebook",xe="Chromium OS",Ee="Mac OS",he=function(ot,bt){var ce={};for(var te in ot)bt[te]&&bt[te].length%2===0?ce[te]=bt[te].concat(ot[te]):ce[te]=ot[te];return ce},me=function(ot){for(var bt={},ce=0;ce<ot.length;ce++)bt[ot[ce].toUpperCase()]=ot[ce];return bt},Ae=function(ot,bt){return typeof ot===X?Ue(bt).indexOf(Ue(ot))!==-1:!1},Ue=function(ot){return ot.toLowerCase()},Ye=function(ot){return typeof ot===X?ot.replace(/[^\d\.]/g,q).split(".")[0]:j},Qe=function(ot,bt){if(typeof ot===X)return ot=ot.replace(/^\s\s*/,q),typeof bt===Y?ot:ot.substring(0,ge)},nt=function(ot,bt){for(var ce=0,te,re,de,_e,ke,Oe;ce<bt.length&&!ke;){var rt=bt[ce],pt=bt[ce+1];for(te=re=0;te<rt.length&&!ke&&rt[te];)if(ke=rt[te++].exec(ot),ke)for(de=0;de<pt.length;de++)Oe=ke[++re],_e=pt[de],typeof _e===J&&_e.length>0?_e.length===2?typeof _e[1]==K?this[_e[0]]=_e[1].call(this,Oe):this[_e[0]]=_e[1]:_e.length===3?typeof _e[1]===K&&!(_e[1].exec&&_e[1].test)?this[_e[0]]=Oe?_e[1].call(this,Oe,_e[2]):j:this[_e[0]]=Oe?Oe.replace(_e[1],_e[2]):j:_e.length===4&&(this[_e[0]]=Oe?_e[3].call(this,Oe.replace(_e[1],_e[2])):j):this[_e]=Oe||j;ce+=2}},it=function(ot,bt){for(var ce in bt)if(typeof bt[ce]===J&&bt[ce].length>0){for(var te=0;te<bt[ce].length;te++)if(Ae(bt[ce][te],ot))return ce===G?j:ce}else if(Ae(bt[ce],ot))return ce===G?j:ce;return ot},Ve={"1.0":"/8","1.2":"/1","1.3":"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"},ht={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2","8.1":"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},Et={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[oe,[ee,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[oe,[ee,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[ee,oe],[/opios[\/ ]+([\w\.]+)/i],[oe,[ee,Ne+" Mini"]],[/\bopr\/([\w\.]+)/i],[oe,[ee,Ne]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[ee,oe],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[oe,[ee,"UC"+Me]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[oe,[ee,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[oe,[ee,"WeChat"]],[/konqueror\/([\w\.]+)/i],[oe,[ee,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[oe,[ee,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[oe,[ee,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[ee,/(.+)/,"$1 Secure "+Me],oe],[/\bfocus\/([\w\.]+)/i],[oe,[ee,We+" Focus"]],[/\bopt\/([\w\.]+)/i],[oe,[ee,Ne+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[oe,[ee,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[oe,[ee,"Dolphin"]],[/coast\/([\w\.]+)/i],[oe,[ee,Ne+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[oe,[ee,"MIUI "+Me]],[/fxios\/([-\w\.]+)/i],[oe,[ee,We]],[/\bqihu|(qi?ho?o?|360)browser/i],[[ee,"360 "+Me]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[ee,/(.+)/,"$1 "+Me],oe],[/(comodo_dragon)\/([\w\.]+)/i],[[ee,/_/g," "],oe],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[ee,oe],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[ee],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[ee,Se],oe],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[ee,oe],[/\bgsa\/([\w\.]+) .*safari\//i],[oe,[ee,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[oe,[ee,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[oe,[ee,Ie+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[ee,Ie+" WebView"],oe],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[oe,[ee,"Android "+Me]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[ee,oe],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[oe,[ee,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[oe,ee],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[ee,[oe,it,Ve]],[/(webkit|khtml)\/([\w\.]+)/i],[ee,oe],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[ee,"Netscape"],oe],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[oe,[ee,We+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[ee,oe],[/(cobalt)\/([\w\.]+)/i],[ee,[oe,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[se,"amd64"]],[/(ia32(?=;))/i],[[se,Ue]],[/((?:i[346]|x)86)[;\)]/i],[[se,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[se,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[se,"armhf"]],[/windows (ce|mobile); ppc;/i],[[se,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[se,/ower/,q,Ue]],[/(sun4\w)[;\)]/i],[[se,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[se,Ue]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[Q,[ie,De],[ne,le]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[Q,[ie,De],[ne,fe]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[Q,[ie,Re],[ne,fe]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[Q,[ie,Re],[ne,le]],[/(macintosh);/i],[Q,[ie,Re]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[Q,[ie,He],[ne,fe]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[Q,[ie,Je],[ne,le]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[Q,[ie,Je],[ne,fe]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[Q,/_/g," "],[ie,Pe],[ne,fe]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[Q,/_/g," "],[ie,Pe],[ne,le]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[Q,[ie,"OPPO"],[ne,fe]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[Q,[ie,"Vivo"],[ne,fe]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[Q,[ie,"Realme"],[ne,fe]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[Q,[ie,Ge],[ne,fe]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[Q,[ie,Ge],[ne,le]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[Q,[ie,qe],[ne,le]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[Q,[ie,qe],[ne,fe]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[Q,[ie,"Lenovo"],[ne,le]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[Q,/_/g," "],[ie,"Nokia"],[ne,fe]],[/(pixel c)\b/i],[Q,[ie,Ke],[ne,le]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[Q,[ie,Ke],[ne,fe]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[Q,[ie,tt],[ne,fe]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[Q,"Xperia Tablet"],[ie,tt],[ne,le]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[Q,[ie,"OnePlus"],[ne,fe]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[Q,[ie,be],[ne,le]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[Q,/(.+)/g,"Fire Phone $1"],[ie,be],[ne,fe]],[/(playbook);[-\w\),; ]+(rim)/i],[Q,ie,[ne,le]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[Q,[ie,$e],[ne,fe]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[Q,[ie,we],[ne,le]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[Q,[ie,we],[ne,fe]],[/(nexus 9)/i],[Q,[ie,"HTC"],[ne,le]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[ie,[Q,/_/g," "],[ne,fe]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[Q,[ie,"Acer"],[ne,le]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[Q,[ie,"Meizu"],[ne,fe]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[ie,Q,[ne,fe]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[ie,Q,[ne,le]],[/(surface duo)/i],[Q,[ie,Ze],[ne,le]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[Q,[ie,"Fairphone"],[ne,fe]],[/(u304aa)/i],[Q,[ie,"AT&T"],[ne,fe]],[/\bsie-(\w*)/i],[Q,[ie,"Siemens"],[ne,fe]],[/\b(rct\w+) b/i],[Q,[ie,"RCA"],[ne,le]],[/\b(venue[\d ]{2,7}) b/i],[Q,[ie,"Dell"],[ne,le]],[/\b(q(?:mv|ta)\w+) b/i],[Q,[ie,"Verizon"],[ne,le]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[Q,[ie,"Barnes & Noble"],[ne,le]],[/\b(tm\d{3}\w+) b/i],[Q,[ie,"NuVision"],[ne,le]],[/\b(k88) b/i],[Q,[ie,"ZTE"],[ne,le]],[/\b(nx\d{3}j) b/i],[Q,[ie,"ZTE"],[ne,fe]],[/\b(gen\d{3}) b.+49h/i],[Q,[ie,"Swiss"],[ne,fe]],[/\b(zur\d{3}) b/i],[Q,[ie,"Swiss"],[ne,le]],[/\b((zeki)?tb.*\b) b/i],[Q,[ie,"Zeki"],[ne,le]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[ie,"Dragon Touch"],Q,[ne,le]],[/\b(ns-?\w{0,9}) b/i],[Q,[ie,"Insignia"],[ne,le]],[/\b((nxa|next)-?\w{0,9}) b/i],[Q,[ie,"NextBook"],[ne,le]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[ie,"Voice"],Q,[ne,fe]],[/\b(lvtel\-)?(v1[12]) b/i],[[ie,"LvTel"],Q,[ne,fe]],[/\b(ph-1) /i],[Q,[ie,"Essential"],[ne,fe]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[Q,[ie,"Envizen"],[ne,le]],[/\b(trio[-\w\. ]+) b/i],[Q,[ie,"MachSpeed"],[ne,le]],[/\btu_(1491) b/i],[Q,[ie,"Rotor"],[ne,le]],[/(shield[\w ]+) b/i],[Q,[ie,"Nvidia"],[ne,le]],[/(sprint) (\w+)/i],[ie,Q,[ne,fe]],[/(kin\.[onetw]{3})/i],[[Q,/\./g," "],[ie,Ze],[ne,fe]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[Q,[ie,Le],[ne,le]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[Q,[ie,Le],[ne,fe]],[/smart-tv.+(samsung)/i],[ie,[ne,pe]],[/hbbtv.+maple;(\d+)/i],[[Q,/^/,"SmartTV"],[ie,De],[ne,pe]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[ie,qe],[ne,pe]],[/(apple) ?tv/i],[ie,[Q,Re+" TV"],[ne,pe]],[/crkey/i],[[Q,Ie+"cast"],[ie,Ke],[ne,pe]],[/droid.+aft(\w)( bui|\))/i],[Q,[ie,be],[ne,pe]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[Q,[ie,He],[ne,pe]],[/(bravia[\w ]+)( bui|\))/i],[Q,[ie,tt],[ne,pe]],[/(mitv-\w{5}) bui/i],[Q,[ie,Pe],[ne,pe]],[/Hbbtv.*(technisat) (.*);/i],[ie,Q,[ne,pe]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[ie,Qe],[Q,Qe],[ne,pe]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[ne,pe]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[ie,Q,[ne,ae]],[/droid.+; (shield) bui/i],[Q,[ie,"Nvidia"],[ne,ae]],[/(playstation [345portablevi]+)/i],[Q,[ie,tt],[ne,ae]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[Q,[ie,Ze],[ne,ae]],[/((pebble))app/i],[ie,Q,[ne,ue]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[Q,[ie,Re],[ne,ue]],[/droid.+; (glass) \d/i],[Q,[ie,Ke],[ne,ue]],[/droid.+; (wt63?0{2,3})\)/i],[Q,[ie,Le],[ne,ue]],[/(quest( 2| pro)?)/i],[Q,[ie,Se],[ne,ue]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[ie,[ne,ve]],[/(aeobc)\b/i],[Q,[ie,be],[ne,ve]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[Q,[ne,fe]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[Q,[ne,le]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[ne,le]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[ne,fe]],[/(android[-\w\. ]{0,9});.+buil/i],[Q,[ie,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[oe,[ee,Be+"HTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[oe,[ee,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[ee,oe],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[oe,ee]],os:[[/microsoft (windows) (vista|xp)/i],[ee,oe],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[ee,[oe,it,ht]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[ee,"Windows"],[oe,it,ht]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[oe,/_/g,"."],[ee,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[ee,Ee],[oe,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[oe,ee],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[ee,oe],[/\(bb(10);/i],[oe,[ee,$e]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[oe,[ee,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[oe,[ee,We+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[oe,[ee,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[oe,[ee,"watchOS"]],[/crkey\/([\d\.]+)/i],[oe,[ee,Ie+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[ee,xe],oe],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[ee,oe],[/(sunos) ?([\w\.\d]*)/i],[[ee,"Solaris"],oe],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[ee,oe]]},lt=function(ot,bt){if(typeof ot===J&&(bt=ot,ot=j),!(this instanceof lt))return new lt(ot,bt).getResult();var ce=typeof I!==Y&&I.navigator?I.navigator:j,te=ot||(ce&&ce.userAgent?ce.userAgent:q),re=ce&&ce.userAgentData?ce.userAgentData:j,de=bt?he(Et,bt):Et,_e=ce&&ce.userAgent==te;return this.getBrowser=function(){var ke={};return ke[ee]=j,ke[oe]=j,nt.call(ke,te,de.browser),ke[Z]=Ye(ke[oe]),_e&&ce&&ce.brave&&typeof ce.brave.isBrave==K&&(ke[ee]="Brave"),ke},this.getCPU=function(){var ke={};return ke[se]=j,nt.call(ke,te,de.cpu),ke},this.getDevice=function(){var ke={};return ke[ie]=j,ke[Q]=j,ke[ne]=j,nt.call(ke,te,de.device),_e&&!ke[ne]&&re&&re.mobile&&(ke[ne]=fe),_e&&ke[Q]=="Macintosh"&&ce&&typeof ce.standalone!==Y&&ce.maxTouchPoints&&ce.maxTouchPoints>2&&(ke[Q]="iPad",ke[ne]=le),ke},this.getEngine=function(){var ke={};return ke[ee]=j,ke[oe]=j,nt.call(ke,te,de.engine),ke},this.getOS=function(){var ke={};return ke[ee]=j,ke[oe]=j,nt.call(ke,te,de.os),_e&&!ke[ee]&&re&&re.platform!="Unknown"&&(ke[ee]=re.platform.replace(/chrome os/i,xe).replace(/macos/i,Ee)),ke},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return te},this.setUA=function(ke){return te=typeof ke===X&&ke.length>ge?Qe(ke,ge):ke,this},this.setUA(te),this};lt.VERSION=U,lt.BROWSER=me([ee,oe,Z]),lt.CPU=me([se]),lt.DEVICE=me([Q,ie,ne,ae,fe,pe,le,ue,ve]),lt.ENGINE=lt.OS=me([ee,oe]),_.exports&&($=_.exports=lt),$.UAParser=lt;var yt=typeof I!==Y&&(I.jQuery||I.Zepto);if(yt&&!yt.ua){var St=new lt;yt.ua=St.getResult(),yt.ua.get=function(){return St.getUA()},yt.ua.set=function(ot){St.setUA(ot);var bt=St.getResult();for(var ce in bt)yt.ua[ce]=bt[ce]}}})(typeof window=="object"?window:commonjsGlobal)})(uaParser,uaParser.exports);var uaParserExports=uaParser.exports,__dxlog_file$1="/home/runner/work/dxos/dxos/packages/core/mesh/rpc-tunnel/src/ports/iframe.ts",browser,os$1;if(typeof navigator<"u"){const _=new uaParserExports.UAParser(navigator.userAgent);browser=_.getBrowser().name,os$1=_.getOS().name}var sendToIFrame=(_,$,I)=>{if(!_.contentWindow){log$2("IFrame content window missing",{origin:$},{F:__dxlog_file$1,L:24,S:void 0,C:(j,U)=>j(...U)});return}browser==="Chrome"&&os$1==="iOS"?_.contentWindow.postMessage(I,$):_.contentWindow.postMessage(I,$,[I.payload])},sendToParentWindow=(_,$)=>{browser==="Chrome"&&os$1==="iOS"?window.parent.postMessage($,_):window.parent.postMessage($,_,[$.payload])},createIFramePort=({channel:_,iframe:$,origin:I,onOrigin:j})=>({send:async U=>{if(!I){log$2("no origin set",{channel:_},{F:__dxlog_file$1,L:62,S:void 0,C:(K,Y)=>K(...Y)});return}log$2("sending",{channel:_,data:U.length},{F:__dxlog_file$1,L:66,S:void 0,C:(K,Y)=>K(...Y)});const q=U.buffer.slice(U.byteOffset,U.byteOffset+U.byteLength),G={channel:_,payload:q};$?sendToIFrame($,I,G):sendToParentWindow(I,G)},subscribe:U=>{const q=G=>{if(!$&&G.source!==window.parent)return;if($&&G.source!==$.contentWindow)return;const Y=G.data&&typeof G.data=="object"&&"channel"in G.data&&"payload"in G.data?G.data:void 0;(Y==null?void 0:Y.channel)===_&&(I||(I=G.origin,j==null||j(I)),log$2("received",Y,{F:__dxlog_file$1,L:98,S:void 0,C:(J,X)=>J(...X)}),U(new Uint8Array(Y.payload)))};return window.addEventListener("message",q),()=>window.removeEventListener("message",q)}});const SpaceDialog=_=>{const $=useId("spaceDialog__title");return React.createElement(Dialog.Root,{defaultOpen:!0,onOpenChange:I=>{var j;return I||((j=_.onDone)==null?void 0:j.call(_))}},React.createElement(Dialog.Portal,null,React.createElement(Dialog.Overlay,null,React.createElement(Dialog.Content,{"aria-labelledby":$},React.createElement(ClipboardProvider,null,React.createElement(SpacePanel,{..._,titleId:$,doneActionParent:React.createElement(Dialog.Close,{asChild:!0})}))))))},StatusDialog=()=>{const _=useId("statusDialog__title");return React.createElement(AlertDialog.Root,{open:!0},React.createElement(AlertDialog.Portal,null,React.createElement(AlertDialog.Overlay,null,React.createElement(AlertDialog.Content,{"aria-labelledby":_},React.createElement(StatusPanel,{titleId:_})))))},Shell=({runtime:_})=>{const[{layout:$,invitationCode:I,spaceKey:j,spaceId:U,target:q},G]=React.useState({layout:_.layout,invitationCode:_.invitationCode,spaceKey:_.spaceKey,spaceId:_.spaceId,target:_.target}),[{invitationUrl:K,deviceInvitationParam:Y,spaceInvitationParam:J},X]=React.useState({invitationUrl:_.invitationUrl,deviceInvitationParam:_.deviceInvitationParam,spaceInvitationParam:_.spaceInvitationParam}),Z=reactClient.useClient(),Q=echo.useSpace(j??U),ee=ie=>{const oe=new URL(K);return oe.searchParams.set(Y,ie),oe.toString()},ne=ie=>{const oe=new URL(K);return oe.searchParams.set(J,ie),oe.toString()};switch(React.useEffect(()=>{const ie=_.layoutUpdate.on(se=>G(se)),oe=_.invitationUrlUpdate.on(se=>X(se));return()=>{ie(),oe()}},[_]),React.useEffect(()=>{if($===reactClient.ShellLayout.SPACE&&!Q){log$2.warn("No space found for shell space invitations.");const ie=setTimeout(async()=>{await _.setAppContext({display:reactClient.ShellDisplay.NONE}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})});return()=>clearTimeout(ie)}},[_,$,Q]),$){case reactClient.ShellLayout.STATUS:return React.createElement(StatusDialog,null);case reactClient.ShellLayout.INITIALIZE_IDENTITY:case reactClient.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION:return React.createElement(JoinDialog,{mode:"halo-only",initialDisposition:$===reactClient.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION?"accept-halo-invitation":"default",initialInvitationCode:I,onCancelResetStorage:()=>_.setLayout({layout:reactClient.ShellLayout.IDENTITY}),onDone:()=>{_.setAppContext({display:reactClient.ShellDisplay.NONE}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})}});case reactClient.ShellLayout.IDENTITY:case reactClient.ShellLayout.SHARE_IDENTITY:case reactClient.ShellLayout.EDIT_PROFILE:return React.createElement(IdentityDialog,{createInvitationUrl:ee,onResetStorage:async()=>(_.setLayout({layout:reactClient.ShellLayout.STATUS}),await Z.reset(),_.setAppContext({display:reactClient.ShellDisplay.NONE,reload:!0})),onJoinNewIdentity:async()=>(_.setLayout({layout:reactClient.ShellLayout.STATUS}),await Z.reset(),_.setLayout({layout:reactClient.ShellLayout.INITIALIZE_IDENTITY_FROM_INVITATION})),onDone:async()=>{await _.setAppContext({display:reactClient.ShellDisplay.NONE}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})},initialDisposition:$===reactClient.ShellLayout.SHARE_IDENTITY?"manage-device-invitation":"default"});case reactClient.ShellLayout.SPACE:return Q?React.createElement(SpaceDialog,{space:Q,target:q,createInvitationUrl:ne,onDone:async()=>{await _.setAppContext({display:reactClient.ShellDisplay.NONE}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})}}):null;case reactClient.ShellLayout.JOIN_SPACE:return React.createElement(JoinDialog,{initialInvitationCode:I,onDone:async ie=>{const oe=(ie==null?void 0:ie.target)??void 0;await _.setAppContext({display:reactClient.ShellDisplay.NONE,spaceKey:(ie==null?void 0:ie.spaceKey)??void 0,target:oe}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})},onExit:async()=>{await _.setAppContext({display:reactClient.ShellDisplay.NONE}),_.setLayout({layout:reactClient.ShellLayout.DEFAULT})}});default:return null}};var ShellDisplay;(function(_){_[_.NONE=0]="NONE",_[_.FULLSCREEN=1]="FULLSCREEN"})(ShellDisplay||(ShellDisplay={}));var ShellLayout;(function(_){_[_.DEFAULT=0]="DEFAULT",_[_.INITIALIZE_IDENTITY=1]="INITIALIZE_IDENTITY",_[_.INITIALIZE_IDENTITY_FROM_INVITATION=2]="INITIALIZE_IDENTITY_FROM_INVITATION",_[_.IDENTITY=3]="IDENTITY",_[_.SHARE_IDENTITY=4]="SHARE_IDENTITY",_[_.EDIT_PROFILE=5]="EDIT_PROFILE",_[_.SPACE=6]="SPACE",_[_.JOIN_SPACE=7]="JOIN_SPACE",_[_.STATUS=8]="STATUS"})(ShellLayout||(ShellLayout={}));var indexLight={exports:{}},indexMinimal={},minimal={},aspromise=asPromise$1;function asPromise$1(_,$){for(var I=new Array(arguments.length-1),j=0,U=2,q=!0;U<arguments.length;)I[j++]=arguments[U++];return new Promise(function(K,Y){I[j]=function(X){if(q)if(q=!1,X)Y(X);else{for(var Z=new Array(arguments.length-1),Q=0;Q<Z.length;)Z[Q++]=arguments[Q];K.apply(null,Z)}};try{_.apply($||null,I)}catch(J){q&&(q=!1,Y(J))}})}var base64$1={};(function(_){var $=_;$.length=function(K){var Y=K.length;if(!Y)return 0;for(var J=0;--Y%4>1&&K.charAt(Y)==="=";)++J;return Math.ceil(K.length*3)/4-J};for(var I=new Array(64),j=new Array(123),U=0;U<64;)j[I[U]=U<26?U+65:U<52?U+71:U<62?U-4:U-59|43]=U++;$.encode=function(K,Y,J){for(var X=null,Z=[],Q=0,ee=0,ne;Y<J;){var ie=K[Y++];switch(ee){case 0:Z[Q++]=I[ie>>2],ne=(ie&3)<<4,ee=1;break;case 1:Z[Q++]=I[ne|ie>>4],ne=(ie&15)<<2,ee=2;break;case 2:Z[Q++]=I[ne|ie>>6],Z[Q++]=I[ie&63],ee=0;break}Q>8191&&((X||(X=[])).push(String.fromCharCode.apply(String,Z)),Q=0)}return ee&&(Z[Q++]=I[ne],Z[Q++]=61,ee===1&&(Z[Q++]=61)),X?(Q&&X.push(String.fromCharCode.apply(String,Z.slice(0,Q))),X.join("")):String.fromCharCode.apply(String,Z.slice(0,Q))};var q="invalid encoding";$.decode=function(K,Y,J){for(var X=J,Z=0,Q,ee=0;ee<K.length;){var ne=K.charCodeAt(ee++);if(ne===61&&Z>1)break;if((ne=j[ne])===void 0)throw Error(q);switch(Z){case 0:Q=ne,Z=1;break;case 1:Y[J++]=Q<<2|(ne&48)>>4,Q=ne,Z=2;break;case 2:Y[J++]=(Q&15)<<4|(ne&60)>>2,Q=ne,Z=3;break;case 3:Y[J++]=(Q&3)<<6|ne,Z=0;break}}if(Z===1)throw Error(q);return J-X},$.test=function(K){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(K)}})(base64$1);var eventemitter=EventEmitter;function EventEmitter(){this._listeners={}}EventEmitter.prototype.on=function($,I,j){return(this._listeners[$]||(this._listeners[$]=[])).push({fn:I,ctx:j||this}),this},EventEmitter.prototype.off=function($,I){if($===void 0)this._listeners={};else if(I===void 0)this._listeners[$]=[];else for(var j=this._listeners[$],U=0;U<j.length;)j[U].fn===I?j.splice(U,1):++U;return this},EventEmitter.prototype.emit=function($){var I=this._listeners[$];if(I){for(var j=[],U=1;U<arguments.length;)j.push(arguments[U++]);for(U=0;U<I.length;)I[U].fn.apply(I[U++].ctx,j)}return this};var float=factory(factory);function factory(_){return typeof Float32Array<"u"?function(){var $=new Float32Array([-0]),I=new Uint8Array($.buffer),j=I[3]===128;function U(Y,J,X){$[0]=Y,J[X]=I[0],J[X+1]=I[1],J[X+2]=I[2],J[X+3]=I[3]}function q(Y,J,X){$[0]=Y,J[X]=I[3],J[X+1]=I[2],J[X+2]=I[1],J[X+3]=I[0]}_.writeFloatLE=j?U:q,_.writeFloatBE=j?q:U;function G(Y,J){return I[0]=Y[J],I[1]=Y[J+1],I[2]=Y[J+2],I[3]=Y[J+3],$[0]}function K(Y,J){return I[3]=Y[J],I[2]=Y[J+1],I[1]=Y[J+2],I[0]=Y[J+3],$[0]}_.readFloatLE=j?G:K,_.readFloatBE=j?K:G}():function(){function $(j,U,q,G){var K=U<0?1:0;if(K&&(U=-U),U===0)j(1/U>0?0:2147483648,q,G);else if(isNaN(U))j(2143289344,q,G);else if(U>34028234663852886e22)j((K<<31|2139095040)>>>0,q,G);else if(U<11754943508222875e-54)j((K<<31|Math.round(U/1401298464324817e-60))>>>0,q,G);else{var Y=Math.floor(Math.log(U)/Math.LN2),J=Math.round(U*Math.pow(2,-Y)*8388608)&8388607;j((K<<31|Y+127<<23|J)>>>0,q,G)}}_.writeFloatLE=$.bind(null,writeUintLE),_.writeFloatBE=$.bind(null,writeUintBE);function I(j,U,q){var G=j(U,q),K=(G>>31)*2+1,Y=G>>>23&255,J=G&8388607;return Y===255?J?NaN:K*(1/0):Y===0?K*1401298464324817e-60*J:K*Math.pow(2,Y-150)*(J+8388608)}_.readFloatLE=I.bind(null,readUintLE),_.readFloatBE=I.bind(null,readUintBE)}(),typeof Float64Array<"u"?function(){var $=new Float64Array([-0]),I=new Uint8Array($.buffer),j=I[7]===128;function U(Y,J,X){$[0]=Y,J[X]=I[0],J[X+1]=I[1],J[X+2]=I[2],J[X+3]=I[3],J[X+4]=I[4],J[X+5]=I[5],J[X+6]=I[6],J[X+7]=I[7]}function q(Y,J,X){$[0]=Y,J[X]=I[7],J[X+1]=I[6],J[X+2]=I[5],J[X+3]=I[4],J[X+4]=I[3],J[X+5]=I[2],J[X+6]=I[1],J[X+7]=I[0]}_.writeDoubleLE=j?U:q,_.writeDoubleBE=j?q:U;function G(Y,J){return I[0]=Y[J],I[1]=Y[J+1],I[2]=Y[J+2],I[3]=Y[J+3],I[4]=Y[J+4],I[5]=Y[J+5],I[6]=Y[J+6],I[7]=Y[J+7],$[0]}function K(Y,J){return I[7]=Y[J],I[6]=Y[J+1],I[5]=Y[J+2],I[4]=Y[J+3],I[3]=Y[J+4],I[2]=Y[J+5],I[1]=Y[J+6],I[0]=Y[J+7],$[0]}_.readDoubleLE=j?G:K,_.readDoubleBE=j?K:G}():function(){function $(j,U,q,G,K,Y){var J=G<0?1:0;if(J&&(G=-G),G===0)j(0,K,Y+U),j(1/G>0?0:2147483648,K,Y+q);else if(isNaN(G))j(0,K,Y+U),j(2146959360,K,Y+q);else if(G>17976931348623157e292)j(0,K,Y+U),j((J<<31|2146435072)>>>0,K,Y+q);else{var X;if(G<22250738585072014e-324)X=G/5e-324,j(X>>>0,K,Y+U),j((J<<31|X/4294967296)>>>0,K,Y+q);else{var Z=Math.floor(Math.log(G)/Math.LN2);Z===1024&&(Z=1023),X=G*Math.pow(2,-Z),j(X*4503599627370496>>>0,K,Y+U),j((J<<31|Z+1023<<20|X*1048576&1048575)>>>0,K,Y+q)}}}_.writeDoubleLE=$.bind(null,writeUintLE,0,4),_.writeDoubleBE=$.bind(null,writeUintBE,4,0);function I(j,U,q,G,K){var Y=j(G,K+U),J=j(G,K+q),X=(J>>31)*2+1,Z=J>>>20&2047,Q=4294967296*(J&1048575)+Y;return Z===2047?Q?NaN:X*(1/0):Z===0?X*5e-324*Q:X*Math.pow(2,Z-1075)*(Q+4503599627370496)}_.readDoubleLE=I.bind(null,readUintLE,0,4),_.readDoubleBE=I.bind(null,readUintBE,4,0)}(),_}function writeUintLE(_,$,I){$[I]=_&255,$[I+1]=_>>>8&255,$[I+2]=_>>>16&255,$[I+3]=_>>>24}function writeUintBE(_,$,I){$[I]=_>>>24,$[I+1]=_>>>16&255,$[I+2]=_>>>8&255,$[I+3]=_&255}function readUintLE(_,$){return(_[$]|_[$+1]<<8|_[$+2]<<16|_[$+3]<<24)>>>0}function readUintBE(_,$){return(_[$]<<24|_[$+1]<<16|_[$+2]<<8|_[$+3])>>>0}var inquire_1=inquire$1;function inquire$1(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(_){}return null}var utf8$2={};(function(_){var $=_;$.length=function(j){for(var U=0,q=0,G=0;G<j.length;++G)q=j.charCodeAt(G),q<128?U+=1:q<2048?U+=2:(q&64512)===55296&&(j.charCodeAt(G+1)&64512)===56320?(++G,U+=4):U+=3;return U},$.read=function(j,U,q){var G=q-U;if(G<1)return"";for(var K=null,Y=[],J=0,X;U<q;)X=j[U++],X<128?Y[J++]=X:X>191&&X<224?Y[J++]=(X&31)<<6|j[U++]&63:X>239&&X<365?(X=((X&7)<<18|(j[U++]&63)<<12|(j[U++]&63)<<6|j[U++]&63)-65536,Y[J++]=55296+(X>>10),Y[J++]=56320+(X&1023)):Y[J++]=(X&15)<<12|(j[U++]&63)<<6|j[U++]&63,J>8191&&((K||(K=[])).push(String.fromCharCode.apply(String,Y)),J=0);return K?(J&&K.push(String.fromCharCode.apply(String,Y.slice(0,J))),K.join("")):String.fromCharCode.apply(String,Y.slice(0,J))},$.write=function(j,U,q){for(var G=q,K,Y,J=0;J<j.length;++J)K=j.charCodeAt(J),K<128?U[q++]=K:K<2048?(U[q++]=K>>6|192,U[q++]=K&63|128):(K&64512)===55296&&((Y=j.charCodeAt(J+1))&64512)===56320?(K=65536+((K&1023)<<10)+(Y&1023),++J,U[q++]=K>>18|240,U[q++]=K>>12&63|128,U[q++]=K>>6&63|128,U[q++]=K&63|128):(U[q++]=K>>12|224,U[q++]=K>>6&63|128,U[q++]=K&63|128);return q-G}})(utf8$2);var pool_1=pool;function pool(_,$,I){var j=I||8192,U=j>>>1,q=null,G=j;return function(Y){if(Y<1||Y>U)return _(Y);G+Y>j&&(q=_(j),G=0);var J=$.call(q,G,G+=Y);return G&7&&(G=(G|7)+1),J}}var longbits,hasRequiredLongbits;function requireLongbits(){if(hasRequiredLongbits)return longbits;hasRequiredLongbits=1,longbits=$;var _=requireMinimal();function $(q,G){this.lo=q>>>0,this.hi=G>>>0}var I=$.zero=new $(0,0);I.toNumber=function(){return 0},I.zzEncode=I.zzDecode=function(){return this},I.length=function(){return 1};var j=$.zeroHash="\0\0\0\0\0\0\0\0";$.fromNumber=function(G){if(G===0)return I;var K=G<0;K&&(G=-G);var Y=G>>>0,J=(G-Y)/4294967296>>>0;return K&&(J=~J>>>0,Y=~Y>>>0,++Y>4294967295&&(Y=0,++J>4294967295&&(J=0))),new $(Y,J)},$.from=function(G){if(typeof G=="number")return $.fromNumber(G);if(_.isString(G))if(_.Long)G=_.Long.fromString(G);else return $.fromNumber(parseInt(G,10));return G.low||G.high?new $(G.low>>>0,G.high>>>0):I},$.prototype.toNumber=function(G){if(!G&&this.hi>>>31){var K=~this.lo+1>>>0,Y=~this.hi>>>0;return K||(Y=Y+1>>>0),-(K+Y*4294967296)}return this.lo+this.hi*4294967296},$.prototype.toLong=function(G){return _.Long?new _.Long(this.lo|0,this.hi|0,!!G):{low:this.lo|0,high:this.hi|0,unsigned:!!G}};var U=String.prototype.charCodeAt;return $.fromHash=function(G){return G===j?I:new $((U.call(G,0)|U.call(G,1)<<8|U.call(G,2)<<16|U.call(G,3)<<24)>>>0,(U.call(G,4)|U.call(G,5)<<8|U.call(G,6)<<16|U.call(G,7)<<24)>>>0)},$.prototype.toHash=function(){return String.fromCharCode(this.lo&255,this.lo>>>8&255,this.lo>>>16&255,this.lo>>>24,this.hi&255,this.hi>>>8&255,this.hi>>>16&255,this.hi>>>24)},$.prototype.zzEncode=function(){var G=this.hi>>31;return this.hi=((this.hi<<1|this.lo>>>31)^G)>>>0,this.lo=(this.lo<<1^G)>>>0,this},$.prototype.zzDecode=function(){var G=-(this.lo&1);return this.lo=((this.lo>>>1|this.hi<<31)^G)>>>0,this.hi=(this.hi>>>1^G)>>>0,this},$.prototype.length=function(){var G=this.lo,K=(this.lo>>>28|this.hi<<4)>>>0,Y=this.hi>>>24;return Y===0?K===0?G<16384?G<128?1:2:G<2097152?3:4:K<16384?K<128?5:6:K<2097152?7:8:Y<128?9:10},longbits}var hasRequiredMinimal;function requireMinimal(){return hasRequiredMinimal||(hasRequiredMinimal=1,function(_){var $=_;$.asPromise=aspromise,$.base64=base64$1,$.EventEmitter=eventemitter,$.float=float,$.inquire=inquire_1,$.utf8=utf8$2,$.pool=pool_1,$.LongBits=requireLongbits(),$.isNode=!!(typeof commonjsGlobal<"u"&&commonjsGlobal&&commonjsGlobal.process&&commonjsGlobal.process.versions&&commonjsGlobal.process.versions.node),$.global=$.isNode&&commonjsGlobal||typeof window<"u"&&window||typeof self<"u"&&self||commonjsGlobal,$.emptyArray=Object.freeze?Object.freeze([]):[],$.emptyObject=Object.freeze?Object.freeze({}):{},$.isInteger=Number.isInteger||function(q){return typeof q=="number"&&isFinite(q)&&Math.floor(q)===q},$.isString=function(q){return typeof q=="string"||q instanceof String},$.isObject=function(q){return q&&typeof q=="object"},$.isset=$.isSet=function(q,G){var K=q[G];return K!=null&&q.hasOwnProperty(G)?typeof K!="object"||(Array.isArray(K)?K.length:Object.keys(K).length)>0:!1},$.Buffer=function(){try{var U=$.inquire("buffer").Buffer;return U.prototype.utf8Write?U:null}catch{return null}}(),$._Buffer_from=null,$._Buffer_allocUnsafe=null,$.newBuffer=function(q){return typeof q=="number"?$.Buffer?$._Buffer_allocUnsafe(q):new $.Array(q):$.Buffer?$._Buffer_from(q):typeof Uint8Array>"u"?q:new Uint8Array(q)},$.Array=typeof Uint8Array<"u"?Uint8Array:Array,$.Long=$.global.dcodeIO&&$.global.dcodeIO.Long||$.global.Long||$.inquire("long"),$.key2Re=/^true|false|0|1$/,$.key32Re=/^-?(?:0|[1-9][0-9]*)$/,$.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,$.longToHash=function(q){return q?$.LongBits.from(q).toHash():$.LongBits.zeroHash},$.longFromHash=function(q,G){var K=$.LongBits.fromHash(q);return $.Long?$.Long.fromBits(K.lo,K.hi,G):K.toNumber(!!G)};function I(U,q,G){for(var K=Object.keys(q),Y=0;Y<K.length;++Y)(U[K[Y]]===void 0||!G)&&(U[K[Y]]=q[K[Y]]);return U}$.merge=I,$.lcFirst=function(q){return q.charAt(0).toLowerCase()+q.substring(1)};function j(U){function q(G,K){if(!(this instanceof q))return new q(G,K);Object.defineProperty(this,"message",{get:function(){return G}}),Error.captureStackTrace?Error.captureStackTrace(this,q):Object.defineProperty(this,"stack",{value:new Error().stack||""}),K&&I(this,K)}return q.prototype=Object.create(Error.prototype,{constructor:{value:q,writable:!0,enumerable:!1,configurable:!0},name:{get:function(){return U},set:void 0,enumerable:!1,configurable:!0},toString:{value:function(){return this.name+": "+this.message},writable:!0,enumerable:!1,configurable:!0}}),q}$.newError=j,$.ProtocolError=j("ProtocolError"),$.oneOfGetter=function(q){for(var G={},K=0;K<q.length;++K)G[q[K]]=1;return function(){for(var Y=Object.keys(this),J=Y.length-1;J>-1;--J)if(G[Y[J]]===1&&this[Y[J]]!==void 0&&this[Y[J]]!==null)return Y[J]}},$.oneOfSetter=function(q){return function(G){for(var K=0;K<q.length;++K)q[K]!==G&&delete this[q[K]]}},$.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},$._configure=function(){var U=$.Buffer;if(!U){$._Buffer_from=$._Buffer_allocUnsafe=null;return}$._Buffer_from=U.from!==Uint8Array.from&&U.from||function(G,K){return new U(G,K)},$._Buffer_allocUnsafe=U.allocUnsafe||function(G){return new U(G)}}}(minimal)),minimal}var writer=Writer$1,util$7=requireMinimal(),BufferWriter$1,LongBits$1=util$7.LongBits,base64=util$7.base64,utf8$1=util$7.utf8;function Op(_,$,I){this.fn=_,this.len=$,this.next=void 0,this.val=I}function noop(){}function State(_){this.head=_.head,this.tail=_.tail,this.len=_.len,this.next=_.states}function Writer$1(){this.len=0,this.head=new Op(noop,0,0),this.tail=this.head,this.states=null}var create$1=function _(){return util$7.Buffer?function(){return(Writer$1.create=function(){return new BufferWriter$1})()}:function(){return new Writer$1}};Writer$1.create=create$1(),Writer$1.alloc=function _($){return new util$7.Array($)},util$7.Array!==Array&&(Writer$1.alloc=util$7.pool(Writer$1.alloc,util$7.Array.prototype.subarray)),Writer$1.prototype._push=function _($,I,j){return this.tail=this.tail.next=new Op($,I,j),this.len+=I,this};function writeByte(_,$,I){$[I]=_&255}function writeVarint32(_,$,I){for(;_>127;)$[I++]=_&127|128,_>>>=7;$[I]=_}function VarintOp(_,$){this.len=_,this.next=void 0,this.val=$}VarintOp.prototype=Object.create(Op.prototype),VarintOp.prototype.fn=writeVarint32,Writer$1.prototype.uint32=function _($){return this.len+=(this.tail=this.tail.next=new VarintOp(($=$>>>0)<128?1:$<16384?2:$<2097152?3:$<268435456?4:5,$)).len,this},Writer$1.prototype.int32=function _($){return $<0?this._push(writeVarint64,10,LongBits$1.fromNumber($)):this.uint32($)},Writer$1.prototype.sint32=function _($){return this.uint32(($<<1^$>>31)>>>0)};function writeVarint64(_,$,I){for(;_.hi;)$[I++]=_.lo&127|128,_.lo=(_.lo>>>7|_.hi<<25)>>>0,_.hi>>>=7;for(;_.lo>127;)$[I++]=_.lo&127|128,_.lo=_.lo>>>7;$[I++]=_.lo}Writer$1.prototype.uint64=function _($){var I=LongBits$1.from($);return this._push(writeVarint64,I.length(),I)},Writer$1.prototype.int64=Writer$1.prototype.uint64,Writer$1.prototype.sint64=function _($){var I=LongBits$1.from($).zzEncode();return this._push(writeVarint64,I.length(),I)},Writer$1.prototype.bool=function _($){return this._push(writeByte,1,$?1:0)};function writeFixed32(_,$,I){$[I]=_&255,$[I+1]=_>>>8&255,$[I+2]=_>>>16&255,$[I+3]=_>>>24}Writer$1.prototype.fixed32=function _($){return this._push(writeFixed32,4,$>>>0)},Writer$1.prototype.sfixed32=Writer$1.prototype.fixed32,Writer$1.prototype.fixed64=function _($){var I=LongBits$1.from($);return this._push(writeFixed32,4,I.lo)._push(writeFixed32,4,I.hi)},Writer$1.prototype.sfixed64=Writer$1.prototype.fixed64,Writer$1.prototype.float=function _($){return this._push(util$7.float.writeFloatLE,4,$)},Writer$1.prototype.double=function _($){return this._push(util$7.float.writeDoubleLE,8,$)};var writeBytes=util$7.Array.prototype.set?function _($,I,j){I.set($,j)}:function _($,I,j){for(var U=0;U<$.length;++U)I[j+U]=$[U]};Writer$1.prototype.bytes=function _($){var I=$.length>>>0;if(!I)return this._push(writeByte,1,0);if(util$7.isString($)){var j=Writer$1.alloc(I=base64.length($));base64.decode($,j,0),$=j}return this.uint32(I)._push(writeBytes,I,$)},Writer$1.prototype.string=function _($){var I=utf8$1.length($);return I?this.uint32(I)._push(utf8$1.write,I,$):this._push(writeByte,1,0)},Writer$1.prototype.fork=function _(){return this.states=new State(this),this.head=this.tail=new Op(noop,0,0),this.len=0,this},Writer$1.prototype.reset=function _(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new Op(noop,0,0),this.len=0),this},Writer$1.prototype.ldelim=function _(){var $=this.head,I=this.tail,j=this.len;return this.reset().uint32(j),j&&(this.tail.next=$.next,this.tail=I,this.len+=j),this},Writer$1.prototype.finish=function _(){for(var $=this.head.next,I=this.constructor.alloc(this.len),j=0;$;)$.fn($.val,I,j),j+=$.len,$=$.next;return I},Writer$1._configure=function(_){BufferWriter$1=_,Writer$1.create=create$1(),BufferWriter$1._configure()};var writer_buffer=BufferWriter,Writer=writer;(BufferWriter.prototype=Object.create(Writer.prototype)).constructor=BufferWriter;var util$6=requireMinimal();function BufferWriter(){Writer.call(this)}BufferWriter._configure=function(){BufferWriter.alloc=util$6._Buffer_allocUnsafe,BufferWriter.writeBytesBuffer=util$6.Buffer&&util$6.Buffer.prototype instanceof Uint8Array&&util$6.Buffer.prototype.set.name==="set"?function($,I,j){I.set($,j)}:function($,I,j){if($.copy)$.copy(I,j,0,$.length);else for(var U=0;U<$.length;)I[j++]=$[U++]}},BufferWriter.prototype.bytes=function _($){util$6.isString($)&&($=util$6._Buffer_from($,"base64"));var I=$.length>>>0;return this.uint32(I),I&&this._push(BufferWriter.writeBytesBuffer,I,$),this};function writeStringBuffer(_,$,I){_.length<40?util$6.utf8.write(_,$,I):$.utf8Write?$.utf8Write(_,I):$.write(_,I)}BufferWriter.prototype.string=function _($){var I=util$6.Buffer.byteLength($);return this.uint32(I),I&&this._push(writeStringBuffer,I,$),this},BufferWriter._configure();var reader=Reader$1,util$5=requireMinimal(),BufferReader$1,LongBits=util$5.LongBits,utf8=util$5.utf8;function indexOutOfRange(_,$){return RangeError("index out of range: "+_.pos+" + "+($||1)+" > "+_.len)}function Reader$1(_){this.buf=_,this.pos=0,this.len=_.length}var create_array=typeof Uint8Array<"u"?function _($){if($ instanceof Uint8Array||Array.isArray($))return new Reader$1($);throw Error("illegal buffer")}:function _($){if(Array.isArray($))return new Reader$1($);throw Error("illegal buffer")},create=function _(){return util$5.Buffer?function(I){return(Reader$1.create=function(U){return util$5.Buffer.isBuffer(U)?new BufferReader$1(U):create_array(U)})(I)}:create_array};Reader$1.create=create(),Reader$1.prototype._slice=util$5.Array.prototype.subarray||util$5.Array.prototype.slice,Reader$1.prototype.uint32=function _(){var $=4294967295;return function(){if($=(this.buf[this.pos]&127)>>>0,this.buf[this.pos++]<128||($=($|(this.buf[this.pos]&127)<<7)>>>0,this.buf[this.pos++]<128)||($=($|(this.buf[this.pos]&127)<<14)>>>0,this.buf[this.pos++]<128)||($=($|(this.buf[this.pos]&127)<<21)>>>0,this.buf[this.pos++]<128)||($=($|(this.buf[this.pos]&15)<<28)>>>0,this.buf[this.pos++]<128))return $;if((this.pos+=5)>this.len)throw this.pos=this.len,indexOutOfRange(this,10);return $}}(),Reader$1.prototype.int32=function _(){return this.uint32()|0},Reader$1.prototype.sint32=function _(){var $=this.uint32();return $>>>1^-($&1)|0};function readLongVarint(){var _=new LongBits(0,0),$=0;if(this.len-this.pos>4){for(;$<4;++$)if(_.lo=(_.lo|(this.buf[this.pos]&127)<<$*7)>>>0,this.buf[this.pos++]<128)return _;if(_.lo=(_.lo|(this.buf[this.pos]&127)<<28)>>>0,_.hi=(_.hi|(this.buf[this.pos]&127)>>4)>>>0,this.buf[this.pos++]<128)return _;$=0}else{for(;$<3;++$){if(this.pos>=this.len)throw indexOutOfRange(this);if(_.lo=(_.lo|(this.buf[this.pos]&127)<<$*7)>>>0,this.buf[this.pos++]<128)return _}return _.lo=(_.lo|(this.buf[this.pos++]&127)<<$*7)>>>0,_}if(this.len-this.pos>4){for(;$<5;++$)if(_.hi=(_.hi|(this.buf[this.pos]&127)<<$*7+3)>>>0,this.buf[this.pos++]<128)return _}else for(;$<5;++$){if(this.pos>=this.len)throw indexOutOfRange(this);if(_.hi=(_.hi|(this.buf[this.pos]&127)<<$*7+3)>>>0,this.buf[this.pos++]<128)return _}throw Error("invalid varint encoding")}Reader$1.prototype.bool=function _(){return this.uint32()!==0};function readFixed32_end(_,$){return(_[$-4]|_[$-3]<<8|_[$-2]<<16|_[$-1]<<24)>>>0}Reader$1.prototype.fixed32=function _(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)},Reader$1.prototype.sfixed32=function _(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);return readFixed32_end(this.buf,this.pos+=4)|0};function readFixed64(){if(this.pos+8>this.len)throw indexOutOfRange(this,8);return new LongBits(readFixed32_end(this.buf,this.pos+=4),readFixed32_end(this.buf,this.pos+=4))}Reader$1.prototype.float=function _(){if(this.pos+4>this.len)throw indexOutOfRange(this,4);var $=util$5.float.readFloatLE(this.buf,this.pos);return this.pos+=4,$},Reader$1.prototype.double=function _(){if(this.pos+8>this.len)throw indexOutOfRange(this,4);var $=util$5.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,$},Reader$1.prototype.bytes=function _(){var $=this.uint32(),I=this.pos,j=this.pos+$;if(j>this.len)throw indexOutOfRange(this,$);if(this.pos+=$,Array.isArray(this.buf))return this.buf.slice(I,j);if(I===j){var U=util$5.Buffer;return U?U.alloc(0):new this.buf.constructor(0)}return this._slice.call(this.buf,I,j)},Reader$1.prototype.string=function _(){var $=this.bytes();return utf8.read($,0,$.length)},Reader$1.prototype.skip=function _($){if(typeof $=="number"){if(this.pos+$>this.len)throw indexOutOfRange(this,$);this.pos+=$}else do if(this.pos>=this.len)throw indexOutOfRange(this);while(this.buf[this.pos++]&128);return this},Reader$1.prototype.skipType=function(_){switch(_){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;(_=this.uint32()&7)!==4;)this.skipType(_);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+_+" at offset "+this.pos)}return this},Reader$1._configure=function(_){BufferReader$1=_,Reader$1.create=create(),BufferReader$1._configure();var $=util$5.Long?"toLong":"toNumber";util$5.merge(Reader$1.prototype,{int64:function(){return readLongVarint.call(this)[$](!1)},uint64:function(){return readLongVarint.call(this)[$](!0)},sint64:function(){return readLongVarint.call(this).zzDecode()[$](!1)},fixed64:function(){return readFixed64.call(this)[$](!0)},sfixed64:function(){return readFixed64.call(this)[$](!1)}})};var reader_buffer=BufferReader,Reader=reader;(BufferReader.prototype=Object.create(Reader.prototype)).constructor=BufferReader;var util$4=requireMinimal();function BufferReader(_){Reader.call(this,_)}BufferReader._configure=function(){util$4.Buffer&&(BufferReader.prototype._slice=util$4.Buffer.prototype.slice)},BufferReader.prototype.string=function _(){var $=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+$,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+$,this.len))},BufferReader._configure();var rpc={},service$1=Service$1,util$3=requireMinimal();(Service$1.prototype=Object.create(util$3.EventEmitter.prototype)).constructor=Service$1;function Service$1(_,$,I){if(typeof _!="function")throw TypeError("rpcImpl must be a function");util$3.EventEmitter.call(this),this.rpcImpl=_,this.requestDelimited=!!$,this.responseDelimited=!!I}Service$1.prototype.rpcCall=function _($,I,j,U,q){if(!U)throw TypeError("request must be specified");var G=this;if(!q)return util$3.asPromise(_,G,$,I,j,U);if(!G.rpcImpl){setTimeout(function(){q(Error("already ended"))},0);return}try{return G.rpcImpl($,I[G.requestDelimited?"encodeDelimited":"encode"](U).finish(),function(Y,J){if(Y)return G.emit("error",Y,$),q(Y);if(J===null){G.end(!0);return}if(!(J instanceof j))try{J=j[G.responseDelimited?"decodeDelimited":"decode"](J)}catch(X){return G.emit("error",X,$),q(X)}return G.emit("data",J,$),q(null,J)})}catch(K){G.emit("error",K,$),setTimeout(function(){q(K)},0);return}},Service$1.prototype.end=function _($){return this.rpcImpl&&($||this.rpcImpl(null,null,null),this.rpcImpl=null,this.emit("end").off()),this},function(_){var $=_;$.Service=service$1}(rpc);var roots={};(function(_){var $=_;$.build="minimal",$.Writer=writer,$.BufferWriter=writer_buffer,$.Reader=reader,$.BufferReader=reader_buffer,$.util=requireMinimal(),$.rpc=rpc,$.roots=roots,$.configure=I;function I(){$.util._configure(),$.Writer._configure($.BufferWriter),$.Reader._configure($.BufferReader)}I()})(indexMinimal);var util$2={exports:{}},codegen_1=codegen;function codegen(_,$){typeof _=="string"&&($=_,_=void 0);var I=[];function j(q){if(typeof q!="string"){var G=U();if(codegen.verbose&&console.log("codegen: "+G),G="return "+G,q){for(var K=Object.keys(q),Y=new Array(K.length+1),J=new Array(K.length),X=0;X<K.length;)Y[X]=K[X],J[X]=q[K[X++]];return Y[X]=G,Function.apply(null,Y).apply(null,J)}return Function(G)()}for(var Z=new Array(arguments.length-1),Q=0;Q<Z.length;)Z[Q]=arguments[++Q];if(Q=0,q=q.replace(/%([%dfijs])/g,function(ne,ie){var oe=Z[Q++];switch(ie){case"d":case"f":return String(Number(oe));case"i":return String(Math.floor(oe));case"j":return JSON.stringify(oe);case"s":return String(oe)}return"%"}),Q!==Z.length)throw Error("parameter count mismatch");return I.push(q),j}function U(q){return"function "+(q||$||"")+"("+(_&&_.join(",")||"")+`){
|
|
950
950
|
`+I.join(`
|