@lostgradient/cinder 0.26.1 → 0.26.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/components.json +1 -1
  3. package/dist/_internal/chart/chart-utilities.d.ts +1 -1
  4. package/dist/components/alert-dialog/index.js +2 -2
  5. package/dist/components/autocomplete/index.js +2 -2
  6. package/dist/components/carousel/index.js +2 -2
  7. package/dist/components/combobox/index.js +2 -2
  8. package/dist/components/command-menu/index.js +2 -2
  9. package/dist/components/command-palette/index.js +2 -2
  10. package/dist/components/confirm-dialog/index.js +2 -2
  11. package/dist/components/context-menu/index.js +2 -2
  12. package/dist/components/date-picker/index.js +2 -2
  13. package/dist/components/date-range-field/index.js +2 -2
  14. package/dist/components/drawer/index.js +2 -2
  15. package/dist/components/dropdown/index.js +2 -2
  16. package/dist/components/dropdown-menu/index.js +2 -2
  17. package/dist/components/focus-trap/index.js +2 -2
  18. package/dist/components/invocation-rule-builder/index.js +2 -2
  19. package/dist/components/mega-menu/index.js +2 -2
  20. package/dist/components/menu-bar/index.js +2 -2
  21. package/dist/components/modal/index.js +2 -2
  22. package/dist/components/navigation-bar/index.js +2 -2
  23. package/dist/components/popover/index.js +2 -2
  24. package/dist/components/sidebar/index.js +2 -2
  25. package/dist/components/slider/index.js +2 -2
  26. package/dist/components/speed-dial/index.js +2 -2
  27. package/dist/components/terminal-output/index.js +2 -2
  28. package/dist/components/terminal-output/terminal-output-parser.d.ts +1 -0
  29. package/dist/index.js +4 -4
  30. package/dist/server/components/alert-dialog/index.js +1 -1
  31. package/dist/server/components/autocomplete/index.js +1 -1
  32. package/dist/server/components/carousel/index.js +1 -1
  33. package/dist/server/components/combobox/index.js +1 -1
  34. package/dist/server/components/command-menu/index.js +1 -1
  35. package/dist/server/components/command-palette/index.js +1 -1
  36. package/dist/server/components/confirm-dialog/index.js +1 -1
  37. package/dist/server/components/context-menu/index.js +1 -1
  38. package/dist/server/components/date-picker/index.js +1 -1
  39. package/dist/server/components/date-range-field/index.js +1 -1
  40. package/dist/server/components/drawer/index.js +1 -1
  41. package/dist/server/components/dropdown/index.js +1 -1
  42. package/dist/server/components/dropdown-menu/index.js +1 -1
  43. package/dist/server/components/focus-trap/index.js +1 -1
  44. package/dist/server/components/invocation-rule-builder/index.js +1 -1
  45. package/dist/server/components/mega-menu/index.js +1 -1
  46. package/dist/server/components/menu-bar/index.js +1 -1
  47. package/dist/server/components/modal/index.js +1 -1
  48. package/dist/server/components/navigation-bar/index.js +1 -1
  49. package/dist/server/components/popover/index.js +1 -1
  50. package/dist/server/components/sidebar/index.js +1 -1
  51. package/dist/server/components/slider/index.js +1 -1
  52. package/dist/server/components/speed-dial/index.js +1 -1
  53. package/dist/server/components/terminal-output/index.js +1 -1
  54. package/dist/server/index.js +1 -1
  55. package/dist/server/{index.server-8h5caecr.js → index.server-1dxv84rs.js} +1 -1
  56. package/dist/server/{index.server-bfed6a8a.js → index.server-23726hh9.js} +1 -1
  57. package/dist/server/{index.server-c1746s0z.js → index.server-3ywpedsf.js} +1 -1
  58. package/dist/server/{index.server-y6vtbmyj.js → index.server-468y89tb.js} +1 -1
  59. package/dist/server/{index.server-80qgcjnm.js → index.server-4p0y8zrz.js} +1 -1
  60. package/dist/server/{index.server-99penx1m.js → index.server-7h28mv50.js} +1 -1
  61. package/dist/server/{index.server-vq1k69xt.js → index.server-96m4kera.js} +1 -1
  62. package/dist/server/index.server-9gac00vp.js +4 -0
  63. package/dist/server/{index.server-qgne9v2w.js → index.server-aajmj6rm.js} +1 -1
  64. package/dist/server/{index.server-y298khv4.js → index.server-ad66mjqp.js} +1 -1
  65. package/dist/server/{index.server-a2yhk45s.js → index.server-bvjqpbwk.js} +1 -1
  66. package/dist/server/{index.server-x9f5fqhn.js → index.server-dj8zqjdf.js} +2 -2
  67. package/dist/server/{index.server-na22gwzw.js → index.server-gt00wxxy.js} +1 -1
  68. package/dist/server/{index.server-5s94r0kk.js → index.server-k7x83whv.js} +1 -1
  69. package/dist/server/{index.server-zff2qp1v.js → index.server-m10489y5.js} +1 -1
  70. package/dist/server/{index.server-j52rbk57.js → index.server-p7vvv0cj.js} +1 -1
  71. package/dist/server/{index.server-s9tjs45r.js → index.server-qp53129k.js} +1 -1
  72. package/dist/server/{index.server-3xwvw6w2.js → index.server-setw377k.js} +1 -1
  73. package/dist/server/{index.server-d51wq0ak.js → index.server-sq7vyqnn.js} +1 -1
  74. package/dist/server/{index.server-p423fy4q.js → index.server-tfgwbvy2.js} +1 -1
  75. package/dist/server/{index.server-4gbrpan2.js → index.server-vkhb6g7x.js} +2 -2
  76. package/dist/server/{index.server-tyhta5n3.js → index.server-wd4d7aqx.js} +1 -1
  77. package/dist/server/{index.server-jm89hxfb.js → index.server-yhr56vkb.js} +1 -1
  78. package/dist/utilities/focus.d.ts +3 -1
  79. package/package.json +2 -1
  80. package/src/_internal/chart/chart-utilities.ts +5 -1
  81. package/src/_internal/text-direction-container.ts +21 -11
  82. package/src/_internal/text-direction-css.ts +15 -3
  83. package/src/_internal/text-direction.ts +13 -3
  84. package/src/components/button/button.examples.json +6 -0
  85. package/src/components/terminal-output/terminal-output-parser.ts +8 -0
  86. package/src/utilities/focus.ts +21 -8
  87. package/dist/server/index.server-k42t379x.js +0 -4
@@ -1,4 +1,4 @@
1
- var __create=Object.create;var __getProtoOf=Object.getPrototypeOf;var __defProp=Object.defineProperty;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;function __accessProp(key){return this[key]}var __toESMCache_node;var __toESMCache_esm;var __toESM=(mod,isNodeMode,target)=>{var canCache=mod!=null&&typeof mod==="object";if(canCache){var cache=isNodeMode?__toESMCache_node??=new WeakMap:__toESMCache_esm??=new WeakMap;var cached=cache.get(mod);if(cached)return cached}target=mod!=null?__create(__getProtoOf(mod)):{};const to=isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target;if(mod&&typeof mod==="object"||typeof mod==="function"){for(let key of __getOwnPropNames(mod))if(!__hasOwnProp.call(to,key))__defProp(to,key,{get:__accessProp.bind(mod,key),enumerable:true})}if(canCache)cache.set(mod,to);return to};var __commonJS=(cb,mod)=>()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports);var __returnValue=(v)=>v;function __exportSetter(name,newValue){this[name]=__returnValue.bind(null,newValue)}var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true,configurable:true,set:__exportSetter.bind(all,name)})};var __esm=(fn,res)=>()=>(fn&&(res=fn(fn=0)),res);var __require=((x)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!=="undefined"?require:a)[b]}):x)(function(x){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import"@lostgradient/cinder/mega-menu/styles";import"svelte/internal/disclose-version";import*as $5 from"svelte/internal/client";import{tick as tick2}from"svelte";import{createContext}from"svelte";function optionalContext(getStrict){return()=>{try{return getStrict()}catch{return}}}var[getLocaleContextStrict,setLocaleContextRaw]=createContext();function setLocaleContext(context){setLocaleContextRaw(context)}var getLocaleContext=optionalContext(getLocaleContextStrict);function parseStyleQuery(conditionText){const start=/style\(\s*(--[\w-]+)\s*:\s*/i.exec(conditionText);if(!start||!start[1])return;let depth=0;for(let index=start.index+start[0].length;index<conditionText.length;index+=1){const character=conditionText[index];if(character==="(")depth+=1;if(character===")"){if(depth===0)return{index:start.index,end:index+1,name:start[1],value:conditionText.slice(start.index+start[0].length,index)};depth-=1}}return}function splitTopLevel(conditionText,operator){const parts=[];let depth=0;let start=0;let index=0;while(index<conditionText.length){const character=conditionText[index];if(character==="("){depth+=1;index+=1;continue}if(character===")"){depth=Math.max(0,depth-1);index+=1;continue}if(depth===0&&conditionText.slice(index,index+operator.length).toLowerCase()===operator&&/\s/.test(conditionText[index-1]??"")&&/\s/.test(conditionText[index+operator.length]??"")){parts.push(conditionText.slice(start,index));index+=operator.length;start=index;continue}index+=1}parts.push(conditionText.slice(start));return parts}function evaluateLogicalContainerCondition(conditionText,width,remSize,inlineSize){if(!isFullyParsedContainerCondition(conditionText))return false;return evaluateParsedLogicalContainerCondition(conditionText,width,remSize,inlineSize)}function evaluateParsedLogicalContainerCondition(conditionText,width,remSize,inlineSize){const orParts=splitTopLevel(conditionText,"or");if(orParts.length>1)return orParts.some((part)=>evaluateParsedLogicalContainerCondition(part,width,remSize,inlineSize));const andParts=splitTopLevel(conditionText,"and");if(andParts.length>1)return andParts.every((part)=>evaluateParsedLogicalContainerCondition(part,width,remSize,inlineSize));const trimmed=conditionText.trim();const unwrapped=unwrapRedundantParentheses(trimmed);if(unwrapped!==trimmed)return evaluateParsedLogicalContainerCondition(unwrapped,width,remSize,inlineSize);const notPrefix=/^not\s+/i.exec(trimmed);if(notPrefix)return!evaluateParsedLogicalContainerCondition(trimmed.slice(notPrefix[0].length),width,remSize,inlineSize);return evaluateContainerSizeConstraints(trimmed,width,remSize,inlineSize)}var containerSizeTermPattern=/^(?:(?:min|max)-(?:width|inline-size)|(?:width|inline-size))\s*:\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;var featureFirstRangePattern=/^(?:width|inline-size)\s*(?:>=|>|<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;var valueFirstRangePattern=/^(?:(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:<=|<)\s*(?:width|inline-size))(?:\s*(?:<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?|(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:>=|>)\s*(?:width|inline-size))(?:\s*(?:>=|>)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?)$/i;function isFullyParsedContainerCondition(conditionText){const trimmed=conditionText.trim();if(!trimmed||!hasBalancedParentheses(trimmed))return false;return parseContainerCondition(trimmed)}function parseContainerCondition(conditionText,isTopLevelCondition=true){const original=conditionText.trim();const trimmed=unwrapRedundantParentheses(original);const wasGrouped=trimmed!==original;const orParts=splitTopLevel(trimmed,"or");const andParts=splitTopLevel(trimmed,"and");if(orParts.length>1&&andParts.length>1)return false;if(orParts.length>1)return orParts.every((part)=>parseContainerCondition(part,false));if(andParts.length>1)return andParts.every((part)=>parseContainerCondition(part,false));const notPrefix=/^not\s+/i.exec(trimmed);if(notPrefix){if(!isTopLevelCondition&&!wasGrouped)return false;const operand=trimmed.slice(notPrefix[0].length).trim();const unwrappedOperand=unwrapRedundantParentheses(operand);return unwrappedOperand!==operand&&parseContainerCondition(operand)}return wasGrouped&&(containerSizeTermPattern.test(trimmed)||featureFirstRangePattern.test(trimmed)||valueFirstRangePattern.test(trimmed))}function hasBalancedParentheses(conditionText){let depth=0;for(const character of conditionText){if(character==="(")depth+=1;if(character===")"){depth-=1;if(depth<0)return false}}return depth===0}function unwrapRedundantParentheses(conditionText){const trimmed=conditionText.trim();if(!trimmed.startsWith("(")||!trimmed.endsWith(")"))return trimmed;const matchingClose=new Map;const openPositions=[];let depth=0;for(let index=0;index<trimmed.length;index+=1){if(trimmed[index]==="("){openPositions.push(index);depth+=1}else if(trimmed[index]===")"){const open=openPositions.pop();if(open===undefined)return trimmed;matchingClose.set(open,index);depth-=1}}if(depth!==0)return trimmed;let start=0;let end=trimmed.length-1;while(start<end&&matchingClose.get(start)===end){start+=1;end-=1;while(/\s/.test(trimmed[start]??""))start+=1;while(/\s/.test(trimmed[end]??""))end-=1}return start===0?trimmed:trimmed.slice(start,end+1).trim()}function hasUnsupportedContainerSizeQuery(conditionText){if(/(?:min-|max-)?(?:height|block-size)\b/i.test(conditionText))return true;if(/\baspect-ratio\b/i.test(conditionText))return true;if(/\borientation\s*:/i.test(conditionText))return true;const featureFirstUnitMatches=conditionText.matchAll(/(?:min-|max-)?(?:width|inline-size)\s*(?:>=|>|<=|<|:)\s*[\d.]+([a-z%]+)/gi);const valueFirstUnitMatches=conditionText.matchAll(/[\d.]+([a-z%]+)\s*(?:>=|>|<=|<)\s*(?:width|inline-size)/gi);return[...featureFirstUnitMatches,...valueFirstUnitMatches].some((match)=>!/^(?:px|rem)$/i.test(match[1]))}function evaluateRangeComparisons(conditionText,width,remSize){const featureFirstPattern=/(?:width|inline-size)\s*(>=|>|<=|<)\s*([\d.]+)(px|rem)/gi;const valueFirstPattern=/([\d.]+)(px|rem)\s*(<=|<|>=|>)\s*(width|inline-size)/gi;const comparisons=[];for(const comparison of conditionText.matchAll(featureFirstPattern)){const operator=comparison[1];const threshold=comparison[2];const unit=comparison[3];if(operator&&threshold&&unit)comparisons.push({operator,threshold,unit})}for(const comparison of conditionText.matchAll(valueFirstPattern)){const threshold=comparison[1];const unit=comparison[2];const operator=comparison[3]==="<="?">=":comparison[3]==="<"?">":comparison[3]===">="?"<=":"<";if(threshold&&unit)comparisons.push({operator,threshold,unit})}if(comparisons.length===0)return;const satisfiesAll=comparisons.every((comparison)=>{const{operator}=comparison;const threshold=Number(comparison.threshold)*(comparison.unit.toLowerCase()==="rem"?remSize:1);if(operator===">=")return width>=threshold;if(operator===">")return width>threshold;if(operator==="<=")return width<=threshold;return width<threshold});return satisfiesAll}function evaluateEqualityComparison(conditionText,width,remSize){const equalityPattern=/(?:^|[\s(])(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/gi;const comparisons=[...conditionText.matchAll(equalityPattern)];if(comparisons.length===0)return;const satisfiesAll=comparisons.every((comparison)=>{const threshold=Number(comparison[1])*(comparison[2].toLowerCase()==="rem"?remSize:1);return width===threshold});return satisfiesAll}function evaluateContainerSizeConstraints(conditionText,width,remSize,inlineSize=width){const measuredSize=/\binline-size\b/i.test(conditionText)&&!/\bwidth\b/i.test(conditionText)?inlineSize:width;if(/\bwidth\b/i.test(conditionText)&&/\binline-size\b/i.test(conditionText)&&/\band\b/i.test(conditionText)){return conditionText.split(/\s+and\s+/i).every((clause)=>evaluateContainerSizeConstraints(clause,/\binline-size\b/i.test(clause)?inlineSize:width,remSize,inlineSize))}const minimum=/min-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);const maximum=/max-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);const toPixels=(value)=>Number(value[1])*(value[2].toLowerCase()==="rem"?remSize:1);const legacyMatches=(!minimum||measuredSize>=toPixels(minimum))&&(!maximum||measuredSize<=toPixels(maximum));const rangeMatches=evaluateRangeComparisons(conditionText,measuredSize,remSize)??true;const equalityMatches=evaluateEqualityComparison(conditionText,measuredSize,remSize)??true;const hasSizeFeature=/\b(?:width|inline-size)\b/i.test(conditionText);const hasRecognizedRange=/(?:width|inline-size)\s*(?:>=|>|<=|<)\s*[\d.]+(?:px|rem)/i.test(conditionText)||/[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*(?:width|inline-size)/i.test(conditionText);const hasRecognizedEquality=/(?:width|inline-size)\s*:\s*[\d.]+(?:px|rem)/i.test(conditionText);if(hasSizeFeature&&!minimum&&!maximum&&!hasRecognizedRange&&!hasRecognizedEquality)return false;const combinedMatches=legacyMatches&&rangeMatches&&equalityMatches;return/^\s*not\b/i.test(conditionText)?!combinedMatches:combinedMatches}var sheetIndex=new WeakMap;function resetDirectionStyleSheetIndex(){sheetIndex=new WeakMap}function styleSheetDeclaresDirection(sheet){let rules;try{rules=sheet.cssRules}catch{return true}const cached=sheetIndex.get(sheet);if(cached!==undefined&&cached.ruleCount===rules.length)return cached.declaresDirection;const isConstructed=Reflect.get(sheet,"ownerNode")==null;const scan={declaresDirection:false,cacheable:!isConstructed};scanRuleList(rules,scan);if(scan.cacheable||scan.declaresDirection){sheetIndex.set(sheet,{ruleCount:rules.length,declaresDirection:scan.declaresDirection})}else{sheetIndex.delete(sheet)}return scan.declaresDirection}function scanRuleList(rules,state){for(const rule of Array.from(rules)){if(state.declaresDirection)return;if(Reflect.get(rule,"type")===3){state.cacheable=false;const imported=Reflect.get(rule,"styleSheet");if(imported){try{const importedRules=Reflect.get(imported,"cssRules");if(isRuleCollection(importedRules))scanRuleList(importedRules,state)}catch{state.declaresDirection=true}}continue}const style=Reflect.get(rule,"style");if(typeof style==="object"&&style!==null&&typeof Reflect.get(rule,"selectorText")==="string"&&Boolean(Reflect.get(style,"direction"))){state.declaresDirection=true;return}if(!("cssRules"in rule))continue;try{const nested=Reflect.get(rule,"cssRules");if(isRuleCollection(nested))scanRuleList(nested,state)}catch{state.declaresDirection=true;return}}}function isRuleCollection(value){if(typeof CSSRuleList!=="undefined"&&value instanceof CSSRuleList)return true;if(Array.isArray(value))return true;if(typeof value!=="object"||value===null)return false;return typeof Reflect.get(value,Symbol.iterator)==="function"}function matchesDirectionStyleRule(element,getParentElement){const styleSheets=new Map;for(const sheet of Array.from(element.ownerDocument.styleSheets))styleSheets.set(sheet,null);for(const sheet of Array.from(element.ownerDocument.adoptedStyleSheets??[]))styleSheets.set(sheet,null);const root=element.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot){for(const sheet of root.adoptedStyleSheets)styleSheets.set(sheet,root);for(const styleElement of root.querySelectorAll("style")){if(styleElement.sheet)styleSheets.set(styleElement.sheet,root)}for(const linkElement of root.querySelectorAll('link[rel~="stylesheet"]')){if(linkElement.sheet)styleSheets.set(linkElement.sheet,root)}}for(const[sheet,fallbackRoot]of styleSheets){if(!isActiveStyleSheet(sheet))continue;if(!styleSheetDeclaresDirection(sheet))continue;let rules;try{rules=sheet.cssRules}catch{continue}if(matchesDirectionStyleRuleList(element,rules,getParentElement,[],getImplicitScopeRoot(sheet,fallbackRoot,element.ownerDocument.documentElement)))return true}return false}function isActiveStyleSheet(sheet){if(sheet.disabled)return false;const mediaText=sheet.media?.mediaText;if(!mediaText)return true;if(typeof matchMedia!=="function")return true;return matchMedia(mediaText).matches}function getImplicitScopeRoot(sheet,fallbackRoot,documentRoot){const ownerNode=Reflect.get(sheet,"ownerNode");if(!(ownerNode instanceof Element)||ownerNode.localName?.toLowerCase()!=="style"){return typeof ShadowRoot!=="undefined"&&fallbackRoot instanceof ShadowRoot?fallbackRoot:documentRoot}if(ownerNode.parentElement)return ownerNode.parentElement;const root=ownerNode.getRootNode();return typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?root:typeof ShadowRoot!=="undefined"&&fallbackRoot instanceof ShadowRoot?fallbackRoot:null}function matchesDirectionStyleRuleCached(element,cache,getParentElement){if(!getParentElement)return false;if(!cache)return matchesDirectionStyleRule(element,getParentElement);const cached=cache.get(element);if(cached!==undefined)return cached;const matched=matchesDirectionStyleRule(element,getParentElement);cache.set(element,matched);return matched}function matchesDirectionStyleRuleList(element,rules,getParentElement,scopes=[],implicitScopeRoot=null){for(const rule of Array.from(rules)){if(Reflect.get(rule,"type")===3){const imported=Reflect.get(rule,"styleSheet");if(imported){try{const importedRules=Reflect.get(imported,"cssRules");if(isCssRuleCollection(importedRules)&&matchesDirectionStyleRuleList(element,importedRules,getParentElement,scopes,implicitScopeRoot))return true}catch{}}continue}if(isCssStyleRule(rule)){if(!rule.style.direction){const nestedRules2=readNestedCssRules(rule);if(nestedRules2&&matchesDirectionStyleRuleList(element,nestedRules2,getParentElement,scopes,implicitScopeRoot))return true;continue}try{const selectorText=resolveNestedSelector(rule);if(selectorText&&matchesScopedSelector(element,selectorText,scopes))return true}catch{continue}}const nestedRules=readNestedCssRules(rule);if(isScopeRule(rule)){const scope=createActiveScope(rule,element,scopes,implicitScopeRoot);if(scope&&nestedRules){if(matchesDirectionStyleRuleList(element,nestedRules,getParentElement,[...scopes,scope],implicitScopeRoot))return true}continue}if(nestedRules&&isConditionalRuleActive(rule,element,getParentElement)&&matchesDirectionStyleRuleList(element,nestedRules,getParentElement,scopes,implicitScopeRoot)){return true}}return false}function readNestedCssRules(rule){if(!("cssRules"in rule))return;try{const nestedRules=Reflect.get(rule,"cssRules");return isCssRuleCollection(nestedRules)?nestedRules:undefined}catch{return}}function isCssRuleCollection(value){if(typeof CSSRuleList!=="undefined"&&value instanceof CSSRuleList)return true;if(Array.isArray(value))return value.every(isCssRule);if(typeof value!=="object"||value===null)return false;const iterator=Reflect.get(value,Symbol.iterator);return typeof iterator==="function"}function isCssRule(value){return typeof value==="object"&&value!==null&&typeof Reflect.get(value,"cssText")==="string"&&typeof Reflect.get(value,"type")==="number"}function isCssStyleRule(rule){return typeof Reflect.get(rule,"selectorText")==="string"&&typeof Reflect.get(rule,"style")==="object"&&Reflect.get(rule,"style")!==null}function resolveNestedSelector(rule){let selector=rule.selectorText.trim();let parentRule=Reflect.get(rule,"parentRule");while(parentRule){if(isCssStyleRule(parentRule)){const parentSelector=parentRule.selectorText.trim();if(!parentSelector)return;selector=combineNestedSelectors(parentSelector,selector);if(!selector)return}parentRule=Reflect.get(parentRule,"parentRule")}return selector}function combineNestedSelectors(parentSelector,nestedSelector){const parentContext=splitSelectorList(parentSelector).length>1?`:is(${parentSelector})`:parentSelector;return splitSelectorList(nestedSelector).map((selector)=>{const resolved=replaceNestingReferences(selector,parentContext);return resolved.replaced?resolved.selector:`${parentContext} ${selector}`}).join(", ")}function replaceNestingReferences(selector,parentContext){let quote;let replaced=false;let resolved="";for(let index=0;index<selector.length;index+=1){const character=selector[index];if(character==="\\"){resolved+=character;if(index+1<selector.length)resolved+=selector[++index];continue}if(quote!==undefined){resolved+=character;if(character===quote)quote=undefined;continue}if(character==='"'||character==="'"){quote=character;resolved+=character;continue}if(character==="&"){resolved+=parentContext;replaced=true;continue}resolved+=character}return{selector:resolved,replaced}}function splitSelectorList(selectorText){const selectors=[];let parenthesesDepth=0;let bracketDepth=0;let quote;let start=0;for(let index=0;index<selectorText.length;index+=1){const character=selectorText[index];if(character==="\\"){index+=1;continue}if(quote!==undefined){if(character===quote)quote=undefined;continue}if(character==='"'||character==="'"){quote=character;continue}if(character==="(")parenthesesDepth+=1;if(character===")")parenthesesDepth=Math.max(0,parenthesesDepth-1);if(character==="[")bracketDepth+=1;if(character==="]")bracketDepth=Math.max(0,bracketDepth-1);if(character===","&&parenthesesDepth===0&&bracketDepth===0){const selector2=selectorText.slice(start,index).trim();if(selector2)selectors.push(selector2);start=index+1}}const selector=selectorText.slice(start).trim();if(selector)selectors.push(selector);return selectors}function isConditionalRuleActive(rule,element,getParentElement){const conditionText=Reflect.get(rule,"conditionText");if(typeof conditionText!=="string"||!conditionText.trim())return true;if(isContainerRule(rule))return isContainerQueryActive(conditionText,element,rule,getParentElement);if(isMediaRule(rule)&&typeof matchMedia==="function"){return matchMedia(conditionText).matches}if(isSupportsRule(rule)&&typeof CSS!=="undefined"&&typeof CSS.supports==="function")return CSS.supports(conditionText);return true}function isScopeRule(rule){if(rule.constructor.name==="CSSScopeRule")return true;const cssText=Reflect.get(rule,"cssText");return typeof cssText==="string"&&/^\s*@scope\b/i.test(cssText)}function createActiveScope(rule,element,parentScopes,implicitScopeRoot){const cssText=Reflect.get(rule,"cssText");if(typeof cssText!=="string")return null;const prelude=parseScopePrelude(cssText);if(!prelude)return null;const roots=findActiveScopeRoots(element,prelude,parentScopes,implicitScopeRoot);return roots===null?null:{roots}}function scopePseudoRootCandidates(parentScopes,implicitScopeRoot){if(parentScopes.length>0)return parentScopes.at(-1).roots;return implicitScopeRoot?[implicitScopeRoot]:[]}function findActiveScopeRoots(element,prelude,parentScopes,implicitScopeRoot){if(!selectorsAreValid(element,prelude.rootSelectors))return null;if(prelude.limitSelectors&&!selectorsAreValid(element,prelude.limitSelectors))return null;if(prelude.rootSelectors.length===0){const candidates=scopePseudoRootCandidates(parentScopes,implicitScopeRoot);const roots2=candidates.length>0?candidates:[implicitScopeRoot??element.ownerDocument.documentElement];return finalizeActiveScopeRoots(roots2.filter((root)=>root.contains(element)),element,prelude,parentScopes)}const scopeRootSelectors=prelude.rootSelectors.filter(hasScopePseudoClass);const ordinaryRootSelectors=prelude.rootSelectors.filter((selector)=>!hasScopePseudoClass(selector));const scopeRootCandidates=scopePseudoRootCandidates(parentScopes,implicitScopeRoot);const roots=[...findRelativeScopeRootMatches(element,scopeRootSelectors,scopeRootCandidates),...findScopeMatches(element,ordinaryRootSelectors)];return finalizeActiveScopeRoots(roots,element,prelude,parentScopes)}function findRelativeScopeRootMatches(element,selectors,scopeRootCandidates){if(selectors.length===0||scopeRootCandidates.length===0)return[];const parentScope={roots:[...scopeRootCandidates]};const hasExactScopeSelector=selectors.some(isExactScopeSelector);const matches=[];let current=element;while(current){const currentElement=current;if(selectors.some((selector)=>matchesScopedSelector(currentElement,selector,[parentScope])))matches.push(currentElement);const parent=currentElement.parentElement;if(parent){current=parent;continue}const root=currentElement.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&hasExactScopeSelector&&scopeRootCandidates.includes(root))matches.push(root);current=null}return matches}function isExactScopeSelector(selector){return selector.trim().toLowerCase()===":scope"}function finalizeActiveScopeRoots(roots,element,prelude,parentScopes){const activeRoots=[];for(const root of roots){if(!isWithinParentScopes(root,parentScopes))continue;if(prelude.limitSelectors&&isWithinScopeLimit(element,root,prelude.limitSelectors)){continue}activeRoots.push(root)}return activeRoots.length===0?null:activeRoots}function selectorsAreValid(element,selectors){try{for(const selector of selectors)element.matches(selector);return true}catch{return false}}function isWithinParentScopes(root,parentScopes){return parentScopes.every((scope)=>scope.roots.some((parentRoot)=>parentRoot.contains(root)))}function isWithinScopeLimit(element,root,limitSelectors){let current=element;while(current){if(current===root)break;if(limitSelectors.some((selector)=>hasScopePseudoClass(selector)?matchesScopedSelector(current,selector,[{roots:[root]}]):matchesSelectorSafely(current,selector)))return true;current=current.parentElement}return false}function matchesSelectorSafely(element,selector){try{return element.matches(selector)}catch{return false}}function normalizeScopeRelativeSelector(selector){return splitSelectorList(selector).map((part)=>{if(!part.includes("&")&&!/^\s*[>+~]/.test(part))return part;const withScopeAlias=replaceNestingReferences(part,":scope").selector;return/^\s*[>+~]/.test(withScopeAlias)?`:scope ${withScopeAlias}`:withScopeAlias}).join(", ")}function matchesScopedSelector(element,selector,scopes){const normalizedSelector=scopes.length>0?normalizeScopeRelativeSelector(selector):selector;return splitSelectorList(normalizedSelector).some((item)=>matchesScopedSelectorItem(element,item,scopes))}function matchesScopedSelectorItem(element,selector,scopes){if(!hasScopePseudoClass(selector))return matchesSelectorSafely(element,selector);if(scopes.length===0)return false;const scope=scopes.at(-1);if(!scope)return false;const outsideContext=splitScopeOutsideContext(selector);const remainderSelector=outsideContext?outsideContext.remainder:selector;for(const root of scope.roots){try{if(outsideContext){if(!(root instanceof Element))continue;if(!matchesOutsideScopeContext(root,outsideContext.before,outsideContext.combinator))continue}if(matchesRemainderAgainstScopeRoot(element,remainderSelector,root))return true}catch{}}return false}function splitScopeOutsideContext(selector){const scopeIndex=findScopePseudoClassIndex(selector,{topLevelOnly:true});if(scopeIndex===null)return null;const beforeRaw=selector.slice(0,scopeIndex);if(!beforeRaw.trim())return null;const trimmedEnd=beforeRaw.replace(/\s+$/,"");const lastCharacter=trimmedEnd.at(-1);if(lastCharacter===">"||lastCharacter==="+"||lastCharacter==="~"){const before2=trimmedEnd.slice(0,-1).trim();return before2?{before:before2,combinator:lastCharacter,remainder:selector.slice(scopeIndex)}:null}if(!/\s$/.test(beforeRaw))return null;const before=trimmedEnd.trim();return before?{before,combinator:" ",remainder:selector.slice(scopeIndex)}:null}function matchesOutsideScopeContext(root,before,combinator){if(combinator===" ")return root.parentElement?.closest(before)!=null;if(combinator===">")return root.parentElement!==null&&matchesSelectorSafely(root.parentElement,before);if(combinator==="+"){const sibling2=root.previousElementSibling;return sibling2!==null&&matchesSelectorSafely(sibling2,before)}let sibling=root.previousElementSibling;while(sibling){if(matchesSelectorSafely(sibling,before))return true;sibling=sibling.previousElementSibling}return false}function matchesRemainderAgainstScopeRoot(element,selector,root){if(root.querySelector(":scope")===root){return Array.from(root.querySelectorAll(selector)).includes(element)}const clone=typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?null:root.cloneNode(true);const cloneElement=clone instanceof Element?clone:typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?(()=>{const wrapper=root.ownerDocument.createElement("div");wrapper.append(...Array.from(root.children,(child)=>child.cloneNode(true)));return wrapper})():null;if(!cloneElement)return false;const marker="data-cinder-scope-root";const replacedSelector=replaceScopePseudoClass(selector,`[${marker}]`);if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&/^\[[^\]]+\][^\s>+~]/.test(replacedSelector))return false;cloneElement.setAttribute(marker,"true");const path=[];let current=element;while(current&&current!==root){const parent=current.parentElement;if(!parent){if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&current.getRootNode()===root)path.unshift(Array.prototype.indexOf.call(root.children,current));break}path.unshift(Array.prototype.indexOf.call(parent.children,current));current=parent}if(current!==root&&!(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&current?.getRootNode()===root))return false;let matchedCloneElement=cloneElement;for(const index of path){const child=matchedCloneElement.children[index];if(!child)break;matchedCloneElement=child}return matchedCloneElement===cloneElement&&cloneElement.matches(replacedSelector)||Array.from(cloneElement.querySelectorAll(replacedSelector)).includes(matchedCloneElement)}function replaceScopePseudoClass(selector,replacement){let result="";let quote=null;let escaped=false;let brackets=0;for(let index=0;index<selector.length;index+=1){const character=selector[index];if(escaped){result+=character;escaped=false;continue}if(character==="\\"){result+=character;escaped=true;continue}if(quote){result+=character;if(character===quote)quote=null;continue}if(character==='"'||character==="'"){result+=character;quote=character;continue}if(character==="["){brackets+=1;result+=character;continue}if(character==="]"){brackets=Math.max(0,brackets-1);result+=character;continue}if(brackets===0&&character===":"&&selector.slice(index+1,index+6).toLowerCase()==="scope"&&!/[\w-]/.test(selector[index+6]??"")){result+=replacement;index+=5;continue}result+=character}return result}function findScopePseudoClassIndex(selector,options={}){let quote=null;let brackets=0;let parentheses=0;let escaped=false;for(let index=0;index<selector.length;index+=1){const character=selector[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'"){quote=character;continue}if(character==="["){brackets+=1;continue}if(character==="]"){brackets=Math.max(0,brackets-1);continue}if(character==="("){parentheses+=1;continue}if(character===")"){parentheses=Math.max(0,parentheses-1);continue}if(brackets===0&&(!options.topLevelOnly||parentheses===0)&&character===":"&&selector.slice(index+1,index+6).toLowerCase()==="scope"&&!/[\w-]/.test(selector[index+6]??""))return index}return null}function hasScopePseudoClass(selector){return findScopePseudoClassIndex(selector)!==null}function parseScopePrelude(cssText){const match=/^\s*@scope\b/i.exec(cssText);if(!match)return null;const start=match[0].length;let quote=null;let escaped=false;let parentheses=0;let brackets=0;let end=-1;for(let index=start;index<cssText.length;index+=1){const character=cssText[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character==="{"&&parentheses===0&&brackets===0){end=index;break}if(parentheses<0||brackets<0)return null}if(end<0||quote||escaped||parentheses!==0||brackets!==0)return null;const prelude=cssText.slice(start,end).trim();const limitIndex=findScopeLimitKeyword(prelude);const rootText=(limitIndex===null?prelude:prelude.slice(0,limitIndex)).trim();const limitText=limitIndex===null?null:prelude.slice(limitIndex+2).trim();const rootSelectorText=unwrapScopeGroup(rootText);if(rootSelectorText===null)return null;const rootSelectors=rootSelectorText?splitScopeSelectors(rootSelectorText):[];if(rootSelectorText&&rootSelectors.length===0)return null;if(limitText===null)return{rootSelectors,limitSelectors:null};const limitSelectorText=unwrapScopeGroup(limitText);if(limitSelectorText===null||!limitSelectorText)return null;const limitSelectors=splitScopeSelectors(limitSelectorText);return limitSelectors.length>0?{rootSelectors,limitSelectors}:null}function findScopeLimitKeyword(prelude){let quote=null;let escaped=false;let parentheses=0;let brackets=0;for(let index=0;index<prelude.length;index+=1){const character=prelude[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;if(parentheses<0||brackets<0)return null;if(parentheses===0&&brackets===0&&prelude.slice(index,index+2).toLowerCase()==="to"&&!/[\w-]/.test(prelude[index-1]??"")&&!/[\w-]/.test(prelude[index+2]??"")){const remainder=prelude.slice(index+2);const opening=remainder.search(/\S/);if(opening>=0&&remainder[opening]==="(")return index}}return null}function unwrapScopeGroup(value){if(!value)return"";if(value[0]!=="(")return value;const end=findScopeGroupEnd(value);if(end<0||value.slice(end+1).trim())return null;return value.slice(1,end).trim()}function findScopeGroupEnd(value){let depth=0;let brackets=0;let quote=null;let escaped=false;for(let index=0;index<value.length;index+=1){const character=value[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character==="("&&brackets===0)depth+=1;else if(character===")"&&brackets===0){depth-=1;if(depth===0)return index}if(brackets<0)return-1}return-1}function findScopeMatches(element,selectors){if(selectors.length===0)return[];const matches=[];let current=element;while(current){const currentElement=current;if(selectors.some((selector)=>matchesSelectorSafely(currentElement,selector)))matches.push(currentElement);current=currentElement.parentElement}return matches}function splitScopeSelectors(value){const selectors=[];let parentheses=0;let brackets=0;let quote=null;let escaped=false;let start=0;for(let index=0;index<value.length;index+=1){const character=value[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character===","&&parentheses===0&&brackets===0){const selector2=value.slice(start,index).trim();if(!selector2)return[];selectors.push(selector2);start=index+1}if(parentheses<0||brackets<0)return[]}if(escaped||quote||parentheses!==0||brackets!==0)return[];const selector=value.slice(start).trim();if(!selector)return[];selectors.push(selector);return selectors}function resolveContainerQueryText(conditionText,rule,containerName){const containerQuery=Reflect.get(rule,"containerQuery");if(typeof containerQuery==="string")return containerQuery;if(typeof containerName!=="string"||!containerName)return conditionText;if(!conditionText.startsWith(containerName))return conditionText;const rest=conditionText.slice(containerName.length);if(!/^\s/.test(rest))return conditionText;return rest.trimStart()}function isContainerConditionList(value){if(!Array.isArray(value)||value.length===0)return false;return value.every((entry)=>typeof entry==="object"&&entry!==null&&typeof Reflect.get(entry,"name")==="string"&&typeof Reflect.get(entry,"query")==="string")}function isContainerQueryActive(conditionText,element,rule,getParentElement){if(typeof getComputedStyle!=="function")return false;const conditions=Reflect.get(rule,"conditions");if(isContainerConditionList(conditions))return conditions.some((condition)=>isSingleContainerConditionActive(condition.query,condition.name,element,getParentElement));const containerName=Reflect.get(rule,"containerName");const queryText=resolveContainerQueryText(conditionText,rule,containerName);return isSingleContainerConditionActive(queryText,containerName,element,getParentElement)}function isSingleContainerConditionActive(queryText,containerName,element,getParentElement){if(!queryText.trim())return false;const styleQuery=parseStyleQuery(queryText);if(styleQuery){const remainder=(queryText.slice(0,styleQuery.index)+queryText.slice(styleQuery.end)).replace(/^\s*(?:and|or|not)\b/i,"").replace(/^\(|\)$/g,"").trim();if(remainder)return false;let ancestor=getParentElement(element);while(ancestor){if(typeof containerName==="string"&&containerName){const computedStyle=getComputedStyle(ancestor);const name=computedStyle.containerName||computedStyle.getPropertyValue("container-name")||ancestor.style.containerName||ancestor.style.getPropertyValue("container-name");if(!name.split(/\s+/).includes(containerName)){ancestor=getParentElement(ancestor);continue}}const value=getComputedStyle(ancestor).getPropertyValue(styleQuery.name).trim()||ancestor.style.getPropertyValue(styleQuery.name).trim();return/^\s*not\b/i.test(queryText)?value!==styleQuery.value.trim():value===styleQuery.value.trim()}return false}const queriesPhysicalWidth=/(?:^|[\s(])(?:width|min-width|max-width)\s*[:<>=]/i.test(queryText)||/[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*width\b/i.test(queryText);let container=getParentElement(element);while(container){const computedStyle=getComputedStyle(container);const type=computedStyle.containerType||computedStyle.getPropertyValue("container-type")||container.style.containerType||container.style.getPropertyValue("container-type");const name=computedStyle.containerName||computedStyle.getPropertyValue("container-name")||container.style.containerName||container.style.getPropertyValue("container-name");const writingMode2=computedStyle.writingMode||computedStyle.getPropertyValue("writing-mode")||container.style.writingMode||container.style.getPropertyValue("writing-mode");if((typeof containerName!=="string"||!containerName||name.split(/\s+/).includes(containerName))&&type&&type!=="normal"&&!(queriesPhysicalWidth&&/^(?:vertical|sideways)-/i.test(writingMode2)&&type==="inline-size")){break}container=getParentElement(container)}if(!container)return false;const computedContainerStyle=getComputedStyle(container);const readInset=(property,fallbackProperty)=>{const camel=property.replace(/-([a-z])/g,(_,character)=>character.toUpperCase());const fallbackCamel=fallbackProperty.replace(/-([a-z])/g,(_,character)=>character.toUpperCase());const value=Reflect.get(computedContainerStyle,camel)||Reflect.get(container.style,camel)||computedContainerStyle.getPropertyValue(property).trim()||container.style.getPropertyValue(property).trim()||Reflect.get(computedContainerStyle,fallbackCamel)||Reflect.get(container.style,fallbackCamel)||computedContainerStyle.getPropertyValue(fallbackProperty).trim()||container.style.getPropertyValue(fallbackProperty).trim();const parsed=Number.parseFloat(value);return Number.isFinite(parsed)&&parsed>0?parsed:0};const writingMode=computedContainerStyle.writingMode||computedContainerStyle.getPropertyValue("writing-mode")||container.style.writingMode||container.style.getPropertyValue("writing-mode");const usesInlineSize=/(?:inline-size|min-inline-size|max-inline-size)/i.test(queryText);const isVerticalWritingMode=/^(?:vertical|sideways)-/i.test(writingMode);const verticalInlineAxis=usesInlineSize&&isVerticalWritingMode;const physicalInsets=readInset("padding-left","padding-inline-start")+readInset("padding-right","padding-inline-end");const physicalBorders=readInset("border-left-width","border-inline-start-width")+readInset("border-right-width","border-inline-end-width");const inlineInsets=verticalInlineAxis?readInset("padding-inline-start","padding-top")+readInset("padding-inline-end","padding-bottom"):physicalInsets;const inlineBorders=verticalInlineAxis?readInset("border-inline-start-width","border-top-width")+readInset("border-inline-end-width","border-bottom-width"):physicalBorders;const readUsedContentSize=(axis,fallback,insets,borders)=>{const parsed=Number.parseFloat(computedContainerStyle[axis]);if(!Number.isFinite(parsed))return fallback;const boxSizing=computedContainerStyle.boxSizing||container.style.boxSizing;return boxSizing==="border-box"?Math.max(0,parsed-insets-borders):parsed};const physicalClientSize=container.clientWidth;const inlineClientSize=verticalInlineAxis?container.clientHeight:physicalClientSize;const width=Math.max(0,readUsedContentSize("width",physicalClientSize>0?physicalClientSize-physicalInsets:container.offsetWidth-physicalBorders-physicalInsets,physicalInsets,physicalBorders));const inlineSize=Math.max(0,readUsedContentSize(verticalInlineAxis?"height":"width",inlineClientSize>0?inlineClientSize-inlineInsets:(verticalInlineAxis?container.offsetHeight:container.offsetWidth)-inlineBorders-inlineInsets,inlineInsets,inlineBorders));const rootFontSize=Number.parseFloat(getComputedStyle(element.ownerDocument.documentElement).fontSize);const remSize=Number.isFinite(rootFontSize)&&rootFontSize>0?rootFontSize:16;if(hasUnsupportedContainerSizeQuery(queryText))return false;return evaluateLogicalContainerCondition(queryText,width,remSize,inlineSize)}function isContainerRule(rule){if(rule.constructor.name==="CSSContainerRule")return true;if(Reflect.get(rule,"type")!==0)return false;const cssText=Reflect.get(rule,"cssText");return typeof cssText==="string"&&/^\s*@container\b/i.test(cssText)}function isMediaRule(rule){return typeof Reflect.get(rule,"media")==="object"&&Reflect.get(rule,"media")!==null}function isSupportsRule(rule){return rule.constructor.name==="CSSSupportsRule"||Reflect.get(rule,"type")===12}function observeTextDirectionMediaQueries(element,onChange){if(!element||typeof matchMedia!=="function")return;const sheets=new Set(Array.from(element.ownerDocument.styleSheets));for(const sheet of element.ownerDocument.adoptedStyleSheets??[])sheets.add(sheet);const root=element.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot){for(const sheet of root.adoptedStyleSheets)sheets.add(sheet);for(const style of root.querySelectorAll('style,link[rel~="stylesheet"]')){const sheet=style.sheet;if(sheet)sheets.add(sheet)}}const queries=new Set;const visitedSheets=new Set;const visit=(rules)=>{for(const rule of Array.from(rules)){if(Reflect.get(rule,"type")===3){try{const media=Reflect.get(rule,"media");const condition=media&&Reflect.get(media,"mediaText");if(typeof condition==="string"&&condition)queries.add(condition)}catch{}let imported;try{imported=Reflect.get(rule,"styleSheet")}catch{continue}if(imported&&!visitedSheets.has(imported)){visitedSheets.add(imported);try{const importedRules=Reflect.get(imported,"cssRules");if(isCssRuleCollection(importedRules))visit(importedRules)}catch{}}continue}if(isMediaRule(rule)){const condition=Reflect.get(rule,"conditionText");if(typeof condition==="string"&&condition)queries.add(condition)}const nested=readNestedCssRules(rule);if(nested)visit(nested)}};for(const sheet of sheets){if(visitedSheets.has(sheet))continue;visitedSheets.add(sheet);try{visit(sheet.cssRules)}catch{}}const mediaQueries=[...queries].map((query)=>matchMedia(query));const handler=()=>onChange();for(const mediaQuery of mediaQueries)mediaQuery.addEventListener?.("change",handler);return()=>{for(const mediaQuery of mediaQueries)mediaQuery.removeEventListener?.("change",handler)}}function elementDirectionStyleOverride(element){if(!element)return;if(element.style.direction)return readComputedTextDirection(element);if(!matchesDirectionStyleRuleCached(element,undefined,composedParentElement))return;return readComputedTextDirection(element)}function resolveTextDirection(element,fallback,options){const ignoreElementDirectionAttribute=options?.ignoreElementDirectionAttribute??false;const directionStyleRuleCache=new WeakMap;if(ignoreElementDirectionAttribute&&element){const styledDirection=readComputedTextDirection(element);const rootComputedDirection2=readComputedTextDirection(element.ownerDocument.documentElement);const elementDirectionAttribute=element.getAttribute("dir")?.toLowerCase();const differsFromRootViaStyling=styledDirection!==rootComputedDirection2&&styledDirection!==elementDirectionAttribute;if(styledDirection&&(hasElementDirectionStylingHint(element,directionStyleRuleCache)||differsFromRootViaStyling))return styledDirection}let currentElement=ignoreElementDirectionAttribute?element?composedParentElement(element):null:element??null;let documentDirection;let styledDirectionElement=null;while(currentElement){if(!styledDirectionElement&&currentElement!==currentElement.ownerDocument.documentElement&&(Boolean(currentElement.style.direction)||matchesDirectionStyleRuleCached(currentElement,directionStyleRuleCache,composedParentElement))){styledDirectionElement=currentElement}const direction=currentElement.getAttribute("dir")?.toLowerCase();if(direction==="rtl"||direction==="ltr"){if(typeof getComputedStyle==="function"&&styledDirectionElement){const styledDirection2=getComputedStyle(styledDirectionElement).direction;if(styledDirection2==="rtl"||styledDirection2==="ltr")return styledDirection2}if(currentElement===currentElement.ownerDocument.documentElement){documentDirection=direction;break}return direction}if(direction==="auto"&&typeof getComputedStyle==="function"){const computedDirection2=getComputedStyle(currentElement).direction;if(computedDirection2==="rtl"||computedDirection2==="ltr")return computedDirection2}const styledDirection=currentElement.style.direction;if(!styledDirectionElement&&(styledDirection==="rtl"||styledDirection==="ltr")){styledDirectionElement=currentElement}currentElement=composedParentElement(currentElement)}if(typeof getComputedStyle==="function"&&styledDirectionElement){const direction=getComputedStyle(styledDirectionElement).direction;if(direction==="rtl"||direction==="ltr")return direction}const computedDirection=readComputedTextDirection(element);const rootComputedDirection=readComputedTextDirection(element?.ownerDocument.documentElement);if(!ignoreElementDirectionAttribute&&computedDirection&&computedDirection!==rootComputedDirection)return computedDirection;if(computedDirection&&fallback&&computedDirection!==fallback&&hasDirectionStylingHint(element,false,directionStyleRuleCache)){return computedDirection}if(!fallback&&computedDirection==="rtl")return computedDirection;if(fallback)return fallback;if(documentDirection)return documentDirection;return}function hasElementDirectionStylingHint(element,cache){return Boolean(element.style.direction)||matchesDirectionStyleRuleCached(element,cache,composedParentElement)}function readComputedTextDirection(element){if(!element||typeof getComputedStyle!=="function")return;const direction=getComputedStyle(element).direction;return direction==="rtl"||direction==="ltr"?direction:undefined}function hasDirectionStylingHint(element,includeElement=false,cache){let currentElement=includeElement?element:element?composedParentElement(element):null;while(currentElement&&currentElement!==currentElement.ownerDocument.documentElement){if(currentElement.style.direction)return true;if(matchesDirectionStyleRuleCached(currentElement,cache,composedParentElement))return true;currentElement=composedParentElement(currentElement)}return false}function composedParentElement(element){if(element.parentElement)return element.parentElement;const root=element.getRootNode();return typeof ShadowRoot!=="undefined"&&typeof HTMLElement!=="undefined"&&root instanceof ShadowRoot&&root.host instanceof HTMLElement?root.host:null}function isRightToLeftElement(element){return resolveTextDirection(element)==="rtl"}function observeTextDirection(element,onChange){if(!element||typeof MutationObserver==="undefined")return;const observedElement=element;const observer=new MutationObserver((mutations)=>{if(mutations.some((mutation)=>mutation.type==="attributes"&&mutation.attributeName==="dir"||mutation.type==="childList")){observeDirectionChain()}onChange()});function observeDirectionChain(){observer.disconnect();let currentElement=observedElement;while(currentElement){const isAutoDirection=currentElement.getAttribute("dir")?.toLowerCase()==="auto";observer.observe(currentElement,{attributes:true,childList:true,characterData:isAutoDirection,subtree:isAutoDirection});currentElement=composedParentElement(currentElement)}}observeDirectionChain();return()=>observer.disconnect()}function classNames(...parts){return parts.filter((part)=>typeof part==="string"&&part.length>0).join(" ")}import"svelte/internal/disclose-version";import*as $4 from"svelte/internal/client";import{tick}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $2 from"svelte/internal/client";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $ from"svelte/internal/client";var defaultAttributes={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var defaultAttributes_default=defaultAttributes;var root=$.from_svg(`<svg><!><!></svg>`);function Icon($$anchor,$$props){const $$sanitized_props=$.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const $$restProps=$.legacy_rest_props($$sanitized_props,["name","color","size","strokeWidth","absoluteStrokeWidth","iconNode"]);$.push($$props,false);let name=$.prop($$props,"name",8,undefined);let color=$.prop($$props,"color",8,"currentColor");let size=$.prop($$props,"size",8,24);let strokeWidth=$.prop($$props,"strokeWidth",8,2);let absoluteStrokeWidth=$.prop($$props,"absoluteStrokeWidth",8,false);let iconNode=$.prop($$props,"iconNode",24,()=>[]);const mergeClasses=(...classes)=>classes.filter((className,index2,array)=>{return Boolean(className)&&array.indexOf(className)===index2}).join(" ");$.init();var svg=root();$.attribute_effect(svg,($0,$1)=>({...defaultAttributes_default,...$$restProps,width:size(),height:size(),stroke:color(),"stroke-width":$0,class:$1}),[()=>($.deep_read_state(absoluteStrokeWidth()),$.deep_read_state(strokeWidth()),$.deep_read_state(size()),$.untrack(()=>absoluteStrokeWidth()?Number(strokeWidth())*24/Number(size()):strokeWidth())),()=>($.deep_read_state(name()),$.deep_read_state($$sanitized_props),$.untrack(()=>mergeClasses("lucide-icon","lucide",name()?`lucide-${name()}`:"",$$sanitized_props.class)))]);var node=$.child(svg);$.each(node,1,iconNode,$.index,($$anchor2,$$item)=>{var $$array=$.derived(()=>$.to_array($.get($$item),2));let tag=()=>$.get($$array)[0];let attrs=()=>$.get($$array)[1];var fragment=$.comment();var node_1=$.first_child(fragment);$.element(node_1,tag,true,($$element,$$anchor3)=>{$.attribute_effect($$element,()=>({...attrs()}))});$.append($$anchor2,fragment)});var node_2=$.sibling(node);$.slot(node_2,$$props,"default",{},null);$.reset(svg);$.append($$anchor,svg);$.pop()}function Chevron_left($$anchor,$$props){const $$sanitized_props=$2.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const iconNode=[["path",{d:"m15 18-6-6 6-6"}]];Icon($$anchor,$2.spread_props({name:"chevron-left"},()=>$$sanitized_props,{get iconNode(){return iconNode},children:($$anchor2,$$slotProps)=>{var fragment_1=$2.comment();var node=$2.first_child(fragment_1);$2.slot(node,$$props,"default",{},null);$2.append($$anchor2,fragment_1)},$$slots:{default:true}}))}import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $3 from"svelte/internal/client";function Chevron_right($$anchor,$$props){const $$sanitized_props=$3.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const iconNode=[["path",{d:"m9 18 6-6-6-6"}]];Icon($$anchor,$3.spread_props({name:"chevron-right"},()=>$$sanitized_props,{get iconNode(){return iconNode},children:($$anchor2,$$slotProps)=>{var fragment_1=$3.comment();var node=$3.first_child(fragment_1);$3.slot(node,$$props,"default",{},null);$3.append($$anchor2,fragment_1)},$$slots:{default:true}}))}var root2=$4.from_html(`<h3 class="cinder-mega-menu__section-title"> </h3>`);var root_1=$4.from_html(`<span class="cinder-mega-menu__link-description"> </span>`);var root_2=$4.from_html(`<li><a class="cinder-mega-menu__link"><span> </span> <!></a></li>`);var root_3=$4.from_html(`<section><!> <ul class="cinder-mega-menu__links"></ul></section>`);var root_4=$4.from_html(`<li><button type="button" class="cinder-mega-menu__submenu-trigger"> <!></button></li>`);var root_5=$4.from_html(`<h4 class="cinder-mega-menu__section-title"> </h4>`);var root_6=$4.from_html(`<div class="cinder-mega-menu__sections cinder-mega-menu__submenu-panel" role="group" tabindex="-1"></div>`);var root_7=$4.from_html(`<section class="cinder-mega-menu__sub"><ul class="cinder-mega-menu__submenu-list"></ul> <!></section>`);var root_8=$4.from_html(`<section class="cinder-mega-menu__content" role="group" tabindex="-1"><div class="cinder-mega-menu__sections"></div> <!></section>`);function Mega_menu_content($$anchor,$$props){$4.push($$props,true);let openSubmenuId=$4.state(null);const openSubmenu=$4.derived(()=>{if(!$$props.item.submenu?.length||!$4.get(openSubmenuId))return $$props.item.submenu?.[0]??null;return $$props.item.submenu.find((entry)=>entry.id===$4.get(openSubmenuId))??$$props.item.submenu[0]??null});function sections(menuItem){return menuItem?.sections??[]}function focusSubmenuTriggerAt(index2){if(!$$props.item.submenu?.length||typeof document==="undefined")return;const bounded=(index2%$$props.item.submenu.length+$$props.item.submenu.length)%$$props.item.submenu.length;const target=$$props.item.submenu[bounded];if(!target)return;$4.set(openSubmenuId,target.id,true);$$props.focusElementById($$props.submenuTriggerId($$props.item.id,target.id))}async function focusSubmenuPanel(submenuId){if(typeof document==="undefined")return;await tick();const panel=$$props.elementById($$props.submenuPanelId($$props.item.id,submenuId));if(!(panel instanceof HTMLElement))return;const firstFocusable=panel.querySelector("a[href], button:not([disabled])");(firstFocusable??panel).focus()}function submenuHorizontalKeys(){const isRightToLeft=$$props.resolvedDirection==="rtl";return isRightToLeft?{enter:"ArrowLeft",return:"ArrowRight"}:{enter:"ArrowRight",return:"ArrowLeft"}}function isModifiedHorizontalArrow(event2){return(event2.key==="ArrowLeft"||event2.key==="ArrowRight")&&(event2.altKey||event2.ctrlKey||event2.metaKey)}function onSubmenuChange(submenuId){$4.set(openSubmenuId,submenuId,true)}function onSubmenuTriggerKeydown(event2,index2){if(isModifiedHorizontalArrow(event2))return;if((event2.key==="Home"||event2.key==="End")&&(event2.altKey||event2.ctrlKey||event2.metaKey))return;const horizontalKeys=submenuHorizontalKeys();if(event2.key===horizontalKeys.enter){event2.preventDefault();if($$props.item.submenu?.[index2]){const submenuId=$$props.item.submenu[index2].id;$4.set(openSubmenuId,submenuId,true);focusSubmenuPanel(submenuId)}return}if(event2.key===horizontalKeys.return){event2.preventDefault();$$props.focusElementById($$props.triggerId($$props.item.id));return}switch(event2.key){case"ArrowDown":event2.preventDefault();focusSubmenuTriggerAt(index2+1);break;case"ArrowUp":event2.preventDefault();focusSubmenuTriggerAt(index2-1);break;case"Home":event2.preventDefault();focusSubmenuTriggerAt(0);break;case"End":event2.preventDefault();if($$props.item.submenu)focusSubmenuTriggerAt($$props.item.submenu.length-1);break;case"Enter":case" ":event2.preventDefault();if($$props.item.submenu?.[index2]){const submenuId=$$props.item.submenu[index2].id;$4.set(openSubmenuId,submenuId,true);focusSubmenuPanel(submenuId)}break;case"Escape":event2.preventDefault();$$props.closeMenu(true);break;default:break}}function onSubmenuPanelKeydown(event2){if(isModifiedHorizontalArrow(event2))return;if(event2.key===submenuHorizontalKeys().return&&$4.get(openSubmenu)){event2.preventDefault();event2.stopPropagation();$$props.focusElementById($$props.submenuTriggerId($$props.item.id,$4.get(openSubmenu).id));return}if(event2.key==="Escape"){event2.preventDefault();event2.stopPropagation();$$props.closeMenu(true)}}function onContentKeydown(event2){if(event2.key!=="Escape")return;event2.preventDefault();$$props.closeMenu(true)}var section_1=root_8();var div=$4.child(section_1);$4.each(div,21,()=>sections($$props.item),(section)=>section.id,($$anchor2,section)=>{var section_2=root_3();var node=$4.child(section_2);{var consequent=($$anchor3)=>{var h3=root2();var text=$4.child(h3,true);$4.reset(h3);$4.template_effect(()=>$4.set_text(text,$4.get(section).title));$4.append($$anchor3,h3)};$4.if(node,($$render)=>{if($4.get(section).title)$$render(consequent)})}var ul=$4.sibling(node,2);$4.each(ul,21,()=>$4.get(section).links,(link)=>link.id,($$anchor3,link)=>{var li=root_2();var a=$4.child(li);var span=$4.child(a);var text_1=$4.child(span,true);$4.reset(span);var node_1=$4.sibling(span,2);{var consequent_1=($$anchor4)=>{var span_1=root_1();var text_2=$4.child(span_1,true);$4.reset(span_1);$4.template_effect(()=>$4.set_text(text_2,$4.get(link).description));$4.append($$anchor4,span_1)};$4.if(node_1,($$render)=>{if($4.get(link).description)$$render(consequent_1)})}$4.reset(a);$4.reset(li);$4.template_effect(()=>{$4.set_attribute(a,"href",$4.get(link).href);$4.set_text(text_1,$4.get(link).label)});$4.append($$anchor3,li)});$4.reset(ul);$4.reset(section_2);$4.append($$anchor2,section_2)});$4.reset(div);var node_2=$4.sibling(div,2);{var consequent_6=($$anchor2)=>{var section_3=root_7();var ul_1=$4.child(section_3);$4.each(ul_1,23,()=>$$props.item.submenu,(sub)=>sub.id,($$anchor3,sub,subIndex)=>{var li_1=root_4();var button=$4.child(li_1);var text_3=$4.child(button);var node_3=$4.sibling(text_3);{var consequent_2=($$anchor4)=>{Chevron_left($$anchor4,{size:16,strokeWidth:2,"aria-hidden":"true"})};var alternate=($$anchor4)=>{Chevron_right($$anchor4,{size:16,strokeWidth:2,"aria-hidden":"true"})};$4.if(node_3,($$render)=>{if($$props.resolvedDirection==="rtl")$$render(consequent_2);else $$render(alternate,-1)})}$4.reset(button);$4.reset(li_1);$4.template_effect(($0,$1)=>{$4.set_attribute(button,"id",$0);$4.set_attribute(button,"aria-controls",$1);$4.set_attribute(button,"aria-expanded",$4.get(openSubmenu)?.id===$4.get(sub).id?"true":"false");$4.set_attribute(button,"data-active",$4.get(openSubmenu)?.id===$4.get(sub).id?"true":"false");$4.set_text(text_3,`${$4.get(sub).label??""} `)},[()=>$$props.submenuTriggerId($$props.item.id,$4.get(sub).id),()=>$4.get(openSubmenu)?.id===$4.get(sub).id?$$props.submenuPanelId($$props.item.id,$4.get(sub).id):undefined]);$4.event("mouseenter",button,()=>onSubmenuChange($4.get(sub).id));$4.delegated("click",button,()=>onSubmenuChange($4.get(sub).id));$4.event("focus",button,()=>onSubmenuChange($4.get(sub).id));$4.delegated("keydown",button,(event2)=>onSubmenuTriggerKeydown(event2,$4.get(subIndex)));$4.append($$anchor3,li_1)});$4.reset(ul_1);var node_4=$4.sibling(ul_1,2);{var consequent_5=($$anchor3)=>{var div_1=root_6();$4.each(div_1,21,()=>sections($4.get(openSubmenu)),(section)=>section.id,($$anchor4,section)=>{var section_4=root_3();var node_5=$4.child(section_4);{var consequent_3=($$anchor5)=>{var h4=root_5();var text_4=$4.child(h4,true);$4.reset(h4);$4.template_effect(()=>$4.set_text(text_4,$4.get(section).title));$4.append($$anchor5,h4)};$4.if(node_5,($$render)=>{if($4.get(section).title&&$4.get(section).title!==$4.get(openSubmenu).label)$$render(consequent_3)})}var ul_2=$4.sibling(node_5,2);$4.each(ul_2,21,()=>$4.get(section).links,(link)=>link.id,($$anchor5,link)=>{var li_2=root_2();var a_1=$4.child(li_2);var span_2=$4.child(a_1);var text_5=$4.child(span_2,true);$4.reset(span_2);var node_6=$4.sibling(span_2,2);{var consequent_4=($$anchor6)=>{var span_3=root_1();var text_6=$4.child(span_3,true);$4.reset(span_3);$4.template_effect(()=>$4.set_text(text_6,$4.get(link).description));$4.append($$anchor6,span_3)};$4.if(node_6,($$render)=>{if($4.get(link).description)$$render(consequent_4)})}$4.reset(a_1);$4.reset(li_2);$4.template_effect(()=>{$4.set_attribute(a_1,"href",$4.get(link).href);$4.set_text(text_5,$4.get(link).label)});$4.append($$anchor5,li_2)});$4.reset(ul_2);$4.reset(section_4);$4.append($$anchor4,section_4)});$4.reset(div_1);$4.template_effect(($0,$1)=>{$4.set_attribute(div_1,"id",$0);$4.set_attribute(div_1,"aria-labelledby",$1)},[()=>$$props.submenuPanelId($$props.item.id,$4.get(openSubmenu).id),()=>$$props.submenuTriggerId($$props.item.id,$4.get(openSubmenu).id)]);$4.delegated("keydown",div_1,onSubmenuPanelKeydown);$4.append($$anchor3,div_1)};$4.if(node_4,($$render)=>{if($4.get(openSubmenu))$$render(consequent_5)})}$4.reset(section_3);$4.template_effect(()=>$4.set_attribute(section_3,"aria-label",`${$$props.item.label} submenu`));$4.append($$anchor2,section_3)};$4.if(node_2,($$render)=>{if($$props.item.submenu&&$$props.item.submenu.length>0)$$render(consequent_6)})}$4.reset(section_1);$4.template_effect(($0,$1)=>{$4.set_attribute(section_1,"id",$0);$4.set_attribute(section_1,"aria-labelledby",$1);$4.set_attribute(section_1,"data-motion",$$props.motionDirection)},[()=>$$props.contentId($$props.item.id),()=>$$props.triggerId($$props.item.id)]);$4.delegated("keydown",section_1,onContentKeydown);$4.append($$anchor,section_1);$4.pop()}$4.delegate(["keydown","click"]);var rest_excludes=new Set(["$$slots","$$events","$$legacy","id","items","openOnHover","viewportVisible","indicatorVisible","label","dir","class"]);var root_12=$5.from_html(`<li><button type="button" class="cinder-mega-menu__trigger"> </button></li>`);var root_22=$5.from_html(`<div class="cinder-mega-menu__indicator-track" aria-hidden="true"><div class="cinder-mega-menu__indicator"></div></div>`);var root_32=$5.from_html(`<div><!></div>`);var root_42=$5.from_html(`<nav><ul class="cinder-mega-menu__list"></ul> <!> <!></nav>`);function Mega_menu($$anchor,$$props){const generatedId=$5.props_id();$5.push($$props,true);let openOnHover=$5.prop($$props,"openOnHover",3,false),viewportVisible=$5.prop($$props,"viewportVisible",3,true),indicatorVisible=$5.prop($$props,"indicatorVisible",3,true),label=$5.prop($$props,"label",3,"Main navigation"),rest=$5.rest_props($$props,rest_excludes);let navElement=$5.state(null);let directionRevision=$5.state(0);let directionChainRevision=$5.state(0);const localeContext=getLocaleContext();let openItemId=$5.state(null);let previousOpenIndex=$5.state(null);let indicatorStyle=$5.state("");let hoverOpenedId=$5.state(null);const directionElement=$5.derived(()=>$$props.dir==="auto"?$5.get(navElement):$5.get(navElement)?.parentElement??$5.get(navElement));const resolvedDirection=$5.derived(()=>{$5.get(directionRevision);if($$props.dir==="rtl"||$$props.dir==="ltr"){return elementDirectionStyleOverride($5.get(navElement))??$$props.dir}if($$props.dir==="auto"){return resolveTextDirection($5.get(navElement),localeContext?.direction)}return $5.get(navElement)?resolveTextDirection($5.get(navElement),localeContext?.direction,{ignoreElementDirectionAttribute:true}):resolveTextDirection($5.get(directionElement),localeContext?.direction)});const renderedDirection=$5.derived(()=>{$5.get(directionRevision);if($$props.dir==="auto"||$$props.dir==="rtl"||$$props.dir==="ltr"){return $$props.dir}return $5.get(navElement)?resolveTextDirection($5.get(navElement),localeContext?.direction,{ignoreElementDirectionAttribute:true})??null:localeContext?.direction??null});let pendingIndicatorFrame=null;function scheduleIndicatorRecompute(){if(pendingIndicatorFrame!==null)return;pendingIndicatorFrame=requestAnimationFrame(()=>{pendingIndicatorFrame=null;$5.set(directionRevision,$5.get(directionRevision)+1);if($5.get(openItemId)!==null)updateIndicator()})}$5.user_effect(()=>{return()=>{if(pendingIndicatorFrame===null)return;cancelAnimationFrame(pendingIndicatorFrame);pendingIndicatorFrame=null}});$5.user_effect(()=>{return observeTextDirection($5.get(navElement),()=>{$5.set(directionChainRevision,$5.get(directionChainRevision)+1);scheduleIndicatorRecompute()})});$5.user_effect(()=>observeTextDirectionMediaQueries($5.get(navElement),()=>{scheduleIndicatorRecompute()}));const openItem=$5.derived(()=>$$props.items.find((item)=>item.id===$5.get(openItemId))??null);const openIndex=$5.derived(()=>$5.get(openItemId)?$$props.items.findIndex((item)=>item.id===$5.get(openItemId)):-1);const motionDirection=$5.derived(()=>{if($5.get(openIndex)<0||$5.get(previousOpenIndex)===null||$5.get(previousOpenIndex)===$5.get(openIndex))return"none";const movingTowardEnd=$5.get(resolvedDirection)==="rtl"?$5.get(openIndex)<$5.get(previousOpenIndex):$5.get(openIndex)>$5.get(previousOpenIndex);return movingTowardEnd?"from-end":"from-start"});$5.user_effect(()=>{if(!$5.get(openItemId))return;if($$props.items.some((item)=>item.id===$5.get(openItemId)))return;closeMenu()});function safeDomId(value){return value.trim().replaceAll(/[^A-Za-z0-9_-]+/g,"-").replaceAll(/^-+|-+$/g,"")}function stableHash(value){return Array.from(value).map((character)=>(character.codePointAt(0)??0).toString(16).padStart(5,"0")).join("-")}const instanceId=$5.derived(()=>safeDomId($$props.id??generatedId)||safeDomId(generatedId)||"menu");function triggerId(itemId){const normalized=safeDomId(itemId)||"item";return`cinder-mega-menu-${$5.get(instanceId)}-trigger-${normalized}-${stableHash(itemId)}`}function contentId(itemId){const normalized=safeDomId(itemId)||"item";return`cinder-mega-menu-${$5.get(instanceId)}-content-${normalized}-${stableHash(itemId)}`}function submenuTriggerId(itemId,submenuId){const normalizedItem=safeDomId(itemId)||"item";const normalizedSubmenu=safeDomId(submenuId)||"submenu";return`cinder-mega-menu-${$5.get(instanceId)}-submenu-trigger-${normalizedItem}-${normalizedSubmenu}-${stableHash(`${itemId}:${submenuId}`)}`}function submenuPanelId(itemId,submenuId){const normalizedItem=safeDomId(itemId)||"item";const normalizedSubmenu=safeDomId(submenuId)||"submenu";return`cinder-mega-menu-${$5.get(instanceId)}-submenu-panel-${normalizedItem}-${normalizedSubmenu}-${stableHash(`${itemId}:${submenuId}`)}`}function menuRoot(){const root3=$5.get(navElement)?.getRootNode();if(!root3||!("activeElement"in root3)||!("querySelector"in root3))return null;return root3}function escapeIdForSelector(id){if(typeof CSS!=="undefined"&&typeof CSS.escape==="function")return CSS.escape(id);return id.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll(`
1
+ var __create=Object.create;var __getProtoOf=Object.getPrototypeOf;var __defProp=Object.defineProperty;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;function __accessProp(key){return this[key]}var __toESMCache_node;var __toESMCache_esm;var __toESM=(mod,isNodeMode,target)=>{var canCache=mod!=null&&typeof mod==="object";if(canCache){var cache=isNodeMode?__toESMCache_node??=new WeakMap:__toESMCache_esm??=new WeakMap;var cached=cache.get(mod);if(cached)return cached}target=mod!=null?__create(__getProtoOf(mod)):{};const to=isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target;if(mod&&typeof mod==="object"||typeof mod==="function"){for(let key of __getOwnPropNames(mod))if(!__hasOwnProp.call(to,key))__defProp(to,key,{get:__accessProp.bind(mod,key),enumerable:true})}if(canCache)cache.set(mod,to);return to};var __commonJS=(cb,mod)=>()=>(mod||cb((mod={exports:{}}).exports,mod),mod.exports);var __returnValue=(v)=>v;function __exportSetter(name,newValue){this[name]=__returnValue.bind(null,newValue)}var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true,configurable:true,set:__exportSetter.bind(all,name)})};var __esm=(fn,res)=>()=>(fn&&(res=fn(fn=0)),res);var __require=((x)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(x,{get:(a,b)=>(typeof require!=="undefined"?require:a)[b]}):x)(function(x){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+x+'" is not supported')});import"@lostgradient/cinder/mega-menu/styles";import"svelte/internal/disclose-version";import*as $5 from"svelte/internal/client";import{tick as tick2}from"svelte";import{createContext}from"svelte";function optionalContext(getStrict){return()=>{try{return getStrict()}catch{return}}}var[getLocaleContextStrict,setLocaleContextRaw]=createContext();function setLocaleContext(context){setLocaleContextRaw(context)}var getLocaleContext=optionalContext(getLocaleContextStrict);function parseStyleQuery(conditionText){const start=/style\(\s*(--[\w-]+)\s*:\s*/i.exec(conditionText);if(!start||!start[1])return;let depth=0;for(let index=start.index+start[0].length;index<conditionText.length;index+=1){const character=conditionText[index];if(character==="(")depth+=1;if(character===")"){if(depth===0)return{index:start.index,end:index+1,name:start[1],value:conditionText.slice(start.index+start[0].length,index)};depth-=1}}return}function splitTopLevel(conditionText,operator){const parts=[];let depth=0;let start=0;let index=0;while(index<conditionText.length){const character=conditionText[index];if(character==="("){depth+=1;index+=1;continue}if(character===")"){depth=Math.max(0,depth-1);index+=1;continue}if(depth===0&&conditionText.slice(index,index+operator.length).toLowerCase()===operator&&/\s/.test(conditionText[index-1]??"")&&/\s/.test(conditionText[index+operator.length]??"")){parts.push(conditionText.slice(start,index));index+=operator.length;start=index;continue}index+=1}parts.push(conditionText.slice(start));return parts}function evaluateLogicalContainerCondition(conditionText,width,remSize,inlineSize){if(!isFullyParsedContainerCondition(conditionText))return false;return evaluateParsedLogicalContainerCondition(conditionText,width,remSize,inlineSize)}function evaluateParsedLogicalContainerCondition(conditionText,width,remSize,inlineSize){const orParts=splitTopLevel(conditionText,"or");if(orParts.length>1)return orParts.some((part)=>evaluateParsedLogicalContainerCondition(part,width,remSize,inlineSize));const andParts=splitTopLevel(conditionText,"and");if(andParts.length>1)return andParts.every((part)=>evaluateParsedLogicalContainerCondition(part,width,remSize,inlineSize));const trimmed=conditionText.trim();const unwrapped=unwrapRedundantParentheses(trimmed);if(unwrapped!==trimmed)return evaluateParsedLogicalContainerCondition(unwrapped,width,remSize,inlineSize);const notPrefix=/^not\s+/i.exec(trimmed);if(notPrefix)return!evaluateParsedLogicalContainerCondition(trimmed.slice(notPrefix[0].length),width,remSize,inlineSize);return evaluateContainerSizeConstraints(trimmed,width,remSize,inlineSize)}var containerSizeTermPattern=/^(?:(?:min|max)-(?:width|inline-size)|(?:width|inline-size))\s*:\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;var featureFirstRangePattern=/^(?:width|inline-size)\s*(?:>=|>|<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)$/i;var valueFirstRangePattern=/^(?:(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:<=|<)\s*(?:width|inline-size))(?:\s*(?:<=|<)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?|(?:(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem)\s*(?:>=|>)\s*(?:width|inline-size))(?:\s*(?:>=|>)\s*(?:\d+(?:\.\d+)?|\.\d+)(?:px|rem))?)$/i;function isFullyParsedContainerCondition(conditionText){const trimmed=conditionText.trim();if(!trimmed||!hasBalancedParentheses(trimmed))return false;return parseContainerCondition(trimmed)}function parseContainerCondition(conditionText,isTopLevelCondition=true){const original=conditionText.trim();const trimmed=unwrapRedundantParentheses(original);const wasGrouped=trimmed!==original;const orParts=splitTopLevel(trimmed,"or");const andParts=splitTopLevel(trimmed,"and");if(orParts.length>1&&andParts.length>1)return false;if(orParts.length>1)return orParts.every((part)=>parseContainerCondition(part,false));if(andParts.length>1)return andParts.every((part)=>parseContainerCondition(part,false));const notPrefix=/^not\s+/i.exec(trimmed);if(notPrefix){if(!isTopLevelCondition&&!wasGrouped)return false;const operand=trimmed.slice(notPrefix[0].length).trim();const unwrappedOperand=unwrapRedundantParentheses(operand);return unwrappedOperand!==operand&&parseContainerCondition(operand)}return wasGrouped&&(containerSizeTermPattern.test(trimmed)||featureFirstRangePattern.test(trimmed)||valueFirstRangePattern.test(trimmed))}function hasBalancedParentheses(conditionText){let depth=0;for(const character of conditionText){if(character==="(")depth+=1;if(character===")"){depth-=1;if(depth<0)return false}}return depth===0}function unwrapRedundantParentheses(conditionText){const trimmed=conditionText.trim();if(!trimmed.startsWith("(")||!trimmed.endsWith(")"))return trimmed;const matchingClose=new Map;const openPositions=[];let depth=0;for(let index=0;index<trimmed.length;index+=1){if(trimmed[index]==="("){openPositions.push(index);depth+=1}else if(trimmed[index]===")"){const open=openPositions.pop();if(open===undefined)return trimmed;matchingClose.set(open,index);depth-=1}}if(depth!==0)return trimmed;let start=0;let end=trimmed.length-1;while(start<end&&matchingClose.get(start)===end){start+=1;end-=1;while(/\s/.test(trimmed[start]??""))start+=1;while(/\s/.test(trimmed[end]??""))end-=1}return start===0?trimmed:trimmed.slice(start,end+1).trim()}function hasUnsupportedContainerSizeQuery(conditionText){if(/(?:min-|max-)?(?:height|block-size)\b/i.test(conditionText))return true;if(/\baspect-ratio\b/i.test(conditionText))return true;if(/\borientation\s*:/i.test(conditionText))return true;const featureFirstUnitMatches=conditionText.matchAll(/(?:min-|max-)?(?:width|inline-size)\s*(?:>=|>|<=|<|:)\s*[\d.]+([a-z%]+)/gi);const valueFirstUnitMatches=conditionText.matchAll(/[\d.]+([a-z%]+)\s*(?:>=|>|<=|<)\s*(?:width|inline-size)/gi);return[...featureFirstUnitMatches,...valueFirstUnitMatches].some((match)=>!/^(?:px|rem)$/i.test(match[1]))}function evaluateRangeComparisons(conditionText,width,remSize){const featureFirstPattern=/(?:width|inline-size)\s*(>=|>|<=|<)\s*([\d.]+)(px|rem)/gi;const valueFirstPattern=/([\d.]+)(px|rem)\s*(<=|<|>=|>)\s*(width|inline-size)/gi;const comparisons=[];for(const comparison of conditionText.matchAll(featureFirstPattern)){const operator=comparison[1];const threshold=comparison[2];const unit=comparison[3];if(operator&&threshold&&unit)comparisons.push({operator,threshold,unit})}for(const comparison of conditionText.matchAll(valueFirstPattern)){const threshold=comparison[1];const unit=comparison[2];const operator=comparison[3]==="<="?">=":comparison[3]==="<"?">":comparison[3]===">="?"<=":"<";if(threshold&&unit)comparisons.push({operator,threshold,unit})}if(comparisons.length===0)return;const satisfiesAll=comparisons.every((comparison)=>{const{operator}=comparison;const threshold=Number(comparison.threshold)*(comparison.unit.toLowerCase()==="rem"?remSize:1);if(operator===">=")return width>=threshold;if(operator===">")return width>threshold;if(operator==="<=")return width<=threshold;return width<threshold});return satisfiesAll}function evaluateEqualityComparison(conditionText,width,remSize){const equalityPattern=/(?:^|[\s(])(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/gi;const comparisons=[...conditionText.matchAll(equalityPattern)];if(comparisons.length===0)return;const satisfiesAll=comparisons.every((comparison)=>{const threshold=Number(comparison[1])*(comparison[2].toLowerCase()==="rem"?remSize:1);return width===threshold});return satisfiesAll}function evaluateContainerSizeConstraints(conditionText,width,remSize,inlineSize=width){const measuredSize=/\binline-size\b/i.test(conditionText)&&!/\bwidth\b/i.test(conditionText)?inlineSize:width;const andSplitPattern=/\s+and\s+/i;if(/\bwidth\b/i.test(conditionText)&&/\binline-size\b/i.test(conditionText)&&/\band\b/i.test(conditionText)){for(const clause of conditionText.split(andSplitPattern)){const clauseSize=/\binline-size\b/i.test(clause)?inlineSize:width;if(!evaluateContainerSizeConstraints(clause,clauseSize,remSize,inlineSize))return false}return true}const minimum=/min-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);const maximum=/max-(?:width|inline-size)\s*:\s*([\d.]+)(px|rem)/i.exec(conditionText);const toPixels=(value)=>Number(value[1])*(value[2].toLowerCase()==="rem"?remSize:1);const legacyMatches=(!minimum||measuredSize>=toPixels(minimum))&&(!maximum||measuredSize<=toPixels(maximum));const rangeMatches=evaluateRangeComparisons(conditionText,measuredSize,remSize)??true;const equalityMatches=evaluateEqualityComparison(conditionText,measuredSize,remSize)??true;const hasSizeFeature=/\b(?:width|inline-size)\b/i.test(conditionText);const hasRecognizedRange=/(?:width|inline-size)\s*(?:>=|>|<=|<)\s*[\d.]+(?:px|rem)/i.test(conditionText)||/[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*(?:width|inline-size)/i.test(conditionText);const hasRecognizedEquality=/(?:width|inline-size)\s*:\s*[\d.]+(?:px|rem)/i.test(conditionText);if(hasSizeFeature&&!minimum&&!maximum&&!hasRecognizedRange&&!hasRecognizedEquality)return false;const combinedMatches=legacyMatches&&rangeMatches&&equalityMatches;return/^\s*not\b/i.test(conditionText)?!combinedMatches:combinedMatches}var sheetIndex=new WeakMap;function resetDirectionStyleSheetIndex(){sheetIndex=new WeakMap}function styleSheetDeclaresDirection(sheet){let rules;try{rules=sheet.cssRules}catch{return true}const cached=sheetIndex.get(sheet);if(cached!==undefined&&cached.ruleCount===rules.length)return cached.declaresDirection;const isConstructed=Reflect.get(sheet,"ownerNode")==null;const scan={declaresDirection:false,cacheable:!isConstructed};scanRuleList(rules,scan);if(scan.cacheable||scan.declaresDirection){sheetIndex.set(sheet,{ruleCount:rules.length,declaresDirection:scan.declaresDirection})}else{sheetIndex.delete(sheet)}return scan.declaresDirection}function scanRuleList(rules,state){for(const rule of Array.from(rules)){if(state.declaresDirection)return;if(Reflect.get(rule,"type")===3){state.cacheable=false;const imported=Reflect.get(rule,"styleSheet");if(imported){try{const importedRules=Reflect.get(imported,"cssRules");if(isRuleCollection(importedRules))scanRuleList(importedRules,state)}catch{state.declaresDirection=true}}continue}const style=Reflect.get(rule,"style");if(typeof style==="object"&&style!==null&&typeof Reflect.get(rule,"selectorText")==="string"&&Boolean(Reflect.get(style,"direction"))){state.declaresDirection=true;return}if(!("cssRules"in rule))continue;try{const nested=Reflect.get(rule,"cssRules");if(isRuleCollection(nested))scanRuleList(nested,state)}catch{state.declaresDirection=true;return}}}function isRuleCollection(value){if(typeof CSSRuleList!=="undefined"&&value instanceof CSSRuleList)return true;if(Array.isArray(value))return true;if(typeof value!=="object"||value===null)return false;return typeof Reflect.get(value,Symbol.iterator)==="function"}function matchesDirectionStyleRule(element,getParentElement){const styleSheets=new Map;for(const sheet of Array.from(element.ownerDocument.styleSheets))styleSheets.set(sheet,null);for(const sheet of Array.from(element.ownerDocument.adoptedStyleSheets??[]))styleSheets.set(sheet,null);const root=element.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot){for(const sheet of root.adoptedStyleSheets)styleSheets.set(sheet,root);for(const styleElement of root.querySelectorAll("style")){if(styleElement.sheet)styleSheets.set(styleElement.sheet,root)}for(const linkElement of root.querySelectorAll('link[rel~="stylesheet"]')){if(linkElement.sheet)styleSheets.set(linkElement.sheet,root)}}for(const[sheet,fallbackRoot]of styleSheets){if(!isActiveStyleSheet(sheet))continue;if(!styleSheetDeclaresDirection(sheet))continue;let rules;try{rules=sheet.cssRules}catch{continue}if(matchesDirectionStyleRuleList(element,rules,getParentElement,[],getImplicitScopeRoot(sheet,fallbackRoot,element.ownerDocument.documentElement)))return true}return false}function isActiveStyleSheet(sheet){if(sheet.disabled)return false;const mediaText=sheet.media?.mediaText;if(!mediaText)return true;if(typeof matchMedia!=="function")return true;return matchMedia(mediaText).matches}function getImplicitScopeRoot(sheet,fallbackRoot,documentRoot){const ownerNode=Reflect.get(sheet,"ownerNode");if(!(ownerNode instanceof Element)||ownerNode.localName?.toLowerCase()!=="style"){return typeof ShadowRoot!=="undefined"&&fallbackRoot instanceof ShadowRoot?fallbackRoot:documentRoot}if(ownerNode.parentElement)return ownerNode.parentElement;const root=ownerNode.getRootNode();return typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?root:typeof ShadowRoot!=="undefined"&&fallbackRoot instanceof ShadowRoot?fallbackRoot:null}function matchesDirectionStyleRuleCached(element,cache,getParentElement){if(!getParentElement)return false;if(!cache)return matchesDirectionStyleRule(element,getParentElement);const cached=cache.get(element);if(cached!==undefined)return cached;const matched=matchesDirectionStyleRule(element,getParentElement);cache.set(element,matched);return matched}function matchesDirectionStyleRuleList(element,rules,getParentElement,scopes=[],implicitScopeRoot=null){for(const rule of Array.from(rules)){if(Reflect.get(rule,"type")===3){const imported=Reflect.get(rule,"styleSheet");if(imported){try{const importedRules=Reflect.get(imported,"cssRules");if(isCssRuleCollection(importedRules)&&matchesDirectionStyleRuleList(element,importedRules,getParentElement,scopes,implicitScopeRoot))return true}catch{}}continue}if(isCssStyleRule(rule)){if(!rule.style.direction){const nestedRules2=readNestedCssRules(rule);if(nestedRules2&&matchesDirectionStyleRuleList(element,nestedRules2,getParentElement,scopes,implicitScopeRoot))return true;continue}try{const selectorText=resolveNestedSelector(rule);if(selectorText&&matchesScopedSelector(element,selectorText,scopes))return true}catch{continue}}const nestedRules=readNestedCssRules(rule);if(isScopeRule(rule)){const scope=createActiveScope(rule,element,scopes,implicitScopeRoot);if(scope&&nestedRules){if(matchesDirectionStyleRuleList(element,nestedRules,getParentElement,[...scopes,scope],implicitScopeRoot))return true}continue}if(nestedRules&&isConditionalRuleActive(rule,element,getParentElement)&&matchesDirectionStyleRuleList(element,nestedRules,getParentElement,scopes,implicitScopeRoot)){return true}}return false}function readNestedCssRules(rule){if(!("cssRules"in rule))return;try{const nestedRules=Reflect.get(rule,"cssRules");return isCssRuleCollection(nestedRules)?nestedRules:undefined}catch{return}}function isCssRuleCollection(value){if(typeof CSSRuleList!=="undefined"&&value instanceof CSSRuleList)return true;if(Array.isArray(value))return value.every(isCssRule);if(typeof value!=="object"||value===null)return false;const iterator=Reflect.get(value,Symbol.iterator);return typeof iterator==="function"}function isCssRule(value){return typeof value==="object"&&value!==null&&typeof Reflect.get(value,"cssText")==="string"&&typeof Reflect.get(value,"type")==="number"}function isCssStyleRule(rule){return typeof Reflect.get(rule,"selectorText")==="string"&&typeof Reflect.get(rule,"style")==="object"&&Reflect.get(rule,"style")!==null}function resolveNestedSelector(rule){let selector=rule.selectorText.trim();let parentRule=Reflect.get(rule,"parentRule");while(parentRule){if(isCssStyleRule(parentRule)){const parentSelector=parentRule.selectorText.trim();if(!parentSelector)return;selector=combineNestedSelectors(parentSelector,selector);if(!selector)return}parentRule=Reflect.get(parentRule,"parentRule")}return selector}function combineNestedSelectors(parentSelector,nestedSelector){const parentContext=splitSelectorList(parentSelector).length>1?`:is(${parentSelector})`:parentSelector;return splitSelectorList(nestedSelector).map((selector)=>{const resolved=replaceNestingReferences(selector,parentContext);return resolved.replaced?resolved.selector:`${parentContext} ${selector}`}).join(", ")}function replaceNestingReferences(selector,parentContext){let quote;let replaced=false;let resolved="";for(let index=0;index<selector.length;index+=1){const character=selector[index];if(character==="\\"){resolved+=character;if(index+1<selector.length)resolved+=selector[++index];continue}if(quote!==undefined){resolved+=character;if(character===quote)quote=undefined;continue}if(character==='"'||character==="'"){quote=character;resolved+=character;continue}if(character==="&"){resolved+=parentContext;replaced=true;continue}resolved+=character}return{selector:resolved,replaced}}function splitSelectorList(selectorText){const selectors=[];let parenthesesDepth=0;let bracketDepth=0;let quote;let start=0;for(let index=0;index<selectorText.length;index+=1){const character=selectorText[index];if(character==="\\"){index+=1;continue}if(quote!==undefined){if(character===quote)quote=undefined;continue}if(character==='"'||character==="'"){quote=character;continue}if(character==="(")parenthesesDepth+=1;if(character===")")parenthesesDepth=Math.max(0,parenthesesDepth-1);if(character==="[")bracketDepth+=1;if(character==="]")bracketDepth=Math.max(0,bracketDepth-1);if(character===","&&parenthesesDepth===0&&bracketDepth===0){const selector2=selectorText.slice(start,index).trim();if(selector2)selectors.push(selector2);start=index+1}}const selector=selectorText.slice(start).trim();if(selector)selectors.push(selector);return selectors}function isConditionalRuleActive(rule,element,getParentElement){const conditionText=Reflect.get(rule,"conditionText");if(typeof conditionText!=="string"||!conditionText.trim())return true;if(isContainerRule(rule))return isContainerQueryActive(conditionText,element,rule,getParentElement);if(isMediaRule(rule)&&typeof matchMedia==="function"){return matchMedia(conditionText).matches}if(isSupportsRule(rule)&&typeof CSS!=="undefined"&&typeof CSS.supports==="function")return CSS.supports(conditionText);return true}function isScopeRule(rule){if(rule.constructor.name==="CSSScopeRule")return true;const cssText=Reflect.get(rule,"cssText");return typeof cssText==="string"&&/^\s*@scope\b/i.test(cssText)}function createActiveScope(rule,element,parentScopes,implicitScopeRoot){const cssText=Reflect.get(rule,"cssText");if(typeof cssText!=="string")return null;const prelude=parseScopePrelude(cssText);if(!prelude)return null;const roots=findActiveScopeRoots(element,prelude,parentScopes,implicitScopeRoot);return roots===null?null:{roots}}function scopePseudoRootCandidates(parentScopes,implicitScopeRoot){if(parentScopes.length>0)return parentScopes.at(-1).roots;return implicitScopeRoot?[implicitScopeRoot]:[]}function findActiveScopeRoots(element,prelude,parentScopes,implicitScopeRoot){if(!selectorsAreValid(element,prelude.rootSelectors))return null;if(prelude.limitSelectors&&!selectorsAreValid(element,prelude.limitSelectors))return null;if(prelude.rootSelectors.length===0){const candidates=scopePseudoRootCandidates(parentScopes,implicitScopeRoot);const roots2=candidates.length>0?candidates:[implicitScopeRoot??element.ownerDocument.documentElement];return finalizeActiveScopeRoots(roots2.filter((root)=>root.contains(element)),element,prelude,parentScopes)}const scopeRootSelectors=prelude.rootSelectors.filter(hasScopePseudoClass);const ordinaryRootSelectors=prelude.rootSelectors.filter((selector)=>!hasScopePseudoClass(selector));const scopeRootCandidates=scopePseudoRootCandidates(parentScopes,implicitScopeRoot);const roots=[...findRelativeScopeRootMatches(element,scopeRootSelectors,scopeRootCandidates),...findScopeMatches(element,ordinaryRootSelectors)];return finalizeActiveScopeRoots(roots,element,prelude,parentScopes)}function findRelativeScopeRootMatches(element,selectors,scopeRootCandidates){if(selectors.length===0||scopeRootCandidates.length===0)return[];const parentScope={roots:[...scopeRootCandidates]};const hasExactScopeSelector=selectors.some(isExactScopeSelector);const matches=[];let current=element;while(current){const currentElement=current;if(selectors.some((selector)=>matchesScopedSelector(currentElement,selector,[parentScope])))matches.push(currentElement);const parent=currentElement.parentElement;if(parent){current=parent;continue}const root=currentElement.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&hasExactScopeSelector&&scopeRootCandidates.includes(root))matches.push(root);current=null}return matches}function isExactScopeSelector(selector){return selector.trim().toLowerCase()===":scope"}function finalizeActiveScopeRoots(roots,element,prelude,parentScopes){const activeRoots=[];for(const root of roots){if(!isWithinParentScopes(root,parentScopes))continue;if(prelude.limitSelectors&&isWithinScopeLimit(element,root,prelude.limitSelectors)){continue}activeRoots.push(root)}return activeRoots.length===0?null:activeRoots}function selectorsAreValid(element,selectors){try{for(const selector of selectors)element.matches(selector);return true}catch{return false}}function isWithinParentScopes(root,parentScopes){return parentScopes.every((scope)=>scope.roots.some((parentRoot)=>parentRoot.contains(root)))}function isWithinScopeLimit(element,root,limitSelectors){let current=element;while(current){if(current===root)break;if(limitSelectors.some((selector)=>hasScopePseudoClass(selector)?matchesScopedSelector(current,selector,[{roots:[root]}]):matchesSelectorSafely(current,selector)))return true;current=current.parentElement}return false}function matchesSelectorSafely(element,selector){try{return element.matches(selector)}catch{return false}}function normalizeScopeRelativeSelector(selector){return splitSelectorList(selector).map((part)=>{if(!part.includes("&")&&!/^\s*[>+~]/.test(part))return part;const withScopeAlias=replaceNestingReferences(part,":scope").selector;return/^\s*[>+~]/.test(withScopeAlias)?`:scope ${withScopeAlias}`:withScopeAlias}).join(", ")}function matchesScopedSelector(element,selector,scopes){const normalizedSelector=scopes.length>0?normalizeScopeRelativeSelector(selector):selector;return splitSelectorList(normalizedSelector).some((item)=>matchesScopedSelectorItem(element,item,scopes))}function matchesScopedSelectorItem(element,selector,scopes){if(!hasScopePseudoClass(selector))return matchesSelectorSafely(element,selector);if(scopes.length===0)return false;const scope=scopes.at(-1);if(!scope)return false;const outsideContext=splitScopeOutsideContext(selector);const remainderSelector=outsideContext?outsideContext.remainder:selector;for(const root of scope.roots){try{if(outsideContext){if(!(root instanceof Element))continue;if(!matchesOutsideScopeContext(root,outsideContext.before,outsideContext.combinator))continue}if(matchesRemainderAgainstScopeRoot(element,remainderSelector,root))return true}catch{}}return false}function splitScopeOutsideContext(selector){const scopeIndex=findScopePseudoClassIndex(selector,{topLevelOnly:true});if(scopeIndex===null)return null;const beforeRaw=selector.slice(0,scopeIndex);if(!beforeRaw.trim())return null;const trimmedEnd=beforeRaw.replace(/\s+$/,"");const lastCharacter=trimmedEnd.at(-1);if(lastCharacter===">"||lastCharacter==="+"||lastCharacter==="~"){const before2=trimmedEnd.slice(0,-1).trim();if(!before2){return null}return{before:before2,combinator:lastCharacter,remainder:selector.slice(scopeIndex)}}if(!/\s$/.test(beforeRaw))return null;const before=trimmedEnd.trim();return before?{before,combinator:" ",remainder:selector.slice(scopeIndex)}:null}function matchesOutsideScopeContext(root,before,combinator){if(combinator===" ")return root.parentElement?.closest(before)!=null;if(combinator===">")return root.parentElement!==null&&matchesSelectorSafely(root.parentElement,before);if(combinator==="+"){const sibling2=root.previousElementSibling;return sibling2!==null&&matchesSelectorSafely(sibling2,before)}let sibling=root.previousElementSibling;while(sibling){if(matchesSelectorSafely(sibling,before))return true;sibling=sibling.previousElementSibling}return false}function matchesRemainderAgainstScopeRoot(element,selector,root){if(root.querySelector(":scope")===root){return Array.from(root.querySelectorAll(selector)).includes(element)}const clone=typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?null:root.cloneNode(true);const cloneElement=clone instanceof Element?clone:typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot?(()=>{const wrapper=root.ownerDocument.createElement("div");wrapper.append(...Array.from(root.children,(child)=>child.cloneNode(true)));return wrapper})():null;if(!cloneElement)return false;const marker="data-cinder-scope-root";const replacedSelector=replaceScopePseudoClass(selector,`[${marker}]`);if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&/^\[[^\]]+\][^\s>+~]/.test(replacedSelector))return false;cloneElement.setAttribute(marker,"true");const path=[];let current=element;while(current&&current!==root){const parent=current.parentElement;if(!parent){if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&current.getRootNode()===root)path.unshift(Array.prototype.indexOf.call(root.children,current));break}path.unshift(Array.prototype.indexOf.call(parent.children,current));current=parent}if(current!==root&&!(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot&&current?.getRootNode()===root))return false;let matchedCloneElement=cloneElement;for(const index of path){const child=matchedCloneElement.children[index];if(!child)break;matchedCloneElement=child}return matchedCloneElement===cloneElement&&cloneElement.matches(replacedSelector)||Array.from(cloneElement.querySelectorAll(replacedSelector)).includes(matchedCloneElement)}function replaceScopePseudoClass(selector,replacement){let result="";let quote=null;let escaped=false;let brackets=0;for(let index=0;index<selector.length;index+=1){const character=selector[index];if(escaped){result+=character;escaped=false;continue}if(character==="\\"){result+=character;escaped=true;continue}if(quote){result+=character;if(character===quote)quote=null;continue}if(character==='"'||character==="'"){result+=character;quote=character;continue}if(character==="["){brackets+=1;result+=character;continue}if(character==="]"){brackets=Math.max(0,brackets-1);result+=character;continue}if(brackets===0&&character===":"&&selector.slice(index+1,index+6).toLowerCase()==="scope"&&!/[\w-]/.test(selector[index+6]??"")){result+=replacement;index+=5;continue}result+=character}return result}function findScopePseudoClassIndex(selector,options={}){let quote=null;let brackets=0;let parentheses=0;let escaped=false;for(let index=0;index<selector.length;index+=1){const character=selector[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'"){quote=character;continue}if(character==="["){brackets+=1;continue}if(character==="]"){brackets=Math.max(0,brackets-1);continue}if(character==="("){parentheses+=1;continue}if(character===")"){parentheses=Math.max(0,parentheses-1);continue}if(brackets===0&&(!options.topLevelOnly||parentheses===0)&&character===":"&&selector.slice(index+1,index+6).toLowerCase()==="scope"&&!/[\w-]/.test(selector[index+6]??""))return index}return null}function hasScopePseudoClass(selector){return findScopePseudoClassIndex(selector)!==null}function parseScopePrelude(cssText){const match=/^\s*@scope\b/i.exec(cssText);if(!match)return null;const start=match[0].length;let quote=null;let escaped=false;let parentheses=0;let brackets=0;let end=-1;for(let index=start;index<cssText.length;index+=1){const character=cssText[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character==="{"&&parentheses===0&&brackets===0){end=index;break}if(parentheses<0||brackets<0)return null}if(end<0||quote||escaped||parentheses!==0||brackets!==0)return null;const prelude=cssText.slice(start,end).trim();const limitIndex=findScopeLimitKeyword(prelude);const rootText=(limitIndex===null?prelude:prelude.slice(0,limitIndex)).trim();const limitText=limitIndex===null?null:prelude.slice(limitIndex+2).trim();const rootSelectorText=unwrapScopeGroup(rootText);if(rootSelectorText===null)return null;const rootSelectors=rootSelectorText?splitScopeSelectors(rootSelectorText):[];if(rootSelectorText&&rootSelectors.length===0)return null;if(limitText===null)return{rootSelectors,limitSelectors:null};const limitSelectorText=unwrapScopeGroup(limitText);if(limitSelectorText===null||!limitSelectorText)return null;const limitSelectors=splitScopeSelectors(limitSelectorText);return limitSelectors.length>0?{rootSelectors,limitSelectors}:null}function findScopeLimitKeyword(prelude){let quote=null;let escaped=false;let parentheses=0;let brackets=0;for(let index=0;index<prelude.length;index+=1){const character=prelude[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;if(parentheses<0||brackets<0)return null;if(parentheses===0&&brackets===0&&prelude.slice(index,index+2).toLowerCase()==="to"&&!/[\w-]/.test(prelude[index-1]??"")&&!/[\w-]/.test(prelude[index+2]??"")){const remainder=prelude.slice(index+2);const opening=remainder.search(/\S/);if(opening>=0&&remainder[opening]==="(")return index}}return null}function unwrapScopeGroup(value){if(!value)return"";if(value[0]!=="(")return value;const end=findScopeGroupEnd(value);if(end<0||value.slice(end+1).trim())return null;return value.slice(1,end).trim()}function findScopeGroupEnd(value){let depth=0;let brackets=0;let quote=null;let escaped=false;for(let index=0;index<value.length;index+=1){const character=value[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character==="("&&brackets===0)depth+=1;else if(character===")"&&brackets===0){depth-=1;if(depth===0)return index}if(brackets<0)return-1}return-1}function findScopeMatches(element,selectors){if(selectors.length===0)return[];const matches=[];let current=element;while(current){const currentElement=current;if(selectors.some((selector)=>matchesSelectorSafely(currentElement,selector)))matches.push(currentElement);current=currentElement.parentElement}return matches}function splitScopeSelectors(value){const selectors=[];let parentheses=0;let brackets=0;let quote=null;let escaped=false;let start=0;for(let index=0;index<value.length;index+=1){const character=value[index];if(escaped){escaped=false;continue}if(character==="\\"){escaped=true;continue}if(quote){if(character===quote)quote=null;continue}if(character==='"'||character==="'")quote=character;else if(character==="(")parentheses+=1;else if(character===")")parentheses-=1;else if(character==="[")brackets+=1;else if(character==="]")brackets-=1;else if(character===","&&parentheses===0&&brackets===0){const selector2=value.slice(start,index).trim();if(!selector2)return[];selectors.push(selector2);start=index+1}if(parentheses<0||brackets<0)return[]}if(escaped||quote||parentheses!==0||brackets!==0)return[];const selector=value.slice(start).trim();if(!selector)return[];selectors.push(selector);return selectors}function resolveContainerQueryText(conditionText,rule,containerName){const containerQuery=Reflect.get(rule,"containerQuery");if(typeof containerQuery==="string")return containerQuery;if(typeof containerName!=="string"||!containerName)return conditionText;if(!conditionText.startsWith(containerName))return conditionText;const rest=conditionText.slice(containerName.length);if(!/^\s/.test(rest))return conditionText;return rest.trimStart()}function isContainerConditionList(value){if(!Array.isArray(value)||value.length===0)return false;return value.every((entry)=>typeof entry==="object"&&entry!==null&&typeof Reflect.get(entry,"name")==="string"&&typeof Reflect.get(entry,"query")==="string")}function isContainerQueryActive(conditionText,element,rule,getParentElement){if(typeof getComputedStyle!=="function")return false;const conditions=Reflect.get(rule,"conditions");if(isContainerConditionList(conditions))return conditions.some((condition)=>isSingleContainerConditionActive(condition.query,condition.name,element,getParentElement));const containerName=Reflect.get(rule,"containerName");const queryText=resolveContainerQueryText(conditionText,rule,containerName);return isSingleContainerConditionActive(queryText,containerName,element,getParentElement)}function isSingleContainerConditionActive(queryText,containerName,element,getParentElement){if(!queryText.trim())return false;const styleQuery=parseStyleQuery(queryText);if(styleQuery){const remainder=(queryText.slice(0,styleQuery.index)+queryText.slice(styleQuery.end)).replace(/^\s*(?:and|or|not)\b/i,"").replace(/^\(|\)$/g,"").trim();if(remainder)return false;let ancestor=getParentElement(element);while(ancestor){if(typeof containerName==="string"&&containerName){const computedStyle=getComputedStyle(ancestor);const name=computedStyle.containerName||computedStyle.getPropertyValue("container-name")||ancestor.style.containerName||ancestor.style.getPropertyValue("container-name");if(!name.split(/\s+/).includes(containerName)){ancestor=getParentElement(ancestor);continue}}const value=getComputedStyle(ancestor).getPropertyValue(styleQuery.name).trim()||ancestor.style.getPropertyValue(styleQuery.name).trim();return/^\s*not\b/i.test(queryText)?value!==styleQuery.value.trim():value===styleQuery.value.trim()}return false}const queriesPhysicalWidth=/(?:^|[\s(])(?:width|min-width|max-width)\s*[:<>=]/i.test(queryText)||/[\d.]+(?:px|rem)\s*(?:<=|<|>=|>)\s*width\b/i.test(queryText);let container=getParentElement(element);while(container){const computedStyle=getComputedStyle(container);const type=computedStyle.containerType||computedStyle.getPropertyValue("container-type")||container.style.containerType||container.style.getPropertyValue("container-type");const name=computedStyle.containerName||computedStyle.getPropertyValue("container-name")||container.style.containerName||container.style.getPropertyValue("container-name");const writingMode2=computedStyle.writingMode||computedStyle.getPropertyValue("writing-mode")||container.style.writingMode||container.style.getPropertyValue("writing-mode");if((typeof containerName!=="string"||!containerName||name.split(/\s+/).includes(containerName))&&type&&type!=="normal"&&!(queriesPhysicalWidth&&/^(?:vertical|sideways)-/i.test(writingMode2)&&type==="inline-size")){break}container=getParentElement(container)}if(!container)return false;const computedContainerStyle=getComputedStyle(container);const readInset=(property,fallbackProperty)=>{const camel=property.replace(/-([a-z])/g,(_,character)=>character.toUpperCase());const fallbackCamel=fallbackProperty.replace(/-([a-z])/g,(_,character)=>character.toUpperCase());const value=Reflect.get(computedContainerStyle,camel)||Reflect.get(container.style,camel)||computedContainerStyle.getPropertyValue(property).trim()||container.style.getPropertyValue(property).trim()||Reflect.get(computedContainerStyle,fallbackCamel)||Reflect.get(container.style,fallbackCamel)||computedContainerStyle.getPropertyValue(fallbackProperty).trim()||container.style.getPropertyValue(fallbackProperty).trim();const parsed=Number.parseFloat(value);return Number.isFinite(parsed)&&parsed>0?parsed:0};const writingMode=computedContainerStyle.writingMode||computedContainerStyle.getPropertyValue("writing-mode")||container.style.writingMode||container.style.getPropertyValue("writing-mode");const usesInlineSize=/(?:inline-size|min-inline-size|max-inline-size)/i.test(queryText);const isVerticalWritingMode=/^(?:vertical|sideways)-/i.test(writingMode);const verticalInlineAxis=usesInlineSize&&isVerticalWritingMode;const physicalInsets=readInset("padding-left","padding-inline-start")+readInset("padding-right","padding-inline-end");const physicalBorders=readInset("border-left-width","border-inline-start-width")+readInset("border-right-width","border-inline-end-width");const inlineInsets=verticalInlineAxis?readInset("padding-inline-start","padding-top")+readInset("padding-inline-end","padding-bottom"):physicalInsets;const inlineBorders=verticalInlineAxis?readInset("border-inline-start-width","border-top-width")+readInset("border-inline-end-width","border-bottom-width"):physicalBorders;const readUsedContentSize=(axis,fallback,insets,borders)=>{const parsed=Number.parseFloat(computedContainerStyle[axis]);if(!Number.isFinite(parsed))return fallback;const boxSizing=computedContainerStyle.boxSizing||container.style.boxSizing;return boxSizing==="border-box"?Math.max(0,parsed-insets-borders):parsed};const physicalClientSize=container.clientWidth;const inlineClientSize=verticalInlineAxis?container.clientHeight:physicalClientSize;const width=Math.max(0,readUsedContentSize("width",physicalClientSize>0?physicalClientSize-physicalInsets:container.offsetWidth-physicalBorders-physicalInsets,physicalInsets,physicalBorders));const inlineSize=Math.max(0,readUsedContentSize(verticalInlineAxis?"height":"width",inlineClientSize>0?inlineClientSize-inlineInsets:(verticalInlineAxis?container.offsetHeight:container.offsetWidth)-inlineBorders-inlineInsets,inlineInsets,inlineBorders));const rootFontSize=Number.parseFloat(getComputedStyle(element.ownerDocument.documentElement).fontSize);const remSize=Number.isFinite(rootFontSize)&&rootFontSize>0?rootFontSize:16;if(hasUnsupportedContainerSizeQuery(queryText))return false;return evaluateLogicalContainerCondition(queryText,width,remSize,inlineSize)}function isContainerRule(rule){if(rule.constructor.name==="CSSContainerRule")return true;if(Reflect.get(rule,"type")!==0)return false;const cssText=Reflect.get(rule,"cssText");return typeof cssText==="string"&&/^\s*@container\b/i.test(cssText)}function isMediaRule(rule){return typeof Reflect.get(rule,"media")==="object"&&Reflect.get(rule,"media")!==null}function isSupportsRule(rule){return rule.constructor.name==="CSSSupportsRule"||Reflect.get(rule,"type")===12}function observeTextDirectionMediaQueries(element,onChange){if(!element||typeof matchMedia!=="function")return;const sheets=new Set(Array.from(element.ownerDocument.styleSheets));for(const sheet of element.ownerDocument.adoptedStyleSheets??[])sheets.add(sheet);const root=element.getRootNode();if(typeof ShadowRoot!=="undefined"&&root instanceof ShadowRoot){for(const sheet of root.adoptedStyleSheets)sheets.add(sheet);for(const style of root.querySelectorAll('style,link[rel~="stylesheet"]')){const sheet=style.sheet;if(sheet)sheets.add(sheet)}}const queries=new Set;const visitedSheets=new Set;const visit=(rules)=>{for(const rule of Array.from(rules)){if(Reflect.get(rule,"type")===3){try{const media=Reflect.get(rule,"media");const condition=media&&Reflect.get(media,"mediaText");if(typeof condition==="string"&&condition)queries.add(condition)}catch{}let imported;try{imported=Reflect.get(rule,"styleSheet")}catch{continue}if(imported&&!visitedSheets.has(imported)){visitedSheets.add(imported);try{const importedRules=Reflect.get(imported,"cssRules");if(isCssRuleCollection(importedRules))visit(importedRules)}catch{}}continue}if(isMediaRule(rule)){const condition=Reflect.get(rule,"conditionText");if(typeof condition==="string"&&condition)queries.add(condition)}const nested=readNestedCssRules(rule);if(nested)visit(nested)}};for(const sheet of sheets){if(visitedSheets.has(sheet))continue;visitedSheets.add(sheet);try{visit(sheet.cssRules)}catch{}}const mediaQueries=[...queries].map((query)=>matchMedia(query));const handler=()=>onChange();for(const mediaQuery of mediaQueries)mediaQuery.addEventListener?.("change",handler);return()=>{for(const mediaQuery of mediaQueries)mediaQuery.removeEventListener?.("change",handler)}}function elementDirectionStyleOverride(element){if(!element)return;if(element.style.direction)return readComputedTextDirection(element);if(!matchesDirectionStyleRuleCached(element,undefined,composedParentElement))return;return readComputedTextDirection(element)}function resolveTextDirection(element,fallback,options){const ignoreElementDirectionAttribute=options?.ignoreElementDirectionAttribute??false;const directionStyleRuleCache=new WeakMap;if(ignoreElementDirectionAttribute&&element){const styledDirection=readComputedTextDirection(element);const rootComputedDirection2=readComputedTextDirection(element.ownerDocument.documentElement);const elementDirectionAttribute=element.getAttribute("dir")?.toLowerCase();const differsFromRootViaStyling=styledDirection!==rootComputedDirection2&&styledDirection!==elementDirectionAttribute;if(styledDirection&&(hasElementDirectionStylingHint(element,directionStyleRuleCache)||differsFromRootViaStyling))return styledDirection}let currentElement=ignoreElementDirectionAttribute?element?composedParentElement(element):null:element??null;let documentDirection;let styledDirectionElement=null;while(currentElement){if(!styledDirectionElement&&currentElement!==currentElement.ownerDocument.documentElement&&(Boolean(currentElement.style.direction)||matchesDirectionStyleRuleCached(currentElement,directionStyleRuleCache,composedParentElement))){styledDirectionElement=currentElement}const direction=currentElement.getAttribute("dir")?.toLowerCase();if(direction==="rtl"||direction==="ltr"){if(typeof getComputedStyle==="function"&&styledDirectionElement){const styledDirection2=getComputedStyle(styledDirectionElement).direction;if(styledDirection2==="rtl"||styledDirection2==="ltr")return styledDirection2}if(currentElement===currentElement.ownerDocument.documentElement){documentDirection=direction;break}return direction}if(direction==="auto"&&typeof getComputedStyle==="function"){const computedDirection2=getComputedStyle(currentElement).direction;if(computedDirection2==="rtl"||computedDirection2==="ltr")return computedDirection2}const styledDirection=currentElement.style.direction;if(!styledDirectionElement&&(styledDirection==="rtl"||styledDirection==="ltr")){styledDirectionElement=currentElement}currentElement=composedParentElement(currentElement)}if(typeof getComputedStyle==="function"&&styledDirectionElement){const direction=getComputedStyle(styledDirectionElement).direction;if(direction==="rtl"||direction==="ltr")return direction}const computedDirection=readComputedTextDirection(element);const rootComputedDirection=readComputedTextDirection(element?.ownerDocument.documentElement);if(!ignoreElementDirectionAttribute&&computedDirection&&computedDirection!==rootComputedDirection)return computedDirection;if(computedDirection&&fallback&&computedDirection!==fallback&&hasDirectionStylingHint(element,false,directionStyleRuleCache))return computedDirection;if(!fallback&&computedDirection==="rtl")return computedDirection;if(fallback)return fallback;if(documentDirection)return documentDirection;return}function hasElementDirectionStylingHint(element,cache){return Boolean(element.style.direction)||matchesDirectionStyleRuleCached(element,cache,composedParentElement)}function readComputedTextDirection(element){if(!element||typeof getComputedStyle!=="function")return;const direction=getComputedStyle(element).direction;return direction==="rtl"||direction==="ltr"?direction:undefined}function hasDirectionStylingHint(element,includeElement=false,cache){let currentElement=includeElement?element:element?composedParentElement(element):null;while(currentElement&&currentElement!==currentElement.ownerDocument.documentElement){if(currentElement.style.direction)return true;if(matchesDirectionStyleRuleCached(currentElement,cache,composedParentElement))return true;currentElement=composedParentElement(currentElement)}return false}function composedParentElement(element){if(element.parentElement)return element.parentElement;const root=element.getRootNode();return typeof ShadowRoot!=="undefined"&&typeof HTMLElement!=="undefined"&&root instanceof ShadowRoot&&root.host instanceof HTMLElement?root.host:null}function isRightToLeftElement(element){return resolveTextDirection(element)==="rtl"}function observeTextDirection(element,onChange){if(!element||typeof MutationObserver==="undefined")return;const observedElement=element;const observer=new MutationObserver((mutations)=>{if(mutations.some((mutation)=>mutation.type==="attributes"&&mutation.attributeName==="dir"||mutation.type==="childList")){observeDirectionChain()}onChange()});function observeDirectionChain(){observer.disconnect();let currentElement=observedElement;while(currentElement){const isAutoDirection=currentElement.getAttribute("dir")?.toLowerCase()==="auto";observer.observe(currentElement,{attributes:true,childList:true,characterData:isAutoDirection,subtree:isAutoDirection});currentElement=composedParentElement(currentElement)}}observeDirectionChain();return()=>observer.disconnect()}function classNames(...parts){return parts.filter((part)=>typeof part==="string"&&part.length>0).join(" ")}import"svelte/internal/disclose-version";import*as $4 from"svelte/internal/client";import{tick}from"svelte";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $2 from"svelte/internal/client";import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $ from"svelte/internal/client";var defaultAttributes={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"};var defaultAttributes_default=defaultAttributes;var root=$.from_svg(`<svg><!><!></svg>`);function Icon($$anchor,$$props){const $$sanitized_props=$.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const $$restProps=$.legacy_rest_props($$sanitized_props,["name","color","size","strokeWidth","absoluteStrokeWidth","iconNode"]);$.push($$props,false);let name=$.prop($$props,"name",8,undefined);let color=$.prop($$props,"color",8,"currentColor");let size=$.prop($$props,"size",8,24);let strokeWidth=$.prop($$props,"strokeWidth",8,2);let absoluteStrokeWidth=$.prop($$props,"absoluteStrokeWidth",8,false);let iconNode=$.prop($$props,"iconNode",24,()=>[]);const mergeClasses=(...classes)=>classes.filter((className,index2,array)=>{return Boolean(className)&&array.indexOf(className)===index2}).join(" ");$.init();var svg=root();$.attribute_effect(svg,($0,$1)=>({...defaultAttributes_default,...$$restProps,width:size(),height:size(),stroke:color(),"stroke-width":$0,class:$1}),[()=>($.deep_read_state(absoluteStrokeWidth()),$.deep_read_state(strokeWidth()),$.deep_read_state(size()),$.untrack(()=>absoluteStrokeWidth()?Number(strokeWidth())*24/Number(size()):strokeWidth())),()=>($.deep_read_state(name()),$.deep_read_state($$sanitized_props),$.untrack(()=>mergeClasses("lucide-icon","lucide",name()?`lucide-${name()}`:"",$$sanitized_props.class)))]);var node=$.child(svg);$.each(node,1,iconNode,$.index,($$anchor2,$$item)=>{var $$array=$.derived(()=>$.to_array($.get($$item),2));let tag=()=>$.get($$array)[0];let attrs=()=>$.get($$array)[1];var fragment=$.comment();var node_1=$.first_child(fragment);$.element(node_1,tag,true,($$element,$$anchor3)=>{$.attribute_effect($$element,()=>({...attrs()}))});$.append($$anchor2,fragment)});var node_2=$.sibling(node);$.slot(node_2,$$props,"default",{},null);$.reset(svg);$.append($$anchor,svg);$.pop()}function Chevron_left($$anchor,$$props){const $$sanitized_props=$2.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const iconNode=[["path",{d:"m15 18-6-6 6-6"}]];Icon($$anchor,$2.spread_props({name:"chevron-left"},()=>$$sanitized_props,{get iconNode(){return iconNode},children:($$anchor2,$$slotProps)=>{var fragment_1=$2.comment();var node=$2.first_child(fragment_1);$2.slot(node,$$props,"default",{},null);$2.append($$anchor2,fragment_1)},$$slots:{default:true}}))}import"svelte/internal/disclose-version";import"svelte/internal/flags/legacy";import*as $3 from"svelte/internal/client";function Chevron_right($$anchor,$$props){const $$sanitized_props=$3.legacy_rest_props($$props,["children","$$slots","$$events","$$legacy"]);const iconNode=[["path",{d:"m9 18 6-6-6-6"}]];Icon($$anchor,$3.spread_props({name:"chevron-right"},()=>$$sanitized_props,{get iconNode(){return iconNode},children:($$anchor2,$$slotProps)=>{var fragment_1=$3.comment();var node=$3.first_child(fragment_1);$3.slot(node,$$props,"default",{},null);$3.append($$anchor2,fragment_1)},$$slots:{default:true}}))}var root2=$4.from_html(`<h3 class="cinder-mega-menu__section-title"> </h3>`);var root_1=$4.from_html(`<span class="cinder-mega-menu__link-description"> </span>`);var root_2=$4.from_html(`<li><a class="cinder-mega-menu__link"><span> </span> <!></a></li>`);var root_3=$4.from_html(`<section><!> <ul class="cinder-mega-menu__links"></ul></section>`);var root_4=$4.from_html(`<li><button type="button" class="cinder-mega-menu__submenu-trigger"> <!></button></li>`);var root_5=$4.from_html(`<h4 class="cinder-mega-menu__section-title"> </h4>`);var root_6=$4.from_html(`<div class="cinder-mega-menu__sections cinder-mega-menu__submenu-panel" role="group" tabindex="-1"></div>`);var root_7=$4.from_html(`<section class="cinder-mega-menu__sub"><ul class="cinder-mega-menu__submenu-list"></ul> <!></section>`);var root_8=$4.from_html(`<section class="cinder-mega-menu__content" role="group" tabindex="-1"><div class="cinder-mega-menu__sections"></div> <!></section>`);function Mega_menu_content($$anchor,$$props){$4.push($$props,true);let openSubmenuId=$4.state(null);const openSubmenu=$4.derived(()=>{if(!$$props.item.submenu?.length||!$4.get(openSubmenuId))return $$props.item.submenu?.[0]??null;return $$props.item.submenu.find((entry)=>entry.id===$4.get(openSubmenuId))??$$props.item.submenu[0]??null});function sections(menuItem){return menuItem?.sections??[]}function focusSubmenuTriggerAt(index2){if(!$$props.item.submenu?.length||typeof document==="undefined")return;const bounded=(index2%$$props.item.submenu.length+$$props.item.submenu.length)%$$props.item.submenu.length;const target=$$props.item.submenu[bounded];if(!target)return;$4.set(openSubmenuId,target.id,true);$$props.focusElementById($$props.submenuTriggerId($$props.item.id,target.id))}async function focusSubmenuPanel(submenuId){if(typeof document==="undefined")return;await tick();const panel=$$props.elementById($$props.submenuPanelId($$props.item.id,submenuId));if(!(panel instanceof HTMLElement))return;const firstFocusable=panel.querySelector("a[href], button:not([disabled])");(firstFocusable??panel).focus()}function submenuHorizontalKeys(){const isRightToLeft=$$props.resolvedDirection==="rtl";return isRightToLeft?{enter:"ArrowLeft",return:"ArrowRight"}:{enter:"ArrowRight",return:"ArrowLeft"}}function isModifiedHorizontalArrow(event2){return(event2.key==="ArrowLeft"||event2.key==="ArrowRight")&&(event2.altKey||event2.ctrlKey||event2.metaKey)}function onSubmenuChange(submenuId){$4.set(openSubmenuId,submenuId,true)}function onSubmenuTriggerKeydown(event2,index2){if(isModifiedHorizontalArrow(event2))return;if((event2.key==="Home"||event2.key==="End")&&(event2.altKey||event2.ctrlKey||event2.metaKey))return;const horizontalKeys=submenuHorizontalKeys();if(event2.key===horizontalKeys.enter){event2.preventDefault();if($$props.item.submenu?.[index2]){const submenuId=$$props.item.submenu[index2].id;$4.set(openSubmenuId,submenuId,true);focusSubmenuPanel(submenuId)}return}if(event2.key===horizontalKeys.return){event2.preventDefault();$$props.focusElementById($$props.triggerId($$props.item.id));return}switch(event2.key){case"ArrowDown":event2.preventDefault();focusSubmenuTriggerAt(index2+1);break;case"ArrowUp":event2.preventDefault();focusSubmenuTriggerAt(index2-1);break;case"Home":event2.preventDefault();focusSubmenuTriggerAt(0);break;case"End":event2.preventDefault();if($$props.item.submenu)focusSubmenuTriggerAt($$props.item.submenu.length-1);break;case"Enter":case" ":event2.preventDefault();if($$props.item.submenu?.[index2]){const submenuId=$$props.item.submenu[index2].id;$4.set(openSubmenuId,submenuId,true);focusSubmenuPanel(submenuId)}break;case"Escape":event2.preventDefault();$$props.closeMenu(true);break;default:break}}function onSubmenuPanelKeydown(event2){if(isModifiedHorizontalArrow(event2))return;if(event2.key===submenuHorizontalKeys().return&&$4.get(openSubmenu)){event2.preventDefault();event2.stopPropagation();$$props.focusElementById($$props.submenuTriggerId($$props.item.id,$4.get(openSubmenu).id));return}if(event2.key==="Escape"){event2.preventDefault();event2.stopPropagation();$$props.closeMenu(true)}}function onContentKeydown(event2){if(event2.key!=="Escape")return;event2.preventDefault();$$props.closeMenu(true)}var section_1=root_8();var div=$4.child(section_1);$4.each(div,21,()=>sections($$props.item),(section)=>section.id,($$anchor2,section)=>{var section_2=root_3();var node=$4.child(section_2);{var consequent=($$anchor3)=>{var h3=root2();var text=$4.child(h3,true);$4.reset(h3);$4.template_effect(()=>$4.set_text(text,$4.get(section).title));$4.append($$anchor3,h3)};$4.if(node,($$render)=>{if($4.get(section).title)$$render(consequent)})}var ul=$4.sibling(node,2);$4.each(ul,21,()=>$4.get(section).links,(link)=>link.id,($$anchor3,link)=>{var li=root_2();var a=$4.child(li);var span=$4.child(a);var text_1=$4.child(span,true);$4.reset(span);var node_1=$4.sibling(span,2);{var consequent_1=($$anchor4)=>{var span_1=root_1();var text_2=$4.child(span_1,true);$4.reset(span_1);$4.template_effect(()=>$4.set_text(text_2,$4.get(link).description));$4.append($$anchor4,span_1)};$4.if(node_1,($$render)=>{if($4.get(link).description)$$render(consequent_1)})}$4.reset(a);$4.reset(li);$4.template_effect(()=>{$4.set_attribute(a,"href",$4.get(link).href);$4.set_text(text_1,$4.get(link).label)});$4.append($$anchor3,li)});$4.reset(ul);$4.reset(section_2);$4.append($$anchor2,section_2)});$4.reset(div);var node_2=$4.sibling(div,2);{var consequent_6=($$anchor2)=>{var section_3=root_7();var ul_1=$4.child(section_3);$4.each(ul_1,23,()=>$$props.item.submenu,(sub)=>sub.id,($$anchor3,sub,subIndex)=>{var li_1=root_4();var button=$4.child(li_1);var text_3=$4.child(button);var node_3=$4.sibling(text_3);{var consequent_2=($$anchor4)=>{Chevron_left($$anchor4,{size:16,strokeWidth:2,"aria-hidden":"true"})};var alternate=($$anchor4)=>{Chevron_right($$anchor4,{size:16,strokeWidth:2,"aria-hidden":"true"})};$4.if(node_3,($$render)=>{if($$props.resolvedDirection==="rtl")$$render(consequent_2);else $$render(alternate,-1)})}$4.reset(button);$4.reset(li_1);$4.template_effect(($0,$1)=>{$4.set_attribute(button,"id",$0);$4.set_attribute(button,"aria-controls",$1);$4.set_attribute(button,"aria-expanded",$4.get(openSubmenu)?.id===$4.get(sub).id?"true":"false");$4.set_attribute(button,"data-active",$4.get(openSubmenu)?.id===$4.get(sub).id?"true":"false");$4.set_text(text_3,`${$4.get(sub).label??""} `)},[()=>$$props.submenuTriggerId($$props.item.id,$4.get(sub).id),()=>$4.get(openSubmenu)?.id===$4.get(sub).id?$$props.submenuPanelId($$props.item.id,$4.get(sub).id):undefined]);$4.event("mouseenter",button,()=>onSubmenuChange($4.get(sub).id));$4.delegated("click",button,()=>onSubmenuChange($4.get(sub).id));$4.event("focus",button,()=>onSubmenuChange($4.get(sub).id));$4.delegated("keydown",button,(event2)=>onSubmenuTriggerKeydown(event2,$4.get(subIndex)));$4.append($$anchor3,li_1)});$4.reset(ul_1);var node_4=$4.sibling(ul_1,2);{var consequent_5=($$anchor3)=>{var div_1=root_6();$4.each(div_1,21,()=>sections($4.get(openSubmenu)),(section)=>section.id,($$anchor4,section)=>{var section_4=root_3();var node_5=$4.child(section_4);{var consequent_3=($$anchor5)=>{var h4=root_5();var text_4=$4.child(h4,true);$4.reset(h4);$4.template_effect(()=>$4.set_text(text_4,$4.get(section).title));$4.append($$anchor5,h4)};$4.if(node_5,($$render)=>{if($4.get(section).title&&$4.get(section).title!==$4.get(openSubmenu).label)$$render(consequent_3)})}var ul_2=$4.sibling(node_5,2);$4.each(ul_2,21,()=>$4.get(section).links,(link)=>link.id,($$anchor5,link)=>{var li_2=root_2();var a_1=$4.child(li_2);var span_2=$4.child(a_1);var text_5=$4.child(span_2,true);$4.reset(span_2);var node_6=$4.sibling(span_2,2);{var consequent_4=($$anchor6)=>{var span_3=root_1();var text_6=$4.child(span_3,true);$4.reset(span_3);$4.template_effect(()=>$4.set_text(text_6,$4.get(link).description));$4.append($$anchor6,span_3)};$4.if(node_6,($$render)=>{if($4.get(link).description)$$render(consequent_4)})}$4.reset(a_1);$4.reset(li_2);$4.template_effect(()=>{$4.set_attribute(a_1,"href",$4.get(link).href);$4.set_text(text_5,$4.get(link).label)});$4.append($$anchor5,li_2)});$4.reset(ul_2);$4.reset(section_4);$4.append($$anchor4,section_4)});$4.reset(div_1);$4.template_effect(($0,$1)=>{$4.set_attribute(div_1,"id",$0);$4.set_attribute(div_1,"aria-labelledby",$1)},[()=>$$props.submenuPanelId($$props.item.id,$4.get(openSubmenu).id),()=>$$props.submenuTriggerId($$props.item.id,$4.get(openSubmenu).id)]);$4.delegated("keydown",div_1,onSubmenuPanelKeydown);$4.append($$anchor3,div_1)};$4.if(node_4,($$render)=>{if($4.get(openSubmenu))$$render(consequent_5)})}$4.reset(section_3);$4.template_effect(()=>$4.set_attribute(section_3,"aria-label",`${$$props.item.label} submenu`));$4.append($$anchor2,section_3)};$4.if(node_2,($$render)=>{if($$props.item.submenu&&$$props.item.submenu.length>0)$$render(consequent_6)})}$4.reset(section_1);$4.template_effect(($0,$1)=>{$4.set_attribute(section_1,"id",$0);$4.set_attribute(section_1,"aria-labelledby",$1);$4.set_attribute(section_1,"data-motion",$$props.motionDirection)},[()=>$$props.contentId($$props.item.id),()=>$$props.triggerId($$props.item.id)]);$4.delegated("keydown",section_1,onContentKeydown);$4.append($$anchor,section_1);$4.pop()}$4.delegate(["keydown","click"]);var rest_excludes=new Set(["$$slots","$$events","$$legacy","id","items","openOnHover","viewportVisible","indicatorVisible","label","dir","class"]);var root_12=$5.from_html(`<li><button type="button" class="cinder-mega-menu__trigger"> </button></li>`);var root_22=$5.from_html(`<div class="cinder-mega-menu__indicator-track" aria-hidden="true"><div class="cinder-mega-menu__indicator"></div></div>`);var root_32=$5.from_html(`<div><!></div>`);var root_42=$5.from_html(`<nav><ul class="cinder-mega-menu__list"></ul> <!> <!></nav>`);function Mega_menu($$anchor,$$props){const generatedId=$5.props_id();$5.push($$props,true);let openOnHover=$5.prop($$props,"openOnHover",3,false),viewportVisible=$5.prop($$props,"viewportVisible",3,true),indicatorVisible=$5.prop($$props,"indicatorVisible",3,true),label=$5.prop($$props,"label",3,"Main navigation"),rest=$5.rest_props($$props,rest_excludes);let navElement=$5.state(null);let directionRevision=$5.state(0);let directionChainRevision=$5.state(0);const localeContext=getLocaleContext();let openItemId=$5.state(null);let previousOpenIndex=$5.state(null);let indicatorStyle=$5.state("");let hoverOpenedId=$5.state(null);const directionElement=$5.derived(()=>$$props.dir==="auto"?$5.get(navElement):$5.get(navElement)?.parentElement??$5.get(navElement));const resolvedDirection=$5.derived(()=>{$5.get(directionRevision);if($$props.dir==="rtl"||$$props.dir==="ltr"){return elementDirectionStyleOverride($5.get(navElement))??$$props.dir}if($$props.dir==="auto"){return resolveTextDirection($5.get(navElement),localeContext?.direction)}return $5.get(navElement)?resolveTextDirection($5.get(navElement),localeContext?.direction,{ignoreElementDirectionAttribute:true}):resolveTextDirection($5.get(directionElement),localeContext?.direction)});const renderedDirection=$5.derived(()=>{$5.get(directionRevision);if($$props.dir==="auto"||$$props.dir==="rtl"||$$props.dir==="ltr"){return $$props.dir}return $5.get(navElement)?resolveTextDirection($5.get(navElement),localeContext?.direction,{ignoreElementDirectionAttribute:true})??null:localeContext?.direction??null});let pendingIndicatorFrame=null;function scheduleIndicatorRecompute(){if(pendingIndicatorFrame!==null)return;pendingIndicatorFrame=requestAnimationFrame(()=>{pendingIndicatorFrame=null;$5.set(directionRevision,$5.get(directionRevision)+1);if($5.get(openItemId)!==null)updateIndicator()})}$5.user_effect(()=>{return()=>{if(pendingIndicatorFrame===null)return;cancelAnimationFrame(pendingIndicatorFrame);pendingIndicatorFrame=null}});$5.user_effect(()=>{return observeTextDirection($5.get(navElement),()=>{$5.set(directionChainRevision,$5.get(directionChainRevision)+1);scheduleIndicatorRecompute()})});$5.user_effect(()=>observeTextDirectionMediaQueries($5.get(navElement),()=>{scheduleIndicatorRecompute()}));const openItem=$5.derived(()=>$$props.items.find((item)=>item.id===$5.get(openItemId))??null);const openIndex=$5.derived(()=>$5.get(openItemId)?$$props.items.findIndex((item)=>item.id===$5.get(openItemId)):-1);const motionDirection=$5.derived(()=>{if($5.get(openIndex)<0||$5.get(previousOpenIndex)===null||$5.get(previousOpenIndex)===$5.get(openIndex))return"none";const movingTowardEnd=$5.get(resolvedDirection)==="rtl"?$5.get(openIndex)<$5.get(previousOpenIndex):$5.get(openIndex)>$5.get(previousOpenIndex);return movingTowardEnd?"from-end":"from-start"});$5.user_effect(()=>{if(!$5.get(openItemId))return;if($$props.items.some((item)=>item.id===$5.get(openItemId)))return;closeMenu()});function safeDomId(value){return value.trim().replaceAll(/[^A-Za-z0-9_-]+/g,"-").replaceAll(/^-+|-+$/g,"")}function stableHash(value){return Array.from(value).map((character)=>(character.codePointAt(0)??0).toString(16).padStart(5,"0")).join("-")}const instanceId=$5.derived(()=>safeDomId($$props.id??generatedId)||safeDomId(generatedId)||"menu");function triggerId(itemId){const normalized=safeDomId(itemId)||"item";return`cinder-mega-menu-${$5.get(instanceId)}-trigger-${normalized}-${stableHash(itemId)}`}function contentId(itemId){const normalized=safeDomId(itemId)||"item";return`cinder-mega-menu-${$5.get(instanceId)}-content-${normalized}-${stableHash(itemId)}`}function submenuTriggerId(itemId,submenuId){const normalizedItem=safeDomId(itemId)||"item";const normalizedSubmenu=safeDomId(submenuId)||"submenu";return`cinder-mega-menu-${$5.get(instanceId)}-submenu-trigger-${normalizedItem}-${normalizedSubmenu}-${stableHash(`${itemId}:${submenuId}`)}`}function submenuPanelId(itemId,submenuId){const normalizedItem=safeDomId(itemId)||"item";const normalizedSubmenu=safeDomId(submenuId)||"submenu";return`cinder-mega-menu-${$5.get(instanceId)}-submenu-panel-${normalizedItem}-${normalizedSubmenu}-${stableHash(`${itemId}:${submenuId}`)}`}function menuRoot(){const root3=$5.get(navElement)?.getRootNode();if(!root3||!("activeElement"in root3)||!("querySelector"in root3))return null;return root3}function escapeIdForSelector(id){if(typeof CSS!=="undefined"&&typeof CSS.escape==="function")return CSS.escape(id);return id.replaceAll("\\","\\\\").replaceAll('"',"\\\"").replaceAll(`
2
2
  `,"\\a ").replaceAll("\r","\\d ").replaceAll("\f","\\c ")}function elementById(id){return menuRoot()?.querySelector(`[id="${escapeIdForSelector(id)}"]`)??null}function focusElementById(id){elementById(id)?.focus()}function activeElement(){return menuRoot()?.activeElement??null}function updateIndicator(){if(!indicatorVisible()||!$5.get(navElement)||!$5.get(openItemId)){$5.set(indicatorStyle,"");return}const trigger=$5.get(navElement).querySelector(`#${CSS.escape(triggerId($5.get(openItemId)))}`);if(!trigger){$5.set(indicatorStyle,"");return}const navRect=$5.get(navElement).getBoundingClientRect();const triggerRect=trigger.getBoundingClientRect();const left=Math.max(0,triggerRect.left-navRect.left);$5.set(indicatorStyle,`inline-size:${triggerRect.width}px;transform:translateX(${left}px);`)}function openItemByIndex(index2){const bounded=(index2%$$props.items.length+$$props.items.length)%$$props.items.length;const next=$$props.items[bounded];if(!next)return;if($5.get(openIndex)>=0)$5.set(previousOpenIndex,$5.get(openIndex),true);$5.set(openItemId,next.id,true)}function closeMenu(restoreFocus=false){const currentItemId=$5.get(openItemId);const shouldRestoreFocus=restoreFocus&&currentItemId!==null&&typeof document!=="undefined"&&$5.get(navElement)?.contains(activeElement());$5.set(openItemId,null);$5.set(previousOpenIndex,null);if(shouldRestoreFocus&&currentItemId){tick2().then(()=>{focusElementById(triggerId(currentItemId))})}}function focusTriggerAt(index2){const bounded=(index2%$$props.items.length+$$props.items.length)%$$props.items.length;const target=$$props.items[bounded];if(!target||typeof document==="undefined")return;focusElementById(triggerId(target.id))}function onTriggerClick(index2){const target=$$props.items[index2];if(!target)return;if($5.get(hoverOpenedId)===target.id){$5.set(hoverOpenedId,null);return}$5.set(hoverOpenedId,null);if($5.get(openItemId)===target.id){closeMenu();return}openItemByIndex(index2)}function onTriggerEnter(index2){if(!openOnHover())return;const target=$$props.items[index2];if(!target)return;$5.set(hoverOpenedId,target.id,true);openItemByIndex(index2)}async function focusPanelContent(itemId){if(typeof document==="undefined")return;await tick2();const panel=elementById(contentId(itemId));if(!(panel instanceof HTMLElement))return;const firstFocusable=panel.querySelector('a[href], button:not([disabled]), [tabindex]:not([tabindex="-1"])');if(firstFocusable){firstFocusable.focus();return}panel.focus()}function onTriggerKeydown(event3,index2){const forwardIndexDelta=$5.get(resolvedDirection)==="rtl"?-1:1;switch(event3.key){case"ArrowRight":event3.preventDefault();focusTriggerAt(index2+forwardIndexDelta);if($5.get(openItemId))openItemByIndex(index2+forwardIndexDelta);break;case"ArrowLeft":event3.preventDefault();focusTriggerAt(index2-forwardIndexDelta);if($5.get(openItemId))openItemByIndex(index2-forwardIndexDelta);break;case"Home":event3.preventDefault();focusTriggerAt(0);if($5.get(openItemId))openItemByIndex(0);break;case"End":event3.preventDefault();focusTriggerAt($$props.items.length-1);if($5.get(openItemId))openItemByIndex($$props.items.length-1);break;case"ArrowDown":case"Enter":case" ":event3.preventDefault();const target=$$props.items[index2];if(!target)return;openItemByIndex(index2);focusPanelContent(target.id);break;case"Escape":event3.preventDefault();closeMenu();break;default:break}}function onRootFocusOut(event3){if(!$5.get(navElement))return;if(event3.relatedTarget instanceof Node&&$5.get(navElement).contains(event3.relatedTarget))return;closeMenu()}$5.user_effect(()=>{$5.get(resolvedDirection);updateIndicator()});$5.user_effect(()=>{if(typeof window==="undefined")return;const handler=()=>{scheduleIndicatorRecompute()};window.addEventListener("resize",handler);return()=>window.removeEventListener("resize",handler)});$5.user_effect(()=>{if(!$5.get(navElement))return;const element2=$5.get(navElement);const refresh=()=>{scheduleIndicatorRecompute()};element2.addEventListener("focusin",refresh);element2.addEventListener("focusout",refresh);return()=>{element2.removeEventListener("focusin",refresh);element2.removeEventListener("focusout",refresh)}});$5.user_effect(()=>{$5.get(directionChainRevision);if(!$5.get(navElement)||typeof ResizeObserver==="undefined"||$5.get(openItemId)===null)return;const observer=new ResizeObserver(()=>{scheduleIndicatorRecompute()});let current=$5.get(navElement);while(current){observer.observe(current);current=composedParentElement(current)}return()=>observer.disconnect()});$5.user_effect(()=>{if(!openOnHover()||!$5.get(openItemId))return;const closeIfOutside=(event3)=>{if(!$5.get(navElement))return;if(event3.target instanceof Node&&$5.get(navElement).contains(event3.target))return;closeMenu()};document.addEventListener("mousemove",closeIfOutside,true);return()=>document.removeEventListener("mousemove",closeIfOutside,true)});$5.user_effect(()=>{if(!$5.get(openItemId))return;const closeOnOutsidePointer=(event3)=>{if(!$5.get(navElement))return;if(event3.target instanceof Node&&$5.get(navElement).contains(event3.target))return;closeMenu()};const supportsPointerEvents=typeof window!=="undefined"&&typeof window.PointerEvent!=="undefined";if(supportsPointerEvents){document.addEventListener("pointerdown",closeOnOutsidePointer,true);return()=>document.removeEventListener("pointerdown",closeOnOutsidePointer,true)}document.addEventListener("mousedown",closeOnOutsidePointer,true);document.addEventListener("touchstart",closeOnOutsidePointer,{capture:true,passive:true});return()=>{document.removeEventListener("mousedown",closeOnOutsidePointer,true);document.removeEventListener("touchstart",closeOnOutsidePointer,true)}});var nav=root_42();$5.attribute_effect(nav,($0)=>({id:$$props.id,...rest,dir:$5.get(renderedDirection),class:$0,"aria-label":label(),onfocusout:onRootFocusOut}),[()=>classNames("cinder-mega-menu",$$props.class)]);var ul=$5.child(nav);$5.each(ul,23,()=>$$props.items,(item)=>item.id,($$anchor2,item,index2)=>{var li=root_12();var button=$5.child(li);var text=$5.child(button,true);$5.reset(button);$5.reset(li);$5.template_effect(($0,$1)=>{$5.set_attribute(button,"id",$0);$5.set_attribute(button,"aria-controls",$1);$5.set_attribute(button,"aria-expanded",$5.get(openItemId)===$5.get(item).id?"true":"false");$5.set_text(text,$5.get(item).label)},[()=>triggerId($5.get(item).id),()=>$5.get(openItemId)===$5.get(item).id?contentId($5.get(item).id):undefined]);$5.event("mouseenter",button,()=>onTriggerEnter($5.get(index2)));$5.delegated("click",button,()=>onTriggerClick($5.get(index2)));$5.delegated("keydown",button,(event3)=>onTriggerKeydown(event3,$5.get(index2)));$5.append($$anchor2,li)});$5.reset(ul);var node=$5.sibling(ul,2);{var consequent=($$anchor2)=>{var div=root_22();var div_1=$5.child(div);$5.reset(div);$5.template_effect(()=>$5.set_style(div_1,$5.get(indicatorStyle)));$5.append($$anchor2,div)};$5.if(node,($$render)=>{if(indicatorVisible())$$render(consequent)})}var node_1=$5.sibling(node,2);{var consequent_1=($$anchor2)=>{var div_2=root_32();var node_2=$5.child(div_2);$5.key(node_2,()=>$5.get(openItem).id,($$anchor3)=>{Mega_menu_content($$anchor3,{get item(){return $5.get(openItem)},get motionDirection(){return $5.get(motionDirection)},get resolvedDirection(){return $5.get(resolvedDirection)},contentId,triggerId,submenuTriggerId,submenuPanelId,elementById,focusElementById,closeMenu})});$5.reset(div_2);$5.template_effect(()=>$5.set_class(div_2,1,$5.clsx(viewportVisible()?"cinder-mega-menu__viewport":undefined)));$5.append($$anchor2,div_2)};$5.if(node_1,($$render)=>{if($5.get(openItem))$$render(consequent_1)})}$5.reset(nav);$5.bind_this(nav,($$value)=>$5.set(navElement,$$value),()=>$5.get(navElement));$5.template_effect(()=>nav.dir=nav.dir);$5.append($$anchor,nav);$5.pop()}$5.delegate(["click","keydown"]);var mega_menu_default=Mega_menu;export{Mega_menu as MegaMenu,mega_menu_default as default};
3
3
 
4
- //# debugId=5F8648A61DF68F2464756E2164756E21
4
+ //# debugId=ADA1C40961A68A3564756E2164756E21