@dxos/shell 0.5.1-next.b309071 → 0.5.1-next.bb5476b

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.
@@ -840,7 +840,7 @@ button {
840
840
  background-color: #61493f;
841
841
  }
842
842
 
843
- `;function zL(e){const n=l.useRef(null),t=l.useRef(null);return t.current&&t.current.update(e),l.useEffect(()=>(t.current=new Eu({...e,ref:n}),()=>{t.current=null}),[]),l.createElement("div",{ref:n})}const WL=({disabled:e,defaultEmoji:n,emoji:t,onChangeEmoji:i,classNames:r})=>{const{t:a}=vn("os"),[o,s]=kt({prop:t,onChange:i,defaultProp:n}),[f,d]=l.useState(!1),c=l.useRef(!1),[u,h]=l.useState(!1);return l.createElement(Ze.Root,{open:u,onOpenChange:p=>{c.current?(h(!1),c.current=!1):h(p)}},l.createElement(of.Root,{open:f,onOpenChange:p=>{d(p),c.current=!0}},l.createElement(Ze.Trigger,{asChild:!0},l.createElement(of.Trigger,{asChild:!0},l.createElement(mo.Button,{classNames:["gap-2 text-2xl plb-1",r],disabled:e},l.createElement("span",{className:"sr-only"},a("select emoji label")),l.createElement(qe.ImageSquare,{className:He(5)})))),l.createElement(Ze.Portal,null,l.createElement(Ze.Content,{side:"bottom",classNames:"z-50"},a("select emoji label"),l.createElement(Ze.Arrow,null))),l.createElement(of.Content,{side:"bottom",onKeyDownCapture:p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1),c.current=!0)}},l.createElement(zL,{data:iL,onEmojiSelect:({native:p})=>{p&&(s(p),d(!1))},autoFocus:!0,maxFrequentRows:0,noCountryFlags:!0}),l.createElement(of.Arrow,null))))},HL=({hue:e})=>{const{tx:n}=Ae();return l.createElement("svg",{width:12,height:12,viewBox:"0 0 12 12"},l.createElement("rect",{x:0,y:0,width:12,height:12,className:n("hue.fill","select--hue__preview",{hue:e})}))},VL=({disabled:e,hue:n,onChangeHue:t,classNames:i,defaultHue:r})=>{const{t:a}=vn("os"),[o,s]=kt({prop:n,onChange:t,defaultProp:r}),[f,d]=l.useState(!1),c=l.useRef(!1),[u,h]=l.useState(!1);return l.createElement(Ze.Root,{open:u,onOpenChange:p=>{c.current?(h(!1),c.current=!1):h(p)}},l.createElement(Dn.Root,{modal:!1,open:f,onOpenChange:p=>{d(p),c.current=!0}},l.createElement(Ze.Trigger,{asChild:!0},l.createElement(Dn.Trigger,{asChild:!0},l.createElement(mo.Button,{classNames:le("gap-2 plb-1",i),disabled:e},l.createElement("span",{className:"sr-only"},a("select hue label")),l.createElement(qe.Palette,{className:He(5)})))),l.createElement(Ze.Portal,null,l.createElement(Ze.Content,{side:"bottom",classNames:"z-50"},a("select hue label"),l.createElement(Ze.Arrow,null))),l.createElement(Dn.Content,{side:"bottom"},l.createElement(Dn.Viewport,null,Object.keys(aa).map(p=>l.createElement(Dn.CheckboxItem,{key:p,checked:p===o,onCheckedChange:()=>s(p)},l.createElement(HL,{hue:p}),l.createElement("span",{className:"grow"},a(`${p} label`)),l.createElement(Dn.ItemIndicator,null,l.createElement(qe.Check,null))))),l.createElement(Dn.Arrow,null))))};var Mf={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"]},hw=e=>e.charAt(0).toUpperCase()+e.slice(1),Nf=e=>{const n=e.length*2/3,t=e.substring(0,n),i=e.substring(n),r=hw(Mf.adjectives[parseInt(t,16)%Mf.adjectives.length]),a=hw(Mf.animals[parseInt(i,16)%Mf.animals.length]);return`${r} ${a}`};const qL=l.forwardRef(({identity:e,presence:n,onClick:t,classNames:i,...r},a)=>{var d,c,u,h,p;const o=oc(e.identityKey),s=$n("identityListItem__label"),f=((d=e.profile)==null?void 0:d.displayName)??Nf(e.identityKey.toHex());return l.createElement(af.Root,{...r,classNames:le("flex gap-2 pis-3 pie-1 items-center",t&&"cursor-pointer",i),onClick:()=>t==null?void 0:t(),"data-testid":"identity-list-item",labelId:s,ref:a},l.createElement(wn.Root,{status:n===Jo.SpaceMember.PresenceState.ONLINE?"active":"inactive",labelId:s,hue:((u=(c=e.profile)==null?void 0:c.data)==null?void 0:u.hue)||o.hue},l.createElement(wn.Frame,{classNames:"place-self-center"},l.createElement(wn.Fallback,{text:((p=(h=e.profile)==null?void 0:h.data)==null?void 0:p.emoji)||o.emoji})),l.createElement(wn.Label,{classNames:"text-sm truncate pli-2"},f)))}),GL=({spaceKey:e,includeSelf:n,onSelect:t})=>{const i=Re.useClient(),r=Jo.useMembers(e),a=l.useMemo(()=>n?r.sort(o=>o.identity.identityKey.equals(i.halo.identity.get().identityKey)?-1:1):r.filter(o=>!o.identity.identityKey.equals(i.halo.identity.get().identityKey)),[r]);return l.createElement(KL,{members:a,onSelect:t})},KL=({members:e,onSelect:n})=>{const{t}=vn("os"),i=e.filter(r=>r.identity);return i.length>0?l.createElement(Fc,{classNames:"flex flex-col gap-2","data-testid":"space-members-list"},i.map(r=>l.createElement(qL,{key:r.identity.identityKey.toHex(),identity:r.identity,presence:r.presence,onClick:n&&(()=>n(r))}))):l.createElement("div",{role:"none",className:"grow flex items-center p-2"},l.createElement("p",{className:le(In,"text-center is-full mlb-2")},t("empty space members message")))},_o={weight:"duotone",width:24,height:24,x:8,y:8},YL=l.forwardRef(({device:e,onClickAdd:n,onClickEdit:t,onClickReset:i,onClickJoinExisting:r,classNames:a,...o},s)=>{var p;const{t:f}=vn("os"),d=oc(e.deviceKey),c=$n("identityListItem__label"),u=e.profile?f("device name placeholder",{os:e.profile.os,platform:e.profile.platform}):Nf(e.deviceKey.toHex()),h=e.kind===vt.DeviceKind.CURRENT;return l.createElement(af.Root,{...o,classNames:["flex gap-2 items-center mlb-2",a],"data-testid":`device-list-item${h?"-current":""}`,labelId:c,ref:s},l.createElement(wn.Root,{status:e.presence===vt.Device.PresenceState.ONLINE?"active":"inactive",labelId:c,hue:d.hue,variant:"square"},l.createElement(wn.Frame,{classNames:"place-self-center"},(p=e.profile)!=null&&p.type?e.profile.type===vt.DeviceType.BROWSER?l.createElement(qe.Compass,{..._o}):e.profile.type===vt.DeviceType.NATIVE?l.createElement(qe.Desktop,{..._o}):[vt.DeviceType.AGENT,vt.DeviceType.AGENT_MANAGED].includes(e.profile.type)?l.createElement(qe.Robot,{..._o}):e.profile.type===vt.DeviceType.MOBILE?l.createElement(qe.DeviceMobile,{..._o}):l.createElement(qe.Devices,{..._o}):l.createElement(wn.Fallback,{text:d.emoji})),h&&l.createElement(LO,{color:"primary"},f("current device tag label")),l.createElement(wn.Label,{classNames:"flex-1 text-sm truncate"},u),e.kind===vt.DeviceKind.CURRENT&&l.createElement(Dn.Root,null,l.createElement(Dn.Trigger,{asChild:!0},l.createElement(jn,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":`device-list-item${h?"-current":""}.options`},l.createElement("span",{className:"sr-only"},f("more options label")),l.createElement(qe.DotsThree,{className:He(5)}))),l.createElement(Dn.Content,null,l.createElement(Dn.Viewport,null,l.createElement(Dn.Item,{"data-testid":"device-list-item-current.join-existing",onClick:r},l.createElement(qe.Intersect,{className:He(5)}),f("choose join new identity label")),l.createElement(Dn.Item,{"data-testid":"device-list-item-current.reset",onClick:i},l.createElement(qe.Power,{className:He(5)}),f("reset device label")))))))}),JL=({devices:e,onClickAdd:n,onClickEdit:t,onClickReset:i,onClickJoinExisting:r})=>{const{t:a}=vn("os");return l.createElement(l.Fragment,null,l.createElement("h2",{className:le(In,"text-center mbs-4")},a("devices heading")),e.length>0&&l.createElement(Fc,null,e.map(o=>l.createElement(YL,{key:o.deviceKey.toHex(),device:o,onClickEdit:()=>t==null?void 0:t(o),onClickReset:i,onClickJoinExisting:r}))),l.createElement(jn,{variant:"ghost",classNames:"justify-start gap-2 !pis-0 !pie-3","data-testid":"devices-panel.create-invitation",onClick:n},l.createElement("div",{role:"img",className:le(He(8),"m-1 rounded-sm surface-input grid place-items-center")},l.createElement(qe.Plus,{weight:"light",className:He(6)})),l.createElement("span",{className:"grow font-medium text-start"},a("choose add device label")),l.createElement(qe.CaretRight,{weight:"bold",className:He(4)})))},Df=43200,vw=1440;function pw(e){const n=Wn(e),t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return t.setUTCFullYear(n.getFullYear()),+e-+t}function Lf(e,n){const t=Wn(e),i=Wn(n),r=t.getTime()-i.getTime();return r<0?-1:r>0?1:r}function XL(e,n){const t=Wn(e),i=Wn(n),r=t.getFullYear()-i.getFullYear(),a=t.getMonth()-i.getMonth();return r*12+a}function ZL(e){return n=>{const i=(e?Math[e]:Math.trunc)(n);return i===0?0:i}}function QL(e,n){return+Wn(e)-+Wn(n)}function eB(e){const n=Wn(e);return n.setHours(23,59,59,999),n}function nB(e){const n=Wn(e),t=n.getMonth();return n.setFullYear(n.getFullYear(),t+1,0),n.setHours(23,59,59,999),n}function tB(e){const n=Wn(e);return+eB(n)==+nB(n)}function iB(e,n){const t=Wn(e),i=Wn(n),r=Lf(t,i),a=Math.abs(XL(t,i));let o;if(a<1)o=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-r*a);let s=Lf(t,i)===-r;tB(Wn(e))&&a===1&&Lf(e,i)===1&&(s=!1),o=r*(a-Number(s))}return o===0?0:o}function rB(e,n,t){const i=QL(e,n)/1e3;return ZL(t==null?void 0:t.roundingMethod)(i)}function aB(e,n,t){const i=Nk(),r=(t==null?void 0:t.locale)??i.locale??u1,a=2520,o=Lf(e,n);if(isNaN(o))throw new RangeError("Invalid time value");const s=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:o});let f,d;o>0?(f=Wn(n),d=Wn(e)):(f=Wn(e),d=Wn(n));const c=rB(d,f),u=(pw(d)-pw(f))/1e3,h=Math.round((c-u)/60);let p;if(h<2)return t!=null&&t.includeSeconds?c<5?r.formatDistance("lessThanXSeconds",5,s):c<10?r.formatDistance("lessThanXSeconds",10,s):c<20?r.formatDistance("lessThanXSeconds",20,s):c<40?r.formatDistance("halfAMinute",0,s):c<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):h===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",h,s);if(h<45)return r.formatDistance("xMinutes",h,s);if(h<90)return r.formatDistance("aboutXHours",1,s);if(h<vw){const g=Math.round(h/60);return r.formatDistance("aboutXHours",g,s)}else{if(h<a)return r.formatDistance("xDays",1,s);if(h<Df){const g=Math.round(h/vw);return r.formatDistance("xDays",g,s)}else if(h<Df*2)return p=Math.round(h/Df),r.formatDistance("aboutXMonths",p,s)}if(p=iB(d,f),p<12){const g=Math.round(h/Df);return r.formatDistance("xMonths",g,s)}else{const g=p%12,b=Math.trunc(p/12);return g<3?r.formatDistance("aboutXYears",b,s):g<9?r.formatDistance("overXYears",b,s):r.formatDistance("almostXYears",b+1,s)}}function oB(e,n){return aB(e,Date.now(),n)}var mw;(function(e){e[e.ACTIVE=0]="ACTIVE",e[e.INACTIVE=1]="INACTIVE"})(mw||(mw={}));var gw;(function(e){(function(n){n[n.NONE=0]="NONE",n[n.TRUNCATE=1]="TRUNCATE",n[n.HUMANIZE=2]="HUMANIZE"})(e.KEY_OPTION||(e.KEY_OPTION={}))})(gw||(gw={}));var bw;(function(e){(function(n){n[n.BROWSER=0]="BROWSER",n[n.SHARED_WORKER=1]="SHARED_WORKER",n[n.NODE=2]="NODE"})(e.PLATFORM_TYPE||(e.PLATFORM_TYPE={}))})(bw||(bw={}));var yw;(function(e){e[e.CURRENT=0]="CURRENT",e[e.TRUSTED=1]="TRUSTED"})(yw||(yw={}));var ww;(function(e){(function(n){n[n.OFFLINE=0]="OFFLINE",n[n.ONLINE=1]="ONLINE",n[n.REMOVED=2]="REMOVED"})(e.PresenceState||(e.PresenceState={}))})(ww||(ww={}));var _w;(function(e){(function(n){n[n.OFFLINE=0]="OFFLINE",n[n.ONLINE=1]="ONLINE",n[n.REMOVED=2]="REMOVED"})(e.PresenceState||(e.PresenceState={}))})(_w||(_w={}));var kw;(function(e){e[e.INACTIVE=2]="INACTIVE",e[e.ACTIVE=6]="ACTIVE",e[e.CLOSED=1]="CLOSED",e[e.CONTROL_ONLY=7]="CONTROL_ONLY",e[e.INITIALIZING=4]="INITIALIZING",e[e.READY=3]="READY",e[e.ERROR=5]="ERROR"})(kw||(kw={}));var xw;(function(e){(function(n){n[n.NONE=0]="NONE",n[n.INIT_AUTOMERGE=1]="INIT_AUTOMERGE",n[n.PRUNE_AUTOMERGE_ROOT_HISTORY=2]="PRUNE_AUTOMERGE_ROOT_HISTORY",n[n.FRAGMENT_AUTOMERGE_ROOT=3]="FRAGMENT_AUTOMERGE_ROOT"})(e.Migration||(e.Migration={}))})(xw||(xw={}));var Se;(function(e){(function(n){n[n.INTERACTIVE=0]="INTERACTIVE",n[n.DELEGATED=1]="DELEGATED",n[n.MULTIUSE=2]="MULTIUSE"})(e.Type||(e.Type={})),function(n){n[n.DEVICE=0]="DEVICE",n[n.SPACE=1]="SPACE"}(e.Kind||(e.Kind={})),function(n){n[n.NONE=0]="NONE",n[n.SHARED_SECRET=1]="SHARED_SECRET",n[n.KNOWN_PUBLIC_KEY=2]="KNOWN_PUBLIC_KEY"}(e.AuthMethod||(e.AuthMethod={})),function(n){n[n.INIT=0]="INIT",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED",n[n.READY_FOR_AUTHENTICATION=3]="READY_FOR_AUTHENTICATION",n[n.AUTHENTICATING=4]="AUTHENTICATING",n[n.SUCCESS=5]="SUCCESS",n[n.CANCELLED=6]="CANCELLED",n[n.TIMEOUT=7]="TIMEOUT",n[n.ERROR=8]="ERROR",n[n.EXPIRED=9]="EXPIRED"}(e.State||(e.State={}))})(Se||(Se={}));var Ew;(function(e){(function(n){n[n.ADDED=0]="ADDED",n[n.REMOVED=1]="REMOVED",n[n.SAVED=2]="SAVED",n[n.LOAD_COMPLETE=3]="LOAD_COMPLETE"})(e.Action||(e.Action={})),function(n){n[n.CREATED=0]="CREATED",n[n.ACCEPTED=1]="ACCEPTED"}(e.Type||(e.Type={}))})(Ew||(Ew={}));var Sw;(function(e){e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE"})(Sw||(Sw={}));var Cw;(function(e){e[e.TRACE=5]="TRACE",e[e.DEBUG=10]="DEBUG",e[e.INFO=11]="INFO",e[e.WARN=12]="WARN",e[e.ERROR=13]="ERROR"})(Cw||(Cw={}));var $w;(function(e){(function(n){n[n.INCLUSIVE=1]="INCLUSIVE",n[n.EXPLICIT=2]="EXPLICIT"})(e.MatchingOptions||(e.MatchingOptions={}))})($w||($w={}));var sB=class extends Error{constructor(){super("Context disposed.")}};function fB(e,n,t,i){var r=arguments.length,a=r<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,n,t,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(n,t,a):o(n,t))||a);return r>3&&a&&Object.defineProperty(n,t,a),a}var Su="/home/runner/work/dxos/dxos/packages/common/context/src/context.ts",lB=300,Tw,Aw,Ow=(Sa=class{constructor({onError:n=r=>{if(!(r instanceof sB))throw this.dispose(),r},attributes:t={},parent:i}={}){this._disposeCallbacks=[],this._isDisposed=!1,this._disposePromise=void 0,this._parent=null,this.maxSafeDisposeCallbacks=lB,this[Tw]="Context",this[Aw]=()=>this.toString(),this._onError=n,this._attributes=t,i!==void 0&&(this._parent=i)}static default(){return new Sa}get disposed(){return this._isDisposed}get disposeCallbacksLength(){return this._disposeCallbacks.length}onDispose(n){return this._isDisposed&&(async()=>{try{await n()}catch(t){Ge.catch(t,void 0,{F:Su,L:88,S:this,C:(i,r)=>i(...r)})}})(),this._disposeCallbacks.push(n),this._disposeCallbacks.length>this.maxSafeDisposeCallbacks&&Ge.warn("Context has a large number of dispose callbacks. This might be a memory leak.",{count:this._disposeCallbacks.length,safeThreshold:this.maxSafeDisposeCallbacks},{F:Su,L:95,S:this,C:(t,i)=>t(...i)}),()=>{const t=this._disposeCallbacks.indexOf(n);t!==-1&&this._disposeCallbacks.splice(t,1)}}async dispose(){if(this._disposePromise)return this._disposePromise;this._isDisposed=!0;let n;this._disposePromise=new Promise(i=>{n=i});const t=Array.from(this._disposeCallbacks).reverse();this._disposeCallbacks.length=0;for(const i of t)try{await i()}catch(r){Ge.catch(r,void 0,{F:Su,L:136,S:this,C:(a,o)=>a(...o)})}n()}raise(n){if(!this._isDisposed)try{this._onError(n)}catch(t){Promise.reject(t)}}derive({onError:n,attributes:t}={}){const i=new Sa({onError:async a=>{if(!n)this.raise(a);else try{await n(a)}catch{this.raise(a)}},attributes:t}),r=this.onDispose(()=>i.dispose());return i.onDispose(r),i}getAttribute(n){if(n in this._attributes)return this._attributes[n];if(this._parent!==null)return this._parent.getAttribute(n)}toString(){return`Context(${this._isDisposed?"disposed":"active"})`}},Tw=Symbol.toStringTag,Aw=Et.custom,Sa);Ow=fB([p$("Context")],Ow);var Pw;(function(e){e.CLOSED="CLOSED",e.OPEN="OPEN",e.ERROR="ERROR"})(Pw||(Pw={}));var Bf={};Object.defineProperty(Bf,"__esModule",{value:!0}),Bf.Observable=void 0;const Iw=e=>!!Symbol[e],Cu=e=>Iw(e)?Symbol[e]:"@@"+e,dB=Cu("iterator"),$u=Cu("observable"),Fw=Cu("species");function jf(e,n){let t=e[n];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function ko(e){let n=e.constructor;return n!==void 0&&(n=n[Fw],n===null&&(n=void 0)),n!==void 0?n:Uf}function cB(e){return e instanceof Uf}function ua(e){ua.log?ua.log(e):setTimeout(()=>{throw e})}function Rf(e){Promise.resolve().then(()=>{try{e()}catch(n){ua(n)}})}function Mw(e){let n=e._cleanup;if(n!==void 0&&(e._cleanup=void 0,!!n))try{if(typeof n=="function")n();else{let t=jf(n,"unsubscribe");t&&t.call(n)}}catch(t){ua(t)}}function Tu(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function uB(e){let n=e._queue;if(n){e._queue=void 0,e._state="ready";for(let t=0;t<n.length&&(Nw(e,n[t].type,n[t].value),e._state!=="closed");++t);}}function Nw(e,n,t){e._state="running";let i=e._observer;try{let r=jf(i,n);switch(n){case"next":r&&r.call(i,t);break;case"error":if(Tu(e),r)r.call(i,t);else throw t;break;case"complete":Tu(e),r&&r.call(i);break}}catch(r){ua(r)}e._state==="closed"?Mw(e):e._state==="running"&&(e._state="ready")}function Au(e,n,t){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:n,value:t});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:n,value:t}],Rf(()=>uB(e));return}Nw(e,n,t)}}class hB{constructor(n,t){this._cleanup=void 0,this._observer=n,this._queue=void 0,this._state="initializing";let i=this,r={get closed(){return i._state==="closed"},next(a){Au(i,"next",a)},error(a){Au(i,"error",a)},complete(){Au(i,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(a){r.error(a)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(Tu(this),Mw(this))}}let Uf=class Ol{constructor(n){if(!(this instanceof Ol))throw new TypeError("Observable cannot be called as a function");if(typeof n!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=n}subscribe(n){return(typeof n!="object"||n===null)&&(n={next:n,error:arguments[1],complete:arguments[2]}),new hB(n,this._subscriber)}forEach(n){return new Promise((t,i)=>{if(typeof n!="function"){i(new TypeError(n+" is not a function"));return}function r(){a.unsubscribe(),t()}let a=this.subscribe({next(o){try{n(o,r)}catch(s){i(s),a.unsubscribe()}},error:i,complete:t})})}map(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>this.subscribe({next(r){try{r=n(r)}catch(a){return i.error(a)}i.next(r)},error(r){i.error(r)},complete(){i.complete()}}))}filter(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>this.subscribe({next(r){try{if(!n(r))return}catch(a){return i.error(a)}i.next(r)},error(r){i.error(r)},complete(){i.complete()}}))}reduce(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this),i=arguments.length>1,r=!1,o=arguments[1];return new t(s=>this.subscribe({next(f){let d=!r;if(r=!0,!d||i)try{o=n(o,f)}catch(c){return s.error(c)}else o=f},error(f){s.error(f)},complete(){if(!r&&!i)return s.error(new TypeError("Cannot reduce an empty sequence"));s.next(o),s.complete()}}))}async all(){let n=[];return await this.forEach(t=>n.push(t)),n}concat(...n){let t=ko(this);return new t(i=>{let r,a=0;function o(s){r=s.subscribe({next(f){i.next(f)},error(f){i.error(f)},complete(){a===n.length?(r=void 0,i.complete()):o(t.from(n[a++]))}})}return o(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>{let r=[],a=this.subscribe({next(s){if(n)try{s=n(s)}catch(d){return i.error(d)}let f=t.from(s).subscribe({next(d){i.next(d)},error(d){i.error(d)},complete(){let d=r.indexOf(f);d>=0&&r.splice(d,1),o()}});r.push(f)},error(s){i.error(s)},complete(){o()}});function o(){a.closed&&r.length===0&&i.complete()}return()=>{r.forEach(s=>s.unsubscribe()),a.unsubscribe()}})}[$u](){return this}static from(n){let t=typeof this=="function"?this:Ol;if(n==null)throw new TypeError(n+" is not an object");let i=jf(n,$u);if(i){let r=i.call(n);if(Object(r)!==r)throw new TypeError(r+" is not an object");return cB(r)&&r.constructor===t?r:new t(a=>r.subscribe(a))}if(Iw("iterator")&&(i=jf(n,dB),i))return new t(r=>{Rf(()=>{if(!r.closed){for(let a of i.call(n))if(r.next(a),r.closed)return;r.complete()}})});if(Array.isArray(n))return new t(r=>{Rf(()=>{if(!r.closed){for(let a=0;a<n.length;++a)if(r.next(n[a]),r.closed)return;r.complete()}})});throw new TypeError(n+" is not observable")}static of(...n){let t=typeof this=="function"?this:Ol;return new t(i=>{Rf(()=>{if(!i.closed){for(let r=0;r<n.length;++r)if(i.next(n[r]),i.closed)return;i.complete()}})})}static get[Fw](){return this}};Bf.Observable=Uf,Object.defineProperty(Uf,Symbol("extensions"),{value:{symbol:$u,hostReportError:ua},configurable:!0});var vB=Bf.Observable;const zf=Qi(vB);var Dw={exports:{}},Ou={exports:{}},ha=typeof Reflect=="object"?Reflect:null,Lw=ha&&typeof ha.apply=="function"?ha.apply:function(n,t,i){return Function.prototype.apply.call(n,t,i)},Wf;ha&&typeof ha.ownKeys=="function"?Wf=ha.ownKeys:Object.getOwnPropertySymbols?Wf=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Wf=function(n){return Object.getOwnPropertyNames(n)};function pB(e){console&&console.warn&&console.warn(e)}var Bw=Number.isNaN||function(n){return n!==n};function gn(){gn.init.call(this)}Ou.exports=gn,Ou.exports.once=yB,gn.EventEmitter=gn,gn.prototype._events=void 0,gn.prototype._eventsCount=0,gn.prototype._maxListeners=void 0;var jw=10;function Hf(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(gn,"defaultMaxListeners",{enumerable:!0,get:function(){return jw},set:function(e){if(typeof e!="number"||e<0||Bw(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");jw=e}}),gn.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},gn.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Bw(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Rw(e){return e._maxListeners===void 0?gn.defaultMaxListeners:e._maxListeners}gn.prototype.getMaxListeners=function(){return Rw(this)},gn.prototype.emit=function(n){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=n==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var f=a[n];if(f===void 0)return!1;if(typeof f=="function")Lw(f,this,t);else for(var d=f.length,c=Vw(f,d),i=0;i<d;++i)Lw(c[i],this,t);return!0};function Uw(e,n,t,i){var r,a,o;if(Hf(t),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",n,t.listener?t.listener:t),a=e._events),o=a[n]),o===void 0)o=a[n]=t,++e._eventsCount;else if(typeof o=="function"?o=a[n]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=Rw(e),r>0&&o.length>r&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=n,s.count=o.length,pB(s)}return e}gn.prototype.addListener=function(n,t){return Uw(this,n,t,!1)},gn.prototype.on=gn.prototype.addListener,gn.prototype.prependListener=function(n,t){return Uw(this,n,t,!0)};function mB(){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 zw(e,n,t){var i={fired:!1,wrapFn:void 0,target:e,type:n,listener:t},r=mB.bind(i);return r.listener=t,i.wrapFn=r,r}gn.prototype.once=function(n,t){return Hf(t),this.on(n,zw(this,n,t)),this},gn.prototype.prependOnceListener=function(n,t){return Hf(t),this.prependListener(n,zw(this,n,t)),this},gn.prototype.removeListener=function(n,t){var i,r,a,o,s;if(Hf(t),r=this._events,r===void 0)return this;if(i=r[n],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[n],r.removeListener&&this.emit("removeListener",n,i.listener||t));else if(typeof i!="function"){for(a=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,a=o;break}if(a<0)return this;a===0?i.shift():gB(i,a),i.length===1&&(r[n]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",n,s||t)}return this},gn.prototype.off=gn.prototype.removeListener,gn.prototype.removeAllListeners=function(n){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[n]),this;if(arguments.length===0){var a=Object.keys(i),o;for(r=0;r<a.length;++r)o=a[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[n],typeof t=="function")this.removeListener(n,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(n,t[r]);return this};function Ww(e,n,t){var i=e._events;if(i===void 0)return[];var r=i[n];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?bB(r):Vw(r,r.length)}gn.prototype.listeners=function(n){return Ww(this,n,!0)},gn.prototype.rawListeners=function(n){return Ww(this,n,!1)},gn.listenerCount=function(e,n){return typeof e.listenerCount=="function"?e.listenerCount(n):Hw.call(e,n)},gn.prototype.listenerCount=Hw;function Hw(e){var n=this._events;if(n!==void 0){var t=n[e];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}gn.prototype.eventNames=function(){return this._eventsCount>0?Wf(this._events):[]};function Vw(e,n){for(var t=new Array(n),i=0;i<n;++i)t[i]=e[i];return t}function gB(e,n){for(;n+1<e.length;n++)e[n]=e[n+1];e.pop()}function bB(e){for(var n=new Array(e.length),t=0;t<n.length;++t)n[t]=e[t].listener||e[t];return n}function yB(e,n){return new Promise(function(t,i){function r(o){e.removeListener(n,a),i(o)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",r),t([].slice.call(arguments))}qw(e,n,a,{once:!0}),n!=="error"&&wB(e,r,{once:!0})})}function wB(e,n,t){typeof e.on=="function"&&qw(e,"error",n,t)}function qw(e,n,t,i){if(typeof e.on=="function")i.once?e.once(n,t):e.on(n,t);else if(typeof e.addEventListener=="function")e.addEventListener(n,function r(a){i.once&&e.removeEventListener(n,r),t(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Gw=Ou.exports,Kw=Gw.EventEmitter,xo={},Vf={};Vf.byteLength=xB,Vf.toByteArray=SB,Vf.fromByteArray=TB;for(var ni=[],$t=[],_B=typeof Uint8Array<"u"?Uint8Array:Array,Pu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",va=0,kB=Pu.length;va<kB;++va)ni[va]=Pu[va],$t[Pu.charCodeAt(va)]=va;$t[45]=62,$t[95]=63;function Yw(e){var n=e.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=n);var i=t===n?0:4-t%4;return[t,i]}function xB(e){var n=Yw(e),t=n[0],i=n[1];return(t+i)*3/4-i}function EB(e,n,t){return(n+t)*3/4-t}function SB(e){var n,t=Yw(e),i=t[0],r=t[1],a=new _B(EB(e,i,r)),o=0,s=r>0?i-4:i,f;for(f=0;f<s;f+=4)n=$t[e.charCodeAt(f)]<<18|$t[e.charCodeAt(f+1)]<<12|$t[e.charCodeAt(f+2)]<<6|$t[e.charCodeAt(f+3)],a[o++]=n>>16&255,a[o++]=n>>8&255,a[o++]=n&255;return r===2&&(n=$t[e.charCodeAt(f)]<<2|$t[e.charCodeAt(f+1)]>>4,a[o++]=n&255),r===1&&(n=$t[e.charCodeAt(f)]<<10|$t[e.charCodeAt(f+1)]<<4|$t[e.charCodeAt(f+2)]>>2,a[o++]=n>>8&255,a[o++]=n&255),a}function CB(e){return ni[e>>18&63]+ni[e>>12&63]+ni[e>>6&63]+ni[e&63]}function $B(e,n,t){for(var i,r=[],a=n;a<t;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),r.push(CB(i));return r.join("")}function TB(e){for(var n,t=e.length,i=t%3,r=[],a=16383,o=0,s=t-i;o<s;o+=a)r.push($B(e,o,o+a>s?s:o+a));return i===1?(n=e[t-1],r.push(ni[n>>2]+ni[n<<4&63]+"==")):i===2&&(n=(e[t-2]<<8)+e[t-1],r.push(ni[n>>10]+ni[n>>4&63]+ni[n<<2&63]+"=")),r.join("")}var Iu={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Iu.read=function(e,n,t,i,r){var a,o,s=r*8-i-1,f=(1<<s)-1,d=f>>1,c=-7,u=t?r-1:0,h=t?-1:1,p=e[n+u];for(u+=h,a=p&(1<<-c)-1,p>>=-c,c+=s;c>0;a=a*256+e[n+u],u+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=i;c>0;o=o*256+e[n+u],u+=h,c-=8);if(a===0)a=1-d;else{if(a===f)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,i),a=a-d}return(p?-1:1)*o*Math.pow(2,a-i)},Iu.write=function(e,n,t,i,r,a){var o,s,f,d=a*8-r-1,c=(1<<d)-1,u=c>>1,h=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,g=i?1:-1,b=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(s=isNaN(n)?1:0,o=c):(o=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+u>=1?n+=h/f:n+=h*Math.pow(2,1-u),n*f>=2&&(o++,f/=2),o+u>=c?(s=0,o=c):o+u>=1?(s=(n*f-1)*Math.pow(2,r),o=o+u):(s=n*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;e[t+p]=s&255,p+=g,s/=256,r-=8);for(o=o<<r|s,d+=r;d>0;e[t+p]=o&255,p+=g,o/=256,d-=8);e[t+p-g]|=b*128};/*!
843
+ `;function zL(e){const n=l.useRef(null),t=l.useRef(null);return t.current&&t.current.update(e),l.useEffect(()=>(t.current=new Eu({...e,ref:n}),()=>{t.current=null}),[]),l.createElement("div",{ref:n})}const WL=({disabled:e,defaultEmoji:n,emoji:t,onChangeEmoji:i,classNames:r})=>{const{t:a}=vn("os"),[o,s]=kt({prop:t,onChange:i,defaultProp:n}),[f,d]=l.useState(!1),c=l.useRef(!1),[u,h]=l.useState(!1);return l.createElement(Ze.Root,{open:u,onOpenChange:p=>{c.current?(h(!1),c.current=!1):h(p)}},l.createElement(of.Root,{open:f,onOpenChange:p=>{d(p),c.current=!0}},l.createElement(Ze.Trigger,{asChild:!0},l.createElement(of.Trigger,{asChild:!0},l.createElement(mo.Button,{classNames:["gap-2 text-2xl plb-1",r],disabled:e},l.createElement("span",{className:"sr-only"},a("select emoji label")),l.createElement(qe.ImageSquare,{className:He(5)})))),l.createElement(Ze.Portal,null,l.createElement(Ze.Content,{side:"bottom",classNames:"z-50"},a("select emoji label"),l.createElement(Ze.Arrow,null))),l.createElement(of.Content,{side:"bottom",onKeyDownCapture:p=>{p.key==="Escape"&&(p.stopPropagation(),d(!1),c.current=!0)}},l.createElement(zL,{data:iL,onEmojiSelect:({native:p})=>{p&&(s(p),d(!1))},autoFocus:!0,maxFrequentRows:0,noCountryFlags:!0}),l.createElement(of.Arrow,null))))},HL=({hue:e})=>{const{tx:n}=Ae();return l.createElement("svg",{width:12,height:12,viewBox:"0 0 12 12"},l.createElement("rect",{x:0,y:0,width:12,height:12,className:n("hue.fill","select--hue__preview",{hue:e})}))},VL=({disabled:e,hue:n,onChangeHue:t,classNames:i,defaultHue:r})=>{const{t:a}=vn("os"),[o,s]=kt({prop:n,onChange:t,defaultProp:r}),[f,d]=l.useState(!1),c=l.useRef(!1),[u,h]=l.useState(!1);return l.createElement(Ze.Root,{open:u,onOpenChange:p=>{c.current?(h(!1),c.current=!1):h(p)}},l.createElement(Dn.Root,{modal:!1,open:f,onOpenChange:p=>{d(p),c.current=!0}},l.createElement(Ze.Trigger,{asChild:!0},l.createElement(Dn.Trigger,{asChild:!0},l.createElement(mo.Button,{classNames:le("gap-2 plb-1",i),disabled:e},l.createElement("span",{className:"sr-only"},a("select hue label")),l.createElement(qe.Palette,{className:He(5)})))),l.createElement(Ze.Portal,null,l.createElement(Ze.Content,{side:"bottom",classNames:"z-50"},a("select hue label"),l.createElement(Ze.Arrow,null))),l.createElement(Dn.Content,{side:"bottom"},l.createElement(Dn.Viewport,null,Object.keys(aa).map(p=>l.createElement(Dn.CheckboxItem,{key:p,checked:p===o,onCheckedChange:()=>s(p)},l.createElement(HL,{hue:p}),l.createElement("span",{className:"grow"},a(`${p} label`)),l.createElement(Dn.ItemIndicator,null,l.createElement(qe.Check,null))))),l.createElement(Dn.Arrow,null))))};var Mf={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"]},hw=e=>e.charAt(0).toUpperCase()+e.slice(1),Nf=e=>{const n=e.length*2/3,t=e.substring(0,n),i=e.substring(n),r=hw(Mf.adjectives[parseInt(t,16)%Mf.adjectives.length]),a=hw(Mf.animals[parseInt(i,16)%Mf.animals.length]);return`${r} ${a}`};const qL=l.forwardRef(({identity:e,presence:n,onClick:t,classNames:i,...r},a)=>{var d,c,u,h,p;const o=oc(e.identityKey),s=$n("identityListItem__label"),f=((d=e.profile)==null?void 0:d.displayName)??Nf(e.identityKey.toHex());return l.createElement(af.Root,{...r,classNames:le("flex gap-2 pis-3 pie-1 items-center",t&&"cursor-pointer",i),onClick:()=>t==null?void 0:t(),"data-testid":"identity-list-item",labelId:s,ref:a},l.createElement(wn.Root,{status:n===Jo.SpaceMember.PresenceState.ONLINE?"active":"inactive",labelId:s,hue:((u=(c=e.profile)==null?void 0:c.data)==null?void 0:u.hue)||o.hue},l.createElement(wn.Frame,{classNames:"place-self-center"},l.createElement(wn.Fallback,{text:((p=(h=e.profile)==null?void 0:h.data)==null?void 0:p.emoji)||o.emoji})),l.createElement(wn.Label,{classNames:"text-sm truncate pli-2"},f)))}),GL=({spaceKey:e,includeSelf:n,onSelect:t})=>{const i=Re.useClient(),r=Jo.useMembers(e),a=l.useMemo(()=>n?r.sort(o=>o.identity.identityKey.equals(i.halo.identity.get().identityKey)?-1:1):r.filter(o=>!o.identity.identityKey.equals(i.halo.identity.get().identityKey)),[r]);return l.createElement(KL,{members:a,onSelect:t})},KL=({members:e,onSelect:n})=>{const{t}=vn("os"),i=e.filter(r=>r.identity);return i.length>0?l.createElement(Fc,{classNames:"flex flex-col gap-2","data-testid":"space-members-list"},i.map(r=>l.createElement(qL,{key:r.identity.identityKey.toHex(),identity:r.identity,presence:r.presence,onClick:n&&(()=>n(r))}))):l.createElement("div",{role:"none",className:"grow flex items-center p-2"},l.createElement("p",{className:le(In,"text-center is-full mlb-2")},t("empty space members message")))},_o={weight:"duotone",width:24,height:24,x:8,y:8},YL=l.forwardRef(({device:e,onClickAdd:n,onClickEdit:t,onClickReset:i,onClickJoinExisting:r,classNames:a,...o},s)=>{var p;const{t:f}=vn("os"),d=oc(e.deviceKey),c=$n("identityListItem__label"),u=e.profile?f("device name placeholder",{os:e.profile.os,platform:e.profile.platform}):Nf(e.deviceKey.toHex()),h=e.kind===vt.DeviceKind.CURRENT;return l.createElement(af.Root,{...o,classNames:["flex gap-2 items-center mlb-2",a],"data-testid":`device-list-item${h?"-current":""}`,labelId:c,ref:s},l.createElement(wn.Root,{status:e.presence===vt.Device.PresenceState.ONLINE?"active":"inactive",labelId:c,hue:d.hue,variant:"square"},l.createElement(wn.Frame,{classNames:"place-self-center"},(p=e.profile)!=null&&p.type?e.profile.type===vt.DeviceType.BROWSER?l.createElement(qe.Compass,{..._o}):e.profile.type===vt.DeviceType.NATIVE?l.createElement(qe.Desktop,{..._o}):[vt.DeviceType.AGENT,vt.DeviceType.AGENT_MANAGED].includes(e.profile.type)?l.createElement(qe.Robot,{..._o}):e.profile.type===vt.DeviceType.MOBILE?l.createElement(qe.DeviceMobile,{..._o}):l.createElement(qe.Devices,{..._o}):l.createElement(wn.Fallback,{text:d.emoji})),h&&l.createElement(LO,{color:"primary"},f("current device tag label")),l.createElement(wn.Label,{classNames:"flex-1 text-sm truncate"},u),e.kind===vt.DeviceKind.CURRENT&&l.createElement(Dn.Root,null,l.createElement(Dn.Trigger,{asChild:!0},l.createElement(jn,{variant:"ghost",classNames:"pli-0 is-[--rail-action] bs-[--rail-action]","data-testid":`device-list-item${h?"-current":""}.options`},l.createElement("span",{className:"sr-only"},f("more options label")),l.createElement(qe.DotsThree,{className:He(5)}))),l.createElement(Dn.Content,null,l.createElement(Dn.Viewport,null,l.createElement(Dn.Item,{"data-testid":"device-list-item-current.join-existing",onClick:r},l.createElement(qe.Intersect,{className:He(5)}),f("choose join new identity label")),l.createElement(Dn.Item,{"data-testid":"device-list-item-current.reset",onClick:i},l.createElement(qe.Power,{className:He(5)}),f("reset device label")))))))}),JL=({devices:e,onClickAdd:n,onClickEdit:t,onClickReset:i,onClickJoinExisting:r})=>{const{t:a}=vn("os");return l.createElement(l.Fragment,null,l.createElement("h2",{className:le(In,"text-center mbs-4")},a("devices heading")),e.length>0&&l.createElement(Fc,null,e.map(o=>l.createElement(YL,{key:o.deviceKey.toHex(),device:o,onClickEdit:()=>t==null?void 0:t(o),onClickReset:i,onClickJoinExisting:r}))),l.createElement(jn,{variant:"ghost",classNames:"justify-start gap-2 !pis-0 !pie-3","data-testid":"devices-panel.create-invitation",onClick:n},l.createElement("div",{role:"img",className:le(He(8),"m-1 rounded-sm surface-input grid place-items-center")},l.createElement(qe.Plus,{weight:"light",className:He(6)})),l.createElement("span",{className:"grow font-medium text-start"},a("choose add device label")),l.createElement(qe.CaretRight,{weight:"bold",className:He(4)})))},Df=43200,vw=1440;function pw(e){const n=Wn(e),t=new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate(),n.getHours(),n.getMinutes(),n.getSeconds(),n.getMilliseconds()));return t.setUTCFullYear(n.getFullYear()),+e-+t}function Lf(e,n){const t=Wn(e),i=Wn(n),r=t.getTime()-i.getTime();return r<0?-1:r>0?1:r}function XL(e,n){const t=Wn(e),i=Wn(n),r=t.getFullYear()-i.getFullYear(),a=t.getMonth()-i.getMonth();return r*12+a}function ZL(e){return n=>{const i=(e?Math[e]:Math.trunc)(n);return i===0?0:i}}function QL(e,n){return+Wn(e)-+Wn(n)}function eB(e){const n=Wn(e);return n.setHours(23,59,59,999),n}function nB(e){const n=Wn(e),t=n.getMonth();return n.setFullYear(n.getFullYear(),t+1,0),n.setHours(23,59,59,999),n}function tB(e){const n=Wn(e);return+eB(n)==+nB(n)}function iB(e,n){const t=Wn(e),i=Wn(n),r=Lf(t,i),a=Math.abs(XL(t,i));let o;if(a<1)o=0;else{t.getMonth()===1&&t.getDate()>27&&t.setDate(30),t.setMonth(t.getMonth()-r*a);let s=Lf(t,i)===-r;tB(Wn(e))&&a===1&&Lf(e,i)===1&&(s=!1),o=r*(a-Number(s))}return o===0?0:o}function rB(e,n,t){const i=QL(e,n)/1e3;return ZL(t==null?void 0:t.roundingMethod)(i)}function aB(e,n,t){const i=Nk(),r=(t==null?void 0:t.locale)??i.locale??u1,a=2520,o=Lf(e,n);if(isNaN(o))throw new RangeError("Invalid time value");const s=Object.assign({},t,{addSuffix:t==null?void 0:t.addSuffix,comparison:o});let f,d;o>0?(f=Wn(n),d=Wn(e)):(f=Wn(e),d=Wn(n));const c=rB(d,f),u=(pw(d)-pw(f))/1e3,h=Math.round((c-u)/60);let p;if(h<2)return t!=null&&t.includeSeconds?c<5?r.formatDistance("lessThanXSeconds",5,s):c<10?r.formatDistance("lessThanXSeconds",10,s):c<20?r.formatDistance("lessThanXSeconds",20,s):c<40?r.formatDistance("halfAMinute",0,s):c<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):h===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",h,s);if(h<45)return r.formatDistance("xMinutes",h,s);if(h<90)return r.formatDistance("aboutXHours",1,s);if(h<vw){const g=Math.round(h/60);return r.formatDistance("aboutXHours",g,s)}else{if(h<a)return r.formatDistance("xDays",1,s);if(h<Df){const g=Math.round(h/vw);return r.formatDistance("xDays",g,s)}else if(h<Df*2)return p=Math.round(h/Df),r.formatDistance("aboutXMonths",p,s)}if(p=iB(d,f),p<12){const g=Math.round(h/Df);return r.formatDistance("xMonths",g,s)}else{const g=p%12,b=Math.trunc(p/12);return g<3?r.formatDistance("aboutXYears",b,s):g<9?r.formatDistance("overXYears",b,s):r.formatDistance("almostXYears",b+1,s)}}function oB(e,n){return aB(e,Date.now(),n)}var mw;(function(e){e[e.TRACE=5]="TRACE",e[e.DEBUG=10]="DEBUG",e[e.INFO=11]="INFO",e[e.WARN=12]="WARN",e[e.ERROR=13]="ERROR"})(mw||(mw={}));var gw;(function(e){(function(n){n[n.INCLUSIVE=1]="INCLUSIVE",n[n.EXPLICIT=2]="EXPLICIT"})(e.MatchingOptions||(e.MatchingOptions={}))})(gw||(gw={}));var bw;(function(e){e[e.ACTIVE=0]="ACTIVE",e[e.INACTIVE=1]="INACTIVE"})(bw||(bw={}));var yw;(function(e){(function(n){n[n.NONE=0]="NONE",n[n.TRUNCATE=1]="TRUNCATE",n[n.HUMANIZE=2]="HUMANIZE"})(e.KEY_OPTION||(e.KEY_OPTION={}))})(yw||(yw={}));var ww;(function(e){(function(n){n[n.BROWSER=0]="BROWSER",n[n.SHARED_WORKER=1]="SHARED_WORKER",n[n.NODE=2]="NODE"})(e.PLATFORM_TYPE||(e.PLATFORM_TYPE={}))})(ww||(ww={}));var _w;(function(e){e[e.CURRENT=0]="CURRENT",e[e.TRUSTED=1]="TRUSTED"})(_w||(_w={}));var kw;(function(e){(function(n){n[n.OFFLINE=0]="OFFLINE",n[n.ONLINE=1]="ONLINE",n[n.REMOVED=2]="REMOVED"})(e.PresenceState||(e.PresenceState={}))})(kw||(kw={}));var xw;(function(e){(function(n){n[n.OFFLINE=0]="OFFLINE",n[n.ONLINE=1]="ONLINE",n[n.REMOVED=2]="REMOVED"})(e.PresenceState||(e.PresenceState={}))})(xw||(xw={}));var Ew;(function(e){e[e.INACTIVE=2]="INACTIVE",e[e.ACTIVE=6]="ACTIVE",e[e.CLOSED=1]="CLOSED",e[e.CONTROL_ONLY=7]="CONTROL_ONLY",e[e.INITIALIZING=4]="INITIALIZING",e[e.READY=3]="READY",e[e.ERROR=5]="ERROR"})(Ew||(Ew={}));var Sw;(function(e){(function(n){n[n.NONE=0]="NONE",n[n.INIT_AUTOMERGE=1]="INIT_AUTOMERGE",n[n.PRUNE_AUTOMERGE_ROOT_HISTORY=2]="PRUNE_AUTOMERGE_ROOT_HISTORY",n[n.FRAGMENT_AUTOMERGE_ROOT=3]="FRAGMENT_AUTOMERGE_ROOT"})(e.Migration||(e.Migration={}))})(Sw||(Sw={}));var Se;(function(e){(function(n){n[n.INTERACTIVE=0]="INTERACTIVE",n[n.DELEGATED=1]="DELEGATED",n[n.MULTIUSE=2]="MULTIUSE"})(e.Type||(e.Type={})),function(n){n[n.DEVICE=0]="DEVICE",n[n.SPACE=1]="SPACE"}(e.Kind||(e.Kind={})),function(n){n[n.NONE=0]="NONE",n[n.SHARED_SECRET=1]="SHARED_SECRET",n[n.KNOWN_PUBLIC_KEY=2]="KNOWN_PUBLIC_KEY"}(e.AuthMethod||(e.AuthMethod={})),function(n){n[n.INIT=0]="INIT",n[n.CONNECTING=1]="CONNECTING",n[n.CONNECTED=2]="CONNECTED",n[n.READY_FOR_AUTHENTICATION=3]="READY_FOR_AUTHENTICATION",n[n.AUTHENTICATING=4]="AUTHENTICATING",n[n.SUCCESS=5]="SUCCESS",n[n.CANCELLED=6]="CANCELLED",n[n.TIMEOUT=7]="TIMEOUT",n[n.ERROR=8]="ERROR",n[n.EXPIRED=9]="EXPIRED"}(e.State||(e.State={}))})(Se||(Se={}));var Cw;(function(e){(function(n){n[n.ADDED=0]="ADDED",n[n.REMOVED=1]="REMOVED",n[n.SAVED=2]="SAVED",n[n.LOAD_COMPLETE=3]="LOAD_COMPLETE"})(e.Action||(e.Action={})),function(n){n[n.CREATED=0]="CREATED",n[n.ACCEPTED=1]="ACCEPTED"}(e.Type||(e.Type={}))})(Cw||(Cw={}));var $w;(function(e){e[e.OFFLINE=0]="OFFLINE",e[e.ONLINE=1]="ONLINE"})($w||($w={}));var sB=class extends Error{constructor(){super("Context disposed.")}};function fB(e,n,t,i){var r=arguments.length,a=r<3?n:i===null?i=Object.getOwnPropertyDescriptor(n,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(e,n,t,i);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(r<3?o(a):r>3?o(n,t,a):o(n,t))||a);return r>3&&a&&Object.defineProperty(n,t,a),a}var Su="/home/runner/work/dxos/dxos/packages/common/context/src/context.ts",lB=300,Tw,Aw,Ow=(Sa=class{constructor({onError:n=r=>{if(!(r instanceof sB))throw this.dispose(),r},attributes:t={},parent:i}={}){this._disposeCallbacks=[],this._isDisposed=!1,this._disposePromise=void 0,this._parent=null,this.maxSafeDisposeCallbacks=lB,this[Tw]="Context",this[Aw]=()=>this.toString(),this._onError=n,this._attributes=t,i!==void 0&&(this._parent=i)}static default(){return new Sa}get disposed(){return this._isDisposed}get disposeCallbacksLength(){return this._disposeCallbacks.length}onDispose(n){return this._isDisposed&&(async()=>{try{await n()}catch(t){Ge.catch(t,void 0,{F:Su,L:88,S:this,C:(i,r)=>i(...r)})}})(),this._disposeCallbacks.push(n),this._disposeCallbacks.length>this.maxSafeDisposeCallbacks&&Ge.warn("Context has a large number of dispose callbacks. This might be a memory leak.",{count:this._disposeCallbacks.length,safeThreshold:this.maxSafeDisposeCallbacks},{F:Su,L:95,S:this,C:(t,i)=>t(...i)}),()=>{const t=this._disposeCallbacks.indexOf(n);t!==-1&&this._disposeCallbacks.splice(t,1)}}async dispose(){if(this._disposePromise)return this._disposePromise;this._isDisposed=!0;let n;this._disposePromise=new Promise(i=>{n=i});const t=Array.from(this._disposeCallbacks).reverse();this._disposeCallbacks.length=0;for(const i of t)try{await i()}catch(r){Ge.catch(r,void 0,{F:Su,L:136,S:this,C:(a,o)=>a(...o)})}n()}raise(n){if(!this._isDisposed)try{this._onError(n)}catch(t){Promise.reject(t)}}derive({onError:n,attributes:t}={}){const i=new Sa({onError:async a=>{if(!n)this.raise(a);else try{await n(a)}catch{this.raise(a)}},attributes:t}),r=this.onDispose(()=>i.dispose());return i.onDispose(r),i}getAttribute(n){if(n in this._attributes)return this._attributes[n];if(this._parent!==null)return this._parent.getAttribute(n)}toString(){return`Context(${this._isDisposed?"disposed":"active"})`}},Tw=Symbol.toStringTag,Aw=Et.custom,Sa);Ow=fB([p$("Context")],Ow);var Pw;(function(e){e.CLOSED="CLOSED",e.OPEN="OPEN",e.ERROR="ERROR"})(Pw||(Pw={}));var Bf={};Object.defineProperty(Bf,"__esModule",{value:!0}),Bf.Observable=void 0;const Iw=e=>!!Symbol[e],Cu=e=>Iw(e)?Symbol[e]:"@@"+e,dB=Cu("iterator"),$u=Cu("observable"),Fw=Cu("species");function jf(e,n){let t=e[n];if(t!=null){if(typeof t!="function")throw new TypeError(t+" is not a function");return t}}function ko(e){let n=e.constructor;return n!==void 0&&(n=n[Fw],n===null&&(n=void 0)),n!==void 0?n:Uf}function cB(e){return e instanceof Uf}function ua(e){ua.log?ua.log(e):setTimeout(()=>{throw e})}function Rf(e){Promise.resolve().then(()=>{try{e()}catch(n){ua(n)}})}function Mw(e){let n=e._cleanup;if(n!==void 0&&(e._cleanup=void 0,!!n))try{if(typeof n=="function")n();else{let t=jf(n,"unsubscribe");t&&t.call(n)}}catch(t){ua(t)}}function Tu(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function uB(e){let n=e._queue;if(n){e._queue=void 0,e._state="ready";for(let t=0;t<n.length&&(Nw(e,n[t].type,n[t].value),e._state!=="closed");++t);}}function Nw(e,n,t){e._state="running";let i=e._observer;try{let r=jf(i,n);switch(n){case"next":r&&r.call(i,t);break;case"error":if(Tu(e),r)r.call(i,t);else throw t;break;case"complete":Tu(e),r&&r.call(i);break}}catch(r){ua(r)}e._state==="closed"?Mw(e):e._state==="running"&&(e._state="ready")}function Au(e,n,t){if(e._state!=="closed"){if(e._state==="buffering"){e._queue.push({type:n,value:t});return}if(e._state!=="ready"){e._state="buffering",e._queue=[{type:n,value:t}],Rf(()=>uB(e));return}Nw(e,n,t)}}class hB{constructor(n,t){this._cleanup=void 0,this._observer=n,this._queue=void 0,this._state="initializing";let i=this,r={get closed(){return i._state==="closed"},next(a){Au(i,"next",a)},error(a){Au(i,"error",a)},complete(){Au(i,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(a){r.error(a)}this._state==="initializing"&&(this._state="ready")}get closed(){return this._state==="closed"}unsubscribe(){this._state!=="closed"&&(Tu(this),Mw(this))}}let Uf=class Ol{constructor(n){if(!(this instanceof Ol))throw new TypeError("Observable cannot be called as a function");if(typeof n!="function")throw new TypeError("Observable initializer must be a function");this._subscriber=n}subscribe(n){return(typeof n!="object"||n===null)&&(n={next:n,error:arguments[1],complete:arguments[2]}),new hB(n,this._subscriber)}forEach(n){return new Promise((t,i)=>{if(typeof n!="function"){i(new TypeError(n+" is not a function"));return}function r(){a.unsubscribe(),t()}let a=this.subscribe({next(o){try{n(o,r)}catch(s){i(s),a.unsubscribe()}},error:i,complete:t})})}map(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>this.subscribe({next(r){try{r=n(r)}catch(a){return i.error(a)}i.next(r)},error(r){i.error(r)},complete(){i.complete()}}))}filter(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>this.subscribe({next(r){try{if(!n(r))return}catch(a){return i.error(a)}i.next(r)},error(r){i.error(r)},complete(){i.complete()}}))}reduce(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this),i=arguments.length>1,r=!1,o=arguments[1];return new t(s=>this.subscribe({next(f){let d=!r;if(r=!0,!d||i)try{o=n(o,f)}catch(c){return s.error(c)}else o=f},error(f){s.error(f)},complete(){if(!r&&!i)return s.error(new TypeError("Cannot reduce an empty sequence"));s.next(o),s.complete()}}))}async all(){let n=[];return await this.forEach(t=>n.push(t)),n}concat(...n){let t=ko(this);return new t(i=>{let r,a=0;function o(s){r=s.subscribe({next(f){i.next(f)},error(f){i.error(f)},complete(){a===n.length?(r=void 0,i.complete()):o(t.from(n[a++]))}})}return o(this),()=>{r&&(r.unsubscribe(),r=void 0)}})}flatMap(n){if(typeof n!="function")throw new TypeError(n+" is not a function");let t=ko(this);return new t(i=>{let r=[],a=this.subscribe({next(s){if(n)try{s=n(s)}catch(d){return i.error(d)}let f=t.from(s).subscribe({next(d){i.next(d)},error(d){i.error(d)},complete(){let d=r.indexOf(f);d>=0&&r.splice(d,1),o()}});r.push(f)},error(s){i.error(s)},complete(){o()}});function o(){a.closed&&r.length===0&&i.complete()}return()=>{r.forEach(s=>s.unsubscribe()),a.unsubscribe()}})}[$u](){return this}static from(n){let t=typeof this=="function"?this:Ol;if(n==null)throw new TypeError(n+" is not an object");let i=jf(n,$u);if(i){let r=i.call(n);if(Object(r)!==r)throw new TypeError(r+" is not an object");return cB(r)&&r.constructor===t?r:new t(a=>r.subscribe(a))}if(Iw("iterator")&&(i=jf(n,dB),i))return new t(r=>{Rf(()=>{if(!r.closed){for(let a of i.call(n))if(r.next(a),r.closed)return;r.complete()}})});if(Array.isArray(n))return new t(r=>{Rf(()=>{if(!r.closed){for(let a=0;a<n.length;++a)if(r.next(n[a]),r.closed)return;r.complete()}})});throw new TypeError(n+" is not observable")}static of(...n){let t=typeof this=="function"?this:Ol;return new t(i=>{Rf(()=>{if(!i.closed){for(let r=0;r<n.length;++r)if(i.next(n[r]),i.closed)return;i.complete()}})})}static get[Fw](){return this}};Bf.Observable=Uf,Object.defineProperty(Uf,Symbol("extensions"),{value:{symbol:$u,hostReportError:ua},configurable:!0});var vB=Bf.Observable;const zf=Qi(vB);var Dw={exports:{}},Ou={exports:{}},ha=typeof Reflect=="object"?Reflect:null,Lw=ha&&typeof ha.apply=="function"?ha.apply:function(n,t,i){return Function.prototype.apply.call(n,t,i)},Wf;ha&&typeof ha.ownKeys=="function"?Wf=ha.ownKeys:Object.getOwnPropertySymbols?Wf=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Wf=function(n){return Object.getOwnPropertyNames(n)};function pB(e){console&&console.warn&&console.warn(e)}var Bw=Number.isNaN||function(n){return n!==n};function gn(){gn.init.call(this)}Ou.exports=gn,Ou.exports.once=yB,gn.EventEmitter=gn,gn.prototype._events=void 0,gn.prototype._eventsCount=0,gn.prototype._maxListeners=void 0;var jw=10;function Hf(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(gn,"defaultMaxListeners",{enumerable:!0,get:function(){return jw},set:function(e){if(typeof e!="number"||e<0||Bw(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");jw=e}}),gn.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},gn.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Bw(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Rw(e){return e._maxListeners===void 0?gn.defaultMaxListeners:e._maxListeners}gn.prototype.getMaxListeners=function(){return Rw(this)},gn.prototype.emit=function(n){for(var t=[],i=1;i<arguments.length;i++)t.push(arguments[i]);var r=n==="error",a=this._events;if(a!==void 0)r=r&&a.error===void 0;else if(!r)return!1;if(r){var o;if(t.length>0&&(o=t[0]),o instanceof Error)throw o;var s=new Error("Unhandled error."+(o?" ("+o.message+")":""));throw s.context=o,s}var f=a[n];if(f===void 0)return!1;if(typeof f=="function")Lw(f,this,t);else for(var d=f.length,c=Vw(f,d),i=0;i<d;++i)Lw(c[i],this,t);return!0};function Uw(e,n,t,i){var r,a,o;if(Hf(t),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",n,t.listener?t.listener:t),a=e._events),o=a[n]),o===void 0)o=a[n]=t,++e._eventsCount;else if(typeof o=="function"?o=a[n]=i?[t,o]:[o,t]:i?o.unshift(t):o.push(t),r=Rw(e),r>0&&o.length>r&&!o.warned){o.warned=!0;var s=new Error("Possible EventEmitter memory leak detected. "+o.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");s.name="MaxListenersExceededWarning",s.emitter=e,s.type=n,s.count=o.length,pB(s)}return e}gn.prototype.addListener=function(n,t){return Uw(this,n,t,!1)},gn.prototype.on=gn.prototype.addListener,gn.prototype.prependListener=function(n,t){return Uw(this,n,t,!0)};function mB(){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 zw(e,n,t){var i={fired:!1,wrapFn:void 0,target:e,type:n,listener:t},r=mB.bind(i);return r.listener=t,i.wrapFn=r,r}gn.prototype.once=function(n,t){return Hf(t),this.on(n,zw(this,n,t)),this},gn.prototype.prependOnceListener=function(n,t){return Hf(t),this.prependListener(n,zw(this,n,t)),this},gn.prototype.removeListener=function(n,t){var i,r,a,o,s;if(Hf(t),r=this._events,r===void 0)return this;if(i=r[n],i===void 0)return this;if(i===t||i.listener===t)--this._eventsCount===0?this._events=Object.create(null):(delete r[n],r.removeListener&&this.emit("removeListener",n,i.listener||t));else if(typeof i!="function"){for(a=-1,o=i.length-1;o>=0;o--)if(i[o]===t||i[o].listener===t){s=i[o].listener,a=o;break}if(a<0)return this;a===0?i.shift():gB(i,a),i.length===1&&(r[n]=i[0]),r.removeListener!==void 0&&this.emit("removeListener",n,s||t)}return this},gn.prototype.off=gn.prototype.removeListener,gn.prototype.removeAllListeners=function(n){var t,i,r;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[n]),this;if(arguments.length===0){var a=Object.keys(i),o;for(r=0;r<a.length;++r)o=a[r],o!=="removeListener"&&this.removeAllListeners(o);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(t=i[n],typeof t=="function")this.removeListener(n,t);else if(t!==void 0)for(r=t.length-1;r>=0;r--)this.removeListener(n,t[r]);return this};function Ww(e,n,t){var i=e._events;if(i===void 0)return[];var r=i[n];return r===void 0?[]:typeof r=="function"?t?[r.listener||r]:[r]:t?bB(r):Vw(r,r.length)}gn.prototype.listeners=function(n){return Ww(this,n,!0)},gn.prototype.rawListeners=function(n){return Ww(this,n,!1)},gn.listenerCount=function(e,n){return typeof e.listenerCount=="function"?e.listenerCount(n):Hw.call(e,n)},gn.prototype.listenerCount=Hw;function Hw(e){var n=this._events;if(n!==void 0){var t=n[e];if(typeof t=="function")return 1;if(t!==void 0)return t.length}return 0}gn.prototype.eventNames=function(){return this._eventsCount>0?Wf(this._events):[]};function Vw(e,n){for(var t=new Array(n),i=0;i<n;++i)t[i]=e[i];return t}function gB(e,n){for(;n+1<e.length;n++)e[n]=e[n+1];e.pop()}function bB(e){for(var n=new Array(e.length),t=0;t<n.length;++t)n[t]=e[t].listener||e[t];return n}function yB(e,n){return new Promise(function(t,i){function r(o){e.removeListener(n,a),i(o)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",r),t([].slice.call(arguments))}qw(e,n,a,{once:!0}),n!=="error"&&wB(e,r,{once:!0})})}function wB(e,n,t){typeof e.on=="function"&&qw(e,"error",n,t)}function qw(e,n,t,i){if(typeof e.on=="function")i.once?e.once(n,t):e.on(n,t);else if(typeof e.addEventListener=="function")e.addEventListener(n,function r(a){i.once&&e.removeEventListener(n,r),t(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Gw=Ou.exports,Kw=Gw.EventEmitter,xo={},Vf={};Vf.byteLength=xB,Vf.toByteArray=SB,Vf.fromByteArray=TB;for(var ni=[],$t=[],_B=typeof Uint8Array<"u"?Uint8Array:Array,Pu="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",va=0,kB=Pu.length;va<kB;++va)ni[va]=Pu[va],$t[Pu.charCodeAt(va)]=va;$t[45]=62,$t[95]=63;function Yw(e){var n=e.length;if(n%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var t=e.indexOf("=");t===-1&&(t=n);var i=t===n?0:4-t%4;return[t,i]}function xB(e){var n=Yw(e),t=n[0],i=n[1];return(t+i)*3/4-i}function EB(e,n,t){return(n+t)*3/4-t}function SB(e){var n,t=Yw(e),i=t[0],r=t[1],a=new _B(EB(e,i,r)),o=0,s=r>0?i-4:i,f;for(f=0;f<s;f+=4)n=$t[e.charCodeAt(f)]<<18|$t[e.charCodeAt(f+1)]<<12|$t[e.charCodeAt(f+2)]<<6|$t[e.charCodeAt(f+3)],a[o++]=n>>16&255,a[o++]=n>>8&255,a[o++]=n&255;return r===2&&(n=$t[e.charCodeAt(f)]<<2|$t[e.charCodeAt(f+1)]>>4,a[o++]=n&255),r===1&&(n=$t[e.charCodeAt(f)]<<10|$t[e.charCodeAt(f+1)]<<4|$t[e.charCodeAt(f+2)]>>2,a[o++]=n>>8&255,a[o++]=n&255),a}function CB(e){return ni[e>>18&63]+ni[e>>12&63]+ni[e>>6&63]+ni[e&63]}function $B(e,n,t){for(var i,r=[],a=n;a<t;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(e[a+2]&255),r.push(CB(i));return r.join("")}function TB(e){for(var n,t=e.length,i=t%3,r=[],a=16383,o=0,s=t-i;o<s;o+=a)r.push($B(e,o,o+a>s?s:o+a));return i===1?(n=e[t-1],r.push(ni[n>>2]+ni[n<<4&63]+"==")):i===2&&(n=(e[t-2]<<8)+e[t-1],r.push(ni[n>>10]+ni[n>>4&63]+ni[n<<2&63]+"=")),r.join("")}var Iu={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Iu.read=function(e,n,t,i,r){var a,o,s=r*8-i-1,f=(1<<s)-1,d=f>>1,c=-7,u=t?r-1:0,h=t?-1:1,p=e[n+u];for(u+=h,a=p&(1<<-c)-1,p>>=-c,c+=s;c>0;a=a*256+e[n+u],u+=h,c-=8);for(o=a&(1<<-c)-1,a>>=-c,c+=i;c>0;o=o*256+e[n+u],u+=h,c-=8);if(a===0)a=1-d;else{if(a===f)return o?NaN:(p?-1:1)*(1/0);o=o+Math.pow(2,i),a=a-d}return(p?-1:1)*o*Math.pow(2,a-i)},Iu.write=function(e,n,t,i,r,a){var o,s,f,d=a*8-r-1,c=(1<<d)-1,u=c>>1,h=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,p=i?0:a-1,g=i?1:-1,b=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(s=isNaN(n)?1:0,o=c):(o=Math.floor(Math.log(n)/Math.LN2),n*(f=Math.pow(2,-o))<1&&(o--,f*=2),o+u>=1?n+=h/f:n+=h*Math.pow(2,1-u),n*f>=2&&(o++,f/=2),o+u>=c?(s=0,o=c):o+u>=1?(s=(n*f-1)*Math.pow(2,r),o=o+u):(s=n*Math.pow(2,u-1)*Math.pow(2,r),o=0));r>=8;e[t+p]=s&255,p+=g,s/=256,r-=8);for(o=o<<r|s,d+=r;d>0;e[t+p]=o&255,p+=g,o/=256,d-=8);e[t+p-g]|=b*128};/*!
844
844
  * The buffer module from node.js, for the browser.
845
845
  *
846
846
  * @author Feross Aboukhadijeh <https://feross.org>