@rogieking/figui3 10.0.6 → 10.0.7

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.
@@ -1 +1 @@
1
- fig-layer{--indent:var(--spacer-3);color:var(--figma-color-text);user-select:none;width:100%;padding:0 var(--spacer-3);border-radius:var(--radius-medium);display:block;position:relative}fig-layer:has(fig-layer)>.fig-layer-row>.fig-layer-chevron{visibility:visible}fig-layer>.fig-layer-row{align-items:center;gap:var(--spacer-1);padding:var(--spacer-1) var(--spacer-2);height:var(--spacer-4);border-radius:var(--radius-medium);display:flex;position:relative}fig-layer>.fig-layer-row .fig-layer-chevron{mask-image:var(--icon-16-chevron);visibility:hidden;background:var(--figma-color-text-tertiary);width:var(--spacer-3);height:var(--spacer-3);left:calc(var(--spacer-3) * -1);top:var(--spacer-1);flex-shrink:0;transition:transform .15s;display:flex;position:absolute;rotate:-90deg;mask-position:50%;mask-size:contain;mask-repeat:no-repeat}fig-layer>.fig-layer-row:hover{background:var(--figma-color-bg-secondary)}fig-layer>.fig-layer-row:hover .fig-layer-actions{opacity:1}fig-layer>.fig-layer-row .fig-layer-icon{width:var(--spacer-3);height:var(--spacer-3);color:var(--figma-color-icon-tertiary);margin-left:calc(var(--spacer-1) * -1);flex-shrink:0}fig-layer>.fig-layer-row>label{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--figma-color-text);flex:1;overflow:hidden}fig-layer .fig-layer-actions{margin-right:calc(-1 * var(--spacer-1));opacity:0;flex-shrink:0;gap:0;transition:opacity .15s;display:flex}fig-layer .fig-layer-actions>*{flex-shrink:0}fig-layer>fig-layer{margin-top:1px;padding:0}fig-layer>fig-layer .fig-layer-row{padding-left:var(--indent)}fig-layer:not([open])>fig-layer,fig-layer[open=false]>fig-layer{display:none}fig-layer[open]:not([open=false])>.fig-layer-row>.fig-layer-chevron{rotate:0deg}fig-layer[visible=false]>.fig-layer-row>label{color:var(--figma-color-text-tertiary)}fig-layer[selected]:not([selected=false])>.fig-layer-row{background:var(--figma-color-bg-selected)}fig-layer[selected]:not([selected=false])>.fig-layer-row>.fig-layer-icon{color:var(--figma-color-icon)}:root,:host{--icon-24-eyedropper:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15.1592 5.65801C16.0376 4.78045 17.4621 4.78055 18.3408 5.65899L18.4951 5.82989C19.1671 6.65442 19.168 7.84476 18.4951 8.66973L18.3408 8.84063L16.6455 10.533C17.1104 11.083 17.1181 11.889 16.6641 12.4461L16.5605 12.5604C16.0111 13.1097 15.1425 13.1428 14.5537 12.6629L14.5342 12.6453L10.0908 17.0916C9.6188 17.5633 8.98876 17.7764 8.375 17.742L7.56055 18.5574C6.97441 19.1432 6.02451 19.1422 5.43945 18.5584V18.5574C4.8538 17.9718 4.85405 17.0221 5.43945 16.4363L6.25586 15.618C6.22412 15.0058 6.44026 14.3794 6.90918 13.91L11.3516 9.46367C10.856 8.87434 10.885 7.99381 11.4395 7.43926L11.5537 7.33574C12.1094 6.88283 12.9136 6.88854 13.4639 7.35137L15.1592 5.65801ZM7.61621 14.617C7.33755 14.8961 7.21782 15.2747 7.25781 15.6385C7.27925 15.8351 7.24419 16.0445 7.10449 16.1844L6.14648 17.1434C5.9516 17.3387 5.95135 17.6553 6.14648 17.8504C6.34167 18.0449 6.65842 18.0451 6.85352 17.8504L7.80859 16.8943C7.94931 16.7536 8.16065 16.7184 8.3584 16.741C8.72329 16.7828 9.10374 16.6643 9.38379 16.3846L13.8223 11.9432L12.0547 10.1756L7.61621 14.617ZM17.6338 6.36602C17.1458 5.87828 16.3544 5.8783 15.8662 6.36602L14.084 8.14629L14.0186 8.20586C13.6767 8.48476 13.1722 8.46484 12.8535 8.14629C12.6583 7.95131 12.3417 7.95119 12.1465 8.14629C11.9514 8.34148 11.9515 8.65808 12.1465 8.85332L15.1465 11.8533C15.3175 12.024 15.5814 12.0451 15.7754 11.9168L15.8535 11.8533C16.0486 11.6582 16.0484 11.3416 15.8535 11.1463V11.1453C15.8524 11.1443 15.8507 11.1434 15.8496 11.1424C15.5128 10.8013 15.514 10.2513 15.8535 9.91192L17.6338 8.1336C18.1216 7.6457 18.1213 6.85425 17.6338 6.36602Z' fill='black' fill-opacity='0.9'/%3E%3C/svg%3E")}fig-interpolation-swatch{width:1.5rem;height:1.5rem;color:var(--figma-color-bordertranslucent);flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative;overflow:visible;&[size=large]{width:2rem;height:2rem;& .fig-interpolation-swatch-svg,& .fig-interpolation-swatch-fill{width:1.25rem;height:1.25rem}}& .fig-interpolation-swatch-svg{width:1rem;height:1rem;display:block;overflow:visible}& .fig-interpolation-swatch-fill{background:linear-gradient(90deg,red,#4f9eff);width:1rem;height:1rem;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}}dialog[is=fig-toast]{--fig-toast-bg-color:var(--figma-color-bg);--z-index:999999;z-index:var(--z-index);box-shadow:var(--figma-elevation-100);border-radius:var(--radius-large);padding:var(--spacer-2) var(--spacer-3);align-items:center;gap:var(--spacer-2-5);min-width:0;height:2.5rem;color:var(--figma-color-text);background-color:var(--fig-toast-bg-color);flex-wrap:nowrap;justify-content:center;&[icon]{&>fig-icon:first-child{margin-inline:calc(var(--spacer-2) * -1)}}&>fig-spinner:first-child{margin-inline:calc(var(--spacer-2) * -1)}&[open]:not([open=false]){flex-direction:row;display:flex}& p{color:inherit;font-weight:var(--body-medium-strong-fontWeight);margin:0;padding:0}& hr[vertical]{margin:0}&>fig-separator[data-fig-toast-dismiss-separator]{--fig-separator-color:var(--figma-color-bordertranslucent);flex:none;align-self:stretch;margin:0}& fig-button:last-child{margin-inline:calc(var(--spacer-2) * -1);margin-left:calc(var(--spacer-1) * -1)}&>fig-icon[data-fig-toast-icon]{--size:var(--spacer-4);flex:none}&>fig-button[data-fig-toast-dismiss]{flex:none}&[theme=dark]{color-scheme:dark}&[theme=light]{color-scheme:light}&[theme=danger]{background-color:var(--figma-color-bg-danger);color-scheme:dark}&[theme=brand]{background-color:var(--figma-color-bg-brand);color-scheme:dark}&[theme=success]{background-color:var(--figma-color-bg-success);color-scheme:dark}}fig-fill-picker{display:contents;&>[slot^=mode-]{display:none}}.fig-fill-picker-dialog{width:240px;padding:0;&>fig-content{padding-bottom:var(--spacer-2-5);padding-top:var(--spacer-2)}& fig-tab{padding:var(--spacer-1) var(--spacer-1);font-size:.6875rem}& .fig-fill-picker-close{margin-left:auto}& .fig-fill-picker-tab{display:none;&:first-child{display:block}}& .fig-fill-picker-tab:is([data-tab=solid],[data-tab=gradient]){& fig-preview{overflow:visible}}& .fig-fill-picker-color-area{aspect-ratio:1;width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3);&>:not(fig-handle){border-radius:inherit;place-self:center;width:100%;height:100%}& canvas{border-radius:var(--radius-medium);width:100%;height:100%}}& .fig-fill-picker-color-area fig-handle{z-index:3}& .fig-fill-picker-sliders{grid-template-columns:calc(3.5rem + var(--spacer-3)) 1fr;padding-right:var(--spacer-3);align-items:center;gap:var(--spacer-2);padding-bottom:var(--spacer-1);grid-template-rows:1fr 1fr;display:grid;& .fig-fill-picker-eyedropper{margin-right:calc(var(--spacer-3) * -1);aspect-ratio:1;grid-area:1/1/3;place-self:center;width:3.5rem;height:3.5rem}& fig-slider{grid-column:2;min-width:0}&.is-hue-only{grid-template-rows:1fr;& .fig-fill-picker-eyedropper{width:auto;height:var(--spacer-4);aspect-ratio:auto;grid-row:1}}}& .fig-fill-picker-inputs{&:not([direction=vertical]):not(:has(>label)){grid-template-columns:var(--fig-field-left-padding) 3.5rem var(--spacer-2) minmax(0, 1fr) var(--fig-field-right-padding)}& .fig-fill-picker-input-mode{flex-shrink:0;align-self:center;width:3.5rem}& .fig-fill-picker-input-fields{width:100%;min-width:0;display:flex;& .input-combo{flex:1;min-width:0;& fig-input-number>input,& fig-input-text:not(.fig-fill-picker-ci-hex)>input{text-align:center;padding-inline:0}}& fig-input-text{flex:1;min-width:0}& .fig-fill-picker-ci-css{font-variant-numeric:tabular-nums}& .fig-fill-picker-ci-hex-row{& .fig-fill-picker-ci-hex{flex:auto;min-width:0}& .fig-fill-picker-ci-a{flex:0 0 3rem}}& .fig-fill-picker-ci-a{flex:0 0 2.75rem;min-width:2.75rem}}}& .fig-fill-picker-gradient-preview{aspect-ratio:auto;width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3);margin-top:calc(var(--spacer-4) + var(--spacer-1));background:0 0;margin-bottom:0;&:after{display:none}}& fig-field.fig-fill-picker-gradient-header{grid-template-columns:unset;grid-template-areas:unset;padding-right:var(--spacer-2);padding-left:var(--spacer-2);align-items:center;gap:var(--spacer-2);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}& .fig-fill-picker-gradient-type{flex:0 auto;width:auto;min-width:0;display:flex}& .fig-fill-picker-gradient-actions{align-items:center;gap:var(--spacer-1);flex-shrink:0;margin-left:auto;display:flex}}& .fig-fill-picker-gradient-stops{& .fig-fill-picker-gradient-stops-header{&>span{flex:1}}}& fig-field.fig-fill-picker-gradient-interpolation-field{grid-template-columns:unset;grid-template-areas:unset;padding-left:var(--spacer-3);padding-right:var(--spacer-2);align-items:center;gap:var(--spacer-1);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}}& .fig-fill-picker-gradient-interpolation-modes{flex:auto;min-width:0;& fig-interpolation-swatch{pointer-events:none}}& .fig-fill-picker-gradient-interpolation-more{flex:none;display:inline-flex;position:relative;&>fig-button{pointer-events:none}& .fig-fill-picker-gradient-space{opacity:0;width:100%;position:absolute;inset:0}&:has(.fig-fill-picker-gradient-space:hover)>fig-button,&:has(.fig-fill-picker-gradient-space[open])>fig-button{background-color:var(--figma-color-bg-transparent-hover)}&:has(.fig-fill-picker-gradient-space:focus-within)>fig-button{outline:var(--figma-focus-outline);outline-offset:var(--figma-focus-outline-offset)}}& .fig-fill-picker-gradient-space{&::part(prepend){display:none}& fig-select-option{min-height:3rem;&:hover:before,&:focus-visible:before{background-color:var(--figma-color-bg-tertiary)}}& .fig-fill-picker-gradient-interpolation-label{flex-direction:column;justify-content:center;min-width:0;line-height:1.25;display:flex}& .fig-fill-picker-gradient-interpolation-title,& .fig-fill-picker-gradient-interpolation-subtitle{text-overflow:ellipsis;display:block;overflow:hidden}& .fig-fill-picker-gradient-interpolation-subtitle{color:var(--figma-color-text-tertiary)}& fig-select-options.fig-fill-picker-gradient-interpolation-collapsed{overflow:hidden}}& .fig-fill-picker-gradient-stops-list{gap:var(--spacer-1);flex-direction:column;display:flex;& fig-reorder{display:contents}}& .fig-fill-picker-gradient-stop-row{padding-right:var(--spacer-2);padding-left:var(--spacer-3);gap:var(--spacer-2);display:flex;&.dragging{background-color:var(--figma-color-bg-selected)}&>.fig-fill-picker-stop-position{flex:0 3rem;width:3rem;min-width:0}& .fig-fill-picker-stop-color{flex:1;min-width:0;& fig-input-text{min-width:0}}& .fig-fill-picker-stop-remove{flex-shrink:0}}& fig-field.fig-fill-picker-media-header{grid-template-columns:unset;grid-template-areas:unset;padding-left:var(--spacer-3);padding-right:var(--spacer-2);justify-content:space-between;align-items:center;gap:var(--spacer-2);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}& .fig-fill-picker-scale-mode{flex:none;width:4.5rem}& .fig-fill-picker-scale{flex:none;width:56px}& .fig-fill-picker-media-rotate{flex-shrink:0;margin-left:auto}}& .fig-fill-picker-media-preview{width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3) var(--spacer-1);border-radius:var(--radius-medium);position:relative;&.dragover{outline:2px dashed var(--figma-color-border-brand);outline-offset:-2px}&.has-media{& fig-preview fig-button,& fig-input-file fig-button{visibility:hidden}&:hover{& fig-preview fig-button,& fig-input-file fig-button{visibility:visible}}}}& fig-image.fig-fill-picker-media-preview{aspect-ratio:1;justify-content:center;align-items:center;display:flex;overflow:hidden}& .fig-fill-picker-checkerboard{background-image:linear-gradient(45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%), linear-gradient(-45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%), linear-gradient(-45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%);background-position:0 0,0 8px,8px -8px,-8px 0;background-size:16px 16px;position:absolute;inset:0}& div.fig-fill-picker-image-preview{width:100%;height:100%;display:none;position:absolute;inset:0}& fig-image.fig-fill-picker-image-preview{width:auto;max-width:none;max-height:none}& video.fig-fill-picker-video-preview{object-fit:cover;width:100%;height:100%;display:none;position:absolute;inset:0}& fig-media.fig-fill-picker-video-preview{aspect-ratio:unset;max-width:none;max-height:none;width:calc(100% - var(--spacer-3) * 2);align-items:stretch;gap:var(--spacer-2);flex-direction:column;display:flex;overflow:visible;&>fig-preview{aspect-ratio:1;border-radius:var(--radius-medium);width:100%;max-width:none;overflow:hidden}}& .fig-fill-picker-upload{z-index:1;position:relative}& .fig-fill-picker-webcam-preview{aspect-ratio:1;width:calc(100% - var(--spacer-3) * 2);max-width:none;max-height:none;margin:0 var(--spacer-3);border-radius:var(--radius-medium);margin:var(--spacer-2) var(--spacer-3);display:flex;position:relative;overflow:hidden}& .fig-fill-picker-webcam-video{object-fit:cover;width:100%;height:100%}& .fig-fill-picker-webcam-status{background:var(--figma-color-bg-secondary);color:var(--figma-color-text-secondary);justify-content:center;align-items:center;font-size:.75rem;display:flex;position:absolute;inset:0}& .fig-fill-picker-webcam-controls{padding:0 var(--spacer-3);gap:var(--spacer-1);display:flex;& .fig-fill-picker-webcam-capture{width:100%}}}fig-select{min-width:0;height:var(--spacer-4);border-radius:var(--radius-medium);background-color:var(--figma-color-bg);color:var(--figma-color-text);box-shadow:inset 0 0 0 1px var(--figma-color-border);align-items:center;display:inline-flex;position:relative;&[size=large]{height:var(--spacer-5)}&[full]:not([full=false]){width:100%;display:flex}&[icon]:not([icon=false]){--fig-select-icon-size:var(--spacer-4);flex:0 0 var(--fig-select-icon-size);width:var(--fig-select-icon-size);&[size=large]{--fig-select-icon-size:var(--spacer-5)}&::part(trigger){flex:0 0 var(--fig-select-icon-size);width:var(--fig-select-icon-size);justify-content:center;padding:0}&::part(label),&::part(prepend){display:none}&:after{left:50%;right:auto;transform:translate(-50%,-50%)}}&[disabled]:not([disabled=false]){pointer-events:none;color:var(--figma-color-text-tertiary);&:after{background-color:var(--figma-color-icon-disabled)}}&[variant=ghost]{box-shadow:none;background-color:#0000;&:hover:not([disabled]):not([disabled=false]){background-color:var(--figma-color-bg-secondary)}}&:after{content:"";width:1rem;height:1rem;mask-image:var(--icon-16-chevron);background-color:var(--figma-color-icon);pointer-events:none;z-index:1;position:absolute;top:50%;right:.25rem;transform:translateY(-50%);mask-position:50%;mask-size:contain;mask-repeat:no-repeat}}fig-select::part(listbox){--z-index:999999;--fig-popup-radius:var(--radius-large);--fig-popup-bg-color:var(--figma-color-bg-menu);z-index:var(--z-index);border-radius:var(--fig-popup-radius);background-color:var(--fig-popup-bg-color);color:var(--figma-color-text-menu);color-scheme:dark;box-shadow:var(--figma-elevation-400-menu-panel);border:0;outline:0;height:max-content;max-height:calc(100vh - 1rem);margin:0;padding:0;position:fixed;overflow:hidden}fig-select-options>:is(fig-separator,fig-menu-separator){&[label]:not([label=""]){--fig-menu-inline-padding:0 var(--spacer-2) 0 var(--spacer-5);&:before{margin-inline:unset;margin-left:calc(-1 * var(--spacer-5));margin-right:calc(-1 * var(--spacer-2))}}}fig-select-option{box-sizing:border-box;min-width:0;max-width:100%;min-height:var(--spacer-4);height:auto;padding:var(--spacer-1) var(--spacer-2);padding-right:var(--spacer-3);border-radius:var(--radius-medium);color:var(--figma-color-text-menu);cursor:default;user-select:none;text-overflow:ellipsis;white-space:nowrap;text-align:left;align-items:center;gap:0;display:flex;position:relative;overflow:hidden;& h3{margin:0 0 var(--spacer-1) 0;text-overflow:ellipsis;overflow:hidden}& label{text-overflow:ellipsis;overflow:hidden}&:before{content:"";inset:0 var(--spacer-2);border-radius:var(--radius-medium);z-index:-1;background-color:#0000;display:block;position:absolute}&:after{content:"";float:left;width:1rem;height:1rem;margin-left:var(--spacer-1);margin-right:var(--spacer-1);-webkit-mask-image:var(--icon-16-checkmark);mask-image:var(--icon-16-checkmark);visibility:hidden;background-color:currentColor;flex:0 0 1rem;order:-1;display:block;-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:contain;mask-size:contain;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}&>[slot=prepend]{margin-top:calc(var(--spacer-1) * -1);margin-bottom:calc(var(--spacer-1) * -1);margin-right:var(--spacer-1)}&:not(:has(>:not([slot=prepend]):not([slot=append])))>[slot=prepend]{vertical-align:middle;display:inline-flex}&:not(:has(>:not([slot=prepend]):not([slot=append])))>[slot=append]{float:right}&>:not([slot=prepend]):not([slot=append]){text-overflow:ellipsis;flex:auto;min-width:0;overflow:hidden}&>[slot=append]{color:var(--figma-color-text-tertiary);flex:none;margin-inline-start:auto}&:hover,&:focus-visible{outline:none;&:before{background-color:var(--figma-color-bg-menu-hover)}}&[subtle]:not([subtle=false]),fig-select[subtle]:not([subtle=false]) &:not([subtle=false]){&:hover,&:focus-visible{&:before{background-color:var(--figma-color-bg-secondary)}}}&[selected]:not([selected=false]):after,&[aria-selected=true]:after{visibility:visible}&[disabled]:not([disabled=false]),&[aria-disabled=true]{opacity:.4;pointer-events:none}}
1
+ fig-layer{--indent:var(--spacer-3);color:var(--figma-color-text);user-select:none;width:100%;padding:0 var(--spacer-3);border-radius:var(--radius-medium);display:block;position:relative}fig-layer:has(fig-layer)>.fig-layer-row>.fig-layer-chevron{visibility:visible}fig-layer>.fig-layer-row{align-items:center;gap:var(--spacer-1);padding:var(--spacer-1) var(--spacer-2);height:var(--spacer-4);border-radius:var(--radius-medium);display:flex;position:relative}fig-layer>.fig-layer-row .fig-layer-chevron{mask-image:var(--icon-16-chevron);visibility:hidden;background:var(--figma-color-text-tertiary);width:var(--spacer-3);height:var(--spacer-3);left:calc(var(--spacer-3) * -1);top:var(--spacer-1);flex-shrink:0;transition:transform .15s;display:flex;position:absolute;rotate:-90deg;mask-position:50%;mask-size:contain;mask-repeat:no-repeat}fig-layer>.fig-layer-row:hover{background:var(--figma-color-bg-secondary)}fig-layer>.fig-layer-row:hover .fig-layer-actions{opacity:1}fig-layer>.fig-layer-row .fig-layer-icon{width:var(--spacer-3);height:var(--spacer-3);color:var(--figma-color-icon-tertiary);margin-left:calc(var(--spacer-1) * -1);flex-shrink:0}fig-layer>.fig-layer-row>label{text-overflow:ellipsis;white-space:nowrap;min-width:0;color:var(--figma-color-text);flex:1;overflow:hidden}fig-layer .fig-layer-actions{margin-right:calc(-1 * var(--spacer-1));opacity:0;flex-shrink:0;gap:0;transition:opacity .15s;display:flex}fig-layer .fig-layer-actions>*{flex-shrink:0}fig-layer>fig-layer{margin-top:1px;padding:0}fig-layer>fig-layer .fig-layer-row{padding-left:var(--indent)}fig-layer:not([open])>fig-layer,fig-layer[open=false]>fig-layer{display:none}fig-layer[open]:not([open=false])>.fig-layer-row>.fig-layer-chevron{rotate:0deg}fig-layer[visible=false]>.fig-layer-row>label{color:var(--figma-color-text-tertiary)}fig-layer[selected]:not([selected=false])>.fig-layer-row{background:var(--figma-color-bg-selected)}fig-layer[selected]:not([selected=false])>.fig-layer-row>.fig-layer-icon{color:var(--figma-color-icon)}:root,:host{--icon-24-eyedropper:url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M15.1592 5.65801C16.0376 4.78045 17.4621 4.78055 18.3408 5.65899L18.4951 5.82989C19.1671 6.65442 19.168 7.84476 18.4951 8.66973L18.3408 8.84063L16.6455 10.533C17.1104 11.083 17.1181 11.889 16.6641 12.4461L16.5605 12.5604C16.0111 13.1097 15.1425 13.1428 14.5537 12.6629L14.5342 12.6453L10.0908 17.0916C9.6188 17.5633 8.98876 17.7764 8.375 17.742L7.56055 18.5574C6.97441 19.1432 6.02451 19.1422 5.43945 18.5584V18.5574C4.8538 17.9718 4.85405 17.0221 5.43945 16.4363L6.25586 15.618C6.22412 15.0058 6.44026 14.3794 6.90918 13.91L11.3516 9.46367C10.856 8.87434 10.885 7.99381 11.4395 7.43926L11.5537 7.33574C12.1094 6.88283 12.9136 6.88854 13.4639 7.35137L15.1592 5.65801ZM7.61621 14.617C7.33755 14.8961 7.21782 15.2747 7.25781 15.6385C7.27925 15.8351 7.24419 16.0445 7.10449 16.1844L6.14648 17.1434C5.9516 17.3387 5.95135 17.6553 6.14648 17.8504C6.34167 18.0449 6.65842 18.0451 6.85352 17.8504L7.80859 16.8943C7.94931 16.7536 8.16065 16.7184 8.3584 16.741C8.72329 16.7828 9.10374 16.6643 9.38379 16.3846L13.8223 11.9432L12.0547 10.1756L7.61621 14.617ZM17.6338 6.36602C17.1458 5.87828 16.3544 5.8783 15.8662 6.36602L14.084 8.14629L14.0186 8.20586C13.6767 8.48476 13.1722 8.46484 12.8535 8.14629C12.6583 7.95131 12.3417 7.95119 12.1465 8.14629C11.9514 8.34148 11.9515 8.65808 12.1465 8.85332L15.1465 11.8533C15.3175 12.024 15.5814 12.0451 15.7754 11.9168L15.8535 11.8533C16.0486 11.6582 16.0484 11.3416 15.8535 11.1463V11.1453C15.8524 11.1443 15.8507 11.1434 15.8496 11.1424C15.5128 10.8013 15.514 10.2513 15.8535 9.91192L17.6338 8.1336C18.1216 7.6457 18.1213 6.85425 17.6338 6.36602Z' fill='black' fill-opacity='0.9'/%3E%3C/svg%3E")}fig-interpolation-swatch{width:1.5rem;height:1.5rem;color:var(--figma-color-bordertranslucent);flex:none;justify-content:center;align-items:center;display:inline-flex;position:relative;overflow:visible;&[size=large]{width:2rem;height:2rem;& .fig-interpolation-swatch-svg,& .fig-interpolation-swatch-fill{width:1.25rem;height:1.25rem}}& .fig-interpolation-swatch-svg{width:1rem;height:1rem;display:block;overflow:visible}& .fig-interpolation-swatch-fill{background:linear-gradient(90deg,red,#4f9eff);width:1rem;height:1rem;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);-webkit-mask-position:50%;mask-position:50%;-webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}}dialog[is=fig-toast]{--fig-toast-bg-color:var(--figma-color-bg);--z-index:999999;z-index:var(--z-index);box-shadow:var(--figma-elevation-100);border-radius:var(--radius-large);padding:var(--spacer-2) var(--spacer-3);align-items:center;gap:var(--spacer-2-5);min-width:0;height:2.5rem;color:var(--figma-color-text);background-color:var(--fig-toast-bg-color);flex-wrap:nowrap;justify-content:center;&[icon]{&>fig-icon:first-child{margin-inline:calc(var(--spacer-2) * -1)}}&>fig-spinner:first-child{margin-inline:calc(var(--spacer-2) * -1)}&[open]:not([open=false]){flex-direction:row;display:flex}& p{color:inherit;font-weight:var(--body-medium-strong-fontWeight);margin:0;padding:0}& hr[vertical]{margin:0}&>fig-separator[data-fig-toast-dismiss-separator]{--fig-separator-color:var(--figma-color-bordertranslucent);flex:none;align-self:stretch;margin:0}& fig-button:last-child{margin-inline:calc(var(--spacer-2) * -1);margin-left:calc(var(--spacer-1) * -1)}&>fig-icon[data-fig-toast-icon]{--size:var(--spacer-4);flex:none}&>fig-button[data-fig-toast-dismiss]{flex:none}&[theme=dark]{color-scheme:dark}&[theme=light]{color-scheme:light}&[theme=danger]{background-color:var(--figma-color-bg-danger);color-scheme:dark}&[theme=brand]{background-color:var(--figma-color-bg-brand);color-scheme:dark}&[theme=success]{background-color:var(--figma-color-bg-success);color-scheme:dark}}fig-fill-picker{display:contents;&>[slot^=mode-]{display:none}}.fig-fill-picker-dialog{width:240px;padding:0;&>fig-content{padding-bottom:var(--spacer-2-5);padding-top:var(--spacer-2)}& fig-tab{padding:var(--spacer-1) var(--spacer-1);font-size:.6875rem}& .fig-fill-picker-close{margin-left:auto}& .fig-fill-picker-tab{display:none;&:first-child{display:block}}& .fig-fill-picker-tab:is([data-tab=solid],[data-tab=gradient]){& fig-preview{overflow:visible}}& .fig-fill-picker-color-area{aspect-ratio:1;width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3);&>:not(fig-handle){border-radius:inherit;place-self:center;width:100%;height:100%}& canvas{border-radius:var(--radius-medium);width:100%;height:100%}}& .fig-fill-picker-color-area fig-handle{z-index:3}& .fig-fill-picker-sliders{grid-template-columns:calc(3.5rem + var(--spacer-3)) 1fr;padding-right:var(--spacer-3);align-items:center;gap:var(--spacer-2);padding-bottom:var(--spacer-1);grid-template-rows:1fr 1fr;display:grid;& .fig-fill-picker-eyedropper{margin-right:calc(var(--spacer-3) * -1);aspect-ratio:1;grid-area:1/1/3;place-self:center;width:3.5rem;height:3.5rem}& fig-slider{grid-column:2;min-width:0}&.is-hue-only{grid-template-rows:1fr;& .fig-fill-picker-eyedropper{width:auto;height:var(--spacer-4);aspect-ratio:auto;grid-row:1}}}& .fig-fill-picker-inputs{&:not([direction=vertical]):not(:has(>label)){grid-template-columns:var(--fig-field-left-padding) 3.5rem var(--spacer-2) minmax(0, 1fr) var(--fig-field-right-padding)}& .fig-fill-picker-input-mode{flex-shrink:0;align-self:center;width:3.5rem}& .fig-fill-picker-input-fields{width:100%;min-width:0;display:flex;& .input-combo{flex:1;min-width:0;& fig-input-number>input,& fig-input-text:not(.fig-fill-picker-ci-hex)>input{text-align:center;padding-inline:0}}& fig-input-text{flex:1;min-width:0}& .fig-fill-picker-ci-css{font-variant-numeric:tabular-nums}& .fig-fill-picker-ci-hex-row{& .fig-fill-picker-ci-hex{flex:auto;min-width:0}& .fig-fill-picker-ci-a{flex:0 0 3rem}}& .fig-fill-picker-ci-a{flex:0 0 2.75rem;min-width:2.75rem}}}& .fig-fill-picker-gradient-preview{aspect-ratio:auto;width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3);margin-top:calc(var(--spacer-4) + var(--spacer-1));background:0 0;margin-bottom:0;&:after{display:none}}& fig-field.fig-fill-picker-gradient-header{grid-template-columns:unset;grid-template-areas:unset;padding-right:var(--spacer-2);padding-left:var(--spacer-2);align-items:center;gap:var(--spacer-2);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}& .fig-fill-picker-gradient-type{flex:0 auto;width:auto;min-width:0;display:flex}& .fig-fill-picker-gradient-actions{align-items:center;gap:var(--spacer-1);flex-shrink:0;margin-left:auto;display:flex}}& .fig-fill-picker-gradient-stops{& .fig-fill-picker-gradient-stops-header{&>span{flex:1}}}& fig-field.fig-fill-picker-gradient-interpolation-field{grid-template-columns:unset;grid-template-areas:unset;padding-left:var(--spacer-3);padding-right:var(--spacer-2);align-items:center;gap:var(--spacer-1);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}}& .fig-fill-picker-gradient-interpolation-modes{flex:auto;min-width:0;& fig-interpolation-swatch{pointer-events:none}}& .fig-fill-picker-gradient-interpolation-more{flex:none;display:inline-flex;position:relative;&>fig-button{pointer-events:none}& .fig-fill-picker-gradient-space{opacity:0;width:100%;position:absolute;inset:0}&:has(.fig-fill-picker-gradient-space:hover)>fig-button,&:has(.fig-fill-picker-gradient-space[open])>fig-button{background-color:var(--figma-color-bg-transparent-hover)}&:has(.fig-fill-picker-gradient-space:focus-within)>fig-button{outline:var(--figma-focus-outline);outline-offset:var(--figma-focus-outline-offset)}}& .fig-fill-picker-gradient-space{&::part(prepend){display:none}& fig-select-option{min-height:3rem;&:hover:before,&:focus-visible:before{background-color:var(--figma-color-bg-tertiary)}}& .fig-fill-picker-gradient-interpolation-label{flex-direction:column;justify-content:center;min-width:0;line-height:1.25;display:flex}& .fig-fill-picker-gradient-interpolation-title,& .fig-fill-picker-gradient-interpolation-subtitle{text-overflow:ellipsis;display:block;overflow:hidden}& .fig-fill-picker-gradient-interpolation-subtitle{color:var(--figma-color-text-tertiary)}& fig-select-options.fig-fill-picker-gradient-interpolation-collapsed{overflow:hidden}}& .fig-fill-picker-gradient-stops-list{gap:var(--spacer-1);flex-direction:column;display:flex;& fig-reorder{display:contents}}& .fig-fill-picker-gradient-stop-row{padding-right:var(--spacer-2);padding-left:var(--spacer-3);gap:var(--spacer-2);display:flex;&.dragging{background-color:var(--figma-color-bg-selected)}&>.fig-fill-picker-stop-position{flex:0 3rem;width:3rem;min-width:0}& .fig-fill-picker-stop-color{flex:1;min-width:0;& fig-input-text{min-width:0}}& .fig-fill-picker-stop-remove{flex-shrink:0}}& fig-field.fig-fill-picker-media-header{grid-template-columns:unset;grid-template-areas:unset;padding-left:var(--spacer-3);padding-right:var(--spacer-2);justify-content:space-between;align-items:center;gap:var(--spacer-2);display:flex;&>:not(.fig-field-chevron):not(label){grid-area:unset}& .fig-fill-picker-scale-mode{flex:none;width:4.5rem}& .fig-fill-picker-scale{flex:none;width:56px}& .fig-fill-picker-media-rotate{flex-shrink:0;margin-left:auto}}& .fig-fill-picker-media-preview{width:calc(100% - var(--spacer-3) * 2);margin:var(--spacer-2) var(--spacer-3) var(--spacer-1);border-radius:var(--radius-medium);position:relative;&.dragover{outline:2px dashed var(--figma-color-border-brand);outline-offset:-2px}&.has-media{& fig-preview fig-button,& fig-input-file fig-button{visibility:hidden}&:hover{& fig-preview fig-button,& fig-input-file fig-button{visibility:visible}}}}& fig-image.fig-fill-picker-media-preview{aspect-ratio:1;justify-content:center;align-items:center;display:flex;overflow:hidden}& .fig-fill-picker-checkerboard{background-image:linear-gradient(45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%), linear-gradient(-45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%), linear-gradient(45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%), linear-gradient(-45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%);background-position:0 0,0 8px,8px -8px,-8px 0;background-size:16px 16px;position:absolute;inset:0}& div.fig-fill-picker-image-preview{width:100%;height:100%;display:none;position:absolute;inset:0}& fig-image.fig-fill-picker-image-preview{width:auto;max-width:none;max-height:none}& video.fig-fill-picker-video-preview{object-fit:cover;width:100%;height:100%;display:none;position:absolute;inset:0}& fig-media.fig-fill-picker-video-preview{aspect-ratio:unset;max-width:none;max-height:none;width:calc(100% - var(--spacer-3) * 2);align-items:stretch;gap:var(--spacer-2);flex-direction:column;display:flex;overflow:visible;&>fig-preview{aspect-ratio:1;border-radius:var(--radius-medium);width:100%;max-width:none;overflow:hidden}}& .fig-fill-picker-upload{z-index:1;position:relative}& .fig-fill-picker-webcam-preview{aspect-ratio:1;width:calc(100% - var(--spacer-3) * 2);max-width:none;max-height:none;margin:0 var(--spacer-3);border-radius:var(--radius-medium);margin:var(--spacer-2) var(--spacer-3);display:flex;position:relative;overflow:hidden}& .fig-fill-picker-webcam-video{object-fit:cover;width:100%;height:100%}& .fig-fill-picker-webcam-status{background:var(--figma-color-bg-secondary);color:var(--figma-color-text-secondary);justify-content:center;align-items:center;font-size:.75rem;display:flex;position:absolute;inset:0}& .fig-fill-picker-webcam-controls{padding:0 var(--spacer-3);gap:var(--spacer-1);display:flex;& .fig-fill-picker-webcam-capture{width:100%}}}fig-select{min-width:0;height:var(--spacer-4);border-radius:var(--radius-medium);background-color:var(--figma-color-bg);color:var(--figma-color-text);box-shadow:inset 0 0 0 1px var(--figma-color-border);align-items:center;display:inline-flex;position:relative;&[size=large]{height:var(--spacer-5)}&[full]:not([full=false]){width:100%;display:flex}&[icon]:not([icon=false]){--fig-select-icon-size:var(--spacer-4);flex:0 0 var(--fig-select-icon-size);width:var(--fig-select-icon-size);&[size=large]{--fig-select-icon-size:var(--spacer-5)}&::part(trigger){flex:0 0 var(--fig-select-icon-size);width:var(--fig-select-icon-size);justify-content:center;padding:0}&::part(label),&::part(prepend){display:none}&:after{left:50%;right:auto;transform:translate(-50%,-50%)}}&[disabled]:not([disabled=false]){pointer-events:none;color:var(--figma-color-text-tertiary);&:after{background-color:var(--figma-color-icon-disabled)}}&[variant=ghost]{box-shadow:none;background-color:#0000;&:hover:not([disabled]):not([disabled=false]){background-color:var(--figma-color-bg-secondary)}}&:after{content:"";width:1rem;height:1rem;mask-image:var(--icon-16-chevron);background-color:var(--figma-color-icon);pointer-events:none;z-index:1;position:absolute;top:50%;right:.25rem;transform:translateY(-50%);mask-position:50%;mask-size:contain;mask-repeat:no-repeat}}fig-select::part(listbox){--z-index:999999;--fig-popup-radius:var(--radius-large);--fig-popup-bg-color:var(--figma-color-bg-menu);z-index:var(--z-index);border-radius:var(--fig-popup-radius);background-color:var(--fig-popup-bg-color);color:var(--figma-color-text-menu);color-scheme:dark;box-shadow:var(--figma-elevation-400-menu-panel);border:0;outline:0;height:max-content;max-height:calc(100vh - 1rem);margin:0;padding:0;position:fixed;overflow:hidden}fig-select-options>:is(fig-separator,fig-menu-separator){&[label]:not([label=""]){--fig-menu-inline-padding:0 var(--spacer-2) 0 var(--spacer-5);&:before{margin-inline:unset;margin-left:calc(-1 * var(--spacer-5));margin-right:calc(-1 * var(--spacer-2))}}}fig-select-option{max-width:100%;color:var(--figma-color-text-menu);user-select:none;text-overflow:ellipsis;white-space:nowrap;text-align:left;overflow:hidden;& h3,& label{text-overflow:ellipsis;overflow:hidden}&>fig-icon[data-fig-select-checkmark]{margin:0 var(--spacer-1);visibility:hidden;order:-1}&:not(:has(>:not([slot=prepend]):not([slot=append])))>[slot=append]{float:right}&>:not([slot=prepend]):not([slot=append]){text-overflow:ellipsis;overflow:hidden}&>[slot=append]{color:var(--figma-color-text-tertiary)}fig-select[subtle]:not([subtle=false]) &:not([subtle=false]){&:hover,&:focus-visible{&:before{background-color:var(--figma-color-bg-secondary)}}}&[selected]:not([selected=false])>fig-icon[data-fig-select-checkmark],&[aria-selected=true]>fig-icon[data-fig-select-checkmark]{visibility:visible}}
@@ -1,6 +1,6 @@
1
- import"./fig.js";import"./fig-lab.js";function A(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function k(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function p(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function I(J){if(!J)return"";return`url("${String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function d(J){let Q=String(J??"").trim();if(!Q||Q.startsWith("{")||Q.startsWith("#"))return!1;if(Q.startsWith("data:video/"))return!0;try{let Z=new URL(Q,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test(Z)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Q)}}function C(J,Q={}){let Z=document.createElement("fig-icon");if(J)Z.setAttribute("name",J);if(Q.size)Z.setAttribute("size",Q.size);if(Q.className)Z.className=Q.className;return Z}function h(J,Q){let Z=($)=>{if($===null||$===void 0||$===!1)return;if(Array.isArray($)){$.forEach(Z);return}J.append($ instanceof Node?$:String($))};return Z(Q),J}function s(J,Q={}){for(let[Z,$]of Object.entries(Q)){if($===null||$===void 0||$===!1)continue;if(Z==="className")J.className=String($);else if($===!0)J.setAttribute(Z,"");else J.setAttribute(Z,String($))}return J}function G(J,Q,Z){let $=document.createElement(J);return s($,Q),h($,Z)}var i="http://www.w3.org/2000/svg";function u(J,Q,Z){let $=document.createElementNS(i,J);for(let[X,Y]of Object.entries(Q||{})){if(Y===null||Y===void 0||Y===!1)continue;if(X==="className")$.setAttribute("class",String(Y));else if(Y===!0)$.setAttribute(X,"");else $.setAttribute(X,String(Y))}return h($,Z)}function l(J){let Q=String(J||"").replace(/^#/,"");return{r:parseInt(Q.substring(0,2),16)||0,g:parseInt(Q.substring(2,4),16)||0,b:parseInt(Q.substring(4,6),16)||0}}function r(J,Q,Z){let $=J/255,X=Q/255,Y=Z/255,j=Math.max($,X,Y),K=Math.min($,X,Y),W=(j+K)/2;if(j===K)return{h:0,s:0,l:W*100};let z=j-K,L=W>0.5?z/(2-j-K):z/(j+K),U;switch(j){case $:U=((X-Y)/z+(X<Y?6:0))/6;break;case X:U=((Y-$)/z+2)/6;break;default:U=(($-X)/z+4)/6;break}return{h:U*360,s:L*100,l:W*100}}function x(J){let Q=J/255;return Q<=0.04045?Q/12.92:Math.pow((Q+0.055)/1.055,2.4)}function o(J,Q,Z){let $=x(J),X=x(Q),Y=x(Z),j=Math.cbrt(0.4122214708*$+0.5363325363*X+0.0514459929*Y),K=Math.cbrt(0.2119034982*$+0.6806995451*X+0.1073969566*Y),W=Math.cbrt(0.0883024619*$+0.2817188376*X+0.6299787005*Y);return{l:0.2104542553*j+0.793617785*K-0.0040720468*W,a:1.9779984951*j-2.428592205*K+0.4505937099*W,b:0.0259040371*j+0.7827717662*K-0.808675766*W}}function n(J,Q,Z){return{l:J,c:Math.sqrt(Q*Q+Z*Z),h:Math.atan2(Z,Q)*180/Math.PI}}function a({owner:J,onStart:Q,onEnd:Z,startClass:$="",endClass:X="",chevronClass:Y="",startLabel:j="Scroll back",endLabel:K="Scroll forward"}={}){let W=(z,L)=>{let U=document.createElement("button");if(U.type="button",U.className=["fig-overflow",`fig-overflow-${z}`,z==="start"?$:X].filter(Boolean).join(" "),U.dataset.figOverflow=z,J)U.setAttribute(`data-fig-${J}-nav`,z);return U.setAttribute("tabindex","-1"),U.setAttribute("aria-label",z==="start"?j:K),U.appendChild(C("chevron",{size:"small",className:["fig-overflow-chevron",Y].filter(Boolean).join(" ")})),U.addEventListener("click",(O)=>{O.preventDefault(),O.stopPropagation(),L?.(O)}),U};return{start:W("start",Q),end:W("end",Z)}}function w(J,Q,Z="x",$=2){if(!J||!Q)return!1;let X=Z==="x",Y=X?Q.scrollWidth:Q.scrollHeight,j=X?Q.clientWidth:Q.clientHeight,K=X?Q.scrollLeft:Q.scrollTop,W=Y-j>$,z=!W||K<=$,L=!W||K+j>=Y-$;return J.classList.toggle("overflow-start",!z),J.classList.toggle("overflow-end",!L),W}function b(J,Q="x",Z=1){if(!J)return;let $=Q==="x",Y=($?J.clientWidth:J.clientHeight)*0.8*Z;J.scrollBy({[$?"left":"top"]:Y,behavior:"smooth"})}function t(J,Q,Z="y",$="auto"){if(!J||!Q||!J.contains(Q))return;requestAnimationFrame(()=>{if(!J.isConnected||!Q.isConnected)return;let X=Z==="x",Y=X?J.scrollWidth:J.scrollHeight,j=X?J.clientWidth:J.clientHeight;if(Y<=j+1){w(J,J,Z);return}let K=Q.getBoundingClientRect(),W=J.getBoundingClientRect(),z=X?J.scrollLeft:J.scrollTop,L=(X?K.left-W.left:K.top-W.top)+z,U=X?K.width:K.height,O=Y-j,f=Math.max(0,Math.min(L+U/2-j/2,O));J.scrollTo({[X?"left":"top"]:f,behavior:$}),w(J,J,Z)})}function e(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
1
+ import"./fig.js";import"./fig-lab.js";function A(J,Q){if(!customElements.get(J))customElements.define(J,Q)}function k(J,Q){return J.hasAttribute(Q)&&J.getAttribute(Q)!=="false"}function d(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function I(J){if(!J)return"";return`url("${String(J).replace(/\\/g,"\\\\").replace(/"/g,"\\\"")}")`}function s(J){let Q=String(J??"").trim();if(!Q||Q.startsWith("{")||Q.startsWith("#"))return!1;if(Q.startsWith("data:video/"))return!0;try{let Z=new URL(Q,"https://fig.local").pathname;return/\.(mp4|webm|mov|m4v|ogv)$/i.test(Z)}catch{return/\.(mp4|webm|mov|m4v|ogv)(?:[?#]|$)/i.test(Q)}}function y(J,Q={}){let Z=document.createElement("fig-icon");if(J)Z.setAttribute("name",J);if(Q.size)Z.setAttribute("size",Q.size);if(Q.className)Z.className=Q.className;return Z}function h(J,Q){let Z=($)=>{if($===null||$===void 0||$===!1)return;if(Array.isArray($)){$.forEach(Z);return}J.append($ instanceof Node?$:String($))};return Z(Q),J}function i(J,Q={}){for(let[Z,$]of Object.entries(Q)){if($===null||$===void 0||$===!1)continue;if(Z==="className")J.className=String($);else if($===!0)J.setAttribute(Z,"");else J.setAttribute(Z,String($))}return J}function G(J,Q,Z){let $=document.createElement(J);return i($,Q),h($,Z)}var l="http://www.w3.org/2000/svg";function u(J,Q,Z){let $=document.createElementNS(l,J);for(let[X,Y]of Object.entries(Q||{})){if(Y===null||Y===void 0||Y===!1)continue;if(X==="className")$.setAttribute("class",String(Y));else if(Y===!0)$.setAttribute(X,"");else $.setAttribute(X,String(Y))}return h($,Z)}function r(J){let Q=String(J||"").replace(/^#/,"");return{r:parseInt(Q.substring(0,2),16)||0,g:parseInt(Q.substring(2,4),16)||0,b:parseInt(Q.substring(4,6),16)||0}}function o(J,Q,Z){let $=J/255,X=Q/255,Y=Z/255,j=Math.max($,X,Y),K=Math.min($,X,Y),W=(j+K)/2;if(j===K)return{h:0,s:0,l:W*100};let z=j-K,L=W>0.5?z/(2-j-K):z/(j+K),U;switch(j){case $:U=((X-Y)/z+(X<Y?6:0))/6;break;case X:U=((Y-$)/z+2)/6;break;default:U=(($-X)/z+4)/6;break}return{h:U*360,s:L*100,l:W*100}}function x(J){let Q=J/255;return Q<=0.04045?Q/12.92:Math.pow((Q+0.055)/1.055,2.4)}function n(J,Q,Z){let $=x(J),X=x(Q),Y=x(Z),j=Math.cbrt(0.4122214708*$+0.5363325363*X+0.0514459929*Y),K=Math.cbrt(0.2119034982*$+0.6806995451*X+0.1073969566*Y),W=Math.cbrt(0.0883024619*$+0.2817188376*X+0.6299787005*Y);return{l:0.2104542553*j+0.793617785*K-0.0040720468*W,a:1.9779984951*j-2.428592205*K+0.4505937099*W,b:0.0259040371*j+0.7827717662*K-0.808675766*W}}function a(J,Q,Z){return{l:J,c:Math.sqrt(Q*Q+Z*Z),h:Math.atan2(Z,Q)*180/Math.PI}}function t({owner:J,onStart:Q,onEnd:Z,startClass:$="",endClass:X="",chevronClass:Y="",startLabel:j="Scroll back",endLabel:K="Scroll forward"}={}){let W=(z,L)=>{let U=document.createElement("button");if(U.type="button",U.className=["fig-overflow",`fig-overflow-${z}`,z==="start"?$:X].filter(Boolean).join(" "),U.dataset.figOverflow=z,J)U.setAttribute(`data-fig-${J}-nav`,z);return U.setAttribute("tabindex","-1"),U.setAttribute("aria-label",z==="start"?j:K),U.appendChild(y("chevron",{size:"small",className:["fig-overflow-chevron",Y].filter(Boolean).join(" ")})),U.addEventListener("click",(O)=>{O.preventDefault(),O.stopPropagation(),L?.(O)}),U};return{start:W("start",Q),end:W("end",Z)}}function w(J,Q,Z="x",$=2){if(!J||!Q)return!1;let X=Z==="x",Y=X?Q.scrollWidth:Q.scrollHeight,j=X?Q.clientWidth:Q.clientHeight,K=X?Q.scrollLeft:Q.scrollTop,W=Y-j>$,z=!W||K<=$,L=!W||K+j>=Y-$;return J.classList.toggle("overflow-start",!z),J.classList.toggle("overflow-end",!L),W}function b(J,Q="x",Z=1){if(!J)return;let $=Q==="x",Y=($?J.clientWidth:J.clientHeight)*0.8*Z;J.scrollBy({[$?"left":"top"]:Y,behavior:"smooth"})}function e(J,Q,Z="y",$="auto"){if(!J||!Q||!J.contains(Q))return;requestAnimationFrame(()=>{if(!J.isConnected||!Q.isConnected)return;let X=Z==="x",Y=X?J.scrollWidth:J.scrollHeight,j=X?J.clientWidth:J.clientHeight;if(Y<=j+1){w(J,J,Z);return}let K=Q.getBoundingClientRect(),W=J.getBoundingClientRect(),z=X?J.scrollLeft:J.scrollTop,L=(X?K.left-W.left:K.top-W.top)+z,U=X?K.width:K.height,O=Y-j,f=Math.max(0,Math.min(L+U/2-j/2,O));J.scrollTo({[X?"left":"top"]:f,behavior:$}),w(J,J,Z)})}function JJ(J){let Q=J||"";if(Q.startsWith("["))try{let $=JSON.parse(Q);return Array.isArray($)?$:[]}catch{}let Z=Q.includes(`
2
2
  `)?`
3
- `:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function JJ(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}function QJ(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}class v extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let J=this.getAttribute("value");if(J!==null)return J;return(this.textContent||"").trim()}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get disabled(){return k(this,"disabled")}set disabled(J){if(J)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return k(this,"selected")}set selected(J){if(J)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");this.#K()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="disabled")this.#K()}#K(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}A("fig-select-option",v);class m extends HTMLElement{#K=null;#Q=null;#j=null;#W=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#E(),this.#L(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.syncOverflow()),this.#j.observe(this),this.#W?.disconnect(),this.#W=new MutationObserver(()=>{if(!this.isConnected)return;this.#L(),this.syncOverflow()}),this.#W.observe(this,{childList:!0}),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#j?.disconnect(),this.#j=null,this.#W?.disconnect(),this.#W=null,this.#R()}syncOverflow(){return w(this,this,"y")}scrollToOption(J,Q="auto"){t(this,J,"y",Q)}#E(){let J=this.querySelector(":scope > fig-chooser");if(!J)return;while(J.firstChild)this.insertBefore(J.firstChild,J);J.remove()}#L(){if(this.#K&&this.#Q&&this.contains(this.#K)&&this.contains(this.#Q)){this.#z();return}this.#R();let J=a({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>b(this,"y",-1),onEnd:()=>b(this,"y",1)});this.#K=J.start,this.#Q=J.end,this.#z()}#z(){if(this.firstElementChild!==this.#K)this.prepend(this.#K);if(this.lastElementChild!==this.#Q)this.append(this.#Q)}#R(){this.#K?.remove(),this.#Q?.remove(),this.#K=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}A("fig-select-options",m);class c extends HTMLElement{#K=null;#Q=null;#j=null;#W=null;#J=null;#E=null;#L=null;#z=null;#R=null;#X=!1;#G=-1;#Y=!1;#U=!1;#Z=null;#$=!1;#C=null;#D=null;#F=!1;#f=null;#h=this.#kJ.bind(this);#H=this.#MJ.bind(this);#B=this.#t.bind(this);#_=this.#hJ.bind(this);#T=this.#ZJ.bind(this);#A=this.#wJ.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open","variant","size","menu-anchor","aria-label"]}get value(){return this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get open(){return k(this,"open")}set open(J){if(J)this.setAttribute("open","");else this.removeAttribute("open")}get menuAnchor(){return this.#f??this.getAttribute("menu-anchor")}set menuAnchor(J){if(J instanceof Element){if(this.hasAttribute("menu-anchor"))this.removeAttribute("menu-anchor");this.#f=J}else if(typeof J==="string"&&J.trim())this.#f=null,this.setAttribute("menu-anchor",J);else this.#f=null,this.removeAttribute("menu-anchor");this.#p()}connectedCallback(){if(!this.#X)this.#JJ();if(this.#v(),this.#c(),this.#V(),this.#k(),this.#GJ(),this.#d(),this.#xJ(),this.#uJ(),this.open)this.#$J()}disconnectedCallback(){this.#n(),document.removeEventListener("keydown",this.#_,!0),this.#R?.disconnect(),this.#R=null}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#X)return;if(J==="options"){this.#c(),this.#d();return}if(J==="value"||J==="label"||J==="aria-label"){this.#d();return}if(J==="disabled"){this.#V();return}if(J==="size"){this.#k();return}if(J==="open"){if(Z===null||Z==="false")this.#fJ();else this.#$J();return}if(J==="menu-anchor"){this.#f=null,this.#p();return}if(J==="position"||J==="offset"||J==="closedby"){if(this.#GJ(),this.open)this.#QJ()}}focus(J){this.#K?.focus(J)}blur(){this.#K?.blur()}#k(){if(!this.#K)return;let J=this.getAttribute("size");if(J)this.#K.setAttribute("size",J);else this.#K.removeAttribute("size")}#w(J){return J?.nodeType===1&&(J.tagName==="FIG-SELECT-OPTION"||J.tagName==="FIG-SEPARATOR"||J.tagName==="FIG-SELECT-OPTIONS")}#v(){for(let J of this.querySelectorAll(":scope > fig-select-options"))if(!J.hasAttribute("slot"))J.setAttribute("slot","panel")}#P(){let Q=(this.#z?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#m(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#zJ(){let J=this.#P();if(J){if(!J.hasAttribute("slot"))J.setAttribute("slot","panel");return J}return J=document.createElement("fig-select-options"),J.setAttribute("slot","panel"),J.setAttribute("data-fig-generated",""),this.appendChild(J),J}#c(){if(this.#m())return;let J=this.hasAttribute("options"),Q=J?this.#zJ():this.#P();if(!Q)return;this.#F=!0;try{for(let X of Q.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))X.remove();if(!J)return;let Z=e(this.getAttribute("options")),$=Q.querySelector(":scope > .fig-overflow-end");for(let X of Z){let Y=document.createElement("fig-select-option");if(Y.setAttribute("data-fig-generated",""),Y.setAttribute("value",JJ(X)),Y.textContent=QJ(X),$)Q.insertBefore(Y,$);else Q.appendChild(Y)}}finally{this.#F=!1}}#JJ(){this.#X=!0;let J=this.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=`
3
+ `:",";return Q.split(Z).map(($)=>$.trim()).filter(Boolean)}function QJ(J){if(J&&typeof J==="object")return String(J.value??J.label??"");return String(J??"")}function ZJ(J){if(J&&typeof J==="object")return String(J.label??J.value??"");return String(J??"")}function v(J){let Q=J.querySelector(":scope > fig-icon[data-fig-select-checkmark]");if(Q)return Q;return Q=y("checkmark",{size:"small",className:"fig-select-option-checkmark"}),Q.setAttribute("slot","prepend"),Q.setAttribute("aria-hidden","true"),Q.setAttribute("data-fig-select-checkmark",""),J.append(Q),Q}class m extends HTMLElement{static get observedAttributes(){return["value","disabled","selected","label"]}get value(){let J=this.getAttribute("value");if(J!==null)return J;return(this.textContent||"").trim()}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get disabled(){return k(this,"disabled")}set disabled(J){if(J)this.setAttribute("disabled","");else this.removeAttribute("disabled")}get selected(){return k(this,"selected")}set selected(J){if(J)this.setAttribute("selected","");else this.removeAttribute("selected")}connectedCallback(){if(!this.hasAttribute("role"))this.setAttribute("role","option");if(!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1");v(this),this.#K()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J==="disabled")this.#K()}#K(){if(this.disabled)this.setAttribute("aria-disabled","true"),this.setAttribute("tabindex","-1");else if(this.removeAttribute("aria-disabled"),!this.hasAttribute("tabindex"))this.setAttribute("tabindex","-1")}}A("fig-select-option",m);class c extends HTMLElement{#K=null;#Q=null;#j=null;#W=null;#J=this.syncOverflow.bind(this);connectedCallback(){if(!this.hasAttribute("slot"))this.setAttribute("slot","panel");this.#E(),this.#L(),this.addEventListener("scroll",this.#J,{passive:!0}),this.#j?.disconnect(),this.#j=new ResizeObserver(()=>this.syncOverflow()),this.#j.observe(this),this.#W?.disconnect(),this.#W=new MutationObserver(()=>{if(!this.isConnected)return;this.#L(),this.syncOverflow()}),this.#W.observe(this,{childList:!0}),requestAnimationFrame(()=>this.syncOverflow())}disconnectedCallback(){this.removeEventListener("scroll",this.#J),this.#j?.disconnect(),this.#j=null,this.#W?.disconnect(),this.#W=null,this.#R()}syncOverflow(){return w(this,this,"y")}scrollToOption(J,Q="auto"){e(this,J,"y",Q)}#E(){let J=this.querySelector(":scope > fig-chooser");if(!J)return;while(J.firstChild)this.insertBefore(J.firstChild,J);J.remove()}#L(){if(this.#K&&this.#Q&&this.contains(this.#K)&&this.contains(this.#Q)){this.#z();return}this.#R();let J=t({owner:"select",startLabel:"Scroll up",endLabel:"Scroll down",onStart:()=>b(this,"y",-1),onEnd:()=>b(this,"y",1)});this.#K=J.start,this.#Q=J.end,this.#z()}#z(){if(this.firstElementChild!==this.#K)this.prepend(this.#K);if(this.lastElementChild!==this.#Q)this.append(this.#Q)}#R(){this.#K?.remove(),this.#Q?.remove(),this.#K=null,this.#Q=null,this.classList.remove("overflow-start","overflow-end")}}A("fig-select-options",c);class p extends HTMLElement{#K=null;#Q=null;#j=null;#W=null;#J=null;#E=null;#L=null;#z=null;#R=null;#X=!1;#G=-1;#Y=!1;#U=!1;#Z=null;#$=!1;#C=null;#D=null;#F=!1;#f=null;#h=this.#kJ.bind(this);#H=this.#MJ.bind(this);#B=this.#t.bind(this);#_=this.#hJ.bind(this);#T=this.#ZJ.bind(this);#A=this.#wJ.bind(this);static get observedAttributes(){return["value","disabled","label","options","position","offset","closedby","open","variant","size","menu-anchor","aria-label"]}get value(){return this.getAttribute("value")??""}set value(J){if(J===null||J===void 0)this.removeAttribute("value");else this.setAttribute("value",String(J))}get open(){return k(this,"open")}set open(J){if(J)this.setAttribute("open","");else this.removeAttribute("open")}get menuAnchor(){return this.#f??this.getAttribute("menu-anchor")}set menuAnchor(J){if(J instanceof Element){if(this.hasAttribute("menu-anchor"))this.removeAttribute("menu-anchor");this.#f=J}else if(typeof J==="string"&&J.trim())this.#f=null,this.setAttribute("menu-anchor",J);else this.#f=null,this.removeAttribute("menu-anchor");this.#p()}connectedCallback(){if(!this.#X)this.#JJ();if(this.#v(),this.#c(),this.#V(),this.#k(),this.#GJ(),this.#d(),this.#xJ(),this.#uJ(),this.open)this.#$J()}disconnectedCallback(){this.#n(),document.removeEventListener("keydown",this.#_,!0),this.#R?.disconnect(),this.#R=null}attributeChangedCallback(J,Q,Z){if(Q===Z||!this.#X)return;if(J==="options"){this.#c(),this.#d();return}if(J==="value"||J==="label"||J==="aria-label"){this.#d();return}if(J==="disabled"){this.#V();return}if(J==="size"){this.#k();return}if(J==="open"){if(Z===null||Z==="false")this.#fJ();else this.#$J();return}if(J==="menu-anchor"){this.#f=null,this.#p();return}if(J==="position"||J==="offset"||J==="closedby"){if(this.#GJ(),this.open)this.#QJ()}}focus(J){this.#K?.focus(J)}blur(){this.#K?.blur()}#k(){if(!this.#K)return;let J=this.getAttribute("size");if(J)this.#K.setAttribute("size",J);else this.#K.removeAttribute("size")}#w(J){return J?.nodeType===1&&(J.tagName==="FIG-SELECT-OPTION"||J.tagName==="FIG-SEPARATOR"||J.tagName==="FIG-SELECT-OPTIONS")}#v(){for(let J of this.querySelectorAll(":scope > fig-select-options"))if(!J.hasAttribute("slot"))J.setAttribute("slot","panel")}#P(){let Q=(this.#z?.assignedElements({flatten:!0})??[]).find((Z)=>Z.tagName==="FIG-SELECT-OPTIONS");if(Q)return Q;return this.querySelector(":scope > fig-select-options")}#m(){return Boolean(this.querySelector(":scope > fig-select-option:not([data-fig-generated]), :scope > fig-select-options > fig-select-option:not([data-fig-generated])"))}#zJ(){let J=this.#P();if(J){if(!J.hasAttribute("slot"))J.setAttribute("slot","panel");return J}return J=document.createElement("fig-select-options"),J.setAttribute("slot","panel"),J.setAttribute("data-fig-generated",""),this.appendChild(J),J}#c(){if(this.#m())return;let J=this.hasAttribute("options"),Q=J?this.#zJ():this.#P();if(!Q)return;this.#F=!0;try{for(let X of Q.querySelectorAll(":scope > fig-select-option[data-fig-generated]"))X.remove();if(!J)return;let Z=JJ(this.getAttribute("options")),$=Q.querySelector(":scope > .fig-overflow-end");for(let X of Z){let Y=document.createElement("fig-select-option");if(Y.setAttribute("data-fig-generated",""),Y.setAttribute("value",QJ(X)),Y.textContent=ZJ(X),$)Q.insertBefore(Y,$);else Q.appendChild(Y)}}finally{this.#F=!1}}#JJ(){this.#X=!0;let J=this.attachShadow({mode:"open"}),Q=document.createElement("style");Q.textContent=`
4
4
  :host {
5
5
  display: inline-flex;
6
6
  position: relative;
@@ -105,4 +105,4 @@ import"./fig.js";import"./fig-lab.js";function A(J,Q){if(!customElements.get(J))
105
105
  min-height: 0;
106
106
  max-height: inherit;
107
107
  }
108
- `,J.appendChild(Q);let Z=document.createElement("fig-button");Z.className="fig-select-trigger",Z.setAttribute("part","trigger"),Z.setAttribute("variant","ghost"),Z.setAttribute("aria-haspopup","listbox"),Z.setAttribute("aria-expanded","false");let $=document.createElement("span");$.className="fig-select-prepend",$.setAttribute("part","prepend"),$.setAttribute("aria-hidden","true");let X=document.createElement("slot");X.setAttribute("name","prepend-trigger"),X.hidden=!0;let Y=document.createElement("span");Y.className="fig-select-prepend-fallback",$.append(X,Y);let j=document.createElement("span");j.className="fig-select-label",j.setAttribute("part","label");let K=document.createElement("slot");K.setAttribute("name","trigger"),K.hidden=!0,Z.append($,j,K);let W=document.createElement("dialog",{is:"fig-popup"});if(W.setAttribute("is","fig-popup"),W.setAttribute("part","listbox"),W.setAttribute("theme","menu"),W.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)W.setAttribute("popover","manual");W.id=p(),Z.setAttribute("aria-controls",W.id);let z=document.createElement("slot");if(z.setAttribute("name","panel"),W.appendChild(z),J.append(Z,W),this.#K=Z,this.#j=$,this.#W=X,this.#J=Y,this.#E=K,this.#L=j,this.#Q=W,this.#z=z,this.#p(),this.#v(),this.#i(),!this.hasAttribute("value")){let L=this.#x().find((U)=>k(U,"selected"));if(L)this.setAttribute("value",L.value)}}#i(){if(!this.#Q||this.#U)return;if(typeof this.#Q.positionPopup!=="function")return;this.#Z=this.#Q.positionPopup.bind(this.#Q),this.#Q.positionPopup=()=>{if(!this.open){this.#Z?.();return}this.#QJ()},this.#U=!0}#l(J){if(!J)return null;let Q=document.createRange();Q.selectNodeContents(J);let Z=[...Q.getClientRects()].filter(($)=>$.width>0&&$.height>0);if(Z.length)return Z[0];return J.getBoundingClientRect()}#S(){if(typeof this.#Q?.parseViewportMargins==="function")return this.#Q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#I(){if(this.#f?.isConnected)return this.#f;let J=this.getAttribute("menu-anchor");if(J)try{let Q=this.parentElement?.querySelector(J);if(Q&&Q!==this&&!this.contains(Q))return Q;let $=this.getRootNode()?.querySelector?.(J);if($&&$!==this&&!this.contains($))return $}catch{}return null}#r(){return this.#I()||this.#K}#u(){return Boolean(this.#I())}#o(){return!this.#OJ()&&this.#u()}#p(){if(!this.#Q)return;if(this.#Q.anchor=this.#r(),this.#M(),!this.open)return;this.#$=!1,this.#C=null,this.#D=null,this.#Q.setupObservers?.(),this.#Q.queueReposition?.()}#BJ(){let J=this.#L?.getBoundingClientRect();if(J?.width&&J?.height)return J;let Q=this.querySelector(':scope > [slot="trigger"]')?.getBoundingClientRect();if(Q?.width&&Q?.height)return Q;return this.#j?.getBoundingClientRect()??null}#RJ(){let Q=(this.#o()?this.#I():null)?.getBoundingClientRect()??this.#BJ();if(!Q)return null;return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}#_J(){let J=window.visualViewport;return{width:J?.width??window.innerWidth,height:J?.height??window.innerHeight,offsetLeft:J?.offsetLeft??0,offsetTop:J?.offsetTop??0}}#UJ(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.x-Q.x)>Z||Math.abs(J.y-Q.y)>Z||Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z}#EJ(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z||Math.abs(J.offsetLeft-Q.offsetLeft)>Z||Math.abs(J.offsetTop-Q.offsetTop)>Z}#AJ(){if(!this.#$)return!1;let J=this.#UJ(this.#C,this.#RJ()),Q=this.#EJ(this.#D,this.#_J());return!J&&!Q}#TJ(){this.#C=this.#RJ(),this.#D=this.#_J()}#OJ(){let J=this.getAttribute("position");return Boolean(J&&J.trim())}#PJ(){if(!this.#Q)return;this.#Q.style.removeProperty("left"),this.#Q.style.removeProperty("top"),this.#Q.style.removeProperty("right"),this.#Q.style.removeProperty("bottom")}#QJ(){if(this.#OJ()){if(this.#$=!1,this.#C=null,this.#D=null,this.#M(),this.#PJ(),this.#SJ())return;this.#Z?.(),this.#N();return}this.#IJ()}#SJ(){let J=this.#Q,Q=this.#I();if(!J||!Q||typeof J.parsePosition!=="function"||typeof J.parseOffset!=="function"||typeof J.computeCoords!=="function")return!1;let Z=J.getBoundingClientRect(),$=Q.getBoundingClientRect();if(!Z.width||!Z.height)return!1;let{vertical:X,horizontal:Y,shorthand:j}=J.parsePosition(),K=J.parseOffset(),{left:W,top:z}=J.computeCoords($,Z,X,Y,K,j),L=this.#S();if(typeof J.clampToViewport==="function")({left:W,top:z}=J.clampToViewport({left:W,top:z},Z,L));return J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(W)}px`,"important"),J.style.setProperty("top",`${Math.round(z)}px`,"important"),!0}#N(){let J=this.#Q;if(!J||typeof J.clampToViewport!=="function")return;let Q=J.getBoundingClientRect();if(!Q.width||!Q.height)return;let Z=this.#S(),{left:$,top:X}=J.clampToViewport({left:Q.left,top:Q.top},Q,Z);J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round($)}px`,"important"),J.style.setProperty("top",`${Math.round(X)}px`,"important")}#IJ(){if(this.#AJ()){this.#N();return}let J=this.#Q,Q=this.#L;if(!J||!Q){this.#Z?.();return}let Z=this.#x(),$=Z.find((q)=>this.#q(q)===this.value)||Z[0];if(!$){this.#Z?.();return}let X=this.#o()?this.#I():null;if(X)this.#M();this.#Z?.();let Y=J.getBoundingClientRect(),j=$.getBoundingClientRect();if(!Y.width||!Y.height||!j.height)return;let K,W,z;if(X){let q=X.getBoundingClientRect();z=q,K=q.left+(q.width-Y.width)/2,W=q.top+(q.height-j.height)/2-(j.top-Y.top)}else{let q=this.#BJ(),_=this.#l($);if(!q?.width||!_)return;z=q;let R=_.left-Y.left,T=_.top-Y.top;K=k(this,"full")?this.getBoundingClientRect().left:q.left-R,W=q.top-T}let L=this.#S();if(typeof J.clampToViewport==="function")({left:K,top:W}=J.clampToViewport({left:K,top:W},Y,L));else{let{left:q,top:_}=L,R=window.innerWidth-Y.width-L.right,T=window.innerHeight-Y.height-L.bottom;K=Math.min(Math.max(K,q),Math.max(q,R)),W=Math.min(Math.max(W,_),Math.max(_,T))}J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(K)}px`,"important"),J.style.setProperty("top",`${Math.round(W)}px`,"important");let U=this.#P(),O=$.getBoundingClientRect(),f=X?null:this.#l($);if(U&&U.scrollHeight>U.clientHeight+1){let q=X?O.top+O.height/2-(z.top+z.height/2):f?f.top-z.top:0;if(Math.abs(q)>0.5)U.scrollTop+=q;U.syncOverflow?.()}if(this.#$||this.open)this.#TJ()}#xJ(){this.#K?.addEventListener("click",this.#h),this.#K?.addEventListener("keydown",this.#_),this.addEventListener("click",this.#H),this.addEventListener("pointerover",this.#B),this.#Q?.addEventListener("keydown",this.#_),this.#Q?.addEventListener("close",this.#T),this.#z?.addEventListener("slotchange",this.#A)}#n(){this.#K?.removeEventListener("click",this.#h),this.#K?.removeEventListener("keydown",this.#_),this.removeEventListener("click",this.#H),this.removeEventListener("pointerover",this.#B),this.#Q?.removeEventListener("keydown",this.#_),this.#Q?.removeEventListener("close",this.#T),this.#z?.removeEventListener("slotchange",this.#A)}#wJ(){this.#v(),this.#d()}#uJ(){if(this.#R)return;this.#R=new MutationObserver((J)=>{if(this.#Y||this.#F)return;let Q=!1;for(let Z of J){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#w($))||[...Z.removedNodes].some(($)=>this.#w($))||Z.target?.closest?.("fig-select-option"))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"){if(Z.attributeName==="value"||Z.attributeName==="disabled"||Z.attributeName==="label")Q=!0;else if(Z.attributeName==="selected"){if(k(Z.target,"selected")){let $=this.#q(Z.target);if((this.getAttribute("value")??"")!==$)this.setAttribute("value",$),Q=!0}else if(this.#q(Z.target)===(this.getAttribute("value")??""))Q=!0}}if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#d()}),this.#R.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#x({enabledOnly:J=!1}={}){let Q=this.#P(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!J)return Z;return Z.filter(($)=>!k($,"disabled"))}#q(J){if(!J)return"";if(typeof J.value==="string")return J.value;let Q=J.getAttribute?.("value");if(Q!=null)return Q;return(J.textContent||"").trim()}#bJ(J){if(!J)return"";let Q=J.getAttribute?.("label");if(Q!=null&&Q!=="")return Q.trim();let Z=[];for(let $ of J.childNodes){if($.nodeType===Node.TEXT_NODE){let j=$.textContent?.trim();if(j)Z.push(j);continue}if(!($ instanceof Element))continue;let X=$.getAttribute("slot");if(X==="prepend"||X==="append")continue;let Y=$.textContent?.trim();if(Y)Z.push(Y)}if(Z.length)return Z.join(" ").trim();return(J.textContent||"").trim()}#gJ(J){if(!this.#j||!this.#W||!this.#J||!this.#E)return;let Q=this.querySelector(':scope > [slot="trigger"]'),Z=this.querySelector(':scope > [slot="prepend-trigger"][data-fig-select-generated]'),$=this.querySelector(':scope > [slot="prepend-trigger"]:not([data-fig-select-generated])'),X=J?.querySelector?.(':scope > [slot="prepend"]');if(this.#E.hidden=!Q,this.#L.hidden=Boolean(Q),this.#j.hidden=Boolean(Q),Q){Z?.remove(),this.#j.classList.remove("has-content"),this.#W.hidden=!0,this.#J.replaceChildren();return}if(!$&&X?.childNodes.length){let j=Z||document.createElement("span");if(j.setAttribute("slot","prepend-trigger"),j.setAttribute("data-fig-select-generated",""),j.replaceChildren(...Array.from(X.childNodes,(K)=>K.cloneNode(!0))),j.parentElement!==this)this.append(j);$=j}else if($)Z?.remove();else Z?.remove();let Y=Boolean($);if(this.#j.classList.toggle("has-content",Y),this.#W.hidden=!$,this.#J.hidden=Boolean($),$){this.#J.replaceChildren();return}this.#J.replaceChildren()}#GJ(){if(!this.#Q)return;this.#Q.setAttribute("position",this.getAttribute("position")||"bottom left");let J=this.getAttribute("offset");if(J)this.#Q.setAttribute("offset",J);else this.#Q.removeAttribute("offset");let Q=this.getAttribute("closedby");if(Q)this.#Q.setAttribute("closedby",Q);else this.#Q.removeAttribute("closedby")}#V(){let J=k(this,"disabled");if(this.#K)if(J)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled");if(J&&this.open)this.open=!1}#LJ(J){if(!J.length)return null;let Q=J.find((Z)=>k(Z,"selected"));if(Q&&!k(Q,"disabled"))return Q;return J.find((Z)=>!k(Z,"disabled"))||J[0]||null}#a(J){this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#d(){if(this.#Y)return;this.#Y=!0;try{let J=this.#x(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?J.find((K)=>this.#q(K)===Z):null,X=!1;if(!$){if(Q){if(!J.length){if(this.#L)this.#L.textContent=Z||this.getAttribute("label")||"";return}if($=this.#LJ(J),$){let K=this.#q($);if(Z!==K)this.setAttribute("value",K),X=!0}else this.removeAttribute("value"),X=!0}else if($=J.find((K)=>k(K,"selected")),$)this.setAttribute("value",this.#q($)),X=!0}for(let K of J){let W=K===$;if(K.setAttribute("aria-selected",W?"true":"false"),W)K.setAttribute("selected","");else K.removeAttribute("selected")}let Y=$&&this.#bJ($)||this.getAttribute("label")||"";if(this.#L)this.#L.textContent=Y;this.#gJ($);let j=this.getAttribute("aria-label")||this.getAttribute("label")||"Select";if(this.#K?.setAttribute("aria-label",j),this.#P()?.syncOverflow?.(),X)this.#a(this.getAttribute("value")??"")}finally{this.#Y=!1}}#kJ(J){if(k(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=!this.open;if(Q)this.#p();this.open=Q}#MJ(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(k(Z,"disabled"))return;this.#NJ(Z)}#t(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(k(Z,"disabled"))return;if(J.relatedTarget instanceof Node&&Z.contains(J.relatedTarget))return;this.dispatchEvent(new CustomEvent("optionhover",{detail:this.#q(Z),bubbles:!0,composed:!0}))}#hJ(J){if(J.currentTarget===document&&J.key!=="Escape")return;if(!(this.open&&(this.#Q?.matches?.(":open")??!1))){if(this.#K?.contains(J.target)&&(J.key==="ArrowDown"||J.key==="Enter"||J.key===" "))J.preventDefault(),this.#p(),this.open=!0,requestAnimationFrame(()=>{let X=this.#x({enabledOnly:!0}).findIndex((Y)=>this.#q(Y)===this.value);this.#y(X>=0?X:0)});return}let Z=this.#x({enabledOnly:!0});if(!Z.length)return;switch(J.key){case"ArrowDown":J.preventDefault(),this.#yJ(),this.#y(this.#G+1,!0);break;case"ArrowUp":J.preventDefault(),this.#yJ(),this.#y(this.#G-1,!0);break;case"Home":J.preventDefault(),this.#y(0,!0);break;case"End":J.preventDefault(),this.#y(Z.length-1,!0);break;case"Escape":J.preventDefault(),this.open=!1,this.#K?.focus();break;case"Enter":case" ":{this.#yJ();let $=Z[this.#G];if(!$)return;J.preventDefault(),this.#NJ($);break}}}#ZJ(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#K?.setAttribute("aria-expanded","false"),this.#K?.focus(),this.#G=-1}#NJ(J){let Q=this.#q(J);this.setAttribute("value",Q),this.#d(),this.#a(Q),this.open=!1}#VJ(){return this.#x({enabledOnly:!0})}#yJ(){let J=this.#VJ();if(!J.length){this.#G=-1;return}let Q=J.find(($)=>$===document.activeElement),Z=Q?J.indexOf(Q):-1;this.#G=Z>=0?Z:this.#G}#y(J,Q=!1){let Z=this.#VJ();if(!Z.length)return;let $=(J%Z.length+Z.length)%Z.length,X=Z[$],Y=document.activeElement!==X;if(this.#G=$,X?.focus(),Q&&Y)this.dispatchEvent(new CustomEvent("optionfocus",{detail:this.#q(X),bubbles:!0,composed:!0}))}#M(){if(!this.#Q||!this.#K)return;let J=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#K.getBoundingClientRect().width),Z=Math.max(J,Q,96),$=this.#u()?this.#I():null,X=window.visualViewport?.width??window.innerWidth,Y=window.visualViewport?.height??window.innerHeight,j=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,K=Math.max(0,Math.min(Math.floor(20*j),Math.floor(X-16))),W=Math.max(0,Math.floor(Y-16));if(this.#Q.style.setProperty("box-sizing","border-box","important"),this.#Q.style.setProperty("padding","0","important"),this.#Q.style.setProperty("border","0","important"),this.#Q.style.setProperty("margin","0","important"),$){let L=$.getBoundingClientRect().width;this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width","0","important"),this.#Q.style.setProperty("max-width",`${K}px`,"important");let U=this.#Q.getBoundingClientRect().width,O=Math.min(K,Math.max(Z,U)),f=Math.max(L,O);this.#Q.style.setProperty("width",`${f}px`,"important"),this.#Q.style.setProperty("min-width",`${f}px`,"important"),this.#Q.style.setProperty("max-width",`${f}px`,"important")}else this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width",`${K}px`,"important");this.#Q.style.setProperty("max-height",`${W}px`,"important"),this.#Q.style.setProperty("height","max-content","important"),this.#Q.style.setProperty("overflow","hidden","important");let z=this.#Q.getBoundingClientRect();if(z.height>W)this.#Q.style.setProperty("height",`${W}px`,"important");if(!$&&z.width>K)this.#Q.style.setProperty("width",`${K}px`,"important")}#$J(){if(!this.#Q||k(this,"disabled"))return;this.#p(),this.#i(),this.#$=!1,this.#C=null,this.#D=null,this.#d(),this.#M(),this.#Q.open=!0,document.addEventListener("keydown",this.#_,!0),this.#K?.setAttribute("aria-expanded","true"),this.#G=-1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#M(),this.#QJ(),this.#M(),this.#N();let J=this.#P(),Z=this.#VJ().findIndex(($)=>this.#q($)===this.value);if(Z>=0)this.#y(Z);else if(this.#K?.hasAttribute("data-focus-visible")||this.#K?.matches?.(":focus-visible"))this.#y(0);if(J?.syncOverflow?.(),!this.#OJ())this.#$=!0,this.#TJ()})})}#fJ(){if(!this.#Q)return;this.#$=!1,this.#C=null,this.#D=null,document.removeEventListener("keydown",this.#_,!0),this.#Q.open=!1,this.#K?.setAttribute("aria-expanded","false")}}A("fig-select",c);var ZJ=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],$J=["shorter","longer","increasing","decreasing"],E=new Set(["oklch","hsl"]);function N(J){let Q={...J??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase();if(!ZJ.includes(Z))Z="srgb";Q.interpolationSpace=Z;let $=String(Q.hueInterpolation??"shorter").toLowerCase();return Q.hueInterpolation=$J.includes($)?$:"shorter",Q}function S(J){let Q=N(J);return Q.interpolationSpace="srgb",delete Q.hueInterpolation,Q}function P(J){let Q=S(J),Z={...Q,interpolationSpace:Q.interpolationSpace};if(E.has(Q.interpolationSpace))Z.hueInterpolation=Q.hueInterpolation;else delete Z.hueInterpolation;return Z}function XJ(J){let Q=N(J);if(Q.interpolationSpace==="srgb")return"";if(E.has(Q.interpolationSpace))return`in ${Q.interpolationSpace} ${Q.hueInterpolation} hue`;return`in ${Q.interpolationSpace}`}function g(J){let Q=N(J);if(E.has(Q.interpolationSpace))return`${Q.interpolationSpace}-${Q.hueInterpolation||"shorter"}`;return Q.interpolationSpace}function F(J){let Q=String(J??"");for(let Z of E){let $=`${Z}-`;if(Q.startsWith($))return{interpolationSpace:Z,hueInterpolation:Q.slice($.length)||"shorter"}}return{interpolationSpace:Q||"srgb",hueInterpolation:"shorter"}}var YJ=0;class y extends HTMLElement{static#K=[{value:"srgb",space:"srgb",title:"Classic",subtitle:"sRGB Linear"},{value:"oklab",space:"oklab",title:"Smooth",subtitle:"OKLab"},{value:"oklch-increasing",space:"oklch",title:"Vibrant",subtitle:"OKLCH Increasing"},{value:"hsl-increasing",space:"hsl",title:"Vivid",subtitle:"HSL Increasing"},{value:"oklch-decreasing",space:"oklch",title:"Vibrant",subtitle:"OKLCH Decreasing",advanced:!0},{value:"hsl-decreasing",space:"hsl",title:"Vivid",subtitle:"HSL Decreasing",advanced:!0}];static#Q(J){let Q=y.#K,Z=Q.find((K)=>K.value===J);if(Z)return Z;let $=F(J),X=Q.find((K)=>K.space===$.interpolationSpace),Y=X?.subtitle.split(" ")[0]??$.interpolationSpace.toUpperCase(),j=$.hueInterpolation;return{value:J,space:$.interpolationSpace,title:X?.title??"Custom",subtitle:E.has($.interpolationSpace)?`${Y} ${j.charAt(0).toUpperCase()}${j.slice(1)}`:Y}}#j=null;#W=null;#J=null;#E=`fig-fill-picker-dialog-${++YJ}`;#L="solid";anchorElement=null;#z="solid";#R="srgb";#X={h:0,s:0,v:85,a:1};#G="hex";#Y={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#U={url:null,scaleMode:"fill",scale:50};#Z={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#$={stream:null,live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#C=null;#D=!1;#F=null;#f={};#h={};#H=null;#B=null;#_=null;#T=null;#A=!1;#k=!1;#w=null;#v=null;#P=null;#m=null;#zJ=null;#c=0;#JJ=null;#i=null;#l=new Set;#S=new Set;#I=null;#r=null;constructor(){super();this.#JJ=this.#bJ.bind(this),this.#i=this.#gJ.bind(this)}static get observedAttributes(){return["value","disabled","alpha","mode","webcam-mode","default-video","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.style.display="contents",this.#N(()=>{this.#uJ(),this.#GJ(),this.#V(),this.#tJ()})}disconnectedCallback(){if(this.#kJ({stopWebcam:!0}),this.#IJ(),this.#xJ(),this.#n(this.#W))this.#W.removeAttribute("selected");if(this.#j)this.#j.removeEventListener("click",this.#JJ),this.#j.removeEventListener("keydown",this.#i);this.#j=null,this.#W=null}#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#o(){return this.getAttribute("webcam-mode")==="snapshot"?"snapshot":"live"}#p(){return this.#z==="webcam"&&this.#o()==="live"&&this.#$.live!==!1}#BJ(){return{live:this.#o()==="live"&&this.#$.live!==!1,snapshot:this.#$.snapshot??null,deviceId:this.#$.deviceId??null,scaleMode:this.#$.scaleMode||"fill",scale:this.#$.scale??50,opacity:this.#$.opacity??1}}#RJ(){let J=this.#Z.url??null;return{url:J,poster:this.#Z.poster??null,scaleMode:this.#Z.scaleMode||"fill",scale:this.#Z.scale??50,opacity:this.#Z.opacity??1,...J?{}:{missing:!0}}}#_J(J){if(J.webcam&&typeof J.webcam==="object"){let{stream:Q,snapshot:Z,...$}=J.webcam;if(Object.assign(this.#$,$),typeof Z==="string"&&Z)this.#$.snapshot=Z;return}if(J.type==="webcam"&&J.image){if(J.image.url!=null)this.#$.snapshot=J.image.url;if(J.image.scaleMode)this.#$.scaleMode=J.image.scaleMode;if(J.image.scale!=null)this.#$.scale=J.image.scale}}#UJ(){this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:{stream:this.#$.stream,deviceId:this.#$.deviceId??null}}))}get webcamStream(){return this.#$.stream}releaseWebcam(){this.#t()}#EJ(J){if(!J)return null;if(this.#$.snapshot?.startsWith("blob:"))URL.revokeObjectURL(this.#$.snapshot),this.#S.delete(this.#$.snapshot);return this.#$.snapshot=URL.createObjectURL(J),this.#S.add(this.#$.snapshot),this.#$.snapshot}#AJ(J,Q,Z){if(typeof J.getImageData!=="function")return!1;let $;try{$=J.getImageData(0,0,Q,Z).data}catch{return!1}let X=Math.max(1,Math.floor(Q*Z/256)),Y=0,j=0,K=0;for(let W=0;W<$.length;W+=X*4){let z=Math.max($[W],$[W+1],$[W+2]);if(Y=Math.max(Y,z),K+=1,z>24)j+=1}if(!K)return!0;return Y<=40||j/K<0.04}async#TJ(J){let Q=[],Z=this.#$.stream?.getVideoTracks?.()?.[0];if(Z&&typeof ImageCapture==="function")try{if(this.#F?.track!==Z)this.#F=new ImageCapture(Z);Q.push(await this.#F.grabFrame())}catch{this.#F=null}if(typeof createImageBitmap==="function")try{Q.push(await createImageBitmap(J))}catch{}return Q.push(J),Q.filter(Boolean)}async#OJ(J,Q,Z,$){let X=await this.#TJ(Q);for(let Y of X){try{J.drawImage(Y,0,0,Z,$)}catch{continue}finally{Y.close?.()}if(!this.#AJ(J,Z,$))return!0}return!1}#PJ(J){return new Promise((Q)=>{if(typeof J.requestVideoFrameCallback==="function"){let Z=setTimeout(()=>Q(!1),400);J.requestVideoFrameCallback(()=>{clearTimeout(Z),Q(!0)});return}setTimeout(()=>Q(!1),200)})}async#QJ(J){if(!J?.videoWidth||!J.videoHeight)return null;let Q=document.createElement("canvas");Q.width=J.videoWidth,Q.height=J.videoHeight;let Z=Q.getContext("2d",{willReadFrequently:!0});if(!Z)return null;if(!await this.#OJ(Z,J,Q.width,Q.height))return null;let X=await new Promise((Y)=>Q.toBlob(Y,"image/png"));return this.#EJ(X)}#SJ(J){if(this.#z!=="webcam")return;let Q=this.#$.stream;if(!Q)return;if(this.#C===Q&&this.#$.snapshot){this.#V();return}if(this.#D)return;this.#D=!0;let Z=(X)=>{if(this.#D=!1,!X||this.#z!=="webcam"||this.#$.stream!==Q)return;this.#C=Q,this.#V()},$=async()=>{let X=await this.#QJ(J);if(X){Z(X);return}if(this.#z!=="webcam"||this.#$.stream!==Q){this.#D=!1;return}return await this.#PJ(J),$()};$()}#N(J){let Q=requestAnimationFrame(()=>{if(this.#l.delete(Q),this.isConnected)J()});return this.#l.add(Q),Q}#IJ(){this.#l.forEach((J)=>cancelAnimationFrame(J)),this.#l.clear()}#xJ(){let J=new Set([this.#$.snapshot,this.#Z.poster,this.#U.url].filter((Q)=>typeof Q==="string"&&Q.startsWith("blob:")));this.#S.forEach((Q)=>{if(!J.has(Q))URL.revokeObjectURL(Q)}),this.#S.clear(),J.forEach((Q)=>this.#S.add(Q))}#n(J){return J?.matches("fig-swatch, fig-chit")??!1}#wJ(J){return this.#n(J)||(J?.matches("[data-fig-fill-picker-swatch]")??!1)}#uJ(){let J=Array.from(this.children).find((Q)=>!Q.getAttribute("slot")?.startsWith("mode-"));if(!J)this.#W=document.createElement("fig-swatch"),this.#W.setAttribute("background","#D9D9D9"),this.appendChild(this.#W),this.#j=this.#W;else if(this.#wJ(J))this.#W=J,this.#j=J;else this.#j=J,this.#W=null;if(this.#q(),this.#j.removeEventListener("click",this.#JJ),this.#j.addEventListener("click",this.#JJ),this.#j.removeEventListener("keydown",this.#i),this.#j.addEventListener("keydown",this.#i),this.#n(this.#W))this.#N(()=>{let Q=this.#W.querySelector('input[type="color"]');if(Q)Q.remove();this.#q()})}#x(){return this.getAttribute("aria-label")||"Fill picker"}#q(){if(!this.#j)return;let J=this.#u(),Q=this.getAttribute("aria-labelledby");if(!this.#j.hasAttribute("role"))this.#j.setAttribute("role","button");if(this.#j.setAttribute("tabindex",J?"-1":"0"),this.#j.setAttribute("aria-disabled",J?"true":"false"),this.#j.setAttribute("aria-haspopup","dialog"),this.#j.setAttribute("aria-expanded",this.#J?.open?"true":"false"),this.#j.setAttribute("aria-controls",this.#E),this.#j.removeAttribute("aria-hidden"),Q)this.#j.setAttribute("aria-labelledby",Q),this.#j.removeAttribute("aria-label");else if(this.hasAttribute("aria-label"))this.#j.setAttribute("aria-label",`Open ${this.#x()}`),this.#j.removeAttribute("aria-labelledby");else if(this.#j.removeAttribute("aria-labelledby"),!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("aria-label",`Open ${this.#x()}`);let Z=this.getAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-describedby",Z);else this.#j.removeAttribute("aria-describedby")}#bJ(J){if(this.#u())return;J.stopPropagation(),J.preventDefault(),this.#a()}#gJ(J){if(J.key!=="Enter"&&J.key!==" ")return;if(this.#u())return;J.preventDefault(),J.stopPropagation(),this.#a()}#GJ(){let J=this.getAttribute("value");if(!J)return;let Q=["solid","gradient","image","video","webcam"];try{let Z=JSON.parse(J);if(Z.type)this.#z=Z.type;if(Z.color){if(typeof Z.color==="string")this.#X=this.#WJ(Z.color);else if(typeof Z.color==="object"&&Z.color.h!==void 0)this.#X=Z.color}let $=Z.alpha!==void 0?Number(Z.alpha):Z.opacity!==void 0?Number(Z.opacity)/100:void 0;if(Number.isFinite($))this.#X.a=Math.max(0,Math.min(1,$));if(this.#R="srgb",Z.gradient)this.#Y=S({...this.#Y,...Z.gradient});if(Z.image)this.#U={...this.#U,...Z.image};if(Z.video){let X=this.#Z.url;if(this.#Z={...this.#Z,...Z.video},this.#Z.missing=!this.#Z.url,Z.video.poster!=null&&Z.video.poster!=="")this.#r=this.#Z.url;else if(this.#Z.url!==X)this.#jJ();else this.#DJ()}if(this.#_J(Z),Z.type&&!Q.includes(Z.type)){let{type:X,...Y}=Z;this.#h[Z.type]=Y}}catch(Z){if(J.startsWith("#")){this.#z="solid",this.#X=this.#WJ(J);return}if(d(J)){let $=this.#Z.url;if(this.#z="video",this.#Z.url=J.trim(),this.#Z.missing=!1,this.#Z.url!==$)this.#jJ();else this.#DJ()}}}#V(){if(!this.#W)return;let J,Q="cover",Z="center";switch(this.#z){case"solid":J=this.#s(this.#X);break;case"gradient":J=this.#aJ();break;case"image":if(this.#U.url){J=I(this.#U.url);let $=this.#LJ(this.#U.scaleMode,this.#U.scale);Q=$.size,Z=$.position}else J="";break;case"video":if(this.#Z.poster){J=I(this.#Z.poster);let $=this.#LJ(this.#Z.scaleMode,this.#Z.scale);Q=$.size,Z=$.position}else J="";break;case"webcam":if(this.#$.snapshot){J=I(this.#$.snapshot);let $=this.#LJ(this.#$.scaleMode,this.#$.scale);Q=$.size,Z=$.position}else J="";break;default:{J=(this.#f[this.#z]?.element||this.querySelector(`[slot="mode-${this.#z}"]`))?.getAttribute("swatch-background")||"";break}}if(this.#W.setAttribute("background",J),this.#W.style.setProperty("--swatch-bg-size",Q),this.#W.style.setProperty("--swatch-bg-position",Z),this.#z==="solid")this.#W.setAttribute("alpha",this.#X.a);else this.#W.removeAttribute("alpha")}#LJ(J,Q){switch(J){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${Q}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#a(){if(this.#u())return;if(!this.#J)this.#hJ();else this.#J.anchor=this.anchorElement||this.#j;if(this.#ZJ(this.#z,{emit:!1}),this.#P=JSON.stringify(this.value),this.#m=this.#P,this.#n(this.#W))this.#W.setAttribute("selected","true");this.#J.open=!0,this.#q(),this.#N(()=>{this.#J?.querySelector(".fig-fill-picker-close, .fig-fill-picker-type, fig-button, button, input, [tabindex='0']")?.focus?.(),this.#N(()=>{this.#y(),this.#M()})})}open(){this.#a()}close(){if(this.#J)this.#J.open=!1,this.#q()}#d(){if(!this.#J)return;for(let[J,{element:Q}]of Object.entries(this.#f)){let Z=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find(($)=>$.dataset.tab===J);if(!Z)continue;while(Z.firstChild)Q.appendChild(Z.firstChild)}}#kJ({stopWebcam:J=!1}={}){if(this.#w)this.#w(),this.#w=null;if(this.#v?.disconnect(),this.#v=null,!J&&this.#p())this.#MJ();else this.#t();if(!this.#J)return;this.#d(),this.#J.remove(),this.#J=null,this.#zJ=null,this.#P=null,this.#m=null,this.#H=null,this.#B=null,this.#_=null,this.#T=null,this.#k=!1,this.#q()}#MJ(){this.#c+=1;let J=this.#J?.querySelector(".fig-fill-picker-webcam-video");if(J)J.srcObject=null}#t({emit:J=!0}={}){this.#c+=1;let Q=Boolean(this.#$.stream);if(this.#$.stream)this.#$.stream.getTracks().forEach(($)=>$.stop()),this.#$.stream=null;this.#C=null,this.#D=!1,this.#F=null;let Z=this.#J?.querySelector(".fig-fill-picker-webcam-video");if(Z)Z.srcObject=null;if(Q&&J)this.#UJ()}#hJ(){this.#f={},this.querySelectorAll('[slot^="mode-"]').forEach((O)=>{let f=O.getAttribute("slot").slice(5);this.#f[f]={element:O,label:O.getAttribute("label")||f.charAt(0).toUpperCase()+f.slice(1)}}),this.#J=document.createElement("dialog",{is:"fig-popup"}),this.#J.setAttribute("is","fig-popup"),this.#J.id=this.#E,this.#J.setAttribute("aria-label",this.#x()),this.#J.setAttribute("drag","true"),this.#J.setAttribute("handle","fig-header"),this.#J.setAttribute("autoresize","false"),this.#J.classList.add("fig-fill-picker-dialog"),this.#J.anchor=this.anchorElement||this.#j;let J=this.getAttribute("dialog-position")||"left";this.#J.setAttribute("position",J),this.#J.setAttribute("offset",this.getAttribute("dialog-offset")||"8 8");let Q=["solid","gradient","image","video","webcam"],Z={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},$=this.getAttribute("mode"),X;if($){if(X=$.split(",").map((f)=>f.trim().toLowerCase()).filter((f)=>Q.includes(f)||this.#f[f]),X.length===0)X=[...Q]}else X=[...Q];let Y={...Z};for(let[O,{label:f}]of Object.entries(this.#f))Y[O]=f;if(!X.includes(this.#z))this.#z=X[0],this.#L=X[0];let j;if(X.length===1)j=G("h3",{className:"fig-fill-picker-type-label"},Y[X[0]]);else{let O=G("fig-select-options",{},X.map((f)=>G("fig-select-option",{value:f},Y[f])));j=G("fig-select",{className:"fig-fill-picker-type",label:"Fill type",variant:"ghost",value:this.#z},O)}let K=X.map((O)=>G("div",{className:"fig-fill-picker-tab","data-tab":O})),W=G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-close","aria-label":"Close fill picker"},C("close"));this.#J.replaceChildren(G("fig-header",{},[j,W]),G("fig-content",{},K)),document.body.appendChild(this.#J);for(let[O,{element:f}]of Object.entries(this.#f)){let q=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find((_)=>_.dataset.tab===O);if(!q)continue;while(f.firstChild)q.appendChild(f.firstChild);this.dispatchEvent(new CustomEvent("modeready",{bubbles:!0,detail:{mode:O,container:q}}))}let z=this.#J.querySelector(".fig-fill-picker-type");if(z)z.addEventListener("change",(O)=>{let f=typeof O.detail==="string"?O.detail:O.target?.value;if(f)this.#ZJ(f)});this.#J.querySelector(".fig-fill-picker-close").addEventListener("click",()=>{this.#J.open=!1});let L=()=>{if(this.#n(this.#W))this.#W.removeAttribute("selected");if(this.#p())this.#MJ();else this.#t();let O=JSON.stringify(this.value);if(this.#m!==null&&this.#m!==O)this.#g();this.#P=null,this.#m=null,this.#q();let f=this.#j;this.#N(()=>{if(f?.isConnected)HTMLElement.prototype.focus.call(f)}),this.dispatchEvent(new CustomEvent("close"))};this.#J.addEventListener("close",L);let U={solid:()=>this.#VJ(),gradient:()=>this.#XQ(),image:()=>this.#GQ(),video:()=>this.#VQ(),webcam:()=>this.#BQ()};for(let[O,f]of Object.entries(U))if(!this.#f[O]&&X.includes(O))f();for(let O of Object.keys(this.#f)){if(Q.includes(O))continue;let f=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find((q)=>q.dataset.tab===O);if(!f)continue;f.addEventListener("input",(q)=>{if(q.target===this)return;if(q.stopPropagation(),q.detail)this.#h[O]=q.detail;this.#O()}),f.addEventListener("change",(q)=>{if(q.target===this)return;if(q.stopPropagation(),q.detail)this.#h[O]=q.detail;this.#g()})}}#ZJ(J,{emit:Q=!0}={}){let Z=Array.from(this.#J?.querySelectorAll(".fig-fill-picker-tab")??[]).find((K)=>K.dataset.tab===J);if(!Z)return;let $=this.#L;if(this.#L=J,this.#z=J,$==="webcam"&&J!=="webcam")this.#t();let X=this.#J.querySelector(".fig-fill-picker-type");if(X&&X.value!==J)X.value=J;this.#J.querySelectorAll(".fig-fill-picker-tab").forEach((K)=>{if(K.dataset.tab===J)K.style.display="block";else K.style.display="none"});let j=this.#J.querySelector("fig-content");if(j)j.style.padding=this.#f[J]?"0":"";if(J==="gradient")this.#N(()=>{this.#b();let K=Z.querySelector(".fig-fill-picker-gradient-bar-input");K?.refreshLayout?.(),this.#N(()=>{K?.refreshLayout?.()})});if(J==="video")this.#FJ({emit:!1});if(J==="webcam")this.#$.live=this.#o()==="live",this.#zJ?.(this.#$.deviceId);if(this.#V(),Q)this.#O()}#NJ(){if(!this.#J?.open)return;if(this.#ZJ(this.#z,{emit:!1}),this.#y(),this.#M(),this.#XJ(),this.#_)this.#_.setAttribute("value",this.#X.h);if(this.#T)this.#T.setAttribute("value",this.#X.a*100),this.#T.setAttribute("color",this.#s(this.#X));this.#b();let J=this.#J.querySelector('[data-tab="image"]'),Q=J?.querySelector(".fig-fill-picker-scale-mode"),Z=J?.querySelector(".fig-fill-picker-scale"),$=J?.querySelector(".fig-fill-picker-image-preview");if(Q)Q.value=this.#U.scaleMode;if(Z)Z.setAttribute("value",this.#U.scale),Z.style.display=this.#U.scaleMode==="tile"?"block":"none";if($)this.#e($);let X=this.#J.querySelector('[data-tab="video"]'),Y=X?.querySelector(".fig-fill-picker-scale-mode"),j=X?.querySelector(".fig-fill-picker-video-preview");if(Y)Y.value=this.#Z.scaleMode;if(j)this.#YJ(j)}#VJ(){let J=this.#J.querySelector('[data-tab="solid"]'),Q=this.getAttribute("alpha")!=="false",Z=G("canvas",{width:"200",height:"200"}),$=G("fig-handle",{"aria-label":"Color saturation and brightness",role:"slider","aria-valuemin":"0","aria-valuemax":"100",type:"color",color:this.#s({...this.#X,a:1}),"data-no-color-picker":!0,drag:!0,"drag-surface":".fig-fill-picker-color-area","drag-axes":"x,y","drag-snapping":"modifier"}),X=G("fig-preview",{className:"fig-fill-picker-color-area"},[Z,$]),Y=G("fig-tooltip",{text:"Sample color"},G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-eyedropper","aria-label":"Sample color"},C("eyedropper"))),j=G("div",{className:`fig-fill-picker-sliders${Q?"":" is-hue-only"}`},[Y,G("fig-slider",{type:"hue",variant:"classic",text:"false",min:"0",max:"360","aria-label":"Hue",value:this.#X.h}),Q?G("fig-slider",{type:"opacity",variant:"classic",text:"false",min:"0",max:"100","aria-label":"Opacity",value:this.#X.a*100,color:this.#s(this.#X)}):null]),K=G("fig-select-options",{},[["hex","Hex"],["rgb","RGB"],["css","CSS"],["hsl","HSL"],["hsb","HSB"],["lab","LAB"],["lch","LCH"]].map(([U,O])=>G("fig-select-option",{value:U},O))),W=G("fig-field",{className:"fig-fill-picker-inputs"},[G("fig-select",{className:"fig-fill-picker-input-mode",label:"Color value format",value:this.#G},K),G("span",{className:"fig-fill-picker-input-fields"})]);if(J.replaceChildren(X,j,W),this.#H=J.querySelector("canvas"),this.#B=J.querySelector("fig-handle"),this.#$J(),this.#y(),this.#M(),this.#iJ(),this.#_=J.querySelector('fig-slider[type="hue"]'),this.#_.addEventListener("input",(U)=>{this.#X.h=parseFloat(U.target.value),this.#y(),this.#M(),this.#XJ(),this.#O()}),this.#_.addEventListener("change",()=>{this.#g()}),Q)this.#T=J.querySelector('fig-slider[type="opacity"]'),this.#T.addEventListener("input",(U)=>{this.#X.a=parseFloat(U.target.value)/100,this.#XJ(),this.#O()}),this.#T.addEventListener("change",()=>{this.#g()});J.querySelector(".fig-fill-picker-input-mode").addEventListener("change",(U)=>{let O=typeof U.detail==="string"?U.detail:U.target?.value;if(!O)return;this.#G=O,this.#lJ()}),this.#lJ();let L=J.querySelector(".fig-fill-picker-eyedropper");if("EyeDropper"in window)L.addEventListener("click",async()=>{try{let O=await new EyeDropper().open();this.#X={...this.#WJ(O.sRGBHex),a:this.#X.a},this.#y(),this.#M(),this.#XJ(),this.#O()}catch(U){}});else L.setAttribute("disabled",""),L.title="EyeDropper not supported in this browser"}#yJ(){let J=this.#J?.querySelector('[data-tab="solid"]');if(J){let Q=J.querySelector("canvas");if(Q){let Z=document.createElement("canvas");Z.width=Q.width,Z.height=Q.height,Q.replaceWith(Z),this.#H=Z,this.#iJ()}this.#y(),this.#M()}this.#HJ(),this.#O()}#y(){if(!this.#H&&this.#J)this.#H=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#H)return;let J=this.#R==="display-p3"?"display-p3":"srgb",Q=this.#H.getContext("2d",{colorSpace:J});if(!Q)return;let Z=this.#H.width,$=this.#H.height;Q.clearRect(0,0,Z,$);let X=this.#X.h,Y=this.#R==="display-p3",j=Q.createLinearGradient(0,0,Z,0);if(Y){j.addColorStop(0,"color(display-p3 1 1 1)");let[W,z,L]=hslToP3(X,100,50);j.addColorStop(1,`color(display-p3 ${W} ${z} ${L})`)}else j.addColorStop(0,"#FFFFFF"),j.addColorStop(1,`hsl(${X}, 100%, 50%)`);Q.fillStyle=j,Q.fillRect(0,0,Z,$);let K=Q.createLinearGradient(0,0,0,$);K.addColorStop(0,"rgba(0,0,0,0)"),K.addColorStop(1,"rgba(0,0,0,1)"),Q.fillStyle=K,Q.fillRect(0,0,Z,$)}#M(J=0){if(!this.#B||!this.#H)return;this.#$J();let Q=this.#H.getBoundingClientRect();if((Q.width===0||Q.height===0)&&J<5){this.#N(()=>this.#M(J+1));return}let Z=Math.max(0,Math.min(100,this.#X.s)),$=Math.max(0,Math.min(100,100-this.#X.v));this.#B.setAttribute("value",`${Z}% ${$}%`),this.#B.setAttribute("color",this.#s({...this.#X,a:1}))}#$J(){if(!this.#B)return;this.#B.setAttribute("aria-valuenow",String(Math.round(this.#X.v))),this.#B.setAttribute("aria-valuetext",`Saturation ${Math.round(this.#X.s)}%, brightness ${Math.round(this.#X.v)}%`),this.#B.removeAttribute("aria-pressed")}#fJ(J,Q,Z={}){let{updateHandle:$=!0,emitInput:X=!0,emitChange:Y=!1}=Z;if(this.#X.s=Math.max(0,Math.min(100,J*100)),this.#X.v=Math.max(0,Math.min(100,(1-Q)*100)),this.#B)this.#B.setAttribute("color",this.#s({...this.#X,a:1})),this.#$J();if($)this.#M();if(this.#XJ(),X)this.#O();if(Y)this.#g()}#iJ(){if(this.#w)this.#w(),this.#w=null;if(!this.#H||!this.#B)return;let J=this.#H.parentElement||this.#H,Q=this.#B,Z=!1,$=(z,L={})=>{let U=J.getBoundingClientRect();if(U.width===0||U.height===0)return;let O=Math.max(0,Math.min(z.clientX-U.left,U.width)),f=Math.max(0,Math.min(z.clientY-U.top,U.height));this.#fJ(O/U.width,f/U.height,L)},X=(z)=>{if(z.button!==0)return;if(z.target===Q||Q.contains(z.target))return;Z=!0,this.#A=!0,J.setPointerCapture(z.pointerId),$(z,{updateHandle:!0,emitInput:!0})},Y=(z)=>{if(!Z)return;if(z.buttons===0){j();return}$(z,{updateHandle:!0,emitInput:!0})},j=()=>{if(!Z)return;Z=!1,this.#A=!1,this.#g()},K=(z)=>{this.#A=!0;let L=z.detail?.px,U=z.detail?.py;if(!Number.isFinite(L)||!Number.isFinite(U))return;Q.setAttribute("value",`${L*100}% ${U*100}%`),this.#fJ(L,U,{updateHandle:!1,emitInput:!0})},W=(z)=>{let L=z.detail?.px,U=z.detail?.py;if(Number.isFinite(L)&&Number.isFinite(U))Q.setAttribute("value",`${L*100}% ${U*100}%`),this.#fJ(L,U,{updateHandle:!1,emitInput:!1});this.#A=!1,this.#g()};J.addEventListener("pointerdown",X),J.addEventListener("pointermove",Y),J.addEventListener("pointerup",j),J.addEventListener("pointercancel",j),J.addEventListener("lostpointercapture",j),Q.addEventListener("input",K),Q.addEventListener("change",W),this.#w=()=>{J.removeEventListener("pointerdown",X),J.removeEventListener("pointermove",Y),J.removeEventListener("pointerup",j),J.removeEventListener("pointercancel",j),J.removeEventListener("lostpointercapture",j),Q.removeEventListener("input",K),Q.removeEventListener("change",W),this.#A=!1}}#lJ(){let J=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!J)return;let Q=(K,W)=>G("fig-tooltip",{text:K},W),Z=(K,W,z,L,U,O)=>G("fig-input-number",{className:K,"aria-label":W,min:z,max:L,step:U,units:O}),$=this.getAttribute("alpha")!=="false",X=()=>$?Q("Alpha",Z("fig-fill-picker-ci-a","Alpha",0,100,0.1,"%")):null,Y=(K,W="")=>G("div",{className:["input-combo",W].filter(Boolean).join(" ")},K),j;switch(this.#G){case"rgb":j=Y([Q("Red",Z("fig-fill-picker-ci-r","Red",0,255)),Q("Green",Z("fig-fill-picker-ci-g","Green",0,255)),Q("Blue",Z("fig-fill-picker-ci-b","Blue",0,255)),X()]);break;case"hsl":j=Y([Q("Hue",Z("fig-fill-picker-ci-h","Hue",0,360)),Q("Saturation",Z("fig-fill-picker-ci-s","Saturation",0,100)),Q("Lightness",Z("fig-fill-picker-ci-l","Lightness",0,100)),X()]);break;case"hsb":j=Y([Q("Hue",Z("fig-fill-picker-ci-h","Hue",0,360)),Q("Saturation",Z("fig-fill-picker-ci-s","Saturation",0,100)),Q("Brightness",Z("fig-fill-picker-ci-v","Brightness",0,100)),X()]);break;case"lab":j=Y([Q("Lightness",Z("fig-fill-picker-ci-okl","Lightness",0,100)),Q("Green-Red axis",Z("fig-fill-picker-ci-oka","Green-Red axis",-0.4,0.4,0.001)),Q("Blue-Yellow axis",Z("fig-fill-picker-ci-okb","Blue-Yellow axis",-0.4,0.4,0.001)),X()]);break;case"lch":j=Y([Q("Lightness",Z("fig-fill-picker-ci-okl","Lightness",0,100)),Q("Chroma",Z("fig-fill-picker-ci-okc","Chroma",0,0.4,0.001)),Q("Hue",Z("fig-fill-picker-ci-okh","Hue",0,360)),X()]);break;case"css":j=G("fig-input-text",{className:"fig-fill-picker-ci-css","aria-label":"CSS color",placeholder:"rgba(0, 0, 0, 1)"});break;default:{let K=G("fig-input-text",{className:"fig-fill-picker-ci-hex","aria-label":"Hex color",placeholder:"FFFFFF"});j=$?Y([K,X()],"fig-fill-picker-ci-hex-row"):K}break}J.replaceChildren(j),this.#QQ(),this.#N(()=>this.#XJ())}#QQ(){let J=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!J)return;let Q=()=>{if(this.#A)return;let X=this.#$Q();if(!X)return;let Y=Number.isFinite(X.a)?X.a:this.#X.a;if(this.#X={...X,a:Y},this.#y(),this.#M(),this.#_)this.#_.setAttribute("value",this.#X.h);if(this.#T&&Number.isFinite(X.a))this.#T.setAttribute("value",this.#X.a*100);this.#O()},Z=()=>this.#g();J.querySelectorAll("fig-input-number, fig-input-text").forEach((X)=>{X.addEventListener("input",Q),X.addEventListener("change",Z)})}#ZQ(){let J=this.#J?.querySelector(".fig-fill-picker-ci-a");if(!J)return;let Q=parseFloat(J.value);if(!Number.isFinite(Q))return;return Math.max(0,Math.min(1,Q/100))}#$Q(){let J=($)=>this.#J?.querySelector(`.${$}`),Q=($)=>parseFloat(J($)?.value??0),Z=($)=>{if(!$)return null;let X=this.#ZQ();return{...$,a:X??$.a??this.#X.a}};switch(this.#G){case"rgb":return Z(this.#KJ({r:Q("fig-fill-picker-ci-r"),g:Q("fig-fill-picker-ci-g"),b:Q("fig-fill-picker-ci-b")}));case"hsl":{let $=this.#DQ({h:Q("fig-fill-picker-ci-h"),s:Q("fig-fill-picker-ci-s"),l:Q("fig-fill-picker-ci-l")});return Z(this.#KJ($))}case"hsb":return Z({h:Q("fig-fill-picker-ci-h"),s:Q("fig-fill-picker-ci-s"),v:Q("fig-fill-picker-ci-v")});case"lab":{let $=this.#JQ({l:Q("fig-fill-picker-ci-okl")/100,a:Q("fig-fill-picker-ci-oka"),b:Q("fig-fill-picker-ci-okb")});return Z(this.#KJ($))}case"lch":{let $=this.#CQ({l:Q("fig-fill-picker-ci-okl")/100,c:Q("fig-fill-picker-ci-okc"),h:Q("fig-fill-picker-ci-okh")});return Z(this.#KJ($))}case"css":{let $=J("fig-fill-picker-ci-css");if(!$)return null;return this.#MQ($.value)}default:{let $=J("fig-fill-picker-ci-hex");if(!$)return null;let X=$.value.replace(/^#/,"");if(X.length===3)X=X[0]+X[0]+X[1]+X[1]+X[2]+X[2];if(X.length===8){let Y=parseInt(X.slice(6,8),16)/255;if(X=X.slice(0,6),!/^[0-9a-fA-F]{6}$/.test(X))return null;return{...this.#WJ(`#${X}`),a:Y}}if(X.length!==6||!/^[0-9a-fA-F]{6}$/.test(X))return null;return Z(this.#WJ(`#${X}`))}}}#XJ(){if(!this.#J)return;let J=this.#s(this.#X),Q=this.#sJ(this.#X),Z=(X)=>this.#J.querySelector(`.${X}`),$=(X,Y)=>{let j=Z(X);if(j)j.setAttribute("value",Y)};switch(this.#G){case"rgb":$("fig-fill-picker-ci-r",Q.r),$("fig-fill-picker-ci-g",Q.g),$("fig-fill-picker-ci-b",Q.b);break;case"hsl":{let X=this.#yQ(Q);$("fig-fill-picker-ci-h",Math.round(X.h)),$("fig-fill-picker-ci-s",Math.round(X.s)),$("fig-fill-picker-ci-l",Math.round(X.l));break}case"hsb":$("fig-fill-picker-ci-h",Math.round(this.#X.h)),$("fig-fill-picker-ci-s",Math.round(this.#X.s)),$("fig-fill-picker-ci-v",Math.round(this.#X.v));break;case"lab":{let X=this.#eJ(Q);$("fig-fill-picker-ci-okl",Math.round(X.l*100)),$("fig-fill-picker-ci-oka",+X.a.toFixed(3)),$("fig-fill-picker-ci-okb",+X.b.toFixed(3));break}case"lch":{let X=this.#FQ(Q);$("fig-fill-picker-ci-okl",Math.round(X.l*100)),$("fig-fill-picker-ci-okc",+X.c.toFixed(3)),$("fig-fill-picker-ci-okh",Math.round(X.h));break}case"css":$("fig-fill-picker-ci-css",this.#kQ(this.#X));break;default:$("fig-fill-picker-ci-hex",J.replace(/^#/,"").toUpperCase());break}if(this.#G!=="css"){let X=Math.round(this.#X.a*1000)/10;$("fig-fill-picker-ci-a",Number.isInteger(X)?X:+X.toFixed(1))}if(this.#T)this.#T.setAttribute("color",J);this.#V()}#XQ(){let J=this.#J.querySelector('[data-tab="gradient"]'),Q=G("fig-select",{className:"fig-fill-picker-gradient-type",label:"Gradient type",value:this.#Y.type,variant:"ghost"},G("fig-select-options",{},[["linear","Linear"],["radial","Radial"],["angular","Angular"]].map(([z,L])=>G("fig-select-option",{value:z},L)))),Z=(z,L,U)=>G("fig-tooltip",{text:z},G("fig-button",{icon:!0,variant:"ghost",className:L,"aria-label":z},C(U))),$=G("div",{className:"fig-fill-picker-gradient-actions"},[Z("Flip gradient","fig-fill-picker-gradient-flip","swap"),Z("Rotate gradient","fig-fill-picker-gradient-rotate","rotate")]),X=G("fig-field",{className:"fig-fill-picker-gradient-header"},[Q,$]),Y=G("fig-input-gradient",{className:"fig-fill-picker-gradient-bar-input","aria-label":"Gradient stops",edit:"true",mode:"tip",size:"large",value:JSON.stringify({type:"gradient",gradient:P(this.#Y)})}),j=G("fig-preview",{className:"fig-fill-picker-gradient-preview"},Y),K=G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-gradient-add","aria-label":"Add gradient stop",title:"Add stop"},C("add")),W=G("div",{className:"fig-fill-picker-gradient-stops"},[G("fig-header",{className:"fig-fill-picker-gradient-stops-header",borderless:!0},[G("h3",{},"Stops"),K]),G("div",{className:"fig-fill-picker-gradient-stops-list"},document.createElement("fig-reorder"))]);J.replaceChildren(X,j,W),this.#b(),this.#YQ(J)}#EQ(){let J=({value:$,title:X,subtitle:Y,advanced:j=!1})=>G("fig-select-option",{value:$,label:`${X} — ${Y}`,className:j?"fig-fill-picker-gradient-interpolation-advanced":null},[G("fig-interpolation-swatch",{slot:"prepend",size:"large","aria-hidden":"true"}),G("span",{className:"fig-fill-picker-gradient-interpolation-label"},[G("span",{className:"fig-fill-picker-gradient-interpolation-title"},X),G("span",{className:"fig-fill-picker-gradient-interpolation-subtitle"},Y)])]),Q=G("fig-separator",{className:"fig-fill-picker-gradient-interpolation-advanced"}),Z=y.#K;return[...Z.filter(($)=>!$.advanced).map(J),Q,...Z.filter(($)=>$.advanced).map(J)]}#YQ(J){let Q=(V)=>typeof V.detail==="string"?V.detail:V.target?.value,Z=J.querySelector(".fig-fill-picker-gradient-bar-input"),$=(V)=>{if(!Z)return;this.#k=!0;try{Z.setAttribute("value",JSON.stringify({type:"gradient",gradient:P(V)}))}finally{this.#k=!1}},X=()=>{$(this.#Y)};J.querySelector(".fig-fill-picker-gradient-type")?.addEventListener("change",(V)=>{let H=Q(V);if(!H)return;this.#Y.type=H,this.#b(),this.#O()});let j=J.querySelector(".fig-fill-picker-gradient-space"),K=j?.querySelector("fig-select-options"),W="fig-fill-picker-gradient-interpolation-collapsed",z=K?.querySelector(".fig-fill-picker-gradient-interpolation-advanced"),L=()=>Boolean(K?.classList.contains(W)),U=(V)=>{K?.querySelector(".fig-overflow-end")?.setAttribute("aria-label",V?"Show all color interpolation options":"Scroll down")},O=()=>{if(!K)return;K.classList.remove(W),K.style.removeProperty("max-height"),U(!1),K.syncOverflow?.()},f=()=>{if(!K||!z)return;K.style.removeProperty("max-height"),K.classList.add(W),K.scrollTop=0;let V=K.getBoundingClientRect().top,H=z.getBoundingClientRect().top,M=K.querySelector(".fig-overflow-end")?.offsetHeight||0,D=H-V;if(D>0)K.style.maxHeight=`${Math.round(D+M)}px`;U(!0),K.syncOverflow?.()},q=(V)=>Boolean(K?.querySelector(`fig-select-option.fig-fill-picker-gradient-interpolation-advanced[value="${V}"]`)),_=()=>{if(q(g(this.#Y)))O();else f()};if(K?.addEventListener("click",(V)=>{if(!L())return;if(!V.target?.closest?.(".fig-overflow-end"))return;V.preventDefault(),V.stopPropagation(),O()},!0),K?.addEventListener("focusin",(V)=>{if(!L())return;if(V.target?.closest?.(".fig-fill-picker-gradient-interpolation-advanced"))O()}),K?.addEventListener("scroll",()=>{if(L()&&K.scrollTop!==0)K.scrollTop=0}),j?.querySelectorAll("fig-select-option").forEach((V)=>{let H=()=>{let M=F(V.getAttribute("value")||"srgb");$(N({...this.#Y,...M}))};V.addEventListener("pointerenter",H),V.addEventListener("pointerleave",()=>{if(document.activeElement!==V)X()}),V.addEventListener("focus",H),V.addEventListener("blur",()=>{if(!V.matches(":hover"))X()})}),this.#v?.disconnect(),j)this.#v=new MutationObserver(()=>{if(!j.hasAttribute("open"))X();else this.#N(_)}),this.#v.observe(j,{attributes:!0,attributeFilter:["open"]});let R=J.querySelector(".fig-fill-picker-gradient-interpolation-modes");if(R?.addEventListener("change",(V)=>{let H=typeof V.detail==="string"?V.detail:V.target?.value;if(!H)return;let M=F(H);this.#Y=N({...this.#Y,...M}),this.#b(),this.#O()}),R?.querySelectorAll("fig-segment").forEach((V)=>{let H=()=>{$(N({...this.#Y,...F(V.getAttribute("value")||"srgb")}))};V.addEventListener("pointerenter",H),V.addEventListener("pointerleave",X)}),j?.addEventListener("change",(V)=>{let H=Q(V);if(!H)return;let M=F(H);this.#Y=N({...this.#Y,...M}),this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-rotate")?.addEventListener("click",()=>{this.#Y.angle=(Number(this.#Y.angle)+90)%360,this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#Y.stops.forEach((V)=>{V.position=100-V.position}),this.#Y.stops.sort((V,H)=>V.position-H.position),this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#Y.stops.push({position:50,color:"#888888",opacity:100}),this.#Y.stops.sort((H,M)=>H.position-M.position),this.#b(),this.#O()}),Z){let V=(H)=>{if(H.stopPropagation(),this.#k)return;let M=H.detail;if(!M?.gradient)return;this.#Y=S({...this.#Y,...M.gradient}),this.#V(),this.#qJ(),this.#rJ()};Z.addEventListener("input",(H)=>{V(H),this.#O()}),Z.addEventListener("change",(H)=>{V(H),this.#g()})}J.querySelector(".fig-fill-picker-gradient-stops-list > fig-reorder")?.addEventListener("reorder",(V)=>{this.#zQ(V)})}#vJ(J){let Q=String(J.color||"#888888").replace(/^#/,"").slice(0,6),Z=J.opacity??100;if(Z>=100)return`#${Q}`;let $=Math.round(Z/100*255).toString(16).padStart(2,"0");return`#${Q}${$}`}#jQ(J){if(!(J instanceof HTMLElement))return"#888888";if(J.hexOpaque)return this.#mJ(J.hexOpaque);let Q=J.value;if(typeof Q==="string"&&Q.startsWith("#"))return this.#mJ(Q.length>7?Q.slice(0,7):Q);let Z=J.querySelector('fig-input-text:not([type="number"])'),$=String(Z?.value??Z?.getAttribute("value")??"").replace(/#/g,"").slice(0,6);if(/^[0-9A-Fa-f]{6}$/.test($))return`#${$.toUpperCase()}`;let X=J.getAttribute("value");if(typeof X==="string"&&X.startsWith("#"))return this.#mJ(X.length>7?X.slice(0,7):X);return"#888888"}#mJ(J){let Q=String(J||"#888888").replace(/^#/,"").slice(0,6);if(!/^[0-9A-Fa-f]{6}$/.test(Q))return"#888888";return`#${Q.toUpperCase()}`}#KQ(J){let Q=J.querySelector(".fig-fill-picker-stop-position"),Z=J.querySelector(".fig-fill-picker-stop-color"),$=parseFloat(Q?.value??Q?.getAttribute("value")??"0")||0,X=this.#jQ(Z),Y=100;if(Z instanceof HTMLElement&&Z.rgba?.a!==void 0)Y=Math.round(Z.rgba.a*100);else{let j=parseInt(J.dataset.index,10);if(!isNaN(j)&&this.#Y.stops[j])Y=this.#Y.stops[j].opacity??100}return{position:$,color:X,opacity:Y}}#cJ(J){let Q=parseInt(J.dataset.index,10);if(isNaN(Q)||Q<0||Q>=this.#Y.stops.length)return;let Z={...this.#Y.stops[Q],...this.#KQ(J)};this.#Y.stops[Q]=Z,this.#WQ(J,Z)}#WQ(J,Q){let Z=J.querySelector(".fig-fill-picker-stop-position");if(Z)Z.setAttribute("value",String(Q.position));let $=J.querySelector(".fig-fill-picker-stop-color");if($)$.setAttribute("value",this.#vJ(Q))}#zQ(J){let{oldIndex:Q,newIndex:Z}=J.detail??{};if(Q==null||Z==null||Q===Z||Q<0||Z<0||Q>=this.#Y.stops.length||Z>=this.#Y.stops.length)return;let X=J.currentTarget.querySelectorAll(".fig-fill-picker-gradient-stop-row");X.forEach((j)=>this.#cJ(j));let[Y]=this.#Y.stops.splice(Q,1);this.#Y.stops.splice(Z,0,Y),X.forEach((j,K)=>{j.dataset.index=String(K)}),this.#k=!0;try{this.#qJ(),this.#HJ(),this.#O()}finally{this.#k=!1}}#b(){if(!this.#J)return;let J=this.#J.querySelector('[data-tab="gradient"]');if(!J)return;this.#Y=S(this.#Y);let Q=g(this.#Y),Z=J.querySelector(".fig-fill-picker-gradient-space");if(Z)Z.value=Q;let $=J.querySelector(".fig-fill-picker-gradient-interpolation-modes");if($){let X=y.#Q(Q),Y=$.querySelector(`fig-segment[value="${Q}"]`)||$.querySelector(`fig-segment[data-space="${X.space}"]`);if(Y){let j=`${X.title} — ${X.subtitle}`;Y.setAttribute("value",Q),Y.setAttribute("aria-label",j);let K=Y.closest("fig-tooltip");if(K)K.setAttribute("text",j);$.value=Q}}this.#qJ(),this.#HJ(),this.#rJ()}#UQ(){let J=Array.isArray(this.#Y.stops)?[...this.#Y.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0)):[];if(J.length<2)return[{color:"#FF0000",position:0},{color:"#4F9EFF",position:100}];return J.map((Q)=>({color:String(Q.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:Q.position??0}))}#qJ(){if(!this.#J)return;let J=this.#UQ();this.#J.querySelectorAll("fig-interpolation-swatch").forEach((Q)=>{let Z=Q.closest("fig-select-option, fig-segment")?.getAttribute("value")||"srgb",$=F(Z),X={type:"linear",stops:J,interpolationSpace:$.interpolationSpace};if(E.has($.interpolationSpace))X.hueInterpolation=$.hueInterpolation;Q.value={type:"gradient",gradient:X}})}#HJ(){if(!this.#J)return;let J=this.#J.querySelector(".fig-fill-picker-gradient-bar-input");if(J)this.#k=!0,J.setAttribute("value",JSON.stringify({type:"gradient",gradient:P(this.#Y)})),this.#k=!1;this.#V()}#rJ(){if(!this.#J)return;let J=this.#J.querySelector(".fig-fill-picker-gradient-stops-list"),Q=J?.querySelector("fig-reorder");if(!J||!Q)return;let Z=Q.querySelectorAll(".fig-fill-picker-gradient-stop-row");if(Z.length===this.#Y.stops.length){this.#Y.stops.forEach(($,X)=>{let Y=Z[X];Y.dataset.index=X;let j=Y.querySelector(".fig-fill-picker-stop-position");if(j)j.setAttribute("value",$.position);let K=Y.querySelector(".fig-fill-picker-stop-color");if(K)K.setAttribute("value",this.#vJ($));let W=Y.querySelector(".fig-fill-picker-stop-remove");if(W)if(this.#Y.stops.length<=2)W.setAttribute("disabled","");else W.removeAttribute("disabled")});return}this.#OQ(J)}#OQ(J){let Q=J.querySelector("fig-reorder");if(!Q)return;let Z=this.#Y.stops.map(($,X)=>G("fig-field",{className:"fig-fill-picker-gradient-stop-row","data-index":X},[G("fig-input-number",{className:"fig-fill-picker-stop-position","aria-label":"Gradient stop position",min:"0",max:"100",value:$.position,units:"%"}),G("fig-input-color",{className:"fig-fill-picker-stop-color","aria-label":"Gradient stop color",text:"true",alpha:"true",picker:"figma","picker-dialog-position":"right",value:this.#vJ($)}),G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-stop-remove",disabled:this.#Y.stops.length<=2,"aria-label":"Remove gradient stop"},C("minus"))]));Q.replaceChildren(...Z),Q.querySelectorAll(".fig-fill-picker-gradient-stop-row").forEach(($)=>{$.querySelector(".fig-fill-picker-stop-position").addEventListener("input",()=>{this.#cJ($),this.#qJ(),this.#HJ(),this.#O()});let X=$.querySelector(".fig-fill-picker-stop-color"),Y=X.querySelector("fig-fill-picker");if(Y)Y.anchorElement=this.#J;else this.#N(()=>{let K=X.querySelector("fig-fill-picker");if(K)K.anchorElement=this.#J});let j=()=>{this.#cJ($),this.#k=!0;try{this.#qJ(),this.#HJ(),this.#O()}finally{this.#k=!1}};X.addEventListener("input",j),X.addEventListener("change",j),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{let K=parseInt($.dataset.index,10);if(this.#Y.stops.length>2)this.#Y.stops.splice(K,1),this.#b(),this.#O()})})}#pJ(J,Q=!0){let Z=N({...this.#Y,interpolationSpace:J??this.#Y.interpolationSpace}),$=this.#R==="display-p3",X=Z.stops.map((K)=>{let W=(K.opacity??100)/100;return`${$?this.#NQ(K.color,W):this.#_Q(K.color,W)} ${K.position}%`}).join(", "),Y=XJ(Z),j=Q&&Y?` ${Y}`:"";switch(Z.type){case"linear":return`linear-gradient(${Z.angle}deg${j}, ${X})`;case"radial":return`radial-gradient(circle at ${Z.centerX}% ${Z.centerY}%${j}, ${X})`;case"angular":return`conic-gradient(from ${Z.angle}deg${j}, ${X})`;default:return`linear-gradient(${Z.angle}deg${j}, ${X})`}}static#oJ=new Map;#nJ(J){let Q=y.#oJ.get(J);if(Q!==void 0)return Q;let Z=document.createElement("div");Z.style.background=J;let $=!!Z.style.background;return y.#oJ.set(J,$),$}#aJ(){let J=this.#pJ(void 0,!0);if(this.#nJ(J))return J;let Q=this.#pJ("oklab",!0);if(this.#nJ(Q))return Q;return this.#pJ("oklab",!1)}#GQ(){let J=this.#J.querySelector('[data-tab="image"]'),Q=G("fig-select",{className:"fig-fill-picker-scale-mode",label:"Image scale mode",value:this.#U.scaleMode},G("fig-select-options",{},[["fill","Fill"],["fit","Fit"],["crop","Crop"],["tile","Tile"]].map(([Y,j])=>G("fig-select-option",{value:Y},j)))),Z=G("fig-input-number",{className:"fig-fill-picker-scale","aria-label":"Image tile scale",min:"1",max:"200",value:this.#U.scale,units:"%"});if(this.#U.scaleMode!=="tile")Z.style.display="none";let $=G("fig-field",{className:"fig-fill-picker-media-header"},[Q,Z]),X=G("fig-image",{className:"fig-fill-picker-media-preview fig-fill-picker-image-preview",upload:"true",label:"Upload from computer",alt:"Image fill preview",size:"auto","aspect-ratio":"1/1",fit:"cover",checkerboard:"true"});J.replaceChildren($,X),this.#LQ(J)}#LQ(J){let Q=J.querySelector(".fig-fill-picker-scale-mode"),Z=J.querySelector(".fig-fill-picker-scale"),$=J.querySelector(".fig-fill-picker-image-preview");Q.addEventListener("change",(X)=>{let Y=typeof X.detail==="string"?X.detail:X.target?.value;if(!Y)return;this.#U.scaleMode=Y,Z.style.display=Y==="tile"?"block":"none",this.#e($),this.#V(),this.#O()}),Z.addEventListener("input",(X)=>{this.#U.scale=parseFloat(X.target.value)||100,this.#e($),this.#V(),this.#O()}),$.addEventListener("loaded",(X)=>{let Y=X.detail?.src||$.src;if(!Y)return;let j=Y!==this.#U.url;if(this.#U.url=Y,this.#e($),this.#V(),j)this.#O();this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:X.detail??{src:Y}}))}),$.addEventListener("change",()=>{if($.src)return;this.#U.url=null,this.#e($),this.#V(),this.#O()}),this.#e($)}#e(J){if(!this.#U.url){J.removeAttribute("src"),J.classList.remove("has-media","is-tiled"),J.style.backgroundImage="",J.style.backgroundPosition="",J.style.backgroundRepeat="",J.style.backgroundSize="";return}J.setAttribute("src",this.#U.url),J.classList.add("has-media"),J.style.backgroundImage="",J.style.backgroundPosition="",J.style.backgroundRepeat="",J.style.backgroundSize="",J.mediaEl?.style.removeProperty("opacity");let Q=J.querySelector("fig-input-file[data-generated]");if(Q)Q.setAttribute("label","Replace"),Q.removeAttribute("url");switch(this.#U.scaleMode){case"fill":J.classList.remove("is-tiled"),J.setAttribute("fit","cover");break;case"crop":J.classList.remove("is-tiled"),J.setAttribute("fit","cover");break;case"fit":J.classList.remove("is-tiled"),J.setAttribute("fit","contain");break;case"tile":if(J.classList.add("is-tiled"),J.setAttribute("fit","none"),J.style.backgroundImage=`url(${this.#U.url})`,J.style.backgroundPosition="top left",J.style.backgroundSize=`${this.#U.scale}%`,J.style.backgroundRepeat="repeat",J.mediaEl)J.mediaEl.style.opacity="0";break}}#YJ(J){if(J.tagName==="FIG-MEDIA"){if(!this.#Z.url){J.removeAttribute("src"),J.classList.remove("has-media");return}if(J.setAttribute("src",this.#Z.url),this.#Z.poster)J.setAttribute("poster",this.#Z.poster);else J.removeAttribute("poster");J.classList.add("has-media");let Q=J.querySelector("fig-input-file[data-generated]");if(Q)Q.setAttribute("label","Replace"),Q.removeAttribute("url");switch(this.#Z.scaleMode){case"fill":case"crop":J.setAttribute("fit","cover");break;case"fit":J.setAttribute("fit","contain");break}return}switch(J.style.objectPosition="center",J.style.width="100%",J.style.height="100%",this.#Z.scaleMode){case"fill":case"crop":J.style.objectFit="cover";break;case"fit":J.style.objectFit="contain";break}}#VQ(){let J=this.#J.querySelector('[data-tab="video"]'),Q=G("fig-select",{className:"fig-fill-picker-scale-mode",label:"Video scale mode",value:this.#Z.scaleMode},G("fig-select-options",{},[["fill","Fill"],["fit","Fit"],["crop","Crop"]].map(([X,Y])=>G("fig-select-option",{value:X},Y)))),Z=G("fig-field",{className:"fig-fill-picker-media-header"},Q),$=G("fig-media",{className:"fig-fill-picker-media-preview fig-fill-picker-video-preview",type:"video",upload:"true",label:"Upload from computer","aria-label":"Video fill preview",size:"auto","aspect-ratio":"1/1",fit:"cover",checkerboard:"true",controls:!0,muted:"true",loop:"true"});J.replaceChildren(Z,$),this.#HQ(J),this.#FJ({emit:!1})}#jJ(){if(this.#Z.poster?.startsWith("blob:"))URL.revokeObjectURL(this.#Z.poster),this.#S.delete(this.#Z.poster);this.#Z.poster=null,this.#r=null}#DJ(){if(!this.#Z.poster)return;if(this.#r&&this.#r===this.#Z.url)return;this.#jJ()}#dJ(){let J=this.#J?.querySelector(".fig-fill-picker-video-preview");if(J)this.#YJ(J)}#FJ({emit:J=!1}={}){if(this.#Z.url){if(this.#Z.missing=!1,this.#DJ(),!this.#Z.poster)this.#CJ(this.#Z.url);else this.#dJ();return}let Q=this.getAttribute("default-video");if(!Q){this.#Z.missing=!0;return}if(this.#Z.url=Q,this.#Z.missing=!1,this.#dJ(),this.#CJ(Q),J)this.#O()}#tJ(){if(this.#z!=="video")return;let J=this.#Z.url;if(!J)return;if(this.#DJ(),this.#Z.poster)return;this.#CJ(J)}async#fQ(J){if(typeof J.requestVideoFrameCallback==="function")await Promise.race([new Promise((Q)=>J.requestVideoFrameCallback(()=>Q())),new Promise((Q)=>setTimeout(Q,80))]);else try{await J.play(),J.pause()}catch{}if(typeof createImageBitmap==="function")try{return await createImageBitmap(J)}catch{}return null}async#qQ(J){let Q=await this.#fQ(J),Z=Q?.width||J.videoWidth,$=Q?.height||J.videoHeight;if(!Z||!$)return Q?.close?.(),null;let X=typeof OffscreenCanvas==="function"?new OffscreenCanvas(Z,$):Object.assign(document.createElement("canvas"),{width:Z,height:$}),Y=X.getContext("2d");if(!Y)return Q?.close?.(),null;try{Y.drawImage(Q||J,0,0,Z,$)}finally{Q?.close?.()}return X.convertToBlob?X.convertToBlob({type:"image/jpeg",quality:0.85}):new Promise((j)=>X.toBlob(j,"image/jpeg",0.85))}async#CJ(J,{emit:Q=!1}={}){if(!J||this.#I===J)return;this.#I=J;let Z=document.createElement("video");Z.muted=!0,Z.playsInline=!0,Z.preload="auto",Z.crossOrigin="anonymous";try{if(await new Promise((X,Y)=>{let j=()=>Y(Error("video poster failed"));Z.addEventListener("error",j,{once:!0}),Z.addEventListener("loadeddata",X,{once:!0}),Z.src=J}),!Z.videoWidth||!Z.videoHeight)return;let $=await this.#qQ(Z);if(!$||this.#Z.url!==J)return;if(this.#jJ(),this.#Z.poster=URL.createObjectURL($),this.#r=J,this.#S.add(this.#Z.poster),this.#V(),this.#dJ(),Q)this.#O()}catch{}finally{if(Z.removeAttribute("src"),Z.load(),this.#I===J)this.#I=null}}#HQ(J){let Q=J.querySelector(".fig-fill-picker-scale-mode"),Z=J.querySelector(".fig-fill-picker-video-preview");Q.addEventListener("change",($)=>{let X=typeof $.detail==="string"?$.detail:$.target?.value;if(!X)return;this.#Z.scaleMode=X,this.#YJ(Z),this.#V(),this.#O()}),Z.addEventListener("loaded",($)=>{let X=$.detail?.src||Z.src;if(!X)return;let Y=X!==this.#Z.url;if(Y)this.#jJ();if(this.#Z.url=X,this.#Z.missing=!1,this.#YJ(Z),this.#CJ(X),this.#V(),Y)this.#O();this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail??{src:X}}))}),Z.addEventListener("change",()=>{if(Z.src)return;this.#Z.url=null,this.#jJ(),this.#FJ(),this.#YJ(Z),this.#V(),this.#O()}),this.#YJ(Z)}#BQ(){let J=this.#J.querySelector('[data-tab="webcam"]'),Q=G("fig-field",{className:"fig-fill-picker-webcam-camera"},G("fig-select",{className:"fig-fill-picker-camera-select",label:"Camera",full:!0},document.createElement("fig-select-options")));Q.style.display="none";let Z=G("video",{className:"fig-fill-picker-webcam-video",autoplay:!0,muted:!0,playsinline:!0});Z.muted=!0;let $=G("div",{className:"fig-fill-picker-webcam-status",role:"status","aria-live":"polite"},G("span",{},"Camera access required")),X=G("fig-video",{className:"fig-fill-picker-webcam-preview","aria-label":"Webcam preview","aspect-ratio":"1/1",fit:"cover",checkerboard:"true",autoplay:"true",muted:"true"},[Z,$]),Y=G("div",{className:"fig-fill-picker-webcam-controls"},G("fig-button",{className:"fig-fill-picker-webcam-capture",variant:"secondary",full:!0,disabled:!0},"Capture"));J.replaceChildren(Q,X,Y),this.#RQ(J)}#RQ(J){let Q=J.querySelector(".fig-fill-picker-webcam-video"),Z=J.querySelector(".fig-fill-picker-webcam-status"),$=J.querySelector(".fig-fill-picker-webcam-capture"),X=J.querySelector(".fig-fill-picker-webcam-camera"),Y=J.querySelector(".fig-fill-picker-camera-select"),j=(U)=>{if(U)$.removeAttribute("disabled");else $.setAttribute("disabled","")},K=()=>{let U=!!this.#$.stream&&Q.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&Q.videoWidth>0&&Q.videoHeight>0;if(j(U),U)Z.querySelector("span").textContent="Camera ready",Z.style.display="none",this.#SJ(Q)};Q.addEventListener("loadedmetadata",K),Q.addEventListener("canplay",K),Q.addEventListener("playing",K);let W=(U)=>{this.#$.stream=U,Q.srcObject=U,Q.muted=!0,Q.playsInline=!0,Q.style.display="block";let O=Q.play?.();if(O?.catch)O.catch(()=>{});K()},z=async(U,O)=>{let f=await navigator.mediaDevices.enumerateDevices();if(U!=null&&U!==this.#c)return;let q=f.filter((_)=>_.kind==="videoinput");if(q.length>1){X.style.display="";let _=Y.querySelector(":scope > fig-select-options");if(!_)_=document.createElement("fig-select-options"),Y.append(_);if(_.replaceChildren(),q.forEach((R,T)=>{let V=document.createElement("fig-select-option");V.value=R.deviceId;let H=R.label||(q.length>1?`Camera ${T+1}`:"Camera");V.textContent=H.replace(/\s*\((?:[0-9a-f]{4}:)*([0-9a-f]{4})\)$/i,(M,D)=>{return` ${/^\d+$/.test(D)?Number.parseInt(D,10).toString():D.replace(/^0+/,"")||"0"}`}),_.append(V)}),O)Y.value=O}else X.style.display="none",Y.querySelector(":scope > fig-select-options")?.replaceChildren()},L=async(U=null)=>{let O=U||this.#$.deviceId||null,f=this.#$.stream,q=f?.getTracks?.().filter((R)=>R.readyState!=="ended")??[];if(f&&q.length){let R=f.getVideoTracks?.()?.[0]?.getSettings?.()?.deviceId||this.#$.deviceId||null;if(!O||O===R){W(f),this.#UJ(),z(null,O||R);return}}this.#t({emit:Boolean(f)});let _=this.#c;j(!1),Z.querySelector("span").textContent="Starting camera",Z.style.display="flex";try{let R={video:O?{deviceId:{exact:O}}:!0},T=await navigator.mediaDevices.getUserMedia(R);if(_!==this.#c||!this.isConnected||this.#L!=="webcam"){T.getTracks().forEach((H)=>H.stop());return}let V=T.getVideoTracks?.()?.[0];this.#$.deviceId=O||V?.getSettings?.()?.deviceId||null,this.#$.live=this.#o()==="live",W(T),this.#UJ(),await z(_,O)}catch(R){if(_!==this.#c)return;console.error("Webcam error:",R.name,R.message);let T="Camera access denied";if(R.name==="NotAllowedError")T="Camera permission denied";else if(R.name==="NotFoundError")T="No camera found";else if(R.name==="NotReadableError")T="Camera in use by another app";else if(R.name==="OverconstrainedError")T="Camera constraints not supported";else if(!window.isSecureContext)T="Camera requires secure context";Z.replaceChildren();let V=document.createElement("span");V.textContent=T,Z.appendChild(V),Z.style.display="flex",Q.style.display="none",j(!1)}};this.#zJ=L,Y.addEventListener("change",(U)=>{let O=typeof U.detail==="string"?U.detail:U.target?.value;if(!O||O===this.#$.deviceId)return;L(O)}),$.addEventListener("click",async()=>{if(!this.#$.stream)return;let U=await this.#QJ(Q);if(!U)return;this.#U.url=U,this.#$.live=!1;let O=this.#J.querySelector(".fig-fill-picker-image-preview");if(O)this.#e(O);if(Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).some((q)=>q.dataset.tab==="image"))this.#ZJ("image");else this.#V(),this.#O();this.#g()})}#sJ(J){let Q=J.h/360,Z=J.s/100,$=J.v/100,X,Y,j,K=Math.floor(Q*6),W=Q*6-K,z=$*(1-Z),L=$*(1-W*Z),U=$*(1-(1-W)*Z);switch(K%6){case 0:X=$,Y=U,j=z;break;case 1:X=L,Y=$,j=z;break;case 2:X=z,Y=$,j=U;break;case 3:X=z,Y=L,j=$;break;case 4:X=U,Y=z,j=$;break;case 5:X=$,Y=z,j=L;break}return{r:Math.round(X*255),g:Math.round(Y*255),b:Math.round(j*255)}}#KJ(J){let Q=J.r/255,Z=J.g/255,$=J.b/255,X=Math.max(Q,Z,$),Y=Math.min(Q,Z,$),j=X-Y,K=0,W=X===0?0:j/X,z=X;if(X!==Y){switch(X){case Q:K=(Z-$)/j+(Z<$?6:0);break;case Z:K=($-Q)/j+2;break;case $:K=(Q-Z)/j+4;break}K/=6}return{h:K*360,s:W*100,v:z*100,a:1}}#s(J){if(!J||typeof J.h!=="number"||typeof J.s!=="number"||typeof J.v!=="number")return"#D9D9D9";let Q=this.#sJ(J),Z=($)=>{return(isNaN($)?217:Math.max(0,Math.min(255,Math.round($)))).toString(16).padStart(2,"0")};return`#${Z(Q.r)}${Z(Q.g)}${Z(Q.b)}`}#WJ(J){let Q=parseInt(J.slice(1,3),16),Z=parseInt(J.slice(3,5),16),$=parseInt(J.slice(5,7),16);return this.#KJ({r:Q,g:Z,b:$})}#_Q(J,Q=1){let Z=parseInt(J.slice(1,3),16),$=parseInt(J.slice(3,5),16),X=parseInt(J.slice(5,7),16);return`rgba(${Z}, ${$}, ${X}, ${Q})`}#TQ(J){let Q=Math.max(0,Math.min(1,Number(J)||0)),Z=Math.round(Q*1000)/1000;return String(Z)}#kQ(J=this.#X){let Q=this.#sJ(J);return`rgba(${Q.r}, ${Q.g}, ${Q.b}, ${this.#TQ(J.a)})`}#MQ(J){let Q=String(J??"").trim();if(!Q)return null;let Z=Q.match(/^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i);if(Z){let X=Z[1];if(X.length===3)X=X[0]+X[0]+X[1]+X[1]+X[2]+X[2];let Y=1;if(X.length===8)Y=parseInt(X.slice(6,8),16)/255,X=X.slice(0,6);return{...this.#WJ(`#${X}`),a:Y}}let $=Q.match(/^rgba?\(\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))(?:\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*)?\)$/i);if($){let X=Math.max(0,Math.min(255,Math.round(parseFloat($[1])))),Y=Math.max(0,Math.min(255,Math.round(parseFloat($[2])))),j=Math.max(0,Math.min(255,Math.round(parseFloat($[3])))),K=$[4]!==void 0?Math.max(0,Math.min(1,parseFloat($[4]))):1;if(![X,Y,j,K].every(Number.isFinite))return null;return{...this.#KJ({r:X,g:Y,b:j}),a:K}}return null}#NQ(J,Q=1){let Z=+(parseInt(J.slice(1,3),16)/255).toFixed(4),$=+(parseInt(J.slice(3,5),16)/255).toFixed(4),X=+(parseInt(J.slice(5,7),16)/255).toFixed(4);return`color(display-p3 ${Z} ${$} ${X} / ${Q})`}#yQ(J){let Q=J.r/255,Z=J.g/255,$=J.b/255,X=Math.max(Q,Z,$),Y=Math.min(Q,Z,$),j,K,W=(X+Y)/2;if(X===Y)j=K=0;else{let z=X-Y;switch(K=W>0.5?z/(2-X-Y):z/(X+Y),X){case Q:j=((Z-$)/z+(Z<$?6:0))/6;break;case Z:j=(($-Q)/z+2)/6;break;case $:j=((Q-Z)/z+4)/6;break}}return{h:j*360,s:K*100,l:W*100}}#DQ(J){let Q=J.h/360,Z=J.s/100,$=J.l/100,X,Y,j;if(Z===0)X=Y=j=$;else{let K=(L,U,O)=>{if(O<0)O+=1;if(O>1)O-=1;if(O<0.16666666666666666)return L+(U-L)*6*O;if(O<0.5)return U;if(O<0.6666666666666666)return L+(U-L)*(0.6666666666666666-O)*6;return L},W=$<0.5?$*(1+Z):$+Z-$*Z,z=2*$-W;X=K(z,W,Q+0.3333333333333333),Y=K(z,W,Q),j=K(z,W,Q-0.3333333333333333)}return{r:Math.round(X*255),g:Math.round(Y*255),b:Math.round(j*255)}}#eJ(J){let Q=(U)=>{return U=U/255,U<=0.04045?U/12.92:Math.pow((U+0.055)/1.055,2.4)},Z=Q(J.r),$=Q(J.g),X=Q(J.b),Y=0.4122214708*Z+0.5363325363*$+0.0514459929*X,j=0.2119034982*Z+0.6806995451*$+0.1073969566*X,K=0.0883024619*Z+0.2817188376*$+0.6299787005*X,W=Math.cbrt(Y),z=Math.cbrt(j),L=Math.cbrt(K);return{l:0.2104542553*W+0.793617785*z-0.0040720468*L,a:1.9779984951*W-2.428592205*z+0.4505937099*L,b:0.0259040371*W+0.7827717662*z-0.808675766*L}}#FQ(J){let Q=this.#eJ(J);return{l:Q.l,c:Math.sqrt(Q.a*Q.a+Q.b*Q.b),h:(Math.atan2(Q.b,Q.a)*180/Math.PI+360)%360}}#JQ(J){let Q=J.l+0.3963377774*J.a+0.2158037573*J.b,Z=J.l-0.1055613458*J.a-0.0638541728*J.b,$=J.l-0.0894841775*J.a-1.291485548*J.b,X=Q*Q*Q,Y=Z*Z*Z,j=$*$*$,K=(W)=>{let z=W<=0.0031308?12.92*W:1.055*Math.pow(W,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,z))*255)};return{r:K(4.0767416621*X-3.3077115913*Y+0.2309699292*j),g:K(-1.2684380046*X+2.6097574011*Y-0.3413193965*j),b:K(-0.0041960863*X-0.7034186147*Y+1.707614701*j)}}#CQ(J){let Q=J.h*Math.PI/180;return this.#JQ({l:J.l,a:J.c*Math.cos(Q),b:J.c*Math.sin(Q)})}#O(){if(this.#u())return;this.#V(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#g(){if(this.#u())return;this.#m=JSON.stringify(this.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){let J={type:this.#z,colorSpace:this.#R};switch(this.#z){case"solid":return{...J,color:this.#s(this.#X),alpha:this.#X.a,hsv:{...this.#X}};case"gradient":return{...J,gradient:P(this.#Y),css:this.#aJ()};case"image":return{...J,image:{...this.#U}};case"video":return{...J,video:this.#RJ()};case"webcam":return{...J,webcam:this.#BJ()};default:return{...J,...this.#h[this.#z]}}}set value(J){if(typeof J==="string")this.setAttribute("value",J);else this.setAttribute("value",JSON.stringify(J))}attributeChangedCallback(J,Q,Z){if(Q===Z)return;switch(J){case"value":if(this.#GJ(),this.#V(),this.#tJ(),this.#J?.open&&!this.#A)this.#NJ(),this.#m=JSON.stringify(this.value);break;case"disabled":if(this.#q(),this.#u()&&this.#J?.open)this.close();break;case"alpha":case"mode":{if(!this.#J)break;let $=this.#J.open;if(this.#kJ(),$&&this.isConnected)this.#a();break}case"webcam-mode":if(this.#z==="webcam")this.#V();break;case"default-video":if(this.#z==="video")this.#FJ({emit:!1}),this.#V();break;case"aria-label":if(this.#J)this.#J.setAttribute("aria-label",this.#x());case"aria-labelledby":case"aria-describedby":this.#q();break}}}A("fig-fill-picker",y);class B extends HTMLElement{static#K=new Set(["oklch","hsl"]);static#Q=10;static#j=10;static#W=8;static#J=3;static#E=210;static#L={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#z=!1;#R=null;#X=null;#G={...B.#L};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}set value(J){if(J==null||J===""){this.removeAttribute("value");return}if(typeof J==="string"){this.setAttribute("value",J);return}this.setAttribute("value",JSON.stringify(J))}connectedCallback(){this.#Y(),this.#U(),this.#A(),this.#k()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J!=="value")return;if(this.#U(),this.#z)this.#k()}#Y(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#U(){let J=this.getAttribute("value");if(!J){this.#G={...B.#L,stops:B.#L.stops.map((Q)=>({...Q}))};return}try{let Q=JSON.parse(J),Z=Q?.type==="gradient"&&Q.gradient?Q.gradient:Q?.gradient?Q.gradient:Q;if(!Z||typeof Z!=="object")return;this.#G=this.#Z({...B.#L,...Z})}catch{}}#Z(J){let Q={...J??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase(),$=String(Q.hueInterpolation??"shorter").toLowerCase(),X=Array.isArray(Q.stops)?Q.stops.map((Y)=>({color:String(Y?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:Y?.position??0,opacity:Y?.opacity??100})):B.#L.stops.map((Y)=>({...Y}));if(X.length<2)return{...B.#L,stops:B.#L.stops.map((Y)=>({...Y}))};return{type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):135,interpolationSpace:Z,hueInterpolation:$,stops:X}}#$(){return B.#K.has(this.#G.interpolationSpace||"srgb")}#C(J){let{r:Q,g:Z,b:$}=l(J);if(this.#G.interpolationSpace==="hsl")return r(Q,Z,$).h;let X=o(Q,Z,$);return(n(X.l,X.a,X.b).h%360+360)%360}#D(){let J=this.#B(),Q=this.#C(J[0]?.color||"#FF0000"),Z=this.#C(J[J.length-1]?.color||"#4F9EFF"),$=B.#E-Q,Y=((B.#E-Z-$)%360+360)%360,j=Y===0?0:Y-360,K=this.#G.hueInterpolation||"shorter",W;if(K==="increasing")W=j;else if(K==="decreasing")W=Y;else if(K==="longer")W=Y<180?j:Y;else W=Y<=180?Y:j;let z=Math.sign(W),L=Math.asin(B.#J/2/B.#W)*180/Math.PI,U=Math.min(L,Math.max(0,(Math.abs(W)-0.01)/2));return{startDeg:$+z*U,sweepDeg:W-z*U*2}}#F(J){let Q=J*Math.PI/180;return{x:B.#Q+B.#W*Math.cos(Q),y:B.#j+B.#W*Math.sin(Q)}}#f(J,Q){let Z=J+Q,$=this.#F(J),X=this.#F(Z),Y=Math.abs(Q)>180?1:0,j=Q>=0?1:0;return`M ${$.x} ${$.y} A ${B.#W} ${B.#W} 0 ${Y} ${j} ${X.x} ${X.y}`}#h(){let J=this.#F(180),Q=this.#F(0);return`M ${J.x} ${J.y} L ${Q.x} ${Q.y}`}#H(J){let Q=B.#J,Z=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${J}" fill="none" stroke="white" stroke-width="${Q}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(Z)}")`}#B(){return[...this.#G.stops].sort((J,Q)=>(J.position??0)-(Q.position??0))}#_(){let J=this.#G.interpolationSpace||"srgb";if(J==="srgb")return"";if(B.#K.has(J))return` in ${J} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${J}`}#T(){let J=this.#B(),Q=this.#_();if(this.#$()){let $=(B.#E+90)%360,X=this.#G.interpolationSpace,Y=(K)=>X==="oklch"?`oklch(65% 0.25 ${K})`:`hsl(${K} 100% 50%)`,j=[0,300,240,180,120,60,0].map(Y).join(", ");return`conic-gradient(from ${$}deg in ${X} decreasing hue, ${j})`}let Z=J.map(($)=>`${$.color} ${$.position??0}%`).join(", ");return`linear-gradient(90deg${Q}, ${Z})`}#A(){if(this.#z)return;let J=B.#J,Q=u("svg",{className:"fig-interpolation-swatch-svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true"},u("circle",{className:"fig-interpolation-swatch-rim",cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor","stroke-width":J})),Z=G("div",{className:"fig-interpolation-swatch-fill","aria-hidden":"true"});this.replaceChildren(Q,Z),this.#R=Q,this.#X=Z,this.#z=!0}#k(){if(!this.#X)return;let J=this.#$();if(this.#R)this.#R.style.display=J?"":"none";let Q=J?(()=>{let{startDeg:$,sweepDeg:X}=this.#D();return this.#f($,X)})():this.#h(),Z=this.#H(Q);this.#X.style.setProperty("-webkit-mask-image",Z),this.#X.style.maskImage=Z,this.#X.style.background=this.#T()}}A("fig-interpolation-swatch",B);
108
+ `,J.appendChild(Q);let Z=document.createElement("fig-button");Z.className="fig-select-trigger",Z.setAttribute("part","trigger"),Z.setAttribute("variant","ghost"),Z.setAttribute("aria-haspopup","listbox"),Z.setAttribute("aria-expanded","false");let $=document.createElement("span");$.className="fig-select-prepend",$.setAttribute("part","prepend"),$.setAttribute("aria-hidden","true");let X=document.createElement("slot");X.setAttribute("name","prepend-trigger"),X.hidden=!0;let Y=document.createElement("span");Y.className="fig-select-prepend-fallback",$.append(X,Y);let j=document.createElement("span");j.className="fig-select-label",j.setAttribute("part","label");let K=document.createElement("slot");K.setAttribute("name","trigger"),K.hidden=!0,Z.append($,j,K);let W=document.createElement("dialog",{is:"fig-popup"});if(W.setAttribute("is","fig-popup"),W.setAttribute("part","listbox"),W.setAttribute("theme","menu"),W.setAttribute("role","listbox"),"popover"in HTMLElement.prototype)W.setAttribute("popover","manual");W.id=d(),Z.setAttribute("aria-controls",W.id);let z=document.createElement("slot");if(z.setAttribute("name","panel"),W.appendChild(z),J.append(Z,W),this.#K=Z,this.#j=$,this.#W=X,this.#J=Y,this.#E=K,this.#L=j,this.#Q=W,this.#z=z,this.#p(),this.#v(),this.#i(),!this.hasAttribute("value")){let L=this.#x().find((U)=>k(U,"selected"));if(L)this.setAttribute("value",L.value)}}#i(){if(!this.#Q||this.#U)return;if(typeof this.#Q.positionPopup!=="function")return;this.#Z=this.#Q.positionPopup.bind(this.#Q),this.#Q.positionPopup=()=>{if(!this.open){this.#Z?.();return}this.#QJ()},this.#U=!0}#l(J){if(!J)return null;let Q=document.createRange();Q.selectNodeContents(J);let Z=[...Q.getClientRects()].filter(($)=>$.width>0&&$.height>0);if(Z.length)return Z[0];return J.getBoundingClientRect()}#S(){if(typeof this.#Q?.parseViewportMargins==="function")return this.#Q.parseViewportMargins();return{top:8,right:8,bottom:8,left:8}}#I(){if(this.#f?.isConnected)return this.#f;let J=this.getAttribute("menu-anchor");if(J)try{let Q=this.parentElement?.querySelector(J);if(Q&&Q!==this&&!this.contains(Q))return Q;let $=this.getRootNode()?.querySelector?.(J);if($&&$!==this&&!this.contains($))return $}catch{}return null}#r(){return this.#I()||this.#K}#u(){return Boolean(this.#I())}#o(){return!this.#OJ()&&this.#u()}#p(){if(!this.#Q)return;if(this.#Q.anchor=this.#r(),this.#M(),!this.open)return;this.#$=!1,this.#C=null,this.#D=null,this.#Q.setupObservers?.(),this.#Q.queueReposition?.()}#BJ(){let J=this.#L?.getBoundingClientRect();if(J?.width&&J?.height)return J;let Q=this.querySelector(':scope > [slot="trigger"]')?.getBoundingClientRect();if(Q?.width&&Q?.height)return Q;return this.#j?.getBoundingClientRect()??null}#RJ(){let Q=(this.#o()?this.#I():null)?.getBoundingClientRect()??this.#BJ();if(!Q)return null;return{x:Q.x,y:Q.y,width:Q.width,height:Q.height}}#_J(){let J=window.visualViewport;return{width:J?.width??window.innerWidth,height:J?.height??window.innerHeight,offsetLeft:J?.offsetLeft??0,offsetTop:J?.offsetTop??0}}#UJ(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.x-Q.x)>Z||Math.abs(J.y-Q.y)>Z||Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z}#EJ(J,Q,Z=0.25){if(!J&&!Q)return!1;if(!J||!Q)return!0;return Math.abs(J.width-Q.width)>Z||Math.abs(J.height-Q.height)>Z||Math.abs(J.offsetLeft-Q.offsetLeft)>Z||Math.abs(J.offsetTop-Q.offsetTop)>Z}#AJ(){if(!this.#$)return!1;let J=this.#UJ(this.#C,this.#RJ()),Q=this.#EJ(this.#D,this.#_J());return!J&&!Q}#TJ(){this.#C=this.#RJ(),this.#D=this.#_J()}#OJ(){let J=this.getAttribute("position");return Boolean(J&&J.trim())}#PJ(){if(!this.#Q)return;this.#Q.style.removeProperty("left"),this.#Q.style.removeProperty("top"),this.#Q.style.removeProperty("right"),this.#Q.style.removeProperty("bottom")}#QJ(){if(this.#OJ()){if(this.#$=!1,this.#C=null,this.#D=null,this.#M(),this.#PJ(),this.#SJ())return;this.#Z?.(),this.#N();return}this.#IJ()}#SJ(){let J=this.#Q,Q=this.#I();if(!J||!Q||typeof J.parsePosition!=="function"||typeof J.parseOffset!=="function"||typeof J.computeCoords!=="function")return!1;let Z=J.getBoundingClientRect(),$=Q.getBoundingClientRect();if(!Z.width||!Z.height)return!1;let{vertical:X,horizontal:Y,shorthand:j}=J.parsePosition(),K=J.parseOffset(),{left:W,top:z}=J.computeCoords($,Z,X,Y,K,j),L=this.#S();if(typeof J.clampToViewport==="function")({left:W,top:z}=J.clampToViewport({left:W,top:z},Z,L));return J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(W)}px`,"important"),J.style.setProperty("top",`${Math.round(z)}px`,"important"),!0}#N(){let J=this.#Q;if(!J||typeof J.clampToViewport!=="function")return;let Q=J.getBoundingClientRect();if(!Q.width||!Q.height)return;let Z=this.#S(),{left:$,top:X}=J.clampToViewport({left:Q.left,top:Q.top},Q,Z);J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round($)}px`,"important"),J.style.setProperty("top",`${Math.round(X)}px`,"important")}#IJ(){if(this.#AJ()){this.#N();return}let J=this.#Q,Q=this.#L;if(!J||!Q){this.#Z?.();return}let Z=this.#x(),$=Z.find((q)=>this.#q(q)===this.value)||Z[0];if(!$){this.#Z?.();return}let X=this.#o()?this.#I():null;if(X)this.#M();this.#Z?.();let Y=J.getBoundingClientRect(),j=$.getBoundingClientRect();if(!Y.width||!Y.height||!j.height)return;let K,W,z;if(X){let q=X.getBoundingClientRect();z=q,K=q.left+(q.width-Y.width)/2,W=q.top+(q.height-j.height)/2-(j.top-Y.top)}else{let q=this.#BJ(),_=this.#l($);if(!q?.width||!_)return;z=q;let R=_.left-Y.left,T=_.top-Y.top;K=k(this,"full")?this.getBoundingClientRect().left:q.left-R,W=q.top-T}let L=this.#S();if(typeof J.clampToViewport==="function")({left:K,top:W}=J.clampToViewport({left:K,top:W},Y,L));else{let{left:q,top:_}=L,R=window.innerWidth-Y.width-L.right,T=window.innerHeight-Y.height-L.bottom;K=Math.min(Math.max(K,q),Math.max(q,R)),W=Math.min(Math.max(W,_),Math.max(_,T))}J.style.setProperty("right","auto","important"),J.style.setProperty("bottom","auto","important"),J.style.setProperty("left",`${Math.round(K)}px`,"important"),J.style.setProperty("top",`${Math.round(W)}px`,"important");let U=this.#P(),O=$.getBoundingClientRect(),f=X?null:this.#l($);if(U&&U.scrollHeight>U.clientHeight+1){let q=X?O.top+O.height/2-(z.top+z.height/2):f?f.top-z.top:0;if(Math.abs(q)>0.5)U.scrollTop+=q;U.syncOverflow?.()}if(this.#$||this.open)this.#TJ()}#xJ(){this.#K?.addEventListener("click",this.#h),this.#K?.addEventListener("keydown",this.#_),this.addEventListener("click",this.#H),this.addEventListener("pointerover",this.#B),this.#Q?.addEventListener("keydown",this.#_),this.#Q?.addEventListener("close",this.#T),this.#z?.addEventListener("slotchange",this.#A)}#n(){this.#K?.removeEventListener("click",this.#h),this.#K?.removeEventListener("keydown",this.#_),this.removeEventListener("click",this.#H),this.removeEventListener("pointerover",this.#B),this.#Q?.removeEventListener("keydown",this.#_),this.#Q?.removeEventListener("close",this.#T),this.#z?.removeEventListener("slotchange",this.#A)}#wJ(){this.#v(),this.#d()}#uJ(){if(this.#R)return;this.#R=new MutationObserver((J)=>{if(this.#Y||this.#F)return;let Q=!1;for(let Z of J){if(Z.type==="childList"){if([...Z.addedNodes].some(($)=>this.#w($))||[...Z.removedNodes].some(($)=>this.#w($))||Z.target?.closest?.("fig-select-option"))Q=!0}if(Z.type==="attributes"&&Z.target?.tagName==="FIG-SELECT-OPTION"){if(Z.attributeName==="value"||Z.attributeName==="disabled"||Z.attributeName==="label")Q=!0;else if(Z.attributeName==="selected"){if(k(Z.target,"selected")){let $=this.#q(Z.target);if((this.getAttribute("value")??"")!==$)this.setAttribute("value",$),Q=!0}else if(this.#q(Z.target)===(this.getAttribute("value")??""))Q=!0}}if(Z.type==="characterData"&&Z.target?.parentElement?.tagName==="FIG-SELECT-OPTION")Q=!0}if(Q)this.#d()}),this.#R.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:["value","disabled","selected","label"]})}#x({enabledOnly:J=!1}={}){let Q=this.#P(),Z=Q?Array.from(Q.querySelectorAll(":scope > fig-select-option")):[];if(!J)return Z;return Z.filter(($)=>!k($,"disabled"))}#q(J){if(!J)return"";if(typeof J.value==="string")return J.value;let Q=J.getAttribute?.("value");if(Q!=null)return Q;return(J.textContent||"").trim()}#bJ(J){if(!J)return"";let Q=J.getAttribute?.("label");if(Q!=null&&Q!=="")return Q.trim();let Z=[];for(let $ of J.childNodes){if($.nodeType===Node.TEXT_NODE){let j=$.textContent?.trim();if(j)Z.push(j);continue}if(!($ instanceof Element))continue;let X=$.getAttribute("slot");if(X==="prepend"||X==="append")continue;let Y=$.textContent?.trim();if(Y)Z.push(Y)}if(Z.length)return Z.join(" ").trim();return(J.textContent||"").trim()}#gJ(J){if(!this.#j||!this.#W||!this.#J||!this.#E)return;let Q=this.querySelector(':scope > [slot="trigger"]'),Z=this.querySelector(':scope > [slot="prepend-trigger"][data-fig-select-generated]'),$=this.querySelector(':scope > [slot="prepend-trigger"]:not([data-fig-select-generated])'),X=J?.querySelector?.(':scope > [slot="prepend"]:not([data-fig-select-checkmark])');if(this.#E.hidden=!Q,this.#L.hidden=Boolean(Q),this.#j.hidden=Boolean(Q),Q){Z?.remove(),this.#j.classList.remove("has-content"),this.#W.hidden=!0,this.#J.replaceChildren();return}if(!$&&X?.childNodes.length){let j=Z||document.createElement("span");if(j.setAttribute("slot","prepend-trigger"),j.setAttribute("data-fig-select-generated",""),j.replaceChildren(...Array.from(X.childNodes,(K)=>K.cloneNode(!0))),j.parentElement!==this)this.append(j);$=j}else if($)Z?.remove();else Z?.remove();let Y=Boolean($);if(this.#j.classList.toggle("has-content",Y),this.#W.hidden=!$,this.#J.hidden=Boolean($),$){this.#J.replaceChildren();return}this.#J.replaceChildren()}#GJ(){if(!this.#Q)return;this.#Q.setAttribute("position",this.getAttribute("position")||"bottom left");let J=this.getAttribute("offset");if(J)this.#Q.setAttribute("offset",J);else this.#Q.removeAttribute("offset");let Q=this.getAttribute("closedby");if(Q)this.#Q.setAttribute("closedby",Q);else this.#Q.removeAttribute("closedby")}#V(){let J=k(this,"disabled");if(this.#K)if(J)this.#K.setAttribute("disabled","");else this.#K.removeAttribute("disabled");if(J&&this.open)this.open=!1}#LJ(J){if(!J.length)return null;let Q=J.find((Z)=>k(Z,"selected"));if(Q&&!k(Q,"disabled"))return Q;return J.find((Z)=>!k(Z,"disabled"))||J[0]||null}#a(J){this.dispatchEvent(new CustomEvent("input",{detail:J,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("change",{detail:J,bubbles:!0,composed:!0}))}#d(){if(this.#Y)return;this.#Y=!0;try{let J=this.#x(),Q=this.hasAttribute("value"),Z=Q?this.getAttribute("value"):null,$=Q?J.find((K)=>this.#q(K)===Z):null,X=!1;if(!$){if(Q){if(!J.length){if(this.#L)this.#L.textContent=Z||this.getAttribute("label")||"";return}if($=this.#LJ(J),$){let K=this.#q($);if(Z!==K)this.setAttribute("value",K),X=!0}else this.removeAttribute("value"),X=!0}else if($=J.find((K)=>k(K,"selected")),$)this.setAttribute("value",this.#q($)),X=!0}for(let K of J){v(K);let W=K===$;if(K.setAttribute("aria-selected",W?"true":"false"),W)K.setAttribute("selected","");else K.removeAttribute("selected")}let Y=$&&this.#bJ($)||this.getAttribute("label")||"";if(this.#L)this.#L.textContent=Y;this.#gJ($);let j=this.getAttribute("aria-label")||this.getAttribute("label")||"Select";if(this.#K?.setAttribute("aria-label",j),this.#P()?.syncOverflow?.(),X)this.#a(this.getAttribute("value")??"")}finally{this.#Y=!1}}#kJ(J){if(k(this,"disabled"))return;J.preventDefault(),J.stopPropagation();let Q=!this.open;if(Q)this.#p();this.open=Q}#MJ(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(k(Z,"disabled"))return;this.#NJ(Z)}#t(J){let Z=(typeof J.composedPath==="function"?J.composedPath():[]).find(($)=>$?.tagName==="FIG-SELECT-OPTION");if(!Z||!this.contains(Z))return;if(k(Z,"disabled"))return;if(J.relatedTarget instanceof Node&&Z.contains(J.relatedTarget))return;this.dispatchEvent(new CustomEvent("optionhover",{detail:this.#q(Z),bubbles:!0,composed:!0}))}#hJ(J){if(J.currentTarget===document&&J.key!=="Escape")return;if(!(this.open&&(this.#Q?.matches?.(":open")??!1))){if(this.#K?.contains(J.target)&&(J.key==="ArrowDown"||J.key==="Enter"||J.key===" "))J.preventDefault(),this.#p(),this.open=!0,requestAnimationFrame(()=>{let X=this.#x({enabledOnly:!0}).findIndex((Y)=>this.#q(Y)===this.value);this.#y(X>=0?X:0)});return}let Z=this.#x({enabledOnly:!0});if(!Z.length)return;switch(J.key){case"ArrowDown":J.preventDefault(),this.#yJ(),this.#y(this.#G+1,!0);break;case"ArrowUp":J.preventDefault(),this.#yJ(),this.#y(this.#G-1,!0);break;case"Home":J.preventDefault(),this.#y(0,!0);break;case"End":J.preventDefault(),this.#y(Z.length-1,!0);break;case"Escape":J.preventDefault(),this.open=!1,this.#K?.focus();break;case"Enter":case" ":{this.#yJ();let $=Z[this.#G];if(!$)return;J.preventDefault(),this.#NJ($);break}}}#ZJ(){if(this.hasAttribute("open"))this.removeAttribute("open");this.#K?.setAttribute("aria-expanded","false"),this.#K?.focus(),this.#G=-1}#NJ(J){let Q=this.#q(J);this.setAttribute("value",Q),this.#d(),this.#a(Q),this.open=!1}#VJ(){return this.#x({enabledOnly:!0})}#yJ(){let J=this.#VJ();if(!J.length){this.#G=-1;return}let Q=J.find(($)=>$===document.activeElement),Z=Q?J.indexOf(Q):-1;this.#G=Z>=0?Z:this.#G}#y(J,Q=!1){let Z=this.#VJ();if(!Z.length)return;let $=(J%Z.length+Z.length)%Z.length,X=Z[$],Y=document.activeElement!==X;if(this.#G=$,X?.focus(),Q&&Y)this.dispatchEvent(new CustomEvent("optionfocus",{detail:this.#q(X),bubbles:!0,composed:!0}))}#M(){if(!this.#Q||!this.#K)return;let J=Math.ceil(this.getBoundingClientRect().width),Q=Math.ceil(this.#K.getBoundingClientRect().width),Z=Math.max(J,Q,96),$=this.#u()?this.#I():null,X=window.visualViewport?.width??window.innerWidth,Y=window.visualViewport?.height??window.innerHeight,j=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,K=Math.max(0,Math.min(Math.floor(20*j),Math.floor(X-16))),W=Math.max(0,Math.floor(Y-16));if(this.#Q.style.setProperty("box-sizing","border-box","important"),this.#Q.style.setProperty("padding","0","important"),this.#Q.style.setProperty("border","0","important"),this.#Q.style.setProperty("margin","0","important"),$){let L=$.getBoundingClientRect().width;this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width","0","important"),this.#Q.style.setProperty("max-width",`${K}px`,"important");let U=this.#Q.getBoundingClientRect().width,O=Math.min(K,Math.max(Z,U)),f=Math.max(L,O);this.#Q.style.setProperty("width",`${f}px`,"important"),this.#Q.style.setProperty("min-width",`${f}px`,"important"),this.#Q.style.setProperty("max-width",`${f}px`,"important")}else this.#Q.style.setProperty("width","max-content","important"),this.#Q.style.setProperty("min-width",`${Z}px`,"important"),this.#Q.style.setProperty("max-width",`${K}px`,"important");this.#Q.style.setProperty("max-height",`${W}px`,"important"),this.#Q.style.setProperty("height","max-content","important"),this.#Q.style.setProperty("overflow","hidden","important");let z=this.#Q.getBoundingClientRect();if(z.height>W)this.#Q.style.setProperty("height",`${W}px`,"important");if(!$&&z.width>K)this.#Q.style.setProperty("width",`${K}px`,"important")}#$J(){if(!this.#Q||k(this,"disabled"))return;this.#p(),this.#i(),this.#$=!1,this.#C=null,this.#D=null,this.#d(),this.#M(),this.#Q.open=!0,document.addEventListener("keydown",this.#_,!0),this.#K?.setAttribute("aria-expanded","true"),this.#G=-1,requestAnimationFrame(()=>{requestAnimationFrame(()=>{this.#M(),this.#QJ(),this.#M(),this.#N();let J=this.#P(),Z=this.#VJ().findIndex(($)=>this.#q($)===this.value);if(Z>=0)this.#y(Z);else if(this.#K?.hasAttribute("data-focus-visible")||this.#K?.matches?.(":focus-visible"))this.#y(0);if(J?.syncOverflow?.(),!this.#OJ())this.#$=!0,this.#TJ()})})}#fJ(){if(!this.#Q)return;this.#$=!1,this.#C=null,this.#D=null,document.removeEventListener("keydown",this.#_,!0),this.#Q.open=!1,this.#K?.setAttribute("aria-expanded","false")}}A("fig-select",p);var $J=["srgb","srgb-linear","display-p3","oklab","oklch","hsl"],XJ=["shorter","longer","increasing","decreasing"],E=new Set(["oklch","hsl"]);function N(J){let Q={...J??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase();if(!$J.includes(Z))Z="srgb";Q.interpolationSpace=Z;let $=String(Q.hueInterpolation??"shorter").toLowerCase();return Q.hueInterpolation=XJ.includes($)?$:"shorter",Q}function S(J){let Q=N(J);return Q.interpolationSpace="srgb",delete Q.hueInterpolation,Q}function P(J){let Q=S(J),Z={...Q,interpolationSpace:Q.interpolationSpace};if(E.has(Q.interpolationSpace))Z.hueInterpolation=Q.hueInterpolation;else delete Z.hueInterpolation;return Z}function YJ(J){let Q=N(J);if(Q.interpolationSpace==="srgb")return"";if(E.has(Q.interpolationSpace))return`in ${Q.interpolationSpace} ${Q.hueInterpolation} hue`;return`in ${Q.interpolationSpace}`}function g(J){let Q=N(J);if(E.has(Q.interpolationSpace))return`${Q.interpolationSpace}-${Q.hueInterpolation||"shorter"}`;return Q.interpolationSpace}function C(J){let Q=String(J??"");for(let Z of E){let $=`${Z}-`;if(Q.startsWith($))return{interpolationSpace:Z,hueInterpolation:Q.slice($.length)||"shorter"}}return{interpolationSpace:Q||"srgb",hueInterpolation:"shorter"}}var jJ=0;class D extends HTMLElement{static#K=[{value:"srgb",space:"srgb",title:"Classic",subtitle:"sRGB Linear"},{value:"oklab",space:"oklab",title:"Smooth",subtitle:"OKLab"},{value:"oklch-increasing",space:"oklch",title:"Vibrant",subtitle:"OKLCH Increasing"},{value:"hsl-increasing",space:"hsl",title:"Vivid",subtitle:"HSL Increasing"},{value:"oklch-decreasing",space:"oklch",title:"Vibrant",subtitle:"OKLCH Decreasing",advanced:!0},{value:"hsl-decreasing",space:"hsl",title:"Vivid",subtitle:"HSL Decreasing",advanced:!0}];static#Q(J){let Q=D.#K,Z=Q.find((K)=>K.value===J);if(Z)return Z;let $=C(J),X=Q.find((K)=>K.space===$.interpolationSpace),Y=X?.subtitle.split(" ")[0]??$.interpolationSpace.toUpperCase(),j=$.hueInterpolation;return{value:J,space:$.interpolationSpace,title:X?.title??"Custom",subtitle:E.has($.interpolationSpace)?`${Y} ${j.charAt(0).toUpperCase()}${j.slice(1)}`:Y}}#j=null;#W=null;#J=null;#E=`fig-fill-picker-dialog-${++jJ}`;#L="solid";anchorElement=null;#z="solid";#R="srgb";#X={h:0,s:0,v:85,a:1};#G="hex";#Y={type:"linear",angle:0,centerX:50,centerY:50,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{position:0,color:"#D9D9D9",opacity:100},{position:100,color:"#737373",opacity:100}]};#U={url:null,scaleMode:"fill",scale:50};#Z={url:null,poster:null,scaleMode:"fill",scale:50,opacity:1,missing:!0};#$={stream:null,live:!0,snapshot:null,deviceId:null,scaleMode:"fill",scale:50,opacity:1};#C=null;#D=!1;#F=null;#f={};#h={};#H=null;#B=null;#_=null;#T=null;#A=!1;#k=!1;#w=null;#v=null;#P=null;#m=null;#zJ=null;#c=0;#JJ=null;#i=null;#l=new Set;#S=new Set;#I=null;#r=null;constructor(){super();this.#JJ=this.#bJ.bind(this),this.#i=this.#gJ.bind(this)}static get observedAttributes(){return["value","disabled","alpha","mode","webcam-mode","default-video","aria-label","aria-labelledby","aria-describedby"]}connectedCallback(){this.style.display="contents",this.#N(()=>{this.#uJ(),this.#GJ(),this.#V(),this.#tJ()})}disconnectedCallback(){if(this.#kJ({stopWebcam:!0}),this.#IJ(),this.#xJ(),this.#n(this.#W))this.#W.removeAttribute("selected");if(this.#j)this.#j.removeEventListener("click",this.#JJ),this.#j.removeEventListener("keydown",this.#i);this.#j=null,this.#W=null}#u(){return this.hasAttribute("disabled")&&this.getAttribute("disabled")!=="false"}#o(){return this.getAttribute("webcam-mode")==="snapshot"?"snapshot":"live"}#p(){return this.#z==="webcam"&&this.#o()==="live"&&this.#$.live!==!1}#BJ(){return{live:this.#o()==="live"&&this.#$.live!==!1,snapshot:this.#$.snapshot??null,deviceId:this.#$.deviceId??null,scaleMode:this.#$.scaleMode||"fill",scale:this.#$.scale??50,opacity:this.#$.opacity??1}}#RJ(){let J=this.#Z.url??null;return{url:J,poster:this.#Z.poster??null,scaleMode:this.#Z.scaleMode||"fill",scale:this.#Z.scale??50,opacity:this.#Z.opacity??1,...J?{}:{missing:!0}}}#_J(J){if(J.webcam&&typeof J.webcam==="object"){let{stream:Q,snapshot:Z,...$}=J.webcam;if(Object.assign(this.#$,$),typeof Z==="string"&&Z)this.#$.snapshot=Z;return}if(J.type==="webcam"&&J.image){if(J.image.url!=null)this.#$.snapshot=J.image.url;if(J.image.scaleMode)this.#$.scaleMode=J.image.scaleMode;if(J.image.scale!=null)this.#$.scale=J.image.scale}}#UJ(){this.dispatchEvent(new CustomEvent("webcamstream",{bubbles:!0,composed:!0,detail:{stream:this.#$.stream,deviceId:this.#$.deviceId??null}}))}get webcamStream(){return this.#$.stream}releaseWebcam(){this.#t()}#EJ(J){if(!J)return null;if(this.#$.snapshot?.startsWith("blob:"))URL.revokeObjectURL(this.#$.snapshot),this.#S.delete(this.#$.snapshot);return this.#$.snapshot=URL.createObjectURL(J),this.#S.add(this.#$.snapshot),this.#$.snapshot}#AJ(J,Q,Z){if(typeof J.getImageData!=="function")return!1;let $;try{$=J.getImageData(0,0,Q,Z).data}catch{return!1}let X=Math.max(1,Math.floor(Q*Z/256)),Y=0,j=0,K=0;for(let W=0;W<$.length;W+=X*4){let z=Math.max($[W],$[W+1],$[W+2]);if(Y=Math.max(Y,z),K+=1,z>24)j+=1}if(!K)return!0;return Y<=40||j/K<0.04}async#TJ(J){let Q=[],Z=this.#$.stream?.getVideoTracks?.()?.[0];if(Z&&typeof ImageCapture==="function")try{if(this.#F?.track!==Z)this.#F=new ImageCapture(Z);Q.push(await this.#F.grabFrame())}catch{this.#F=null}if(typeof createImageBitmap==="function")try{Q.push(await createImageBitmap(J))}catch{}return Q.push(J),Q.filter(Boolean)}async#OJ(J,Q,Z,$){let X=await this.#TJ(Q);for(let Y of X){try{J.drawImage(Y,0,0,Z,$)}catch{continue}finally{Y.close?.()}if(!this.#AJ(J,Z,$))return!0}return!1}#PJ(J){return new Promise((Q)=>{if(typeof J.requestVideoFrameCallback==="function"){let Z=setTimeout(()=>Q(!1),400);J.requestVideoFrameCallback(()=>{clearTimeout(Z),Q(!0)});return}setTimeout(()=>Q(!1),200)})}async#QJ(J){if(!J?.videoWidth||!J.videoHeight)return null;let Q=document.createElement("canvas");Q.width=J.videoWidth,Q.height=J.videoHeight;let Z=Q.getContext("2d",{willReadFrequently:!0});if(!Z)return null;if(!await this.#OJ(Z,J,Q.width,Q.height))return null;let X=await new Promise((Y)=>Q.toBlob(Y,"image/png"));return this.#EJ(X)}#SJ(J){if(this.#z!=="webcam")return;let Q=this.#$.stream;if(!Q)return;if(this.#C===Q&&this.#$.snapshot){this.#V();return}if(this.#D)return;this.#D=!0;let Z=(X)=>{if(this.#D=!1,!X||this.#z!=="webcam"||this.#$.stream!==Q)return;this.#C=Q,this.#V()},$=async()=>{let X=await this.#QJ(J);if(X){Z(X);return}if(this.#z!=="webcam"||this.#$.stream!==Q){this.#D=!1;return}return await this.#PJ(J),$()};$()}#N(J){let Q=requestAnimationFrame(()=>{if(this.#l.delete(Q),this.isConnected)J()});return this.#l.add(Q),Q}#IJ(){this.#l.forEach((J)=>cancelAnimationFrame(J)),this.#l.clear()}#xJ(){let J=new Set([this.#$.snapshot,this.#Z.poster,this.#U.url].filter((Q)=>typeof Q==="string"&&Q.startsWith("blob:")));this.#S.forEach((Q)=>{if(!J.has(Q))URL.revokeObjectURL(Q)}),this.#S.clear(),J.forEach((Q)=>this.#S.add(Q))}#n(J){return J?.matches("fig-swatch, fig-chit")??!1}#wJ(J){return this.#n(J)||(J?.matches("[data-fig-fill-picker-swatch]")??!1)}#uJ(){let J=Array.from(this.children).find((Q)=>!Q.getAttribute("slot")?.startsWith("mode-"));if(!J)this.#W=document.createElement("fig-swatch"),this.#W.setAttribute("background","#D9D9D9"),this.appendChild(this.#W),this.#j=this.#W;else if(this.#wJ(J))this.#W=J,this.#j=J;else this.#j=J,this.#W=null;if(this.#q(),this.#j.removeEventListener("click",this.#JJ),this.#j.addEventListener("click",this.#JJ),this.#j.removeEventListener("keydown",this.#i),this.#j.addEventListener("keydown",this.#i),this.#n(this.#W))this.#N(()=>{let Q=this.#W.querySelector('input[type="color"]');if(Q)Q.remove();this.#q()})}#x(){return this.getAttribute("aria-label")||"Fill picker"}#q(){if(!this.#j)return;let J=this.#u(),Q=this.getAttribute("aria-labelledby");if(!this.#j.hasAttribute("role"))this.#j.setAttribute("role","button");if(this.#j.setAttribute("tabindex",J?"-1":"0"),this.#j.setAttribute("aria-disabled",J?"true":"false"),this.#j.setAttribute("aria-haspopup","dialog"),this.#j.setAttribute("aria-expanded",this.#J?.open?"true":"false"),this.#j.setAttribute("aria-controls",this.#E),this.#j.removeAttribute("aria-hidden"),Q)this.#j.setAttribute("aria-labelledby",Q),this.#j.removeAttribute("aria-label");else if(this.hasAttribute("aria-label"))this.#j.setAttribute("aria-label",`Open ${this.#x()}`),this.#j.removeAttribute("aria-labelledby");else if(this.#j.removeAttribute("aria-labelledby"),!this.#j.hasAttribute("aria-label"))this.#j.setAttribute("aria-label",`Open ${this.#x()}`);let Z=this.getAttribute("aria-describedby");if(Z)this.#j.setAttribute("aria-describedby",Z);else this.#j.removeAttribute("aria-describedby")}#bJ(J){if(this.#u())return;J.stopPropagation(),J.preventDefault(),this.#a()}#gJ(J){if(J.key!=="Enter"&&J.key!==" ")return;if(this.#u())return;J.preventDefault(),J.stopPropagation(),this.#a()}#GJ(){let J=this.getAttribute("value");if(!J)return;let Q=["solid","gradient","image","video","webcam"];try{let Z=JSON.parse(J);if(Z.type)this.#z=Z.type;if(Z.color){if(typeof Z.color==="string")this.#X=this.#WJ(Z.color);else if(typeof Z.color==="object"&&Z.color.h!==void 0)this.#X=Z.color}let $=Z.alpha!==void 0?Number(Z.alpha):Z.opacity!==void 0?Number(Z.opacity)/100:void 0;if(Number.isFinite($))this.#X.a=Math.max(0,Math.min(1,$));if(this.#R="srgb",Z.gradient)this.#Y=S({...this.#Y,...Z.gradient});if(Z.image)this.#U={...this.#U,...Z.image};if(Z.video){let X=this.#Z.url;if(this.#Z={...this.#Z,...Z.video},this.#Z.missing=!this.#Z.url,Z.video.poster!=null&&Z.video.poster!=="")this.#r=this.#Z.url;else if(this.#Z.url!==X)this.#jJ();else this.#DJ()}if(this.#_J(Z),Z.type&&!Q.includes(Z.type)){let{type:X,...Y}=Z;this.#h[Z.type]=Y}}catch(Z){if(J.startsWith("#")){this.#z="solid",this.#X=this.#WJ(J);return}if(s(J)){let $=this.#Z.url;if(this.#z="video",this.#Z.url=J.trim(),this.#Z.missing=!1,this.#Z.url!==$)this.#jJ();else this.#DJ()}}}#V(){if(!this.#W)return;let J,Q="cover",Z="center";switch(this.#z){case"solid":J=this.#s(this.#X);break;case"gradient":J=this.#aJ();break;case"image":if(this.#U.url){J=I(this.#U.url);let $=this.#LJ(this.#U.scaleMode,this.#U.scale);Q=$.size,Z=$.position}else J="";break;case"video":if(this.#Z.poster){J=I(this.#Z.poster);let $=this.#LJ(this.#Z.scaleMode,this.#Z.scale);Q=$.size,Z=$.position}else J="";break;case"webcam":if(this.#$.snapshot){J=I(this.#$.snapshot);let $=this.#LJ(this.#$.scaleMode,this.#$.scale);Q=$.size,Z=$.position}else J="";break;default:{J=(this.#f[this.#z]?.element||this.querySelector(`[slot="mode-${this.#z}"]`))?.getAttribute("swatch-background")||"";break}}if(this.#W.setAttribute("background",J),this.#W.style.setProperty("--swatch-bg-size",Q),this.#W.style.setProperty("--swatch-bg-position",Z),this.#z==="solid")this.#W.setAttribute("alpha",this.#X.a);else this.#W.removeAttribute("alpha")}#LJ(J,Q){switch(J){case"fill":return{size:"cover",position:"center"};case"fit":return{size:"contain",position:"center"};case"crop":return{size:"cover",position:"center"};case"tile":return{size:`${Q}%`,position:"top left"};default:return{size:"cover",position:"center"}}}#a(){if(this.#u())return;if(!this.#J)this.#hJ();else this.#J.anchor=this.anchorElement||this.#j;if(this.#ZJ(this.#z,{emit:!1}),this.#P=JSON.stringify(this.value),this.#m=this.#P,this.#n(this.#W))this.#W.setAttribute("selected","true");this.#J.open=!0,this.#q(),this.#N(()=>{this.#J?.querySelector(".fig-fill-picker-close, .fig-fill-picker-type, fig-button, button, input, [tabindex='0']")?.focus?.(),this.#N(()=>{this.#y(),this.#M()})})}open(){this.#a()}close(){if(this.#J)this.#J.open=!1,this.#q()}#d(){if(!this.#J)return;for(let[J,{element:Q}]of Object.entries(this.#f)){let Z=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find(($)=>$.dataset.tab===J);if(!Z)continue;while(Z.firstChild)Q.appendChild(Z.firstChild)}}#kJ({stopWebcam:J=!1}={}){if(this.#w)this.#w(),this.#w=null;if(this.#v?.disconnect(),this.#v=null,!J&&this.#p())this.#MJ();else this.#t();if(!this.#J)return;this.#d(),this.#J.remove(),this.#J=null,this.#zJ=null,this.#P=null,this.#m=null,this.#H=null,this.#B=null,this.#_=null,this.#T=null,this.#k=!1,this.#q()}#MJ(){this.#c+=1;let J=this.#J?.querySelector(".fig-fill-picker-webcam-video");if(J)J.srcObject=null}#t({emit:J=!0}={}){this.#c+=1;let Q=Boolean(this.#$.stream);if(this.#$.stream)this.#$.stream.getTracks().forEach(($)=>$.stop()),this.#$.stream=null;this.#C=null,this.#D=!1,this.#F=null;let Z=this.#J?.querySelector(".fig-fill-picker-webcam-video");if(Z)Z.srcObject=null;if(Q&&J)this.#UJ()}#hJ(){this.#f={},this.querySelectorAll('[slot^="mode-"]').forEach((O)=>{let f=O.getAttribute("slot").slice(5);this.#f[f]={element:O,label:O.getAttribute("label")||f.charAt(0).toUpperCase()+f.slice(1)}}),this.#J=document.createElement("dialog",{is:"fig-popup"}),this.#J.setAttribute("is","fig-popup"),this.#J.id=this.#E,this.#J.setAttribute("aria-label",this.#x()),this.#J.setAttribute("drag","true"),this.#J.setAttribute("handle","fig-header"),this.#J.setAttribute("autoresize","false"),this.#J.classList.add("fig-fill-picker-dialog"),this.#J.anchor=this.anchorElement||this.#j;let J=this.getAttribute("dialog-position")||"left";this.#J.setAttribute("position",J),this.#J.setAttribute("offset",this.getAttribute("dialog-offset")||"8 8");let Q=["solid","gradient","image","video","webcam"],Z={solid:"Solid",gradient:"Gradient",image:"Image",video:"Video",webcam:"Webcam"},$=this.getAttribute("mode"),X;if($){if(X=$.split(",").map((f)=>f.trim().toLowerCase()).filter((f)=>Q.includes(f)||this.#f[f]),X.length===0)X=[...Q]}else X=[...Q];let Y={...Z};for(let[O,{label:f}]of Object.entries(this.#f))Y[O]=f;if(!X.includes(this.#z))this.#z=X[0],this.#L=X[0];let j;if(X.length===1)j=G("h3",{className:"fig-fill-picker-type-label"},Y[X[0]]);else{let O=G("fig-select-options",{},X.map((f)=>G("fig-select-option",{value:f},Y[f])));j=G("fig-select",{className:"fig-fill-picker-type",label:"Fill type",variant:"ghost",value:this.#z},O)}let K=X.map((O)=>G("div",{className:"fig-fill-picker-tab","data-tab":O})),W=G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-close","aria-label":"Close fill picker"},y("close"));this.#J.replaceChildren(G("fig-header",{},[j,W]),G("fig-content",{},K)),document.body.appendChild(this.#J);for(let[O,{element:f}]of Object.entries(this.#f)){let q=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find((_)=>_.dataset.tab===O);if(!q)continue;while(f.firstChild)q.appendChild(f.firstChild);this.dispatchEvent(new CustomEvent("modeready",{bubbles:!0,detail:{mode:O,container:q}}))}let z=this.#J.querySelector(".fig-fill-picker-type");if(z)z.addEventListener("change",(O)=>{let f=typeof O.detail==="string"?O.detail:O.target?.value;if(f)this.#ZJ(f)});this.#J.querySelector(".fig-fill-picker-close").addEventListener("click",()=>{this.#J.open=!1});let L=()=>{if(this.#n(this.#W))this.#W.removeAttribute("selected");if(this.#p())this.#MJ();else this.#t();let O=JSON.stringify(this.value);if(this.#m!==null&&this.#m!==O)this.#g();this.#P=null,this.#m=null,this.#q();let f=this.#j;this.#N(()=>{if(f?.isConnected)HTMLElement.prototype.focus.call(f)}),this.dispatchEvent(new CustomEvent("close"))};this.#J.addEventListener("close",L);let U={solid:()=>this.#VJ(),gradient:()=>this.#XQ(),image:()=>this.#GQ(),video:()=>this.#VQ(),webcam:()=>this.#BQ()};for(let[O,f]of Object.entries(U))if(!this.#f[O]&&X.includes(O))f();for(let O of Object.keys(this.#f)){if(Q.includes(O))continue;let f=Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).find((q)=>q.dataset.tab===O);if(!f)continue;f.addEventListener("input",(q)=>{if(q.target===this)return;if(q.stopPropagation(),q.detail)this.#h[O]=q.detail;this.#O()}),f.addEventListener("change",(q)=>{if(q.target===this)return;if(q.stopPropagation(),q.detail)this.#h[O]=q.detail;this.#g()})}}#ZJ(J,{emit:Q=!0}={}){let Z=Array.from(this.#J?.querySelectorAll(".fig-fill-picker-tab")??[]).find((K)=>K.dataset.tab===J);if(!Z)return;let $=this.#L;if(this.#L=J,this.#z=J,$==="webcam"&&J!=="webcam")this.#t();let X=this.#J.querySelector(".fig-fill-picker-type");if(X&&X.value!==J)X.value=J;this.#J.querySelectorAll(".fig-fill-picker-tab").forEach((K)=>{if(K.dataset.tab===J)K.style.display="block";else K.style.display="none"});let j=this.#J.querySelector("fig-content");if(j)j.style.padding=this.#f[J]?"0":"";if(J==="gradient")this.#N(()=>{this.#b();let K=Z.querySelector(".fig-fill-picker-gradient-bar-input");K?.refreshLayout?.(),this.#N(()=>{K?.refreshLayout?.()})});if(J==="video")this.#FJ({emit:!1});if(J==="webcam")this.#$.live=this.#o()==="live",this.#zJ?.(this.#$.deviceId);if(this.#V(),Q)this.#O()}#NJ(){if(!this.#J?.open)return;if(this.#ZJ(this.#z,{emit:!1}),this.#y(),this.#M(),this.#XJ(),this.#_)this.#_.setAttribute("value",this.#X.h);if(this.#T)this.#T.setAttribute("value",this.#X.a*100),this.#T.setAttribute("color",this.#s(this.#X));this.#b();let J=this.#J.querySelector('[data-tab="image"]'),Q=J?.querySelector(".fig-fill-picker-scale-mode"),Z=J?.querySelector(".fig-fill-picker-scale"),$=J?.querySelector(".fig-fill-picker-image-preview");if(Q)Q.value=this.#U.scaleMode;if(Z)Z.setAttribute("value",this.#U.scale),Z.style.display=this.#U.scaleMode==="tile"?"block":"none";if($)this.#e($);let X=this.#J.querySelector('[data-tab="video"]'),Y=X?.querySelector(".fig-fill-picker-scale-mode"),j=X?.querySelector(".fig-fill-picker-video-preview");if(Y)Y.value=this.#Z.scaleMode;if(j)this.#YJ(j)}#VJ(){let J=this.#J.querySelector('[data-tab="solid"]'),Q=this.getAttribute("alpha")!=="false",Z=G("canvas",{width:"200",height:"200"}),$=G("fig-handle",{"aria-label":"Color saturation and brightness",role:"slider","aria-valuemin":"0","aria-valuemax":"100",type:"color",color:this.#s({...this.#X,a:1}),"data-no-color-picker":!0,drag:!0,"drag-surface":".fig-fill-picker-color-area","drag-axes":"x,y","drag-snapping":"modifier"}),X=G("fig-preview",{className:"fig-fill-picker-color-area"},[Z,$]),Y=G("fig-tooltip",{text:"Sample color"},G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-eyedropper","aria-label":"Sample color"},y("eyedropper"))),j=G("div",{className:`fig-fill-picker-sliders${Q?"":" is-hue-only"}`},[Y,G("fig-slider",{type:"hue",variant:"classic",text:"false",min:"0",max:"360","aria-label":"Hue",value:this.#X.h}),Q?G("fig-slider",{type:"opacity",variant:"classic",text:"false",min:"0",max:"100","aria-label":"Opacity",value:this.#X.a*100,color:this.#s(this.#X)}):null]),K=G("fig-select-options",{},[["hex","Hex"],["rgb","RGB"],["css","CSS"],["hsl","HSL"],["hsb","HSB"],["lab","LAB"],["lch","LCH"]].map(([U,O])=>G("fig-select-option",{value:U},O))),W=G("fig-field",{className:"fig-fill-picker-inputs"},[G("fig-select",{className:"fig-fill-picker-input-mode",label:"Color value format",value:this.#G},K),G("span",{className:"fig-fill-picker-input-fields"})]);if(J.replaceChildren(X,j,W),this.#H=J.querySelector("canvas"),this.#B=J.querySelector("fig-handle"),this.#$J(),this.#y(),this.#M(),this.#iJ(),this.#_=J.querySelector('fig-slider[type="hue"]'),this.#_.addEventListener("input",(U)=>{this.#X.h=parseFloat(U.target.value),this.#y(),this.#M(),this.#XJ(),this.#O()}),this.#_.addEventListener("change",()=>{this.#g()}),Q)this.#T=J.querySelector('fig-slider[type="opacity"]'),this.#T.addEventListener("input",(U)=>{this.#X.a=parseFloat(U.target.value)/100,this.#XJ(),this.#O()}),this.#T.addEventListener("change",()=>{this.#g()});J.querySelector(".fig-fill-picker-input-mode").addEventListener("change",(U)=>{let O=typeof U.detail==="string"?U.detail:U.target?.value;if(!O)return;this.#G=O,this.#lJ()}),this.#lJ();let L=J.querySelector(".fig-fill-picker-eyedropper");if("EyeDropper"in window)L.addEventListener("click",async()=>{try{let O=await new EyeDropper().open();this.#X={...this.#WJ(O.sRGBHex),a:this.#X.a},this.#y(),this.#M(),this.#XJ(),this.#O()}catch(U){}});else L.setAttribute("disabled",""),L.title="EyeDropper not supported in this browser"}#yJ(){let J=this.#J?.querySelector('[data-tab="solid"]');if(J){let Q=J.querySelector("canvas");if(Q){let Z=document.createElement("canvas");Z.width=Q.width,Z.height=Q.height,Q.replaceWith(Z),this.#H=Z,this.#iJ()}this.#y(),this.#M()}this.#HJ(),this.#O()}#y(){if(!this.#H&&this.#J)this.#H=this.#J.querySelector('[data-tab="solid"] canvas');if(!this.#H)return;let J=this.#R==="display-p3"?"display-p3":"srgb",Q=this.#H.getContext("2d",{colorSpace:J});if(!Q)return;let Z=this.#H.width,$=this.#H.height;Q.clearRect(0,0,Z,$);let X=this.#X.h,Y=this.#R==="display-p3",j=Q.createLinearGradient(0,0,Z,0);if(Y){j.addColorStop(0,"color(display-p3 1 1 1)");let[W,z,L]=hslToP3(X,100,50);j.addColorStop(1,`color(display-p3 ${W} ${z} ${L})`)}else j.addColorStop(0,"#FFFFFF"),j.addColorStop(1,`hsl(${X}, 100%, 50%)`);Q.fillStyle=j,Q.fillRect(0,0,Z,$);let K=Q.createLinearGradient(0,0,0,$);K.addColorStop(0,"rgba(0,0,0,0)"),K.addColorStop(1,"rgba(0,0,0,1)"),Q.fillStyle=K,Q.fillRect(0,0,Z,$)}#M(J=0){if(!this.#B||!this.#H)return;this.#$J();let Q=this.#H.getBoundingClientRect();if((Q.width===0||Q.height===0)&&J<5){this.#N(()=>this.#M(J+1));return}let Z=Math.max(0,Math.min(100,this.#X.s)),$=Math.max(0,Math.min(100,100-this.#X.v));this.#B.setAttribute("value",`${Z}% ${$}%`),this.#B.setAttribute("color",this.#s({...this.#X,a:1}))}#$J(){if(!this.#B)return;this.#B.setAttribute("aria-valuenow",String(Math.round(this.#X.v))),this.#B.setAttribute("aria-valuetext",`Saturation ${Math.round(this.#X.s)}%, brightness ${Math.round(this.#X.v)}%`),this.#B.removeAttribute("aria-pressed")}#fJ(J,Q,Z={}){let{updateHandle:$=!0,emitInput:X=!0,emitChange:Y=!1}=Z;if(this.#X.s=Math.max(0,Math.min(100,J*100)),this.#X.v=Math.max(0,Math.min(100,(1-Q)*100)),this.#B)this.#B.setAttribute("color",this.#s({...this.#X,a:1})),this.#$J();if($)this.#M();if(this.#XJ(),X)this.#O();if(Y)this.#g()}#iJ(){if(this.#w)this.#w(),this.#w=null;if(!this.#H||!this.#B)return;let J=this.#H.parentElement||this.#H,Q=this.#B,Z=!1,$=(z,L={})=>{let U=J.getBoundingClientRect();if(U.width===0||U.height===0)return;let O=Math.max(0,Math.min(z.clientX-U.left,U.width)),f=Math.max(0,Math.min(z.clientY-U.top,U.height));this.#fJ(O/U.width,f/U.height,L)},X=(z)=>{if(z.button!==0)return;if(z.target===Q||Q.contains(z.target))return;Z=!0,this.#A=!0,J.setPointerCapture(z.pointerId),$(z,{updateHandle:!0,emitInput:!0})},Y=(z)=>{if(!Z)return;if(z.buttons===0){j();return}$(z,{updateHandle:!0,emitInput:!0})},j=()=>{if(!Z)return;Z=!1,this.#A=!1,this.#g()},K=(z)=>{this.#A=!0;let L=z.detail?.px,U=z.detail?.py;if(!Number.isFinite(L)||!Number.isFinite(U))return;Q.setAttribute("value",`${L*100}% ${U*100}%`),this.#fJ(L,U,{updateHandle:!1,emitInput:!0})},W=(z)=>{let L=z.detail?.px,U=z.detail?.py;if(Number.isFinite(L)&&Number.isFinite(U))Q.setAttribute("value",`${L*100}% ${U*100}%`),this.#fJ(L,U,{updateHandle:!1,emitInput:!1});this.#A=!1,this.#g()};J.addEventListener("pointerdown",X),J.addEventListener("pointermove",Y),J.addEventListener("pointerup",j),J.addEventListener("pointercancel",j),J.addEventListener("lostpointercapture",j),Q.addEventListener("input",K),Q.addEventListener("change",W),this.#w=()=>{J.removeEventListener("pointerdown",X),J.removeEventListener("pointermove",Y),J.removeEventListener("pointerup",j),J.removeEventListener("pointercancel",j),J.removeEventListener("lostpointercapture",j),Q.removeEventListener("input",K),Q.removeEventListener("change",W),this.#A=!1}}#lJ(){let J=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!J)return;let Q=(K,W)=>G("fig-tooltip",{text:K},W),Z=(K,W,z,L,U,O)=>G("fig-input-number",{className:K,"aria-label":W,min:z,max:L,step:U,units:O}),$=this.getAttribute("alpha")!=="false",X=()=>$?Q("Alpha",Z("fig-fill-picker-ci-a","Alpha",0,100,0.1,"%")):null,Y=(K,W="")=>G("div",{className:["input-combo",W].filter(Boolean).join(" ")},K),j;switch(this.#G){case"rgb":j=Y([Q("Red",Z("fig-fill-picker-ci-r","Red",0,255)),Q("Green",Z("fig-fill-picker-ci-g","Green",0,255)),Q("Blue",Z("fig-fill-picker-ci-b","Blue",0,255)),X()]);break;case"hsl":j=Y([Q("Hue",Z("fig-fill-picker-ci-h","Hue",0,360)),Q("Saturation",Z("fig-fill-picker-ci-s","Saturation",0,100)),Q("Lightness",Z("fig-fill-picker-ci-l","Lightness",0,100)),X()]);break;case"hsb":j=Y([Q("Hue",Z("fig-fill-picker-ci-h","Hue",0,360)),Q("Saturation",Z("fig-fill-picker-ci-s","Saturation",0,100)),Q("Brightness",Z("fig-fill-picker-ci-v","Brightness",0,100)),X()]);break;case"lab":j=Y([Q("Lightness",Z("fig-fill-picker-ci-okl","Lightness",0,100)),Q("Green-Red axis",Z("fig-fill-picker-ci-oka","Green-Red axis",-0.4,0.4,0.001)),Q("Blue-Yellow axis",Z("fig-fill-picker-ci-okb","Blue-Yellow axis",-0.4,0.4,0.001)),X()]);break;case"lch":j=Y([Q("Lightness",Z("fig-fill-picker-ci-okl","Lightness",0,100)),Q("Chroma",Z("fig-fill-picker-ci-okc","Chroma",0,0.4,0.001)),Q("Hue",Z("fig-fill-picker-ci-okh","Hue",0,360)),X()]);break;case"css":j=G("fig-input-text",{className:"fig-fill-picker-ci-css","aria-label":"CSS color",placeholder:"rgba(0, 0, 0, 1)"});break;default:{let K=G("fig-input-text",{className:"fig-fill-picker-ci-hex","aria-label":"Hex color",placeholder:"FFFFFF"});j=$?Y([K,X()],"fig-fill-picker-ci-hex-row"):K}break}J.replaceChildren(j),this.#QQ(),this.#N(()=>this.#XJ())}#QQ(){let J=this.#J?.querySelector(".fig-fill-picker-input-fields");if(!J)return;let Q=()=>{if(this.#A)return;let X=this.#$Q();if(!X)return;let Y=Number.isFinite(X.a)?X.a:this.#X.a;if(this.#X={...X,a:Y},this.#y(),this.#M(),this.#_)this.#_.setAttribute("value",this.#X.h);if(this.#T&&Number.isFinite(X.a))this.#T.setAttribute("value",this.#X.a*100);this.#O()},Z=()=>this.#g();J.querySelectorAll("fig-input-number, fig-input-text").forEach((X)=>{X.addEventListener("input",Q),X.addEventListener("change",Z)})}#ZQ(){let J=this.#J?.querySelector(".fig-fill-picker-ci-a");if(!J)return;let Q=parseFloat(J.value);if(!Number.isFinite(Q))return;return Math.max(0,Math.min(1,Q/100))}#$Q(){let J=($)=>this.#J?.querySelector(`.${$}`),Q=($)=>parseFloat(J($)?.value??0),Z=($)=>{if(!$)return null;let X=this.#ZQ();return{...$,a:X??$.a??this.#X.a}};switch(this.#G){case"rgb":return Z(this.#KJ({r:Q("fig-fill-picker-ci-r"),g:Q("fig-fill-picker-ci-g"),b:Q("fig-fill-picker-ci-b")}));case"hsl":{let $=this.#DQ({h:Q("fig-fill-picker-ci-h"),s:Q("fig-fill-picker-ci-s"),l:Q("fig-fill-picker-ci-l")});return Z(this.#KJ($))}case"hsb":return Z({h:Q("fig-fill-picker-ci-h"),s:Q("fig-fill-picker-ci-s"),v:Q("fig-fill-picker-ci-v")});case"lab":{let $=this.#JQ({l:Q("fig-fill-picker-ci-okl")/100,a:Q("fig-fill-picker-ci-oka"),b:Q("fig-fill-picker-ci-okb")});return Z(this.#KJ($))}case"lch":{let $=this.#CQ({l:Q("fig-fill-picker-ci-okl")/100,c:Q("fig-fill-picker-ci-okc"),h:Q("fig-fill-picker-ci-okh")});return Z(this.#KJ($))}case"css":{let $=J("fig-fill-picker-ci-css");if(!$)return null;return this.#MQ($.value)}default:{let $=J("fig-fill-picker-ci-hex");if(!$)return null;let X=$.value.replace(/^#/,"");if(X.length===3)X=X[0]+X[0]+X[1]+X[1]+X[2]+X[2];if(X.length===8){let Y=parseInt(X.slice(6,8),16)/255;if(X=X.slice(0,6),!/^[0-9a-fA-F]{6}$/.test(X))return null;return{...this.#WJ(`#${X}`),a:Y}}if(X.length!==6||!/^[0-9a-fA-F]{6}$/.test(X))return null;return Z(this.#WJ(`#${X}`))}}}#XJ(){if(!this.#J)return;let J=this.#s(this.#X),Q=this.#sJ(this.#X),Z=(X)=>this.#J.querySelector(`.${X}`),$=(X,Y)=>{let j=Z(X);if(j)j.setAttribute("value",Y)};switch(this.#G){case"rgb":$("fig-fill-picker-ci-r",Q.r),$("fig-fill-picker-ci-g",Q.g),$("fig-fill-picker-ci-b",Q.b);break;case"hsl":{let X=this.#yQ(Q);$("fig-fill-picker-ci-h",Math.round(X.h)),$("fig-fill-picker-ci-s",Math.round(X.s)),$("fig-fill-picker-ci-l",Math.round(X.l));break}case"hsb":$("fig-fill-picker-ci-h",Math.round(this.#X.h)),$("fig-fill-picker-ci-s",Math.round(this.#X.s)),$("fig-fill-picker-ci-v",Math.round(this.#X.v));break;case"lab":{let X=this.#eJ(Q);$("fig-fill-picker-ci-okl",Math.round(X.l*100)),$("fig-fill-picker-ci-oka",+X.a.toFixed(3)),$("fig-fill-picker-ci-okb",+X.b.toFixed(3));break}case"lch":{let X=this.#FQ(Q);$("fig-fill-picker-ci-okl",Math.round(X.l*100)),$("fig-fill-picker-ci-okc",+X.c.toFixed(3)),$("fig-fill-picker-ci-okh",Math.round(X.h));break}case"css":$("fig-fill-picker-ci-css",this.#kQ(this.#X));break;default:$("fig-fill-picker-ci-hex",J.replace(/^#/,"").toUpperCase());break}if(this.#G!=="css"){let X=Math.round(this.#X.a*1000)/10;$("fig-fill-picker-ci-a",Number.isInteger(X)?X:+X.toFixed(1))}if(this.#T)this.#T.setAttribute("color",J);this.#V()}#XQ(){let J=this.#J.querySelector('[data-tab="gradient"]'),Q=G("fig-select",{className:"fig-fill-picker-gradient-type",label:"Gradient type",value:this.#Y.type,variant:"ghost"},G("fig-select-options",{},[["linear","Linear"],["radial","Radial"],["angular","Angular"]].map(([z,L])=>G("fig-select-option",{value:z},L)))),Z=(z,L,U)=>G("fig-tooltip",{text:z},G("fig-button",{icon:!0,variant:"ghost",className:L,"aria-label":z},y(U))),$=G("div",{className:"fig-fill-picker-gradient-actions"},[Z("Flip gradient","fig-fill-picker-gradient-flip","swap"),Z("Rotate gradient","fig-fill-picker-gradient-rotate","rotate")]),X=G("fig-field",{className:"fig-fill-picker-gradient-header"},[Q,$]),Y=G("fig-input-gradient",{className:"fig-fill-picker-gradient-bar-input","aria-label":"Gradient stops",edit:"true",mode:"tip",size:"large",value:JSON.stringify({type:"gradient",gradient:P(this.#Y)})}),j=G("fig-preview",{className:"fig-fill-picker-gradient-preview"},Y),K=G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-gradient-add","aria-label":"Add gradient stop",title:"Add stop"},y("add")),W=G("div",{className:"fig-fill-picker-gradient-stops"},[G("fig-header",{className:"fig-fill-picker-gradient-stops-header",borderless:!0},[G("h3",{},"Stops"),K]),G("div",{className:"fig-fill-picker-gradient-stops-list"},document.createElement("fig-reorder"))]);J.replaceChildren(X,j,W),this.#b(),this.#YQ(J)}#EQ(){let J=({value:$,title:X,subtitle:Y,advanced:j=!1})=>G("fig-select-option",{value:$,label:`${X} — ${Y}`,className:j?"fig-fill-picker-gradient-interpolation-advanced":null},[G("fig-interpolation-swatch",{slot:"prepend",size:"large","aria-hidden":"true"}),G("span",{className:"fig-fill-picker-gradient-interpolation-label"},[G("span",{className:"fig-fill-picker-gradient-interpolation-title"},X),G("span",{className:"fig-fill-picker-gradient-interpolation-subtitle"},Y)])]),Q=G("fig-separator",{className:"fig-fill-picker-gradient-interpolation-advanced"}),Z=D.#K;return[...Z.filter(($)=>!$.advanced).map(J),Q,...Z.filter(($)=>$.advanced).map(J)]}#YQ(J){let Q=(V)=>typeof V.detail==="string"?V.detail:V.target?.value,Z=J.querySelector(".fig-fill-picker-gradient-bar-input"),$=(V)=>{if(!Z)return;this.#k=!0;try{Z.setAttribute("value",JSON.stringify({type:"gradient",gradient:P(V)}))}finally{this.#k=!1}},X=()=>{$(this.#Y)};J.querySelector(".fig-fill-picker-gradient-type")?.addEventListener("change",(V)=>{let H=Q(V);if(!H)return;this.#Y.type=H,this.#b(),this.#O()});let j=J.querySelector(".fig-fill-picker-gradient-space"),K=j?.querySelector("fig-select-options"),W="fig-fill-picker-gradient-interpolation-collapsed",z=K?.querySelector(".fig-fill-picker-gradient-interpolation-advanced"),L=()=>Boolean(K?.classList.contains(W)),U=(V)=>{K?.querySelector(".fig-overflow-end")?.setAttribute("aria-label",V?"Show all color interpolation options":"Scroll down")},O=()=>{if(!K)return;K.classList.remove(W),K.style.removeProperty("max-height"),U(!1),K.syncOverflow?.()},f=()=>{if(!K||!z)return;K.style.removeProperty("max-height"),K.classList.add(W),K.scrollTop=0;let V=K.getBoundingClientRect().top,H=z.getBoundingClientRect().top,M=K.querySelector(".fig-overflow-end")?.offsetHeight||0,F=H-V;if(F>0)K.style.maxHeight=`${Math.round(F+M)}px`;U(!0),K.syncOverflow?.()},q=(V)=>Boolean(K?.querySelector(`fig-select-option.fig-fill-picker-gradient-interpolation-advanced[value="${V}"]`)),_=()=>{if(q(g(this.#Y)))O();else f()};if(K?.addEventListener("click",(V)=>{if(!L())return;if(!V.target?.closest?.(".fig-overflow-end"))return;V.preventDefault(),V.stopPropagation(),O()},!0),K?.addEventListener("focusin",(V)=>{if(!L())return;if(V.target?.closest?.(".fig-fill-picker-gradient-interpolation-advanced"))O()}),K?.addEventListener("scroll",()=>{if(L()&&K.scrollTop!==0)K.scrollTop=0}),j?.querySelectorAll("fig-select-option").forEach((V)=>{let H=()=>{let M=C(V.getAttribute("value")||"srgb");$(N({...this.#Y,...M}))};V.addEventListener("pointerenter",H),V.addEventListener("pointerleave",()=>{if(document.activeElement!==V)X()}),V.addEventListener("focus",H),V.addEventListener("blur",()=>{if(!V.matches(":hover"))X()})}),this.#v?.disconnect(),j)this.#v=new MutationObserver(()=>{if(!j.hasAttribute("open"))X();else this.#N(_)}),this.#v.observe(j,{attributes:!0,attributeFilter:["open"]});let R=J.querySelector(".fig-fill-picker-gradient-interpolation-modes");if(R?.addEventListener("change",(V)=>{let H=typeof V.detail==="string"?V.detail:V.target?.value;if(!H)return;let M=C(H);this.#Y=N({...this.#Y,...M}),this.#b(),this.#O()}),R?.querySelectorAll("fig-segment").forEach((V)=>{let H=()=>{$(N({...this.#Y,...C(V.getAttribute("value")||"srgb")}))};V.addEventListener("pointerenter",H),V.addEventListener("pointerleave",X)}),j?.addEventListener("change",(V)=>{let H=Q(V);if(!H)return;let M=C(H);this.#Y=N({...this.#Y,...M}),this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-rotate")?.addEventListener("click",()=>{this.#Y.angle=(Number(this.#Y.angle)+90)%360,this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-flip").addEventListener("click",()=>{this.#Y.stops.forEach((V)=>{V.position=100-V.position}),this.#Y.stops.sort((V,H)=>V.position-H.position),this.#b(),this.#O()}),J.querySelector(".fig-fill-picker-gradient-add").addEventListener("click",()=>{this.#Y.stops.push({position:50,color:"#888888",opacity:100}),this.#Y.stops.sort((H,M)=>H.position-M.position),this.#b(),this.#O()}),Z){let V=(H)=>{if(H.stopPropagation(),this.#k)return;let M=H.detail;if(!M?.gradient)return;this.#Y=S({...this.#Y,...M.gradient}),this.#V(),this.#qJ(),this.#rJ()};Z.addEventListener("input",(H)=>{V(H),this.#O()}),Z.addEventListener("change",(H)=>{V(H),this.#g()})}J.querySelector(".fig-fill-picker-gradient-stops-list > fig-reorder")?.addEventListener("reorder",(V)=>{this.#zQ(V)})}#vJ(J){let Q=String(J.color||"#888888").replace(/^#/,"").slice(0,6),Z=J.opacity??100;if(Z>=100)return`#${Q}`;let $=Math.round(Z/100*255).toString(16).padStart(2,"0");return`#${Q}${$}`}#jQ(J){if(!(J instanceof HTMLElement))return"#888888";if(J.hexOpaque)return this.#mJ(J.hexOpaque);let Q=J.value;if(typeof Q==="string"&&Q.startsWith("#"))return this.#mJ(Q.length>7?Q.slice(0,7):Q);let Z=J.querySelector('fig-input-text:not([type="number"])'),$=String(Z?.value??Z?.getAttribute("value")??"").replace(/#/g,"").slice(0,6);if(/^[0-9A-Fa-f]{6}$/.test($))return`#${$.toUpperCase()}`;let X=J.getAttribute("value");if(typeof X==="string"&&X.startsWith("#"))return this.#mJ(X.length>7?X.slice(0,7):X);return"#888888"}#mJ(J){let Q=String(J||"#888888").replace(/^#/,"").slice(0,6);if(!/^[0-9A-Fa-f]{6}$/.test(Q))return"#888888";return`#${Q.toUpperCase()}`}#KQ(J){let Q=J.querySelector(".fig-fill-picker-stop-position"),Z=J.querySelector(".fig-fill-picker-stop-color"),$=parseFloat(Q?.value??Q?.getAttribute("value")??"0")||0,X=this.#jQ(Z),Y=100;if(Z instanceof HTMLElement&&Z.rgba?.a!==void 0)Y=Math.round(Z.rgba.a*100);else{let j=parseInt(J.dataset.index,10);if(!isNaN(j)&&this.#Y.stops[j])Y=this.#Y.stops[j].opacity??100}return{position:$,color:X,opacity:Y}}#cJ(J){let Q=parseInt(J.dataset.index,10);if(isNaN(Q)||Q<0||Q>=this.#Y.stops.length)return;let Z={...this.#Y.stops[Q],...this.#KQ(J)};this.#Y.stops[Q]=Z,this.#WQ(J,Z)}#WQ(J,Q){let Z=J.querySelector(".fig-fill-picker-stop-position");if(Z)Z.setAttribute("value",String(Q.position));let $=J.querySelector(".fig-fill-picker-stop-color");if($)$.setAttribute("value",this.#vJ(Q))}#zQ(J){let{oldIndex:Q,newIndex:Z}=J.detail??{};if(Q==null||Z==null||Q===Z||Q<0||Z<0||Q>=this.#Y.stops.length||Z>=this.#Y.stops.length)return;let X=J.currentTarget.querySelectorAll(".fig-fill-picker-gradient-stop-row");X.forEach((j)=>this.#cJ(j));let[Y]=this.#Y.stops.splice(Q,1);this.#Y.stops.splice(Z,0,Y),X.forEach((j,K)=>{j.dataset.index=String(K)}),this.#k=!0;try{this.#qJ(),this.#HJ(),this.#O()}finally{this.#k=!1}}#b(){if(!this.#J)return;let J=this.#J.querySelector('[data-tab="gradient"]');if(!J)return;this.#Y=S(this.#Y);let Q=g(this.#Y),Z=J.querySelector(".fig-fill-picker-gradient-space");if(Z)Z.value=Q;let $=J.querySelector(".fig-fill-picker-gradient-interpolation-modes");if($){let X=D.#Q(Q),Y=$.querySelector(`fig-segment[value="${Q}"]`)||$.querySelector(`fig-segment[data-space="${X.space}"]`);if(Y){let j=`${X.title} — ${X.subtitle}`;Y.setAttribute("value",Q),Y.setAttribute("aria-label",j);let K=Y.closest("fig-tooltip");if(K)K.setAttribute("text",j);$.value=Q}}this.#qJ(),this.#HJ(),this.#rJ()}#UQ(){let J=Array.isArray(this.#Y.stops)?[...this.#Y.stops].sort((Q,Z)=>(Q.position??0)-(Z.position??0)):[];if(J.length<2)return[{color:"#FF0000",position:0},{color:"#4F9EFF",position:100}];return J.map((Q)=>({color:String(Q.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:Q.position??0}))}#qJ(){if(!this.#J)return;let J=this.#UQ();this.#J.querySelectorAll("fig-interpolation-swatch").forEach((Q)=>{let Z=Q.closest("fig-select-option, fig-segment")?.getAttribute("value")||"srgb",$=C(Z),X={type:"linear",stops:J,interpolationSpace:$.interpolationSpace};if(E.has($.interpolationSpace))X.hueInterpolation=$.hueInterpolation;Q.value={type:"gradient",gradient:X}})}#HJ(){if(!this.#J)return;let J=this.#J.querySelector(".fig-fill-picker-gradient-bar-input");if(J)this.#k=!0,J.setAttribute("value",JSON.stringify({type:"gradient",gradient:P(this.#Y)})),this.#k=!1;this.#V()}#rJ(){if(!this.#J)return;let J=this.#J.querySelector(".fig-fill-picker-gradient-stops-list"),Q=J?.querySelector("fig-reorder");if(!J||!Q)return;let Z=Q.querySelectorAll(".fig-fill-picker-gradient-stop-row");if(Z.length===this.#Y.stops.length){this.#Y.stops.forEach(($,X)=>{let Y=Z[X];Y.dataset.index=X;let j=Y.querySelector(".fig-fill-picker-stop-position");if(j)j.setAttribute("value",$.position);let K=Y.querySelector(".fig-fill-picker-stop-color");if(K)K.setAttribute("value",this.#vJ($));let W=Y.querySelector(".fig-fill-picker-stop-remove");if(W)if(this.#Y.stops.length<=2)W.setAttribute("disabled","");else W.removeAttribute("disabled")});return}this.#OQ(J)}#OQ(J){let Q=J.querySelector("fig-reorder");if(!Q)return;let Z=this.#Y.stops.map(($,X)=>G("fig-field",{className:"fig-fill-picker-gradient-stop-row","data-index":X},[G("fig-input-number",{className:"fig-fill-picker-stop-position","aria-label":"Gradient stop position",min:"0",max:"100",value:$.position,units:"%"}),G("fig-input-color",{className:"fig-fill-picker-stop-color","aria-label":"Gradient stop color",text:"true",alpha:"true",picker:"figma","picker-dialog-position":"right",value:this.#vJ($)}),G("fig-button",{icon:!0,variant:"ghost",className:"fig-fill-picker-stop-remove",disabled:this.#Y.stops.length<=2,"aria-label":"Remove gradient stop"},y("minus"))]));Q.replaceChildren(...Z),Q.querySelectorAll(".fig-fill-picker-gradient-stop-row").forEach(($)=>{$.querySelector(".fig-fill-picker-stop-position").addEventListener("input",()=>{this.#cJ($),this.#qJ(),this.#HJ(),this.#O()});let X=$.querySelector(".fig-fill-picker-stop-color"),Y=X.querySelector("fig-fill-picker");if(Y)Y.anchorElement=this.#J;else this.#N(()=>{let K=X.querySelector("fig-fill-picker");if(K)K.anchorElement=this.#J});let j=()=>{this.#cJ($),this.#k=!0;try{this.#qJ(),this.#HJ(),this.#O()}finally{this.#k=!1}};X.addEventListener("input",j),X.addEventListener("change",j),$.querySelector(".fig-fill-picker-stop-remove").addEventListener("click",()=>{let K=parseInt($.dataset.index,10);if(this.#Y.stops.length>2)this.#Y.stops.splice(K,1),this.#b(),this.#O()})})}#pJ(J,Q=!0){let Z=N({...this.#Y,interpolationSpace:J??this.#Y.interpolationSpace}),$=this.#R==="display-p3",X=Z.stops.map((K)=>{let W=(K.opacity??100)/100;return`${$?this.#NQ(K.color,W):this.#_Q(K.color,W)} ${K.position}%`}).join(", "),Y=YJ(Z),j=Q&&Y?` ${Y}`:"";switch(Z.type){case"linear":return`linear-gradient(${Z.angle}deg${j}, ${X})`;case"radial":return`radial-gradient(circle at ${Z.centerX}% ${Z.centerY}%${j}, ${X})`;case"angular":return`conic-gradient(from ${Z.angle}deg${j}, ${X})`;default:return`linear-gradient(${Z.angle}deg${j}, ${X})`}}static#oJ=new Map;#nJ(J){let Q=D.#oJ.get(J);if(Q!==void 0)return Q;let Z=document.createElement("div");Z.style.background=J;let $=!!Z.style.background;return D.#oJ.set(J,$),$}#aJ(){let J=this.#pJ(void 0,!0);if(this.#nJ(J))return J;let Q=this.#pJ("oklab",!0);if(this.#nJ(Q))return Q;return this.#pJ("oklab",!1)}#GQ(){let J=this.#J.querySelector('[data-tab="image"]'),Q=G("fig-select",{className:"fig-fill-picker-scale-mode",label:"Image scale mode",value:this.#U.scaleMode},G("fig-select-options",{},[["fill","Fill"],["fit","Fit"],["crop","Crop"],["tile","Tile"]].map(([Y,j])=>G("fig-select-option",{value:Y},j)))),Z=G("fig-input-number",{className:"fig-fill-picker-scale","aria-label":"Image tile scale",min:"1",max:"200",value:this.#U.scale,units:"%"});if(this.#U.scaleMode!=="tile")Z.style.display="none";let $=G("fig-field",{className:"fig-fill-picker-media-header"},[Q,Z]),X=G("fig-image",{className:"fig-fill-picker-media-preview fig-fill-picker-image-preview",upload:"true",label:"Upload from computer",alt:"Image fill preview",size:"auto","aspect-ratio":"1/1",fit:"cover",checkerboard:"true"});J.replaceChildren($,X),this.#LQ(J)}#LQ(J){let Q=J.querySelector(".fig-fill-picker-scale-mode"),Z=J.querySelector(".fig-fill-picker-scale"),$=J.querySelector(".fig-fill-picker-image-preview");Q.addEventListener("change",(X)=>{let Y=typeof X.detail==="string"?X.detail:X.target?.value;if(!Y)return;this.#U.scaleMode=Y,Z.style.display=Y==="tile"?"block":"none",this.#e($),this.#V(),this.#O()}),Z.addEventListener("input",(X)=>{this.#U.scale=parseFloat(X.target.value)||100,this.#e($),this.#V(),this.#O()}),$.addEventListener("loaded",(X)=>{let Y=X.detail?.src||$.src;if(!Y)return;let j=Y!==this.#U.url;if(this.#U.url=Y,this.#e($),this.#V(),j)this.#O();this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:X.detail??{src:Y}}))}),$.addEventListener("change",()=>{if($.src)return;this.#U.url=null,this.#e($),this.#V(),this.#O()}),this.#e($)}#e(J){if(!this.#U.url){J.removeAttribute("src"),J.classList.remove("has-media","is-tiled"),J.style.backgroundImage="",J.style.backgroundPosition="",J.style.backgroundRepeat="",J.style.backgroundSize="";return}J.setAttribute("src",this.#U.url),J.classList.add("has-media"),J.style.backgroundImage="",J.style.backgroundPosition="",J.style.backgroundRepeat="",J.style.backgroundSize="",J.mediaEl?.style.removeProperty("opacity");let Q=J.querySelector("fig-input-file[data-generated]");if(Q)Q.setAttribute("label","Replace"),Q.removeAttribute("url");switch(this.#U.scaleMode){case"fill":J.classList.remove("is-tiled"),J.setAttribute("fit","cover");break;case"crop":J.classList.remove("is-tiled"),J.setAttribute("fit","cover");break;case"fit":J.classList.remove("is-tiled"),J.setAttribute("fit","contain");break;case"tile":if(J.classList.add("is-tiled"),J.setAttribute("fit","none"),J.style.backgroundImage=`url(${this.#U.url})`,J.style.backgroundPosition="top left",J.style.backgroundSize=`${this.#U.scale}%`,J.style.backgroundRepeat="repeat",J.mediaEl)J.mediaEl.style.opacity="0";break}}#YJ(J){if(J.tagName==="FIG-MEDIA"){if(!this.#Z.url){J.removeAttribute("src"),J.classList.remove("has-media");return}if(J.setAttribute("src",this.#Z.url),this.#Z.poster)J.setAttribute("poster",this.#Z.poster);else J.removeAttribute("poster");J.classList.add("has-media");let Q=J.querySelector("fig-input-file[data-generated]");if(Q)Q.setAttribute("label","Replace"),Q.removeAttribute("url");switch(this.#Z.scaleMode){case"fill":case"crop":J.setAttribute("fit","cover");break;case"fit":J.setAttribute("fit","contain");break}return}switch(J.style.objectPosition="center",J.style.width="100%",J.style.height="100%",this.#Z.scaleMode){case"fill":case"crop":J.style.objectFit="cover";break;case"fit":J.style.objectFit="contain";break}}#VQ(){let J=this.#J.querySelector('[data-tab="video"]'),Q=G("fig-select",{className:"fig-fill-picker-scale-mode",label:"Video scale mode",value:this.#Z.scaleMode},G("fig-select-options",{},[["fill","Fill"],["fit","Fit"],["crop","Crop"]].map(([X,Y])=>G("fig-select-option",{value:X},Y)))),Z=G("fig-field",{className:"fig-fill-picker-media-header"},Q),$=G("fig-media",{className:"fig-fill-picker-media-preview fig-fill-picker-video-preview",type:"video",upload:"true",label:"Upload from computer","aria-label":"Video fill preview",size:"auto","aspect-ratio":"1/1",fit:"cover",checkerboard:"true",controls:!0,muted:"true",loop:"true"});J.replaceChildren(Z,$),this.#HQ(J),this.#FJ({emit:!1})}#jJ(){if(this.#Z.poster?.startsWith("blob:"))URL.revokeObjectURL(this.#Z.poster),this.#S.delete(this.#Z.poster);this.#Z.poster=null,this.#r=null}#DJ(){if(!this.#Z.poster)return;if(this.#r&&this.#r===this.#Z.url)return;this.#jJ()}#dJ(){let J=this.#J?.querySelector(".fig-fill-picker-video-preview");if(J)this.#YJ(J)}#FJ({emit:J=!1}={}){if(this.#Z.url){if(this.#Z.missing=!1,this.#DJ(),!this.#Z.poster)this.#CJ(this.#Z.url);else this.#dJ();return}let Q=this.getAttribute("default-video");if(!Q){this.#Z.missing=!0;return}if(this.#Z.url=Q,this.#Z.missing=!1,this.#dJ(),this.#CJ(Q),J)this.#O()}#tJ(){if(this.#z!=="video")return;let J=this.#Z.url;if(!J)return;if(this.#DJ(),this.#Z.poster)return;this.#CJ(J)}async#fQ(J){if(typeof J.requestVideoFrameCallback==="function")await Promise.race([new Promise((Q)=>J.requestVideoFrameCallback(()=>Q())),new Promise((Q)=>setTimeout(Q,80))]);else try{await J.play(),J.pause()}catch{}if(typeof createImageBitmap==="function")try{return await createImageBitmap(J)}catch{}return null}async#qQ(J){let Q=await this.#fQ(J),Z=Q?.width||J.videoWidth,$=Q?.height||J.videoHeight;if(!Z||!$)return Q?.close?.(),null;let X=typeof OffscreenCanvas==="function"?new OffscreenCanvas(Z,$):Object.assign(document.createElement("canvas"),{width:Z,height:$}),Y=X.getContext("2d");if(!Y)return Q?.close?.(),null;try{Y.drawImage(Q||J,0,0,Z,$)}finally{Q?.close?.()}return X.convertToBlob?X.convertToBlob({type:"image/jpeg",quality:0.85}):new Promise((j)=>X.toBlob(j,"image/jpeg",0.85))}async#CJ(J,{emit:Q=!1}={}){if(!J||this.#I===J)return;this.#I=J;let Z=document.createElement("video");Z.muted=!0,Z.playsInline=!0,Z.preload="auto",Z.crossOrigin="anonymous";try{if(await new Promise((X,Y)=>{let j=()=>Y(Error("video poster failed"));Z.addEventListener("error",j,{once:!0}),Z.addEventListener("loadeddata",X,{once:!0}),Z.src=J}),!Z.videoWidth||!Z.videoHeight)return;let $=await this.#qQ(Z);if(!$||this.#Z.url!==J)return;if(this.#jJ(),this.#Z.poster=URL.createObjectURL($),this.#r=J,this.#S.add(this.#Z.poster),this.#V(),this.#dJ(),Q)this.#O()}catch{}finally{if(Z.removeAttribute("src"),Z.load(),this.#I===J)this.#I=null}}#HQ(J){let Q=J.querySelector(".fig-fill-picker-scale-mode"),Z=J.querySelector(".fig-fill-picker-video-preview");Q.addEventListener("change",($)=>{let X=typeof $.detail==="string"?$.detail:$.target?.value;if(!X)return;this.#Z.scaleMode=X,this.#YJ(Z),this.#V(),this.#O()}),Z.addEventListener("loaded",($)=>{let X=$.detail?.src||Z.src;if(!X)return;let Y=X!==this.#Z.url;if(Y)this.#jJ();if(this.#Z.url=X,this.#Z.missing=!1,this.#YJ(Z),this.#CJ(X),this.#V(),Y)this.#O();this.dispatchEvent(new CustomEvent("loaded",{bubbles:!0,detail:$.detail??{src:X}}))}),Z.addEventListener("change",()=>{if(Z.src)return;this.#Z.url=null,this.#jJ(),this.#FJ(),this.#YJ(Z),this.#V(),this.#O()}),this.#YJ(Z)}#BQ(){let J=this.#J.querySelector('[data-tab="webcam"]'),Q=G("fig-field",{className:"fig-fill-picker-webcam-camera"},G("fig-select",{className:"fig-fill-picker-camera-select",label:"Camera",full:!0},document.createElement("fig-select-options")));Q.style.display="none";let Z=G("video",{className:"fig-fill-picker-webcam-video",autoplay:!0,muted:!0,playsinline:!0});Z.muted=!0;let $=G("div",{className:"fig-fill-picker-webcam-status",role:"status","aria-live":"polite"},G("span",{},"Camera access required")),X=G("fig-video",{className:"fig-fill-picker-webcam-preview","aria-label":"Webcam preview","aspect-ratio":"1/1",fit:"cover",checkerboard:"true",autoplay:"true",muted:"true"},[Z,$]),Y=G("div",{className:"fig-fill-picker-webcam-controls"},G("fig-button",{className:"fig-fill-picker-webcam-capture",variant:"secondary",full:!0,disabled:!0},"Capture"));J.replaceChildren(Q,X,Y),this.#RQ(J)}#RQ(J){let Q=J.querySelector(".fig-fill-picker-webcam-video"),Z=J.querySelector(".fig-fill-picker-webcam-status"),$=J.querySelector(".fig-fill-picker-webcam-capture"),X=J.querySelector(".fig-fill-picker-webcam-camera"),Y=J.querySelector(".fig-fill-picker-camera-select"),j=(U)=>{if(U)$.removeAttribute("disabled");else $.setAttribute("disabled","")},K=()=>{let U=!!this.#$.stream&&Q.readyState>=HTMLMediaElement.HAVE_CURRENT_DATA&&Q.videoWidth>0&&Q.videoHeight>0;if(j(U),U)Z.querySelector("span").textContent="Camera ready",Z.style.display="none",this.#SJ(Q)};Q.addEventListener("loadedmetadata",K),Q.addEventListener("canplay",K),Q.addEventListener("playing",K);let W=(U)=>{this.#$.stream=U,Q.srcObject=U,Q.muted=!0,Q.playsInline=!0,Q.style.display="block";let O=Q.play?.();if(O?.catch)O.catch(()=>{});K()},z=async(U,O)=>{let f=await navigator.mediaDevices.enumerateDevices();if(U!=null&&U!==this.#c)return;let q=f.filter((_)=>_.kind==="videoinput");if(q.length>1){X.style.display="";let _=Y.querySelector(":scope > fig-select-options");if(!_)_=document.createElement("fig-select-options"),Y.append(_);if(_.replaceChildren(),q.forEach((R,T)=>{let V=document.createElement("fig-select-option");V.value=R.deviceId;let H=R.label||(q.length>1?`Camera ${T+1}`:"Camera");V.textContent=H.replace(/\s*\((?:[0-9a-f]{4}:)*([0-9a-f]{4})\)$/i,(M,F)=>{return` ${/^\d+$/.test(F)?Number.parseInt(F,10).toString():F.replace(/^0+/,"")||"0"}`}),_.append(V)}),O)Y.value=O}else X.style.display="none",Y.querySelector(":scope > fig-select-options")?.replaceChildren()},L=async(U=null)=>{let O=U||this.#$.deviceId||null,f=this.#$.stream,q=f?.getTracks?.().filter((R)=>R.readyState!=="ended")??[];if(f&&q.length){let R=f.getVideoTracks?.()?.[0]?.getSettings?.()?.deviceId||this.#$.deviceId||null;if(!O||O===R){W(f),this.#UJ(),z(null,O||R);return}}this.#t({emit:Boolean(f)});let _=this.#c;j(!1),Z.querySelector("span").textContent="Starting camera",Z.style.display="flex";try{let R={video:O?{deviceId:{exact:O}}:!0},T=await navigator.mediaDevices.getUserMedia(R);if(_!==this.#c||!this.isConnected||this.#L!=="webcam"){T.getTracks().forEach((H)=>H.stop());return}let V=T.getVideoTracks?.()?.[0];this.#$.deviceId=O||V?.getSettings?.()?.deviceId||null,this.#$.live=this.#o()==="live",W(T),this.#UJ(),await z(_,O)}catch(R){if(_!==this.#c)return;console.error("Webcam error:",R.name,R.message);let T="Camera access denied";if(R.name==="NotAllowedError")T="Camera permission denied";else if(R.name==="NotFoundError")T="No camera found";else if(R.name==="NotReadableError")T="Camera in use by another app";else if(R.name==="OverconstrainedError")T="Camera constraints not supported";else if(!window.isSecureContext)T="Camera requires secure context";Z.replaceChildren();let V=document.createElement("span");V.textContent=T,Z.appendChild(V),Z.style.display="flex",Q.style.display="none",j(!1)}};this.#zJ=L,Y.addEventListener("change",(U)=>{let O=typeof U.detail==="string"?U.detail:U.target?.value;if(!O||O===this.#$.deviceId)return;L(O)}),$.addEventListener("click",async()=>{if(!this.#$.stream)return;let U=await this.#QJ(Q);if(!U)return;this.#U.url=U,this.#$.live=!1;let O=this.#J.querySelector(".fig-fill-picker-image-preview");if(O)this.#e(O);if(Array.from(this.#J.querySelectorAll(".fig-fill-picker-tab")).some((q)=>q.dataset.tab==="image"))this.#ZJ("image");else this.#V(),this.#O();this.#g()})}#sJ(J){let Q=J.h/360,Z=J.s/100,$=J.v/100,X,Y,j,K=Math.floor(Q*6),W=Q*6-K,z=$*(1-Z),L=$*(1-W*Z),U=$*(1-(1-W)*Z);switch(K%6){case 0:X=$,Y=U,j=z;break;case 1:X=L,Y=$,j=z;break;case 2:X=z,Y=$,j=U;break;case 3:X=z,Y=L,j=$;break;case 4:X=U,Y=z,j=$;break;case 5:X=$,Y=z,j=L;break}return{r:Math.round(X*255),g:Math.round(Y*255),b:Math.round(j*255)}}#KJ(J){let Q=J.r/255,Z=J.g/255,$=J.b/255,X=Math.max(Q,Z,$),Y=Math.min(Q,Z,$),j=X-Y,K=0,W=X===0?0:j/X,z=X;if(X!==Y){switch(X){case Q:K=(Z-$)/j+(Z<$?6:0);break;case Z:K=($-Q)/j+2;break;case $:K=(Q-Z)/j+4;break}K/=6}return{h:K*360,s:W*100,v:z*100,a:1}}#s(J){if(!J||typeof J.h!=="number"||typeof J.s!=="number"||typeof J.v!=="number")return"#D9D9D9";let Q=this.#sJ(J),Z=($)=>{return(isNaN($)?217:Math.max(0,Math.min(255,Math.round($)))).toString(16).padStart(2,"0")};return`#${Z(Q.r)}${Z(Q.g)}${Z(Q.b)}`}#WJ(J){let Q=parseInt(J.slice(1,3),16),Z=parseInt(J.slice(3,5),16),$=parseInt(J.slice(5,7),16);return this.#KJ({r:Q,g:Z,b:$})}#_Q(J,Q=1){let Z=parseInt(J.slice(1,3),16),$=parseInt(J.slice(3,5),16),X=parseInt(J.slice(5,7),16);return`rgba(${Z}, ${$}, ${X}, ${Q})`}#TQ(J){let Q=Math.max(0,Math.min(1,Number(J)||0)),Z=Math.round(Q*1000)/1000;return String(Z)}#kQ(J=this.#X){let Q=this.#sJ(J);return`rgba(${Q.r}, ${Q.g}, ${Q.b}, ${this.#TQ(J.a)})`}#MQ(J){let Q=String(J??"").trim();if(!Q)return null;let Z=Q.match(/^#?([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/i);if(Z){let X=Z[1];if(X.length===3)X=X[0]+X[0]+X[1]+X[1]+X[2]+X[2];let Y=1;if(X.length===8)Y=parseInt(X.slice(6,8),16)/255,X=X.slice(0,6);return{...this.#WJ(`#${X}`),a:Y}}let $=Q.match(/^rgba?\(\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))(?:\s*,\s*([+-]?(?:\d+\.?\d*|\.\d+))\s*)?\)$/i);if($){let X=Math.max(0,Math.min(255,Math.round(parseFloat($[1])))),Y=Math.max(0,Math.min(255,Math.round(parseFloat($[2])))),j=Math.max(0,Math.min(255,Math.round(parseFloat($[3])))),K=$[4]!==void 0?Math.max(0,Math.min(1,parseFloat($[4]))):1;if(![X,Y,j,K].every(Number.isFinite))return null;return{...this.#KJ({r:X,g:Y,b:j}),a:K}}return null}#NQ(J,Q=1){let Z=+(parseInt(J.slice(1,3),16)/255).toFixed(4),$=+(parseInt(J.slice(3,5),16)/255).toFixed(4),X=+(parseInt(J.slice(5,7),16)/255).toFixed(4);return`color(display-p3 ${Z} ${$} ${X} / ${Q})`}#yQ(J){let Q=J.r/255,Z=J.g/255,$=J.b/255,X=Math.max(Q,Z,$),Y=Math.min(Q,Z,$),j,K,W=(X+Y)/2;if(X===Y)j=K=0;else{let z=X-Y;switch(K=W>0.5?z/(2-X-Y):z/(X+Y),X){case Q:j=((Z-$)/z+(Z<$?6:0))/6;break;case Z:j=(($-Q)/z+2)/6;break;case $:j=((Q-Z)/z+4)/6;break}}return{h:j*360,s:K*100,l:W*100}}#DQ(J){let Q=J.h/360,Z=J.s/100,$=J.l/100,X,Y,j;if(Z===0)X=Y=j=$;else{let K=(L,U,O)=>{if(O<0)O+=1;if(O>1)O-=1;if(O<0.16666666666666666)return L+(U-L)*6*O;if(O<0.5)return U;if(O<0.6666666666666666)return L+(U-L)*(0.6666666666666666-O)*6;return L},W=$<0.5?$*(1+Z):$+Z-$*Z,z=2*$-W;X=K(z,W,Q+0.3333333333333333),Y=K(z,W,Q),j=K(z,W,Q-0.3333333333333333)}return{r:Math.round(X*255),g:Math.round(Y*255),b:Math.round(j*255)}}#eJ(J){let Q=(U)=>{return U=U/255,U<=0.04045?U/12.92:Math.pow((U+0.055)/1.055,2.4)},Z=Q(J.r),$=Q(J.g),X=Q(J.b),Y=0.4122214708*Z+0.5363325363*$+0.0514459929*X,j=0.2119034982*Z+0.6806995451*$+0.1073969566*X,K=0.0883024619*Z+0.2817188376*$+0.6299787005*X,W=Math.cbrt(Y),z=Math.cbrt(j),L=Math.cbrt(K);return{l:0.2104542553*W+0.793617785*z-0.0040720468*L,a:1.9779984951*W-2.428592205*z+0.4505937099*L,b:0.0259040371*W+0.7827717662*z-0.808675766*L}}#FQ(J){let Q=this.#eJ(J);return{l:Q.l,c:Math.sqrt(Q.a*Q.a+Q.b*Q.b),h:(Math.atan2(Q.b,Q.a)*180/Math.PI+360)%360}}#JQ(J){let Q=J.l+0.3963377774*J.a+0.2158037573*J.b,Z=J.l-0.1055613458*J.a-0.0638541728*J.b,$=J.l-0.0894841775*J.a-1.291485548*J.b,X=Q*Q*Q,Y=Z*Z*Z,j=$*$*$,K=(W)=>{let z=W<=0.0031308?12.92*W:1.055*Math.pow(W,0.4166666666666667)-0.055;return Math.round(Math.max(0,Math.min(1,z))*255)};return{r:K(4.0767416621*X-3.3077115913*Y+0.2309699292*j),g:K(-1.2684380046*X+2.6097574011*Y-0.3413193965*j),b:K(-0.0041960863*X-0.7034186147*Y+1.707614701*j)}}#CQ(J){let Q=J.h*Math.PI/180;return this.#JQ({l:J.l,a:J.c*Math.cos(Q),b:J.c*Math.sin(Q)})}#O(){if(this.#u())return;this.#V(),this.dispatchEvent(new CustomEvent("input",{bubbles:!0,detail:this.value}))}#g(){if(this.#u())return;this.#m=JSON.stringify(this.value),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,detail:this.value}))}get value(){let J={type:this.#z,colorSpace:this.#R};switch(this.#z){case"solid":return{...J,color:this.#s(this.#X),alpha:this.#X.a,hsv:{...this.#X}};case"gradient":return{...J,gradient:P(this.#Y),css:this.#aJ()};case"image":return{...J,image:{...this.#U}};case"video":return{...J,video:this.#RJ()};case"webcam":return{...J,webcam:this.#BJ()};default:return{...J,...this.#h[this.#z]}}}set value(J){if(typeof J==="string")this.setAttribute("value",J);else this.setAttribute("value",JSON.stringify(J))}attributeChangedCallback(J,Q,Z){if(Q===Z)return;switch(J){case"value":if(this.#GJ(),this.#V(),this.#tJ(),this.#J?.open&&!this.#A)this.#NJ(),this.#m=JSON.stringify(this.value);break;case"disabled":if(this.#q(),this.#u()&&this.#J?.open)this.close();break;case"alpha":case"mode":{if(!this.#J)break;let $=this.#J.open;if(this.#kJ(),$&&this.isConnected)this.#a();break}case"webcam-mode":if(this.#z==="webcam")this.#V();break;case"default-video":if(this.#z==="video")this.#FJ({emit:!1}),this.#V();break;case"aria-label":if(this.#J)this.#J.setAttribute("aria-label",this.#x());case"aria-labelledby":case"aria-describedby":this.#q();break}}}A("fig-fill-picker",D);class B extends HTMLElement{static#K=new Set(["oklch","hsl"]);static#Q=10;static#j=10;static#W=8;static#J=3;static#E=210;static#L={type:"linear",angle:135,interpolationSpace:"srgb",hueInterpolation:"shorter",stops:[{color:"#FF0000",position:0,opacity:100},{color:"#4F9EFF",position:100,opacity:100}]};#z=!1;#R=null;#X=null;#G={...B.#L};static get observedAttributes(){return["value"]}get value(){return{type:"gradient",gradient:{...this.#G}}}set value(J){if(J==null||J===""){this.removeAttribute("value");return}if(typeof J==="string"){this.setAttribute("value",J);return}this.setAttribute("value",JSON.stringify(J))}connectedCallback(){this.#Y(),this.#U(),this.#A(),this.#k()}attributeChangedCallback(J,Q,Z){if(Q===Z)return;if(J!=="value")return;if(this.#U(),this.#z)this.#k()}#Y(){if(!(this.hasAttribute("aria-label")||this.hasAttribute("aria-labelledby"))&&!this.hasAttribute("aria-hidden"))this.setAttribute("aria-hidden","true")}#U(){let J=this.getAttribute("value");if(!J){this.#G={...B.#L,stops:B.#L.stops.map((Q)=>({...Q}))};return}try{let Q=JSON.parse(J),Z=Q?.type==="gradient"&&Q.gradient?Q.gradient:Q?.gradient?Q.gradient:Q;if(!Z||typeof Z!=="object")return;this.#G=this.#Z({...B.#L,...Z})}catch{}}#Z(J){let Q={...J??{}},Z=String(Q.interpolationSpace??"srgb").toLowerCase(),$=String(Q.hueInterpolation??"shorter").toLowerCase(),X=Array.isArray(Q.stops)?Q.stops.map((Y)=>({color:String(Y?.color||"#D9D9D9").replace(/^(#(?:[0-9a-f]{6})).*/i,"$1"),position:Y?.position??0,opacity:Y?.opacity??100})):B.#L.stops.map((Y)=>({...Y}));if(X.length<2)return{...B.#L,stops:B.#L.stops.map((Y)=>({...Y}))};return{type:["linear","radial","angular"].includes(Q.type)?Q.type:"linear",angle:Number.isFinite(Number(Q.angle))?Number(Q.angle):135,interpolationSpace:Z,hueInterpolation:$,stops:X}}#$(){return B.#K.has(this.#G.interpolationSpace||"srgb")}#C(J){let{r:Q,g:Z,b:$}=r(J);if(this.#G.interpolationSpace==="hsl")return o(Q,Z,$).h;let X=n(Q,Z,$);return(a(X.l,X.a,X.b).h%360+360)%360}#D(){let J=this.#B(),Q=this.#C(J[0]?.color||"#FF0000"),Z=this.#C(J[J.length-1]?.color||"#4F9EFF"),$=B.#E-Q,Y=((B.#E-Z-$)%360+360)%360,j=Y===0?0:Y-360,K=this.#G.hueInterpolation||"shorter",W;if(K==="increasing")W=j;else if(K==="decreasing")W=Y;else if(K==="longer")W=Y<180?j:Y;else W=Y<=180?Y:j;let z=Math.sign(W),L=Math.asin(B.#J/2/B.#W)*180/Math.PI,U=Math.min(L,Math.max(0,(Math.abs(W)-0.01)/2));return{startDeg:$+z*U,sweepDeg:W-z*U*2}}#F(J){let Q=J*Math.PI/180;return{x:B.#Q+B.#W*Math.cos(Q),y:B.#j+B.#W*Math.sin(Q)}}#f(J,Q){let Z=J+Q,$=this.#F(J),X=this.#F(Z),Y=Math.abs(Q)>180?1:0,j=Q>=0?1:0;return`M ${$.x} ${$.y} A ${B.#W} ${B.#W} 0 ${Y} ${j} ${X.x} ${X.y}`}#h(){let J=this.#F(180),Q=this.#F(0);return`M ${J.x} ${J.y} L ${Q.x} ${Q.y}`}#H(J){let Q=B.#J,Z=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="none"><path d="${J}" fill="none" stroke="white" stroke-width="${Q}" stroke-linecap="round" stroke-linejoin="round"/></svg>`;return`url("data:image/svg+xml,${encodeURIComponent(Z)}")`}#B(){return[...this.#G.stops].sort((J,Q)=>(J.position??0)-(Q.position??0))}#_(){let J=this.#G.interpolationSpace||"srgb";if(J==="srgb")return"";if(B.#K.has(J))return` in ${J} ${this.#G.hueInterpolation||"shorter"} hue`;return` in ${J}`}#T(){let J=this.#B(),Q=this.#_();if(this.#$()){let $=(B.#E+90)%360,X=this.#G.interpolationSpace,Y=(K)=>X==="oklch"?`oklch(65% 0.25 ${K})`:`hsl(${K} 100% 50%)`,j=[0,300,240,180,120,60,0].map(Y).join(", ");return`conic-gradient(from ${$}deg in ${X} decreasing hue, ${j})`}let Z=J.map(($)=>`${$.color} ${$.position??0}%`).join(", ");return`linear-gradient(90deg${Q}, ${Z})`}#A(){if(this.#z)return;let J=B.#J,Q=u("svg",{className:"fig-interpolation-swatch-svg",width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true"},u("circle",{className:"fig-interpolation-swatch-rim",cx:"10",cy:"10",r:"8",fill:"none",stroke:"currentColor","stroke-width":J})),Z=G("div",{className:"fig-interpolation-swatch-fill","aria-hidden":"true"});this.replaceChildren(Q,Z),this.#R=Q,this.#X=Z,this.#z=!0}#k(){if(!this.#X)return;let J=this.#$();if(this.#R)this.#R.style.display=J?"":"none";let Q=J?(()=>{let{startDeg:$,sweepDeg:X}=this.#D();return this.#f($,X)})():this.#h(),Z=this.#H(Q);this.#X.style.setProperty("-webkit-mask-image",Z),this.#X.style.maskImage=Z,this.#X.style.background=this.#T()}}A("fig-interpolation-swatch",B);