1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./Index-cqVcxhkX.js","./index-Bq2njFOY.js","./index-JtiO_h80.css","./Block-DNK-JdLJ.js","./ScrollFade.svelte_svelte_type_style_lang-D0JPkGar.js","./snippet-BG7qkY_1.js","./ScrollFade-DXC81vHi.css","./MarkdownCode.svelte_svelte_type_style_lang-B29zDiob.js","./prism-python-NrKIQnfs.js","./MarkdownCode-hl0Esrgh.css","./utils.svelte-Bi9ASwv9.js","./index-1GCmrSlD.js","./StreamingBar.svelte_svelte_type_style_lang-DWGn5tT_.js","./html-Bwif0JPw.js","./StreamingBar-M0OJiclA.css","./Clear-C8Tfa7QP.js","./Index.svelte_svelte_type_style_lang-B7TVXWMD.js","./Index-D0q0pAfU.css","./Index-CVv5Ke0n.css","./Index-c5VDWsdo.js","./BlockLabel-VpI11pHf.js","./Empty-BrRNpJ3n.js","./Image-DfZjI5oa.js","./IconButtonWrapper-DAsvkfJg.js","./FullscreenButton-C6RgeACK.js","./Maximize-2N5airbC.js","./Index-KYyPl9cR.css","./StaticAudio-CWETG3mI.js","./DownloadLink-D6EYxQxh.js","./ShareButton-CORLYhd9.js","./Download-D5ZNT7uE.js","./Music-Dzd6j5YE.js","./MinimalAudioPlayer-BNuZEaxr.js","./MinimalAudioPlayer-B6PFUF9w.css","./VolumeLevels-DLuAAZ7X.js","./Play-CGGxKNeS.js","./Undo-4MCSCpCy.js","./StaticAudio-BZBUSA4E.css","./Example-D-PFeR7G.js","./Example-DQklQyrP.css","./index-hf62j3_c.js","./Upload-xR3P-2U5.js","./actions-CgRQ2lHA.js","./Upload-B9AbOy1B.css","./ModifyUpload-BzhUWnkZ.js","./Edit-5wNBI2yr.js","./StreamingBar-YIqBWk77.js","./record.esm-BVY9RaAH.js","./Spinner-CGjvf4Sm.js","./UploadText-C6bbM_PO.js","./index-BPHXGoIf.css","./Index-BIfnw3Df.js","./Index-CeOGJPri.js","./__vite-browser-external-CVaeKfQx.js","./Index-Dk8LP6SU.js","./Button-By21KHDn.js","./Image-XuMqTTwB.js","./misc-D8a4ZbMA.js","./Image-DQfoGqtb.css","./Button-CoUFCYL9.css","./ImagePreview-CAbFrrhc.css","./Index-D6KKbqPS.js","./input-CXpCw23l.js","./Check-BKMHx_DF.js","./Copy-BQlJe6-D.js","./File-BiXBtg1a.js","./MarkdownCode-BYKuypS7.js","./event-modifiers-DanhKw3_.js","./index-By61_kAe.js","./Trash-DePlRUVn.js","./Index-uA5k4uH0.css","./Example-lKnDE0-B.js","./Example-bEuOGW3l.css","./Index-BHGkz0L8.js","./Info-CfqzbVCN.js","./Checkbox-dsIC6373.js","./Checkbox-CJBAs2gn.css","./Example-MOIw3ihL.js","./Example-Bq3fAzQx.css","./Index-CnKzAZJw.js","./BlockTitle-Bcj082QO.js","./index-DnoGeqVF.js","./Index-B-Ce7cpr.css","./Example-BYnu_U1h.js","./Example-ZgyKzkPU.css","./Index-DnoopRVS.js","./Code-DQLc8-1z.js","./Code-DSw5753G.css","./Code-CxRgOnU2.js","./Example-DmGLofMR.js","./Example-BpLG3o2o.css","./Index-cXoSwrVM.js","./tinycolor-fdIevY-E.js","./Index-CbmayjvD.css","./Index-BnPF6xy8.js","./index-CjLnGHRW.js","./Example-CSyNUPmz.js","./Example-B0qjHn8W.css","./Index-BOG-LPoW.js","./dsv-BhAd467f.js","./props-o1aFOJaB.js","./size-CWi277d_.js","./DropdownArrow-3lFHYtTD.js","./Index-NsAb-q5h.css","./Index-_a-G1TDi.js","./key-CQEYzg1f.js","./Textbox-BXTb2K73.js","./Send-CFiHLThw.js","./Square-kMgNk9Wy.js","./Textbox-DbZXQzbK.css","./Example-DYo_cEEb.js","./Example-BlSzJhEn.css","./Index-9MMRKKEp.css","./Example-kRad1aPe.js","./Index-D_siBrGR.js","./Index-1AccPlNI.css","./Example-CM1i7hYA.js","./Example-B67Cdnj0.css","./Index-B_Gnb4iA.js","./Plus-CjgGs6LE.js","./Dropdown-BhOh_Yz2.js","./window-BVsmErEt.js","./Dropdown-_c0K7TyY.css","./Index-v1iUT5Sq.css","./Example-ml6sVHU8.css","./Index-B6aCVBT9.js","./Index-dUn14qUu.css","./Index-oRYO6L1a.js","./Index-CR7_W0IB.css","./Example-DldcLCBj.js","./Index-lqZQIaLn.js","./Example-USFi6Hps.js","./Example-CHp_DfzD.css","./Index-Dk7G-RHg.js","./FileUpload-Cvp8_L6I.js","./FileUpload-DhzRhTM7.css","./Example-DQSMQK5Q.js","./Example-Bm-XFf-B.css","./Index-BXduP1J1.js","./Index-CL7x-fxw.css","./Index-Ckn3lSIv.js","./BaseForm-BF0VUPNl.js","./BaseForm-B79fGGKa.css","./Gallery-D9uGL0FX.js","./Video-e9Pn2mbW.js","./Video-BNtsM6tz.css","./Gallery-DU7oBqxe.css","./Example-BstfUWdZ.js","./Example-Cq74O62D.css","./Index-C8iEj0i6.js","./Webcam-CIJ5MvIX.js","./ImageUploader-79Z_jqCu.css","./Index-BlyT2RM2.css","./Example-BDoLBXEz.css","./Index-CG0iU8MX.js","./Index-ipOE50af.css","./Index-mY6Ayb2J.js","./color-DjQxWyAx.js","./Index-DxNvd7lC.css","./HTML-DlbkPABy.js","./HTML-Czz-mkVb.css","./Example-DU6ARnKW.js","./Example-1AHPPrE3.css","./Index-8RVq3tR4.js","./Index-Bdoky1Bb.css","./ImagePreview-XayhIqNU.js","./Example-4MLRTjBC.js","./Index-D2rmpk1k.js","./Example-YlQBeDNh.js","./Example-b2fpUOu4.css","./Index-CvN5jvte.js","./ArrowUp-BfdIRWRH.js","./Index-EIiVYsEh.css","./Example-DA82qMyB.js","./Example-YdVSiIuW.css","./Index-DC3IOpLR.js","./select-k8gDf_61.js","./dispatch-tQmgj1It.js","./Index-BebY3ZUz.css","./Example-CXb8xdQD.js","./JSON-D22hEneH.js","./JSON-DCdmtE2W.css","./Example-BmdzPZC6.css","./Index-DPsbjNiT.js","./Index-CBd_MhXJ.js","./LineChart-CeHNJMuj.js","./Index-CwrN3-r3.css","./Example-DUe-V0Ld.js","./Example-CNix_cQb.css","./Index-DzadCq8f.js","./Index.svelte_svelte_type_style_lang-BIr0F_Dm.js","./Index-BEAewkRY.css","./ScrollFade-CRDohWU-.js","./Model3D-DJQlKi0w.js","./Model3D-C7UzhPnn.css","./Example-DqjmrGmx.js","./Example-BcEr-euO.css","./Index-dV3_KR7K.js","./Index-amT-rIdI.css","./Example-Ciz_10jH.js","./Example-DCuDV3ni.css","./Index-m9n9xbaM.js","./Index-BcxwxuuF.css","./Example-CN-EkgaQ.js","./Index-DaT_S5Dl.js","./Index-qjglRoiX.css","./Index-Bq3RRF73.js","./Example-Cd055f6G.js","./Example-CtUXmdvx.js","./Example-CilajK2g.css","./Index-D5QhI0w9.js","./Index-D6Y3g9po.css","./Example-r8MvLd1a.js","./Example-D6QAAQGU.css","./Index-CMslNhWu.js","./Index-DG6p_pXP.css","./Plot-Bv7e-GKH.js","./Index-BLvIY0lP.js","./Example-ByABbZIR.js","./Example-l4VocDuK.css","./Index-CEkl9UYg.js","./Index-AZOUIcs_.css","./Index-Cyy7LoUW.js","./Index-BnASDwkz.css","./Index-D998CuPi.js","./Index-Dhk15SNf.css","./Example-dmTBkWCg.js","./Example-DEZCrt3g.css","./Index-CClIgVld.js","./Index-Dk23IKH5.css","./Index-zaGJoSm-.js","./index-CHTHcz5h.js","./state.svelte-eX_HNnCz.js","./Index-CvusdnXc.js","./Walkthrough.svelte_svelte_type_style_lang-DyYjqewg.js","./Walkthrough-CTImcoqj.css","./Index-D2fA4viL.css","./Index-BPZgH1F4.js","./Index-DIT5pDCQ.js","./Index-CybaYxJS.js","./Index-0rZUl0Zh.js","./Index-DCXyjWeM.css","./Index-BZjnJz9D.js","./Index-Dm9eNXb9.css","./VideoPreview-D1Zp6agR.js","./VideoPreview-CMRZnztY.css","./Example-CwC21_Sq.js","./Example-Bqpu_FoT.css","./index-VE26-3z-.js","./index-BcUNcoUa.css","./Example-wPalRDrs.js","./Example-mgLMZyqj.css","./Index-DC50X8S0.js","./Index-DOcbyfJN.css"])))=>i.map(i=>d[i]); 2import { G as current_batch, b2 as resume_effect, b3 as destroy_effect, b4 as pause_effect, an as create_text, b5 as branch, b6 as move_effect, b7 as should_defer_append, h as hydrating, i as hydrate_node, p as block, E as EFFECT_TRANSPARENT, e as hydrate_next, b8 as read_hydration_instruction, aJ as HYDRATION_START_ELSE, aK as skip_nodes, s as set_hydrate_node, aq as set_hydrating, Z as get$1, aC as internal_set, b9 as EACH_IS_CONTROLLED, ae as derived_safe_equal, W as is_array, ba as array_from, D as DEV, bb as EACH_ITEM_REACTIVE, bc as EACH_ITEM_IMMUTABLE, a0 as mutable_source, aG as source, bd as EACH_INDEX_REACTIVE, be as EFFECT_OFFSCREEN, bf as INERT, J as queue_micro_task, bg as EACH_IS_ANIMATED, bh as clear_text_content, j as get_next_sibling, g as get_first_child, C as COMMENT_NODE, bi as HYDRATION_END, bj as managed, u as effect, bk as select_multiple_invalid_value, L as is, v as teardown, A as listen_to_event_and_reset_event, K as previous_batch, bl as LOADING_ATTR_SYMBOL, aM as flatten, bm as ATTACHMENT_KEY, bn as NAMESPACE_HTML, ax as get_prototype_of, bo as is_capture_event, bp as create_event, ai as delegate, ak as autofocus, bq as normalize_attribute, aH as UNINITIALIZED, br as can_delegate_event, bs as get_descriptors, bt as add_form_reset_listener, bu as hydration_attribute_changed, x as render_effect, w as untrack, bv as STATE_SYMBOL, bw as component_context, ah as user_pre_effect, ad as user_effect, bx as run_all, by as run, y as deep_read_state, bz as derived$1, a$ as noop, z as safe_not_equal, $ as set$1, bA as define_property, a6 as get_descriptor, bB as props_invali
2d_value, bC as PROPS_IS_UPDATED, ac as proxy, b as active_effect, bD as DESTROYED, bE as PROPS_IS_BINDABLE, bF as PROPS_IS_IMMUTABLE, bG as PROPS_IS_LAZY_INITIAL, bH as is_destroying_effect, a_ as is_function, bI as LEGACY_PROPS, aT as update, bJ as set_active_effect, bK as props_rest_readonly, bL as legacy_mode_flag, bM as PROPS_IS_RUNES, bN as enable_legacy_mode_flag, bO as enable_async_mode_flag, M as push, Y as legacy_pre_effect, _ as legacy_pre_effect_reset, t as template_effect, a as append, O as pop, R as from_html, P as flushSync, S as sibling, Q as child, X as set_text, a2 as user_derived, as as to_array, T as reset, a5 as next, ag as __vitePreload } from './index-Bq2njFOY.js'; 3 4/** @import { Effect, TemplateNode } from '#client' */ 5 6/** 7 * @typedef {{ effect: Effect, fragment: DocumentFragment }} Branch 8 */ 9 10/** 11 * @template Key 12 */ 13class BranchManager { 14 /** @type {TemplateNode} */ 15 anchor; 16 17 /** @type {Map<Batch, Key>} */ 18 #batches = new Map(); 19 20 /** 21 * Map of keys to effects that are currently rendered in the DOM. 22 * These effects are visible and actively part of the document tree. 23 * Example: 24 * ``` 25 * {#if condition} 26 * foo 27 * {:else} 28 * bar 29 * {/if} 30 * ``` 31 * Can result in the entries `true->Effect` and `false->Effect` 32 * @type {Map<Key, Effect>} 33 */ 34 #onscreen = new Map(); 35 36 /** 37 * Similar to #onscreen with respect to the keys, but contains branches that are not yet 38 * in the DOM, because their insertion is deferred. 39 * @type {Map<Key, Branch>} 40 */ 41 #offscreen = new Map(); 42 43 /** 44 * Keys of effects that are currently outroing 45 * @type {Set<Key>} 46 */ 47 #outroing = new Set(); 48 49 /** 50 * Whether to pause (i.e. outro) on change, or destroy immediately. 51 * This is necessary for `<svelte:element>` 52 */ 53 #transition = true; 54 55 /** 56 * @param {TemplateNode} anchor 57 * @param {boolean} transition 58 */ 59 constructor(anchor, transition = true) { 60 this.anchor = anchor; 61 this.#transition = transition; 62 } 63 64 #commit = () => { 65 var batch = /** @type {Batch} */ (current_batch); 66 67 // if this batch was made obsolete, bail 68 if (!this.#batches.has(batch)) return; 69 70 var key = /** @type {Key} */ (this.#batches.get(batch)); 71 72 var onscreen = this.#onscreen.get(key); 73 74 if (onscreen) { 75 // effect is already in the DOM â abort any current outro 76 resume_effect(onscreen); 77 this.#outroing.delete(key); 78 } else { 79 // effect is currently offscreen. put it in the DOM 80 var offscreen = this.#offscreen.get(key); 81 82 if (offscreen) { 83 this.#onscreen.set(key, offscreen.effect); 84 this.#offscreen.delete(key); 85 86 // remove the anchor... 87 /** @type {TemplateNode} */ (offscreen.fragment.lastChild).remove(); 88 89 // ...and append the fragment 90 this.anchor.before(offscreen.fragment); 91 onscreen = offscreen.effect; 92 } 93 } 94 95 for (const [b, k] of this.#batches) { 96 this.#batches.delete(b); 97 98 if (b === batch) { 99 // keep values for newer batches 100 break; 101 } 102 103 const offscreen = this.#offscreen.get(k); 104 105 if (offscreen) { 106 // for older batches, destroy offscreen effects 107 // as they will never be committed 108 destroy_effect(offscreen.effect); 109 this.#offscreen.delete(k); 110 } 111 } 112 113 // outro/destroy all onscreen effects... 114 for (const [k, effect] of this.#onscreen) { 115 // ...except the one that was just committed 116 // or those that are already outroing (else the transition is aborted and the effect destroyed right away) 117 if (k === key || this.#outroing.has(k)) continue; 118 119 const on_destroy = () => { 120 const keys = Array.from(this.#batches.values()); 121 122 if (keys.includes(k)) { 123 // keep the effect offscreen, as another batch will need it 124 var fragment = document.createDocumentFragment(); 125 move_effect(effect, fragment); 126 127 fragment.append(create_text()); // TODO can we avoid this? 128 129 this.#offscreen.set(k, { effect, fragment }); 130 } else { 131 destroy_effect(effect); 132 } 133 134 this.#outroing.delete(k); 135 this.#onscreen.delete(k); 136 }; 137 138 if (this.#transition || !onscreen) { 139 this.#outroing.add(k); 140 pause_effect(effect, on_destroy, false); 141 } else { 142 on_destroy(); 143 } 144 } 145 }; 146 147 /** 148 * @param {Batch} batch 149 */ 150 #discard = (batch) => { 151 this.#batches.delete(batch); 152 153 const keys = Array.from(this.#batches.values()); 154 155 for (const [k, branch] of this.#offscreen) { 156 if (!keys.includes(k)) { 157 destroy_effect(branch.effect); 158 this.#offscreen.delete(k); 159 } 160 } 161 }; 162 163 /** 164 * 165 * @param {any} key 166 * @param {null | ((target: TemplateNode) => void)} fn 167 */ 168 ensure(key, fn) { 169 var batch = /** @type {Batch} */ (current_batch); 170 var defer = should_defer_append(); 171 172 if (fn && !this.#onscreen.has(key) && !this.#offscreen.has(key)) { 173 if (defer) { 174 var fragment = document.createDocumentFragment(); 175 var target = create_text(); 176 177 fragment.append(target); 178 179 this.#offscreen.set(key, { 180 effect: branch(() => fn(target)), 181 fragment 182 }); 183 } else { 184 this.#onscreen.set( 185 key, 186 branch(() => fn(this.anchor)) 187 ); 188 } 189 } 190 191 this.#batches.set(batch, key); 192 193 if (defer) { 194 for (const [k, effect] of this.#onscreen) { 195 if (k === key) { 196 batch.skipped_effects.delete(effect); 197 } else { 198 batch.skipped_effects.add(effect); 199 } 200 } 201 202 for (const [k, branch] of this.#offscreen) { 203 if (k === key) { 204 batch.skipped_effects.delete(branch.effect); 205 } else { 206 batch.skipped_effects.add(branch.effect); 207 } 208 } 209 210 batch.oncommit(this.#commit); 211 batch.ondiscard(this.#discard); 212 } else { 213 if (hydrating) { 214 this.anchor = hydrate_node; 215 } 216 217 this.#commit(); 218 } 219 } 220} 221 222/** @import { TemplateNode } from '#client' */ 223 224// TODO reinstate https://github.com/sveltejs/svelte/pull/15250 225 226/** 227 * @param {TemplateNode} node 228 * @param {(branch: (fn: (anchor: Node) => void, flag?: boolean) => void) => void} fn 229 * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local' 230 * @returns {void} 231 */ 232function if_block(node, fn, elseif = false) { 233 if (hydrating) { 234 hydrate_next(); 235 } 236 237 var branches = new BranchManager(node); 238 var flags = elseif ? EFFECT_TRANSPARENT : 0; 239 240 /** 241 * @param {boolean} condition, 242 * @param {null | ((anchor: Node) => void)} fn 243 */ 244 function update_branch(condition, fn) { 245 if (hydrating) { 246 const is_else = read_hydration_instruction(node) === HYDRATION_START_ELSE; 247 248 if (condition === is_else) {
249 // Hydration mismatch: remove everything inside the anchor and start fresh. 250 // This could happen with `{#if browser}...{/if}`, for example 251 var anchor = skip_nodes(); 252 253 set_hydrate_node(anchor); 254 branches.anchor = anchor; 255 256 set_hydrating(false); 257 branches.ensure(condition, fn); 258 set_hydrating(true); 259 260 return; 261 } 262 } 263 264 branches.ensure(condition, fn); 265 } 266 267 block(() => { 268 var has_branch = false; 269 270 fn((fn, flag = true) => { 271 has_branch = true; 272 update_branch(flag, fn); 273 }); 274 275 if (!has_branch) { 276 update_branch(false, null); 277 } 278 }, flags); 279} 280 281/** @import { EachItem, EachOutroGroup, EachState, Effect, EffectNodes, MaybeSource, Source, TemplateNode, TransitionManager, Value } from '#client' */ 282/** @import { Batch } from '../../reactivity/batch.js'; */ 283 284// When making substantive changes to this file, validate them with the each block stress test: 285// https://svelte.dev/playground/1972b2cf46564476ad8c8c6405b23b7b 286// This test also exists in this repo, as `packages/svelte/tests/manual/each-stress-test` 287 288/** 289 * @param {any} _ 290 * @param {number} i 291 */ 292function index(_, i) { 293 return i; 294} 295 296/** 297 * Pause multiple effects simultaneously, and coordinate their 298 * subsequent destruction. Used in each blocks 299 * @param {EachState} state 300 * @param {Effect[]} to_destroy 301 * @param {null | Node} controlled_anchor 302 */ 303function pause_effects(state, to_destroy, controlled_anchor) { 304 /** @type {TransitionManager[]} */ 305 var transitions = []; 306 var length = to_destroy.length; 307 308 /** @type {EachOutroGroup} */ 309 var group; 310 var remaining = to_destroy.length; 311 312 for (var i = 0; i < length; i++) { 313 let effect = to_destroy[i]; 314 315 pause_effect( 316 effect, 317 () => { 318 if (group) { 319 group.pending.delete(effect); 320 group.done.add(effect); 321 322 if (group.pending.size === 0) { 323 var groups = /** @type {Set<EachOutroGroup>} */ (state.outrogroups); 324 325 destroy_effects(array_from(group.done)); 326 groups.delete(group); 327 328 if (groups.size === 0) { 329 state.outrogroups = null; 330 } 331 } 332 } else { 333 remaining -= 1; 334 } 335 }, 336 false 337 ); 338 } 339 340 if (remaining === 0) { 341 // If we're in a controlled each block (i.e. the block is the only child of an 342 // element), and we are removing all items, _and_ there are no out transitions, 343 // we can use the fast path â emptying the element and replacing the anchor 344 var fast_path = transitions.length === 0 && controlled_anchor !== null; 345 346 if (fast_path) { 347 var anchor = /** @type {Element} */ (controlled_anchor); 348 var parent_node = /** @type {Element} */ (anchor.parentNode); 349 350 clear_text_content(parent_node); 351 parent_node.append(anchor); 352 353 state.items.clear(); 354 } 355 356 destroy_effects(to_destroy, !fast_path); 357 } else { 358 group = { 359 pending: new Set(to_destroy), 360 done: new Set() 361 }; 362 363 (state.outrogroups ??= new Set()).add(group); 364 } 365} 366 367/** 368 * @param {Effect[]} to_destroy 369 * @param {boolean} remove_dom 370 */ 371function destroy_effects(to_destroy, remove_dom = true) { 372 // TODO only destroy effects if no pending batch needs them. otherwise, 373 // just re-add the `EFFECT_OFFSCREEN` flag 374 for (var i = 0; i < to_destroy.length; i++) { 375 destroy_effect(to_destroy[i], remove_dom); 376 } 377} 378 379/** @type {TemplateNode} */ 380var offscreen_anchor; 381 382/** 383 * @template V 384 * @param {Element | Comment} node The next sibling node, or the parent node if this is a 'controlled' block 385 * @param {number} flags 386 * @param {() => V[]} get_collection 387 * @param {(value: V, index: number) => any} get_key 388 * @param {(anchor: Node, item: MaybeSource<V>, index: MaybeSource<number>) => void} render_fn 389 * @param {null | ((anchor: Node) => void)} fallback_fn 390 * @returns {void} 391 */ 392function each(node, flags, get_collection, get_key, render_fn, fallback_fn = null) { 393 var anchor = node; 394 395 /** @type {Map<any, EachItem>} */ 396 var items = new Map(); 397 398 var is_controlled = (flags & EACH_IS_CONTROLLED) !== 0; 399 400 if (is_controlled) { 401 var parent_node = /** @type {Element} */ (node); 402 403 anchor = hydrating 404 ? set_hydrate_node(get_first_child(parent_node)) 405 : parent_node.appendChild(create_text()); 406 } 407 408 if (hydrating) { 409 hydrate_next(); 410 } 411 412 /** @type {Effect | null} */ 413 var fallback = null; 414 415 // TODO: ideally we could use derived for runes mode but because of the ability 416 // to use a store which can be mutated, we can't do that here as mutating a store 417 // will still result in the collection array being the same from the store 418 var each_array = derived_safe_equal(() => { 419 var collection = get_collection(); 420 421 return is_array(collection) ? collection : collection == null ? [] : array_from(collection); 422 }); 423 424 /** @type {V[]} */ 425 var array; 426 427 var first_run = true; 428 429 function commit() { 430 state.fallback = fallback; 431 reconcile(state, array, anchor, flags, get_key); 432 433 if (fallback !== null) { 434 if (array.length === 0) { 435 if ((fallback.f & EFFECT_OFFSCREEN) === 0) { 436 resume_effect(fallback); 437 } else { 438 fallback.f ^= EFFECT_OFFSCREEN; 439 move(fallback, null, anchor); 440 } 441 } else { 442 pause_effect(fallback, () => { 443 // TODO only null out if no pending batch needs it, 444 // otherwise re-add `fallback.fragment` and move the
445 // effect into it 446 fallback = null; 447 }); 448 } 449 } 450 } 451 452 var effect = block(() => { 453 array = /** @type {V[]} */ (get$1(each_array)); 454 var length = array.length; 455 456 /** `true` if there was a hydration mismatch. Needs to be a `let` or else it isn't treeshaken out */ 457 let mismatch = false; 458 459 if (hydrating) { 460 var is_else = read_hydration_instruction(anchor) === HYDRATION_START_ELSE; 461 462 if (is_else !== (length === 0)) { 463 // hydration mismatch â remove the server-rendered DOM and start over 464 anchor = skip_nodes(); 465 466 set_hydrate_node(anchor); 467 set_hydrating(false); 468 mismatch = true; 469 } 470 } 471 472 var keys = new Set(); 473 var batch = /** @type {Batch} */ (current_batch); 474 var defer = should_defer_append(); 475 476 for (var index = 0; index < length; index += 1) { 477 if ( 478 hydrating && 479 hydrate_node.nodeType === COMMENT_NODE && 480 /** @type {Comment} */ (hydrate_node).data === HYDRATION_END 481 ) { 482 // The server rendered fewer items than expected, 483 // so break out and continue appending non-hydrated items 484 anchor = /** @type {Comment} */ (hydrate_node); 485 mismatch = true; 486 set_hydrating(false); 487 } 488 489 var value = array[index]; 490 var key = get_key(value, index); 491 492 var item = first_run ? null : items.get(key); 493 494 if (item) { 495 // update before reconciliation, to trigger any async updates 496 if (item.v) internal_set(item.v, value); 497 if (item.i) internal_set(item.i, index); 498 499 if (defer) { 500 batch.skipped_effects.delete(item.e); 501 } 502 } else { 503 item = create_item( 504 items, 505 first_run ? anchor : (offscreen_anchor ??= create_text()), 506 value, 507 key, 508 index, 509 render_fn, 510 flags, 511 get_collection 512 ); 513 514 if (!first_run) { 515 item.e.f |= EFFECT_OFFSCREEN; 516 } 517 518 items.set(key, item); 519 } 520 521 keys.add(key); 522 } 523 524 if (length === 0 && fallback_fn && !fallback) { 525 if (first_run) { 526 fallback = branch(() => fallback_fn(anchor)); 527 } else { 528 fallback = branch(() => fallback_fn((offscreen_anchor ??= create_text()))); 529 fallback.f |= EFFECT_OFFSCREEN; 530 } 531 } 532 533 // remove excess nodes 534 if (hydrating && length > 0) { 535 set_hydrate_node(skip_nodes()); 536 } 537 538 if (!first_run) { 539 if (defer) { 540 for (const [key, item] of items) { 541 if (!keys.has(key)) { 542 batch.skipped_effects.add(item.e); 543 } 544 } 545 546 batch.oncommit(commit); 547 batch.ondiscard(() => { 548 // TODO presumably we need to do something here? 549 }); 550 } else { 551 commit(); 552 } 553 } 554 555 if (mismatch) { 556 // continue in hydration mode 557 set_hydrating(true); 558 } 559 560 // When we mount the each block for the first time, the collection won't be 561 // connected to this effect as the effect hasn't finished running yet and its deps 562 // won't be assigned. However, it's possible that when reconciling the each block 563 // that a mutation occurred and it's made the collection MAYBE_DIRTY, so reading the 564 // collection again can provide consistency to the reactive graph again as the deriveds 565 // will now be `CLEAN`. 566 get$1(each_array); 567 }); 568 569 /** @type {EachState} */ 570 var state = { effect, items, outrogroups: null, fallback }; 571 572 first_run = false; 573 574 if (hydrating) { 575 anchor = hydrate_node; 576 } 577} 578 579/** 580 * Add, remove, or reorder items output by an each block as its input changes 581 * @template V 582 * @param {EachState} state 583 * @param {Array<V>} array 584 * @param {Element | Comment | Text} anchor 585 * @param {number} flags 586 * @param {(value: V, index: number) => any} get_key 587 * @returns {void} 588 */ 589function reconcile(state, array, anchor, flags, get_key) { 590 var is_animated = (flags & EACH_IS_ANIMATED) !== 0; 591 592 var length = array.length; 593 var items = state.items; 594 var current = state.effect.first; 595 596 /** @type {undefined | Set<Effect>} */ 597 var seen; 598 599 /** @type {Effect | null} */ 600 var prev = null; 601 602 /** @type {undefined | Set<Effect>} */ 603 var to_animate; 604 605 /** @type {Effect[]} */ 606 var matched = []; 607 608 /** @type {Effect[]} */ 609 var stashed = []; 610 611 /** @type {V} */ 612 var value; 613 614 /** @type {any} */ 615 var key; 616 617 /** @type {Effect | undefined} */ 618 var effect; 619 620 /** @type {number} */ 621 var i; 622 623 if (is_animated) { 624 for (i = 0; i < length; i += 1) { 625 value = array[i]; 626 key = get_key(value, i); 627 effect = /** @type {EachItem} */ (items.get(key)).e; 628 629 // offscreen == coming in now, no animation in that case, 630 // else this would happen https://github.com/sveltejs/svelte/issues/17181 631 if ((effect.f & EFFECT_OFFSCREEN) === 0) { 632 effect.nodes?.a?.measure(); 633 (to_animate ??= new Set()).add(effect); 634 } 635 } 636 } 637 638 for (i = 0; i < length; i += 1) { 639 value = array[i]; 640 key = get_key(value, i); 641 642 effect = /** @type {EachItem} */ (items.get(key)).e; 643 644 if (state.outrogroups !== null) { 645 for (const group of state.outrogroups) { 646 group.pending.delete(effect); 647 group.done.delete(effect); 648 } 649 } 650 651 if ((effect.f & EFFECT_OFFSCREEN) !== 0) { 652 effect.f ^= EFFECT_OFFSCREEN; 653 654 if (effect === current) { 655 move(effect, null, anchor); 656 } else { 657 var next = prev ? prev.next : current; 658 659 if (effect === state.effect.last) { 660 state.effect.last = effect.prev; 661 } 662 663 if (effect.prev) effect.prev.next = effect.next; 664 if (effect.next) effect.next.prev = effect.prev; 665 link(state, prev, effect); 666 link(state, effect, next); 667 668 move(effect, next, anchor); 669 prev = effect; 670 671 matched = []; 672 stashed = []; 673 674 current = prev.next; 675 continue; 676 } 677 } 678 679 if ((effect.f & INERT) !== 0) { 680 resume_effect(effect); 681 if (is_animated) { 682 effect.nodes?.a?.unfix(); 683 (to_animate ??= new Set()).delete(effect); 684 } 685 } 686 687 if (effect !== current) { 688 if (seen !== undefined && seen.has(effect)) { 689 if (matched.length < stashed.length) { 690 // more efficient to move later items to the front 691 var start = stashed[0]; 692 var j; 693 694 prev = start.prev; 695 696 var a = matched[0]; 697 var b = matched[matched.length - 1]; 698 699 for (j = 0; j < matched.length; j += 1) { 700 move(matched[j], start, anchor); 701 } 702 703 for (j = 0; j < stashed.length; j += 1) { 704 seen.delete(stashed[j]); 705 } 706 707 link(state, a.prev, b.next); 708 link(state, prev, a); 709 link(state, b, start); 710 711 current = start; 712 prev = b; 713 i -= 1; 714 715 matched = []; 716 stashed = []; 717 } else { 718 // more efficient to move earlier items to the back 719 seen.delete(effect);
720 move(effect, current, anchor); 721 722 link(state, effect.prev, effect.next); 723 link(state, effect, prev === null ? state.effect.first : prev.next); 724 link(state, prev, effect); 725 726 prev = effect; 727 } 728 729 continue; 730 } 731 732 matched = []; 733 stashed = []; 734 735 while (current !== null && current !== effect) { 736 (seen ??= new Set()).add(current); 737 stashed.push(current); 738 current = current.next; 739 } 740 741 if (current === null) { 742 continue; 743 } 744 } 745 746 if ((effect.f & EFFECT_OFFSCREEN) === 0) { 747 matched.push(effect); 748 } 749 750 prev = effect; 751 current = effect.next; 752 } 753 754 if (state.outrogroups !== null) { 755 for (const group of state.outrogroups) { 756 if (group.pending.size === 0) { 757 destroy_effects(array_from(group.done)); 758 state.outrogroups?.delete(group); 759 } 760 } 761 762 if (state.outrogroups.size === 0) { 763 state.outrogroups = null; 764 } 765 } 766 767 if (current !== null || seen !== undefined) { 768 /** @type {Effect[]} */ 769 var to_destroy = []; 770 771 if (seen !== undefined) { 772 for (effect of seen) { 773 if ((effect.f & INERT) === 0) { 774 to_destroy.push(effect); 775 } 776 } 777 } 778 779 while (current !== null) { 780 // If the each block isn't inert, then inert effects are currently outroing and will be removed once the transition is finished 781 if ((current.f & INERT) === 0 && current !== state.fallback) { 782 to_destroy.push(current); 783 } 784 785 current = current.next; 786 } 787 788 var destroy_length = to_destroy.length; 789 790 if (destroy_length > 0) { 791 var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null; 792 793 if (is_animated) { 794 for (i = 0; i < destroy_length; i += 1) { 795 to_destroy[i].nodes?.a?.measure(); 796 } 797 798 for (i = 0; i < destroy_length; i += 1) { 799 to_destroy[i].nodes?.a?.fix(); 800 } 801 } 802 803 pause_effects(state, to_destroy, controlled_anchor); 804 } 805 } 806 807 if (is_animated) { 808 queue_micro_task(() => { 809 if (to_animate === undefined) return; 810 for (effect of to_animate) { 811 effect.nodes?.a?.apply(); 812 } 813 }); 814 } 815} 816 817/** 818 * @template V 819 * @param {Map<any, EachItem>} items 820 * @param {Node} anchor 821 * @param {V} value 822 * @param {unknown} key 823 * @param {number} index 824 * @param {(anchor: Node, item: V | Source<V>, index: number | Value<number>, collection: () => V[]) => void} render_fn 825 * @param {number} flags 826 * @param {() => V[]} get_collection 827 * @returns {EachItem} 828 */ 829function create_item(items, anchor, value, key, index, render_fn, flags, get_collection) { 830 var v = 831 (flags & EACH_ITEM_REACTIVE) !== 0 832 ? (flags & EACH_ITEM_IMMUTABLE) === 0 833 ? mutable_source(value, false, false) 834 : source(value) 835 : null; 836 837 var i = (flags & EACH_INDEX_REACTIVE) !== 0 ? source(index) : null; 838 839 if (DEV && v) { 840 // For tracing purposes, we need to link the source signal we create with the 841 // collection + index so that tracing works as intended 842 v.trace = () => { 843 // eslint-disable-next-line @typescript-eslint/no-unused-expressions 844 get_collection()[i?.v ?? index]; 845 }; 846 } 847 848 return { 849 v, 850 i, 851 e: branch(() => { 852 render_fn(anchor, v ?? value, i ?? index, get_collection); 853 854 return () => { 855 items.delete(key); 856 }; 857 }) 858 }; 859} 860 861/** 862 * @param {Effect} effect 863 * @param {Effect | null} next 864 * @param {Text | Element | Comment} anchor 865 */ 866function move(effect, next, anchor) { 867 if (!effect.nodes) return; 868 869 var node = effect.nodes.start; 870 var end = effect.nodes.end; 871 872 var dest = 873 next && (next.f & EFFECT_OFFSCREEN) === 0 874 ? /** @type {EffectNodes} */ (next.nodes).start 875 : anchor; 876 877 while (node !== null) { 878 var next_node = /** @type {TemplateNode} */ (get_next_sibling(node)); 879 dest.before(node); 880 881 if (node === end) { 882 return; 883 } 884 885 node = next_node; 886 } 887} 888 889/** 890 * @param {EachState} state 891 * @param {Effect | null} prev 892 * @param {Effect | null} next 893 */ 894function link(state, prev, next) { 895 if (prev === null) { 896 state.effect.first = next; 897 } else { 898 prev.next = next; 899 } 900 901 if (next === null) { 902 state.effect.last = prev; 903 } else { 904 next.prev = prev; 905 } 906} 907 908/** 909 * @param {Comment} anchor 910 * @param {Record<string, any>} $$props 911 * @param {string} name 912 * @param {Record<string, unknown>} slot_props 913 * @param {null | ((anchor: Comment) => void)} fallback_fn 914 */ 915function slot(anchor, $$props, name, slot_props, fallback_fn) { 916 if (hydrating) { 917 hydrate_next(); 918 } 919 920 var slot_fn = $$props.$$slots?.[name]; 921 // Interop: Can use snippets to fill slots
vendor: 4,425 bytes, lines 922-1107
922 var is_interop = false; 923 if (slot_fn === true) { 924 slot_fn = $$props[name === 'default' ? 'children' : name]; 925 is_interop = true; 926 } 927 928 if (slot_fn === undefined) { 929 if (fallback_fn !== null) { 930 fallback_fn(anchor); 931 } 932 } else { 933 slot_fn(anchor, is_interop ? () => slot_props : slot_props); 934 } 935} 936 937/** @import { Effect } from '#client' */ 938 939// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by 940// getting rid of the block/branch stuff and just letting the effect rip. 941// see https://github.com/sveltejs/svelte/pull/15962 942 943/** 944 * @param {Element} node 945 * @param {() => (node: Element) => void} get_fn 946 */ 947function attach(node, get_fn) { 948 /** @type {false | undefined | ((node: Element) => void)} */ 949 var fn = undefined; 950 951 /** @type {Effect | null} */ 952 var e; 953 954 managed(() => { 955 if (fn !== (fn = get_fn())) { 956 if (e) { 957 destroy_effect(e); 958 e = null; 959 } 960 961 if (fn) { 962 e = branch(() => { 963 effect(() => /** @type {(node: Element) => void} */ (fn)(node)); 964 }); 965 } 966 } 967 }); 968} 969 970function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx$1(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n} 971 972/** 973 * Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values. 974 * TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does) 975 * @param {any} value 976 */ 977function clsx(value) { 978 if (typeof value === 'object') { 979 return clsx$1(value); 980 } else { 981 return value ?? ''; 982 } 983} 984 985const whitespace = [...' \t\n\r\f\u00a0\u000b\ufeff']; 986 987/** 988 * @param {any} value 989 * @param {string | null} [hash] 990 * @param {Record<string, boolean>} [directives] 991 * @returns {string | null} 992 */ 993function to_class(value, hash, directives) { 994 var classname = value == null ? '' : '' + value; 995 996 if (hash) { 997 classname = classname ? classname + ' ' + hash : hash; 998 } 999 1000 if (directives) { 1001 for (var key in directives) { 1002 if (directives[key]) { 1003 classname = classname ? classname + ' ' + key : key; 1004 } else if (classname.length) { 1005 var len = key.length; 1006 var a = 0; 1007 1008 while ((a = classname.indexOf(key, a)) >= 0) { 1009 var b = a + len; 1010 1011 if ( 1012 (a === 0 || whitespace.includes(classname[a - 1])) && 1013 (b === classname.length || whitespace.includes(classname[b])) 1014 ) { 1015 classname = (a === 0 ? '' : classname.substring(0, a)) + classname.substring(b + 1); 1016 } else { 1017 a = b; 1018 } 1019 } 1020 } 1021 } 1022 } 1023 1024 return classname === '' ? null : classname; 1025} 1026 1027/** 1028 * 1029 * @param {Record<string,any>} styles 1030 * @param {boolean} important 1031 */ 1032function append_styles(styles, important = false) { 1033 var separator = important ? ' !important;' : ';'; 1034 var css = ''; 1035 1036 for (var key in styles) { 1037 var value = styles[key]; 1038 if (value != null && value !== '') { 1039 css += ' ' + key + ': ' + value + separator; 1040 } 1041 } 1042 1043 return css; 1044} 1045 1046/** 1047 * @param {string} name 1048 * @returns {string} 1049 */ 1050function to_css_name(name) { 1051 if (name[0] !== '-' || name[1] !== '-') { 1052 return name.toLowerCase(); 1053 } 1054 return name; 1055} 1056 1057/** 1058 * @param {any} value 1059 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles] 1060 * @returns {string | null} 1061 */ 1062function to_style(value, styles) { 1063 if (styles) { 1064 var new_style = ''; 1065 1066 /** @type {Record<string,any> | undefined} */ 1067 var normal_styles; 1068 1069 /** @type {Record<string,any> | undefined} */ 1070 var important_styles; 1071 1072 if (Array.isArray(styles)) { 1073 normal_styles = styles[0]; 1074 important_styles = styles[1]; 1075 } else { 1076 normal_styles = styles; 1077 } 1078 1079 if (value) { 1080 value = String(value) 1081 .replaceAll(/\s*\/\*.*?\*\/\s*/g, '') 1082 .trim(); 1083 1084 /** @type {boolean | '"' | "'"} */ 1085 var in_str = false; 1086 var in_apo = 0; 1087 var in_comment = false; 1088 1089 var reserved_names = []; 1090 1091 if (normal_styles) { 1092 reserved_names.push(...Object.keys(normal_styles).map(to_css_name)); 1093 } 1094 if (important_styles) { 1095 reserved_names.push(...Object.keys(important_styles).map(to_css_name)); 1096 } 1097 1098 var start_index = 0; 1099 var name_index = -1; 1100 1101 const len = value.length; 1102 for (var i = 0; i < len; i++) { 1103 var c = value[i]; 1104 1105 if (in_comment) { 1106 if (c === '/' && value[i - 1] === '*') { 1107 in_comment = false;
1108 } 1109 } else if (in_str) { 1110 if (in_str === c) { 1111 in_str = false; 1112 } 1113 } else if (c === '/' && value[i + 1] === '*') { 1114 in_comment = true; 1115 } else if (c === '"' || c === "'") { 1116 in_str = c; 1117 } else if (c === '(') { 1118 in_apo++; 1119 } else if (c === ')') { 1120 in_apo--; 1121 } 1122 1123 if (!in_comment && in_str === false && in_apo === 0) { 1124 if (c === ':' && name_index === -1) { 1125 name_index = i; 1126 } else if (c === ';' || i === len - 1) { 1127 if (name_index !== -1) { 1128 var name = to_css_name(value.substring(start_index, name_index).trim()); 1129 1130 if (!reserved_names.includes(name)) { 1131 if (c !== ';') { 1132 i++; 1133 } 1134 1135 var property = value.substring(start_index, i).trim(); 1136 new_style += ' ' + property + ';'; 1137 } 1138 } 1139 1140 start_index = i + 1; 1141 name_index = -1; 1142 } 1143 } 1144 } 1145 } 1146 1147 if (normal_styles) { 1148 new_style += append_styles(normal_styles); 1149 } 1150 1151 if (important_styles) { 1152 new_style += append_styles(important_styles, true); 1153 } 1154 1155 new_style = new_style.trim(); 1156 return new_style === '' ? null : new_style; 1157 } 1158 1159 return value == null ? null : String(value); 1160} 1161 1162/** 1163 * @param {Element} dom 1164 * @param {boolean | number} is_html 1165 * @param {string | null} value 1166 * @param {string} [hash] 1167 * @param {Record<string, any>} [prev_classes] 1168 * @param {Record<string, any>} [next_classes] 1169 * @returns {Record<string, boolean> | undefined} 1170 */ 1171function set_class(dom, is_html, value, hash, prev_classes, next_classes) { 1172 // @ts-expect-error need to add __className to patched prototype 1173 var prev = dom.__className; 1174 1175 if ( 1176 hydrating || 1177 prev !== value || 1178 prev === undefined // for edge case of `class={undefined}` 1179 ) { 1180 var next_class_name = to_class(value, hash, next_classes); 1181 1182 if (!hydrating || next_class_name !== dom.getAttribute('class')) { 1183 // Removing the attribute when the value is only an empty string causes 1184 // performance issues vs simply making the className an empty string. So 1185 // we should only remove the class if the value is nullish 1186 // and there no hash/directives : 1187 if (next_class_name == null) { 1188 dom.removeAttribute('class'); 1189 } else if (is_html) { 1190 dom.className = next_class_name; 1191 } else { 1192 dom.setAttribute('class', next_class_name); 1193 } 1194 } 1195 1196 // @ts-expect-error need to add __className to patched prototype 1197 dom.__className = value; 1198 } else if (next_classes && prev_classes !== next_classes) { 1199 for (var key in next_classes) { 1200 var is_present = !!next_classes[key]; 1201 1202 if (prev_classes == null || is_present !== !!prev_classes[key]) { 1203 dom.classList.toggle(key, is_present); 1204 } 1205 } 1206 } 1207 1208 return next_classes; 1209} 1210 1211/** 1212 * @param {Element & ElementCSSInlineStyle} dom 1213 * @param {Record<string, any>} prev 1214 * @param {Record<string, any>} next 1215 * @param {string} [priority] 1216 */ 1217function update_styles(dom, prev = {}, next, priority) { 1218 for (var key in next) { 1219 var value = next[key]; 1220 1221 if (prev[key] !== value) { 1222 if (next[key] == null) { 1223 dom.style.removeProperty(key); 1224 } else { 1225 dom.style.setProperty(key, value, priority); 1226 } 1227 } 1228 } 1229} 1230 1231/** 1232 * @param {Element & ElementCSSInlineStyle} dom 1233 * @param {string | null} value 1234 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [prev_styles] 1235 * @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [next_styles] 1236 */ 1237function set_style(dom, value, prev_styles, next_styles) { 1238 // @ts-expect-error 1239 var prev = dom.__style; 1240 1241 if (hydrating || prev !== value) { 1242 var next_style_attr = to_style(value, next_styles); 1243 1244 if (!hydrating || next_style_attr !== dom.getAttribute('style')) { 1245 if (next_style_attr == null) { 1246 dom.removeAttribute('style'); 1247 } else { 1248 dom.style.cssText = next_style_attr; 1249 } 1250 } 1251 1252 // @ts-expect-error 1253 dom.__style = value; 1254 } else if (next_styles) { 1255 if (Array.isArray(next_styles)) { 1256 update_styles(dom, prev_styles?.[0], next_styles[0]); 1257 update_styles(dom, prev_styles?.[1], next_styles[1], 'important'); 1258 } else { 1259 update_styles(dom, prev_styles, next_styles); 1260 } 1261 } 1262 1263 return next_styles; 1264} 1265 1266/** 1267 * Selects the correct option(s) (depending on whether this is a multiple select) 1268 * @template V 1269 * @param {HTMLSelectElement} select 1270 * @param {V} value 1271 * @param {boolean} mounting 1272 */ 1273function select_option(select, value, mounting = false) { 1274 if (select.multiple) { 1275 // If value is null or undefined, keep the selection as is 1276 if (value == undefined) { 1277 return; 1278 } 1279 1280 // If not an array, warn and keep the selection as is 1281 if (!is_array(value)) { 1282 return select_multiple_invalid_value(); 1283 } 1284 1285 // Otherwise, update the selection 1286 for (var option of select.options) { 1287 option.selected = value.includes(get_option_value(option)); 1288 } 1289 1290 return; 1291 } 1292 1293 for (option of select.options) { 1294 var option_value = get_option_value(option); 1295 if (is(option_value, value)) { 1296 option.selected = true; 1297 return; 1298 } 1299 } 1300 1301 if (!mounting || value !== undefined) { 1302 select.selectedIndex = -1; // no option should be selected 1303 } 1304} 1305 1306/** 1307 * Selects the correct option(s) if `value` is given, 1308 * and then sets up a mutation observer to sync the 1309 * current selection to the dom when it changes. Such 1310 * changes could for example occur when options are 1311 * inside an `#each` block. 1312 * @param {HTMLSelectElement} select 1313 */ 1314function init_select(select) { 1315 var observer = new MutationObserver(() => { 1316 // @ts-ignore 1317 select_option(select, select.__value); 1318 // Deliberately don't update the potential binding value, 1319 // the model should be preserved unless explicitly changed 1320 }); 1321 1322 observer.observe(select, { 1323 // Listen to option element changes 1324 childList: true, 1325 subtree: true, // because of <optgroup> 1326 // Listen to option element value attribute changes 1327 // (doesn't get notified of select value changes, 1328 // because that property is not reflected as an attribute) 1329 attributes: true, 1330 attributeFilter: ['value'] 1331 }); 1332 1333 teardown(() => { 1334 observer.disconnect(); 1335 }); 1336} 1337 1338/** 1339 * @param {HTMLSelectElement} select 1340 * @param {() => unknown} get 1341 * @param {(value: unknown) => void} set 1342 * @returns {void} 1343 */ 1344function bind_select_value(select, get, set = get) { 1345 var batches = new WeakSet(); 1346 var mounting = true; 1347 1348 listen_to_event_and_reset_event(select, 'change', (is_reset) => { 1349 var query = is_reset ? '[selected]' : ':checked'; 1350 /** @type {unknown} */ 1351 var value; 1352 1353 if (select.multiple) { 1354 value = [].map.call(select.querySelectorAll(query), get_option_value); 1355 } else { 1356 /** @type {HTMLOptionElement | null} */ 1357 var selected_option = 1358 select.querySelector(query) ?? 1359 // will fall back to first non-disabled option if no option is selected 1360 select.querySelector('option:not([disabled])'); 1361 value = selected_option && get_option_value(selected_option); 1362 } 1363 1364 set(value); 1365 1366 if (current_batch !== null) { 1367 batches.add(current_batch); 1368 } 1369 }); 1370 1371 // Needs to be an effect, not a render_effect, so that in case of each loops the logic runs after the each block has updated 1372 effect(() => { 1373 var value = get(); 1374 1375 if (select === document.activeElement) { 1376 // we need both, because in non-async mode, render effects run before previous_batch is set 1377 var batch = /** @type {Batch} */ (previous_batch ?? current_batch); 1378 1379 // Don't update the <select> if it is focused. We can get here if, for example,
1380 // an update is deferred because of async work depending on the select: 1381 // 1382 // <select bind:value={selected}>...</select> 1383 // <p>{await find(selected)}</p> 1384 if (batches.has(batch)) { 1385 return; 1386 } 1387 } 1388 1389 select_option(select, value, mounting); 1390 1391 // Mounting and value undefined -> take selection from dom 1392 if (mounting && value === undefined) { 1393 /** @type {HTMLOptionElement | null} */ 1394 var selected_option = select.querySelector(':checked'); 1395 if (selected_option !== null) { 1396 value = get_option_value(selected_option); 1397 set(value); 1398 } 1399 } 1400 1401 // @ts-ignore 1402 select.__value = value; 1403 mounting = false; 1404 }); 1405 1406 init_select(select); 1407} 1408 1409/** @param {HTMLOptionElement} option */ 1410function get_option_value(option) { 1411 // __value only exists if the <option> has a value attribute 1412 if ('__value' in option) { 1413 return option.__value; 1414 } else { 1415 return option.value; 1416 } 1417} 1418 1419/** @import { Effect } from '#client' */ 1420 1421const CLASS = Symbol('class'); 1422const STYLE = Symbol('style'); 1423 1424const IS_CUSTOM_ELEMENT = Symbol('is custom element'); 1425const IS_HTML = Symbol('is html'); 1426 1427/** 1428 * The value/checked attribute in the template actually corresponds to the defaultValue property, so we need 1429 * to remove it upon hydration to avoid a bug when someone resets the form value. 1430 * @param {HTMLInputElement} input 1431 * @returns {void} 1432 */ 1433function remove_input_defaults(input) { 1434 if (!hydrating) return; 1435 1436 var already_removed = false; 1437 1438 // We try and remove the default attributes later, rather than sync during hydration. 1439 // Doing it sync during hydration has a negative impact on performance, but deferring the
1440 // work in an idle task alleviates this greatly. If a form reset event comes in before 1441 // the idle callback, then we ensure the input defaults are cleared just before. 1442 var remove_defaults = () => { 1443 if (already_removed) return; 1444 already_removed = true; 1445 1446 // Remove the attributes but preserve the values 1447 if (input.hasAttribute('value')) { 1448 var value = input.value; 1449 set_attribute(input, 'value', null); 1450 input.value = value; 1451 } 1452 1453 if (input.hasAttribute('checked')) { 1454 var checked = input.checked; 1455 set_attribute(input, 'checked', null); 1456 input.checked = checked; 1457 } 1458 }; 1459 1460 // @ts-expect-error 1461 input.__on_r = remove_defaults; 1462 queue_micro_task(remove_defaults); 1463 add_form_reset_listener(); 1464} 1465 1466/** 1467 * @param {Element} element 1468 * @param {any} value 1469 */ 1470function set_value(element, value) { 1471 var attributes = get_attributes(element); 1472 1473 if ( 1474 attributes.value === 1475 (attributes.value = 1476 // treat null and undefined the same for the initial value 1477 value ?? undefined) || 1478 // @ts-expect-error 1479 // `progress` elements always need their value set when it's `0` 1480 (element.value === value && (value !== 0 || element.nodeName !== 'PROGRESS')) 1481 ) { 1482 return; 1483 } 1484 1485 // @ts-expect-error 1486 element.value = value ?? ''; 1487} 1488 1489/** 1490 * @param {Element} element 1491 * @param {boolean} checked 1492 */ 1493function set_checked(element, checked) { 1494 var attributes = get_attributes(element); 1495 1496 if ( 1497 attributes.checked === 1498 (attributes.checked = 1499 // treat null and undefined the same for the initial value 1500 checked ?? undefined) 1501 ) { 1502 return; 1503 } 1504 1505 // @ts-expect-error 1506 element.checked = checked; 1507} 1508 1509/** 1510 * Sets the `selected` attribute on an `option` element. 1511 * Not set through the property because that doesn't reflect to the DOM, 1512 * which means it wouldn't be taken into account when a form is reset. 1513 * @param {HTMLOptionElement} element 1514 * @param {boolean} selected 1515 */ 1516function set_selected(element, selected) { 1517 if (selected) { 1518 // The selected option could've changed via user selection, and 1519 // setting the value without this check would set it back. 1520 if (!element.hasAttribute('selected')) { 1521 element.setAttribute('selected', ''); 1522 } 1523 } else { 1524 element.removeAttribute('selected'); 1525 } 1526} 1527 1528/** 1529 * @param {Element} element 1530 * @param {string} attribute 1531 * @param {string | null} value 1532 * @param {boolean} [skip_warning] 1533 */ 1534function set_attribute(element, attribute, value, skip_warning) { 1535 var attributes = get_attributes(element); 1536 1537 if (hydrating) { 1538 attributes[attribute] = element.getAttribute(attribute); 1539 1540 if ( 1541 attribute === 'src' || 1542 attribute === 'srcset' || 1543 (attribute === 'href' && element.nodeName === 'LINK') 1544 ) { 1545 if (!skip_warning) { 1546 check_src_in_dev_hydration(element, attribute, value ?? ''); 1547 } 1548 1549 // If we reset these attributes, they would result in another network request, which we want to avoid. 1550 // We assume they are the same between client and server as checking if they are equal is expensive 1551 // (we can't just compare the strings as they can be different between client and server but result in the 1552 // same url, so we would need to create hidden anchor elements to compare them) 1553 return; 1554 } 1555 } 1556 1557 if (attributes[attribute] === (attributes[attribute] = value)) return; 1558 1559 if (attribute === 'loading') { 1560 // @ts-expect-error 1561 element[LOADING_ATTR_SYMBOL] = value; 1562 } 1563 1564 if (value == null) { 1565 element.removeAttribute(attribute); 1566 } else if (typeof value !== 'string' && get_setters(element).includes(attribute)) { 1567 // @ts-ignore 1568 element[attribute] = value; 1569 } else { 1570 element.setAttribute(attribute, value); 1571 } 1572} 1573 1574/** 1575 * Spreads attributes onto a DOM element, taking into account the currently set attributes 1576 * @param {Element & ElementCSSInlineStyle} element 1577 * @param {Record<string | symbol, any> | undefined} prev 1578 * @param {Record<string | symbol, any>} next New attributes - this function mutates this object 1579 * @param {string} [css_hash] 1580 * @param {boolean} [should_remove_defaults] 1581 * @param {boolean} [skip_warning] 1582 * @returns {Record<string, any>} 1583 */ 1584function set_attributes( 1585 element, 1586 prev, 1587 next, 1588 css_hash, 1589 should_remove_defaults = false, 1590 skip_warning = false 1591) { 1592 if (hydrating && should_remove_defaults && element.tagName === 'INPUT') { 1593 var input = /** @type {HTMLInputElement} */ (element); 1594 var attribute = input.type === 'checkbox' ? 'defaultChecked' : 'defaultValue'; 1595 1596 if (!(attribute in next)) { 1597 remove_input_defaults(input); 1598 } 1599 } 1600 1601 var attributes = get_attributes(element); 1602 1603 var is_custom_element = attributes[IS_CUSTOM_ELEMENT]; 1604 var preserve_attribute_case = !attributes[IS_HTML]; 1605 1606 // If we're hydrating but the custom element is from Svelte, and it already scaffolded, 1607 // then it might run block logic in hydration mode, which we have to prevent. 1608 let is_hydrating_custom_element = hydrating && is_custom_element; 1609 if (is_hydrating_custom_element) { 1610 set_hydrating(false); 1611 } 1612 1613 var current = prev || {}; 1614 var is_option_element = element.tagName === 'OPTION'; 1615 1616 for (var key in prev) { 1617 if (!(key in next)) { 1618 next[key] = null; 1619 } 1620 } 1621 1622 if (next.class) { 1623 next.class = clsx(next.class); 1624 } else if (css_hash || next[CLASS]) { 1625 next.class = null; /* force call to set_class() */ 1626 } 1627 1628 if (next[STYLE]) { 1629 next.style ??= null; /* force call to set_style() */ 1630 } 1631 1632 var setters = get_setters(element); 1633 1634 // since key is captured we use const 1635 for (const key in next) { 1636 // let instead of var because referenced in a closure 1637 let value = next[key]; 1638 1639 // Up here because we want to do this for the initial value, too, even if it's undefined, 1640 // and this wouldn't be reached in case of undefined because of the equality check below
1641 if (is_option_element && key === 'value' && value == null) { 1642 // The <option> element is a special case because removing the value attribute means 1643 // the value is set to the text content of the option element, and setting the value 1644 // to null or undefined means the value is set to the string "null" or "undefined". 1645 // To align with how we handle this case in non-spread-scenarios, this logic is needed. 1646 // There's a super-edge-case bug here that is left in in favor of smaller code size: 1647 // Because of the "set missing props to null" logic above, we can't differentiate 1648 // between a missing value and an explicitly set value of null or undefined. That means 1649 // that once set, the value attribute of an <option> element can't be removed. This is 1650 // a very rare edge case, and removing the attribute altogether isn't possible either 1651 // for the <option value={undefined}> case, so we're not losing any functionality here. 1652 // @ts-ignore 1653 element.value = element.__value = ''; 1654 current[key] = value; 1655 continue; 1656 } 1657 1658 if (key === 'class') { 1659 var is_html = element.namespaceURI === 'http://www.w3.org/1999/xhtml'; 1660 set_class(element, is_html, value, css_hash, prev?.[CLASS], next[CLASS]); 1661 current[key] = value; 1662 current[CLASS] = next[CLASS]; 1663 continue; 1664 } 1665 1666 if (key === 'style') { 1667 set_style(element, value, prev?.[STYLE], next[STYLE]); 1668 current[key] = value; 1669 current[STYLE] = next[STYLE]; 1670 continue; 1671 } 1672 1673 var prev_value = current[key]; 1674 1675 // Skip if value is unchanged, unless it's `undefined` and the element still has the attribute 1676 if (value === prev_value && !(value === undefined && element.hasAttribute(key))) { 1677 continue; 1678 } 1679 1680 current[key] = value; 1681 1682 var prefix = key[0] + key[1]; // this is faster than key.slice(0, 2) 1683 if (prefix === '$$') continue; 1684 1685 if (prefix === 'on') { 1686 /** @type {{ capture?: true }} */ 1687 const opts = {}; 1688 const event_handle_key = '$$' + key; 1689 let event_name = key.slice(2); 1690 var delegated = can_delegate_event(event_name); 1691 1692 if (is_capture_event(event_name)) { 1693 event_name = event_name.slice(0, -7); 1694 opts.capture = true; 1695 } 1696 1697 if (!delegated && prev_value) { 1698 // Listening to same event but different handler -> our handle function below takes care of this 1699 // If we were to remove and add listeners in this case, it could happen that the event is "swallowed" 1700 // (the browser seems to not know yet that a new one exists now) and doesn't reach the handler 1701 // https://github.com/sveltejs/svelte/issues/11903 1702 if (value != null) continue; 1703 1704 element.removeEventListener(event_name, current[event_handle_key], opts); 1705 current[event_handle_key] = null; 1706 } 1707 1708 if (value != null) { 1709 if (!delegated) { 1710 /** 1711 * @this {any} 1712 * @param {Event} evt 1713 */ 1714 function handle(evt) { 1715 current[key].call(this, evt); 1716 } 1717 1718 current[event_handle_key] = create_event(event_name, element, handle, opts); 1719 } else { 1720 // @ts-ignore 1721 element[`__${event_name}`] = value; 1722 delegate([event_name]); 1723 } 1724 } else if (delegated) { 1725 // @ts-ignore 1726 element[`__${event_name}`] = undefined; 1727 } 1728 } else if (key === 'style') { 1729 // avoid using the setter 1730 set_attribute(element, key, value); 1731 } else if (key === 'autofocus') { 1732 autofocus(/** @type {HTMLElement} */ (element), Boolean(value)); 1733 } else if (!is_custom_element && (key === '__value' || (key === 'value' && value != null))) { 1734 // @ts-ignore We're not running this for custom elements because __value is actually 1735 // how Lit stores the current value on the element, and messing with that would break things. 1736 element.value = element.__value = value; 1737 } else if (key === 'selected' && is_option_element) { 1738 set_selected(/** @type {HTMLOptionElement} */ (element), value); 1739 } else { 1740 var name = key; 1741 if (!preserve_attribute_case) { 1742 name = normalize_attribute(name); 1743 } 1744 1745 var is_default = name === 'defaultValue' || name === 'defaultChecked'; 1746 1747 if (value == null && !is_custom_element && !is_default) { 1748 attributes[key] = null; 1749 1750 if (name === 'value' || name === 'checked') { 1751 // removing value/checked also removes defaultValue/defaultChecked â preserve 1752 let input = /** @type {HTMLInputElement} */ (element); 1753 const use_default = prev === undefined; 1754 if (name === 'value') { 1755 let previous = input.defaultValue; 1756 input.removeAttribute(name); 1757 input.defaultValue = previous; 1758 // @ts-ignore 1759 input.value = input.__value = use_default ? previous : null; 1760 } else { 1761 let previous = input.defaultChecked; 1762 input.removeAttribute(name); 1763 input.defaultChecked = previous; 1764 input.checked = use_default ? previous : false;
1765 } 1766 } else { 1767 element.removeAttribute(key); 1768 } 1769 } else if ( 1770 is_default || 1771 (setters.includes(name) && (is_custom_element || typeof value !== 'string')) 1772 ) { 1773 // @ts-ignore 1774 element[name] = value; 1775 // remove it from attributes's cache 1776 if (name in attributes) attributes[name] = UNINITIALIZED; 1777 } else if (typeof value !== 'function') { 1778 set_attribute(element, name, value, skip_warning); 1779 } 1780 } 1781 } 1782 1783 if (is_hydrating_custom_element) { 1784 set_hydrating(true); 1785 } 1786 1787 return current; 1788} 1789 1790/** 1791 * @param {Element & ElementCSSInlineStyle} element 1792 * @param {(...expressions: any) => Record<string | symbol, any>} fn 1793 * @param {Array<() => any>} sync 1794 * @param {Array<() => Promise<any>>} async 1795 * @param {Array<Promise<void>>} blockers 1796 * @param {string} [css_hash] 1797 * @param {boolean} [should_remove_defaults] 1798 * @param {boolean} [skip_warning] 1799 */ 1800function attribute_effect( 1801 element, 1802 fn, 1803 sync = [], 1804 async = [], 1805 blockers = [], 1806 css_hash, 1807 should_remove_defaults = false, 1808 skip_warning = false 1809) { 1810 flatten(blockers, sync, async, (values) => { 1811 /** @type {Record<string | symbol, any> | undefined} */ 1812 var prev = undefined; 1813 1814 /** @type {Record<symbol, Effect>} */ 1815 var effects = {}; 1816 1817 var is_select = element.nodeName === 'SELECT'; 1818 var inited = false; 1819 1820 managed(() => { 1821 var next = fn(...values.map(get$1)); 1822 /** @type {Record<string | symbol, any>} */ 1823 var current = set_attributes( 1824 element, 1825 prev, 1826 next, 1827 css_hash, 1828 should_remove_defaults, 1829 skip_warning 1830 ); 1831 1832 if (inited && is_select && 'value' in next) { 1833 select_option(/** @type {HTMLSelectElement} */ (element), next.value); 1834 } 1835 1836 for (let symbol of Object.getOwnPropertySymbols(effects)) { 1837 if (!next[symbol]) destroy_effect(effects[symbol]); 1838 } 1839 1840 for (let symbol of Object.getOwnPropertySymbols(next)) { 1841 var n = next[symbol]; 1842 1843 if (symbol.description === ATTACHMENT_KEY && (!prev || n !== prev[symbol])) { 1844 if (effects[symbol]) destroy_effect(effects[symbol]); 1845 effects[symbol] = branch(() => attach(element, () => n)); 1846 } 1847 1848 current[symbol] = n; 1849 } 1850 1851 prev = current; 1852 }); 1853 1854 if (is_select) { 1855 var select = /** @type {HTMLSelectElement} */ (element); 1856 1857 effect(() => { 1858 select_option(select, /** @type {Record<string | symbol, any>} */ (prev).value, true); 1859 init_select(select); 1860 }); 1861 } 1862 1863 inited = true; 1864 }); 1865} 1866 1867/** 1868 * 1869 * @param {Element} element 1870 */ 1871function get_attributes(element) { 1872 return /** @type {Record<string | symbol, unknown>} **/ ( 1873 // @ts-expect-error 1874 element.__attributes ??= { 1875 [IS_CUSTOM_ELEMENT]: element.nodeName.includes('-'), 1876 [IS_HTML]: element.namespaceURI === NAMESPACE_HTML 1877 } 1878 ); 1879} 1880 1881/** @type {Map<string, string[]>} */ 1882var setters_cache = new Map(); 1883 1884/** @param {Element} element */ 1885function get_setters(element) { 1886 var cache_key = element.getAttribute('is') || element.nodeName; 1887 var setters = setters_cache.get(cache_key); 1888 if (setters) return setters; 1889 setters_cache.set(cache_key, (setters = [])); 1890 1891 var descriptors; 1892 var proto = element; // In the case of custom elements there might be setters on the instance 1893 var element_proto = Element.prototype; 1894 1895 // Stop at Element, from there on there's only unnecessary setters we're not interested in 1896 // Do not use contructor.name here as that's unreliable in some browser environments 1897 while (element_proto !== proto) { 1898 descriptors = get_descriptors(proto); 1899 1900 for (var key in descriptors) { 1901 if (descriptors[key].set) { 1902 setters.push(key); 1903 } 1904 } 1905 1906 proto = get_prototype_of(proto); 1907 } 1908 1909 return setters; 1910} 1911 1912/** 1913 * @param {any} element 1914 * @param {string} attribute 1915 * @param {string} value 1916 */ 1917function check_src_in_dev_hydration(element, attribute, value) { 1918 if (!DEV) return; 1919 if (attribute === 'srcset' && srcset_url_equal(element, value)) return; 1920 if (src_url_equal(element.getAttribute(attribute) ?? '', value)) return; 1921 1922 hydration_attribute_changed( 1923 attribute, 1924 element.outerHTML.replace(element.innerHTML, element.innerHTML && '...'), 1925 String(value) 1926 ); 1927} 1928 1929/** 1930 * @param {string} element_src 1931 * @param {string} url 1932 * @returns {boolean} 1933 */ 1934function src_url_equal(element_src, url) { 1935 if (element_src === url) return true; 1936 return new URL(element_src, document.baseURI).href === new URL(url, document.baseURI).href; 1937} 1938 1939/** @param {string} srcset */ 1940function split_srcset(srcset) { 1941 return srcset.split(',').map((src) =>
1941 src.trim().split(' ').filter(Boolean)); 1942} 1943 1944/** 1945 * @param {HTMLSourceElement | HTMLImageElement} element 1946 * @param {string} srcset 1947 * @returns {boolean} 1948 */ 1949function srcset_url_equal(element, srcset) { 1950 var element_urls = split_srcset(element.srcset); 1951 var urls = split_srcset(srcset); 1952 1953 return ( 1954 urls.length === element_urls.length && 1955 urls.every( 1956 ([url, width], i) => 1957 width === element_urls[i][1] && 1958 // We need to test both ways because Vite will create an a full URL with 1959 // `new URL(asset, import.meta.url).href` for the client when `base: './'`, and the 1960 // relative URLs inside srcset are not automatically resolved to absolute URLs by 1961 // browsers (in contrast to img.src). This means both SSR and DOM code could 1962 // contain relative or absolute URLs. 1963 (src_url_equal(element_urls[i][0], url) || src_url_equal(url, element_urls[i][0])) 1964 ) 1965 ); 1966} 1967 1968/** 1969 * @param {any} bound_value 1970 * @param {Element} element_or_component 1971 * @returns {boolean} 1972 */ 1973function is_bound_this(bound_value, element_or_component) { 1974 return ( 1975 bound_value === element_or_component || bound_value?.[STATE_SYMBOL] === element_or_component 1976 ); 1977} 1978 1979/** 1980 * @param {any} element_or_component 1981 * @param {(value: unknown, ...parts: unknown[]) => void} update 1982 * @param {(...parts: unknown[]) => unknown} get_value 1983 * @param {() => unknown[]} [get_parts] Set if the this binding is used inside an each block, 1984 * returns all the parts of the each block context that are used in the expression 1985 * @returns {void} 1986 */ 1987function bind_this(element_or_component = {}, update, get_value, get_parts) { 1988 effect(() => { 1989 /** @type {unknown[]} */ 1990 var old_parts; 1991 1992 /** @type {unknown[]} */ 1993 var parts; 1994 1995 render_effect(() => { 1996 old_parts = parts; 1997 // We only track changes to the parts, not the value itself to avoid unnecessary reruns. 1998 parts = get_parts?.() || []; 1999 2000 untrack(() => { 2001 if (element_or_component !== get_value(...parts)) { 2002 update(element_or_component, ...parts); 2003 // If this is an effect rerun (cause: each block context changes), then nullify the binding at 2004 // the previous position if it isn't already taken over by a different effect. 2005 if (old_parts && is_bound_this(get_value(...old_parts), element_or_component)) { 2006 update(null, ...old_parts); 2007 } 2008 } 2009 }); 2010 }); 2011 2012 return () => { 2013 // We cannot use effects in the teardown phase, we we use a microtask instead. 2014 queue_micro_task(() => { 2015 if (parts && is_bound_this(get_value(...parts), element_or_component)) { 2016 update(null, ...parts); 2017 } 2018 }); 2019 }; 2020 }); 2021 2022 return element_or_component; 2023} 2024 2025/** @import { ComponentContextLegacy } from '#client' */ 2026 2027/** 2028 * Legacy-mode only: Call `onMount` callbacks and set up `beforeUpdate`/`afterUpdate` effects 2029 * @param {boolean} [immutable] 2030 */ 2031function init$1(immutable = false) { 2032 const context = /** @type {ComponentContextLegacy} */ (component_context); 2033 2034 const callbacks = context.l.u; 2035 if (!callbacks) return; 2036 2037 let props = () => deep_read_state(context.s); 2038 2039 if (immutable) { 2040 let version = 0; 2041 let prev = /** @type {Record<string, any>} */ ({}); 2042 2043 // In legacy immutable mode, before/afterUpdate only fire if the object identity of a prop changes 2044 const d = derived$1(() => { 2045 let changed = false; 2046 const props = context.s; 2047 for (const key in props) { 2048 if (props[key] !== prev[key]) { 2049 prev[key] = props[key]; 2050 changed = true; 2051 } 2052 } 2053 if (changed) version++; 2054 return version; 2055 }); 2056 2057 props = () => get$1(d); 2058 } 2059 2060 // beforeUpdate 2061 if (callbacks.b.length) { 2062 user_pre_effect(() => { 2063 observe_all(context, props); 2064 run_all(callbacks.b); 2065 }); 2066 } 2067 2068 // onMount (must run before afterUpdate) 2069 user_effect(() => { 2070 const fns = untrack(() => callbacks.m.map(run)); 2071 return () => { 2072 for (const fn of fns) { 2073 if (typeof fn === 'function') { 2074 fn(); 2075 } 2076 } 2077 }; 2078 }); 2079 2080 // afterUpdate 2081 if (callbacks.a.length) { 2082 user_effect(() => { 2083 observe_all(context, props); 2084 run_all(callbacks.a); 2085 }); 2086 } 2087} 2088 2089/** 2090 * Invoke the getter of all signals associated with a component 2091 * so they can be registered to the effect this function is called
2091in. 2092 * @param {ComponentContextLegacy} context 2093 * @param {(() => void)} props 2094 */ 2095function observe_all(context, props) { 2096 if (context.l.s) { 2097 for (const signal of context.l.s) get$1(signal); 2098 } 2099 2100 props(); 2101} 2102 2103/** @import { Readable } from './public' */ 2104 2105/** 2106 * @template T 2107 * @param {Readable<T> | null | undefined} store 2108 * @param {(value: T) => void} run 2109 * @param {(value: T) => void} [invalidate] 2110 * @returns {() => void} 2111 */ 2112function subscribe_to_store(store, run, invalidate) { 2113 if (store == null) { 2114 // @ts-expect-error 2115 run(undefined); 2116 2117 // @ts-expect-error 2118 if (invalidate) invalidate(undefined); 2119 2120 return noop; 2121 } 2122 2123 // Svelte store takes a private second argument 2124 // StartStopNotifier could mutate state, and we want to silence the corresponding validation error 2125 const unsub = untrack(() => 2126 store.subscribe( 2127 run, 2128 // @ts-expect-error 2129 invalidate 2130 ) 2131 ); 2132 2133 // Also support RxJS 2134 // @ts-expect-error TODO fix this in the types? 2135 return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub; 2136} 2137 2138/** @import { Readable, StartStopNotifier, Subscriber, Unsubscriber, Updater, Writable } from '../public.js' */ 2139/** @import { Stores, StoresValues, SubscribeInvalidateTuple } from '../private.js' */ 2140 2141/** 2142 * @type {Array<SubscribeInvalidateTuple<any> | any>} 2143 */ 2144const subscriber_queue = []; 2145 2146/** 2147 * Creates a `Readable` store that allows reading by subscription. 2148 * 2149 * @template T 2150 * @param {T} [value] initial value 2151 * @param {StartStopNotifier<T>} [start] 2152 * @returns {Readable<T>} 2153 */ 2154function readable(value, start) { 2155 return { 2156 subscribe: writable(value, start).subscribe 2157 }; 2158} 2159 2160/** 2161 * Create a `Writable` store that allows both updating and reading by subscription. 2162 * 2163 * @template T 2164 * @param {T} [value] initial value 2165 * @param {StartStopNotifier<T>} [start] 2166 * @returns {Writable<T>} 2167 */ 2168function writable(value, start = noop) { 2169 /** @type {Unsubscriber | null} */ 2170 let stop = null; 2171 2172 /** @type {Set<SubscribeInvalidateTuple<T>>} */ 2173 const subscribers = new Set(); 2174 2175 /** 2176 * @param {T} new_value 2177 * @returns {void} 2178 */ 2179 function set(new_value) { 2180 if (safe_not_equal(value, new_value)) { 2181 value = new_value; 2182 if (stop) { 2183 // store is ready 2184 const run_queue = !subscriber_queue.length; 2185 for (const subscriber of subscribers) { 2186 subscriber[1](); 2187 subscriber_queue.push(subscriber, value); 2188 } 2189 if (run_queue) { 2190 for (let i = 0; i < subscriber_queue.length; i += 2) { 2191 subscriber_queue[i][0](subscriber_queue[i + 1]); 2192 } 2193 subscriber_queue.length = 0; 2194 } 2195 } 2196 } 2197 } 2198 2199 /** 2200 * @param {Updater<T>} fn 2201 * @returns {void} 2202 */ 2203 function update(fn) { 2204 set(fn(/** @type {T} */ (value))); 2205 } 2206 2207 /** 2208 * @param {Subscriber<T>} run 2209 * @param {() => void} [invalidate] 2210 * @returns {Unsubscriber} 2211 */ 2212 function subscribe(run, invalidate = noop) { 2213 /** @type {SubscribeInvalidateTuple<T>} */ 2214 const subscriber = [run, invalidate]; 2215 subscribers.add(subscriber); 2216 if (subscribers.size === 1) { 2217 stop = start(set, update) || noop; 2218 } 2219 run(/** @type {T} */ (value)); 2220 return () => { 2221 subscribers.delete(subscriber); 2222 if (subscribers.size === 0 && stop) { 2223 stop(); 2224 stop = null; 2225 } 2226 }; 2227 } 2228 return { set, update, subscribe }; 2229} 2230 2231/** 2232 * Derived value store by synchronizing one or more readable stores and 2233 * applying an aggregation function over its input values. 2234 * 2235 * @template {Stores} S 2236 * @template T 2237 * @overload 2238 * @param {S} stores 2239 * @param {(values: StoresValues<S>, set: (value: T) => void, update: (fn: Updater<T>) => void) => Unsubscriber | void} fn 2240 * @param {T} [initial_value] 2241 * @returns {Readable<T>} 2242 */ 2243/** 2244 * Derived value store by synchronizing one or more readable stores and 2245 * applying an aggregation function over its input values. 2246 * 2247 * @template {Stores} S 2248 * @template T 2249 * @overload 2250 * @param {S} stores 2251 * @param {(values: StoresValues<S>) => T} fn 2252 * @param {T} [initial_value] 2253 * @returns {Readable<T>} 2254 */ 2255/** 2256 * @template {Stores} S 2257 * @template T 2258 * @param {S} stores 2259 * @param {Function} fn 2260 * @param {T} [initial_value] 2261 * @returns {Readable<T>} 2262 */ 2263function derived(stores, fn, initial_value) { 2264 const single = !Array.isArray(stores); 2265 /** @type {Array<Readable<any>>} */ 2266 const stores_array = single ? [stores] : stores; 2267 if (!stores_array.every(Boolean)) { 2268 throw new Error('derived() expects stores as input, got a falsy value'); 2269 } 2270 const auto = fn.length < 2; 2271 return readable(initial_value, (set, update) => { 2272 let started = false;
2273 /** @type {T[]} */ 2274 const values = []; 2275 let pending = 0; 2276 let cleanup = noop; 2277 const sync = () => { 2278 if (pending) { 2279 return; 2280 } 2281 cleanup(); 2282 const result = fn(single ? values[0] : values, set, update); 2283 if (auto) { 2284 set(result); 2285 } else { 2286 cleanup = typeof result === 'function' ? result : noop; 2287 } 2288 }; 2289 const unsubscribers = stores_array.map((store, i) => 2290 subscribe_to_store( 2291 store, 2292 (value) => { 2293 values[i] = value; 2294 pending &= ~(1 << i); 2295 if (started) { 2296 sync(); 2297 } 2298 }, 2299 () => { 2300 pending |= 1 << i; 2301 } 2302 ) 2303 ); 2304 started = true; 2305 sync(); 2306 return function stop() { 2307 run_all(unsubscribers); 2308 cleanup(); 2309 // We need to set this to false because callbacks can still happen despite having unsubscribed: 2310 // Callbacks might already be placed in the queue which doesn't know it should no longer 2311 // invoke this derived store. 2312 started = false; 2313 }; 2314 }); 2315} 2316 2317/** 2318 * Get the current value from a store by subscribing and immediately unsubscribing. 2319 * 2320 * @template T 2321 * @param {Readable<T>} store 2322 * @returns {T} 2323 */ 2324function get(store) { 2325 let value; 2326 subscribe_to_store(store, (_) => (value = _))(); 2327 // @ts-expect-error 2328 return value; 2329} 2330 2331/** @import { StoreReferencesContainer } from '#client' */ 2332/** @import { Store } from '#shared' */ 2333 2334/** 2335 * Whether or not the prop currently being read is a store binding, as in 2336 * `<Child bind:x={$y} />`. If it is, we treat the prop as mutable even in 2337 * runes mode, and skip `binding_property_non_reactive` validation 2338 */ 2339let is_store_binding = false; 2340 2341let IS_UNMOUNTED = Symbol(); 2342 2343/** 2344 * Gets the current value of a store. If the store isn't subscribed to yet, it will create a proxy 2345 * signal that will be updated when the store is. The store references container is needed to 2346 * track reassignments to stores and to track the correct component context. 2347 * @template V 2348 * @param {Store<V> | null | undefined} store 2349 * @param {string} store_name 2350 * @param {StoreReferencesContainer} stores 2351 * @returns {V} 2352 */ 2353function store_get(store, store_name, stores) { 2354 const entry = (stores[store_name] ??= { 2355 store: null, 2356 source: mutable_source(undefined), 2357 unsubscribe: noop 2358 }); 2359 2360 if (DEV) { 2361 entry.source.label = store_name; 2362 } 2363 2364 // if the component that setup this is already unmounted we don't want to register a subscription 2365 if (entry.store !== store && !(IS_UNMOUNTED in stores)) { 2366 entry.unsubscribe(); 2367 entry.store = store ?? null; 2368 2369 if (store == null) { 2370 entry.source.v = undefined; // see synchronous callback comment below 2371 entry.unsubscribe = noop; 2372 } else { 2373 var is_synchronous_callback = true; 2374 2375 entry.unsubscribe = subscribe_to_store(store, (v) => { 2376 if (is_synchronous_callback) { 2377 // If the first updates to the store value (possibly multiple of them) are synchronously 2378 // inside a derived, we will hit the `state_unsafe_mutation` error if we `set` the value 2379 entry.source.v = v; 2380 } else { 2381 set$1(entry.source, v); 2382 } 2383 }); 2384 2385 is_synchronous_callback = false; 2386 } 2387 } 2388 2389 // if the component that setup this stores is already unmounted the source will be out of sync 2390 // so we just use the `get` for the stores, less performant but it avoids to create a memory leak 2391 // and it will keep the value consistent 2392 if (store && IS_UNMOUNTED in stores) { 2393 return get(store); 2394 } 2395 2396 return get$1(entry.source); 2397} 2398 2399/** 2400 * Sets the new value of a store and returns that value. 2401 * @template V 2402 * @param {Store<V>} store 2403 * @param {V} value 2404 * @returns {V} 2405 */ 2406function store_set(store, value) { 2407 store.set(value); 2408 return value; 2409} 2410 2411/** 2412 * Unsubscribes from all auto-subscribed stores on destroy 2413 * @returns {[StoreReferencesContainer, ()=>void]} 2414 */ 2415function setup_stores() { 2416 /** @type {StoreReferencesContainer} */ 2417 const stores = {}; 2418 2419 function cleanup() { 2420 teardown(() => { 2421 for (var store_name in stores) { 2422 const ref = stores[store_name]; 2423 ref.unsubscribe(); 2424 } 2425 define_property(stores, IS_UNMOUNTED, { 2426 enumerable: false, 2427 value: true 2428 }); 2429 }); 2430 } 2431 2432 return [stores, cleanup]; 2433} 2434 2435/** 2436 * Returns a tuple that indicates whether `fn()` reads a prop that is a store binding. 2437 * Used to prevent `binding_property_non_reactive` validation false positives and 2438 * ensure that these props are treated as mutable even in runes mode 2439 * @template T 2440 * @param {() => T} fn 2441 * @returns {[T, boolean]} 2442 */ 2443function capture_store_binding(fn) { 2444 var previous_is_store_binding = is_store_binding; 2445 2446 try { 2447 is_store_binding = false;
2448 return [fn(), is_store_binding]; 2449 } finally { 2450 is_store_binding = previous_is_store_binding; 2451 } 2452} 2453 2454/** @import { Effect, Source } from './types.js' */ 2455 2456/** 2457 * @param {((value?: number) => number)} fn 2458 * @param {1 | -1} [d] 2459 * @returns {number} 2460 */ 2461function update_prop(fn, d = 1) { 2462 const value = fn(); 2463 fn(value + d); 2464 return value; 2465} 2466 2467/** 2468 * The proxy handler for rest props (i.e. `const { x, ...rest } = $props()`). 2469 * Is passed the full `$$props` object and excludes the named props. 2470 * @type {ProxyHandler<{ props: Record<string | symbol, unknown>, exclude: Array<string | symbol>, name?: string }>}} 2471 */ 2472const rest_props_handler = { 2473 get(target, key) { 2474 if (target.exclude.includes(key)) return; 2475 return target.props[key]; 2476 }, 2477 set(target, key) { 2478 if (DEV) { 2479 // TODO should this happen in prod too? 2480 props_rest_readonly(`${target.name}.${String(key)}`); 2481 } 2482 2483 return false; 2484 }, 2485 getOwnPropertyDescriptor(target, key) { 2486 if (target.exclude.includes(key)) return; 2487 if (key in target.props) { 2488 return { 2489 enumerable: true, 2490 configurable: true, 2491 value: target.props[key] 2492 }; 2493 } 2494 }, 2495 has(target, key) { 2496 if (target.exclude.includes(key)) return false; 2497 return key in target.props; 2498 }, 2499 ownKeys(target) { 2500 return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key)); 2501 } 2502}; 2503 2504/** 2505 * @param {Record<string, unknown>} props 2506 * @param {string[]} exclude 2507 * @param {string} [name] 2508 * @returns {Record<string, unknown>} 2509 */ 2510/*#__NO_SIDE_EFFECTS__*/ 2511function rest_props(props, exclude, name) { 2512 return new Proxy( 2513 DEV ? { props, exclude, name, other: {}, to_proxy: [] } : { props, exclude }, 2514 rest_props_handler 2515 ); 2516} 2517 2518/** 2519 * The proxy handler for legacy $$restProps and $$props 2520 * @type {ProxyHandler<{ props: Record<string | symbol, unknown>, exclude: Array<string | symbol>, special: Record<string | symbol, (v?: unknown) => unknown>, version: Source<number>, parent_effect: Effect }>}} 2521 */ 2522const legacy_rest_props_handler = { 2523 get(target, key) { 2524 if (target.exclude.includes(key)) return; 2525 get$1(target.version); 2526 return key in target.special ? target.special[key]() : target.props[key]; 2527 }, 2528 set(target, key, value) { 2529 if (!(key in target.special)) { 2530 var previous_effect = active_effect; 2531 2532 try { 2533 set_active_effect(target.parent_effect); 2534 2535 // Handle props that can temporarily get out of sync with the parent 2536 /** @type {Record<string, (v?: unknown) => unknown>} */ 2537 target.special[key] = prop( 2538 { 2539 get [key]() { 2540 return target.props[key]; 2541 } 2542 }, 2543 /** @type {string} */ (key), 2544 PROPS_IS_UPDATED 2545 ); 2546 } finally { 2547 set_active_effect(previous_effect); 2548 } 2549 } 2550 2551 target.special[key](value); 2552 update(target.version); // $$props is coarse-grained: when $$props.x is updated, usages of $$props.y etc are also rerun 2553 return true; 2554 }, 2555 getOwnPropertyDescriptor(target, key) { 2556 if (target.exclude.includes(key)) return; 2557 if (key in target.props) { 2558 return { 2559 enumerable: true, 2560 configurable: true, 2561 value: target.props[key] 2562 }; 2563 } 2564 }, 2565 deleteProperty(target, key) { 2566 // Svelte 4 allowed for deletions on $$restProps 2567 if (target.exclude.includes(key)) return true; 2568 target.exclude.push(key); 2569 update(target.version); 2570 return true; 2571 }, 2572 has(target, key) { 2573 if (target.exclude.includes(key)) return false; 2574 return key in target.props; 2575 }, 2576 ownKeys(target) { 2577 return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key)); 2578 } 2579}; 2580 2581/** 2582 * @param {Record<string, unknown>} props 2583 * @param {string[]} exclude 2584 * @returns {Record<string, unknown>} 2585 */ 2586function legacy_rest_props(props, exclude) { 2587 return new Proxy( 2588 { 2589 props, 2590 exclude, 2591 special: {}, 2592 version: source(0), 2593 // TODO this is only necessary because we need to track component 2594 // destruction inside `prop`, because of `bind:this`, but it 2595 // seems likely that we can simplify `bind:this` instead 2596 parent_effect: /** @type {Effect} */ (active_effect) 2597 }, 2598 legacy_rest_props_handler 2599 ); 2600} 2601 2602/** 2603 * The proxy handler for spread props. Handles the incoming array of props 2604 * that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps 2605 * them so that the whole thing is passed to the component as the `$$props` argument. 2606 * @type {ProxyHandler<{ props: Array<Record<string | symbol, unknown> | (() => Record<string | symbol, unknown>)> }>}} 2607 */ 2608const spread_props_handler = { 2609 get(target, key) { 2610 let i = target.props.length; 2611 while (i--) { 2612 let p = target.props[i]; 2613 if (is_function(p)) p = p(); 2614 if (typeof p === 'object' && p !== null && key in p) return p[
2614key]; 2615 } 2616 }, 2617 set(target, key, value) { 2618 let i = target.props.length; 2619 while (i--) { 2620 let p = target.props[i]; 2621 if (is_function(p)) p = p(); 2622 const desc = get_descriptor(p, key); 2623 if (desc && desc.set) { 2624 desc.set(value); 2625 return true; 2626 } 2627 } 2628 return false; 2629 }, 2630 getOwnPropertyDescriptor(target, key) { 2631 let i = target.props.length; 2632 while (i--) { 2633 let p = target.props[i]; 2634 if (is_function(p)) p = p(); 2635 if (typeof p === 'object' && p !== null && key in p) { 2636 const descriptor = get_descriptor(p, key); 2637 if (descriptor && !descriptor.configurable) { 2638 // Prevent a "Non-configurability Report Error": The target is an array, it does 2639 // not actually contain this property. If it is now described as non-configurable, 2640 // the proxy throws a validation error. Setting it to true avoids that. 2641 descriptor.configurable = true; 2642 } 2643 return descriptor; 2644 } 2645 } 2646 }, 2647 has(target, key) { 2648 // To prevent a false positive `is_entry_props` in the `prop` function 2649 if (key === STATE_SYMBOL || key === LEGACY_PROPS) return false; 2650 2651 for (let p of target.props) { 2652 if (is_function(p)) p = p(); 2653 if (p != null && key in p) return true; 2654 } 2655 2656 return false; 2657 }, 2658 ownKeys(target) { 2659 /** @type {Array<string | symbol>} */ 2660 const keys = []; 2661 2662 for (let p of target.props) { 2663 if (is_function(p)) p = p(); 2664 if (!p) continue; 2665 2666 for (const key in p) { 2667 if (!keys.includes(key)) keys.push(key); 2668 } 2669 2670 for (const key of Object.getOwnPropertySymbols(p)) { 2671 if (!keys.includes(key)) keys.push(key); 2672 } 2673 } 2674 2675 return keys; 2676 } 2677}; 2678 2679/** 2680 * @param {Array<Record<string, unknown> | (() => Record<string, unknown>)>} props 2681 * @returns {any} 2682 */ 2683function spread_props(...props) { 2684 return new Proxy({ props }, spread_props_handler); 2685} 2686 2687/** 2688 * This function is responsible for synchronizing a possibly bound prop with the inner component state. 2689 * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value. 2690 * @template V 2691 * @param {Record<string, unknown>} props 2692 * @param {string} key 2693 * @param {number} flags 2694 * @param {V | (() => V)} [fallback] 2695 * @returns {(() => V | ((arg: V) => V) | ((arg: V, mutation: boolean) => V))} 2696 */ 2697function prop(props, key, flags, fallback) { 2698 var runes = !legacy_mode_flag || (flags & PROPS_IS_RUNES) !== 0; 2699 var bindable = (flags & PROPS_IS_BINDABLE) !== 0; 2700 var lazy = (flags & PROPS_IS_LAZY_INITIAL) !== 0; 2701 2702 var fallback_value = /** @type {V} */ (fallback); 2703 var fallback_dirty = true; 2704 2705 var get_fallback = () => { 2706 if (fallback_dirty) { 2707 fallback_dirty = false; 2708 2709 fallback_value = lazy 2710 ? untrack(/** @type {() => V} */ (fallback)) 2711 : /** @type {V} */ (fallback); 2712 } 2713 2714 return fallback_value; 2715 }; 2716 2717 /** @type {((v: V) => void) | undefined} */ 2718 var setter; 2719 2720 if (bindable) { 2721 // Can be the case when someone does `mount(Component, props)` with `let props = $state({...})` 2722 // or `createClassComponent(Component, props)` 2723 var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props; 2724 2725 setter = 2726 get_descriptor(props, key)?.set ?? 2727 (is_entry_props && key in props ? (v) => (props[key] = v) : undefined); 2728 } 2729 2730 var initial_value; 2731 var is_store_sub = false; 2732 2733 if (bindable) { 2734 [initial_value, is_store_sub] = capture_store_binding(() => /** @type {V} */ (props[key])); 2735 } else { 2736 initial_value = /** @type {V} */ (props[key]); 2737 } 2738 2739 if (initial_value === undefined && fallback !== undefined) { 2740 initial_value = get_fallback(); 2741 2742 if (setter) { 2743 if (runes) props_invalid_value(key); 2744 setter(initial_value); 2745 } 2746 } 2747 2748 /** @type {() => V} */ 2749 var getter; 2750 2751 if (runes) { 2752 getter = () => { 2753 var value = /** @type {V} */ (props[key]); 2754 if (value === undefined) return get_fallback(); 2755 fallback_dirty = true; 2756 return value; 2757 }; 2758 } else { 2759 getter = () => { 2760 var value = /** @type {V} */ (props[key]); 2761 2762 if (value !== undefined) { 2763 // in legacy mode, we don't revert to the fallback value 2764 // if the prop goes from defined to undefined. The easiest 2765 // way to model this is to make the fallback undefined 2766 // as soon as the prop has a value 2767 fallback_value = /** @type {V} */ (undefined); 2768 } 2769 2770 return value === undefined ? fallback_value : value; 2771 }; 2772 } 2773 2774 // prop is never written to â we only need a getter 2775 if (runes && (flags & PROPS_IS_UPDATED) === 0) { 2776 return getter; 2777 } 2778 2779 // prop is written to, but the parent component had `bind:foo` which 2780 // means we can just call `$$props.foo = value` directly 2781 if (setter) { 2782 var legacy_parent = props.$$legacy; 2783 return /** @type {() => V} */ ( 2784 function (/** @type {V} */ value, /** @type {boolean} */ mutation) { 2785 if (arguments.length > 0) { 2786 // We don't want to notify if the value was mutated and the parent is in runes mode. 2787 // In that case the state proxy (if it exists) should take care of the notification. 2788 // If the parent is not in runes mode, we need to notify on mutation, too, that the prop 2789 // has changed because the parent will not be able to detect the change otherwise. 2790 if (!runes || !mutation || legacy_parent || is_store_sub) { 2791 /** @type {Function} */ (setter)(mutation ? getter() : value); 2792 } 2793 2794 return value; 2795 } 2796 2797 return getter(); 2798 } 2799 ); 2800 } 2801 2802 // Either prop is written to, but there's no binding, which means we 2803 // create a derived that we can write to locally. 2804 // Or we are in legacy mode where we always create a derived to replicate that 2805 // Svelte 4 did not trigger updates when a primitive value was updated to the same value. 2806 var overridden = false;
2807 2808 var d = ((flags & PROPS_IS_IMMUTABLE) !== 0 ? derived$1 : derived_safe_equal)(() => { 2809 overridden = false; 2810 return getter(); 2811 }); 2812 2813 if (DEV) { 2814 d.label = key; 2815 } 2816 2817 // Capture the initial value if it's bindable 2818 if (bindable) get$1(d); 2819 2820 var parent_effect = /** @type {Effect} */ (active_effect); 2821 2822 return /** @type {() => V} */ ( 2823 function (/** @type {any} */ value, /** @type {boolean} */ mutation) { 2824 if (arguments.length > 0) { 2825 const new_value = mutation ? get$1(d) : runes && bindable ? proxy(value) : value; 2826 2827 set$1(d, new_value); 2828 overridden = true; 2829 2830 if (fallback_value !== undefined) { 2831 fallback_value = new_value; 2832 } 2833 2834 return value; 2835 } 2836 2837 // special case â avoid recalculating the derived if we're in a 2838 // teardown function and the prop was overridden locally, or the 2839 // component was already destroyed (this latter part is necessary 2840 // because `bind:this` can read props after the component has 2841 // been destroyed. TODO simplify `bind:this` 2842 if ((is_destroying_effect && overridden) || (parent_effect.f & DESTROYED) !== 0) { 2843 return d.v; 2844 } 2845 2846 return get$1(d); 2847 } 2848 ); 2849} 2850 2851enable_legacy_mode_flag(); 2852 2853enable_async_mode_flag(); 2854 2855const space_logo = "data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20width='10'%20height='10'%20fill='none'%3e%3cpath%20fill='%23FF3270'%20d='M1.93%206.03v2.04h2.04V6.03H1.93Z'/%3e%3cpath%20fill='%23861FFF'%20d='M6.03%206.03v2.04h2.04V6.03H6.03Z'/%3e%3cpath%20fill='%23097EFF'%20d='M1.93%201.93v2.04h2.04V1.93H1.93Z'/%3e%3cpath%20fill='%23000'%20fill-rule='evenodd'%20d='M.5%201.4c0-.5.4-.9.9-.9h3.1a.9.9%200%200%201%20.87.67A2.44%202.44%200%200%201%209.5%202.95c0%20.65-.25%201.24-.67%201.68.39.1.67.46.67.88v3.08c0%20.5-.4.91-.9.91H1.4a.9.9%200%200%201-.9-.9V1.4Zm1.43.53v2.04h2.04V1.93H1.93Zm0%206.14V6.03h2.04v2.04H1.93Zm4.1%200V6.03h2.04v2.04H6.03Zm0-5.12a1.02%201.02%200%201%201%202.04%200%201.02%201.02%200%200%201-2.04%200Z'%20clip-rule='evenodd'/%3e%3cpath%20fill='%23FFD702'%20d='M7.05%201.93a1.02%201.02%200%201%200%200%202.04%201.02%201.02%200%200%200%200-2.04Z'/%3e%3c/svg%3e"; 2856 2857var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; 2858 2859function getDefaultExportFromCjs (x) { 2860 return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; 2861} 2862 2863function getAugmentedNamespace(n) { 2864 if (Object.prototype.hasOwnProperty.call(n, '__esModule')) return n; 2865 var f = n.default; 2866 if (typeof f == "function") { 2867 var a = function a () { 2868 var isInstance = false; 2869 try { 2870 isInstance = this instanceof a; 2871 } catch {} 2872 if (isInstance) { 2873 return Reflect.construct(f, arguments, this.constructor); 2874 } 2875 return f.apply(this, arguments); 2876 }; 2877 a.prototype = f.prototype; 2878 } else a = {}; 2879 Object.defineProperty(a, '__esModule', {value: true}); 2880 Object.keys(n).forEach(function (k) { 2881 var d = Object.getOwnPropertyDescriptor(n, k); 2882 Object.defineProperty(a, k, d.get ? d : { 2883 enumerable: true, 2884 get: function () { 2885 return n[k]; 2886 } 2887 }); 2888 }); 2889 return a; 2890} 2891 2892var cjs; 2893var hasRequiredCjs; 2894 2895function requireCjs () { 2896 if (hasRequiredCjs) return cjs; 2897 hasRequiredCjs = 1; 2898 2899 var isMergeableObject = function isMergeableObject(value) { 2900 return isNonNullObject(value) 2901 && !isSpecial(value) 2902 }; 2903 2904 function isNonNullObject(value) { 2905 return !!value && typeof value === 'object' 2906 } 2907 2908 function isSpecial(value) { 2909 var stringValue = Object.prototype.toString.call(value); 2910 2911 return stringValue === '[object RegExp]' 2912 || stringValue === '[object Date]' 2913 || isReactElement(value) 2914 } 2915 2916 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25 2917 var canUseSymbol = typeof Symbol === 'function' && Symbol.for; 2918 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7; 2919 2920 function isReactElement(value) { 2921 return value.$$typeof === REACT_ELEMENT_TYPE 2922 } 2923 2924 function emptyTarget(val) { 2925 return Array.isArray(val) ? [] : {} 2926 } 2927 2928 function cloneUnlessOtherwiseSpecified(value, options) { 2929 return (options.clone !== false && options.isMergeableObject(value)) 2930 ? deepmerge(emptyTarget(value), value, options) 2931 : value 2932 } 2933 2934 function defaultArrayMerge(target, source, options) { 2935 return target.concat(source).map(function(element) { 2936 return cloneUnlessOtherwiseSpecified(element, options) 2937 }) 2938 } 2939 2940 function getMergeFunction(key, options) { 2941 if (!options.customMerge) { 2942 return deepmerge 2943 } 2944 var customMerge = options.customMerge(key); 2945 return typeof customMerge === 'function' ? customMerge : deepmerge 2946 } 2947 2948 function getEnumerableOwnPropertySymbols(target) { 2949 return Object.getOwnPropertySymbols 2950 ? Object.getOwnPropertySymbols(target).filter(function(symbol) { 2951 return Object.propertyIsEnumerable.call(target, symbol) 2952 }) 2953 : [] 2954 } 2955 2956 function getKeys(target) { 2957 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target)) 2958 } 2959 2960 function propertyIsOnObject(object, property) { 2961 try { 2962 return property in object 2963 } catch(_) { 2964 return false 2965 } 2966 } 2967 2968 // Protects from prototype poisoning and unexpected merging up the prototype chain.
vendor: 5,067 bytes, lines 2969-3102
2969 function propertyIsUnsafe(target, key) { 2970 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet, 2971 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain, 2972 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable. 2973 } 2974 2975 function mergeObject(target, source, options) { 2976 var destination = {}; 2977 if (options.isMergeableObject(target)) { 2978 getKeys(target).forEach(function(key) { 2979 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options); 2980 }); 2981 } 2982 getKeys(source).forEach(function(key) { 2983 if (propertyIsUnsafe(target, key)) { 2984 return 2985 } 2986 2987 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) { 2988 destination[key] = getMergeFunction(key, options)(target[key], source[key], options); 2989 } else { 2990 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options); 2991 } 2992 }); 2993 return destination 2994 } 2995 2996 function deepmerge(target, source, options) { 2997 options = options || {}; 2998 options.arrayMerge = options.arrayMerge || defaultArrayMerge; 2999 options.isMergeableObject = options.isMergeableObject || isMergeableObject; 3000 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge() 3001 // implementations can use it. The caller may not replace it. 3002 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified; 3003 3004 var sourceIsArray = Array.isArray(source); 3005 var targetIsArray = Array.isArray(target); 3006 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray; 3007 3008 if (!sourceAndTargetTypesMatch) { 3009 return cloneUnlessOtherwiseSpecified(source, options) 3010 } else if (sourceIsArray) { 3011 return options.arrayMerge(target, source, options) 3012 } else { 3013 return mergeObject(target, source, options) 3014 } 3015 } 3016 3017 deepmerge.all = function deepmergeAll(array, options) { 3018 if (!Array.isArray(array)) { 3019 throw new Error('first argument should be an array') 3020 } 3021 3022 return array.reduce(function(prev, next) { 3023 return deepmerge(prev, next, options) 3024 }, {}) 3025 }; 3026 3027 var deepmerge_1 = deepmerge; 3028 3029 cjs = deepmerge_1; 3030 return cjs; 3031} 3032 3033var cjsExports = requireCjs(); 3034const deepmerge = /*@__PURE__*/getDefaultExportFromCjs(cjsExports); 3035 3036/****************************************************************************** 3037Copyright (c) Microsoft Corporation. 3038 3039Permission to use, copy, modify, and/or distribute this software for any 3040purpose with or without fee is hereby granted. 3041 3042THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 3043REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 3044AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 3045INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 3046LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 3047OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 3048PERFORMANCE OF THIS SOFTWARE. 3049***************************************************************************** */ 3050/* global Reflect, Promise, SuppressedError, Symbol, Iterator */ 3051 3052var extendStatics = function(d, b) { 3053 extendStatics = Object.setPrototypeOf || 3054 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 3055 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; 3056 return extendStatics(d, b); 3057}; 3058 3059function __extends(d, b) { 3060 if (typeof b !== "function" && b !== null) 3061 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); 3062 extendStatics(d, b); 3063 function __() { this.constructor = d; } 3064 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 3065} 3066 3067var __assign = function() { 3068 __assign = Object.assign || function __assign(t) { 3069 for (var s, i = 1, n = arguments.length; i < n; i++) { 3070 s = arguments[i]; 3071 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; 3072 } 3073 return t; 3074 }; 3075 return __assign.apply(this, arguments); 3076}; 3077 3078function __rest(s, e) { 3079 var t = {}; 3080 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 3081 t[p] = s[p]; 3082 if (s != null && typeof Object.getOwnPropertySymbols === "function") 3083 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { 3084 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) 3085 t[p[i]] = s[p[i]]; 3086 } 3087 return t; 3088} 3089 3090function __spreadArray(to, from, pack) { 3091 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 3092 if (ar || !(i in from)) { 3093 if (!ar) ar = Array.prototype.slice.call(from, 0, i); 3094 ar[i] = from[i]; 3095 } 3096 } 3097 return to.concat(ar || Array.prototype.slice.call(from)); 3098} 3099 3100typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { 3101 var e = new Error(message); 3102 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
vendor: 14,280 bytes, lines 3102-3463
3102 3103}; 3104 3105// 3106// Main 3107// 3108function memoize(fn, options) { 3109 var cache = options && options.cache ? options.cache : cacheDefault; 3110 var serializer = options && options.serializer ? options.serializer : serializerDefault; 3111 var strategy = options && options.strategy ? options.strategy : strategyDefault; 3112 return strategy(fn, { 3113 cache: cache, 3114 serializer: serializer, 3115 }); 3116} 3117// 3118// Strategy 3119// 3120function isPrimitive(value) { 3121 return (value == null || typeof value === 'number' || typeof value === 'boolean'); // || typeof value === "string" 'unsafe' primitive for our needs 3122} 3123function monadic(fn, cache, serializer, arg) { 3124 var cacheKey = isPrimitive(arg) ? arg : serializer(arg); 3125 var computedValue = cache.get(cacheKey); 3126 if (typeof computedValue === 'undefined') { 3127 computedValue = fn.call(this, arg); 3128 cache.set(cacheKey, computedValue); 3129 } 3130 return computedValue; 3131} 3132function variadic(fn, cache, serializer) { 3133 var args = Array.prototype.slice.call(arguments, 3); 3134 var cacheKey = serializer(args); 3135 var computedValue = cache.get(cacheKey); 3136 if (typeof computedValue === 'undefined') { 3137 computedValue = fn.apply(this, args); 3138 cache.set(cacheKey, computedValue); 3139 } 3140 return computedValue; 3141} 3142function assemble(fn, context, strategy, cache, serialize) { 3143 return strategy.bind(context, fn, cache, serialize); 3144} 3145function strategyDefault(fn, options) { 3146 var strategy = fn.length === 1 ? monadic : variadic; 3147 return assemble(fn, this, strategy, options.cache.create(), options.serializer); 3148} 3149function strategyVariadic(fn, options) { 3150 return assemble(fn, this, variadic, options.cache.create(), options.serializer); 3151} 3152// 3153// Serializer 3154// 3155var serializerDefault = function () { 3156 return JSON.stringify(arguments); 3157}; 3158// 3159// Cache 3160// 3161var ObjectWithoutPrototypeCache = /** @class */ (function () { 3162 function ObjectWithoutPrototypeCache() { 3163 this.cache = Object.create(null); 3164 } 3165 ObjectWithoutPrototypeCache.prototype.get = function (key) { 3166 return this.cache[key]; 3167 }; 3168 ObjectWithoutPrototypeCache.prototype.set = function (key, value) { 3169 this.cache[key] = value; 3170 }; 3171 return ObjectWithoutPrototypeCache; 3172}()); 3173var cacheDefault = { 3174 create: function create() { 3175 return new ObjectWithoutPrototypeCache(); 3176 }, 3177}; 3178var strategies = { 3179 variadic: strategyVariadic}; 3180 3181var ErrorKind; 3182(function (ErrorKind) { 3183 /** Argument is unclosed (e.g. `{0`) */ 3184 ErrorKind[ErrorKind["EXPECT_ARGUMENT_CLOSING_BRACE"] = 1] = "EXPECT_ARGUMENT_CLOSING_BRACE"; 3185 /** Argument is empty (e.g. `{}`). */ 3186 ErrorKind[ErrorKind["EMPTY_ARGUMENT"] = 2] = "EMPTY_ARGUMENT"; 3187 /** Argument is malformed (e.g. `{foo!}``) */ 3188 ErrorKind[ErrorKind["MALFORMED_ARGUMENT"] = 3] = "MALFORMED_ARGUMENT"; 3189 /** Expect an argument type (e.g. `{foo,}`) */ 3190 ErrorKind[ErrorKind["EXPECT_ARGUMENT_TYPE"] = 4] = "EXPECT_ARGUMENT_TYPE"; 3191 /** Unsupported argument type (e.g. `{foo,foo}`) */ 3192 ErrorKind[ErrorKind["INVALID_ARGUMENT_TYPE"] = 5] = "INVALID_ARGUMENT_TYPE"; 3193 /** Expect an argument style (e.g. `{foo, number, }`) */ 3194 ErrorKind[ErrorKind["EXPECT_ARGUMENT_STYLE"] = 6] = "EXPECT_ARGUMENT_STYLE"; 3195 /** The number skeleton is invalid. */ 3196 ErrorKind[ErrorKind["INVALID_NUMBER_SKELETON"] = 7] = "INVALID_NUMBER_SKELETON"; 3197 /** The date time skeleton is invalid. */ 3198 ErrorKind[ErrorKind["INVALID_DATE_TIME_SKELETON"] = 8] = "INVALID_DATE_TIME_SKELETON"; 3199 /** Exepct a number skeleton following the `::` (e.g. `{foo, number, ::}`) */ 3200 ErrorKind[ErrorKind["EXPECT_NUMBER_SKELETON"] = 9] = "EXPECT_NUMBER_SKELETON"; 3201 /** Exepct a date time skeleton following the `::` (e.g. `{foo, date, ::}`) */ 3202 ErrorKind[ErrorKind["EXPECT_DATE_TIME_SKELETON"] = 10] = "EXPECT_DATE_TIME_SKELETON"; 3203 /** Unmatched apostrophes in the argument style (e.g. `{foo, number, 'test`) */ 3204 ErrorKind[ErrorKind["UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"] = 11] = "UNCLOSED_QUOTE_IN_ARGUMENT_STYLE"; 3205 /** Missing select argument options (e.g. `{foo, select}`) */ 3206 ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_OPTIONS"] = 12] = "EXPECT_SELECT_ARGUMENT_OPTIONS"; 3207 /** Expecting an offset value in `plural` or `selectordinal` argument (e.g `{foo, plural, offset}`) */ 3208 ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"] = 13] = "EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE"; 3209 /** Offset value in `plural` or `selectordinal` is invalid (e.g. `{foo, plural, offset: x}`) */ 3210 ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"] = 14] = "INVALID_PLURAL_ARGUMENT_OFFSET_VALUE"; 3211 /** Expecting a selector in `select` argument (e.g `{foo, select}`) */ 3212 ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR"] = 15] = "EXPECT_SELECT_ARGUMENT_SELECTOR"; 3213 /** Expecting a selector in `plural` or `selectordinal` argument (e.g `{foo, plural}`) */ 3214 ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR"] = 16] = "EXPECT_PLURAL_ARGUMENT_SELECTOR"; 3215 /** Expecting a message fragment after the `select` selector (e.g. `{foo, select, apple}`) */ 3216 ErrorKind[ErrorKind["EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"] = 17] = "EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT"; 3217 /** 3218 * Expecting a message fragment after the `plural` or `selectordinal` selector 3219 * (e.g. `{foo, plural, one}`) 3220 */ 3221 ErrorKind[ErrorKind["EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"] = 18] = "EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT"; 3222 /** Selector in `plural` or `selectordinal` is malformed (e.g. `{foo, plural, =x {#}}`) */ 3223 ErrorKind[ErrorKind["INVALID_PLURAL_ARGUMENT_SELECTOR"] = 19] = "INVALID_PLURAL_ARGUMENT_SELECTOR"; 3224 /** 3225 * Duplicate selectors in `plural` or `selectordinal` argument. 3226 * (e.g. {foo, plural, one {#} one {#}}) 3227 */ 3228 ErrorKind[ErrorKind["DUPLICATE_PLURAL_ARGUMENT_SELECTOR"] = 20] = "DUPLICATE_PLURAL_ARGUMENT_SELECTOR"; 3229 /** Duplicate selectors in `select` argument. 3230 * (e.g. {foo, select, apple {apple} apple {apple}}) 3231 */ 3232 ErrorKind[ErrorKind["DUPLICATE_SELECT_ARGUMENT_SELECTOR"] = 21] = "DUPLICATE_SELECT_ARGUMENT_SELECTOR"; 3233 /** Plural or select argument option must have `other` clause. */ 3234 ErrorKind[ErrorKind["MISSING_OTHER_CLAUSE"] = 22] = "MISSING_OTHER_CLAUSE"; 3235 /** The tag is malformed. (e.g. `<bold!>foo</bold!>) */ 3236 ErrorKind[ErrorKind["INVALID_TAG"] = 23] = "INVALID_TAG"; 3237 /** The tag name is invalid. (e.g. `<123>foo</123>`) */ 3238 ErrorKind[ErrorKind["INVALID_TAG_NAME"] = 25] = "INVALID_TAG_NAME"; 3239 /** The closing tag does not match the opening tag. (e.g. `<bold>foo</italic>`) */ 3240 ErrorKind[ErrorKind["UNMATCHED_CLOSING_TAG"] = 26] = "UNMATCHED_CLOSING_TAG"; 3241 /** The opening tag has unmatched closing tag. (e.g. `<bold>foo`) */ 3242 ErrorKind[ErrorKind["UNCLOSED_TAG"] = 27] = "UNCLOSED_TAG"; 3243})(ErrorKind || (ErrorKind = {})); 3244 3245var TYPE; 3246(function (TYPE) { 3247 /** 3248 * Raw text 3249 */ 3250 TYPE[TYPE["literal"] = 0] = "literal"; 3251 /** 3252 * Variable w/o any format, e.g `var` in `this is a {var}` 3253 */ 3254 TYPE[TYPE["argument"] = 1] = "argument"; 3255 /** 3256 * Variable w/ number format 3257 */ 3258 TYPE[TYPE["number"] = 2] = "number"; 3259 /** 3260 * Variable w/ date format 3261 */ 3262 TYPE[TYPE["date"] = 3] = "date"; 3263 /** 3264 * Variable w/ time format 3265 */ 3266 TYPE[TYPE["time"] = 4] = "time"; 3267 /** 3268 * Variable w/ select format 3269 */ 3270 TYPE[TYPE["select"] = 5] = "select"; 3271 /** 3272 * Variable w/ plural format 3273 */ 3274 TYPE[TYPE["plural"] = 6] = "plural"; 3275 /** 3276 * Only possible within plural argument. 3277 * This is the `#` symbol that will be substituted with the count. 3278 */ 3279 TYPE[TYPE["pound"] = 7] = "pound"; 3280 /** 3281 * XML-like tag 3282 */ 3283 TYPE[TYPE["tag"] = 8] = "tag"; 3284})(TYPE || (TYPE = {})); 3285var SKELETON_TYPE; 3286(function (SKELETON_TYPE) { 3287 SKELETON_TYPE[SKELETON_TYPE["number"] = 0] = "number"; 3288 SKELETON_TYPE[SKELETON_TYPE["dateTime"] = 1] = "dateTime"; 3289})(SKELETON_TYPE || (SKELETON_TYPE = {})); 3290/** 3291 * Type Guards 3292 */ 3293function isLiteralElement(el) { 3294 return el.type === TYPE.literal; 3295} 3296function isArgumentElement(el) { 3297 return el.type === TYPE.argument; 3298} 3299function isNumberElement(el) { 3300 return el.type === TYPE.number; 3301} 3302function isDateElement(el) { 3303 return el.type === TYPE.date; 3304} 3305function isTimeElement(el) { 3306 return el.type === TYPE.time; 3307} 3308function isSelectElement(el) { 3309 return el.type === TYPE.select; 3310} 3311function isPluralElement(el) { 3312 return el.type === TYPE.plural; 3313} 3314function isPoundElement(el) { 3315 return el.type === TYPE.pound; 3316} 3317function isTagElement(el) { 3318 return el.type === TYPE.tag; 3319} 3320function isNumberSkeleton(el) { 3321 return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.number); 3322} 3323function isDateTimeSkeleton(el) { 3324 return !!(el && typeof el === 'object' && el.type === SKELETON_TYPE.dateTime); 3325} 3326 3327// @generated from regex-gen.ts 3328var SPACE_SEPARATOR_REGEX = /[ \xA0\u1680\u2000-\u200A\u202F\u205F\u3000]/; 3329 3330/** 3331 * https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table 3332 * Credit: https://github.com/caridy/intl-datetimeformat-pattern/blob/master/index.js 3333 * with some tweaks 3334 */ 3335var DATE_TIME_REGEX = /(?:[Eec]{1,6}|G{1,5}|[Qq]{1,5}|(?:[yYur]+|U{1,5})|[ML]{1,5}|d{1,2}|D{1,3}|F{1}|[abB]{1,5}|[hkHK]{1,2}|w{1,2}|W{1}|m{1,2}|s{1,2}|[zZOvVxX]{1,4})(?=([^']*'[^']*')*[^']*$)/g; 3336/** 3337 * Parse Date time skeleton into Intl.DateTimeFormatOptions 3338 * Ref: https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table 3339 * @public 3340 * @param skeleton skeleton string 3341 */ 3342function parseDateTimeSkeleton(skeleton) { 3343 var result = {}; 3344 skeleton.replace(DATE_TIME_REGEX, function (match) { 3345 var len = match.length; 3346 switch (match[0]) { 3347 // Era 3348 case 'G': 3349 result.era = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short'; 3350 break; 3351 // Year 3352 case 'y': 3353 result.year = len === 2 ? '2-digit' : 'numeric'; 3354 break; 3355 case 'Y': 3356 case 'u': 3357 case 'U': 3358 case 'r': 3359 throw new RangeError('`Y/u/U/r` (year) patterns are not supported, use `y` instead'); 3360 // Quarter 3361 case 'q': 3362 case 'Q': 3363 throw new RangeError('`q/Q` (quarter) patterns are not supported'); 3364 // Month 3365 case 'M': 3366 case 'L': 3367 result.month = ['numeric', '2-digit', 'short', 'long', 'narrow'][len - 1]; 3368 break; 3369 // Week 3370 case 'w': 3371 case 'W': 3372 throw new RangeError('`w/W` (week) patterns are not supported'); 3373 case 'd': 3374 result.day = ['numeric', '2-digit'][len - 1]; 3375 break; 3376 case 'D': 3377 case 'F': 3378 case 'g': 3379 throw new RangeError('`D/F/g` (day) patterns are not supported, use `d` instead'); 3380 // Weekday 3381 case 'E': 3382 result.weekday = len === 4 ? 'long' : len === 5 ? 'narrow' : 'short'; 3383 break; 3384 case 'e': 3385 if (len < 4) { 3386 throw new RangeError('`e..eee` (weekday) patterns are not supported'); 3387 } 3388 result.weekday = ['short', 'long', 'narrow', 'short'][len - 4]; 3389 break; 3390 case 'c': 3391 if (len < 4) { 3392 throw new RangeError('`c..ccc` (weekday) patterns are not supported'); 3393 } 3394 result.weekday = ['short', 'long', 'narrow', 'short'][len - 4]; 3395 break; 3396 // Period 3397 case 'a': // AM, PM 3398 result.hour12 = true; 3399 break; 3400 case 'b': // am, pm, noon, midnight 3401 case 'B': // flexible day periods 3402 throw new RangeError('`b/B` (period) patterns are not supported, use `a` instead'); 3403 // Hour 3404 case 'h': 3405 result.hourCycle = 'h12'; 3406 result.hour = ['numeric', '2-digit'][len - 1]; 3407 break; 3408 case 'H': 3409 result.hourCycle = 'h23'; 3410 result.hour = ['numeric', '2-digit'][len - 1]; 3411 break; 3412 case 'K': 3413 result.hourCycle = 'h11'; 3414 result.hour = ['numeric', '2-digit'][len - 1]; 3415 break; 3416 case 'k': 3417 result.hourCycle = 'h24'; 3418 result.hour = ['numeric', '2-digit'][len - 1]; 3419 break; 3420 case 'j': 3421 case 'J': 3422 case 'C': 3423 throw new RangeError('`j/J/C` (hour) patterns are not supported, use `h/H/K/k` instead'); 3424 // Minute 3425 case 'm': 3426 result.minute = ['numeric', '2-digit'][len - 1]; 3427 break; 3428 // Second 3429 case 's': 3430 result.second = ['numeric', '2-digit'][len - 1]; 3431 break; 3432 case 'S': 3433 case 'A': 3434 throw new RangeError('`S/A` (second) patterns are not supported, use `s` instead'); 3435 // Zone 3436 case 'z': // 1..3, 4: specific non-location format 3437 result.timeZoneName = len < 4 ? 'short' : 'long'; 3438 break; 3439 case 'Z': // 1..3, 4, 5: The ISO8601 varios formats 3440 case 'O': // 1, 4: milliseconds in day short, long 3441 case 'v': // 1, 4: generic non-location format 3442 case 'V': // 1, 2, 3, 4: time zone ID or city 3443 case 'X': // 1, 2, 3, 4: The ISO8601 varios formats 3444 case 'x': // 1, 2, 3, 4: The ISO8601 varios formats 3445 throw new RangeError('`Z/O/v/V/X/x` (timeZone) patterns are not supported, use `z` instead'); 3446 } 3447 return ''; 3448 }); 3449 return result; 3450} 3451 3452// @generated from regex-gen.ts 3453var WHITE_SPACE_REGEX = /[\t-\r \x85\u200E\u200F\u2028\u2029]/i; 3454 3455function parseNumberSkeletonFromString(skeleton) { 3456 if (skeleton.length === 0) { 3457 throw new Error('Number skeleton cannot be empty'); 3458 } 3459 // Parse the skeleton 3460 var stringTokens = skeleton 3461 .split(WHITE_SPACE_REGEX) 3462 .filter(function (x) { return x.length > 0; }); 3463 var tokens = [];
vendor: 4,933 bytes, lines 3464-3622
3464 for (var _i = 0, stringTokens_1 = stringTokens; _i < stringTokens_1.length; _i++) { 3465 var stringToken = stringTokens_1[_i]; 3466 var stemAndOptions = stringToken.split('/'); 3467 if (stemAndOptions.length === 0) { 3468 throw new Error('Invalid number skeleton'); 3469 } 3470 var stem = stemAndOptions[0], options = stemAndOptions.slice(1); 3471 for (var _a = 0, options_1 = options; _a < options_1.length; _a++) { 3472 var option = options_1[_a]; 3473 if (option.length === 0) { 3474 throw new Error('Invalid number skeleton'); 3475 } 3476 } 3477 tokens.push({ stem: stem, options: options }); 3478 } 3479 return tokens; 3480} 3481function icuUnitToEcma(unit) { 3482 return unit.replace(/^(.*?)-/, ''); 3483} 3484var FRACTION_PRECISION_REGEX = /^\.(?:(0+)(\*)?|(#+)|(0+)(#+))$/g; 3485var SIGNIFICANT_PRECISION_REGEX = /^(@+)?(\+|#+)?[rs]?$/g; 3486var INTEGER_WIDTH_REGEX = /(\*)(0+)|(#+)(0+)|(0+)/g; 3487var CONCISE_INTEGER_WIDTH_REGEX = /^(0+)$/; 3488function parseSignificantPrecision(str) { 3489 var result = {}; 3490 if (str[str.length - 1] === 'r') { 3491 result.roundingPriority = 'morePrecision'; 3492 } 3493 else if (str[str.length - 1] === 's') { 3494 result.roundingPriority = 'lessPrecision'; 3495 } 3496 str.replace(SIGNIFICANT_PRECISION_REGEX, function (_, g1, g2) { 3497 // @@@ case 3498 if (typeof g2 !== 'string') { 3499 result.minimumSignificantDigits = g1.length; 3500 result.maximumSignificantDigits = g1.length; 3501 } 3502 // @@@+ case 3503 else if (g2 === '+') { 3504 result.minimumSignificantDigits = g1.length; 3505 } 3506 // .### case 3507 else if (g1[0] === '#') { 3508 result.maximumSignificantDigits = g1.length; 3509 } 3510 // .@@## or .@@@ case 3511 else { 3512 result.minimumSignificantDigits = g1.length; 3513 result.maximumSignificantDigits = 3514 g1.length + (typeof g2 === 'string' ? g2.length : 0); 3515 } 3516 return ''; 3517 }); 3518 return result; 3519} 3520function parseSign(str) { 3521 switch (str) { 3522 case 'sign-auto': 3523 return { 3524 signDisplay: 'auto', 3525 }; 3526 case 'sign-accounting': 3527 case '()': 3528 return { 3529 currencySign: 'accounting', 3530 }; 3531 case 'sign-always': 3532 case '+!': 3533 return { 3534 signDisplay: 'always', 3535 }; 3536 case 'sign-accounting-always': 3537 case '()!': 3538 return { 3539 signDisplay: 'always', 3540 currencySign: 'accounting', 3541 }; 3542 case 'sign-except-zero': 3543 case '+?': 3544 return { 3545 signDisplay: 'exceptZero', 3546 }; 3547 case 'sign-accounting-except-zero': 3548 case '()?': 3549 return { 3550 signDisplay: 'exceptZero', 3551 currencySign: 'accounting', 3552 }; 3553 case 'sign-never': 3554 case '+_': 3555 return { 3556 signDisplay: 'never', 3557 }; 3558 } 3559} 3560function parseConciseScientificAndEngineeringStem(stem) { 3561 // Engineering 3562 var result; 3563 if (stem[0] === 'E' && stem[1] === 'E') { 3564 result = { 3565 notation: 'engineering', 3566 }; 3567 stem = stem.slice(2); 3568 } 3569 else if (stem[0] === 'E') { 3570 result = { 3571 notation: 'scientific', 3572 }; 3573 stem = stem.slice(1); 3574 } 3575 if (result) { 3576 var signDisplay = stem.slice(0, 2); 3577 if (signDisplay === '+!') { 3578 result.signDisplay = 'always'; 3579 stem = stem.slice(2); 3580 } 3581 else if (signDisplay === '+?') { 3582 result.signDisplay = 'exceptZero'; 3583 stem = stem.slice(2); 3584 } 3585 if (!CONCISE_INTEGER_WIDTH_REGEX.test(stem)) { 3586 throw new Error('Malformed concise eng/scientific notation'); 3587 } 3588 result.minimumIntegerDigits = stem.length; 3589 } 3590 return result; 3591} 3592function parseNotationOptions(opt) { 3593 var result = {}; 3594 var signOpts = parseSign(opt); 3595 if (signOpts) { 3596 return signOpts; 3597 } 3598 return result; 3599} 3600/** 3601 * https://github.com/unicode-org/icu/blob/master/docs/userguide/format_parse/numbers/skeletons.md#skeleton-stems-and-options 3602 */ 3603function parseNumberSkeleton(tokens) { 3604 var result = {}; 3605 for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) { 3606 var token = tokens_1[_i]; 3607 switch (token.stem) { 3608 case 'percent': 3609 case '%': 3610 result.style = 'percent'; 3611 continue; 3612 case '%x100': 3613 result.style = 'percent'; 3614 result.scale = 100; 3615 continue; 3616 case 'currency': 3617 result.style = 'currency'; 3618 result.currency = token.options[0]; 3619 continue; 3620 case 'group-off': 3621 case ',_': 3622 result.useGrouping = false;
vendor: 12,268 bytes, lines 3623-4251
3623 continue; 3624 case 'precision-integer': 3625 case '.': 3626 result.maximumFractionDigits = 0; 3627 continue; 3628 case 'measure-unit': 3629 case 'unit': 3630 result.style = 'unit'; 3631 result.unit = icuUnitToEcma(token.options[0]); 3632 continue; 3633 case 'compact-short': 3634 case 'K': 3635 result.notation = 'compact'; 3636 result.compactDisplay = 'short'; 3637 continue; 3638 case 'compact-long': 3639 case 'KK': 3640 result.notation = 'compact'; 3641 result.compactDisplay = 'long'; 3642 continue; 3643 case 'scientific': 3644 result = __assign(__assign(__assign({}, result), { notation: 'scientific' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {})); 3645 continue; 3646 case 'engineering': 3647 result = __assign(__assign(__assign({}, result), { notation: 'engineering' }), token.options.reduce(function (all, opt) { return (__assign(__assign({}, all), parseNotationOptions(opt))); }, {})); 3648 continue; 3649 case 'notation-simple': 3650 result.notation = 'standard'; 3651 continue; 3652 // https://github.com/unicode-org/icu/blob/master/icu4c/source/i18n/unicode/unumberformatter.h 3653 case 'unit-width-narrow': 3654 result.currencyDisplay = 'narrowSymbol'; 3655 result.unitDisplay = 'narrow'; 3656 continue; 3657 case 'unit-width-short': 3658 result.currencyDisplay = 'code'; 3659 result.unitDisplay = 'short'; 3660 continue; 3661 case 'unit-width-full-name': 3662 result.currencyDisplay = 'name'; 3663 result.unitDisplay = 'long'; 3664 continue; 3665 case 'unit-width-iso-code': 3666 result.currencyDisplay = 'symbol'; 3667 continue; 3668 case 'scale': 3669 result.scale = parseFloat(token.options[0]); 3670 continue; 3671 case 'rounding-mode-floor': 3672 result.roundingMode = 'floor'; 3673 continue; 3674 case 'rounding-mode-ceiling': 3675 result.roundingMode = 'ceil'; 3676 continue; 3677 case 'rounding-mode-down': 3678 result.roundingMode = 'trunc'; 3679 continue; 3680 case 'rounding-mode-up': 3681 result.roundingMode = 'expand'; 3682 continue; 3683 case 'rounding-mode-half-even': 3684 result.roundingMode = 'halfEven'; 3685 continue; 3686 case 'rounding-mode-half-down': 3687 result.roundingMode = 'halfTrunc'; 3688 continue; 3689 case 'rounding-mode-half-up': 3690 result.roundingMode = 'halfExpand'; 3691 continue; 3692 // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width 3693 case 'integer-width': 3694 if (token.options.length > 1) { 3695 throw new RangeError('integer-width stems only accept a single optional option'); 3696 } 3697 token.options[0].replace(INTEGER_WIDTH_REGEX, function (_, g1, g2, g3, g4, g5) { 3698 if (g1) { 3699 result.minimumIntegerDigits = g2.length; 3700 } 3701 else if (g3 && g4) { 3702 throw new Error('We currently do not support maximum integer digits'); 3703 } 3704 else if (g5) { 3705 throw new Error('We currently do not support exact integer digits'); 3706 } 3707 return ''; 3708 }); 3709 continue; 3710 } 3711 // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#integer-width 3712 if (CONCISE_INTEGER_WIDTH_REGEX.test(token.stem)) { 3713 result.minimumIntegerDigits = token.stem.length; 3714 continue; 3715 } 3716 if (FRACTION_PRECISION_REGEX.test(token.stem)) { 3717 // Precision 3718 // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#fraction-precision 3719 // precision-integer case 3720 if (token.options.length > 1) { 3721 throw new RangeError('Fraction-precision stems only accept a single optional option'); 3722 } 3723 token.stem.replace(FRACTION_PRECISION_REGEX, function (_, g1, g2, g3, g4, g5) { 3724 // .000* case (before ICU67 it was .000+) 3725 if (g2 === '*') { 3726 result.minimumFractionDigits = g1.length; 3727 } 3728 // .### case 3729 else if (g3 && g3[0] === '#') { 3730 result.maximumFractionDigits = g3.length; 3731 } 3732 // .00## case 3733 else if (g4 && g5) { 3734 result.minimumFractionDigits = g4.length; 3735 result.maximumFractionDigits = g4.length + g5.length; 3736 } 3737 else { 3738 result.minimumFractionDigits = g1.length; 3739 result.maximumFractionDigits = g1.length; 3740 } 3741 return ''; 3742 }); 3743 var opt = token.options[0]; 3744 // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#trailing-zero-display 3745 if (opt === 'w') { 3746 result = __assign(__assign({}, result), { trailingZeroDisplay: 'stripIfInteger' }); 3747 } 3748 else if (opt) { 3749 result = __assign(__assign({}, result), parseSignificantPrecision(opt)); 3750 } 3751 continue; 3752 } 3753 // https://unicode-org.github.io/icu/userguide/format_parse/numbers/skeletons.html#significant-digits-precision 3754 if (SIGNIFICANT_PRECISION_REGEX.test(token.stem)) { 3755 result = __assign(__assign({}, result), parseSignificantPrecision(token.stem)); 3756 continue; 3757 } 3758 var signOpts = parseSign(token.stem); 3759 if (signOpts) { 3760 result = __assign(__assign({}, result), signOpts); 3761 } 3762 var conciseScientificAndEngineeringOpts = parseConciseScientificAndEngineeringStem(token.stem); 3763 if (conciseScientificAndEngineeringOpts) { 3764 result = __assign(__assign({}, result), conciseScientificAndEngineeringOpts); 3765 } 3766 } 3767 return result; 3768} 3769 3770// @generated from time-data-gen.ts 3771// prettier-ignore 3772var timeData = { 3773 "001": [ 3774 "H", 3775 "h" 3776 ], 3777 "419": [ 3778 "h", 3779 "H", 3780 "hB", 3781 "hb" 3782 ], 3783 "AC": [ 3784 "H", 3785 "h", 3786 "hb", 3787 "hB" 3788 ], 3789 "AD": [ 3790 "H", 3791 "hB" 3792 ], 3793 "AE": [ 3794 "h", 3795 "hB", 3796 "hb", 3797 "H" 3798 ], 3799 "AF": [ 3800 "H", 3801 "hb", 3802 "hB", 3803 "h" 3804 ], 3805 "AG": [ 3806 "h", 3807 "hb", 3808 "H", 3809 "hB" 3810 ], 3811 "AI": [ 3812 "H", 3813 "h", 3814 "hb", 3815 "hB" 3816 ], 3817 "AL": [ 3818 "h", 3819 "H", 3820 "hB" 3821 ], 3822 "AM": [ 3823 "H", 3824 "hB" 3825 ], 3826 "AO": [ 3827 "H", 3828 "hB" 3829 ], 3830 "AR": [ 3831 "h", 3832 "H", 3833 "hB", 3834 "hb" 3835 ], 3836 "AS": [ 3837 "h", 3838 "H" 3839 ], 3840 "AT": [ 3841 "H", 3842 "hB" 3843 ], 3844 "AU": [ 3845 "h", 3846 "hb", 3847 "H", 3848 "hB" 3849 ], 3850 "AW": [ 3851 "H", 3852 "hB" 3853 ], 3854 "AX": [ 3855 "H" 3856 ], 3857 "AZ": [ 3858 "H", 3859 "hB", 3860 "h" 3861 ], 3862 "BA": [ 3863 "H", 3864 "hB", 3865 "h" 3866 ], 3867 "BB": [ 3868 "h", 3869 "hb", 3870 "H", 3871 "hB" 3872 ], 3873 "BD": [ 3874 "h", 3875 "hB", 3876 "H" 3877 ], 3878 "BE": [ 3879 "H", 3880 "hB" 3881 ], 3882 "BF": [ 3883 "H", 3884 "hB" 3885 ], 3886 "BG": [ 3887 "H", 3888 "hB", 3889 "h" 3890 ], 3891 "BH": [ 3892 "h", 3893 "hB", 3894 "hb", 3895 "H" 3896 ], 3897 "BI": [ 3898 "H", 3899 "h" 3900 ], 3901 "BJ": [ 3902 "H", 3903 "hB" 3904 ], 3905 "BL": [ 3906 "H", 3907 "hB" 3908 ], 3909 "BM": [ 3910 "h", 3911 "hb", 3912 "H", 3913 "hB" 3914 ], 3915 "BN": [ 3916 "hb", 3917 "hB", 3918 "h", 3919 "H" 3920 ], 3921 "BO": [ 3922 "h", 3923 "H", 3924 "hB", 3925 "hb" 3926 ], 3927 "BQ": [ 3928 "H" 3929 ], 3930 "BR": [ 3931 "H", 3932 "hB" 3933 ], 3934 "BS": [ 3935 "h", 3936 "hb", 3937 "H", 3938 "hB" 3939 ], 3940 "BT": [ 3941 "h", 3942 "H" 3943 ], 3944 "BW": [ 3945 "H", 3946 "h", 3947 "hb", 3948 "hB" 3949 ], 3950 "BY": [ 3951 "H", 3952 "h" 3953 ], 3954 "BZ": [ 3955 "H", 3956 "h", 3957 "hb", 3958 "hB" 3959 ], 3960 "CA": [ 3961 "h", 3962 "hb", 3963 "H", 3964 "hB" 3965 ], 3966 "CC": [ 3967 "H", 3968 "h", 3969 "hb", 3970 "hB" 3971 ], 3972 "CD": [ 3973 "hB", 3974 "H" 3975 ], 3976 "CF": [ 3977 "H", 3978 "h", 3979 "hB" 3980 ], 3981 "CG": [ 3982 "H", 3983 "hB" 3984 ], 3985 "CH": [ 3986 "H", 3987 "hB", 3988 "h" 3989 ], 3990 "CI": [ 3991 "H", 3992 "hB" 3993 ], 3994 "CK": [ 3995 "H", 3996 "h", 3997 "hb", 3998 "hB" 3999 ], 4000 "CL": [ 4001 "h", 4002 "H", 4003 "hB", 4004 "hb" 4005 ], 4006 "CM": [ 4007 "H", 4008 "h", 4009 "hB" 4010 ], 4011 "CN": [ 4012 "H", 4013 "hB", 4014 "hb", 4015 "h" 4016 ], 4017 "CO": [ 4018 "h", 4019 "H", 4020 "hB", 4021 "hb" 4022 ], 4023 "CP": [ 4024 "H" 4025 ], 4026 "CR": [ 4027 "h", 4028 "H", 4029 "hB", 4030 "hb" 4031 ], 4032 "CU": [ 4033 "h", 4034 "H", 4035 "hB", 4036 "hb" 4037 ], 4038 "CV": [ 4039 "H", 4040 "hB" 4041 ], 4042 "CW": [ 4043 "H", 4044 "hB" 4045 ], 4046 "CX": [ 4047 "H", 4048 "h", 4049 "hb", 4050 "hB" 4051 ], 4052 "CY": [ 4053 "h", 4054 "H", 4055 "hb", 4056 "hB" 4057 ], 4058 "CZ": [ 4059 "H" 4060 ], 4061 "DE": [ 4062 "H", 4063 "hB" 4064 ], 4065 "DG": [ 4066 "H", 4067 "h", 4068 "hb", 4069 "hB" 4070 ], 4071 "DJ": [ 4072 "h", 4073 "H" 4074 ], 4075 "DK": [ 4076 "H" 4077 ], 4078 "DM": [ 4079 "h", 4080 "hb", 4081 "H", 4082 "hB" 4083 ], 4084 "DO": [ 4085 "h", 4086 "H", 4087 "hB", 4088 "hb" 4089 ], 4090 "DZ": [ 4091 "h", 4092 "hB", 4093 "hb", 4094 "H" 4095 ], 4096 "EA": [ 4097 "H", 4098 "h", 4099 "hB", 4100 "hb" 4101 ], 4102 "EC": [ 4103 "h", 4104 "H", 4105 "hB", 4106 "hb" 4107 ], 4108 "EE": [ 4109 "H", 4110 "hB" 4111 ], 4112 "EG": [ 4113 "h", 4114 "hB", 4115 "hb", 4116 "H" 4117 ], 4118 "EH": [ 4119 "h", 4120 "hB", 4121 "hb", 4122 "H" 4123 ], 4124 "ER": [ 4125 "h", 4126 "H" 4127 ], 4128 "ES": [ 4129 "H", 4130 "hB", 4131 "h", 4132 "hb" 4133 ], 4134 "ET": [ 4135 "hB", 4136 "hb", 4137 "h", 4138 "H" 4139 ], 4140 "FI": [ 4141 "H" 4142 ], 4143 "FJ": [ 4144 "h", 4145 "hb", 4146 "H", 4147 "hB" 4148 ], 4149 "FK": [ 4150 "H", 4151 "h", 4152 "hb", 4153 "hB" 4154 ], 4155 "FM": [ 4156 "h", 4157 "hb", 4158 "H", 4159 "hB" 4160 ], 4161 "FO": [ 4162 "H", 4163 "h" 4164 ], 4165 "FR": [ 4166 "H", 4167 "hB" 4168 ], 4169 "GA": [ 4170 "H", 4171 "hB" 4172 ], 4173 "GB": [ 4174 "H", 4175 "h", 4176 "hb", 4177 "hB" 4178 ], 4179 "GD": [ 4180 "h", 4181 "hb", 4182 "H", 4183 "hB" 4184 ], 4185 "GE": [ 4186 "H", 4187 "hB", 4188 "h" 4189 ], 4190 "GF": [ 4191 "H", 4192 "hB" 4193 ], 4194 "GG": [ 4195 "H", 4196 "h", 4197 "hb", 4198 "hB" 4199 ], 4200 "GH": [ 4201 "h", 4202 "H" 4203 ], 4204 "GI": [ 4205 "H", 4206 "h", 4207 "hb", 4208 "hB" 4209 ], 4210 "GL": [ 4211 "H", 4212 "h" 4213 ], 4214 "GM": [ 4215 "h", 4216 "hb", 4217 "H", 4218 "hB" 4219 ], 4220 "GN": [ 4221 "H", 4222 "hB" 4223 ], 4224 "GP": [ 4225 "H", 4226 "hB" 4227 ], 4228 "GQ": [ 4229 "H", 4230 "hB", 4231 "h", 4232 "hb" 4233 ], 4234 "GR": [ 4235 "h", 4236 "H", 4237 "hb", 4238 "hB" 4239 ], 4240 "GT": [ 4241 "h", 4242 "H", 4243 "hB", 4244 "hb" 4245 ], 4246 "GU": [ 4247 "h", 4248 "hb", 4249 "H", 4250 "hB" 4251 ],
vendor: 27,756 bytes, lines 4252-5627
4252 "GW": [ 4253 "H", 4254 "hB" 4255 ], 4256 "GY": [ 4257 "h", 4258 "hb", 4259 "H", 4260 "hB" 4261 ], 4262 "HK": [ 4263 "h", 4264 "hB", 4265 "hb", 4266 "H" 4267 ], 4268 "HN": [ 4269 "h", 4270 "H", 4271 "hB", 4272 "hb" 4273 ], 4274 "HR": [ 4275 "H", 4276 "hB" 4277 ], 4278 "HU": [ 4279 "H", 4280 "h" 4281 ], 4282 "IC": [ 4283 "H", 4284 "h", 4285 "hB", 4286 "hb" 4287 ], 4288 "ID": [ 4289 "H" 4290 ], 4291 "IE": [ 4292 "H", 4293 "h", 4294 "hb", 4295 "hB" 4296 ], 4297 "IL": [ 4298 "H", 4299 "hB" 4300 ], 4301 "IM": [ 4302 "H", 4303 "h", 4304 "hb", 4305 "hB" 4306 ], 4307 "IN": [ 4308 "h", 4309 "H" 4310 ], 4311 "IO": [ 4312 "H", 4313 "h", 4314 "hb", 4315 "hB" 4316 ], 4317 "IQ": [ 4318 "h", 4319 "hB", 4320 "hb", 4321 "H" 4322 ], 4323 "IR": [ 4324 "hB", 4325 "H" 4326 ], 4327 "IS": [ 4328 "H" 4329 ], 4330 "IT": [ 4331 "H", 4332 "hB" 4333 ], 4334 "JE": [ 4335 "H", 4336 "h", 4337 "hb", 4338 "hB" 4339 ], 4340 "JM": [ 4341 "h", 4342 "hb", 4343 "H", 4344 "hB" 4345 ], 4346 "JO": [ 4347 "h", 4348 "hB", 4349 "hb", 4350 "H" 4351 ], 4352 "JP": [ 4353 "H", 4354 "K", 4355 "h" 4356 ], 4357 "KE": [ 4358 "hB", 4359 "hb", 4360 "H", 4361 "h" 4362 ], 4363 "KG": [ 4364 "H", 4365 "h", 4366 "hB", 4367 "hb" 4368 ], 4369 "KH": [ 4370 "hB", 4371 "h", 4372 "H", 4373 "hb" 4374 ], 4375 "KI": [ 4376 "h", 4377 "hb", 4378 "H", 4379 "hB" 4380 ], 4381 "KM": [ 4382 "H", 4383 "h", 4384 "hB", 4385 "hb" 4386 ], 4387 "KN": [ 4388 "h", 4389 "hb", 4390 "H", 4391 "hB" 4392 ], 4393 "KP": [ 4394 "h", 4395 "H", 4396 "hB", 4397 "hb" 4398 ], 4399 "KR": [ 4400 "h", 4401 "H", 4402 "hB", 4403 "hb" 4404 ], 4405 "KW": [ 4406 "h", 4407 "hB", 4408 "hb", 4409 "H" 4410 ], 4411 "KY": [ 4412 "h", 4413 "hb", 4414 "H", 4415 "hB" 4416 ], 4417 "KZ": [ 4418 "H", 4419 "hB" 4420 ], 4421 "LA": [ 4422 "H", 4423 "hb", 4424 "hB", 4425 "h" 4426 ], 4427 "LB": [ 4428 "h", 4429 "hB", 4430 "hb", 4431 "H" 4432 ], 4433 "LC": [ 4434 "h", 4435 "hb", 4436 "H", 4437 "hB" 4438 ], 4439 "LI": [ 4440 "H", 4441 "hB", 4442 "h" 4443 ], 4444 "LK": [ 4445 "H", 4446 "h", 4447 "hB", 4448 "hb" 4449 ], 4450 "LR": [ 4451 "h", 4452 "hb", 4453 "H", 4454 "hB" 4455 ], 4456 "LS": [ 4457 "h", 4458 "H" 4459 ], 4460 "LT": [ 4461 "H", 4462 "h", 4463 "hb", 4464 "hB" 4465 ], 4466 "LU": [ 4467 "H", 4468 "h", 4469 "hB" 4470 ], 4471 "LV": [ 4472 "H", 4473 "hB", 4474 "hb", 4475 "h" 4476 ], 4477 "LY": [ 4478 "h", 4479 "hB", 4480 "hb", 4481 "H" 4482 ], 4483 "MA": [ 4484 "H", 4485 "h", 4486 "hB", 4487 "hb" 4488 ], 4489 "MC": [ 4490 "H", 4491 "hB" 4492 ], 4493 "MD": [ 4494 "H", 4495 "hB" 4496 ], 4497 "ME": [ 4498 "H", 4499 "hB", 4500 "h" 4501 ], 4502 "MF": [ 4503 "H", 4504 "hB" 4505 ], 4506 "MG": [ 4507 "H", 4508 "h" 4509 ], 4510 "MH": [ 4511 "h", 4512 "hb", 4513 "H", 4514 "hB" 4515 ], 4516 "MK": [ 4517 "H", 4518 "h", 4519 "hb", 4520 "hB" 4521 ], 4522 "ML": [ 4523 "H" 4524 ], 4525 "MM": [ 4526 "hB", 4527 "hb", 4528 "H", 4529 "h" 4530 ], 4531 "MN": [ 4532 "H", 4533 "h", 4534 "hb", 4535 "hB" 4536 ], 4537 "MO": [ 4538 "h", 4539 "hB", 4540 "hb", 4541 "H" 4542 ], 4543 "MP": [ 4544 "h", 4545 "hb", 4546 "H", 4547 "hB" 4548 ], 4549 "MQ": [ 4550 "H", 4551 "hB" 4552 ], 4553 "MR": [ 4554 "h", 4555 "hB", 4556 "hb", 4557 "H" 4558 ], 4559 "MS": [ 4560 "H", 4561 "h", 4562 "hb", 4563 "hB" 4564 ], 4565 "MT": [ 4566 "H", 4567 "h" 4568 ], 4569 "MU": [ 4570 "H", 4571 "h" 4572 ], 4573 "MV": [ 4574 "H", 4575 "h" 4576 ], 4577 "MW": [ 4578 "h", 4579 "hb", 4580 "H", 4581 "hB" 4582 ], 4583 "MX": [ 4584 "h", 4585 "H", 4586 "hB", 4587 "hb" 4588 ], 4589 "MY": [ 4590 "hb", 4591 "hB", 4592 "h", 4593 "H" 4594 ], 4595 "MZ": [ 4596 "H", 4597 "hB" 4598 ], 4599 "NA": [ 4600 "h", 4601 "H", 4602 "hB", 4603 "hb" 4604 ], 4605 "NC": [ 4606 "H", 4607 "hB" 4608 ], 4609 "NE": [ 4610 "H" 4611 ], 4612 "NF": [ 4613 "H", 4614 "h", 4615 "hb", 4616 "hB" 4617 ], 4618 "NG": [ 4619 "H", 4620 "h", 4621 "hb", 4622 "hB" 4623 ], 4624 "NI": [ 4625 "h", 4626 "H", 4627 "hB", 4628 "hb" 4629 ], 4630 "NL": [ 4631 "H", 4632 "hB" 4633 ], 4634 "NO": [ 4635 "H", 4636 "h" 4637 ], 4638 "NP": [ 4639 "H", 4640 "h", 4641 "hB" 4642 ], 4643 "NR": [ 4644 "H", 4645 "h", 4646 "hb", 4647 "hB" 4648 ], 4649 "NU": [ 4650 "H", 4651 "h", 4652 "hb", 4653 "hB" 4654 ], 4655 "NZ": [ 4656 "h", 4657 "hb", 4658 "H", 4659 "hB" 4660 ], 4661 "OM": [ 4662 "h", 4663 "hB", 4664 "hb", 4665 "H" 4666 ], 4667 "PA": [ 4668 "h", 4669 "H", 4670 "hB", 4671 "hb" 4672 ], 4673 "PE": [ 4674 "h", 4675 "H", 4676 "hB", 4677 "hb" 4678 ], 4679 "PF": [ 4680 "H", 4681 "h", 4682 "hB" 4683 ], 4684 "PG": [ 4685 "h", 4686 "H" 4687 ], 4688 "PH": [ 4689 "h", 4690 "hB", 4691 "hb", 4692 "H" 4693 ], 4694 "PK": [ 4695 "h", 4696 "hB", 4697 "H" 4698 ], 4699 "PL": [ 4700 "H", 4701 "h" 4702 ], 4703 "PM": [ 4704 "H", 4705 "hB" 4706 ], 4707 "PN": [ 4708 "H", 4709 "h", 4710 "hb", 4711 "hB" 4712 ], 4713 "PR": [ 4714 "h", 4715 "H", 4716 "hB", 4717 "hb" 4718 ], 4719 "PS": [ 4720 "h", 4721 "hB", 4722 "hb", 4723 "H" 4724 ], 4725 "PT": [ 4726 "H", 4727 "hB" 4728 ], 4729 "PW": [ 4730 "h", 4731 "H" 4732 ], 4733 "PY": [ 4734 "h", 4735 "H", 4736 "hB", 4737 "hb" 4738 ], 4739 "QA": [ 4740 "h", 4741 "hB", 4742 "hb", 4743 "H" 4744 ], 4745 "RE": [ 4746 "H", 4747 "hB" 4748 ], 4749 "RO": [ 4750 "H", 4751 "hB" 4752 ], 4753 "RS": [ 4754 "H", 4755 "hB", 4756 "h" 4757 ], 4758 "RU": [ 4759 "H" 4760 ], 4761 "RW": [ 4762 "H", 4763 "h" 4764 ], 4765 "SA": [ 4766 "h", 4767 "hB", 4768 "hb", 4769 "H" 4770 ], 4771 "SB": [ 4772 "h", 4773 "hb", 4774 "H", 4775 "hB" 4776 ], 4777 "SC": [ 4778 "H", 4779 "h", 4780 "hB" 4781 ], 4782 "SD": [ 4783 "h", 4784 "hB", 4785 "hb", 4786 "H" 4787 ], 4788 "SE": [ 4789 "H" 4790 ], 4791 "SG": [ 4792 "h", 4793 "hb", 4794 "H", 4795 "hB" 4796 ], 4797 "SH": [ 4798 "H", 4799 "h", 4800 "hb", 4801 "hB" 4802 ], 4803 "SI": [ 4804 "H", 4805 "hB" 4806 ], 4807 "SJ": [ 4808 "H" 4809 ], 4810 "SK": [ 4811 "H" 4812 ], 4813 "SL": [ 4814 "h", 4815 "hb", 4816 "H", 4817 "hB" 4818 ], 4819 "SM": [ 4820 "H", 4821 "h", 4822 "hB" 4823 ], 4824 "SN": [ 4825 "H", 4826 "h", 4827 "hB" 4828 ], 4829 "SO": [ 4830 "h", 4831 "H" 4832 ], 4833 "SR": [ 4834 "H", 4835 "hB" 4836 ], 4837 "SS": [ 4838 "h", 4839 "hb", 4840 "H", 4841 "hB" 4842 ], 4843 "ST": [ 4844 "H", 4845 "hB" 4846 ], 4847 "SV": [ 4848 "h", 4849 "H", 4850 "hB", 4851 "hb" 4852 ], 4853 "SX": [ 4854 "H", 4855 "h", 4856 "hb", 4857 "hB" 4858 ], 4859 "SY": [ 4860 "h", 4861 "hB", 4862 "hb", 4863 "H" 4864 ], 4865 "SZ": [ 4866 "h", 4867 "hb", 4868 "H", 4869 "hB" 4870 ], 4871 "TA": [ 4872 "H", 4873 "h", 4874 "hb", 4875 "hB" 4876 ], 4877 "TC": [ 4878 "h", 4879 "hb", 4880 "H", 4881 "hB" 4882 ], 4883 "TD": [ 4884 "h", 4885 "H", 4886 "hB" 4887 ], 4888 "TF": [ 4889 "H", 4890 "h", 4891 "hB" 4892 ], 4893 "TG": [ 4894 "H", 4895 "hB" 4896 ], 4897 "TH": [ 4898 "H", 4899 "h" 4900 ], 4901 "TJ": [ 4902 "H", 4903 "h" 4904 ], 4905 "TL": [ 4906 "H", 4907 "hB", 4908 "hb", 4909 "h" 4910 ], 4911 "TM": [ 4912 "H", 4913 "h" 4914 ], 4915 "TN": [ 4916 "h", 4917 "hB", 4918 "hb", 4919 "H" 4920 ], 4921 "TO": [ 4922 "h", 4923 "H" 4924 ], 4925 "TR": [ 4926 "H", 4927 "hB" 4928 ], 4929 "TT": [ 4930 "h", 4931 "hb", 4932 "H", 4933 "hB" 4934 ], 4935 "TW": [ 4936 "hB", 4937 "hb", 4938 "h", 4939 "H" 4940 ], 4941 "TZ": [ 4942 "hB", 4943 "hb", 4944 "H", 4945 "h" 4946 ], 4947 "UA": [ 4948 "H", 4949 "hB", 4950 "h" 4951 ], 4952 "UG": [ 4953 "hB", 4954 "hb", 4955 "H", 4956 "h" 4957 ], 4958 "UM": [ 4959 "h", 4960 "hb", 4961 "H", 4962 "hB" 4963 ], 4964 "US": [ 4965 "h", 4966 "hb", 4967 "H", 4968 "hB" 4969 ], 4970 "UY": [ 4971 "h", 4972 "H", 4973 "hB", 4974 "hb" 4975 ], 4976 "UZ": [ 4977 "H", 4978 "hB", 4979 "h" 4980 ], 4981 "VA": [ 4982 "H", 4983 "h", 4984 "hB" 4985 ], 4986 "VC": [ 4987 "h", 4988 "hb", 4989 "H", 4990 "hB" 4991 ], 4992 "VE": [ 4993 "h", 4994 "H", 4995 "hB", 4996 "hb" 4997 ], 4998 "VG": [ 4999 "h", 5000 "hb", 5001 "H", 5002 "hB" 5003 ], 5004 "VI": [ 5005 "h", 5006 "hb", 5007 "H", 5008 "hB" 5009 ], 5010 "VN": [ 5011 "H", 5012 "h" 5013 ], 5014 "VU": [ 5015 "h", 5016 "H" 5017 ], 5018 "WF": [ 5019 "H", 5020 "hB" 5021 ], 5022 "WS": [ 5023 "h", 5024 "H" 5025 ], 5026 "XK": [ 5027 "H", 5028 "hB", 5029 "h" 5030 ], 5031 "YE": [ 5032 "h", 5033 "hB", 5034 "hb", 5035 "H" 5036 ], 5037 "YT": [ 5038 "H", 5039 "hB" 5040 ], 5041 "ZA": [ 5042 "H", 5043 "h", 5044 "hb", 5045 "hB" 5046 ], 5047 "ZM": [ 5048 "h", 5049 "hb", 5050 "H", 5051 "hB" 5052 ], 5053 "ZW": [ 5054 "H", 5055 "h" 5056 ], 5057 "af-ZA": [ 5058 "H", 5059 "h", 5060 "hB", 5061 "hb" 5062 ], 5063 "ar-001": [ 5064 "h", 5065 "hB", 5066 "hb", 5067 "H" 5068 ], 5069 "ca-ES": [ 5070 "H", 5071 "h", 5072 "hB" 5073 ], 5074 "en-001": [ 5075 "h", 5076 "hb", 5077 "H", 5078 "hB" 5079 ], 5080 "en-HK": [ 5081 "h", 5082 "hb", 5083 "H", 5084 "hB" 5085 ], 5086 "en-IL": [ 5087 "H", 5088 "h", 5089 "hb", 5090 "hB" 5091 ], 5092 "en-MY": [ 5093 "h", 5094 "hb", 5095 "H", 5096 "hB" 5097 ], 5098 "es-BR": [ 5099 "H", 5100 "h", 5101 "hB", 5102 "hb" 5103 ], 5104 "es-ES": [ 5105 "H", 5106 "h", 5107 "hB", 5108 "hb" 5109 ], 5110 "es-GQ": [ 5111 "H", 5112 "h", 5113 "hB", 5114 "hb" 5115 ], 5116 "fr-CA": [ 5117 "H", 5118 "h", 5119 "hB" 5120 ], 5121 "gl-ES": [ 5122 "H", 5123 "h", 5124 "hB" 5125 ], 5126 "gu-IN": [ 5127 "hB", 5128 "hb", 5129 "h", 5130 "H" 5131 ], 5132 "hi-IN": [ 5133 "hB", 5134 "h", 5135 "H" 5136 ], 5137 "it-CH": [ 5138 "H", 5139 "h", 5140 "hB" 5141 ], 5142 "it-IT": [ 5143 "H", 5144 "h", 5145 "hB" 5146 ], 5147 "kn-IN": [ 5148 "hB", 5149 "h", 5150 "H" 5151 ], 5152 "ml-IN": [ 5153 "hB", 5154 "h", 5155 "H" 5156 ], 5157 "mr-IN": [ 5158 "hB", 5159 "hb", 5160 "h", 5161 "H" 5162 ], 5163 "pa-IN": [ 5164 "hB", 5165 "hb", 5166 "h", 5167 "H" 5168 ], 5169 "ta-IN": [ 5170 "hB", 5171 "h", 5172 "hb", 5173 "H" 5174 ], 5175 "te-IN": [ 5176 "hB", 5177 "h", 5178 "H" 5179 ], 5180 "zu-ZA": [ 5181 "H", 5182 "hB", 5183 "hb", 5184 "h" 5185 ] 5186}; 5187 5188/** 5189 * Returns the best matching date time pattern if a date time skeleton 5190 * pattern is provided with a locale. Follows the Unicode specification: 5191 * https://www.unicode.org/reports/tr35/tr35-dates.html#table-mapping-requested-time-skeletons-to-patterns 5192 * @param skeleton date time skeleton pattern that possibly includes j, J or C 5193 * @param locale 5194 */ 5195function getBestPattern(skeleton, locale) { 5196 var skeletonCopy = ''; 5197 for (var patternPos = 0; patternPos < skeleton.length; patternPos++) { 5198 var patternChar = skeleton.charAt(patternPos); 5199 if (patternChar === 'j') { 5200 var extraLength = 0; 5201 while (patternPos + 1 < skeleton.length && 5202 skeleton.charAt(patternPos + 1) === patternChar) { 5203 extraLength++; 5204 patternPos++; 5205 } 5206 var hourLen = 1 + (extraLength & 1); 5207 var dayPeriodLen = extraLength < 2 ? 1 : 3 + (extraLength >> 1); 5208 var dayPeriodChar = 'a'; 5209 var hourChar = getDefaultHourSymbolFromLocale(locale); 5210 if (hourChar == 'H' || hourChar == 'k') { 5211 dayPeriodLen = 0; 5212 } 5213 while (dayPeriodLen-- > 0) { 5214 skeletonCopy += dayPeriodChar; 5215 } 5216 while (hourLen-- > 0) { 5217 skeletonCopy = hourChar + skeletonCopy; 5218 } 5219 } 5220 else if (patternChar === 'J') { 5221 skeletonCopy += 'H'; 5222 } 5223 else { 5224 skeletonCopy += patternChar; 5225 } 5226 } 5227 return skeletonCopy; 5228} 5229/** 5230 * Maps the [hour cycle type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/hourCycle) 5231 * of the given `locale` to the corresponding time pattern. 5232 * @param locale 5233 */ 5234function getDefaultHourSymbolFromLocale(locale) { 5235 var hourCycle = locale.hourCycle; 5236 if (hourCycle === undefined && 5237 // @ts-ignore hourCycle(s) is not identified yet 5238 locale.hourCycles && 5239 // @ts-ignore 5240 locale.hourCycles.length) { 5241 // @ts-ignore 5242 hourCycle = locale.hourCycles[0]; 5243 } 5244 if (hourCycle) { 5245 switch (hourCycle) { 5246 case 'h24': 5247 return 'k'; 5248 case 'h23': 5249 return 'H'; 5250 case 'h12': 5251 return 'h'; 5252 case 'h11': 5253 return 'K'; 5254 default: 5255 throw new Error('Invalid hourCycle'); 5256 } 5257 } 5258 // TODO: Once hourCycle is fully supported remove the following with data generation 5259 var languageTag = locale.language; 5260 var regionTag; 5261 if (languageTag !== 'root') { 5262 regionTag = locale.maximize().region; 5263 } 5264 var hourCycles = timeData[regionTag || ''] || 5265 timeData[languageTag || ''] || 5266 timeData["".concat(languageTag, "-001")] || 5267 timeData['001']; 5268 return hourCycles[0]; 5269} 5270 5271var _a; 5272var SPACE_SEPARATOR_START_REGEX = new RegExp("^".concat(SPACE_SEPARATOR_REGEX.source, "*")); 5273var SPACE_SEPARATOR_END_REGEX = new RegExp("".concat(SPACE_SEPARATOR_REGEX.source, "*$")); 5274function createLocation(start, end) { 5275 return { start: start, end: end }; 5276} 5277// #region Ponyfills 5278// Consolidate these variables up top for easier toggling during debugging 5279var hasNativeStartsWith = !!String.prototype.startsWith && '_a'.startsWith('a', 1); 5280var hasNativeFromCodePoint = !!String.fromCodePoint; 5281var hasNativeFromEntries = !!Object.fromEntries; 5282var hasNativeCodePointAt = !!String.prototype.codePointAt; 5283var hasTrimStart = !!String.prototype.trimStart; 5284var hasTrimEnd = !!String.prototype.trimEnd; 5285var hasNativeIsSafeInteger = !!Number.isSafeInteger; 5286var isSafeInteger = hasNativeIsSafeInteger 5287 ? Number.isSafeInteger 5288 : function (n) { 5289 return (typeof n === 'number' && 5290 isFinite(n) && 5291 Math.floor(n) === n && 5292 Math.abs(n) <= 0x1fffffffffffff); 5293 }; 5294// IE11 does not support y and u. 5295var REGEX_SUPPORTS_U_AND_Y = true; 5296try { 5297 var re = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu'); 5298 /** 5299 * legacy Edge or Xbox One browser 5300 * Unicode flag support: supported 5301 * Pattern_Syntax support: not supported 5302 * See https://github.com/formatjs/formatjs/issues/2822 5303 */ 5304 REGEX_SUPPORTS_U_AND_Y = ((_a = re.exec('a')) === null || _a === void 0 ? void 0 : _a[0]) === 'a'; 5305} 5306catch (_) { 5307 REGEX_SUPPORTS_U_AND_Y = false; 5308} 5309var startsWith = hasNativeStartsWith 5310 ? // Native 5311 function startsWith(s, search, position) { 5312 return s.startsWith(search, position); 5313 } 5314 : // For IE11 5315 function startsWith(s, search, position) { 5316 return s.slice(position, position + search.length) === search; 5317 }; 5318var fromCodePoint = hasNativeFromCodePoint 5319 ? String.fromCodePoint 5320 : // IE11 5321 function fromCodePoint() { 5322 var codePoints = []; 5323 for (var _i = 0; _i < arguments.length; _i++) { 5324 codePoints[_i] = arguments[_i]; 5325 } 5326 var elements = ''; 5327 var length = codePoints.length; 5328 var i = 0; 5329 var code; 5330 while (length > i) { 5331 code = codePoints[i++]; 5332 if (code > 0x10ffff) 5333 throw RangeError(code + ' is not a valid code point'); 5334 elements += 5335 code < 0x10000 5336 ? String.fromCharCode(code) 5337 : String.fromCharCode(((code -= 0x10000) >> 10) + 0xd800, (code % 0x400) + 0xdc00); 5338 } 5339 return elements; 5340 }; 5341var fromEntries = 5342// native 5343hasNativeFromEntries 5344 ? Object.fromEntries 5345 : // Ponyfill 5346 function fromEntries(entries) { 5347 var obj = {}; 5348 for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { 5349 var _a = entries_1[_i], k = _a[0], v = _a[1]; 5350 obj[k] = v; 5351 } 5352 return obj; 5353 }; 5354var codePointAt = hasNativeCodePointAt 5355 ? // Native 5356 function codePointAt(s, index) { 5357 return s.codePointAt(index); 5358 } 5359 : // IE 11 5360 function codePointAt(s, index) { 5361 var size = s.length; 5362 if (index < 0 || index >= size) { 5363 return undefined; 5364 } 5365 var first = s.charCodeAt(index); 5366 var second; 5367 return first < 0xd800 || 5368 first > 0xdbff || 5369 index + 1 === size || 5370 (second = s.charCodeAt(index + 1)) < 0xdc00 || 5371 second > 0xdfff 5372 ? first 5373 : ((first - 0xd800) << 10) + (second - 0xdc00) + 0x10000; 5374 }; 5375var trimStart = hasTrimStart 5376 ? // Native 5377 function trimStart(s) { 5378 return s.trimStart(); 5379 } 5380 : // Ponyfill 5381 function trimStart(s) { 5382 return s.replace(SPACE_SEPARATOR_START_REGEX, ''); 5383 }; 5384var trimEnd = hasTrimEnd 5385 ? // Native 5386 function trimEnd(s) { 5387 return s.trimEnd(); 5388 } 5389 : // Ponyfill 5390 function trimEnd(s) { 5391 return s.replace(SPACE_SEPARATOR_END_REGEX, ''); 5392 }; 5393// Prevent minifier to translate new RegExp to literal form that might cause syntax error on IE11. 5394function RE(s, flag) { 5395 return new RegExp(s, flag); 5396} 5397// #endregion 5398var matchIdentifierAtIndex; 5399if (REGEX_SUPPORTS_U_AND_Y) { 5400 // Native 5401 var IDENTIFIER_PREFIX_RE_1 = RE('([^\\p{White_Space}\\p{Pattern_Syntax}]*)', 'yu'); 5402 matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) { 5403 var _a; 5404 IDENTIFIER_PREFIX_RE_1.lastIndex = index; 5405 var match = IDENTIFIER_PREFIX_RE_1.exec(s); 5406 return (_a = match[1]) !== null && _a !== void 0 ? _a : ''; 5407 }; 5408} 5409else { 5410 // IE11 5411 matchIdentifierAtIndex = function matchIdentifierAtIndex(s, index) { 5412 var match = []; 5413 while (true) { 5414 var c = codePointAt(s, index); 5415 if (c === undefined || _isWhiteSpace(c) || _isPatternSyntax(c)) { 5416 break; 5417 } 5418 match.push(c); 5419 index += c >= 0x10000 ? 2 : 1; 5420 } 5421 return fromCodePoint.apply(void 0, match); 5422 }; 5423} 5424var Parser = /** @class */ (function () { 5425 function Parser(message, options) { 5426 if (options === void 0) { options = {}; } 5427 this.message = message; 5428 this.position = { offset: 0, line: 1, column: 1 }; 5429 this.ignoreTag = !!options.ignoreTag; 5430 this.locale = options.locale; 5431 this.requiresOtherClause = !!options.requiresOtherClause; 5432 this.shouldParseSkeletons = !!options.shouldParseSkeletons; 5433 } 5434 Parser.prototype.parse = function () { 5435 if (this.offset() !== 0) { 5436 throw Error('parser can only be used once'); 5437 } 5438 return this.parseMessage(0, '', false); 5439 }; 5440 Parser.prototype.parseMessage = function (nestingLevel, parentArgType, expectingCloseTag) { 5441 var elements = []; 5442 while (!this.isEOF()) { 5443 var char = this.char(); 5444 if (char === 123 /* `{` */) { 5445 var result = this.parseArgument(nestingLevel, expectingCloseTag); 5446 if (result.err) { 5447 return result; 5448 } 5449 elements.push(result.val); 5450 } 5451 else if (char === 125 /* `}` */ && nestingLevel > 0) { 5452 break; 5453 } 5454 else if (char === 35 /* `#` */ && 5455 (parentArgType === 'plural' || parentArgType === 'selectordinal')) { 5456 var position = this.clonePosition(); 5457 this.bump(); 5458 elements.push({ 5459 type: TYPE.pound, 5460 location: createLocation(position, this.clonePosition()), 5461 }); 5462 } 5463 else if (char === 60 /* `<` */ && 5464 !this.ignoreTag && 5465 this.peek() === 47 // char code for '/' 5466 ) { 5467 if (expectingCloseTag) { 5468 break; 5469 } 5470 else { 5471 return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(this.clonePosition(), this.clonePosition())); 5472 } 5473 } 5474 else if (char === 60 /* `<` */ && 5475 !this.ignoreTag && 5476 _isAlpha(this.peek() || 0)) { 5477 var result = this.parseTag(nestingLevel, parentArgType); 5478 if (result.err) { 5479 return result; 5480 } 5481 elements.push(result.val); 5482 } 5483 else { 5484 var result = this.parseLiteral(nestingLevel, parentArgType); 5485 if (result.err) { 5486 return result; 5487 } 5488 elements.push(result.val); 5489 } 5490 } 5491 return { val: elements, err: null }; 5492 }; 5493 /** 5494 * A tag name must start with an ASCII lower/upper case letter. The grammar is based on the 5495 * [custom element name][] except that a dash is NOT always mandatory and uppercase letters 5496 * are accepted: 5497 * 5498 * ``` 5499 * tag ::= "<" tagName (whitespace)* "/>" | "<" tagName (whitespace)* ">" message "</" tagName (whitespace)* ">" 5500 * tagName ::= [a-z] (PENChar)* 5501 * PENChar ::= 5502 * "-" | "." | [0-9] | "_" | [a-z] | [A-Z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] | 5503 * [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | 5504 * [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] 5505 * ``` 5506 * 5507 * [custom element name]: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name 5508 * NOTE: We're a bit more lax here since HTML technically does not allow uppercase HTML element but we do 5509 * since other tag-based engines like React allow it 5510 */ 5511 Parser.prototype.parseTag = function (nestingLevel, parentArgType) { 5512 var startPosition = this.clonePosition(); 5513 this.bump(); // `<` 5514 var tagName = this.parseTagName(); 5515 this.bumpSpace(); 5516 if (this.bumpIf('/>')) { 5517 // Self closing tag 5518 return { 5519 val: { 5520 type: TYPE.literal, 5521 value: "<".concat(tagName, "/>"), 5522 location: createLocation(startPosition, this.clonePosition()), 5523 }, 5524 err: null, 5525 }; 5526 } 5527 else if (this.bumpIf('>')) { 5528 var childrenResult = this.parseMessage(nestingLevel + 1, parentArgType, true); 5529 if (childrenResult.err) { 5530 return childrenResult; 5531 } 5532 var children = childrenResult.val; 5533 // Expecting a close tag 5534 var endTagStartPosition = this.clonePosition(); 5535 if (this.bumpIf('</')) { 5536 if (this.isEOF() || !_isAlpha(this.char())) { 5537 return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition())); 5538 } 5539 var closingTagNameStartPosition = this.clonePosition(); 5540 var closingTagName = this.parseTagName(); 5541 if (tagName !== closingTagName) { 5542 return this.error(ErrorKind.UNMATCHED_CLOSING_TAG, createLocation(closingTagNameStartPosition, this.clonePosition())); 5543 } 5544 this.bumpSpace(); 5545 if (!this.bumpIf('>')) { 5546 return this.error(ErrorKind.INVALID_TAG, createLocation(endTagStartPosition, this.clonePosition())); 5547 } 5548 return { 5549 val: { 5550 type: TYPE.tag, 5551 value: tagName, 5552 children: children, 5553 location: createLocation(startPosition, this.clonePosition()), 5554 }, 5555 err: null, 5556 }; 5557 } 5558 else { 5559 return this.error(ErrorKind.UNCLOSED_TAG, createLocation(startPosition, this.clonePosition())); 5560 } 5561 } 5562 else { 5563 return this.error(ErrorKind.INVALID_TAG, createLocation(startPosition, this.clonePosition())); 5564 } 5565 }; 5566 /** 5567 * This method assumes that the caller has peeked ahead for the first tag character. 5568 */ 5569 Parser.prototype.parseTagName = function () { 5570 var startOffset = this.offset(); 5571 this.bump(); // the first tag name character 5572 while (!this.isEOF() && _isPotentialElementNameChar(this.char())) { 5573 this.bump(); 5574 } 5575 return this.message.slice(startOffset, this.offset()); 5576 }; 5577 Parser.prototype.parseLiteral = function (nestingLevel, parentArgType) { 5578 var start = this.clonePosition(); 5579 var value = ''; 5580 while (true) { 5581 var parseQuoteResult = this.tryParseQuote(parentArgType); 5582 if (parseQuoteResult) { 5583 value += parseQuoteResult; 5584 continue; 5585 } 5586 var parseUnquotedResult = this.tryParseUnquoted(nestingLevel, parentArgType); 5587 if (parseUnquotedResult) { 5588 value += parseUnquotedResult; 5589 continue; 5590 } 5591 var parseLeftAngleResult = this.tryParseLeftAngleBracket(); 5592 if (parseLeftAngleResult) { 5593 value += parseLeftAngleResult; 5594 continue; 5595 } 5596 break; 5597 } 5598 var location = createLocation(start, this.clonePosition()); 5599 return { 5600 val: { type: TYPE.literal, value: value, location: location }, 5601 err: null, 5602 }; 5603 }; 5604 Parser.prototype.tryParseLeftAngleBracket = function () { 5605 if (!this.isEOF() && 5606 this.char() === 60 /* `<` */ && 5607 (this.ignoreTag || 5608 // If at the opening tag or closing tag position, bail. 5609 !_isAlphaOrSlash(this.peek() || 0))) { 5610 this.bump(); // `<` 5611 return '<'; 5612 } 5613 return null; 5614 }; 5615 /** 5616 * Starting with ICU 4.8, an ASCII apostrophe only starts quoted text if it immediately precedes 5617 * a character that requires quoting (that is, "only where needed"), and works the same in 5618 * nested messages as on the top level of the pattern. The new behavior is otherwise compatible. 5619 */ 5620 Parser.prototype.tryParseQuote = function (parentArgType) { 5621 if (this.isEOF() || this.char() !== 39 /* `'` */) { 5622 return null; 5623 } 5624 // Parse escaped char following the apostrophe, or early return if there is no escaped char. 5625 // Check if is valid escaped character 5626 switch (this.peek()) { 5627 case 39 /* `'` */:
vendor: 4,213 bytes, lines 5628-5736
5628 // double quote, should return as a single quote. 5629 this.bump(); 5630 this.bump(); 5631 return "'"; 5632 // '{', '<', '>', '}' 5633 case 123: 5634 case 60: 5635 case 62: 5636 case 125: 5637 break; 5638 case 35: // '#' 5639 if (parentArgType === 'plural' || parentArgType === 'selectordinal') { 5640 break; 5641 } 5642 return null; 5643 default: 5644 return null; 5645 } 5646 this.bump(); // apostrophe 5647 var codePoints = [this.char()]; // escaped char 5648 this.bump(); 5649 // read chars until the optional closing apostrophe is found 5650 while (!this.isEOF()) { 5651 var ch = this.char(); 5652 if (ch === 39 /* `'` */) { 5653 if (this.peek() === 39 /* `'` */) { 5654 codePoints.push(39); 5655 // Bump one more time because we need to skip 2 characters. 5656 this.bump(); 5657 } 5658 else { 5659 // Optional closing apostrophe. 5660 this.bump(); 5661 break; 5662 } 5663 } 5664 else { 5665 codePoints.push(ch); 5666 } 5667 this.bump(); 5668 } 5669 return fromCodePoint.apply(void 0, codePoints); 5670 }; 5671 Parser.prototype.tryParseUnquoted = function (nestingLevel, parentArgType) { 5672 if (this.isEOF()) { 5673 return null; 5674 } 5675 var ch = this.char(); 5676 if (ch === 60 /* `<` */ || 5677 ch === 123 /* `{` */ || 5678 (ch === 35 /* `#` */ && 5679 (parentArgType === 'plural' || parentArgType === 'selectordinal')) || 5680 (ch === 125 /* `}` */ && nestingLevel > 0)) { 5681 return null; 5682 } 5683 else { 5684 this.bump(); 5685 return fromCodePoint(ch); 5686 } 5687 }; 5688 Parser.prototype.parseArgument = function (nestingLevel, expectingCloseTag) { 5689 var openingBracePosition = this.clonePosition(); 5690 this.bump(); // `{` 5691 this.bumpSpace(); 5692 if (this.isEOF()) { 5693 return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())); 5694 } 5695 if (this.char() === 125 /* `}` */) { 5696 this.bump(); 5697 return this.error(ErrorKind.EMPTY_ARGUMENT, createLocation(openingBracePosition, this.clonePosition())); 5698 } 5699 // argument name 5700 var value = this.parseIdentifierIfPossible().value; 5701 if (!value) { 5702 return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition())); 5703 } 5704 this.bumpSpace(); 5705 if (this.isEOF()) { 5706 return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())); 5707 } 5708 switch (this.char()) { 5709 // Simple argument: `{name}` 5710 case 125 /* `}` */: { 5711 this.bump(); // `}` 5712 return { 5713 val: { 5714 type: TYPE.argument, 5715 // value does not include the opening and closing braces. 5716 value: value, 5717 location: createLocation(openingBracePosition, this.clonePosition()), 5718 }, 5719 err: null, 5720 }; 5721 } 5722 // Argument with options: `{name, format, ...}` 5723 case 44 /* `,` */: { 5724 this.bump(); // `,` 5725 this.bumpSpace(); 5726 if (this.isEOF()) { 5727 return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())); 5728 } 5729 return this.parseArgumentOptions(nestingLevel, expectingCloseTag, value, openingBracePosition); 5730 } 5731 default: 5732 return this.error(ErrorKind.MALFORMED_ARGUMENT, createLocation(openingBracePosition, this.clonePosition())); 5733 } 5734 }; 5735 /** 5736 * Advance the parser until the end of the identifier, if it is currently on
vendor: 11,335 bytes, lines 5737-5978
5737 * an identifier character. Return an empty string otherwise. 5738 */ 5739 Parser.prototype.parseIdentifierIfPossible = function () { 5740 var startingPosition = this.clonePosition(); 5741 var startOffset = this.offset(); 5742 var value = matchIdentifierAtIndex(this.message, startOffset); 5743 var endOffset = startOffset + value.length; 5744 this.bumpTo(endOffset); 5745 var endPosition = this.clonePosition(); 5746 var location = createLocation(startingPosition, endPosition); 5747 return { value: value, location: location }; 5748 }; 5749 Parser.prototype.parseArgumentOptions = function (nestingLevel, expectingCloseTag, value, openingBracePosition) { 5750 var _a; 5751 // Parse this range: 5752 // {name, type, style} 5753 // ^---^ 5754 var typeStartPosition = this.clonePosition(); 5755 var argType = this.parseIdentifierIfPossible().value; 5756 var typeEndPosition = this.clonePosition(); 5757 switch (argType) { 5758 case '': 5759 // Expecting a style string number, date, time, plural, selectordinal, or select. 5760 return this.error(ErrorKind.EXPECT_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition)); 5761 case 'number': 5762 case 'date': 5763 case 'time': { 5764 // Parse this range: 5765 // {name, number, style} 5766 // ^-------^ 5767 this.bumpSpace(); 5768 var styleAndLocation = null; 5769 if (this.bumpIf(',')) { 5770 this.bumpSpace(); 5771 var styleStartPosition = this.clonePosition(); 5772 var result = this.parseSimpleArgStyleIfPossible(); 5773 if (result.err) { 5774 return result; 5775 } 5776 var style = trimEnd(result.val); 5777 if (style.length === 0) { 5778 return this.error(ErrorKind.EXPECT_ARGUMENT_STYLE, createLocation(this.clonePosition(), this.clonePosition())); 5779 } 5780 var styleLocation = createLocation(styleStartPosition, this.clonePosition()); 5781 styleAndLocation = { style: style, styleLocation: styleLocation }; 5782 } 5783 var argCloseResult = this.tryParseArgumentClose(openingBracePosition); 5784 if (argCloseResult.err) { 5785 return argCloseResult; 5786 } 5787 var location_1 = createLocation(openingBracePosition, this.clonePosition()); 5788 // Extract style or skeleton 5789 if (styleAndLocation && startsWith(styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style, '::', 0)) { 5790 // Skeleton starts with `::`. 5791 var skeleton = trimStart(styleAndLocation.style.slice(2)); 5792 if (argType === 'number') { 5793 var result = this.parseNumberSkeletonFromString(skeleton, styleAndLocation.styleLocation); 5794 if (result.err) { 5795 return result; 5796 } 5797 return { 5798 val: { type: TYPE.number, value: value, location: location_1, style: result.val }, 5799 err: null, 5800 }; 5801 } 5802 else { 5803 if (skeleton.length === 0) { 5804 return this.error(ErrorKind.EXPECT_DATE_TIME_SKELETON, location_1); 5805 } 5806 var dateTimePattern = skeleton; 5807 // Get "best match" pattern only if locale is passed, if not, let it 5808 // pass as-is where `parseDateTimeSkeleton()` will throw an error 5809 // for unsupported patterns. 5810 if (this.locale) { 5811 dateTimePattern = getBestPattern(skeleton, this.locale); 5812 } 5813 var style = { 5814 type: SKELETON_TYPE.dateTime, 5815 pattern: dateTimePattern, 5816 location: styleAndLocation.styleLocation, 5817 parsedOptions: this.shouldParseSkeletons 5818 ? parseDateTimeSkeleton(dateTimePattern) 5819 : {}, 5820 }; 5821 var type = argType === 'date' ? TYPE.date : TYPE.time; 5822 return { 5823 val: { type: type, value: value, location: location_1, style: style }, 5824 err: null, 5825 }; 5826 } 5827 } 5828 // Regular style or no style. 5829 return { 5830 val: { 5831 type: argType === 'number' 5832 ? TYPE.number 5833 : argType === 'date' 5834 ? TYPE.date 5835 : TYPE.time, 5836 value: value, 5837 location: location_1, 5838 style: (_a = styleAndLocation === null || styleAndLocation === void 0 ? void 0 : styleAndLocation.style) !== null && _a !== void 0 ? _a : null, 5839 }, 5840 err: null, 5841 }; 5842 } 5843 case 'plural': 5844 case 'selectordinal': 5845 case 'select': { 5846 // Parse this range: 5847 // {name, plural, options} 5848 // ^---------^ 5849 var typeEndPosition_1 = this.clonePosition(); 5850 this.bumpSpace(); 5851 if (!this.bumpIf(',')) { 5852 return this.error(ErrorKind.EXPECT_SELECT_ARGUMENT_OPTIONS, createLocation(typeEndPosition_1, __assign({}, typeEndPosition_1))); 5853 } 5854 this.bumpSpace(); 5855 // Parse offset: 5856 // {name, plural, offset:1, options} 5857 // ^-----^ 5858 // 5859 // or the first option: 5860 // 5861 // {name, plural, one {...} other {...}} 5862 // ^--^ 5863 var identifierAndLocation = this.parseIdentifierIfPossible(); 5864 var pluralOffset = 0; 5865 if (argType !== 'select' && identifierAndLocation.value === 'offset') { 5866 if (!this.bumpIf(':')) { 5867 return this.error(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, createLocation(this.clonePosition(), this.clonePosition())); 5868 } 5869 this.bumpSpace(); 5870 var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE, ErrorKind.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE); 5871 if (result.err) { 5872 return result; 5873 } 5874 // Parse another identifier for option parsing 5875 this.bumpSpace(); 5876 identifierAndLocation = this.parseIdentifierIfPossible(); 5877 pluralOffset = result.val; 5878 } 5879 var optionsResult = this.tryParsePluralOrSelectOptions(nestingLevel, argType, expectingCloseTag, identifierAndLocation); 5880 if (optionsResult.err) { 5881 return optionsResult; 5882 } 5883 var argCloseResult = this.tryParseArgumentClose(openingBracePosition); 5884 if (argCloseResult.err) { 5885 return argCloseResult; 5886 } 5887 var location_2 = createLocation(openingBracePosition, this.clonePosition()); 5888 if (argType === 'select') { 5889 return { 5890 val: { 5891 type: TYPE.select, 5892 value: value, 5893 options: fromEntries(optionsResult.val), 5894 location: location_2, 5895 }, 5896 err: null, 5897 }; 5898 } 5899 else { 5900 return { 5901 val: { 5902 type: TYPE.plural, 5903 value: value, 5904 options: fromEntries(optionsResult.val), 5905 offset: pluralOffset, 5906 pluralType: argType === 'plural' ? 'cardinal' : 'ordinal', 5907 location: location_2, 5908 }, 5909 err: null, 5910 }; 5911 } 5912 } 5913 default: 5914 return this.error(ErrorKind.INVALID_ARGUMENT_TYPE, createLocation(typeStartPosition, typeEndPosition)); 5915 } 5916 }; 5917 Parser.prototype.tryParseArgumentClose = function (openingBracePosition) { 5918 // Parse: {value, number, ::currency/GBP } 5919 // 5920 if (this.isEOF() || this.char() !== 125 /* `}` */) { 5921 return this.error(ErrorKind.EXPECT_ARGUMENT_CLOSING_BRACE, createLocation(openingBracePosition, this.clonePosition())); 5922 } 5923 this.bump(); // `}` 5924 return { val: true, err: null }; 5925 }; 5926 /** 5927 * See: https://github.com/unicode-org/icu/blob/af7ed1f6d2298013dc303628438ec4abe1f16479/icu4c/source/common/messagepattern.cpp#L659 5928 */ 5929 Parser.prototype.parseSimpleArgStyleIfPossible = function () { 5930 var nestedBraces = 0; 5931 var startPosition = this.clonePosition(); 5932 while (!this.isEOF()) { 5933 var ch = this.char(); 5934 switch (ch) { 5935 case 39 /* `'` */: { 5936 // Treat apostrophe as quoting but include it in the style part. 5937 // Find the end of the quoted literal text. 5938 this.bump(); 5939 var apostrophePosition = this.clonePosition(); 5940 if (!this.bumpUntil("'")) { 5941 return this.error(ErrorKind.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE, createLocation(apostrophePosition, this.clonePosition())); 5942 } 5943 this.bump(); 5944 break; 5945 } 5946 case 123 /* `{` */: { 5947 nestedBraces += 1; 5948 this.bump(); 5949 break; 5950 } 5951 case 125 /* `}` */: { 5952 if (nestedBraces > 0) { 5953 nestedBraces -= 1; 5954 } 5955 else { 5956 return { 5957 val: this.message.slice(startPosition.offset, this.offset()), 5958 err: null, 5959 }; 5960 } 5961 break; 5962 } 5963 default: 5964 this.bump(); 5965 break; 5966 } 5967 } 5968 return { 5969 val: this.message.slice(startPosition.offset, this.offset()), 5970 err: null, 5971 }; 5972 }; 5973 Parser.prototype.parseNumberSkeletonFromString = function (skeleton, location) { 5974 var tokens = []; 5975 try { 5976 tokens = parseNumberSkeletonFromString(skeleton); 5977 } 5978 catch (e) {
vendor: 4,672 bytes, lines 5979-6078
5979 return this.error(ErrorKind.INVALID_NUMBER_SKELETON, location); 5980 } 5981 return { 5982 val: { 5983 type: SKELETON_TYPE.number, 5984 tokens: tokens, 5985 location: location, 5986 parsedOptions: this.shouldParseSkeletons 5987 ? parseNumberSkeleton(tokens) 5988 : {}, 5989 }, 5990 err: null, 5991 }; 5992 }; 5993 /** 5994 * @param nesting_level The current nesting level of messages. 5995 * This can be positive when parsing message fragment in select or plural argument options. 5996 * @param parent_arg_type The parent argument's type. 5997 * @param parsed_first_identifier If provided, this is the first identifier-like selector of 5998 * the argument. It is a by-product of a previous parsing attempt. 5999 * @param expecting_close_tag If true, this message is directly or indirectly nested inside 6000 * between a pair of opening and closing tags. The nested message will not parse beyond 6001 * the closing tag boundary. 6002 */ 6003 Parser.prototype.tryParsePluralOrSelectOptions = function (nestingLevel, parentArgType, expectCloseTag, parsedFirstIdentifier) { 6004 var _a; 6005 var hasOtherClause = false; 6006 var options = []; 6007 var parsedSelectors = new Set(); 6008 var selector = parsedFirstIdentifier.value, selectorLocation = parsedFirstIdentifier.location; 6009 // Parse: 6010 // one {one apple} 6011 // ^--^ 6012 while (true) { 6013 if (selector.length === 0) { 6014 var startPosition = this.clonePosition(); 6015 if (parentArgType !== 'select' && this.bumpIf('=')) { 6016 // Try parse `={number}` selector 6017 var result = this.tryParseDecimalInteger(ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, ErrorKind.INVALID_PLURAL_ARGUMENT_SELECTOR); 6018 if (result.err) { 6019 return result; 6020 } 6021 selectorLocation = createLocation(startPosition, this.clonePosition()); 6022 selector = this.message.slice(startPosition.offset, this.offset()); 6023 } 6024 else { 6025 break; 6026 } 6027 } 6028 // Duplicate selector clauses 6029 if (parsedSelectors.has(selector)) { 6030 return this.error(parentArgType === 'select' 6031 ? ErrorKind.DUPLICATE_SELECT_ARGUMENT_SELECTOR 6032 : ErrorKind.DUPLICATE_PLURAL_ARGUMENT_SELECTOR, selectorLocation); 6033 } 6034 if (selector === 'other') { 6035 hasOtherClause = true; 6036 } 6037 // Parse: 6038 // one {one apple} 6039 // ^----------^ 6040 this.bumpSpace(); 6041 var openingBracePosition = this.clonePosition(); 6042 if (!this.bumpIf('{')) { 6043 return this.error(parentArgType === 'select' 6044 ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT 6045 : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT, createLocation(this.clonePosition(), this.clonePosition())); 6046 } 6047 var fragmentResult = this.parseMessage(nestingLevel + 1, parentArgType, expectCloseTag); 6048 if (fragmentResult.err) { 6049 return fragmentResult; 6050 } 6051 var argCloseResult = this.tryParseArgumentClose(openingBracePosition); 6052 if (argCloseResult.err) { 6053 return argCloseResult; 6054 } 6055 options.push([ 6056 selector, 6057 { 6058 value: fragmentResult.val, 6059 location: createLocation(openingBracePosition, this.clonePosition()), 6060 }, 6061 ]); 6062 // Keep track of the existing selectors 6063 parsedSelectors.add(selector); 6064 // Prep next selector clause. 6065 this.bumpSpace(); 6066 (_a = this.parseIdentifierIfPossible(), selector = _a.value, selectorLocation = _a.location); 6067 } 6068 if (options.length === 0) { 6069 return this.error(parentArgType === 'select' 6070 ? ErrorKind.EXPECT_SELECT_ARGUMENT_SELECTOR 6071 : ErrorKind.EXPECT_PLURAL_ARGUMENT_SELECTOR, createLocation(this.clonePosition(), this.clonePosition())); 6072 } 6073 if (this.requiresOtherClause && !hasOtherClause) { 6074 return this.error(ErrorKind.MISSING_OTHER_CLAUSE, createLocation(this.clonePosition(), this.clonePosition())); 6075 } 6076 return { val: options, err: null }; 6077 }; 6078 Parser.prototype.tryParseDecimalInteger = function (expectNumberError, invalidNumber
vendor: 8,108 bytes, lines 6078-6327
6078Error) { 6079 var sign = 1; 6080 var startingPosition = this.clonePosition(); 6081 if (this.bumpIf('+')) ; 6082 else if (this.bumpIf('-')) { 6083 sign = -1; 6084 } 6085 var hasDigits = false; 6086 var decimal = 0; 6087 while (!this.isEOF()) { 6088 var ch = this.char(); 6089 if (ch >= 48 /* `0` */ && ch <= 57 /* `9` */) { 6090 hasDigits = true; 6091 decimal = decimal * 10 + (ch - 48); 6092 this.bump(); 6093 } 6094 else { 6095 break; 6096 } 6097 } 6098 var location = createLocation(startingPosition, this.clonePosition()); 6099 if (!hasDigits) { 6100 return this.error(expectNumberError, location); 6101 } 6102 decimal *= sign; 6103 if (!isSafeInteger(decimal)) { 6104 return this.error(invalidNumberError, location); 6105 } 6106 return { val: decimal, err: null }; 6107 }; 6108 Parser.prototype.offset = function () { 6109 return this.position.offset; 6110 }; 6111 Parser.prototype.isEOF = function () { 6112 return this.offset() === this.message.length; 6113 }; 6114 Parser.prototype.clonePosition = function () { 6115 // This is much faster than `Object.assign` or spread. 6116 return { 6117 offset: this.position.offset, 6118 line: this.position.line, 6119 column: this.position.column, 6120 }; 6121 }; 6122 /** 6123 * Return the code point at the current position of the parser. 6124 * Throws if the index is out of bound. 6125 */ 6126 Parser.prototype.char = function () { 6127 var offset = this.position.offset; 6128 if (offset >= this.message.length) { 6129 throw Error('out of bound'); 6130 } 6131 var code = codePointAt(this.message, offset); 6132 if (code === undefined) { 6133 throw Error("Offset ".concat(offset, " is at invalid UTF-16 code unit boundary")); 6134 } 6135 return code; 6136 }; 6137 Parser.prototype.error = function (kind, location) { 6138 return { 6139 val: null, 6140 err: { 6141 kind: kind, 6142 message: this.message, 6143 location: location, 6144 }, 6145 }; 6146 }; 6147 /** Bump the parser to the next UTF-16 code unit. */ 6148 Parser.prototype.bump = function () { 6149 if (this.isEOF()) { 6150 return; 6151 } 6152 var code = this.char(); 6153 if (code === 10 /* '\n' */) { 6154 this.position.line += 1; 6155 this.position.column = 1; 6156 this.position.offset += 1; 6157 } 6158 else { 6159 this.position.column += 1; 6160 // 0 ~ 0x10000 -> unicode BMP, otherwise skip the surrogate pair. 6161 this.position.offset += code < 0x10000 ? 1 : 2; 6162 } 6163 }; 6164 /** 6165 * If the substring starting at the current position of the parser has 6166 * the given prefix, then bump the parser to the character immediately 6167 * following the prefix and return true. Otherwise, don't bump the parser 6168 * and return false. 6169 */ 6170 Parser.prototype.bumpIf = function (prefix) { 6171 if (startsWith(this.message, prefix, this.offset())) { 6172 for (var i = 0; i < prefix.length; i++) { 6173 this.bump(); 6174 } 6175 return true; 6176 } 6177 return false; 6178 }; 6179 /** 6180 * Bump the parser until the pattern character is found and return `true`. 6181 * Otherwise bump to the end of the file and return `false`. 6182 */ 6183 Parser.prototype.bumpUntil = function (pattern) { 6184 var currentOffset = this.offset(); 6185 var index = this.message.indexOf(pattern, currentOffset); 6186 if (index >= 0) { 6187 this.bumpTo(index); 6188 return true; 6189 } 6190 else { 6191 this.bumpTo(this.message.length); 6192 return false; 6193 } 6194 }; 6195 /** 6196 * Bump the parser to the target offset. 6197 * If target offset is beyond the end of the input, bump the parser to the end of the input. 6198 */ 6199 Parser.prototype.bumpTo = function (targetOffset) { 6200 if (this.offset() > targetOffset) { 6201 throw Error("targetOffset ".concat(targetOffset, " must be greater than or equal to the current offset ").concat(this.offset())); 6202 } 6203 targetOffset = Math.min(targetOffset, this.message.length); 6204 while (true) { 6205 var offset = this.offset(); 6206 if (offset === targetOffset) { 6207 break; 6208 } 6209 if (offset > targetOffset) { 6210 throw Error("targetOffset ".concat(targetOffset, " is at invalid UTF-16 code unit boundary")); 6211 } 6212 this.bump(); 6213 if (this.isEOF()) { 6214 break; 6215 } 6216 } 6217 }; 6218 /** advance the parser through all whitespace to the next non-whitespace code unit. */ 6219 Parser.prototype.bumpSpace = function () { 6220 while (!this.isEOF() && _isWhiteSpace(this.char())) { 6221 this.bump(); 6222 } 6223 }; 6224 /** 6225 * Peek at the *next* Unicode codepoint in the input without advancing the parser. 6226 * If the input has been exhausted, then this returns null. 6227 */ 6228 Parser.prototype.peek = function () { 6229 if (this.isEOF()) { 6230 return null; 6231 } 6232 var code = this.char(); 6233 var offset = this.offset(); 6234 var nextCode = this.message.charCodeAt(offset + (code >= 0x10000 ? 2 : 1)); 6235 return nextCode !== null && nextCode !== void 0 ? nextCode : null; 6236 }; 6237 return Parser; 6238}()); 6239/** 6240 * This check if codepoint is alphabet (lower & uppercase) 6241 * @param codepoint 6242 * @returns 6243 */ 6244function _isAlpha(codepoint) { 6245 return ((codepoint >= 97 && codepoint <= 122) || 6246 (codepoint >= 65 && codepoint <= 90)); 6247} 6248function _isAlphaOrSlash(codepoint) { 6249 return _isAlpha(codepoint) || codepoint === 47; /* '/' */ 6250} 6251/** See `parseTag` function docs. */ 6252function _isPotentialElementNameChar(c) { 6253 return (c === 45 /* '-' */ || 6254 c === 46 /* '.' */ || 6255 (c >= 48 && c <= 57) /* 0..9 */ || 6256 c === 95 /* '_' */ || 6257 (c >= 97 && c <= 122) /** a..z */ || 6258 (c >= 65 && c <= 90) /* A..Z */ || 6259 c == 0xb7 || 6260 (c >= 0xc0 && c <= 0xd6) || 6261 (c >= 0xd8 && c <= 0xf6) || 6262 (c >= 0xf8 && c <= 0x37d) || 6263 (c >= 0x37f && c <= 0x1fff) || 6264 (c >= 0x200c && c <= 0x200d) || 6265 (c >= 0x203f && c <= 0x2040) || 6266 (c >= 0x2070 && c <= 0x218f) || 6267 (c >= 0x2c00 && c <= 0x2fef) || 6268 (c >= 0x3001 && c <= 0xd7ff) || 6269 (c >= 0xf900 && c <= 0xfdcf) || 6270 (c >= 0xfdf0 && c <= 0xfffd) || 6271 (c >= 0x10000 && c <= 0xeffff)); 6272} 6273/** 6274 * Code point equivalent of regex `\p{White_Space}`. 6275 * From: https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt 6276 */ 6277function _isWhiteSpace(c) { 6278 return ((c >= 0x0009 && c <= 0x000d) || 6279 c === 0x0020 || 6280 c === 0x0085 || 6281 (c >= 0x200e && c <= 0x200f) || 6282 c === 0x2028 || 6283 c === 0x2029); 6284} 6285/** 6286 * Code point equivalent of regex `\p{Pattern_Syntax}`. 6287 * See https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt 6288 */ 6289function _isPatternSyntax(c) { 6290 return ((c >= 0x0021 && c <= 0x0023) || 6291 c === 0x0024 || 6292 (c >= 0x0025 && c <= 0x0027) || 6293 c === 0x0028 || 6294 c === 0x0029 || 6295 c === 0x002a || 6296 c === 0x002b || 6297 c === 0x002c || 6298 c === 0x002d || 6299 (c >= 0x002e && c <= 0x002f) || 6300 (c >= 0x003a && c <= 0x003b) || 6301 (c >= 0x003c && c <= 0x003e) || 6302 (c >= 0x003f && c <= 0x0040) || 6303 c === 0x005b || 6304 c === 0x005c || 6305 c === 0x005d || 6306 c === 0x005e || 6307 c === 0x0060 || 6308 c === 0x007b || 6309 c === 0x007c || 6310 c === 0x007d || 6311 c === 0x007e || 6312 c === 0x00a1 || 6313 (c >= 0x00a2 && c <= 0x00a5) || 6314 c === 0x00a6 || 6315 c === 0x00a7 || 6316 c === 0x00a9 || 6317 c === 0x00ab || 6318 c === 0x00ac || 6319 c === 0x00ae || 6320 c === 0x00b0 || 6321 c === 0x00b1 || 6322 c === 0x00b6 || 6323 c === 0x00bb || 6324 c === 0x00bf || 6325 c === 0x00d7 || 6326 c === 0x00f7 || 6327 (c >
vendor: 6,252 bytes, lines 6327-6540
6327= 0x2010 && c <= 0x2015) || 6328 (c >= 0x2016 && c <= 0x2017) || 6329 c === 0x2018 || 6330 c === 0x2019 || 6331 c === 0x201a || 6332 (c >= 0x201b && c <= 0x201c) || 6333 c === 0x201d || 6334 c === 0x201e || 6335 c === 0x201f || 6336 (c >= 0x2020 && c <= 0x2027) || 6337 (c >= 0x2030 && c <= 0x2038) || 6338 c === 0x2039 || 6339 c === 0x203a || 6340 (c >= 0x203b && c <= 0x203e) || 6341 (c >= 0x2041 && c <= 0x2043) || 6342 c === 0x2044 || 6343 c === 0x2045 || 6344 c === 0x2046 || 6345 (c >= 0x2047 && c <= 0x2051) || 6346 c === 0x2052 || 6347 c === 0x2053 || 6348 (c >= 0x2055 && c <= 0x205e) || 6349 (c >= 0x2190 && c <= 0x2194) || 6350 (c >= 0x2195 && c <= 0x2199) || 6351 (c >= 0x219a && c <= 0x219b) || 6352 (c >= 0x219c && c <= 0x219f) || 6353 c === 0x21a0 || 6354 (c >= 0x21a1 && c <= 0x21a2) || 6355 c === 0x21a3 || 6356 (c >= 0x21a4 && c <= 0x21a5) || 6357 c === 0x21a6 || 6358 (c >= 0x21a7 && c <= 0x21ad) || 6359 c === 0x21ae || 6360 (c >= 0x21af && c <= 0x21cd) || 6361 (c >= 0x21ce && c <= 0x21cf) || 6362 (c >= 0x21d0 && c <= 0x21d1) || 6363 c === 0x21d2 || 6364 c === 0x21d3 || 6365 c === 0x21d4 || 6366 (c >= 0x21d5 && c <= 0x21f3) || 6367 (c >= 0x21f4 && c <= 0x22ff) || 6368 (c >= 0x2300 && c <= 0x2307) || 6369 c === 0x2308 || 6370 c === 0x2309 || 6371 c === 0x230a || 6372 c === 0x230b || 6373 (c >= 0x230c && c <= 0x231f) || 6374 (c >= 0x2320 && c <= 0x2321) || 6375 (c >= 0x2322 && c <= 0x2328) || 6376 c === 0x2329 || 6377 c === 0x232a || 6378 (c >= 0x232b && c <= 0x237b) || 6379 c === 0x237c || 6380 (c >= 0x237d && c <= 0x239a) || 6381 (c >= 0x239b && c <= 0x23b3) || 6382 (c >= 0x23b4 && c <= 0x23db) || 6383 (c >= 0x23dc && c <= 0x23e1) || 6384 (c >= 0x23e2 && c <= 0x2426) || 6385 (c >= 0x2427 && c <= 0x243f) || 6386 (c >= 0x2440 && c <= 0x244a) || 6387 (c >= 0x244b && c <= 0x245f) || 6388 (c >= 0x2500 && c <= 0x25b6) || 6389 c === 0x25b7 || 6390 (c >= 0x25b8 && c <= 0x25c0) || 6391 c === 0x25c1 || 6392 (c >= 0x25c2 && c <= 0x25f7) || 6393 (c >= 0x25f8 && c <= 0x25ff) || 6394 (c >= 0x2600 && c <= 0x266e) || 6395 c === 0x266f || 6396 (c >= 0x2670 && c <= 0x2767) || 6397 c === 0x2768 || 6398 c === 0x2769 || 6399 c === 0x276a || 6400 c === 0x276b || 6401 c === 0x276c || 6402 c === 0x276d || 6403 c === 0x276e || 6404 c === 0x276f || 6405 c === 0x2770 || 6406 c === 0x2771 || 6407 c === 0x2772 || 6408 c === 0x2773 || 6409 c === 0x2774 || 6410 c === 0x2775 || 6411 (c >= 0x2794 && c <= 0x27bf) || 6412 (c >= 0x27c0 && c <= 0x27c4) || 6413 c === 0x27c5 || 6414 c === 0x27c6 || 6415 (c >= 0x27c7 && c <= 0x27e5) || 6416 c === 0x27e6 || 6417 c === 0x27e7 || 6418 c === 0x27e8 || 6419 c === 0x27e9 || 6420 c === 0x27ea || 6421 c === 0x27eb || 6422 c === 0x27ec || 6423 c === 0x27ed || 6424 c === 0x27ee || 6425 c === 0x27ef || 6426 (c >= 0x27f0 && c <= 0x27ff) || 6427 (c >= 0x2800 && c <= 0x28ff) || 6428 (c >= 0x2900 && c <= 0x2982) || 6429 c === 0x2983 || 6430 c === 0x2984 || 6431 c === 0x2985 || 6432 c === 0x2986 || 6433 c === 0x2987 || 6434 c === 0x2988 || 6435 c === 0x2989 || 6436 c === 0x298a || 6437 c === 0x298b || 6438 c === 0x298c || 6439 c === 0x298d || 6440 c === 0x298e || 6441 c === 0x298f || 6442 c === 0x2990 || 6443 c === 0x2991 || 6444 c === 0x2992 || 6445 c === 0x2993 || 6446 c === 0x2994 || 6447 c === 0x2995 || 6448 c === 0x2996 || 6449 c === 0x2997 || 6450 c === 0x2998 || 6451 (c >= 0x2999 && c <= 0x29d7) || 6452 c === 0x29d8 || 6453 c === 0x29d9 || 6454 c === 0x29da || 6455 c === 0x29db || 6456 (c >= 0x29dc && c <= 0x29fb) || 6457 c === 0x29fc || 6458 c === 0x29fd || 6459 (c >= 0x29fe && c <= 0x2aff) || 6460 (c >= 0x2b00 && c <= 0x2b2f) || 6461 (c >= 0x2b30 && c <= 0x2b44) || 6462 (c >= 0x2b45 && c <= 0x2b46) || 6463 (c >= 0x2b47 && c <= 0x2b4c) || 6464 (c >= 0x2b4d && c <= 0x2b73) || 6465 (c >= 0x2b74 && c <= 0x2b75) || 6466 (c >= 0x2b76 && c <= 0x2b95) || 6467 c === 0x2b96 || 6468 (c >= 0x2b97 && c <= 0x2bff) || 6469 (c >= 0x2e00 && c <= 0x2e01) || 6470 c === 0x2e02 || 6471 c === 0x2e03 || 6472 c === 0x2e04 || 6473 c === 0x2e05 || 6474 (c >= 0x2e06 && c <= 0x2e08) || 6475 c === 0x2e09 || 6476 c === 0x2e0a || 6477 c === 0x2e0b || 6478 c === 0x2e0c || 6479 c === 0x2e0d || 6480 (c >= 0x2e0e && c <= 0x2e16) || 6481 c === 0x2e17 || 6482 (c >= 0x2e18 && c <= 0x2e19) || 6483 c === 0x2e1a || 6484 c === 0x2e1b || 6485 c === 0x2e1c || 6486 c === 0x2e1d || 6487 (c >= 0x2e1e && c <= 0x2e1f) || 6488 c === 0x2e20 || 6489 c === 0x2e21 || 6490 c === 0x2e22 || 6491 c === 0x2e23 || 6492 c === 0x2e24 || 6493 c === 0x2e25 || 6494 c === 0x2e26 || 6495 c === 0x2e27 || 6496 c === 0x2e28 || 6497 c === 0x2e29 || 6498 (c >= 0x2e2a && c <= 0x2e2e) || 6499 c === 0x2e2f || 6500 (c >= 0x2e30 && c <= 0x2e39) || 6501 (c >= 0x2e3a && c <= 0x2e3b) || 6502 (c >= 0x2e3c && c <= 0x2e3f) || 6503 c === 0x2e40 || 6504 c === 0x2e41 || 6505 c === 0x2e42 || 6506 (c >= 0x2e43 && c <= 0x2e4f) || 6507 (c >= 0x2e50 && c <= 0x2e51) || 6508 c === 0x2e52 || 6509 (c >= 0x2e53 && c <= 0x2e7f) || 6510 (c >= 0x3001 && c <= 0x3003) || 6511 c === 0x3008 || 6512 c === 0x3009 || 6513 c === 0x300a || 6514 c === 0x300b || 6515 c === 0x300c || 6516 c === 0x300d || 6517 c === 0x300e || 6518 c === 0x300f || 6519 c === 0x3010 || 6520 c === 0x3011 || 6521 (c >= 0x3012 && c <= 0x3013) || 6522 c === 0x3014 || 6523 c === 0x3015 || 6524 c === 0x3016 || 6525 c === 0x3017 || 6526 c === 0x3018 || 6527 c === 0x3019 || 6528 c === 0x301a || 6529 c === 0x301b || 6530 c === 0x301c || 6531 c === 0x301d || 6532 (c >= 0x301e && c <= 0x301f) || 6533 c === 0x3020 || 6534 c === 0x3030 || 6535 c === 0xfd3e || 6536 c === 0xfd3f || 6537 (c >= 0xfe45 && c <= 0xfe46)); 6538} 6539 6540function pruneLocation(els) {
vendor: 4,134 bytes, lines 6541-6647
6541 els.forEach(function (el) { 6542 delete el.location; 6543 if (isSelectElement(el) || isPluralElement(el)) { 6544 for (var k in el.options) { 6545 delete el.options[k].location; 6546 pruneLocation(el.options[k].value); 6547 } 6548 } 6549 else if (isNumberElement(el) && isNumberSkeleton(el.style)) { 6550 delete el.style.location; 6551 } 6552 else if ((isDateElement(el) || isTimeElement(el)) && 6553 isDateTimeSkeleton(el.style)) { 6554 delete el.style.location; 6555 } 6556 else if (isTagElement(el)) { 6557 pruneLocation(el.children); 6558 } 6559 }); 6560} 6561function parse(message, opts) { 6562 if (opts === void 0) { opts = {}; } 6563 opts = __assign({ shouldParseSkeletons: true, requiresOtherClause: true }, opts); 6564 var result = new Parser(message, opts).parse(); 6565 if (result.err) { 6566 var error = SyntaxError(ErrorKind[result.err.kind]); 6567 // @ts-expect-error Assign to error object 6568 error.location = result.err.location; 6569 // @ts-expect-error Assign to error object 6570 error.originalMessage = result.err.message; 6571 throw error; 6572 } 6573 if (!(opts === null || opts === void 0 ? void 0 : opts.captureLocation)) { 6574 pruneLocation(result.val); 6575 } 6576 return result.val; 6577} 6578 6579var ErrorCode; 6580(function (ErrorCode) { 6581 // When we have a placeholder but no value to format 6582 ErrorCode["MISSING_VALUE"] = "MISSING_VALUE"; 6583 // When value supplied is invalid 6584 ErrorCode["INVALID_VALUE"] = "INVALID_VALUE"; 6585 // When we need specific Intl API but it's not available 6586 ErrorCode["MISSING_INTL_API"] = "MISSING_INTL_API"; 6587})(ErrorCode || (ErrorCode = {})); 6588var FormatError = /** @class */ (function (_super) { 6589 __extends(FormatError, _super); 6590 function FormatError(msg, code, originalMessage) { 6591 var _this = _super.call(this, msg) || this; 6592 _this.code = code; 6593 _this.originalMessage = originalMessage; 6594 return _this; 6595 } 6596 FormatError.prototype.toString = function () { 6597 return "[formatjs Error: ".concat(this.code, "] ").concat(this.message); 6598 }; 6599 return FormatError; 6600}(Error)); 6601var InvalidValueError = /** @class */ (function (_super) { 6602 __extends(InvalidValueError, _super); 6603 function InvalidValueError(variableId, value, options, originalMessage) { 6604 return _super.call(this, "Invalid values for \"".concat(variableId, "\": \"").concat(value, "\". Options are \"").concat(Object.keys(options).join('", "'), "\""), ErrorCode.INVALID_VALUE, originalMessage) || this; 6605 } 6606 return InvalidValueError; 6607}(FormatError)); 6608var InvalidValueTypeError = /** @class */ (function (_super) { 6609 __extends(InvalidValueTypeError, _super); 6610 function InvalidValueTypeError(value, type, originalMessage) { 6611 return _super.call(this, "Value for \"".concat(value, "\" must be of type ").concat(type), ErrorCode.INVALID_VALUE, originalMessage) || this; 6612 } 6613 return InvalidValueTypeError; 6614}(FormatError)); 6615var MissingValueError = /** @class */ (function (_super) { 6616 __extends(MissingValueError, _super); 6617 function MissingValueError(variableId, originalMessage) { 6618 return _super.call(this, "The intl string context variable \"".concat(variableId, "\" was not provided to the string \"").concat(originalMessage, "\""), ErrorCode.MISSING_VALUE, originalMessage) || this; 6619 } 6620 return MissingValueError; 6621}(FormatError)); 6622 6623var PART_TYPE; 6624(function (PART_TYPE) { 6625 PART_TYPE[PART_TYPE["literal"] = 0] = "literal"; 6626 PART_TYPE[PART_TYPE["object"] = 1] = "object"; 6627})(PART_TYPE || (PART_TYPE = {})); 6628function mergeLiteral(parts) { 6629 if (parts.length < 2) { 6630 return parts; 6631 } 6632 return parts.reduce(function (all, part) { 6633 var lastPart = all[all.length - 1]; 6634 if (!lastPart || 6635 lastPart.type !== PART_TYPE.literal || 6636 part.type !== PART_TYPE.literal) { 6637 all.push(part); 6638 } 6639 else { 6640 lastPart.value += part.value; 6641 } 6642 return all; 6643 }, []); 6644} 6645function isFormatXMLElementFn(el) { 6646 return typeof el === 'function'; 6647}
vendor: 6,277 bytes, lines 6648-6809
6648// TODO(skeleton): add skeleton support 6649function formatToParts(els, locales, formatters, formats, values, currentPluralValue, 6650// For debugging 6651originalMessage) { 6652 // Hot path for straight simple msg translations 6653 if (els.length === 1 && isLiteralElement(els[0])) { 6654 return [ 6655 { 6656 type: PART_TYPE.literal, 6657 value: els[0].value, 6658 }, 6659 ]; 6660 } 6661 var result = []; 6662 for (var _i = 0, els_1 = els; _i < els_1.length; _i++) { 6663 var el = els_1[_i]; 6664 // Exit early for string parts. 6665 if (isLiteralElement(el)) { 6666 result.push({ 6667 type: PART_TYPE.literal, 6668 value: el.value, 6669 }); 6670 continue; 6671 } 6672 // TODO: should this part be literal type? 6673 // Replace `#` in plural rules with the actual numeric value. 6674 if (isPoundElement(el)) { 6675 if (typeof currentPluralValue === 'number') { 6676 result.push({ 6677 type: PART_TYPE.literal, 6678 value: formatters.getNumberFormat(locales).format(currentPluralValue), 6679 }); 6680 } 6681 continue; 6682 } 6683 var varName = el.value; 6684 // Enforce that all required values are provided by the caller. 6685 if (!(values && varName in values)) { 6686 throw new MissingValueError(varName, originalMessage); 6687 } 6688 var value = values[varName]; 6689 if (isArgumentElement(el)) { 6690 if (!value || typeof value === 'string' || typeof value === 'number') { 6691 value = 6692 typeof value === 'string' || typeof value === 'number' 6693 ? String(value) 6694 : ''; 6695 } 6696 result.push({ 6697 type: typeof value === 'string' ? PART_TYPE.literal : PART_TYPE.object, 6698 value: value, 6699 }); 6700 continue; 6701 } 6702 // Recursively format plural and select parts' option â which can be a 6703 // nested pattern structure. The choosing of the option to use is 6704 // abstracted-by and delegated-to the part helper object. 6705 if (isDateElement(el)) { 6706 var style = typeof el.style === 'string' 6707 ? formats.date[el.style] 6708 : isDateTimeSkeleton(el.style) 6709 ? el.style.parsedOptions 6710 : undefined; 6711 result.push({ 6712 type: PART_TYPE.literal, 6713 value: formatters 6714 .getDateTimeFormat(locales, style) 6715 .format(value), 6716 }); 6717 continue; 6718 } 6719 if (isTimeElement(el)) { 6720 var style = typeof el.style === 'string' 6721 ? formats.time[el.style] 6722 : isDateTimeSkeleton(el.style) 6723 ? el.style.parsedOptions 6724 : formats.time.medium; 6725 result.push({ 6726 type: PART_TYPE.literal, 6727 value: formatters 6728 .getDateTimeFormat(locales, style) 6729 .format(value), 6730 }); 6731 continue; 6732 } 6733 if (isNumberElement(el)) { 6734 var style = typeof el.style === 'string' 6735 ? formats.number[el.style] 6736 : isNumberSkeleton(el.style) 6737 ? el.style.parsedOptions 6738 : undefined; 6739 if (style && style.scale) { 6740 value = 6741 value * 6742 (style.scale || 1); 6743 } 6744 result.push({ 6745 type: PART_TYPE.literal, 6746 value: formatters 6747 .getNumberFormat(locales, style) 6748 .format(value), 6749 }); 6750 continue; 6751 } 6752 if (isTagElement(el)) { 6753 var children = el.children, value_1 = el.value; 6754 var formatFn = values[value_1]; 6755 if (!isFormatXMLElementFn(formatFn)) { 6756 throw new InvalidValueTypeError(value_1, 'function', originalMessage); 6757 } 6758 var parts = formatToParts(children, locales, formatters, formats, values, currentPluralValue); 6759 var chunks = formatFn(parts.map(function (p) { return p.value; })); 6760 if (!Array.isArray(chunks)) { 6761 chunks = [chunks]; 6762 } 6763 result.push.apply(result, chunks.map(function (c) { 6764 return { 6765 type: typeof c === 'string' ? PART_TYPE.literal : PART_TYPE.object, 6766 value: c, 6767 }; 6768 })); 6769 } 6770 if (isSelectElement(el)) { 6771 var opt = el.options[value] || el.options.other; 6772 if (!opt) { 6773 throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage); 6774 } 6775 result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values)); 6776 continue; 6777 } 6778 if (isPluralElement(el)) { 6779 var opt = el.options["=".concat(value)]; 6780 if (!opt) { 6781 if (!Intl.PluralRules) { 6782 throw new FormatError("Intl.PluralRules is not available in this environment.\nTry polyfilling it using \"@formatjs/intl-pluralrules\"\n", ErrorCode.MISSING_INTL_API, originalMessage); 6783 } 6784 var rule = formatters 6785 .getPluralRules(locales, { type: el.pluralType }) 6786 .select(value - (el.offset || 0)); 6787 opt = el.options[rule] || el.options.other; 6788 } 6789 if (!opt) { 6790 throw new InvalidValueError(el.value, value, Object.keys(el.options), originalMessage); 6791 } 6792 result.push.apply(result, formatToParts(opt.value, locales, formatters, formats, values, value - (el.offset || 0))); 6793 continue; 6794 } 6795 } 6796 return mergeLiteral(result); 6797} 6798 6799/* 6800Copyright (c) 2014, Yahoo! Inc. All rights reserved. 6801Copyrights licensed under the New BSD License. 6802See the accompanying LICENSE file for terms. 6803*/ 6804// -- MessageFormat -------------------------------------------------------- 6805function mergeConfig(c1, c2) { 6806 if (!c2) { 6807 return c1; 6808 } 6809 return __assign
6809(__assign(__assign({}, (c1 || {})), (c2 || {})), Object.keys(c1).reduce(function (all, k) { 6810 all[k] = __assign(__assign({}, c1[k]), (c2[k] || {})); 6811 return all; 6812 }, {})); 6813} 6814function mergeConfigs(defaultConfig, configs) { 6815 if (!configs) { 6816 return defaultConfig; 6817 } 6818 return Object.keys(defaultConfig).reduce(function (all, k) { 6819 all[k] = mergeConfig(defaultConfig[k], configs[k]); 6820 return all; 6821 }, __assign({}, defaultConfig)); 6822} 6823function createFastMemoizeCache(store) { 6824 return { 6825 create: function () { 6826 return { 6827 get: function (key) { 6828 return store[key]; 6829 }, 6830 set: function (key, value) { 6831 store[key] = value; 6832 }, 6833 }; 6834 }, 6835 }; 6836} 6837function createDefaultFormatters(cache) { 6838 if (cache === void 0) { cache = { 6839 number: {}, 6840 dateTime: {}, 6841 pluralRules: {}, 6842 }; } 6843 return { 6844 getNumberFormat: memoize(function () { 6845 var _a; 6846 var args = []; 6847 for (var _i = 0; _i < arguments.length; _i++) { 6848 args[_i] = arguments[_i]; 6849 } 6850 return new ((_a = Intl.NumberFormat).bind.apply(_a, __spreadArray([void 0], args, false)))(); 6851 }, { 6852 cache: createFastMemoizeCache(cache.number), 6853 strategy: strategies.variadic, 6854 }), 6855 getDateTimeFormat: memoize(function () { 6856 var _a; 6857 var args = []; 6858 for (var _i = 0; _i < arguments.length; _i++) { 6859 args[_i] = arguments[_i]; 6860 } 6861 return new ((_a = Intl.DateTimeFormat).bind.apply(_a, __spreadArray([void 0], args, false)))(); 6862 }, { 6863 cache: createFastMemoizeCache(cache.dateTime), 6864 strategy: strategies.variadic, 6865 }), 6866 getPluralRules: memoize(function () { 6867 var _a; 6868 var args = []; 6869 for (var _i = 0; _i < arguments.length; _i++) { 6870 args[_i] = arguments[_i]; 6871 } 6872 return new ((_a = Intl.PluralRules).bind.apply(_a, __spreadArray([void 0], args, false)))(); 6873 }, { 6874 cache: createFastMemoizeCache(cache.pluralRules), 6875 strategy: strategies.variadic, 6876 }), 6877 }; 6878} 6879var IntlMessageFormat = /** @class */ (function () { 6880 function IntlMessageFormat(message, locales, overrideFormats, opts) { 6881 if (locales === void 0) { locales = IntlMessageFormat.defaultLocale; } 6882 var _this = this; 6883 this.formatterCache = { 6884 number: {}, 6885 dateTime: {}, 6886 pluralRules: {}, 6887 }; 6888 this.format = function (values) { 6889 var parts = _this.formatToParts(values); 6890 // Hot path for straight simple msg translations 6891 if (parts.length === 1) { 6892 return parts[0].value; 6893 } 6894 var result = parts.reduce(function (all, part) { 6895 if (!all.length || 6896 part.type !== PART_TYPE.literal || 6897 typeof all[all.length - 1] !== 'string') { 6898 all.push(part.value); 6899 } 6900 else { 6901 all[all.length - 1] += part.value; 6902 } 6903 return all; 6904 }, []); 6905 if (result.length <= 1) { 6906 return result[0] || ''; 6907 } 6908 return result; 6909 }; 6910 this.formatToParts = function (values) { 6911 return formatToParts(_this.ast, _this.locales, _this.formatters, _this.formats, values, undefined, _this.message); 6912 }; 6913 this.resolvedOptions = function () { 6914 var _a; 6915 return ({ 6916 locale: ((_a = _this.resolvedLocale) === null || _a === void 0 ? void 0 : _a.toString()) || 6917 Intl.NumberFormat.supportedLocalesOf(_this.locales)[0], 6918 }); 6919 }; 6920 this.getAst = function () { return _this.ast; }; 6921 // Defined first because it's used to build the format pattern. 6922 this.locales = locales; 6923 this.resolvedLocale = IntlMessageFormat.resolveLocale(locales); 6924 if (typeof message === 'string') { 6925 this.message = message; 6926 if (!IntlMessageFormat.__parse) { 6927 throw new TypeError('IntlMessageFormat.__parse must be set to process `message` of type `string`'); 6928 } 6929 var _a = opts || {}; _a.formatters; var parseOpts = __rest(_a, ["formatters"]); 6930 // Parse string messages into an AST. 6931 this.ast = IntlMessageFormat.__parse(message, __assign(__assign({}, parseOpts), { locale: this.resolvedLocale })); 6932 } 6933 else { 6934 this.ast = message; 6935 } 6936 if (!Array.isArray(this.ast)) { 6937 throw new TypeError('A message must be provided as a String or AST.'); 6938 } 6939 // Creates a new object with the specified `formats` merged with the default 6940 // formats. 6941 this.formats = mergeConfigs(IntlMessageFormat.formats, overrideFormats); 6942 this.formatters = 6943 (opts && opts.formatters) || createDefaultFormatters(this.formatterCache); 6944 } 6945 Object.defineProperty(IntlMessageFormat, "defaultLocale", { 6946 get: function () { 6947 if (!IntlMessageFormat.memoizedDefaultLocale) { 6948 IntlMessageFormat.memoizedDefaultLocale = 6949 new Intl.NumberFormat().resolvedOptions().locale; 6950 } 6951 return IntlMessageFormat.memoizedDefaultLocale; 6952 }, 6953 enumerable: false, 6954 configurable: true 6955 }); 6956 IntlMessageFormat.memoizedDefaultLocale = null; 6957 IntlMessageFormat.resolveLocale = function (locales) { 6958 if (typeof Intl.Locale === 'undefined') { 6959 return; 6960 } 6961 var supportedLocales = Intl.NumberFormat.supportedLocalesOf(locales); 6962 if (supportedLocales.length > 0) { 6963 return new Intl.Locale(supportedLocales[0]); 6964 } 6965 return new Intl.Locale(typeof locales === 'string' ? locales : locales[0]); 6966 }; 6967 IntlMessageFormat.__parse = parse; 6968 // Default format options used as the prototype of the `formats` provided to the 6969 // constructor. These are used when constructing the internal Intl.NumberFormat 6970 // and Intl.DateTimeFormat instances. 6971 IntlMessageFormat.formats = { 6972 number: { 6973 integer: { 6974 maximumFractionDigits: 0, 6975 }, 6976 currency: { 6977 style: 'currency', 6978 }, 6979 percent: { 6980 style: 'percent', 6981 }, 6982 }, 6983 date: { 6984 short: { 6985 month: 'numeric', 6986 day: 'numeric', 6987 year: '2-digit', 6988 }, 6989 medium: { 6990 month: 'short', 6991 day: 'numeric', 6992 year: 'numeric', 6993 }, 6994 long: { 6995 month: 'long', 6996 day: 'numeric', 6997 year: 'numeric', 6998 }, 6999 full: { 7000 weekday: 'long', 7001 month: 'long', 7002 day: 'numeric', 7003 year: 'numeric', 7004 }, 7005 }, 7006 time: { 7007 short: { 7008 hour: 'numeric', 7009 minute: 'numeric', 7010 }, 7011 medium: { 7012 hour: 'numeric', 7013 minute: 'numeric', 7014 second: 'numeric', 7015 }, 7016 long: { 7017 hour: 'numeric', 7018 minute: 'numeric', 7019 second: 'numeric', 7020 timeZoneName: 'short', 7021 }, 7022 full: { 7023 hour: 'numeric', 7024 minute: 'numeric', 7025 second: 'numeric', 7026 timeZoneName: 'short', 7027 }, 7028 }, 7029 }; 7030 return IntlMessageFormat; 7031}()); 7032 7033function delve(obj, fullKey) { 7034 if (fullKey == null) 7035 return void 0; 7036 if (fullKey in obj) { 7037 return obj[fullKey]; 7038 } 7039 const keys = fullKey.split("."); 7040 let result = obj; 7041 for (let p = 0; p < keys.length; p++) { 7042 if (typeof result === "object") { 7043 if (p > 0) { 7044 const partialKey = keys.slice(p, keys.length).join("."); 7045 if (partialKey in result) { 7046 result = result[partialKey]; 7047 break; 7048 } 7049 } 7050 result = result[keys[p]]; 7051 } else { 7052 result = void 0; 7053 } 7054 } 7055 return result; 7056} 7057 7058const lookupCache = {}; 7059const addToCache = (path, locale, message) => { 7060 if (!message) 7061 return message; 7062 if (!(locale in lookupCache)) 7063 lookupCache[locale] = {}; 7064 if (!(path in lookupCache[locale])) 7065 lookupCache[locale][path] = message; 7066 return message; 7067}; 7068const lookup = (path, refLocale) => { 7069 if (refLocale == null) 7070 return void 0; 7071 if (refLocale in lookupCache && path in lookupCache[refLocale]) { 7072 return lookupCache[refLocale][path]; 7073 } 7074 const locales = getPossibleLocales(refLocale); 7075 for (let i = 0; i < locales.length; i++) { 7076 const locale = locales[i]; 7077 const message = getMessageFromDictionary(locale, path); 7078 if (message) { 7079 return addToCache(path, refLocale, message); 7080 } 7081 } 7082 return void 0; 7083}; 7084 7085let dictionary; 7086const $dictionary = writable({}); 7087function getLocaleDictionary(locale) { 7088 return dictionary[locale] || null; 7089} 7090function hasLocaleDictionary(locale) { 7091 return locale in dictionary; 7092}
7093function getMessageFromDictionary(locale, id) { 7094 if (!hasLocaleDictionary(locale)) { 7095 return null; 7096 } 7097 const localeDictionary = getLocaleDictionary(locale); 7098 const match = delve(localeDictionary, id); 7099 return match; 7100} 7101function getClosestAvailableLocale(refLocale) { 7102 if (refLocale == null) 7103 return void 0; 7104 const relatedLocales = getPossibleLocales(refLocale); 7105 for (let i = 0; i < relatedLocales.length; i++) { 7106 const locale = relatedLocales[i]; 7107 if (hasLocaleDictionary(locale)) { 7108 return locale; 7109 } 7110 } 7111 return void 0; 7112} 7113function addMessages(locale, ...partials) { 7114 delete lookupCache[locale]; 7115 $dictionary.update((d) => { 7116 d[locale] = deepmerge.all([d[locale] || {}, ...partials]); 7117 return d; 7118 }); 7119} 7120derived( 7121 [$dictionary], 7122 ([dictionary2]) => Object.keys(dictionary2) 7123); 7124$dictionary.subscribe((newDictionary) => dictionary = newDictionary); 7125 7126const queue = {}; 7127function createLocaleQueue(locale) { 7128 queue[locale] = /* @__PURE__ */ new Set(); 7129} 7130function removeLoaderFromQueue(locale, loader) { 7131 queue[locale].delete(loader); 7132 if (queue[locale].size === 0) { 7133 delete queue[locale]; 7134 } 7135} 7136function getLocaleQueue(locale) { 7137 return queue[locale]; 7138} 7139function getLocalesQueues(locale) { 7140 return getPossibleLocales(locale).map((localeItem) => { 7141 const localeQueue = getLocaleQueue(localeItem); 7142 return [localeItem, localeQueue ? [...localeQueue] : []]; 7143 }).filter(([, localeQueue]) => localeQueue.length > 0); 7144} 7145function hasLocaleQueue(locale) { 7146 if (locale == null) 7147 return false; 7148 return getPossibleLocales(locale).some( 7149 (localeQueue) => { 7150 var _a; 7151 return (_a = getLocaleQueue(localeQueue)) == null ? void 0 : _a.size; 7152 } 7153 ); 7154} 7155function loadLocaleQueue(locale, localeQueue) { 7156 const allLoadersPromise = Promise.all( 7157 localeQueue.map((loader) => { 7158 removeLoaderFromQueue(locale, loader); 7159 return loader().then((partial) => partial.default || partial); 7160 }) 7161 ); 7162 return allLoadersPromise.then((partials) => addMessages(locale, ...partials)); 7163} 7164const activeFlushes = {}; 7165function flush(locale) { 7166 if (!hasLocaleQueue(locale)) { 7167 if (locale in activeFlushes) { 7168 return activeFlushes[locale]; 7169 } 7170 return Promise.resolve(); 7171 } 7172 const queues = getLocalesQueues(locale); 7173 activeFlushes[locale] = Promise.all( 7174 queues.map( 7175 ([localeName, localeQueue]) => loadLocaleQueue(localeName, localeQueue) 7176 ) 7177 ).then(() => { 7178 if (hasLocaleQueue(locale)) { 7179 return flush(locale); 7180 } 7181 delete activeFlushes[locale]; 7182 }); 7183 return activeFlushes[locale]; 7184} 7185function registerLocaleLoader(locale, loader) { 7186 if (!getLocaleQueue(locale)) 7187 createLocaleQueue(locale); 7188 const localeQueue = getLocaleQueue(locale); 7189 if (getLocaleQueue(locale).has(loader)) 7190 return; 7191 if (!hasLocaleDictionary(locale)) { 7192 $dictionary.update((d) => { 7193 d[locale] = {}; 7194 return d; 7195 }); 7196 } 7197 localeQueue.add(loader); 7198} 7199 7200var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols; 7201var __hasOwnProp$2 = Object.prototype.hasOwnProperty; 7202var __propIsEnum$2 = Object.prototype.propertyIsEnumerable; 7203var __objRest$1 = (source, exclude) => { 7204 var target = {}; 7205 for (var prop in source) 7206 if (__hasOwnProp$2.call(source, prop) && exclude.indexOf(prop) < 0) 7207 target[prop] = source[prop]; 7208 if (source != null && __getOwnPropSymbols$2) 7209 for (var prop of __getOwnPropSymbols$2(source)) { 7210 if (exclude.indexOf(prop) < 0 && __propIsEnum$2.call(source, prop)) 7211 target[prop] = source[prop]; 7212 } 7213 return target; 7214}; 7215const defaultFormats = { 7216 number: { 7217 scientific: { notation: "scientific" }, 7218 engineering: { notation: "engineering" }, 7219 compactLong: { notation: "compact", compactDisplay: "long" }, 7220 compactShort: { notation: "compact", compactDisplay: "short" } 7221 }, 7222 date: { 7223 short: { month: "numeric", day: "numeric", year: "2-digit" },
7224 medium: { month: "short", day: "numeric", year: "numeric" }, 7225 long: { month: "long", day: "numeric", year: "numeric" }, 7226 full: { weekday: "long", month: "long", day: "numeric", year: "numeric" } 7227 }, 7228 time: { 7229 short: { hour: "numeric", minute: "numeric" }, 7230 medium: { hour: "numeric", minute: "numeric", second: "numeric" }, 7231 long: { 7232 hour: "numeric", 7233 minute: "numeric", 7234 second: "numeric", 7235 timeZoneName: "short" 7236 }, 7237 full: { 7238 hour: "numeric", 7239 minute: "numeric", 7240 second: "numeric", 7241 timeZoneName: "short" 7242 } 7243 } 7244}; 7245function defaultMissingKeyHandler({ locale, id }) { 7246 console.warn( 7247 `[svelte-i18n] The message "${id}" was not found in "${getPossibleLocales( 7248 locale 7249 ).join('", "')}".${hasLocaleQueue(getCurrentLocale()) ? ` 7250 7251Note: there are at least one loader still registered to this locale that wasn't executed.` : ""}` 7252 ); 7253} 7254const defaultOptions = { 7255 fallbackLocale: null, 7256 loadingDelay: 200, 7257 formats: defaultFormats, 7258 warnOnMissingMessages: true, 7259 handleMissingMessage: void 0, 7260 ignoreTag: true 7261}; 7262const options = defaultOptions; 7263function getOptions() { 7264 return options; 7265} 7266function init(opts) { 7267 const _a = opts, { formats } = _a, rest = __objRest$1(_a, ["formats"]); 7268 let initialLocale = opts.fallbackLocale; 7269 if (opts.initialLocale) { 7270 try { 7271 if (IntlMessageFormat.resolveLocale(opts.initialLocale)) { 7272 initialLocale = opts.initialLocale; 7273 } 7274 } catch (e) { 7275 console.warn( 7276 `[svelte-i18n] The initial locale "${opts.initialLocale}" is not a valid locale.` 7277 ); 7278 } 7279 } 7280 if (rest.warnOnMissingMessages) { 7281 delete rest.warnOnMissingMessages; 7282 if (rest.handleMissingMessage == null) { 7283 rest.handleMissingMessage = defaultMissingKeyHandler; 7284 } else { 7285 console.warn( 7286 '[svelte-i18n] The "warnOnMissingMessages" option is deprecated. Please use the "handleMissingMessage" option instead.' 7287 ); 7288 } 7289 } 7290 Object.assign(options, rest, { initialLocale }); 7291 if (formats) { 7292 if ("number" in formats) { 7293 Object.assign(options.formats.number, formats.number); 7294 } 7295 if ("date" in formats) { 7296 Object.assign(options.formats.date, formats.date); 7297 } 7298 if ("time" in formats) { 7299 Object.assign(options.formats.time, formats.time); 7300 } 7301 } 7302 return $locale.set(initialLocale); 7303} 7304 7305const $isLoading = writable(false); 7306 7307var __defProp$1 = Object.defineProperty; 7308var __defProps = Object.defineProperties; 7309var __getOwnPropDescs = Object.getOwnPropertyDescriptors; 7310var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols; 7311var __hasOwnProp$1 = Object.prototype.hasOwnProperty; 7312var __propIsEnum$1 = Object.prototype.propertyIsEnumerable; 7313var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 7314var __spreadValues$1 = (a, b) => { 7315 for (var prop in b || (b = {})) 7316 if (__hasOwnProp$1.call(b, prop)) 7317 __defNormalProp$1(a, prop, b[prop]); 7318 if (__getOwnPropSymbols$1) 7319 for (var prop of __getOwnPropSymbols$1(b)) { 7320 if (__propIsEnum$1.call(b, prop)) 7321 __defNormalProp$1(a, prop, b[prop]); 7322 } 7323 return a; 7324}; 7325var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b)); 7326let current; 7327const internalLocale = writable(null); 7328function getSubLocales(refLocale) { 7329 return refLocale.split("-").map((_, i, arr) => arr.slice(0, i + 1).join("-")).reverse(); 7330} 7331function getPossibleLocales(refLocale, fallbackLocale = getOptions().fallbackLocale) { 7332 const locales = getSubLocales(refLocale); 7333 if (fallbackLocale) { 7334 return [.../* @__PURE__ */ new Set([...locales, ...getSubLocales(fallbackLocale)])]; 7335 } 7336 return locales; 7337} 7338function getCurrentLocale() { 7339 return current != null ? current : void 0; 7340} 7341internalLocale.subscribe((newLocale) => { 7342 current = newLocale != null ? newLocale : void 0; 7343 if (typeof window !== "undefined" && newLocale != null) { 7344 document.documentElement.setAttribute("lang", newLocale); 7345 } 7346}); 7347const set = (newLocale) => { 7348 if (newLocale && getClosestAvailableLocale(newLocale) && hasLocaleQueue(newLocale)) { 7349 const { loadingDelay } = getOptions(); 7350 let loadingTimer; 7351 if (typeof window !== "undefined" && getCurrentLocale() != null && loadingDelay) { 7352 loadingTimer = window.setTimeout( 7353 () => $isLoading.set(true), 7354 loadingDelay 7355 ); 7356 } else { 7357 $isLoading.set(true); 7358 } 7359 return flush(newLocale).then(() => { 7360 internalLocale.set(newLocale); 7361 }).finally(() => { 7362 clearTimeout(loadingTimer); 7363 $isLoading.set(false); 7364 }); 7365 } 7366 return internalLocale.set(newLocale); 7367}; 7368const $locale = __spreadProps(__spreadValues$1({}, internalLocale), { 7369 set 7370}); 7371const getLocaleFromNavigator = () => { 7372 if (typeof window === "undefined") 7373 return null; 7374 return window.navigator.language || window.navigator.languages[0]; 7375}; 7376 7377const monadicMemoize = (fn) => { 7378 const cache = /* @__PURE__ */ Object.create(null); 7379 const memoizedFn = (arg) => { 7380 const cacheKey = JSON.stringify(arg); 7381 if (cacheKey in cache) { 7382 return cache[cacheKey]; 7383 } 7384 return cache[cacheKey] = fn(arg); 7385 }; 7386 return memoizedFn; 7387}; 7388 7389var __defProp = Object.defineProperty; 7390var __getOwnPropSymbols = Object.getOwnPropertySymbols; 7391var __hasOwnProp = Object.prototype.hasOwnProperty; 7392var __propIsEnum = Object.prototype.propertyIsEnumerable; 7393var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; 7394var __spreadValues = (a, b) => { 7395 for (var prop in b || (b = {})) 7396 if (__hasOwnProp.call(b, prop)) 7397 __defNormalProp(a, prop, b[prop]); 7398 if (__getOwnPropSymbols) 7399 for (var prop of __getOwnPropSymbols(b)) { 7400 if (__propIsEnum.call(b, prop)) 7401 __defNormalProp(a, prop, b[prop]); 7402 } 7403 return a; 7404}; 7405var __objRest = (source, exclude) => { 7406 var target = {}; 7407 for (var prop in source) 7408 if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0) 7409 target[prop] = source[prop]; 7410 if (source != null && __getOwnPropSymbols) 7411 for (var prop of __getOwnPropSymbols(source)) { 7412 if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop)) 7413 target[prop] = source[prop]; 7414 } 7415 return target; 7416}; 7417const getIntlFormatterOptions = (type, name) => { 7418 const { formats } = getOptions(); 7419 if (type in formats && name in formats[type]) { 7420 return formats[type][name]; 7421 } 7422 throw new Error(`[svelte-i18n] Unknown "${name}" ${type} format.`); 7423}; 7424const createNumberFormatter = monadicMemoize( 7425 (_a) => { 7426 var _b = _a, { locale, format } = _b, options = __objRest(_b, ["locale", "format"]); 7427 if (locale == null) { 7428 throw new Error('[svelte-i18n] A "locale" must be set to format numbers'); 7429 } 7430 if (format) { 7431 options = getIntlFormatterOptions("number", format); 7432 } 7433 return new Intl.NumberFormat(locale, options); 7434 } 7435); 7436const createDateFormatter = monadicMemoize( 7437 (_c) => { 7438 var _d = _c, { locale, format } = _d, options = __objRest(_d, ["locale", "format"]); 7439 if (locale == null) { 7440 throw new Error('[svelte-i18n] A "locale" must be set to format dates'); 7441 } 7442 if (format) { 7443 options = getIntlFormatterOptions("date", format); 7444 } else if (Object.keys(options).length === 0) { 7445 options = getIntlFormatterOptions("date", "short"); 7446 } 7447 return new Intl.DateTimeFormat(locale, options); 7448 } 7449); 7450const createTimeFormatter = monadicMemoize( 7451 (_e) => { 7452 var _f = _e, { locale, format } = _f, options = __objRest(_f, ["locale", "format"]); 7453 if (locale == null) { 7454 throw new Error( 7455 '[svelte-i18n] A "locale" must be set to format time values' 7456 ); 7457 } 7458 if (format) { 7459 options = getIntlFormatterOptions("time", format); 7460 } else if (Object.keys(options).length === 0) { 7461 options = getIntlFormatterOptions("time", "short"); 7462 } 7463 return new Intl.DateTimeFormat(locale, options); 7464 } 7465); 7466const getNumberFormatter = (_g = {}) => { 7467 var _h = _g, { 7468 locale = getCurrentLocale() 7469 } = _h, args = __objRest(_h, [ 7470 "locale" 7471 ]); 7472 return createNumberFormatter(__spreadValues({ locale }, args)); 7473}; 7474const getDateFormatter = (_i = {}) => { 7475 var _j = _i, { 7476 locale = getCurrentLocale() 7477 } = _j, args = __objRest(_j, [ 7478 "locale" 7479 ]); 7480 return createDateFormatter(__spreadValues({ locale }, args)); 7481}; 7482const getTimeFormatter = (_k = {}) => { 7483 var _l = _k, { 7484 locale = getCurrentLocale() 7485 } = _l, args = __objRest(_l, [ 7486 "locale" 7487 ]); 7488 return createTimeFormatter(__spreadValues({ locale }, args)); 7489}; 7490const getMessageFormatter = monadicMemoize( 7491 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion 7492 (message, locale = getCurrentLocale()) => new IntlMessageFormat(message, locale, getOptions().formats, { 7493 ignoreTag: getOptions().ignoreTag 7494 }) 7495); 7496 7497const formatMessage = (id, options = {}) => { 7498 var _a, _b, _c, _d; 7499 let messageObj = options; 7500 if (typeof id === "object") { 7501 messageObj = id; 7502 id = messageObj.id; 7503 } 7504 const { 7505 values, 7506 locale = getCurrentLocale(), 7507 default: defaultValue 7508 } = messageObj; 7509 if (locale == null) { 7510 throw new Error( 7511 "[svelte-i18n] Cannot format a message without first setting the initial locale." 7512 ); 7513 } 7514 let message = lookup(id, locale); 7515 if (!message) { 7516 message = (_d = (_c = (_b = (_a = getOptions()).handleMissingMessage) == null ? void 0 : _b.call(_a, { locale, id, defaultValue })) != null ? _c : defaultValue) != null ? _d : id; 7517 } else if (typeof message !== "string") { 7518 console.warn(
7519 `[svelte-i18n] Message with id "${id}" must be of type "string", found: "${typeof message}". Gettin its value through the "$format" method is deprecated; use the "json" method instead.` 7520 ); 7521 return message; 7522 } 7523 if (!values) { 7524 return message; 7525 } 7526 let result = message; 7527 try { 7528 result = getMessageFormatter(message, locale).format(values); 7529 } catch (e) { 7530 if (e instanceof Error) { 7531 console.warn( 7532 `[svelte-i18n] Message "${id}" has syntax error:`, 7533 e.message 7534 ); 7535 } 7536 } 7537 return result; 7538}; 7539const formatTime = (t, options) => { 7540 return getTimeFormatter(options).format(t); 7541}; 7542const formatDate = (d, options) => { 7543 return getDateFormatter(options).format(d); 7544}; 7545const formatNumber = (n, options) => { 7546 return getNumberFormatter(options).format(n); 7547}; 7548const getJSON = (id, locale = getCurrentLocale()) => { 7549 return lookup(id, locale); 7550}; 7551const $format = derived([$locale, $dictionary], () => formatMessage); 7552derived([$locale], () => formatTime); 7553derived([$locale], () => formatDate); 7554derived([$locale], () => formatNumber); 7555derived([$locale, $dictionary], () => getJSON); 7556 7557const navbar_config = writable(null); 7558 7559var root_3 = from_html(`<a data-sveltekit-reload=""> </a>`); 7560var root_2 = from_html(`<div class="nav-holder svelte-99kmwu"><nav></nav></div>`); 7561var root_4 = from_html(`<div class="info svelte-99kmwu"><span class="svelte-99kmwu"><a class="title svelte-99kmwu"> </a></span> <span class="svelte-99kmwu"> <a class="gradio svelte-99kmwu" href="https://gradio.app">Gradio</a>.</span> <span class="svelte-99kmwu"> <a class="hf svelte-99kmwu" href="https://huggingface.co/spaces"><span class="space-logo svelte-99kmwu"><img alt="Hugging Face Space" class="svelte-99kmwu"/></span> Spaces</a></span></div>`); 7562var root_1 = from_html(`<div data-iframe-height=""><!> <div><!> <div><!></div></div></div>`); 7563 7564function Embed($$anchor, $$props) { 7565 push($$props, false); 7566 7567 const $navbar_config = () => store_get(navbar_config, '$navbar_config', $$stores); 7568 const $_ = () => store_get($format, '$_', $$stores); 7569 const [$$stores, $$cleanup] = setup_stores(); 7570 const show_navbar = mutable_source(); 7571 const effective_pages = mutable_source(); 7572 let wrapper = prop($$props, 'wrapper', 12); 7573 let version = prop($$props, 'version', 12); 7574 let initial_height = prop($$props, 'initial_height', 12); 7575 let fill_width = prop($$props, 'fill_width', 12); 7576 let is_embed = prop($$props, 'is_embed', 12); 7577 let space = prop($$props, 'space', 12); 7578 let display = prop($$props, 'display', 12); 7579 let info = prop($$props, 'info', 12); 7580 let loaded = prop($$props, 'loaded', 12); 7581 let pages = prop($$props, 'pages', 28, () => []); 7582 let current_page = prop($$props, 'current_page', 12, ""); 7583 let root = prop($$props, 'root', 12); 7584 let components = prop($$props, 'components', 28, () => []); 7585 let navbar_component = components().find((c) => c.type === "navbar"); 7586 7587 let navbar = mutable_source(navbar_component 7588 ? { 7589 visible: navbar_component.props.visible, 7590 main_page_name: navbar_component.props.main_page_name, 7591 value: navbar_component.props.value 7592 } 7593 : null); 7594 7595 if (get$1(navbar)) { 7596 navbar_config.set(get$1(navbar)); 7597 } 7598 7599 function normalize_path(path) { 7600 // Remove query parameters, hash fragments, and leading/trailing slashes from the path 7601 let normalized = path.split("?")[0].split("#")[0]; 7602 7603 normalized = normalized.replace(/^\/+|\/+$/g, ""); 7604 7605 return normalized; 7606 } 7607 7608 function is_active_route(route, current) { 7609 if (route.startsWith("http://") || route.startsWith("https://")) { 7610 return false; 7611 } 7612 7613 return normalize_path(route) === normalize_path(current); 7614 } 7615 7616 legacy_pre_effect(() => ($navbar_config()), () => { 7617 if ($navbar_config()) { 7618 set$1(navbar, { 7619 visible: $navbar_config().visible ?? true, 7620 main_page_name: $navbar_config().main_page_name ?? "Home", 7621 value: $navbar_config().value ?? null 7622 }); 7623 } 7624 }); 7625 7626 legacy_pre_effect(() => (deep_read_state(pages()), get$1(navbar)), () => { 7627 set$1(show_navbar, pages().length > 1 && (get$1(navbar) === null || get$1(navbar).visible !== false)); 7628 }); 7629 7630 legacy_pre_effect(() => (deep_read_state(pages()), get$1(navbar)), () => { 7631 set$1(effective_pages, (() => { 7632 let visible_pages = pages().filter(([route, label, show], index) => { 7633 if (index === 0 && route === "") { 7634 return get$1(navbar)?.main_page_name !== false; 7635 } 7636 7637 return show !== false; 7638 }); 7639 7640 let base_pages = get$1(navbar) && get$1(navbar).main_page_name !== false && get$1(navbar).main_page_name !== "Home" 7641 ? visible_pages.map(([route, label, show], index) => index === 0 && route === "" && label === "Home" 7642 ? [route, get$1(navbar).main_page_name] 7643 : [route, label]) 7644 : visible_pages.map(([route, label]) => [route, label]); 7645 7646 if (get$1(navbar)?.value && get$1(navbar).value.length > 0) { 7647 const existing_routes = new Set(base_pages.map(([route]) => route)); 7648 const additional_pages = get$1(navbar).value.map(([page_name, page_path]) => [page_path, page_name]).filter(([route]) => !existing_routes.has(route)); 7649 7650 return [...base_pages, ...additional_pages]; 7651 } 7652 7653 return base_pages; 7654 })()); 7655 }); 7656 7657 legacy_pre_effect_reset(); 7658 7659 var $$exports = { 7660 get wrapper() { 7661 return wrapper(); 7662 }, 7663 7664 set wrapper($$value) { 7665 wrapper($$value); 7666 flushSync(); 7667 }, 7668 7669 get version() { 7670 return version(); 7671 }, 7672 7673 set version($$value) { 7674 version($$value); 7675 flushSync(); 7676 }, 7677 7678 get initial_height() { 7679 return initial_height(); 7680 }, 7681 7682 set initial_height($$value) { 7683 initial_height($$value); 7684 flushSync(); 7685 }, 7686 7687 get fill_width() { 7688 return fill_width(); 7689 }, 7690 7691 set fill_width($$value) { 7692 fill_width($$value); 7693 flushSync(); 7694 }, 7695 7696 get is_embed() { 7697 return is_embed(); 7698 }, 7699 7700 set is_embed($$value) { 7701 is_embed($$value); 7702 flushSync(); 7703 }, 7704 7705 get space() { 7706 return space(); 7707 }, 7708 7709 set space($$value) { 7710 space($$value); 7711 flushSync(); 7712 }, 7713 7714 get display() {
7715 return display(); 7716 }, 7717 7718 set display($$value) { 7719 display($$value); 7720 flushSync(); 7721 }, 7722 7723 get info() { 7724 return info(); 7725 }, 7726 7727 set info($$value) { 7728 info($$value); 7729 flushSync(); 7730 }, 7731 7732 get loaded() { 7733 return loaded(); 7734 }, 7735 7736 set loaded($$value) { 7737 loaded($$value); 7738 flushSync(); 7739 }, 7740 7741 get pages() { 7742 return pages(); 7743 }, 7744 7745 set pages($$value) { 7746 pages($$value); 7747 flushSync(); 7748 }, 7749 7750 get current_page() { 7751 return current_page(); 7752 }, 7753 7754 set current_page($$value) { 7755 current_page($$value); 7756 flushSync(); 7757 }, 7758 7759 get root() { 7760 return root(); 7761 }, 7762 7763 set root($$value) { 7764 root($$value); 7765 flushSync(); 7766 }, 7767 7768 get components() { 7769 return components(); 7770 }, 7771 7772 set components($$value) { 7773 components($$value); 7774 flushSync(); 7775 } 7776 }; 7777 7778 init$1(); 7779 7780 var div = root_1(); 7781 let classes; 7782 let styles; 7783 var node = child(div); 7784 7785 { 7786 var consequent = ($$anchor) => { 7787 var div_1 = root_2(); 7788 var nav = child(div_1); 7789 let classes_1; 7790 7791 each(nav, 5, () => get$1(effective_pages), index, ($$anchor, $$item) => { 7792 var $$array = user_derived(() => to_array(get$1($$item), 2)); 7793 let route = () => get$1($$array)[0]; 7794 let label = () => get$1($$array)[1]; 7795 var a = root_3(); 7796 let classes_2; 7797 var text = child(a, true); 7798 7799 reset(a); 7800 7801 template_effect( 7802 ($0, $1, $2, $3) => { 7803 set_attribute(a, 'href', $0); 7804 set_attribute(a, 'target', $1); 7805 set_attribute(a, 'rel', $2); 7806 classes_2 = set_class(a, 1, 'svelte-99kmwu', null, classes_2, $3); 7807 set_text(text, label()); 7808 }, 7809 [ 7810 () => ( 7811 route(), 7812 deep_read_state(root()), 7813 untrack(() => route().startsWith("http://") || route().startsWith("https://") ? route() : `${root()}/${route()}`) 7814 ), 7815 7816 () => ( 7817 route(), 7818 untrack(() => route().startsWith("http://") || route().startsWith("https://") ? "_blank" : "_self") 7819 ), 7820 7821 () => ( 7822 route(), 7823 untrack(() => route().startsWith("http://") || route().startsWith("https://") ? "noopener noreferrer" : "") 7824 ), 7825 () => ({ active: is_active_route(route(), current_page()) }) 7826 ] 7827 ); 7828 7829 append($$anchor, a); 7830 }); 7831 7832 reset(nav); 7833 reset(div_1); 7834 template_effect(() => classes_1 = set_class(nav, 1, 'fillable svelte-99kmwu', null, classes_1, { fill_width: fill_width() })); 7835 append($$anchor, div_1); 7836 }; 7837 7838 if_block(node, ($$render) => { 7839 if (get$1(show_navbar)) $$render(consequent); 7840 }); 7841 } 7842 7843 var div_2 = sibling(node, 2); 7844 let classes_3; 7845 var node_1 = child(div_2); 7846 7847 slot(node_1, $$props, 'default', {}, null); 7848 7849 var div_3 = sibling(node_1, 2); 7850 var node_2 = child(div_3); 7851 7852 { 7853 var consequent_1 = ($$anchor) => { 7854 var div_4 = root_4(); 7855 var span = child(div_4); 7856 var a_1 = child(span); 7857 var text_1 = child(a_1, true); 7858 7859 reset(a_1); 7860 reset(span); 7861 7862 var span_1 = sibling(span, 2); 7863 var text_2 = child(span_1); 7864 7865 next(2); 7866 reset(span_1); 7867 7868 var span_2 = sibling(span_1, 2); 7869 var text_3 = child(span_2); 7870 var a_2 = sibling(text_3); 7871 var span_3 = child(a_2); 7872 var img = child(span_3); 7873 7874 reset(span_3); 7875 next(); 7876 reset(a_2); 7877 reset(span_2); 7878 reset(div_4); 7879 7880 template_effect( 7881 ($0, $1) => { 7882 set_attribute(a_1, 'href', `https://huggingface.co/spaces/${space() ?? ''}`); 7883 set_text(text_1, space()); 7884 set_text(text_2, `${$0 ?? ''} `); 7885 set_text(text_3, `${$1 ?? ''} `); 7886 set_attribute(img, 'src', space_logo); 7887 }, 7888 [ 7889 () => ($_(), untrack(() => $_()("common.built_with"))), 7890 () => ($_(), untrack(() => $_()("common.hosted_on"))) 7891 ] 7892 ); 7893 7894 append($$anchor, div_4); 7895 }; 7896 7897 if_block(node_2, ($$render) => { 7898 if (display() && space() && info()) $$render(consequent_1); 7899 }); 7900 } 7901 7902 reset(div_3); 7903 reset(div_2); 7904 reset(div); 7905 bind_this(div, ($$value) => wrapper($$value), () => wrapper()); 7906 7907 template_effect(() => { 7908 classes = set_class(div, 1, `gradio-container gradio-container-${version() ?? ''}`, 'svelte-99kmwu', classes, { 7909 fill_width: fill_width(), 7910 'embed-container': display(), 7911 'with-info': info() 7912 }); 7913 7914 styles = set_style(div, '', styles, { 7915 'min-height': loaded() ? "initial" : initial_height(), 7916 'flex-grow': !display() ? "1" : "auto" 7917 }); 7918 7919 classes_3 = set_class(div_2, 1, 'main fillable svelte-99kmwu', null, classes_3, { fill_width: fill_width(), app: !display() && !is_embed() }); 7920 }); 7921 7922 append($$anchor, div); 7923 7924 var $$pop = pop($$exports); 7925 7926 $$cleanup(); 7927 7928 return $$pop; 7929} 7930 7931let supports_adopted_stylesheets = false;
7932if (typeof window !== "undefined" && "attachShadow" in Element.prototype && "adoptedStyleSheets" in Document.prototype) { 7933 const shadow_root_test = document.createElement("div").attachShadow({ mode: "open" }); 7934 supports_adopted_stylesheets = "adoptedStyleSheets" in shadow_root_test; 7935} 7936function mount_css(url, target) { 7937 const base = new URL(import.meta.url).origin; 7938 var _url = url; 7939 if (window.location.origin !== base) { 7940 _url = new URL(url, base).href; 7941 } 7942 const existing_link = document.querySelector(`link[href='${_url}']`); 7943 if (existing_link) return Promise.resolve(); 7944 const link = document.createElement("link"); 7945 link.rel = "stylesheet"; 7946 link.href = _url; 7947 return new Promise((res, rej) => { 7948 link.addEventListener("load", () => res()); 7949 link.addEventListener("error", () => { 7950 console.error(`Unable to preload CSS for ${_url}`); 7951 res(); 7952 }); 7953 target.appendChild(link); 7954 }); 7955} 7956function prefix_css(string, version, style_element) { 7957 if (!supports_adopted_stylesheets) return string; 7958 if (!style_element) { 7959 style_element = document.createElement("style"); 7960 } 7961 style_element.remove(); 7962 const stylesheet = new CSSStyleSheet(); 7963 stylesheet.replaceSync(string); 7964 let importString = ""; 7965 string = string.replace(/@import\s+url\((.*?)\);\s*/g, (match, url) => { 7966 importString += `@import url(${url}); 7967`; 7968 return ""; 7969 }); 7970 const rules = stylesheet.cssRules; 7971 let css_string = ""; 7972 let gradio_css_infix = `.gradio-container.gradio-container-${version} .contain `; 7973 for (let i = 0; i < rules.length; i++) { 7974 const rule = rules[i]; 7975 let is_dark_rule = rule.cssText.includes(".dark"); 7976 if (rule instanceof CSSStyleRule) { 7977 const selector = rule.selectorText; 7978 if (selector) { 7979 const new_selector = selector.replace(".dark", "").split(",").map( 7980 (s) => `${is_dark_rule ? ".dark" : ""} ${gradio_css_infix} ${s.trim()} ` 7981 ).join(","); 7982 css_string += rule.cssText; 7983 css_string += rule.cssText.replace(selector, new_selector); 7984 } 7985 } else if (rule instanceof CSSMediaRule) { 7986 let mediaCssString = `@media ${rule.media.mediaText} {`; 7987 for (let j = 0; j < rule.cssRules.length; j++) { 7988 const innerRule = rule.cssRules[j]; 7989 if (innerRule instanceof CSSStyleRule) { 7990 let is_dark_rule2 = innerRule.cssText.includes(".dark "); 7991 const selector = innerRule.selectorText; 7992 const new_selector = selector.replace(".dark", "").split(",").map( 7993 (s) => `${is_dark_rule2 ? ".dark" : ""} ${gradio_css_infix} ${s.trim()} ` 7994 ).join(","); 7995 mediaCssString += innerRule.cssText.replace(selector, new_selector); 7996 } 7997 } 7998 mediaCssString += "}"; 7999 css_string += mediaCssString; 8000 } else if (rule instanceof CSSKeyframesRule) { 8001 css_string += `@keyframes ${rule.name} {`; 8002 for (let j = 0; j < rule.cssRules.length; j++) { 8003 const innerRule = rule.cssRules[j]; 8004 if (innerRule instanceof CSSKeyframeRule) { 8005 css_string += `${innerRule.keyText} { ${innerRule.style.cssText} }`; 8006 } 8007 } 8008 css_string += "}"; 8009 } else if (rule instanceof CSSFontFaceRule) { 8010 css_string += `@font-face { ${rule.style.cssText} }`; 8011 } 8012 } 8013 return importString + css_string; 8014} 8015 8016const component_map = { 8017 "accordion": { 8018 8019 8020 component: () => __vitePreload(() => import('./Index-cqVcxhkX.js'),true ?__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]):void 0,import.meta.url) 8021 }, 8022"annotatedimage": { 8023 8024 8025 component: () => __vitePreload(() => import('./Index-c5VDWsdo.js'),true ?__vite__mapDeps([19,1,2,3,4,5,6,7,8,9,20,21,22,10,23,24,25,11,12,13,14,15,26]):void 0,import.meta.url) 8026 }, 8027"audio": { 8028 base: () => __vitePreload(() => import('./StaticAudio-CWETG3mI.js').then(n => n.a),true ?__vite__mapDeps([27,1,2,10,4,5,6,7,8,9,20,28,21,29,30,31,23,32,33,34,35,36,37]):void 0,import.meta.url), 8029 8030 example: () => __vitePreload(() => import('./Example-D-PFeR7G.js'),true ?__vite__mapDeps([38,1,2,39]):void 0,import.meta.url), 8031 8032 component: () => __vitePreload(() => import('./index-hf62j3_c.js'),true ?__vite__mapDeps([40,1,2,10,11,12,13,4,5,6,7,8,9,14,15,27,20,28,21,29,30,31,23,32,33,34,35,36,37,41,42,43,44,45,46,47,48,3,49,38,39,50]):void 0,import.meta.url) 8033 }, 8034"box": { 8035 8036 8037 component: () => __vitePreload(() => import('./Index-BIfnw3Df.js'),true ?__vite__mapDeps([51,1,2,3,4,5,6,7,8,9]):void 0,import.meta.url) 8038 }, 8039"browserstate": { 8040 8041 8042 component: () => __vitePreload(() => import('./Index-CeOGJPri.js'),true ?__vite__mapDeps([52,1,2,53,10]):void 0,import.meta.url) 8043 }, 8044"button": { 8045 8046 8047 component: () => __vitePreload(() => import('./Index-Dk8LP6SU.js'),true ?__vite__mapDeps([54,1,2,10,55,5,56,57,58,4,6,7,8,9,59,60
8047]):void 0,import.meta.url) 8048 }, 8049"chatbot": { 8050 8051 8052 component: () => __vitePreload(() => import('./Index-D6KKbqPS.js'),true ?__vite__mapDeps([61,1,2,42,10,62,56,57,58,4,5,6,7,8,9,63,64,15,30,45,36,28,29,23,65,66,13,12,14,67,68,69,31,3,20,11,70,60]):void 0,import.meta.url) 8053 }, 8054"checkbox": { 8055 8056 example: () => __vitePreload(() => import('./Example-lKnDE0-B.js'),true ?__vite__mapDeps([71,1,2,72]):void 0,import.meta.url), 8057 8058 component: () => __vitePreload(() => import('./Index-BHGkz0L8.js'),true ?__vite__mapDeps([73,1,2,10,3,4,5,6,74,66,13,7,8,9,23,11,12,14,15,75,62,76]):void 0,import.meta.url) 8059 }, 8060"checkboxgroup": { 8061 8062 example: () => __vitePreload(() => import('./Example-MOIw3ihL.js'),true ?__vite__mapDeps([77,1,2,78]):void 0,import.meta.url), 8063 8064 component: () => __vitePreload(() => import('./Index-CnKzAZJw.js'),true ?__vite__mapDeps([79,1,2,10,3,4,5,6,80,74,66,13,7,8,9,23,11,12,14,15,81,82]):void 0,import.meta.url) 8065 }, 8066"code": { 8067 8068 example: () => __vitePreload(() => import('./Example-BYnu_U1h.js'),true ?__vite__mapDeps([83,1,2,84]):void 0,import.meta.url), 8069 8070 component: () => __vitePreload(() => import('./Index-DnoopRVS.js'),true ?__vite__mapDeps([85,1,2,10,11,12,13,4,5,6,7,8,9,14,15,86,87,63,64,30,28,23,3,20,21,88,83,84]):void 0,import.meta.url) 8071 }, 8072"colorpicker": { 8073 8074 example: () => __vitePreload(() => import('./Example-DmGLofMR.js'),true ?__vite__mapDeps([89,1,2,90]):void 0,import.meta.url), 8075 8076 component: () => __vitePreload(() => import('./Index-cXoSwrVM.js'),true ?__vite__mapDeps([91,1,2,10,42,62,92,4,5,6,80,74,66,13,7,8,9,3,11,12,14,15,89,90,93]):void 0,import.meta.url) 8077 }, 8078"column": { 8079 8080 8081 component: () => __vitePreload(() => import('./Index-BnPF6xy8.js'),true ?__vite__mapDeps([94,1,2,10,16,11,12,13,4,5,6,7,8,9,14,15,17]):void 0,import.meta.url) 8082 }, 8083"core": { 8084 8085 8086 component: () => __vitePreload(() => import('./index-CjLnGHRW.js'),true ?__vite__mapDeps([95,1,2,81,10]):void 0,import.meta.url) 8087 }, 8088"dataframe": { 8089 8090 example: () => __vitePreload(() => import('./Example-CSyNUPmz.js'),true ?__vite__mapDeps([96,1,2,97]):void 0,import.meta.url), 8091 8092 component: () => __vitePreload(() => import('./Index-BOG-LPoW.js').then(n => n.I),true ?__vite__mapDeps([98,1,2,10,81,99,100,57,68,41,5,42,43,4,6,7,8,9,13,62,67,66,12,14,75,76,101,63,102,64,24,25,96,97,103]):void 0,import.meta.url) 8093 }, 8094"dataset": { 8095 8096 8097 component: () => __vitePreload(() => import('./Index-_a-G1TDi.js'),true ?__vite__mapDeps([104,1,2,3,4,5,6,7,8,9,10,105,106,42,62,80,74,66,13,63,64,107,108,23,109,12,14,110,101,111,112]):void 0,import.meta.url) 8098 }, 8099"datetime": { 8100 8101 example: () => __vitePreload(() => import('./Example-kRad1aPe.js'),true ?__vite__mapDeps([113,1,2]):void 0,import.meta.url), 8102 8103 component: () => __vitePreload(() => import('./Index-D_siBrGR.js'),true ?__vite__mapDeps([114,1,2,62,3,4,5,6,80,74,66,13,7,8,9,10,23,113,115]):void 0,import.meta.url) 8104 }, 8105"dialogue": { 8106 8107 example: () => __vitePreload(() => import('./Example-CM1i7hYA.js'),true ?__vite__mapDeps([116,1,2,117]):void 0,import.meta.url), 8108 8109 component: () => __vitePreload(() => import('./Index-B_Gnb4iA.js'),true ?__vite__mapDeps([118,1,2,10,12,13,4,5,6,7,8,9,14,62,80,74,66,63,64,119,107,69,23,120,121,102,122,3,11,15,116,117,123,124]):void 0,import.meta.url) 8110 }, 8111"downloadbutton": { 8112 8113 8114 component: () => __vitePreload(() => import('./Index-B6aCVBT9.js'),true ?__vite__mapDeps([125,1,2,10,5,55,56,57,58,4,6,7,8,9,59,60,126]):void 0,import.meta.url) 8115 }, 8116"draggable": { 8117 8118 8119 component: () => __vitePreload(() => import('./Index-oRYO6L1a.js'),true ?__vite__mapDeps([127,1,2,10,11,12,13,4,5,6,7,8,9,14,15,128]):void 0,import.meta.url) 8120 }, 8121"dropdown": { 8122 8123 example: () => __vitePreload(() => import('./Example-DldcLCBj.js'),true ?__vite__mapDeps([129,1,2,124]):void 0,import.meta.url), 8124 8125 component: () => __vitePreload(() => import('./Index-lqZQIaLn.js'),true ?__vite__mapDeps([130,1,2,10,62,67,4,5,6,80,74,66,13,7,8,9,102,23,120,12,14,121,122,3,11,15,129,124]):void 0,import.meta.url) 8126 }, 8127"file": { 8128 8129 example: () => __vitePreload(() => import('./Example-USFi6Hps.js'),true ?__vite__mapDeps([131,1,2,132]):void 0,import.meta.url), 8130 8131 component: () => __vitePreload(() => import('./Index-Dk7G-RHg.js'),true ?__vite__mapDeps([133,1,2,10,4,5,6,7,8,9,20,21,65,23,134,41,42,43,15,13,28,135,3,49,11,12,14,131,132]):void 0,import.meta.url) 8132 }, 8133"fileexplorer": { 8134 8135 example: () => __vitePreload(() => import('./Example-DQSMQK5Q.js'),true ?__vite__mapDeps([136,1,2,137]):void 0,import.meta.url), 8136 8137 component: () => __vitePreload(() => import('./Index-BXduP1J1.js'),true ?__vite__mapDeps([138,1,2,105,10,4,5,6,65,3,7,8,9,20,23,62,11,12,13,14,15,139]):void 0,import.meta.url) 8138 }, 8139"form": { 8140 8141 8142 component: () => __vitePreload(() => import('./Index-Ckn3lSIv.js'),true ?__vite__mapDeps([140,1,2,10,141,142]):void 0,import.meta.url) 8143 }, 8144"gallery": { 8145 base: () => __vitePreload(() => import('./Gallery-D9uGL0FX.js').then(n => n.a),true ?__vite__mapDeps([143,1,2,121,67,4,5,6,7,8,9,20,21,29,10,15,30,22,35,23,24,25,41,42,43,44,28,45,36,56,57,58,144,145,81,146,60]):void 0,import.meta.url), 8146 8147 example: () => __vitePreload(() => import('./Example-BstfUWdZ.js'),true ?__vite__mapDeps([147,1,2,148]):void 0,import.meta.url), 8148 8149 component: () => __vitePreload(() => import('./Index-C8iEj0i6.js'),true ?__vite__mapDeps([149,1,2,57,3,4,5,6,7,8,9,10,49,143,121,67,20,21,29,15,30,22,35,23,24,25,41,42,43,44,28,45,36,56,58,144,145,81,146,60,11,12,13,14,134,65,135,150,100,102,108,48,46,151,147,148,152,132,153]):void 0,import.meta.url) 8150 }, 8151"group": { 8152 8153 8154 component: () => __vitePreload(() => import('./Index-CG0iU8MX.js'),true ?__vite__mapDeps([154,1,2,10,155]):void 0,import.meta.url) 8155 }, 8156"highlightedtext": { 8157 8158 8159 component: () => __vitePreload(() => import('./Index-mY6Ayb2J.js'),true ?__vite__mapDeps([156,1,2,157,15,4,5,6,3,7,8,9,20,21,10,23,11,12,13,14,158]):void 0,import.meta.url) 8160 }, 8161"html": { 8162 base: () => __vitePreload(() => import('./HTML-DlbkPABy.js'),true ?__vite__mapDeps([159,1,2,5,160]):void 0,import.meta.url), 8163 8164 example: () => __vitePreload(() => import('./Example-DU6ARnKW.js'),true ?__vite__mapDeps([161,1,2,13,162]):void 0,import.meta.url), 8165 8166 component: () => __vitePreload(() => import('./Index-8RVq3tR4.js'),true ?__vite__mapDeps([163,1,2,10,159,5,160,11,12,13,4,6,7,8,9,14,15,3,20,88,23,161,162,164]):void 0,import.meta.url) 8167 }, 8168"image": { 8169 base: () => __vitePreload(() => import('./ImagePreview-XayhIqNU.js').then(n => n.a),true ?__vite__mapDeps([165,1,2,57,10,4,5,6,7,8,9,20,28,21,29,30,22,23,24,25,56,58,60]):void 0,import.meta.url), 8170 8171 example: () => __vitePreload(() => import('./Example-4MLRTjBC.js'),true ?__vite__mapDeps([166,1,2,56,57,58,153]):void 0,import.meta.url), 8172 8173 component: () => __vitePreload(() => import('./Index-D2rmpk1k.js'),true ?__vite__mapDeps([167,1,2,10,165,57,4,5,6,7,8,9,20,28,21,29,30,22,23,24,25,56,58,60,15,150,12,13,14,42,100,102,108,48,46,151,41,43,3,49,11,166,153]):void 0,import.meta.url) 8174 }, 8175"imageeditor": { 8176 8177 example: () => __vitePreload(() => import('./Example-YlQBeDNh.js'),true ?__vite__mapDeps([168,1,2,4,5,6,7,8,9,56,57,58,12,13,14,41,42,43,169,60,151,153]):void 0,import.meta.url), 8178 8179 component: () => __vitePreload(() => import('./Index-CvN5jvte.js').then(n => n.au),true ?__vite__mapDeps([170,1,2,57,10,165,4,5,6,7,8,9,20,28,21,29,30,22,23,24,25,56,58,60,3,11,12,13,14,15,41,42,43,100,150,102,108,48,46,151,121,92,119,62,63,67,171,69,36,172,153]):void 0,import.meta.url) 8180 }, 8181"imageslider": { 8182 8183 example: () => __vitePreload(() => import('./Example-DA82qMyB.js'),true ?__vite__mapDeps([173,1,2,174]):void 0,import.meta.url), 8184 8185 component: () => __vitePreload(() => import('./Index-DC3IOpLR.js'),true ?__vite__mapDeps([175,1,2,10,101,57,176,177,4,5,6,7,8,9,20,28,21,15,30,22,36,23,24,25,12,13,14,11,41,42,43,3,49,178]):void 0,import.meta.url) 8186 }, 8187"json": { 8188 8189 example: () => __vitePreload(() => import('./Example-CXb8xdQD.js'),true ?__vite__mapDeps([179,1,2,180,63,64,4,5,6,7,8,9,21,23,181,182]):void 0,import.meta.url), 8190 8191 component: () => __vitePreload(() => import('./Index-DPsbjNiT.js'),true ?__vite__mapDeps([183,1,2,101,10,180,63,64,4,5,6,7,8,9,21,23,181,3,20,11,12,13,14,15]):void 0,import.meta.url) 8192 }, 8193"label": { 8194 8195 8196 component: () => __vitePreload(() => import('./Index-CBd_MhXJ.js'),true ?__vite__mapDeps([184,1,2,10,4,5,6,185,3,7,8,9,20,21,23,11,12,13,14,15,186]):void 0,import.meta.url) 8197 }, 8198"markdown": { 8199 8200 example: () => __vitePreload(() => import('./Example-DUe-V0Ld.js'),true ?__vite__mapDeps([187,1,2,66,13,7,8,9,188]):void 0,import.meta.url), 8201 8202 component: () => __vitePreload(() => import('./Index-DzadCq8f.js'),true ?__vite__mapDeps([189,1,2,10,190,42,63,64,4,5,6,66,13,7,8,9,23,191,11,12,14,15,3,192,187,188]):void 0,import.meta.url) 8203 }, 8204"model3d": { 8205 base: () => __vitePreload(() => import('./Model3D-DJQlKi0w.js'),true ?__vite__mapDeps([193,1,2,4,5,6,7,8,9,20,30,65,36,23,81,194]):void 0,import.meta.url), 8206 8207 example: () => __vitePreload(() => import('./Example-DqjmrGmx.js'),true ?__vite__mapDeps([195,1,2,196]):void 0,import.meta.url), 8208 8209 component: () => __vitePreload(() => import('./Index-dV3_KR7K.js'),true ?__vite__mapDeps([197,1,2,10,193,4,5,6,7,8,9,20,30,65,36,23,81,194,41,42,43,44,28,15,45,3,21,49,11,12,13,14,195,196,198]):void 0,import.meta.url) 8210 }, 8211"multimodaltextbox": { 8212 8213 example: () => __vitePreload(() => import('./Example-Ciz_10jH.js'),true ?__vite__mapDeps([199,1,2,101,56,57,58,4,5,6,7,8,9,144,42,145,200,60]):void 0,import.meta.url), 8214 8215 component: () => __vitePreload(() => import('./Index-m9n9xbaM.js'),true ?__vite__mapDeps([201,1,2,10,42,62,4,5,6,80,74,66,13,7,8,9,171,63,15,65,31,108,192,41,43,56,57,58,32,33,47,3,11,12,14,199,101,144,145,200,60,202]):void 0,import.meta.url) 8216 }, 8217"nativeplot": { 8218 8219 example: () => __vitePreload(() => import('./Example-CN-EkgaQ.js'),true ?__vite__mapDeps([203,1,2]):void 0,import.meta.url), 8220 8221 component: () => __vitePreload(() => import('./Index-DaT_S5Dl.js'),true ?__vite__mapDeps([204,1,2,10,3,4,5,6,80,74,66,13,7,8,9,21,30,185,23,24,25,11,12,14,15,205]):void 0,import.meta.url) 8222 }, 8223"navbar": { 8224 base: () => __vitePreload(() => import('./Index-Bq3RRF73.js'),true ?__vite__mapDeps([206,1,2,10]):void 0,import.meta.url), 8225 8226 example: () => __vitePreload(() => import('./Example-Cd055f6G.js'),true ?__vite__mapDeps([207,1,2]):void 0,import.meta.url), 8227 8228 component: () => __vitePreload(() => import('./Index-Bq3RRF73.js'),true ?__vite__mapDeps([206,1,2,10]):void 0,import.meta.url) 8229 }, 8230"number": { 8231 8232 example: () => __vitePreload(() => import('./Example-CtUXmdvx.js'),true ?__vite__mapDeps([208,1,2,209]):void 0,import.meta.url), 8233 8234 component: () => __vitePreload(() => import('./Index-D5QhI0w9.js'),true ?__vite__mapDeps([210,1,2,62,10,3,4,5,6,80,74,66,13,7,8,9,23,11,12,14,15,211]):void 0,import.meta.url) 8235 }, 8236"paramviewer": { 8237 8238 example: () => __vitePreload(() => import('./Example-r8MvLd1a.js'),true ?__vite__mapDeps([212,1,2,213]):void 0,import.meta.url), 8239 8240 component: () => __vitePreload(() => import('./Index-CMslNhWu.js'),true ?__vite__mapDeps([214,1,2,10,13,8,215]):void 0,import.meta.url) 8241 }, 8242"plot": { 8243 base: () => __vitePreload(() => import('./Plot-Bv7e-GKH.js').then(n => n.b),true ?__vite__mapDeps([216,1,2,105,4,5,6,57,7,8,9,21]):void 0,import.meta.url), 8244 8245 8246 component: () => __vitePreload(() => import('./Index-BLvIY0lP.js'),true ?__vite__mapDeps([217,1,2,10,216,105,4,5,6,57,7,8,9,21,3,20,23,24,25,11,12,13,14,15]):void 0,import.meta.url) 8247 }, 8248"radio": { 8249 8250 example: () => __vitePreload(() => import('./Example-ByABbZIR.js'),true ?__vite__mapDeps([218,1,2,219]):void 0,import.meta.url), 8251 8252 component: () => __vitePreload(() => import('./Index-CEkl9UYg.js'),true ?__vite__mapDeps([220,1,2,10,3,4,5,6,80,74,66,13,7,8,9,23,11,12,14,15,62,218,219,221]):void 0,import.meta.url) 8253 }, 8254"row": { 8255 8256 8257 component: () => __vitePreload(() => import('./Index-Cyy7LoUW.js'),true ?__vite__mapDeps([222,1,2,11,12,13,4,5,6,7,8,9,14,15,10,223]):void 0,import.meta.url) 8258 }, 8259"sidebar": { 8260 8261 8262 component: () => __vitePreload(() => import('./Index-D998CuPi.js'),true ?__vite__mapDeps([224,1,2,10,11,12,13,4,5,6,7,8,9,14,15,16,17,225]):void 0,import.meta.url) 8263 }, 8264"slider": { 8265 8266 example: () => __vitePreload(() => import('./Example-dmTBkWCg.js'),true ?__vite__mapDeps([226,1,2,227]):void 0,import.meta.url), 8267 8268 component: () => __vitePreload(() => import('./Index-CClIgVld.js'),true ?__vite__mapDeps([228,1,2,62,10,3,4,5,6,80,74,66,13,7,8,9,11,12,14,15,229]):void 0,import.meta.url) 8269 }, 8270"state": { 8271 8272 8273 component: () => __vitePreload(() => import('./Index-zaGJoSm-.js'),true ?__vite__mapDeps([230,1,2,10]):void 0,import.meta.url) 8274 }, 8275"statustracker": { 8276 8277 8278 component: () => __vitePreload(() => import('./index-CHTHcz5h.js'),true ?__vite__mapDeps([231,11,1,2,12,13,4,5,6,7,8,9,14,15,232,46]):void 0,import.meta.url) 8279 }, 8280"tabitem": { 8281 8282 8283 component: () => __vitePreload(() => import('./Index-CvusdnXc.js'),true ?__vite__mapDeps([233,1,2,10,234,67,235,16,11,12,13,4,5,6,7,8,9,14,15,17,236]):void 0,import.meta.url) 8284 }, 8285"tabs": { 8286 8287 8288 component: () => __vitePreload(() => import('./Index-BPZgH1F4.js'),true ?__vite__mapDeps([237,1,2,10,234,67,235]):void 0,import.meta.url) 8289 }, 8290"textbox": { 8291 8292 example: () => __vitePreload(() => import('./Example-DYo_cEEb.js'),true ?__vite__mapDeps([110,1,2,101,111]):void 0,import.meta.url), 8293 8294 component: () => __vitePreload(() => import('./Index-DIT5pDCQ.js'),true ?__vite__mapDeps([238,1,2,10,106,42,62,4,5,6,80,74,66,13,7,8,9,63,64,107,108,23,109,11,12,14,15,3,110,101,111]):void 0,import.meta.url) 8295 }, 8296"timer": { 8297 8298 8299 component: () => __vitePreload(() => import('./Index-CybaYxJS.js'),true ?__vite__mapDeps([239,1,2,10]):void 0,import.meta.url) 8300 }, 8301"uploadbutton": { 8302 8303 8304 component: () => __vitePreload(() => import('./Index-0rZUl0Zh.js'),true ?__vite__mapDeps([240,1,2,10,5,55,56,57,58,4,6,7,8,9,59,60,241]):void 0,import.meta.url) 8305 }, 8306"vibeeditor": { 8307 8308 8309 component: () => __vitePreload(() => import('./Index-BZjnJz9D.js'),true ?__vite__mapDeps([242,1,2,62,12,13,4,5,6,7,8,9,14,86,87,190,42,10,63,64,66,23,191,243,84,188]):void 0,import.meta.url) 8310 }, 8311"video": { 8312 base: () => __vitePreload(() => import('./VideoPreview-D1Zp6agR.js').then(n => n.a),true ?__vite__mapDeps([244,1,2,105,4,5,6,7,8,9,20,28,21,29,10,30,23,25,34,35,36,144,42,145,41,43,44,15,45,245]):void 0,import.meta.url), 8313 8314 example: () => __vitePreload(() => import('./Example-CwC21_Sq.js'),true ?__vite__mapDeps([246,1,2,144,5,42,145,247]):void 0,import.meta.url), 8315 8316 component: () => __vitePreload(() => import('./index-VE26-3z-.js'),true ?__vite__mapDeps([248,1,2,105,5,41,42,43,4,6,7,8,9,20,150,12,13,14,100,102,108,48,46,151,144,145,244,28,21,29,10,30,23,25,34,35,36,44,15,45,245,246,247,3,49,11,249,58,60,153]):void 0,import.meta.url) 8317 }, 8318"walkthrough": { 8319 8320 8321 component: () => __vitePreload(() => import('./Index-BPZgH1F4.js'),true ?__vite__mapDeps([237,1,2,10,234,67,235]):void 0,import.meta.url) 8322 }, 8323"walkthroughstep": { 8324 8325 8326 component: () => __vitePreload(() => import('./Index-CvusdnXc.js'),true ?__vite__mapDeps([233,1,2,10,234,67,235,16,11
8326,12,13,4,5,6,7,8,9,14,15,17,236]):void 0,import.meta.url) 8327 }, 8328 8329 }; 8330 8331 8332// @ts-nocheck 8333 8334const request_map = {}; 8335const runtime_map = {}; 8336 8337const is_browser = typeof window !== "undefined"; 8338 8339function load_component({ api_url, name, id, variant }) { 8340 const comps = is_browser && window.__GRADIO__CC__; 8341 8342 const _component_map = { 8343 // eslint-disable-next-line no-undef 8344 ...component_map, 8345 ...(!comps ? {} : comps) 8346 }; 8347 8348 let _id = id || name; 8349 8350 if (request_map[`${_id}-${variant}`]) { 8351 return { 8352 component: request_map[`${_id}-${variant}`], 8353 name, 8354 runtime: runtime_map[`${_id}-${variant}`] 8355 }; 8356 } 8357 try { 8358 if (!_component_map?.[_id]?.[variant] && !_component_map?.[name]?.[variant]) 8359 throw new Error(); 8360 8361 request_map[`${_id}-${variant}`] = ( 8362 _component_map?.[_id]?.[variant] || // for dev mode custom components 8363 _component_map?.[name]?.[variant] 8364 )(); 8365 8366 runtime_map[`${_id}-${variant}`] = 8367 (is_browser && window.__GRADIO__CC__RUNTIMES__?.[id]) || // for dev mode custom components 8368 false; 8369 8370 return { 8371 name, 8372 component: request_map[`${_id}-${variant}`], 8373 runtime: runtime_map[`${_id}-${variant}`] 8374 }; 8375 } catch (e) { 8376 if (!_id) throw new Error(`Component not found: ${name}`); 8377 try { 8378 const cc = get_component_with_css(api_url, _id, variant); 8379 console.log({ cc }); 8380 8381 const [component_module, svelte_runtime_module] = cc; 8382 8383 request_map[`${_id}-${variant}`] = component_module; 8384 8385 runtime_map[`${_id}-${variant}`] = svelte_runtime_module; 8386 8387 return { 8388 name, 8389 component: request_map[`${_id}-${variant}`], 8390 runtime: runtime_map[`${_id}-${variant}`] 8391 }; 8392 } catch (e) { 8393 if (variant === "example") { 8394 request_map[`${_id}-${variant}`] = __vitePreload(() => import('./Example-wPalRDrs.js'),true ?__vite__mapDeps([250,1,2,251]):void 0,import.meta.url); 8395 8396 return { 8397 name, 8398 component: request_map[`${_id}-${variant}`], 8399 runtime: runtime_map[`${_id}-${variant}`] 8400 }; 8401 } 8402 console.error(`failed to load: ${name}`); 8403 console.error(e); 8404 throw e; 8405 } 8406 } 8407} 8408 8409function load_css(url) { 8410 if (!is_browser) { 8411 return Promise.resolve(); 8412 } 8413 return new Promise((resolve, reject) => { 8414 const link = document.createElement("link"); 8415 link.rel = "stylesheet"; 8416 link.href = url; 8417 document.head.appendChild(link); 8418 link.onload = () => resolve(); 8419 link.onerror = () => reject(); 8420 }); 8421} 8422 8423function get_component_with_css(api_url, id, variant) { 8424 const environment = is_browser ? "client" : "server"; 8425 let path; 8426 if (environment === "server") { 8427 // uncomment when we make gradio cc build support ssr 8428 //path = await (await fetch(`${api_url}/custom_component/${id}/${variant}/index.js/server`)).text(); 8429 [ 8430 Promise.all([ 8431 load_css(`${api_url}/custom_component/${id}/${variant}/style.css`), 8432 __vitePreload(() => import('./Index-DC50X8S0.js'),true ?__vite__mapDeps([252,1,2,10,3,4,5,6,7,8,9,11,12,13,14,15,253]):void 0,import.meta.url) 8433 ]).then(([_, module]) => { 8434 return module; 8435 }) 8436 ]; 8437 } 8438 8439 path = `${api_url}/custom_component/${id}/${environment}/${variant}/index.js`; 8440 8441 return [ 8442 Promise.all([ 8443 load_css( 8444 `${api_url}/custom_component/${id}/${environment}/${variant}/style.css` 8445 ), 8446 import( 8447 /* @vite-ignore */ 8448 path 8449 ) 8450 ]).then(([_, component_module]) => { 8451 return component_module; 8452 }), 8453 __vitePreload(() => import( 8454 /* @vite-ignore */ 8455 `${api_url}/custom_component/${id}/${environment}/${variant}/svelte_runtime_entry.js` 8456 ),true ?[]:void 0,import.meta.url) 8457 ]; 8458} 8459 8460function get_component(type, class_id, root, variant = "component") { 8461 if (type === "api") type = "state"; 8462 return load_component({ 8463 api_url: root, 8464 name: type, 8465 id: class_id, 8466 variant 8467 }); 8468} 8469function get_inputs_outputs(dependencies) { 8470 const inputs = /* @__PURE__ */ new Set(); 8471 const outputs = /* @__PURE__ */ new Set(); 8472 for (const dep of dependencies) { 8473 dep.inputs.forEach((input) => inputs.add(input)); 8474 dep.outputs.forEach((output) => outputs.add(output)); 8475 } 8476 return [inputs, outputs]; 8477} 8478function determine_interactivity(id, interactive_prop, value, dependencies) {
8479 const [inputs, outputs] = dependencies; 8480 if (interactive_prop === false) { 8481 return false; 8482 } else if (interactive_prop === true) { 8483 return true; 8484 } else if (inputs.has(id) || !outputs.has(id) && has_no_default_value(value)) { 8485 return true; 8486 } 8487 return false; 8488} 8489function has_no_default_value(value) { 8490 return Array.isArray(value) && value.length === 0 || value === "" || value === 0 || !value; 8491} 8492const AsyncFunction = Object.getPrototypeOf( 8493 async function() { 8494 } 8495).constructor; 8496 8497const ordered_colors = [ 8498 "red", 8499 "green", 8500 "blue", 8501 "yellow", 8502 "purple", 8503 "teal", 8504 "orange", 8505 "cyan", 8506 "lime", 8507 "pink" 8508]; 8509const color_values = [ 8510 { color: "red", primary: 600, secondary: 100 }, 8511 { color: "green", primary: 600, secondary: 100 }, 8512 { color: "blue", primary: 600, secondary: 100 }, 8513 { color: "yellow", primary: 500, secondary: 100 }, 8514 { color: "purple", primary: 600, secondary: 100 }, 8515 { color: "teal", primary: 600, secondary: 100 }, 8516 { color: "orange", primary: 600, secondary: 100 }, 8517 { color: "cyan", primary: 600, secondary: 100 }, 8518 { color: "lime", primary: 500, secondary: 100 }, 8519 { color: "pink", primary: 600, secondary: 100 } 8520]; 8521const tw_colors = { 8522 inherit: "inherit", 8523 current: "currentColor", 8524 transparent: "transparent", 8525 black: "#000", 8526 white: "#fff", 8527 slate: { 8528 50: "#f8fafc", 8529 100: "#f1f5f9", 8530 200: "#e2e8f0", 8531 300: "#cbd5e1", 8532 400: "#94a3b8", 8533 500: "#64748b", 8534 600: "#475569", 8535 700: "#334155", 8536 800: "#1e293b", 8537 900: "#0f172a", 8538 950: "#020617" 8539 }, 8540 gray: { 8541 50: "#f9fafb", 8542 100: "#f3f4f6", 8543 200: "#e5e7eb", 8544 300: "#d1d5db", 8545 400: "#9ca3af", 8546 500: "#6b7280", 8547 600: "#4b5563", 8548 700: "#374151", 8549 800: "#1f2937", 8550 900: "#111827", 8551 950: "#030712" 8552 }, 8553 zinc: { 8554 50: "#fafafa", 8555 100: "#f4f4f5", 8556 200: "#e4e4e7", 8557 300: "#d4d4d8", 8558 400: "#a1a1aa", 8559 500: "#71717a", 8560 600: "#52525b", 8561 700: "#3f3f46", 8562 800: "#27272a", 8563 900: "#18181b", 8564 950: "#09090b" 8565 }, 8566 neutral: { 8567 50: "#fafafa", 8568 100: "#f5f5f5", 8569 200: "#e5e5e5", 8570 300: "#d4d4d4", 8571 400: "#a3a3a3", 8572 500: "#737373", 8573 600: "#525252", 8574 700: "#404040", 8575 800: "#262626", 8576 900: "#171717", 8577 950: "#0a0a0a" 8578 }, 8579 stone: { 8580 50: "#fafaf9", 8581 100: "#f5f5f4", 8582 200: "#e7e5e4", 8583 300: "#d6d3d1", 8584 400: "#a8a29e", 8585 500: "#78716c", 8586 600: "#57534e", 8587 700: "#44403c", 8588 800: "#292524", 8589 900: "#1c1917", 8590 950: "#0c0a09" 8591 }, 8592 red: { 8593 50: "#fef2f2", 8594 100: "#fee2e2", 8595 200: "#fecaca", 8596 300: "#fca5a5", 8597 400: "#f87171", 8598 500: "#ef4444", 8599 600: "#dc2626", 8600 700: "#b91c1c", 8601 800: "#991b1b", 8602 900: "#7f1d1d", 8603 950: "#450a0a" 8604 }, 8605 orange: { 8606 50: "#fff7ed", 8607 100: "#ffedd5", 8608 200: "#fed7aa", 8609 300: "#fdba74", 8610 400: "#fb923c", 8611 500: "#f97316", 8612 600: "#ea580c", 8613 700: "#c2410c", 8614 800: "#9a3412", 8615 900: "#7c2d12", 8616 950: "#431407" 8617 }, 8618 amber: { 8619 50: "#fffbeb", 8620 100: "#fef3c7", 8621 200: "#fde68a", 8622 300: "#fcd34d", 8623 400: "#fbbf24", 8624 500: "#f59e0b", 8625 600: "#d97706", 8626 700: "#b45309", 8627 800: "#92400e", 8628 900: "#78350f", 8629 950: "#451a03" 8630 }, 8631 yellow: { 8632 50: "#fefce8", 8633 100: "#fef9c3", 8634 200: "#fef08a", 8635 300: "#fde047", 8636 400: "#facc15", 8637 500: "#eab308", 8638 600: "#ca8a04", 8639 700: "#a16207", 8640 800: "#854d0e", 8641 900: "#713f12", 8642 950: "#422006" 8643 }, 8644 lime: { 8645 50: "#f7fee7", 8646 100: "#ecfccb", 8647 200: "#d9f99d", 8648 300: "#bef264", 8649 400: "#a3e635", 8650 500: "#84cc16", 8651 600: "#65a30d", 8652 700: "#4d7c0f", 8653 800: "#3f6212", 8654 900: "#365314", 8655 950: "#1a2e05" 8656 }, 8657 green: { 8658 50: "#f0fdf4", 8659 100: "#dcfce7", 8660 200: "#bbf7d0", 8661 300: "#86efac", 8662 400: "#4ade80", 8663 500: "#22c55e", 8664 600: "#16a34a", 8665 700: "#15803d", 8666 800: "#166534", 8667 900: "#14532d", 8668 950: "#052e16" 8669 }, 8670 emerald: { 8671 50: "#ecfdf5", 8672 100: "#d1fae5", 8673 200: "#a7f3d0", 8674 300: "#6ee7b7", 8675 400: "#34d399", 8676 500: "#10b981", 8677 600: "#059669", 8678 700: "#047857", 8679 800: "#065f46", 8680 900: "#064e3b", 8681 950: "#022c22" 8682 }, 8683 teal: { 8684 50: "#f0fdfa", 8685 100: "#ccfbf1", 8686 200: "#99f6e4", 8687 300: "#5eead4", 8688 400: "#2dd4bf", 8689 500: "#14b8a6", 8690 600: "#0d9488", 8691 700: "#0f766e", 8692 800: "#115e59", 8693 900: "#134e4a", 8694 950: "#042f2e" 8695 }, 8696 cyan: {
8697 50: "#ecfeff", 8698 100: "#cffafe", 8699 200: "#a5f3fc", 8700 300: "#67e8f9", 8701 400: "#22d3ee", 8702 500: "#06b6d4", 8703 600: "#0891b2", 8704 700: "#0e7490", 8705 800: "#155e75", 8706 900: "#164e63", 8707 950: "#083344" 8708 }, 8709 sky: { 8710 50: "#f0f9ff", 8711 100: "#e0f2fe", 8712 200: "#bae6fd", 8713 300: "#7dd3fc", 8714 400: "#38bdf8", 8715 500: "#0ea5e9", 8716 600: "#0284c7", 8717 700: "#0369a1", 8718 800: "#075985", 8719 900: "#0c4a6e", 8720 950: "#082f49" 8721 }, 8722 blue: { 8723 50: "#eff6ff", 8724 100: "#dbeafe", 8725 200: "#bfdbfe", 8726 300: "#93c5fd", 8727 400: "#60a5fa", 8728 500: "#3b82f6", 8729 600: "#2563eb", 8730 700: "#1d4ed8", 8731 800: "#1e40af", 8732 900: "#1e3a8a", 8733 950: "#172554" 8734 }, 8735 indigo: { 8736 50: "#eef2ff", 8737 100: "#e0e7ff", 8738 200: "#c7d2fe", 8739 300: "#a5b4fc", 8740 400: "#818cf8", 8741 500: "#6366f1", 8742 600: "#4f46e5", 8743 700: "#4338ca", 8744 800: "#3730a3", 8745 900: "#312e81", 8746 950: "#1e1b4b" 8747 }, 8748 violet: { 8749 50: "#f5f3ff", 8750 100: "#ede9fe", 8751 200: "#ddd6fe", 8752 300: "#c4b5fd", 8753 400: "#a78bfa", 8754 500: "#8b5cf6", 8755 600: "#7c3aed", 8756 700: "#6d28d9", 8757 800: "#5b21b6", 8758 900: "#4c1d95", 8759 950: "#2e1065" 8760 }, 8761 purple: { 8762 50: "#faf5ff", 8763 100: "#f3e8ff", 8764 200: "#e9d5ff", 8765 300: "#d8b4fe", 8766 400: "#c084fc", 8767 500: "#a855f7", 8768 600: "#9333ea", 8769 700: "#7e22ce", 8770 800: "#6b21a8", 8771 900: "#581c87", 8772 950: "#3b0764" 8773 }, 8774 fuchsia: { 8775 50: "#fdf4ff", 8776 100: "#fae8ff", 8777 200: "#f5d0fe", 8778 300: "#f0abfc", 8779 400: "#e879f9", 8780 500: "#d946ef", 8781 600: "#c026d3", 8782 700: "#a21caf", 8783 800: "#86198f", 8784 900: "#701a75", 8785 950: "#4a044e" 8786 }, 8787 pink: { 8788 50: "#fdf2f8", 8789 100: "#fce7f3", 8790 200: "#fbcfe8", 8791 300: "#f9a8d4", 8792 400: "#f472b6", 8793 500: "#ec4899", 8794 600: "#db2777", 8795 700: "#be185d", 8796 800: "#9d174d", 8797 900: "#831843", 8798 950: "#500724" 8799 }, 8800 rose: { 8801 50: "#fff1f2", 8802 100: "#ffe4e6", 8803 200: "#fecdd3", 8804 300: "#fda4af", 8805 400: "#fb7185", 8806 500: "#f43f5e", 8807 600: "#e11d48", 8808 700: "#be123c", 8809 800: "#9f1239", 8810 900: "#881337", 8811 950: "#4c0519" 8812 } 8813}; 8814const colors = color_values.reduce( 8815 (acc, { color, primary, secondary }) => ({ 8816 ...acc, 8817 [color]: { 8818 primary: tw_colors[color][primary], 8819 secondary: tw_colors[color][secondary] 8820 } 8821 }), 8822 {} 8823); 8824 8825const loading = { 8826 ar: "Ø¬Ø§Ø±Ù Ø§ÙØªØÙ ÙÙ", 8827 ca: "S'està carregant", 8828 ckb: "بارکردÙ", 8829 de: "Laden", 8830 en: "Loading", 8831 es: "Cargando", 8832 eu: "Kargatzen", 8833 fa: "در ØØ§Ù بارگذارÛ", 8834 fi: "Ladataan", 8835 fr: "Chargement", 8836 he: "×××¢×", 8837 hi: "लà¥à¤¡ हॠरहा हà¥", 8838 ja: "èªã¿è¾¼ã¿ä¸", 8839 ko: "ë¡ë© ì¤", 8840 lt: "Kraunama", 8841 nb: "Laster", 8842 nl: "Laden", 8843 pl: "Åadowanie", 8844 "pt-BR": "Carregando", 8845 pt: "A carregar", 8846 ro: "Se încarcÄ", 8847 ru: "ÐагÑÑзка", 8848 sv: "Laddar", 8849 ta: "à®à®±à¯à®±à¯à®à®¿à®±à®¤à¯", 8850 th: "à¸à¸³à¸¥à¸±à¸à¹à¸«à¸¥à¸", 8851 tr: "Yükleniyor", 8852 uk: "ÐаванÑаженнÑ", 8853 ur: "ÙÙÚ ÛÙ Ø±ÛØ§ ÛÛ", 8854 uz: "Yuklanmoqda", 8855 "zh-CN": "å è½½ä¸", 8856 "zh-TW": "è¼å ¥ä¸" 8857}; 8858 8859const _name = "English"; 8860const annotated_image = {"annotated_image":"Annotated Image"}; 8861const audio = {"allow_recording_access":"Please allow access to the microphone for recording.","audio":"Audio","drop_to_upload":"Drop an audio file here to upload","record_from_microphone":"Record from microphone","stop_recording":"Stop recording","no_device_support":"Media devices could not be accessed. Check that you are running on a secure origin (https) or localhost (or you have passed a valid SSL certificate to ssl_verify), and you have allowed browser access to your device.","stop":"Stop","resume":"Resume","record":"Record","no_microphone":"No microphone found","pause":"Pause","play":"Play","waiting":"Waiting"}; 8862const blocks = {"connection_can_break":"On mobile, the connection can break if this tab is unfocused or the device sleeps, losing your position in queue.","long_requests_queue":"There is a long queue of requests pending. Duplicate this Space to skip.","lost_connection":"Lost connection due to leaving page. Rejoining queue...","waiting_for_inputs":"Waiting for file(s) to finish uploading, please retry."}; 8863const chatbot = {"edit":"Edit","retry":"Retry","undo":"Undo","submit":"Submit","cancel":"Cancel","like":"Like","dislike":"Dislike","clear":"Clear","copy_message":"Copy message","copied_message":"Copied message"}; 8864const chat_interface = {"new_chat":"New chat","message_placeholder":"Type a message...","additional_inputs":"Additional inputs","chatbot":"Chatbot","conversation":"Conversation"}; 8865const checkbox = {"checkbox":"Checkbox","checkbox_group":"Checkbox Group"}; 8866const code = {"code":"Code"}; 8867const color_picker = {"color_picker":"Color Picker"}; 8868const common = {"built_with":"built with","built_with_gradio":"Built with Gradio","clear":"Clear","download":"Download","edit":"Edit","empty":"Empty","error":"Error","hosted_on":"Hosted on","loading":"Loading","logo":"logo","or":"or","remove":"Remove","settings":"Settings","share":"Share","submit":"Submit","undo":"Undo","no_devices":"No devices found","language":"Language","display_theme":"Display Theme","pwa":"Progressive Web App","record":"Record","stop_recording":"Stop Recording","screen_studio":"Screen Studio","share_gradio_tab":"[Sharing] Gradio Tab","run":"Run"}; 8869const dataframe = {"incorrect_format":"Incorrect format, only CSV and TSV files are supported","new_column":"Add column","new_row":"New row","add_row_above":"Add row above","add_row_below":"Add row below","delete_row":"Delete row","delete_column":"Delete column","add_column_left":"Add column to the left","add_column_right":"Add column to the right","sort_column":"Sort column","sort_ascending":"Sort ascending","sort_descending":"Sort descending","drop_to_upload":"Drop CSV or TSV files here to import data into dataframe","clear_sort":"Clear sort","filter":"Filter","clear_filter":"Clear filters"}; 8870const dropdown = {"dropdown":"Dropdown"}; 8871const errors = {"build_error":"there is a build error","config_error":"there is a config error","contact_page_author":"Please contact the author of the page to let them know.","no_app_file":"there is no app file","runtime_error":"there is a runtime error","space_not_working":"\"Space isn't working because\" {0}","space_paused":"the space is paused","use_via_api":"Use via API","use_via_api_or_mcp":"Use via API or MCP"}; 8872const file = {"uploading":"Uploading..."}; 8873const highlighted_text = {"highlighted_text":"Highlighted Text"}; 8874const image = {"allow_webcam_access":"Please allow access to the webcam for recording.","brush_color":"Brush color","brush_radius":"Brush radius","image":"Image","remove_image":"Remove Image","select_brush_color":"Select brush color","start_drawing":"Start drawing","use_brush":"Use brush","drop_to_upload":"Drop an image file here to upload"}; 8875const label = {"label":"Label"}; 8876const login = {"enable_cookies":"If you are visiting a HuggingFace Space in Incognito mode, you must enable third party cookies.","incorrect_credentials":"Incorrect Credentials","username":"username","password":"password","login":"Login"}; 8877const number = {"number":"Number"}; 8878const plot = {"plot":"Plot"}; 8879const radio = {"radio":"Radio"}; 8880const slider = {"slider":"Slider"}; 8881const upload_text = {"click_to_upload":"Click to Upload","drop_audio":"Drop Audio Here","drop_csv":"Drop CSV Here","drop_file":"Drop File Here","drop_image":"Drop Image Here","drop_video":"Drop Video Here","drop_gallery":"Drop Media Here","paste_clipboard":"Paste from Clipboard"}; 8882const video = {"drop_to_upload":"Drop a video file here to upload"}; 8883const en = { 8884 _name, 8885 "3D_model": {"3d_model":"3D Model","drop_to_upload":"Drop a 3D model (.obj, .glb, .stl, .gltf, .splat, or .ply) file here to upload"}, 8886 annotated_image, 8887 audio, 8888 blocks, 8889 chatbot, 8890 chat_interface, 8891 checkbox, 8892 code, 8893 color_picker, 8894 common, 8895 dataframe, 8896 dropdown, 8897 errors, 8898 file, 8899 highlighted_text, 8900 image, 8901 label, 8902 login, 8903 number, 8904 plot, 8905 radio, 8906 slider, 8907 upload_text, 8908 video, 8909}; 8910 8911const en$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({ 8912 __proto__: null, 8913 _name, 8914 annotated_image, 8915 audio, 8916 blocks, 8917 chat_interface, 8918 chatbot, 8919 checkbox, 8920 code, 8921 color_picker, 8922 common, 8923 dataframe, 8924 default: en, 8925 dropdown, 8926 errors, 8927 file, 8928 highlighted_text, 8929 image, 8930 label, 8931 login, 8932 number, 8933 plot, 8934 radio, 8935 slider, 8936 upload_text, 8937 video 8938}, Symbol.toStringTag, { value: 'Module' })); 8939 8940const lang_map = { 8941 ar: "Ø§ÙØ¹Ø±Ø¨ÙØ©", 8942 ca: "Català ", 8943 ckb: "Ú©ÙØ±Ø¯Û", 8944 de: "Deutsch", 8945 en: "English", 8946 es: "Español", 8947 eu: "Euskara", 8948 fa: "ÙØ§Ø±Ø³Û", 8949 fi: "Suomi", 8950 fr: "Français", 8951 he: "×¢×ר×ת", 8952 hi: "हिà¤à¤¦à¥", 8953 ja: "æ¥æ¬èª", 8954 ko: "íêµì´", 8955 lt: "Lietuvių", 8956 nb: "Norsk bokmÃ¥l", 8957 nl: "Nederlands", 8958 pl: "Polski", 8959 "pt-BR": "Português do Brasil", 8960 pt: "Português", 8961 ro: "RomânÄ", 8962 ru: "Ð ÑÑÑкий", 8963 sv: "Svenska", 8964 ta: "தமிழà¯", 8965 th: "ภาษาà¹à¸à¸¢", 8966 tr: "Türkçe", 8967 uk: "УкÑаÑнÑÑка", 8968 ur: "اردÙ", 8969 uz: "O'zbek", 8970 "zh-CN": "ç®ä½ä¸æ", 8971 "zh-TW": "ç¹é«ä¸æ" 8972}; 8973const langs = /* #__PURE__ */ Object.assign({
8973"./lang/ar.json": () => __vitePreload(() => import('./ar-Bnr8rik1.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ca.json": () => __vitePreload(() => import('./ca-ZVB5Zcgj.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ckb.json": () => __vitePreload(() => import('./ckb-B5osF7U3.js'),true ?[]:void 0,import.meta.url),
8973"./lang/de.json": () => __vitePreload(() => import('./de-BqO16QIZ.js'),true ?[]:void 0,import.meta.url),
8973"./lang/en.json": () => __vitePreload(() => Promise.resolve().then(() => en$1),true ?void 0:void 0,import.meta.url),
8973"./lang/es.json": () => __vitePreload(() => import('./es-BECHJ7T0.js'),true ?[]:void 0,import.meta.url),
8973"./lang/eu.json": () => __vitePreload(() => import('./eu-CdvSJ_NN.js'),true ?[]:void 0,import.meta.url),
8973"./lang/fa.json": () => __vitePreload(() => import('./fa-n05ND1i-.js'),true ?[]:void 0,import.meta.url),
8973"./lang/fi.json": () => __vitePreload(() => import('./fi-f63CrSuU.js'),true ?[]:void 0,import.meta.url),
8973"./lang/fr.json": () => __vitePreload(() => import('./fr-Xtgf04nj.js'),true ?[]:void 0,import.meta.url),
8973"./lang/he.json": () => __vitePreload(() => import('./he-DzhX_ol8.js'),true ?[]:void 0,import.meta.url),
8973"./lang/hi.json": () => __vitePreload(() => import('./hi-CGq3rrRL.js'),true ?[]:void 0,import.meta.url),
8973"./lang/id.json": () => __vitePreload(() => import('./id-DTBwfi3A.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ja.json": () => __vitePreload(() => import('./ja-Ckff7MTr.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ko.json": () => __vitePreload(() => import('./ko-C2zECW0e.js'),true ?[]:void 0,import.meta.url),
8973"./lang/lt.json": () => __vitePreload(() => import('./lt-CE6Ln202.js'),true ?[]:void 0,import.meta.url),
8973"./lang/nb.json": () => __vitePreload(() => import('./nb-CNxglIEs.js'),true ?[]:void 0,import.meta.url),
8973"./lang/nl.json": () => __vitePreload(() => import('./nl-DO2suw4j.js'),true ?[]:void 0,import.meta.url),
8973"./lang/pl.json": () => __vitePreload(() => import('./pl-BlSku3we.js'),true ?[]:void 0,import.meta.url),
8973"./lang/pt-BR.json": () => __vitePreload(() => import('./pt-BR-87jk7nQ9.js'),true ?[]:void 0,import.meta.url),
8973"./lang/pt.json": () => __vitePreload(() => import('./pt-BVfKCBHm.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ro.json": () => __vitePreload(() => import('./ro-B-y0swIh.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ru.json": () => __vitePreload(() => import('./ru-DGhkoewM.js'),true ?[]:void 0,import.meta.url),
8973"./lang/sv.json": () => __vitePreload(() => import('./sv-CC6VQTaJ.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ta.json": () => __vitePreload(() => import('./ta-BTn6NxAt.js'),true ?[]:void 0,import.meta.url),
8973"./lang/th.json": () => __vitePreload(() => import('./th-Bq4LzcN7.js'),true ?[]:void 0,import.meta.url),
8973"./lang/tr.json": () => __vitePreload(() => import('./tr-DPCQxv16.js'),true ?[]:void 0,import.meta.url),
8973"./lang/uk.json": () => __vitePreload(() => import('./uk-BHClIR2f.js'),true ?[]:void 0,import.meta.url),
8973"./lang/ur.json": () => __vitePreload(() => import('./ur-D3imbk6t.js'),true ?[]:void 0,import.meta.url),
8973"./lang/uz.json": () => __vitePreload(() => import('./uz-Dw46OF3I.js'),true ?[]:void 0,import.meta.url),
8973"./lang/zh-CN.json": () => __vitePreload(() => import('./zh-CN-XOyJonQP.js'),true ?[]:void 0,import.meta.url),
8973"./lang/zh-TW.json": () => __vitePreload(() => import('./zh-TW-BlEWhqmM.js'),true ?[]:void 0,import.meta.url)
8973}); 8974function is_translation_metadata(obj) { 8975 const result = obj && typeof obj === "object" && obj.__type__ === "translation_metadata" && typeof obj.key === "string"; 8976 return result; 8977} 8978function process_langs() { 8979 const lazy_langs = Object.fromEntries( 8980 Object.entries(langs).map(([path, mod]) => [ 8981 path.split("/").pop().split(".")[0], 8982 { type: "lazy", data: mod } 8983 ]) 8984 ); 8985 return { 8986 ...lazy_langs, 8987 en: { type: "static", data: en } 8988 }; 8989} 8990const processed_langs = process_langs(); 8991const available_locales = Object.keys(processed_langs); 8992const language_choices = Object.entries( 8993 processed_langs 8994).map(([code]) => [lang_map[code] || code, code]); 8995let i18n_initialized = false; 8996let previous_translations; 8997function get_lang_from_preferred_locale(header) { 8998 const options = header.split(",").map( 8999 (value) => value.includes(";") ? value.split(";").slice(0, 2) : [value, 1] 9000 ); 9001 options.sort( 9002 (a, b) => parseFloat(b[1]) - parseFloat(a[1]) 9003 ); 9004 for (const [lang, _] of options) { 9005 if (available_locales.includes(lang)) { 9006 return lang; 9007 } 9008 } 9009 return null; 9010} 9011async function setupi18n(custom_translations, preferred_locale) { 9012 const should_reinitialize = i18n_initialized && custom_translations !== previous_translations; 9013 if (i18n_initialized && !should_reinitialize) { 9014 return; 9015 } 9016 const translations_to_use = custom_translations ?? previous_translations ?? {}; 9017 if (custom_translations !== void 0) { 9018 previous_translations = custom_translations; 9019 } 9020 load_translations({ 9021 processed_langs, 9022 custom_translations: translations_to_use 9023 }); 9024 let initial_locale = null; 9025 const browser_locale = getLocaleFromNavigator(); 9026 if (preferred_locale) { 9027 initial_locale = get_lang_from_preferred_locale(preferred_locale); 9028 } else { 9029 initial_locale = browser_locale && available_locales.includes(browser_locale) ? browser_locale : null; 9030 } 9031 if (!initial_locale) { 9032 const normalized_locale = browser_locale?.split("-")[0]; 9033 initial_locale = normalized_locale && available_locales.includes(normalized_locale) ? normalized_locale : "en"; 9034 } 9035 await init({ 9036 fallbackLocale: "en", 9037 initialLocale: initial_locale 9038 }); 9039 i18n_initialized = true; 9040} 9041function changeLocale(new_locale) { 9042 $locale.set(new_locale); 9043} 9044function get_initial_locale(browser_locale, available_locales2, fallback_locale = "en") { 9045 if (!browser_locale) return fallback_locale; 9046 if (available_locales2.includes(browser_locale)) { 9047 return browser_locale; 9048 } 9049 return fallback_locale; 9050} 9051function load_translations(translations) { 9052 if (!translations) { 9053 return; 9054 } 9055 try { 9056 for (const lang in translations.custom_translations) { 9057 addMessages(lang, translations.custom_translations[lang]); 9058 } 9059 for (const lang in translations.processed_langs) { 9060 if (lang === "en" && translations.processed_langs[lang].type === "static") { 9061 addMessages(lang, en); 9062 } else if (translations.processed_langs[lang].type === "lazy") { 9063 registerLocaleLoader(lang, translations.processed_langs[lang].data); 9064 } 9065 } 9066 } catch (e) { 9067 console.error("Error loading translations:", e); 9068 } 9069 for (const lang in loading) { 9070 addMessages(lang, { 9071 common: { loading: loading[lang] } 9072 }); 9073 } 9074} 9075 9076export { $format as $, mount_css as A, BranchManager as B, CLASS as C, $locale as D, Embed as E, set_value as F, getDefaultExportFromCjs as G, set_selected as H, language_choices as I, changeLocale as J, commonjsGlobal as K, update_prop as L, colors as M, bind_select_value as N, derived as O, AsyncFunction as P, getAugmentedNamespace as Q, get_inputs_outputs as R, STYLE as S, get_component as T, determine_interactivity as U, get_initial_locale as V, is_translation_metadata as W, load_translations as X, process_langs as Y, set_attribute as a, set_class as b, attribute_effect as c, bind_this as d, init$1 as e, set_style as f, spread_props as g, clsx as h, if_block as i, get as j, each as k, legacy_rest_props as l, setup_stores as m, navbar_config as n, ordered_colors as o, prop as p, store_get as q, rest_props as r, slot as s, remove_input_defaults as t, index as u, set_checked as v, writable as w, store_set as x, setupi18n as y, prefix_css as z }; 9077//# sourceMappingURL=i18n-CGlVUOvE.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.