@simai-studio/ui 5.20261019.1827 → 5.20261019.1921

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +4 -4
  2. package/distr/component/country-code/js/country-code.min.js +1 -1
  3. package/distr/component/dropdown/js/dropdown.min.js +1 -1
  4. package/distr/component/file-upload/js/file-upload.min.js +1 -1
  5. package/distr/component/inputs/js/inputs.min.js +1 -1
  6. package/distr/component/pagination/css/pagination.min.css +1 -1
  7. package/distr/component/quantity/js/quantity.min.js +1 -1
  8. package/distr/component/textarea/js/textarea.min.js +1 -1
  9. package/distr/core/contracts/adaptive-sizing.schema.json +1 -1
  10. package/distr/core/contracts/composite-host-port.v1.schema.json +1 -1
  11. package/distr/core/contracts/composition-document.v1.schema.json +1 -1
  12. package/distr/core/contracts/composition-editor-field-kind.v1.schema.json +1 -1
  13. package/distr/core/contracts/composition-editor-manifest.v1.schema.json +1 -1
  14. package/distr/core/contracts/composition-port-manifest.v1.schema.json +1 -1
  15. package/distr/core/contracts/composition-type-manifest.v1.schema.json +1 -1
  16. package/distr/core/js/core-loader.js +12 -10
  17. package/distr/core/js/core-loader.min.js +1 -1
  18. package/distr/core/js/core.js +42 -17
  19. package/distr/core/js/core.min.js +1 -1
  20. package/distr/core/js/smart-base.js +2 -2
  21. package/distr/core/js/smart-base.min.js +1 -1
  22. package/distr/smart/avatar/js/avatar.min.js +1 -1
  23. package/distr/smart/badges/js/badges.min.js +1 -1
  24. package/distr/smart/buttons/js/buttons.min.js +1 -1
  25. package/distr/smart/country-code/js/country-code.min.js +1 -1
  26. package/distr/smart/datepicker/js/datepicker.min.js +1 -1
  27. package/distr/smart/dropdown/js/dropdown.min.js +1 -1
  28. package/distr/smart/file-upload/js/file-upload.min.js +1 -1
  29. package/distr/smart/inputs/js/inputs.min.js +1 -1
  30. package/distr/smart/list-item/js/list-item.min.js +16 -16
  31. package/distr/smart/modal/contract.json +1 -1
  32. package/distr/smart/progress-scale/js/progress-scale.min.js +1 -1
  33. package/distr/smart/reference-link/js/reference-link.min.js +1 -1
  34. package/distr/smart/tags/js/tags.min.js +1 -1
  35. package/distr/smart/textarea/js/textarea.min.js +5 -5
  36. package/package-manifest.json +37 -37
  37. package/package.json +4 -4
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";var e={c0450586011d(e,a,s){s.a(e,async(e,t)=>{try{s.d(a,{Dk:()=>T,Ue:()=>J,Xx:()=>L,_i:()=>ce,nD:()=>ue,nK:()=>ke});var n=s("d7f974466839"),o=s("58661bec99a6"),i=s("8c672a55a76a"),l=s("c614c5e30b0d"),r=s("67eed2647f47"),m=s("0ab12d47912a"),d=s("5c1dc214bb5e"),f=s("98e26702f55a"),u=s("0d662e4d7d63"),c=e([d,u]);[d,u]=c.then?(await c)():c;var h=s.n(d);const k={en:{phoneLabel:"Phone number",phoneRequired:"Enter a phone number.",countryLabel:"Country code"},ru:{phoneLabel:"Телефон",phoneRequired:"Введите номер телефона.",countryLabel:"Код страны"}},y=()=>globalThis.SF?.Position||h(),p=".sf-country-code",H="sfCountryCodeBound",g=Array.isArray(l?.items)?l.items:[];let E=null,P=0;const C=new WeakMap,b=new WeakMap,R=new WeakMap,j=new WeakMap,w=new WeakMap;function x(e,a){if(!a)return;const s=j.get(a)||{},t=e.querySelector(".sf-country-code-text"),n=e.querySelector(".sf-country-code-hint"),o=C.get(a),i=a.hasAttribute("aria-label")&&a.getAttribute("aria-label")!==o;for(const[e,o]of[["aria-labelledby",t],["aria-describedby",n]]){const t=o?.textContent.trim()?o:null;let n=(a.getAttribute(e)||"").split(/\s+/).filter(Boolean);const l=o&&/^sf-country-\d+$/.test(o.id)&&n.includes(o.id)?o.id:"",r=s[e]||l;n=n.filter(e=>e!==r);const m=t&&("aria-describedby"===e||!i&&0===n.length)?_(t):"";m&&n.push(m);const d=[...new Set(n)].join(" ");d!==(a.getAttribute(e)||"")&&(d?a.setAttribute(e,d):a.removeAttribute(e)),s[e]=m}if(j.set(a,s),t?.textContent.trim()||a.hasAttribute("aria-labelledby"))o&&a.getAttribute("aria-label")===o&&a.removeAttribute("aria-label");else if(!i){const s=(0,u.pageText)(k,"phoneLabel",e,"sf-country-code");a.getAttribute("aria-label")!==s&&a.setAttribute("aria-label",s),C.set(a,s)}}function S(e,a){const s=R.get(a);if(a.validity.customError&&a.validationMessage!==s)return;const t=e.__sfCountryConfig||{},n=String(a.value||"").trim(),o=t.showCode?K(n,e.dataset.dialCode):n,i=a.required&&""!==n&&!/\d/.test(o)?(0,u.pageText)(k,"phoneRequired",e,"sf-country-code"):"";a.setCustomValidity(i),R.set(a,i)}function _(e){if(!e)return"";if(!e.id||document.getElementById(e.id)&&document.getElementById(e.id)!==e)do{e.id="sf-country-"+ ++P}while(document.getElementById(e.id)&&document.getElementById(e.id)!==e);return e.id}function v(e,a){if(!e||e.hasAttribute("aria-labelledby"))return;const s=C.get(e);e.hasAttribute("aria-label")&&e.getAttribute("aria-label")!==s||(e.setAttribute("aria-label",a),C.set(e,a))}function M(e){const{input:a,toggle:s,list:t,items:n}=N(e),o=e.__sfCountryConfig||{},i=e.classList.contains("open"),l=e.__sfCountrySelected,r=(0,u.pageText)(k,"countryLabel",e,"sf-country-code");x(e,a),e.querySelectorAll(".sf-country-code-required, .sf-country-code-left .sf-icon").forEach(e=>e.setAttribute("aria-hidden","true")),s&&(o.multiCountry&&o.showCode&&t?(v(s,`${r}${l?`: ${Z(l,o.locale)}`:""}`),s.setAttribute("role","button"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",_(t)),s.setAttribute("aria-expanded",String(i))):(s.removeAttribute("aria-haspopup"),s.removeAttribute("aria-controls"),s.removeAttribute("aria-expanded"),s.removeAttribute("aria-disabled"),s.removeAttribute("role"),s.getAttribute("aria-label")===C.get(s)&&(s.removeAttribute("aria-label"),C.delete(s)),s.tabIndex=-1)),t&&(t.setAttribute("role","listbox"),v(t,r),t.setAttribute("aria-hidden",String(!i)),t.inert=!i);let m=!1;for(const e of n){const a=!m&&!!l&&(l.iso2?L(e.dataset.iso2)===l.iso2:e.dataset.code===l.dialCode);m||=a,e.setAttribute("role","option"),e.setAttribute("aria-selected",String(a)),e.tabIndex=i&&e===document.activeElement?0:-1}}function A(e,a=!1){return null==e||""===e?a:"boolean"==typeof e?e:["1","true","yes","on","active","open","disabled"].includes(String(e).toLowerCase())}function L(e){return String(e||"").trim().toUpperCase()}function T(){const e="undefined"!=typeof window?window.sfPath:"";if(!e)return"";try{return new URL("component/flag/flags/rect",e).href.replace(/\/$/,"")}catch{return String(e).replace(/\/$/,"")+"/component/flag/flags/rect"}}function B(e,a){const s=L(e).toLowerCase();return s&&a?`${a}/${s}.svg`:""}function I(e){if(!e||"1"===e.dataset.loaded)return;const a=e.dataset.flagSrc||"";a&&(e.src=a,e.dataset.loaded="1")}function $(e,a=!0){if(!e)return;if(!a)return void I(e);const s=(E||!("IntersectionObserver"in window)||(E=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;const a=e.target;I(a),E?.unobserve?.(a)})},{rootMargin:"120px"})),E);s?s.observe(e):I(e)}function F(e,a,s=!0){const t=document.createElement("div");t.classList.add("sf-country-code-flag"),t.setAttribute("aria-hidden","true");const n=e?.flagEmoji||"",o=B(e?.iso2,a.flagBase);if(!o)return t.textContent=n,t;const i=document.createElement("img");return i.alt=e?.iso2?`${e.iso2} flag`:"flag",i.decoding="async",i.loading="lazy",i.dataset.flagSrc=o,i.dataset.flagFallback=n,i.addEventListener("error",()=>{t.textContent=n},{once:!0}),$(i,s&&a.lazyFlags),t.append(i),t}function N(e){return{input:e?.querySelector?.(".sf-country-code-field input")||null,toggle:e?.querySelector?.(".sf-country-code-left")||null,list:e?.querySelector?.(".sf-country-code-list")||null,itemsWrap:e?.querySelector?.(".sf-country-code-items")||null,items:Array.from(e?.querySelectorAll?.(".sf-country-code-item")||[]),leftFlag:e?.querySelector?.(".sf-country-code-left .sf-country-code-flag-icon")||e?.querySelector?.(".sf-country-code-left .sf-country-code-flag")||null}}function O(e){const a=L(e);return a&&g.find(e=>e.iso2===a)||null}function D(e){const a=String(e||"").trim();return a&&g.find(e=>e.dialCode===a)||null}function q(e,a="native"){const s=String(e||"").trim();if(!s)return s;if("brackets"!==a)return s;const t=s.replace(/[()]/g,""),n=t.match(/^(\+\S+)\s+(.+)$/);if(!n)return t;const o=n[1],i=n[2].trim();if(!i)return t;const l=i.indexOf(" ");let r=l>=0?i.slice(0,l):i,m=l>=0?i.slice(l+1).trim():"",d=r;if(r.includes("-")){const[e,...a]=r.split("-");d=e;m=[a.join("-"),m].filter(Boolean).join(" ")}return d?`${o} (${d})${m?` ${m}`:""}`.trim():t}function z(e,a,s=""){const t=String(e||"");if(!t)return"";const n=a||"_",o=String(s||"").replace(/\D/g,"");let i=0;return t.replace(/0/g,()=>{if(i<o.length){const e=o[i];return i+=1,e}return n})}function G(e){return String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e,a){const s=String(e||"").trim();if(!s)return"";if(a){const e=G(a.trim()),t=new RegExp(`^${e}[\\s\\-()]*`,"i"),n=s.replace(t,"").trim();if(n!==s)return n}return s.replace(/^\+\d+[\s\-()]*/,"").trim()}function U(e=null){document.querySelectorAll(p).forEach(a=>{e&&a===e||V(a,!1)})}function V(e,a){if(!e)return;const{input:s}=N(e);(s?.disabled||e.classList.contains("disabled")||!1===e.__sfCountryConfig?.multiCountry)&&(a=!1),a?e.classList.add("open"):e.classList.remove("open"),M(e),e.__sfCountryViewport?.(a)}function W(e,a){const s=String(e.dataset.locale||a?.dataset.locale||(0,u.pageLanguage)(e)).toLowerCase(),t="brackets"===String(e.dataset.maskStyle??a?.dataset.maskStyle??"native").toLowerCase()?"brackets":"native";return{locale:"ru"===s?"ru":"en",useMask:A(e.dataset.useMask??a?.dataset.useMask,!1),useCountryMasks:A(e.dataset.useCountryMasks??a?.dataset.useCountryMasks,!0),showCode:A(e.dataset.showCode??a?.dataset.showCode,!0),maskStyle:t,multiCountry:A(e.dataset.multiCountry??a?.dataset.multiCountry,!0),defaultIso2:L(e.dataset.iso2??a?.dataset.iso2),fixedDialCode:String(e.dataset.dialCode??a?.dataset.dialCode??"").trim(),fixedMaskPattern:String(e.dataset.maskPattern??a?.dataset.maskPattern??"").trim(),flagBase:String(e.dataset.flagBase||a?.dataset.flagBase||"").trim()||T(),lazyFlags:A(e.dataset.lazyFlags??a?.dataset.lazyFlags,!0),showMaskPlaceholder:A(e.dataset.showMaskPlaceholder??a?.dataset.showMaskPlaceholder,!1),maskPlaceholderChar:String(e.dataset.maskPlaceholderChar??a?.dataset.maskPlaceholderChar??"_"),maxItems:Number.parseInt(e.dataset.maxItems||a?.dataset.maxItems||"0",10)||0}}function Z(e,a){if(!e)return"";if(e.label)return String(e.label);const s=("en"===a?e.nameEn||e.nameRu:e.nameRu||e.nameEn)||e.iso2;return s?`${s} (${e.dialCode})`:String(e.dialCode||"")}function J(e,a="ru",s=0){let t=Array.isArray(e)&&e.length?e:g;return Number(s)>0&&(t=t.slice(0,Number(s))),t.filter(e=>e&&"object"==typeof e).map(e=>{const s=L(e.iso2),t=String(e.dialCode||e.code||"").trim(),n=O(s)||!s&&D(t)||{},o={...n,...e,iso2:s||n.iso2||"",dialCode:t||n.dialCode||""};return o.label=Z(o,a),o})}function Y(e,a){const s=e.cloneNode(!0);return s.querySelectorAll('.sf-country-code-flag, [aria-hidden="true"]').forEach(e=>e.remove()),J([{iso2:e.dataset.iso2,code:e.dataset.code,label:s.textContent.trim(),...e.hasAttribute("data-mask-pattern")?{maskPattern:e.dataset.maskPattern}:{}}],a)[0]}function X(e,a="",s=""){const t=e.__sfCountryOptions||[],n=L(a),o=String(s||"").trim();return n&&t.find(e=>e.iso2===n)||o&&t.find(e=>e.dialCode===o)||O(n)||D(o)}function Q(e,a){const{list:s,itemsWrap:t}=N(e);if(s&&t)return{list:s,itemsWrap:t};const n=document.createElement("span");n.classList.add("sf-country-code-list");const o=document.createElement("span");o.classList.add("sf-country-code-items","flex","flex-col"),n.append(o);const i=e.querySelector(".sf-country-code-field");return i?i.insertAdjacentElement("afterend",n):e.append(n),a.multiCountry||n.classList.add("hidden"),{list:n,itemsWrap:o}}function ee(e,a){if(!a.multiCountry)return;const{itemsWrap:s}=Q(e,a);if(!s)return;if(s.children.length>0)return;const t=a.maxItems>0?g.slice(0,a.maxItems):g,n=document.createDocumentFragment();t.forEach(e=>{const s=document.createElement("span");s.classList.add("sf-country-code-item","flex","items-center","transition"),s.dataset.iso2=e.iso2,s.dataset.code=e.dialCode,e.maskPattern&&(s.dataset.maskPattern=e.maskPattern);const t=F(e,a,!0),o=document.createElement("span");o.textContent=Z(e,a.locale),s.append(t,o),n.append(s)}),s.append(n)}function ae(e){const{list:a}=N(e);a&&a.querySelectorAll("img[data-flag-src]").forEach(e=>$(e,!0))}function se(e,a=8){const{list:s,itemsWrap:t}=N(e);if(!s||!t||a<=0||!e.classList.contains("open"))return 0;const n=Array.from(t.querySelectorAll(".sf-country-code-item")).slice(0,a),o=n.map(e=>e.offsetHeight);if(!o.some(Boolean))return 0;const i=window.getComputedStyle(t),l=Number.parseFloat(i.rowGap||"")||Number.parseFloat(i.gap||"")||0,r=o.reduce((e,a)=>e+a,0)+(n.length-1)*l+(Number.parseFloat(i.paddingTop||"")||0)+(Number.parseFloat(i.paddingBottom||"")||0);return Object.assign(t.style,{maxHeight:`${r}px`,minHeight:"0",overflowY:"auto",overflowX:"hidden"}),r}function te(e){const{list:a,itemsWrap:s}=N(e);if(!a||!s)return;let t=null,n=null;e.__sfCountryViewport=s=>{if(s&&!t&&e.isConnected)n=["display","flex-direction","overflow"].map(e=>[e,a.style.getPropertyValue(e),a.style.getPropertyPriority(e)]),Object.assign(a.style,{display:"flex",flexDirection:"column",overflow:"hidden"}),se(e),t=y().anchor(e,a,{side:"block-end",align:"start",matchWidth:!0,fitHeight:!0,onPosition:()=>{const a=e.getBoundingClientRect();(a.bottom<=0||a.top>=window.innerHeight)&&V(e,!1)}});else if(!s&&t){t.stop(),t=null;for(const[e,s,t]of n)s?a.style.setProperty(e,s,t):a.style.removeProperty(e)}else s&&t&&(se(e),t.update())}}function ne(e,a){for(let s=e;s;s=Object.getPrototypeOf(s)){const e=Object.getOwnPropertyDescriptor(s,a);if(e)return"function"==typeof e.set||!0===e.writable}return!1}async function oe(e,a,s,t=null){if(!a)return;const n=Symbol("country-code-mask");if(e.__sfCountryMaskToken=n,e.__sfCountryMask&&(window.SF?.Mask?.destroy?.(e.__sfCountryMask),delete e.__sfCountryMask),!s)return;const o=await(0,m.y)();if(n!==e.__sfCountryMaskToken)return;const i=a.value;try{const l=t||e.__sfCountryConfig||W(e,a),r=""!==String(i||"").trim(),m=l.showMaskPlaceholder&&r;if(!r&&s){const t=e?.dataset?.dialCode||l.fixedDialCode||"";a.placeholder=z(s,l.maskPlaceholderChar||"_",t)}const d=await o.create(a,{mask:s,lazy:!m,placeholderChar:l.maskPlaceholderChar||"_"});if(!d||n!==e.__sfCountryMaskToken)return void window.SF?.Mask?.destroy?.(d);if(e.__sfCountryMask=d,i){const e=String(i).replace(/\D+/g,"");e&&ne(d,"unmaskedValue")?d.unmaskedValue=e:ne(d,"value")&&(d.value=String(i)),"function"==typeof d.updateValue&&d.updateValue(),a.value=d.value||a.value}S(e,a)}catch(e){console.warn("SF.CountryCode mask init failed",e)}}function ie(e,a){return X(a,e.defaultIso2)||X(a,"",e.fixedDialCode)||a.__sfCountryOptions?.[0]||g[0]||null}function le(e){const{input:a,toggle:s}=N(e);if(!a)return;const t=e.classList.contains("disabled"),n=A(a.disabled,!1),o=t||n;e.classList.toggle("disabled",o),s&&(s.setAttribute("aria-disabled",o?"true":"false"),s.tabIndex=o?-1:0),o&&V(e,!1),M(e)}function re(e,a){if(!a?.showCode)return"";const s=String(e?.dataset?.dialCode||"").trim();return s?`${s} `:""}function me(e,a,s){if(!a)return;const t=re(e,s);if(!t)return;const n=String(a.value||"");if(n.startsWith(t))return;const o=K(n,e?.dataset?.dialCode||"");a.value=`${t}${o}`.trimEnd()}function de(e,a){if(!e||!a)return;const s=e.selectionStart??0,t=e.selectionEnd??0;if(s>=a.length&&t>=a.length)return;const n=a.length;e.setSelectionRange(n,n)}function fe(e,a,s="runtime"){if(!e||!a)return;const{input:t,leftFlag:n}=N(e);if(!t)return;const o=e.__sfCountryConfig||W(e,t),i=e.dataset.dialCode||"";e.dataset.iso2=a.iso2,e.dataset.dialCode=a.dialCode,e.dataset.maskPattern=a.maskPattern||"";const l=w.get(e);if(l&&(l.selected=e.dataset.maskPattern),e.__sfCountrySelected=a,o.showCode&&n){const e=F(a,o,!1),s=e.querySelector("img");n.textContent="",s?n.append(s):n.textContent=e.textContent||""}if("item"===s||"state"===s){const s=K(t.value,i);oe(e,t,"",o);const n=a.dialCode?`${a.dialCode} `:"";t.value=`${n}${s}`.trim(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}if(o.useMask){oe(e,t,q(o.useCountryMasks?a.maskPattern:o.fixedMaskPattern||a.maskPattern,o.maskStyle),o)}else oe(e,t,"",o);M(e),S(e,t)}function ue(e,{resetCountry:a=!1,countries:s,maskPattern:t}={}){if((0,f.vl)(e,"sf-country-code"),e?.__sfCountryCodeBind&&e.__sfCountryCodeBind!==ue)return e.__sfCountryCodeBind(e,{resetCountry:a,countries:s,maskPattern:t});if(!e||"function"==typeof e.__sfCountryCodeInput)return;const{input:n,toggle:o,leftFlag:i}=N(e);if(!n)return;e.__sfCountryCodeBind=ue,e.__sfCountryCodeSetState=ke;const l=W(e,n),m=w.get(e),d=void 0!==t?String(t).trim():m&&l.fixedMaskPattern===m.selected?m.fixed:l.fixedMaskPattern;l.fixedMaskPattern=d,w.set(e,{fixed:d,selected:e.dataset.maskPattern}),e.__sfCountryConfig=l,ee(e,l),se(e,8);const u=N(e),c=u.items;if(te(e),e.__sfCountryOptions=void 0===s?c.map(e=>Y(e,l.locale)):J(s,l.locale,l.maxItems),!l.showCode&&o?o.classList.add("hidden"):o&&o.classList.remove("hidden"),l.multiCountry)e.classList.remove("sf-country-code--fixed-dial-code"),u.list?.classList?.remove("hidden");else{e.classList.add("sf-country-code--fixed-dial-code"),e.classList.remove("open"),u.list?.classList?.add("hidden");const a=o?.querySelector?.(".sf-icon");a&&a.remove()}const h=ie(l,e);!a&&b.has(n)||b.set(n,h),h?fe(e,h,"init"):i&&(i.textContent="");const k=a=>{if(a.preventDefault(),!l.multiCountry||n.disabled||e.classList.contains("disabled"))return;const s=!e.classList.contains("open");U(e),V(e,s),s&&ae(e)},y=a=>{a.altKey||a.ctrlKey||a.metaKey||n.disabled||e.classList.contains("disabled")||!l.multiCountry||("Enter"!==a.key&&" "!==a.key||(a.preventDefault(),k(a),e.classList.contains("open")&&P()),"ArrowDown"!==a.key&&"ArrowUp"!==a.key||(a.preventDefault(),e.classList.contains("open")||k(a),P("ArrowUp"===a.key?-1:void 0)),"Escape"===a.key&&V(e,!1))},p=a=>{e.contains(a.target)||V(e,!1)},g=a=>{if(a.preventDefault(),n.disabled||e.classList.contains("disabled")||!l.multiCountry)return;const s=a.currentTarget;if("true"===s.getAttribute("aria-disabled")||s.classList.contains("disabled"))return;const t=Y(s,l.locale);t&&(fe(e,t,"item"),V(e,!1),("keydown"===a.type?o:n)?.focus({preventScroll:!0}))},E=()=>c.filter(e=>"true"!==e.getAttribute("aria-disabled")&&!e.classList.contains("disabled")&&!e.hidden),P=e=>{const a=E(),s=a.findIndex(e=>"true"===e.getAttribute("aria-selected")),t=void 0===e?Math.max(0,s):e<0?a.length-1:Math.min(e,a.length-1);c.forEach(e=>{e.tabIndex=-1});const n=a[t];if(!n)return;n.tabIndex=0,n.focus({preventScroll:!0});const o=u.itemsWrap;if(o){const e=o.getBoundingClientRect(),a=n.getBoundingClientRect();a.top<e.top?o.scrollTo({top:o.scrollTop-(e.top-a.top),behavior:"instant"}):a.bottom>e.bottom&&o.scrollTo({top:o.scrollTop+(a.bottom-e.bottom),behavior:"instant"})}};let C="",R=0;const j=a=>{if(a.altKey||a.ctrlKey||a.metaKey||n.disabled||e.classList.contains("disabled"))return;const s=E(),t=s.indexOf(a.currentTarget);if("Escape"===a.key)return a.preventDefault(),V(e,!1),void o?.focus({preventScroll:!0});if("Enter"!==a.key&&" "!==a.key){if(["ArrowDown","ArrowUp","Home","End"].includes(a.key)){a.preventDefault();const e="Home"===a.key?0:"End"===a.key?s.length-1:Math.max(0,t+("ArrowDown"===a.key?1:-1));return void P(e)}if(1===a.key.length){const e=performance.now();C=e-R>700?a.key:C+a.key,R=e;const n=[...C].every(e=>e===C[0])?C[0]:C,o=[...s.slice(t+1),...s.slice(0,t+1)].find(e=>(e.querySelector("span")?.textContent||e.textContent).trim().toLocaleLowerCase().startsWith(n.toLocaleLowerCase()));o&&(a.preventDefault(),P(s.indexOf(o)))}}else g(a)},_=a=>{e.contains(a.relatedTarget)||V(e,!1)},v=()=>{me(e,n,l),de(n,re(e,l)),S(e,n)},M=()=>{requestAnimationFrame(()=>{me(e,n,l),de(n,re(e,l))})},A=a=>{const s=re(e,l);if(!s)return;if(!["Backspace","Delete"].includes(a.key))return;const t=n.selectionStart??0,o=n.selectionEnd??t;return"Backspace"===a.key&&t<=s.length||"Delete"===a.key&&t<s.length?(a.preventDefault(),void de(n,s)):void((t<s.length||o<s.length)&&(a.preventDefault(),de(n,s)))};o&&(o.addEventListener("click",k),o.addEventListener("keydown",y),o.setAttribute("role","button")),n.addEventListener("input",v),n.addEventListener("paste",M),n.addEventListener("keydown",A),c.forEach(e=>{e.addEventListener("click",g),e.addEventListener("keydown",j)}),e.addEventListener("focusout",_),document.addEventListener("click",p),e.__sfCountryCodeToggleClick=k,e.__sfCountryCodeToggleKeydown=y,e.__sfCountryCodeDocClick=p,e.__sfCountryCodeItemClick=g,e.__sfCountryCodeItemKeydown=j,e.__sfCountryCodeFocusOut=_,e.__sfCountryCodeInput=v,e.__sfCountryCodePaste=M,e.__sfCountryCodeInputKeydown=A,e.__sfCountryReleaseReset=(0,r.z)(n,()=>{const a=b.get(n);a&&fe(e,a,"reset"),V(e,!1),S(e,n)}),e.__sfCountryRequiredObserver=new MutationObserver(()=>{S(e,n),x(e,n)}),e.__sfCountryRequiredObserver.observe(e,{attributes:!0,attributeFilter:["required","aria-label","aria-labelledby","aria-describedby","id"],childList:!0,characterData:!0,subtree:!0}),e.dataset[H]="1",le(e),e.__sfCountryViewport?.(e.classList.contains("open"))}function ce(e){if(!e||"function"!=typeof e.__sfCountryCodeInput)return;const{input:a,toggle:s,items:t}=N(e);e.__sfCountryReleaseReset?.(),delete e.__sfCountryReleaseReset,e.__sfCountryRequiredObserver?.disconnect(),delete e.__sfCountryRequiredObserver,e.__sfCountryViewport?.(!1),delete e.__sfCountryViewport,e.querySelectorAll("img[data-flag-src]").forEach(e=>E?.unobserve(e)),s&&e.__sfCountryCodeToggleClick&&s.removeEventListener("click",e.__sfCountryCodeToggleClick),s&&e.__sfCountryCodeToggleKeydown&&s.removeEventListener("keydown",e.__sfCountryCodeToggleKeydown),e.__sfCountryCodeDocClick&&document.removeEventListener("click",e.__sfCountryCodeDocClick),t.forEach(a=>{e.__sfCountryCodeItemKeydown&&a.removeEventListener("keydown",e.__sfCountryCodeItemKeydown),e.__sfCountryCodeItemClick&&a.removeEventListener("click",e.__sfCountryCodeItemClick)}),e.__sfCountryCodeFocusOut&&e.removeEventListener("focusout",e.__sfCountryCodeFocusOut),a&&e.__sfCountryCodeInput&&a.removeEventListener("input",e.__sfCountryCodeInput),a&&e.__sfCountryCodePaste&&a.removeEventListener("paste",e.__sfCountryCodePaste),a&&e.__sfCountryCodeInputKeydown&&a.removeEventListener("keydown",e.__sfCountryCodeInputKeydown),e.__sfCountryMask&&window.SF?.Mask?.destroy?.(e.__sfCountryMask),delete e.__sfCountryCodeToggleClick,delete e.__sfCountryCodeToggleKeydown,delete e.__sfCountryCodeDocClick,delete e.__sfCountryCodeItemClick,delete e.__sfCountryCodeItemKeydown,delete e.__sfCountryCodeFocusOut,delete e.__sfCountryCodeInput,delete e.__sfCountryCodePaste,delete e.__sfCountryCodeInputKeydown,delete e.__sfCountryMask,delete e.__sfCountryMaskToken,delete e.__sfCountrySelected,delete e.__sfCountryConfig,delete e.__sfCountryOptions,delete e.dataset[H]}function he(e=document){e.querySelectorAll(p).forEach(e=>{e.closest("sf-country-code")||ue(e)})}function ke(e,a={}){const s=e instanceof HTMLElement?e.closest(p)||e:null;if(!s)return!1;if(s.__sfCountryCodeSetState&&s.__sfCountryCodeSetState!==ke)return s.__sfCountryCodeSetState(s,a);const{input:t}=N(s);if(!t)return!1;if(Object.prototype.hasOwnProperty.call(a,"disabled")){const e=A(a.disabled,!1);t.disabled=e,s.classList.toggle("disabled",e),le(s)}if(Object.prototype.hasOwnProperty.call(a,"active")&&V(s,A(a.active,!1)),Object.prototype.hasOwnProperty.call(a,"open")&&V(s,A(a.open,!1)),Object.prototype.hasOwnProperty.call(a,"value")&&(t.value=String(a.value??""),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))),Object.prototype.hasOwnProperty.call(a,"iso2")){const e=X(s,a.iso2);e&&fe(s,e,"state")}if(Object.prototype.hasOwnProperty.call(a,"dialCode")){const e=X(s,"",a.dialCode);e&&fe(s,e,"state")}return!0}class ye extends n.y{static componentName="CountryCode";html=null;constructor(e){super(e);const{size:a="1",label:s="",required:t=!1,name:n="",form:o="",hint:i="",value:l="",placeholder:r="+7(___)___-__-__",disabled:m=!1,active:d=!1,open:u=d,countries:c=[],locale:h="ru",useMask:k=!1,useCountryMasks:y=!0,showCode:p=!0,maskStyle:H="native",multiCountry:g=!0,iso2:E="",dialCode:P="",maskPattern:C="",flagBase:b="",lazyFlags:R=!0,showMaskPlaceholder:j=!1,maskPlaceholderChar:w="_",maxItems:x=0}=this.params||{},S=this.attrs.class||this.attrs.className;this.template=document.createElement("label"),this.id&&(this.template.id=this.id),this.template.classList.add("sf-country-code",`sf-country-code--size-${(0,f.id)(a,"sf-country-code")}`),A(m)&&this.template.classList.add("disabled"),A(u)&&this.template.classList.add("open"),S&&this.template.classList.add(...`${S}`.split(" ").filter(Boolean)),this.template.dataset.locale=String(h),this.template.dataset.useMask=String(A(k,!1)),this.template.dataset.useCountryMasks=String(A(y,!0)),this.template.dataset.showCode=String(A(p,!0)),this.template.dataset.maskStyle="brackets"===String(H).toLowerCase()?"brackets":"native",this.template.dataset.multiCountry=String(A(g,!0)),this.template.dataset.lazyFlags=String(A(R,!0)),this.template.dataset.showMaskPlaceholder=String(A(j,!1)),this.template.dataset.maskPlaceholderChar=String(w||"_"),E&&(this.template.dataset.iso2=L(E)),P&&(this.template.dataset.dialCode=String(P)),C&&(this.template.dataset.maskPattern=String(C)),b&&(this.template.dataset.flagBase=String(b).replace(/\/$/,"")),Number(x)>0&&(this.template.dataset.maxItems=String(Number(x)));const _=document.createElement("span");_.classList.add("sf-country-code-label");const v=document.createElement("span");if(v.classList.add("sf-country-code-text"),v.textContent=String(s),_.append(v),A(t,!1)){const e=document.createElement("span");e.classList.add("sf-country-code-required"),e.textContent="*",_.append(e)}const M=document.createElement("span");M.classList.add("sf-country-code-field");const B=document.createElement("span");B.classList.add("sf-country-code-left");const I=document.createElement("div");I.classList.add("sf-country-code-flag-icon"),I.setAttribute("aria-hidden","true");const $=document.createElement("i");$.classList.add("sf-icon"),$.textContent=A(u)?"expand_less":"expand_more",B.append(I,$);const N=document.createElement("input");N.type="tel",N.name=String(n),o&&N.setAttribute("form",String(o)),N.required=A(t,!1),N.defaultValue=String(l??""),N.placeholder=String(r??""),N.disabled=A(m,!1),M.append(B,N),this.template.append(_,M);const O=J(c,h,x);if(O.length){const e=document.createElement("span");e.classList.add("sf-country-code-list");const a=document.createElement("span");a.classList.add("sf-country-code-items","flex","flex-col"),O.forEach(e=>{const s=document.createElement("span");s.classList.add("sf-country-code-item"),e?.iso2&&(s.dataset.iso2=L(e.iso2)),(e?.dialCode||e?.code)&&(s.dataset.code=String(e.dialCode||e.code)),void 0!==e?.maskPattern&&(s.dataset.maskPattern=String(e.maskPattern||""));const t=F({iso2:e?.iso2,flagEmoji:e?.flagEmoji||""},{flagBase:this.template.dataset.flagBase||T(),lazyFlags:A(this.template.dataset.lazyFlags,!0)},!0),n=document.createElement("span");if(e?.label)n.textContent=String(e.label);else{const a=e?.nameRu||e?.nameEn||e?.dialCode||"",s=e?.dialCode||e?.code||"";n.textContent=s?`${a} (${s})`:a}s.append(t,n),this.applyLayoutUtilities(s,".sf-country-code .sf-country-code-item"),this.applyLayoutUtilities(t,".sf-country-code .sf-country-code-flag"),a.append(s)}),e.append(a),this.template.append(e)}if(i){const e=document.createElement("span");e.classList.add("sf-country-code-hint"),e.textContent=String(i),this.template.append(e)}this.applyLayoutUtilities(this.template,".sf-country-code"),this.applyLayoutUtilities(_,".sf-country-code .sf-country-code-label"),this.applyLayoutUtilities(M,".sf-country-code .sf-country-code-field"),this.applyLayoutUtilities(B,".sf-country-code .sf-country-code-left"),this.applyLayoutUtilities(N,".sf-country-code .sf-country-code-field input"),this.applyLayoutUtilities(I,".sf-country-code .sf-country-code-flag-icon")}init(){ue(this.template,{maskPattern:this.params?.maskPattern||""})}destroyInternal(){ce(this.template)}}ye.utilityMap=i,(0,o.A)("CountryCode",ye),"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.CountryCode=window.SF.CountryCode||{},window.SF.CountryCode.setState=ke),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>he()):he();new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.forEach(e=>{if(!(e instanceof Element))return;const a=[...e.querySelectorAll(p)];e.matches(p)&&a.unshift(e);for(const e of a)e.isConnected||e.closest("sf-country-code")||ce(e)}),e.addedNodes.forEach(e=>{e instanceof Element&&(e.matches?.(p)&&!e.closest("sf-country-code")&&ue(e),he(e))})})}).observe(document.documentElement,{childList:!0,subtree:!0}),t()}catch(pe){t(pe)}})},"98e26702f55a"(e,a,s){function t(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function n({component:e="",kind:a="attribute",attribute:s="",from:n,to:o=null}={}){if(!n)return;const i=[e,a,s,n].join("|"),l=t(),r=l.get(i);if(r)r.count+=1;else if(l.set(i,{component:e,kind:a,attribute:s,from:n,to:o,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const t=e?`${e}: `:"",i="value"===a?`${s}="${n}"`:`${a} ${n}`;globalThis.console?.warn?.(`[Simai Framework] ${t}${i} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(s.d(a,{id:()=>r,vl:()=>m}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const e=globalThis.SF.deprecations||{};e.list=function(){return[...t().values()].map(e=>({...e}))},e.clear=function(){t().clear()},e.note=n,globalThis.SF.deprecations=e}const o=Object.freeze(["1/2","1","2"]),i=Object.freeze({"1/3":"1/2",3:"2"}),l=new Set;function r(e,a="field",s="1"){const t=String(e??"").trim().toLowerCase();if(o.includes(t))return t;if(Object.hasOwn(i,t)){const e=i[t];n({component:a,kind:"value",attribute:"size",from:t,to:e});const s=`${a}:${t}`;return l.has(s)||"undefined"==typeof console||(l.add(s),console.warn(`[Simai Framework] ${a}: size ${t} is retired for form fields; rendering size ${e}.`)),e}return s}function m(e,a){if(e?.classList)for(const[s,t]of Object.entries(i)){const t=`${a}--size-${s}`;e.classList.contains(t)&&e.classList.replace(t,`${a}--size-${r(s,a)}`)}}},"67eed2647f47"(e,a,s){s.d(a,{z:()=>o});const t=new WeakMap,n=new WeakSet;function o(e,a){const s=e.ownerDocument;n.has(s)||(s.addEventListener("reset",e=>{const a=e.target;if("FORM"!==a?.tagName)return;const s=Array.from(a.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of s)if(e.isConnected&&e.form===a)for(const a of t.get(e)||[])a()},0)},!0),n.add(s));let o=t.get(e);return o||t.set(e,o=new Set),o.add(a),()=>o.delete(a)}},"0ab12d47912a"(e,a,s){s.d(a,{y:()=>n});let t=null;function n(){const e=()=>window.SF?.Mask?.create?window.SF.Mask:null,a=e();return a?Promise.resolve(a):t||(t=new Promise(a=>{const s=[[window,"sf-mask-ready"],[window,"sf-loader-ready"],[window,"load"],[document,"DOMContentLoaded"]],n=()=>{const o=e();o&&(s.forEach(([e,a])=>e.removeEventListener(a,n)),t=null,a(o))};s.forEach(([e,a])=>e.addEventListener(a,n))}),t)}},"58661bec99a6"(e,a,s){const t=function(e,a){if(e&&a)if("undefined"==typeof window||"function"!=typeof window.registerSfComponent){if("undefined"!=typeof window&&window.SF?.Loader?.registerComponent)window.SF.Loader.registerComponent(e,a);else if("undefined"!=typeof window){(window.SF_PENDING_COMPONENTS=window.SF_PENDING_COMPONENTS||[]).push([e,a])}}else window.registerSfComponent(e,a)};s.d(a,["A",0,t])},d7f974466839(e,a,s){s.d(a,{y:()=>t});class t{lifecycleName(){return this.componentName??this.constructor.componentName}constructor(e){this.props=e,this.id=e?.id,this.params=e?.param,this.attrs=e?.attrs||{},this.template=null,window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:beforeRender`,{detail:this}))}getUtilityMap(){return this.constructor.utilityMap||null}extractUtilityClasses(e){if(!Array.isArray(e))return[];const a=new Set;return e.forEach(e=>{if("string"!=typeof e)return;const s=e.match(/\(([^)]+)\)/g);s&&s.forEach(e=>{e.slice(1,-1).split(/\s+/).filter(Boolean).forEach(e=>{e.startsWith(".")&&e.length>1&&a.add(e.slice(1))})})}),Array.from(a)}applyLayoutUtilities(e,a){if(!e||!a)return;const s=this.getUtilityMap();if(!s||!s[a])return;this.extractUtilityClasses(s[a]).forEach(a=>e.classList.add(a))}render(){return this.html=this.template,"function"==typeof this.init&&this.init(),this.html&&window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:render`,{detail:this})),this.html}destroy(){this.destroyInternal?.(),this.props=null,this.id=null,this.params=null,this.template=null,this.html&&(this.html.remove(),this.html=null),window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:destroy`,{detail:this}))}destroyInternal(){}}},"2a25b3f4fc15"(e,a,s){s.a(e,async(e,a)=>{try{var t=s("c614c5e30b0d"),n=s("0d662e4d7d63"),o=s("c0450586011d"),i=s("fbe0570fcc69"),l=s("98e26702f55a"),r=s("788779012d8a"),m=e([n,o,i,r]);[n,o,i,r]=m.then?(await m)():m;var d=s.n(i);const f=".sf-country-code",u=Array.isArray(t?.items)?t.items:[];class c extends(d()){static get props(){return{size:{default:"1"},label:{default:""},required:{type:Boolean,default:!1},name:{default:""},form:{default:""},hint:{default:""},value:{default:""},placeholder:{default:"+7(___)___-__-__"},disabled:{type:Boolean,default:!1},open:{type:Boolean,default:!1},locale:{default:""},useMask:{type:Boolean,default:!1},useCountryMasks:{type:Boolean,default:!0},showCode:{type:Boolean,default:!0},maskStyle:{default:"native"},multiCountry:{type:Boolean,default:!0},iso2:{default:""},dialCode:{default:""},maskPattern:{default:""},flagBase:{default:""},lazyFlags:{type:Boolean,default:!0},showMaskPlaceholder:{type:Boolean,default:!1},maskPlaceholderChar:{default:"_"},maxItems:{type:Number,default:0}}}constructor(){super(),this._countries=null,this._boundRoot=null,this._renderAttributes=new Set}get size(){return(0,l.id)(this.getAttribute("size")||"1","sf-country-code")}get label(){return this.getAttribute("label")||""}get required(){return this.getBooleanAttr("required",!1)}get hint(){return this.getAttribute("hint")||""}get value(){return this.getAttribute("value")||""}get placeholder(){return this.getAttribute("placeholder")||"+7(___)___-__-__"}get disabled(){return this.getBooleanAttr("disabled",!1)}get open(){return this.getBooleanAttr("open",!1)||this.getBooleanAttr("active",!1)}get locale(){return"ru"===String(this.getAttribute("locale")||(0,n.pageLanguage)(this)).toLowerCase()?"ru":"en"}get useMask(){return this.getBooleanAttr("use-mask",!1)}get useCountryMasks(){return this.getBooleanAttr("use-country-masks",!0)}get showCode(){return this.getBooleanAttr("show-code",!0)}get maskStyle(){return"brackets"===String(this.getAttribute("mask-style")||"native").toLowerCase()?"brackets":"native"}get multiCountry(){return this.getBooleanAttr("multi-country",!0)}get iso2(){return(0,o.Xx)(this.getAttribute("iso2"))}get dialCode(){return String(this.getAttribute("dial-code")||"").trim()}get maskPattern(){return String(this.getAttribute("mask-pattern")||"").trim()}get flagBase(){return String(this.getAttribute("flag-base")||"").trim()||(0,o.Dk)()}get lazyFlags(){return this.getBooleanAttr("lazy-flags",!0)}get showMaskPlaceholder(){return this.getBooleanAttr("show-mask-placeholder",!1)}get maskPlaceholderChar(){return String(this.getAttribute("mask-placeholder-char")||"_")}get maxItems(){return Math.trunc(this.getNumberAttr("max-items",0))}get countries(){return(0,o.Ue)(this._countries,this.locale,this.maxItems)}set countries(e){this._countries=Array.isArray(e)?e:null,this.requestComponentUpdate("countries")}templateContext(){const e=this.getPropsContext(),a=this._boundRoot,s=a&&!this._renderAttributes.has("open")&&!this._renderAttributes.has("active"),t=a&&!this._renderAttributes.has("disabled");return this.createTemplateContext({...e,open:s?a.classList.contains("open"):this.open,disabled:t?!!a.querySelector("input")?.disabled||a.classList.contains("disabled"):this.disabled,countries:this.countries.length?this.countries:(0,o.Ue)(u,this.locale,this.maxItems),locale:this.locale,maskStyle:this.maskStyle,iso2:this.iso2,flagBase:this.flagBase,maxItems:this.maxItems})}onDisconnected(){this._boundRoot&&((0,o._i)(this._boundRoot),this._boundRoot=null)}beforeRender(e=[]){this._renderAttributes=new Set(e)}afterRender(e){if("function"==typeof e)return super.afterRender(e);this._boundRoot&&((0,o._i)(this._boundRoot),this._boundRoot=null),this._boundRoot=this.querySelector(f),this._boundRoot&&(0,o.nD)(this._boundRoot,{resetCountry:this._renderAttributes.has("iso2")||this._renderAttributes.has("dial-code"),countries:this.countries,maskPattern:this.maskPattern})}template(){return(0,r.o)(this.templateContext())}get state(){const e=this.querySelector(f),a=e?.querySelector?.(".sf-country-code-field input")||null;return{value:a?.value||"",iso2:e?.dataset?.iso2||"",dialCode:e?.dataset?.dialCode||"",open:e?.classList?.contains("open")||!1,disabled:e?.classList?.contains("disabled")||!1}}setState(e={}){const a=this.querySelector(f);return(0,o.nK)(a,e)}}c.define("sf-country-code"),a()}catch(e){a(e)}})},"788779012d8a"(e,a,s){s.a(e,async(e,t)=>{try{s.d(a,{o:()=>r});var n=s("ddf1cdb42ecc"),o=e([n]),i=o.then?(await o)():o;n=i[0];function l(e,a=""){const s=String(e?.iso2||"").trim().toLowerCase(),t=e?.flagEmoji||"",o=s&&a?`${a}/${s}.svg`:"";return o?n.html`
1
+ (()=>{"use strict";var e={c0450586011d(e,a,s){s.a(e,async(e,t)=>{try{s.d(a,{Dk:()=>T,Ue:()=>J,Xx:()=>L,_i:()=>ce,nD:()=>ue,nK:()=>ke});var n=s("d7f974466839"),o=s("58661bec99a6"),i=s("8c672a55a76a"),l=s("c614c5e30b0d"),r=s("67eed2647f47"),m=s("0ab12d47912a"),d=s("5c1dc214bb5e"),f=s("98e26702f55a"),u=s("0d662e4d7d63"),c=e([d,u]);[d,u]=c.then?(await c)():c;var h=s.n(d);const k={en:{phoneLabel:"Phone number",phoneRequired:"Enter a phone number.",countryLabel:"Country code"},ru:{phoneLabel:"Телефон",phoneRequired:"Введите номер телефона.",countryLabel:"Код страны"}},y=()=>globalThis.SF?.Position||h(),p=".sf-country-code",H="sfCountryCodeBound",g=Array.isArray(l?.items)?l.items:[];let E=null,P=0;const C=new WeakMap,b=new WeakMap,R=new WeakMap,j=new WeakMap,w=new WeakMap;function x(e,a){if(!a)return;const s=j.get(a)||{},t=e.querySelector(".sf-country-code-text"),n=e.querySelector(".sf-country-code-hint"),o=C.get(a),i=a.hasAttribute("aria-label")&&a.getAttribute("aria-label")!==o;for(const[e,o]of[["aria-labelledby",t],["aria-describedby",n]]){const t=o?.textContent.trim()?o:null;let n=(a.getAttribute(e)||"").split(/\s+/).filter(Boolean);const l=o&&/^sf-country-\d+$/.test(o.id)&&n.includes(o.id)?o.id:"",r=s[e]||l;n=n.filter(e=>e!==r);const m=t&&("aria-describedby"===e||!i&&0===n.length)?_(t):"";m&&n.push(m);const d=[...new Set(n)].join(" ");d!==(a.getAttribute(e)||"")&&(d?a.setAttribute(e,d):a.removeAttribute(e)),s[e]=m}if(j.set(a,s),t?.textContent.trim()||a.hasAttribute("aria-labelledby"))o&&a.getAttribute("aria-label")===o&&a.removeAttribute("aria-label");else if(!i){const s=(0,u.pageText)(k,"phoneLabel",e,"sf-country-code");a.getAttribute("aria-label")!==s&&a.setAttribute("aria-label",s),C.set(a,s)}}function S(e,a){const s=R.get(a);if(a.validity.customError&&a.validationMessage!==s)return;const t=e.__sfCountryConfig||{},n=String(a.value||"").trim(),o=t.showCode?K(n,e.dataset.dialCode):n,i=a.required&&""!==n&&!/\d/.test(o)?(0,u.pageText)(k,"phoneRequired",e,"sf-country-code"):"";a.setCustomValidity(i),R.set(a,i)}function _(e){if(!e)return"";if(!e.id||document.getElementById(e.id)&&document.getElementById(e.id)!==e)do{e.id="sf-country-"+ ++P}while(document.getElementById(e.id)&&document.getElementById(e.id)!==e);return e.id}function v(e,a){if(!e||e.hasAttribute("aria-labelledby"))return;const s=C.get(e);e.hasAttribute("aria-label")&&e.getAttribute("aria-label")!==s||(e.setAttribute("aria-label",a),C.set(e,a))}function M(e){const{input:a,toggle:s,list:t,items:n}=N(e),o=e.__sfCountryConfig||{},i=e.classList.contains("open"),l=e.__sfCountrySelected,r=(0,u.pageText)(k,"countryLabel",e,"sf-country-code");x(e,a),e.querySelectorAll(".sf-country-code-required, .sf-country-code-left .sf-icon").forEach(e=>e.setAttribute("aria-hidden","true")),s&&(o.multiCountry&&o.showCode&&t?(v(s,`${r}${l?`: ${Z(l,o.locale)}`:""}`),s.setAttribute("role","button"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",_(t)),s.setAttribute("aria-expanded",String(i))):(s.removeAttribute("aria-haspopup"),s.removeAttribute("aria-controls"),s.removeAttribute("aria-expanded"),s.removeAttribute("aria-disabled"),s.removeAttribute("role"),s.getAttribute("aria-label")===C.get(s)&&(s.removeAttribute("aria-label"),C.delete(s)),s.tabIndex=-1)),t&&(t.setAttribute("role","listbox"),v(t,r),t.setAttribute("aria-hidden",String(!i)),t.inert=!i);let m=!1;for(const e of n){const a=!m&&!!l&&(l.iso2?L(e.dataset.iso2)===l.iso2:e.dataset.code===l.dialCode);m||=a,e.setAttribute("role","option"),e.setAttribute("aria-selected",String(a)),e.tabIndex=i&&e===document.activeElement?0:-1}}function A(e,a=!1){return null==e||""===e?a:"boolean"==typeof e?e:["1","true","yes","on","active","open","disabled"].includes(String(e).toLowerCase())}function L(e){return String(e||"").trim().toUpperCase()}function T(){const e="undefined"!=typeof window?window.sfPath:"";if(!e)return"";try{return new URL("component/flag/flags/rect",e).href.replace(/\/$/,"")}catch{return String(e).replace(/\/$/,"")+"/component/flag/flags/rect"}}function I(e,a){const s=L(e).toLowerCase();return s&&a?`${a}/${s}.svg`:""}function B(e){if(!e||"1"===e.dataset.loaded)return;const a=e.dataset.flagSrc||"";a&&(e.src=a,e.dataset.loaded="1")}function $(e,a=!0){if(!e)return;if(!a)return void B(e);const s=(E||!("IntersectionObserver"in window)||(E=new IntersectionObserver(e=>{e.forEach(e=>{if(!e.isIntersecting)return;const a=e.target;B(a),E?.unobserve?.(a)})},{rootMargin:"120px"})),E);s?s.observe(e):B(e)}function F(e,a,s=!0){const t=document.createElement("div");t.classList.add("sf-country-code-flag"),t.setAttribute("aria-hidden","true");const n=e?.flagEmoji||"",o=I(e?.iso2,a.flagBase);if(!o)return t.textContent=n,t;const i=document.createElement("img");return i.alt=e?.iso2?`${e.iso2} flag`:"flag",i.decoding="async",i.loading="lazy",i.dataset.flagSrc=o,i.dataset.flagFallback=n,i.addEventListener("error",()=>{t.textContent=n},{once:!0}),$(i,s&&a.lazyFlags),t.append(i),t}function N(e){return{input:e?.querySelector?.(".sf-country-code-field input")||null,toggle:e?.querySelector?.(".sf-country-code-left")||null,list:e?.querySelector?.(".sf-country-code-list")||null,itemsWrap:e?.querySelector?.(".sf-country-code-items")||null,items:Array.from(e?.querySelectorAll?.(".sf-country-code-item")||[]),leftFlag:e?.querySelector?.(".sf-country-code-left .sf-country-code-flag-icon")||e?.querySelector?.(".sf-country-code-left .sf-country-code-flag")||null}}function O(e){const a=L(e);return a&&g.find(e=>e.iso2===a)||null}function D(e){const a=String(e||"").trim();return a&&g.find(e=>e.dialCode===a)||null}function q(e,a="native"){const s=String(e||"").trim();if(!s)return s;if("brackets"!==a)return s;const t=s.replace(/[()]/g,""),n=t.match(/^(\+\S+)\s+(.+)$/);if(!n)return t;const o=n[1],i=n[2].trim();if(!i)return t;const l=i.indexOf(" ");let r=l>=0?i.slice(0,l):i,m=l>=0?i.slice(l+1).trim():"",d=r;if(r.includes("-")){const[e,...a]=r.split("-");d=e;m=[a.join("-"),m].filter(Boolean).join(" ")}return d?`${o} (${d})${m?` ${m}`:""}`.trim():t}function z(e,a,s=""){const t=String(e||"");if(!t)return"";const n=a||"_",o=String(s||"").replace(/\D/g,"");let i=0;return t.replace(/0/g,()=>{if(i<o.length){const e=o[i];return i+=1,e}return n})}function G(e){return String(e).replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function K(e,a){const s=String(e||"").trim();if(!s)return"";if(a){const e=G(a.trim()),t=new RegExp(`^${e}[\\s\\-()]*`,"i"),n=s.replace(t,"").trim();if(n!==s)return n}return s.replace(/^\+\d+[\s\-()]*/,"").trim()}function U(e=null){document.querySelectorAll(p).forEach(a=>{e&&a===e||V(a,!1)})}function V(e,a){if(!e)return;const{input:s}=N(e);(s?.disabled||e.classList.contains("disabled")||!1===e.__sfCountryConfig?.multiCountry)&&(a=!1),a?e.classList.add("open"):e.classList.remove("open"),M(e),e.__sfCountryViewport?.(a)}function W(e,a){const s=String(e.dataset.locale||a?.dataset.locale||(0,u.pageLanguage)(e)).toLowerCase(),t="brackets"===String(e.dataset.maskStyle??a?.dataset.maskStyle??"native").toLowerCase()?"brackets":"native";return{locale:"ru"===s?"ru":"en",useMask:A(e.dataset.useMask??a?.dataset.useMask,!1),useCountryMasks:A(e.dataset.useCountryMasks??a?.dataset.useCountryMasks,!0),showCode:A(e.dataset.showCode??a?.dataset.showCode,!0),maskStyle:t,multiCountry:A(e.dataset.multiCountry??a?.dataset.multiCountry,!0),defaultIso2:L(e.dataset.iso2??a?.dataset.iso2),fixedDialCode:String(e.dataset.dialCode??a?.dataset.dialCode??"").trim(),fixedMaskPattern:String(e.dataset.maskPattern??a?.dataset.maskPattern??"").trim(),flagBase:String(e.dataset.flagBase||a?.dataset.flagBase||"").trim()||T(),lazyFlags:A(e.dataset.lazyFlags??a?.dataset.lazyFlags,!0),showMaskPlaceholder:A(e.dataset.showMaskPlaceholder??a?.dataset.showMaskPlaceholder,!1),maskPlaceholderChar:String(e.dataset.maskPlaceholderChar??a?.dataset.maskPlaceholderChar??"_"),maxItems:Number.parseInt(e.dataset.maxItems||a?.dataset.maxItems||"0",10)||0}}function Z(e,a){if(!e)return"";if(e.label)return String(e.label);const s=("en"===a?e.nameEn||e.nameRu:e.nameRu||e.nameEn)||e.iso2;return s?`${s} (${e.dialCode})`:String(e.dialCode||"")}function J(e,a="ru",s=0){let t=Array.isArray(e)&&e.length?e:g;return Number(s)>0&&(t=t.slice(0,Number(s))),t.filter(e=>e&&"object"==typeof e).map(e=>{const s=L(e.iso2),t=String(e.dialCode||e.code||"").trim(),n=O(s)||!s&&D(t)||{},o={...n,...e,iso2:s||n.iso2||"",dialCode:t||n.dialCode||""};return o.label=Z(o,a),o})}function Y(e,a){const s=e.cloneNode(!0);return s.querySelectorAll('.sf-country-code-flag, [aria-hidden="true"]').forEach(e=>e.remove()),J([{iso2:e.dataset.iso2,code:e.dataset.code,label:s.textContent.trim(),...e.hasAttribute("data-mask-pattern")?{maskPattern:e.dataset.maskPattern}:{}}],a)[0]}function X(e,a="",s=""){const t=e.__sfCountryOptions||[],n=L(a),o=String(s||"").trim();return n&&t.find(e=>e.iso2===n)||o&&t.find(e=>e.dialCode===o)||O(n)||D(o)}function Q(e,a){const{list:s,itemsWrap:t}=N(e);if(s&&t)return{list:s,itemsWrap:t};const n=document.createElement("span");n.classList.add("sf-country-code-list");const o=document.createElement("span");o.classList.add("sf-country-code-items","flex","flex-col"),n.append(o);const i=e.querySelector(".sf-country-code-field");return i?i.insertAdjacentElement("afterend",n):e.append(n),a.multiCountry||n.classList.add("hidden"),{list:n,itemsWrap:o}}function ee(e,a){if(!a.multiCountry)return;const{itemsWrap:s}=Q(e,a);if(!s)return;if(s.children.length>0)return;const t=a.maxItems>0?g.slice(0,a.maxItems):g,n=document.createDocumentFragment();t.forEach(e=>{const s=document.createElement("span");s.classList.add("sf-country-code-item","flex","items-center","transition"),s.dataset.iso2=e.iso2,s.dataset.code=e.dialCode,e.maskPattern&&(s.dataset.maskPattern=e.maskPattern);const t=F(e,a,!0),o=document.createElement("span");o.textContent=Z(e,a.locale),s.append(t,o),n.append(s)}),s.append(n)}function ae(e){const{list:a}=N(e);a&&a.querySelectorAll("img[data-flag-src]").forEach(e=>$(e,!0))}function se(e,a=8){const{list:s,itemsWrap:t}=N(e);if(!s||!t||a<=0||!e.classList.contains("open"))return 0;const n=Array.from(t.querySelectorAll(".sf-country-code-item")).slice(0,a),o=n.map(e=>e.offsetHeight);if(!o.some(Boolean))return 0;const i=window.getComputedStyle(t),l=Number.parseFloat(i.rowGap||"")||Number.parseFloat(i.gap||"")||0,r=o.reduce((e,a)=>e+a,0)+(n.length-1)*l+(Number.parseFloat(i.paddingTop||"")||0)+(Number.parseFloat(i.paddingBottom||"")||0);return Object.assign(t.style,{maxHeight:`${r}px`,minHeight:"0",overflowY:"auto",overflowX:"hidden"}),r}function te(e){const{list:a,itemsWrap:s}=N(e);if(!a||!s)return;let t=null,n=null;e.__sfCountryViewport=s=>{if(s&&!t&&e.isConnected)n=["display","flex-direction","overflow"].map(e=>[e,a.style.getPropertyValue(e),a.style.getPropertyPriority(e)]),Object.assign(a.style,{display:"flex",flexDirection:"column",overflow:"hidden"}),se(e),t=y().anchor(e,a,{side:"block-end",align:"start",matchWidth:!0,fitHeight:!0,onPosition:()=>{const a=e.getBoundingClientRect();(a.bottom<=0||a.top>=window.innerHeight)&&V(e,!1)}});else if(!s&&t){t.stop(),t=null;for(const[e,s,t]of n)s?a.style.setProperty(e,s,t):a.style.removeProperty(e)}else s&&t&&(se(e),t.update())}}function ne(e,a){for(let s=e;s;s=Object.getPrototypeOf(s)){const e=Object.getOwnPropertyDescriptor(s,a);if(e)return"function"==typeof e.set||!0===e.writable}return!1}async function oe(e,a,s,t=null){if(!a)return;const n=Symbol("country-code-mask");if(e.__sfCountryMaskToken=n,e.__sfCountryMask&&(window.SF?.Mask?.destroy?.(e.__sfCountryMask),delete e.__sfCountryMask),!s)return;const o=await(0,m.y)();if(n!==e.__sfCountryMaskToken)return;const i=a.value;try{const l=t||e.__sfCountryConfig||W(e,a),r=""!==String(i||"").trim(),m=l.showMaskPlaceholder&&r;if(!r&&s){const t=e?.dataset?.dialCode||l.fixedDialCode||"";a.placeholder=z(s,l.maskPlaceholderChar||"_",t)}const d=await o.create(a,{mask:s,lazy:!m,placeholderChar:l.maskPlaceholderChar||"_"});if(!d||n!==e.__sfCountryMaskToken)return void window.SF?.Mask?.destroy?.(d);if(e.__sfCountryMask=d,i){const e=String(i).replace(/\D+/g,"");e&&ne(d,"unmaskedValue")?d.unmaskedValue=e:ne(d,"value")&&(d.value=String(i)),"function"==typeof d.updateValue&&d.updateValue(),a.value=d.value||a.value}S(e,a)}catch(e){console.warn("SF.CountryCode mask init failed",e)}}function ie(e,a){return X(a,e.defaultIso2)||X(a,"",e.fixedDialCode)||a.__sfCountryOptions?.[0]||g[0]||null}function le(e){const{input:a,toggle:s}=N(e);if(!a)return;const t=e.classList.contains("disabled"),n=A(a.disabled,!1),o=t||n;e.classList.toggle("disabled",o),s&&(s.setAttribute("aria-disabled",o?"true":"false"),s.tabIndex=o?-1:0),o&&V(e,!1),M(e)}function re(e,a){if(!a?.showCode)return"";const s=String(e?.dataset?.dialCode||"").trim();return s?`${s} `:""}function me(e,a,s){if(!a)return;const t=re(e,s);if(!t)return;const n=String(a.value||"");if(n.startsWith(t))return;const o=K(n,e?.dataset?.dialCode||"");a.value=`${t}${o}`.trimEnd()}function de(e,a){if(!e||!a)return;const s=e.selectionStart??0,t=e.selectionEnd??0;if(s>=a.length&&t>=a.length)return;const n=a.length;e.setSelectionRange(n,n)}function fe(e,a,s="runtime"){if(!e||!a)return;const{input:t,leftFlag:n}=N(e);if(!t)return;const o=e.__sfCountryConfig||W(e,t),i=e.dataset.dialCode||"";e.dataset.iso2=a.iso2,e.dataset.dialCode=a.dialCode,e.dataset.maskPattern=a.maskPattern||"";const l=w.get(e);if(l&&(l.selected=e.dataset.maskPattern),e.__sfCountrySelected=a,o.showCode&&n){const e=F(a,o,!1),s=e.querySelector("img");n.textContent="",s?n.append(s):n.textContent=e.textContent||""}if("item"===s||"state"===s){const s=K(t.value,i);oe(e,t,"",o);const n=a.dialCode?`${a.dialCode} `:"";t.value=`${n}${s}`.trim(),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))}if(o.useMask){oe(e,t,q(o.useCountryMasks?a.maskPattern:o.fixedMaskPattern||a.maskPattern,o.maskStyle),o)}else oe(e,t,"",o);M(e),S(e,t)}function ue(e,{resetCountry:a=!1,countries:s,maskPattern:t}={}){if((0,f.vl)(e,"sf-country-code"),e?.__sfCountryCodeBind&&e.__sfCountryCodeBind!==ue)return e.__sfCountryCodeBind(e,{resetCountry:a,countries:s,maskPattern:t});if(!e||"function"==typeof e.__sfCountryCodeInput)return;const{input:n,toggle:o,leftFlag:i}=N(e);if(!n)return;e.__sfCountryCodeBind=ue,e.__sfCountryCodeSetState=ke;const l=W(e,n),m=w.get(e),d=void 0!==t?String(t).trim():m&&l.fixedMaskPattern===m.selected?m.fixed:l.fixedMaskPattern;l.fixedMaskPattern=d,w.set(e,{fixed:d,selected:e.dataset.maskPattern}),e.__sfCountryConfig=l,ee(e,l),se(e,8);const u=N(e),c=u.items;if(te(e),e.__sfCountryOptions=void 0===s?c.map(e=>Y(e,l.locale)):J(s,l.locale,l.maxItems),!l.showCode&&o?o.classList.add("hidden"):o&&o.classList.remove("hidden"),l.multiCountry)e.classList.remove("sf-country-code--fixed-dial-code"),u.list?.classList?.remove("hidden");else{e.classList.add("sf-country-code--fixed-dial-code"),e.classList.remove("open"),u.list?.classList?.add("hidden");const a=o?.querySelector?.(".sf-icon");a&&a.remove()}const h=ie(l,e);!a&&b.has(n)||b.set(n,h),h?fe(e,h,"init"):i&&(i.textContent="");const k=a=>{if(a.preventDefault(),!l.multiCountry||n.disabled||e.classList.contains("disabled"))return;const s=!e.classList.contains("open");U(e),V(e,s),s&&ae(e)},y=a=>{a.altKey||a.ctrlKey||a.metaKey||n.disabled||e.classList.contains("disabled")||!l.multiCountry||("Enter"!==a.key&&" "!==a.key||(a.preventDefault(),k(a),e.classList.contains("open")&&P()),"ArrowDown"!==a.key&&"ArrowUp"!==a.key||(a.preventDefault(),e.classList.contains("open")||k(a),P("ArrowUp"===a.key?-1:void 0)),"Escape"===a.key&&V(e,!1))},p=a=>{e.contains(a.target)||V(e,!1)},g=a=>{if(a.preventDefault(),n.disabled||e.classList.contains("disabled")||!l.multiCountry)return;const s=a.currentTarget;if("true"===s.getAttribute("aria-disabled")||s.classList.contains("disabled"))return;const t=Y(s,l.locale);t&&(fe(e,t,"item"),V(e,!1),("keydown"===a.type?o:n)?.focus({preventScroll:!0}))},E=()=>c.filter(e=>"true"!==e.getAttribute("aria-disabled")&&!e.classList.contains("disabled")&&!e.hidden),P=e=>{const a=E(),s=a.findIndex(e=>"true"===e.getAttribute("aria-selected")),t=void 0===e?Math.max(0,s):e<0?a.length-1:Math.min(e,a.length-1);c.forEach(e=>{e.tabIndex=-1});const n=a[t];if(!n)return;n.tabIndex=0,n.focus({preventScroll:!0});const o=u.itemsWrap;if(o){const e=o.getBoundingClientRect(),a=n.getBoundingClientRect();a.top<e.top?o.scrollTo({top:o.scrollTop-(e.top-a.top),behavior:"instant"}):a.bottom>e.bottom&&o.scrollTo({top:o.scrollTop+(a.bottom-e.bottom),behavior:"instant"})}};let C="",R=0;const j=a=>{if(a.altKey||a.ctrlKey||a.metaKey||n.disabled||e.classList.contains("disabled"))return;const s=E(),t=s.indexOf(a.currentTarget);if("Escape"===a.key)return a.preventDefault(),V(e,!1),void o?.focus({preventScroll:!0});if("Enter"!==a.key&&" "!==a.key){if(["ArrowDown","ArrowUp","Home","End"].includes(a.key)){a.preventDefault();const e="Home"===a.key?0:"End"===a.key?s.length-1:Math.max(0,t+("ArrowDown"===a.key?1:-1));return void P(e)}if(1===a.key.length){const e=performance.now();C=e-R>700?a.key:C+a.key,R=e;const n=[...C].every(e=>e===C[0])?C[0]:C,o=[...s.slice(t+1),...s.slice(0,t+1)].find(e=>(e.querySelector("span")?.textContent||e.textContent).trim().toLocaleLowerCase().startsWith(n.toLocaleLowerCase()));o&&(a.preventDefault(),P(s.indexOf(o)))}}else g(a)},_=a=>{e.contains(a.relatedTarget)||V(e,!1)},v=()=>{me(e,n,l),de(n,re(e,l)),S(e,n)},M=()=>{requestAnimationFrame(()=>{me(e,n,l),de(n,re(e,l))})},A=a=>{const s=re(e,l);if(!s)return;if(!["Backspace","Delete"].includes(a.key))return;const t=n.selectionStart??0,o=n.selectionEnd??t;return"Backspace"===a.key&&t<=s.length||"Delete"===a.key&&t<s.length?(a.preventDefault(),void de(n,s)):void((t<s.length||o<s.length)&&(a.preventDefault(),de(n,s)))};o&&(o.addEventListener("click",k),o.addEventListener("keydown",y),o.setAttribute("role","button")),n.addEventListener("input",v),n.addEventListener("paste",M),n.addEventListener("keydown",A),c.forEach(e=>{e.addEventListener("click",g),e.addEventListener("keydown",j)}),e.addEventListener("focusout",_),document.addEventListener("click",p),e.__sfCountryCodeToggleClick=k,e.__sfCountryCodeToggleKeydown=y,e.__sfCountryCodeDocClick=p,e.__sfCountryCodeItemClick=g,e.__sfCountryCodeItemKeydown=j,e.__sfCountryCodeFocusOut=_,e.__sfCountryCodeInput=v,e.__sfCountryCodePaste=M,e.__sfCountryCodeInputKeydown=A,e.__sfCountryReleaseReset=(0,r.z)(n,()=>{const a=b.get(n);a&&fe(e,a,"reset"),V(e,!1),S(e,n)}),e.__sfCountryRequiredObserver=new MutationObserver(()=>{S(e,n),x(e,n)}),e.__sfCountryRequiredObserver.observe(e,{attributes:!0,attributeFilter:["required","aria-label","aria-labelledby","aria-describedby","id"],childList:!0,characterData:!0,subtree:!0}),e.dataset[H]="1",le(e),e.__sfCountryViewport?.(e.classList.contains("open"))}function ce(e){if(!e||"function"!=typeof e.__sfCountryCodeInput)return;const{input:a,toggle:s,items:t}=N(e);e.__sfCountryReleaseReset?.(),delete e.__sfCountryReleaseReset,e.__sfCountryRequiredObserver?.disconnect(),delete e.__sfCountryRequiredObserver,e.__sfCountryViewport?.(!1),delete e.__sfCountryViewport,e.querySelectorAll("img[data-flag-src]").forEach(e=>E?.unobserve(e)),s&&e.__sfCountryCodeToggleClick&&s.removeEventListener("click",e.__sfCountryCodeToggleClick),s&&e.__sfCountryCodeToggleKeydown&&s.removeEventListener("keydown",e.__sfCountryCodeToggleKeydown),e.__sfCountryCodeDocClick&&document.removeEventListener("click",e.__sfCountryCodeDocClick),t.forEach(a=>{e.__sfCountryCodeItemKeydown&&a.removeEventListener("keydown",e.__sfCountryCodeItemKeydown),e.__sfCountryCodeItemClick&&a.removeEventListener("click",e.__sfCountryCodeItemClick)}),e.__sfCountryCodeFocusOut&&e.removeEventListener("focusout",e.__sfCountryCodeFocusOut),a&&e.__sfCountryCodeInput&&a.removeEventListener("input",e.__sfCountryCodeInput),a&&e.__sfCountryCodePaste&&a.removeEventListener("paste",e.__sfCountryCodePaste),a&&e.__sfCountryCodeInputKeydown&&a.removeEventListener("keydown",e.__sfCountryCodeInputKeydown),e.__sfCountryMask&&window.SF?.Mask?.destroy?.(e.__sfCountryMask),delete e.__sfCountryCodeToggleClick,delete e.__sfCountryCodeToggleKeydown,delete e.__sfCountryCodeDocClick,delete e.__sfCountryCodeItemClick,delete e.__sfCountryCodeItemKeydown,delete e.__sfCountryCodeFocusOut,delete e.__sfCountryCodeInput,delete e.__sfCountryCodePaste,delete e.__sfCountryCodeInputKeydown,delete e.__sfCountryMask,delete e.__sfCountryMaskToken,delete e.__sfCountrySelected,delete e.__sfCountryConfig,delete e.__sfCountryOptions,delete e.dataset[H]}function he(e=document){e.querySelectorAll(p).forEach(e=>{e.closest("sf-country-code")||ue(e)})}function ke(e,a={}){const s=e instanceof HTMLElement?e.closest(p)||e:null;if(!s)return!1;if(s.__sfCountryCodeSetState&&s.__sfCountryCodeSetState!==ke)return s.__sfCountryCodeSetState(s,a);const{input:t}=N(s);if(!t)return!1;if(Object.prototype.hasOwnProperty.call(a,"disabled")){const e=A(a.disabled,!1);t.disabled=e,s.classList.toggle("disabled",e),le(s)}if(Object.prototype.hasOwnProperty.call(a,"active")&&V(s,A(a.active,!1)),Object.prototype.hasOwnProperty.call(a,"open")&&V(s,A(a.open,!1)),Object.prototype.hasOwnProperty.call(a,"value")&&(t.value=String(a.value??""),t.dispatchEvent(new Event("input",{bubbles:!0})),t.dispatchEvent(new Event("change",{bubbles:!0}))),Object.prototype.hasOwnProperty.call(a,"iso2")){const e=X(s,a.iso2);e&&fe(s,e,"state")}if(Object.prototype.hasOwnProperty.call(a,"dialCode")){const e=X(s,"",a.dialCode);e&&fe(s,e,"state")}return!0}class ye extends n.y{static componentName="CountryCode";html=null;constructor(e){super(e);const{size:a="1",label:s="",required:t=!1,name:n="",form:o="",hint:i="",value:l="",placeholder:r="+7(___)___-__-__",disabled:m=!1,active:d=!1,open:u=d,countries:c=[],locale:h="ru",useMask:k=!1,useCountryMasks:y=!0,showCode:p=!0,maskStyle:H="native",multiCountry:g=!0,iso2:E="",dialCode:P="",maskPattern:C="",flagBase:b="",lazyFlags:R=!0,showMaskPlaceholder:j=!1,maskPlaceholderChar:w="_",maxItems:x=0}=this.params||{},S=this.attrs.class||this.attrs.className;this.template=document.createElement("label"),this.id&&(this.template.id=this.id),this.template.classList.add("sf-country-code",`sf-country-code--size-${(0,f.id)(a,"sf-country-code")}`),A(m)&&this.template.classList.add("disabled"),A(u)&&this.template.classList.add("open"),S&&this.template.classList.add(...`${S}`.split(" ").filter(Boolean)),this.template.dataset.locale=String(h),this.template.dataset.useMask=String(A(k,!1)),this.template.dataset.useCountryMasks=String(A(y,!0)),this.template.dataset.showCode=String(A(p,!0)),this.template.dataset.maskStyle="brackets"===String(H).toLowerCase()?"brackets":"native",this.template.dataset.multiCountry=String(A(g,!0)),this.template.dataset.lazyFlags=String(A(R,!0)),this.template.dataset.showMaskPlaceholder=String(A(j,!1)),this.template.dataset.maskPlaceholderChar=String(w||"_"),E&&(this.template.dataset.iso2=L(E)),P&&(this.template.dataset.dialCode=String(P)),C&&(this.template.dataset.maskPattern=String(C)),b&&(this.template.dataset.flagBase=String(b).replace(/\/$/,"")),Number(x)>0&&(this.template.dataset.maxItems=String(Number(x)));const _=document.createElement("span");_.classList.add("sf-country-code-label");const v=document.createElement("span");if(v.classList.add("sf-country-code-text"),v.textContent=String(s),_.append(v),A(t,!1)){const e=document.createElement("span");e.classList.add("sf-country-code-required"),e.textContent="*",_.append(e)}const M=document.createElement("span");M.classList.add("sf-country-code-field");const I=document.createElement("span");I.classList.add("sf-country-code-left");const B=document.createElement("div");B.classList.add("sf-country-code-flag-icon"),B.setAttribute("aria-hidden","true");const $=document.createElement("i");$.classList.add("sf-icon"),$.textContent=A(u)?"expand_less":"expand_more",I.append(B,$);const N=document.createElement("input");N.type="tel",N.name=String(n),o&&N.setAttribute("form",String(o)),N.required=A(t,!1),N.defaultValue=String(l??""),N.placeholder=String(r??""),N.disabled=A(m,!1),M.append(I,N),this.template.append(_,M);const O=J(c,h,x);if(O.length){const e=document.createElement("span");e.classList.add("sf-country-code-list");const a=document.createElement("span");a.classList.add("sf-country-code-items","flex","flex-col"),O.forEach(e=>{const s=document.createElement("span");s.classList.add("sf-country-code-item"),e?.iso2&&(s.dataset.iso2=L(e.iso2)),(e?.dialCode||e?.code)&&(s.dataset.code=String(e.dialCode||e.code)),void 0!==e?.maskPattern&&(s.dataset.maskPattern=String(e.maskPattern||""));const t=F({iso2:e?.iso2,flagEmoji:e?.flagEmoji||""},{flagBase:this.template.dataset.flagBase||T(),lazyFlags:A(this.template.dataset.lazyFlags,!0)},!0),n=document.createElement("span");if(e?.label)n.textContent=String(e.label);else{const a=e?.nameRu||e?.nameEn||e?.dialCode||"",s=e?.dialCode||e?.code||"";n.textContent=s?`${a} (${s})`:a}s.append(t,n),this.applyLayoutUtilities(s,".sf-country-code .sf-country-code-item"),this.applyLayoutUtilities(t,".sf-country-code .sf-country-code-flag"),a.append(s)}),e.append(a),this.template.append(e)}if(i){const e=document.createElement("span");e.classList.add("sf-country-code-hint"),e.textContent=String(i),this.template.append(e)}this.applyLayoutUtilities(this.template,".sf-country-code"),this.applyLayoutUtilities(_,".sf-country-code .sf-country-code-label"),this.applyLayoutUtilities(M,".sf-country-code .sf-country-code-field"),this.applyLayoutUtilities(I,".sf-country-code .sf-country-code-left"),this.applyLayoutUtilities(N,".sf-country-code .sf-country-code-field input"),this.applyLayoutUtilities(B,".sf-country-code .sf-country-code-flag-icon")}init(){ue(this.template,{maskPattern:this.params?.maskPattern||""})}destroyInternal(){ce(this.template)}}ye.utilityMap=i,(0,o.A)("CountryCode",ye),"undefined"!=typeof window&&(window.SF=window.SF||{},window.SF.CountryCode=window.SF.CountryCode||{},window.SF.CountryCode.setState=ke),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",()=>he()):he();new MutationObserver(e=>{e.forEach(e=>{e.removedNodes.forEach(e=>{if(!(e instanceof Element))return;const a=[...e.querySelectorAll(p)];e.matches(p)&&a.unshift(e);for(const e of a)e.isConnected||e.closest("sf-country-code")||ce(e)}),e.addedNodes.forEach(e=>{e instanceof Element&&(e.matches?.(p)&&!e.closest("sf-country-code")&&ue(e),he(e))})})}).observe(document.documentElement,{childList:!0,subtree:!0}),t()}catch(pe){t(pe)}})},"98e26702f55a"(e,a,s){function t(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function n({component:e="",kind:a="attribute",attribute:s="",from:n,to:o=null}={}){if(!n)return;const i=[e,a,s,n].join("|"),l=t(),r=l.get(i);if(r)r.count+=1;else if(l.set(i,{component:e,kind:a,attribute:s,from:n,to:o,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const t=e?`${e}: `:"",i="value"===a?`${s}="${n}"`:`${a} ${n}`;globalThis.console?.warn?.(`[SIMAI Framework] ${t}${i} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(s.d(a,{id:()=>r,vl:()=>m}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const e=globalThis.SF.deprecations||{};e.list=function(){return[...t().values()].map(e=>({...e}))},e.clear=function(){t().clear()},e.note=n,globalThis.SF.deprecations=e}const o=Object.freeze(["1/2","1","2"]),i=Object.freeze({"1/3":"1/2",3:"2"}),l=new Set;function r(e,a="field",s="1"){const t=String(e??"").trim().toLowerCase();if(o.includes(t))return t;if(Object.hasOwn(i,t)){const e=i[t];n({component:a,kind:"value",attribute:"size",from:t,to:e});const s=`${a}:${t}`;return l.has(s)||"undefined"==typeof console||(l.add(s),console.warn(`[SIMAI Framework] ${a}: size ${t} is retired for form fields; rendering size ${e}.`)),e}return s}function m(e,a){if(e?.classList)for(const[s,t]of Object.entries(i)){const t=`${a}--size-${s}`;e.classList.contains(t)&&e.classList.replace(t,`${a}--size-${r(s,a)}`)}}},"67eed2647f47"(e,a,s){s.d(a,{z:()=>o});const t=new WeakMap,n=new WeakSet;function o(e,a){const s=e.ownerDocument;n.has(s)||(s.addEventListener("reset",e=>{const a=e.target;if("FORM"!==a?.tagName)return;const s=Array.from(a.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of s)if(e.isConnected&&e.form===a)for(const a of t.get(e)||[])a()},0)},!0),n.add(s));let o=t.get(e);return o||t.set(e,o=new Set),o.add(a),()=>o.delete(a)}},"0ab12d47912a"(e,a,s){s.d(a,{y:()=>n});let t=null;function n(){const e=()=>window.SF?.Mask?.create?window.SF.Mask:null,a=e();return a?Promise.resolve(a):t||(t=new Promise(a=>{const s=[[window,"sf-mask-ready"],[window,"sf-loader-ready"],[window,"load"],[document,"DOMContentLoaded"]],n=()=>{const o=e();o&&(s.forEach(([e,a])=>e.removeEventListener(a,n)),t=null,a(o))};s.forEach(([e,a])=>e.addEventListener(a,n))}),t)}},"58661bec99a6"(e,a,s){const t=function(e,a){if(e&&a)if("undefined"==typeof window||"function"!=typeof window.registerSfComponent){if("undefined"!=typeof window&&window.SF?.Loader?.registerComponent)window.SF.Loader.registerComponent(e,a);else if("undefined"!=typeof window){(window.SF_PENDING_COMPONENTS=window.SF_PENDING_COMPONENTS||[]).push([e,a])}}else window.registerSfComponent(e,a)};s.d(a,["A",0,t])},d7f974466839(e,a,s){s.d(a,{y:()=>t});class t{lifecycleName(){return this.componentName??this.constructor.componentName}constructor(e){this.props=e,this.id=e?.id,this.params=e?.param,this.attrs=e?.attrs||{},this.template=null,window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:beforeRender`,{detail:this}))}getUtilityMap(){return this.constructor.utilityMap||null}extractUtilityClasses(e){if(!Array.isArray(e))return[];const a=new Set;return e.forEach(e=>{if("string"!=typeof e)return;const s=e.match(/\(([^)]+)\)/g);s&&s.forEach(e=>{e.slice(1,-1).split(/\s+/).filter(Boolean).forEach(e=>{e.startsWith(".")&&e.length>1&&a.add(e.slice(1))})})}),Array.from(a)}applyLayoutUtilities(e,a){if(!e||!a)return;const s=this.getUtilityMap();if(!s||!s[a])return;this.extractUtilityClasses(s[a]).forEach(a=>e.classList.add(a))}render(){return this.html=this.template,"function"==typeof this.init&&this.init(),this.html&&window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:render`,{detail:this})),this.html}destroy(){this.destroyInternal?.(),this.props=null,this.id=null,this.params=null,this.template=null,this.html&&(this.html.remove(),this.html=null),window.dispatchEvent(new CustomEvent(`${this.lifecycleName()}:destroy`,{detail:this}))}destroyInternal(){}}},"2a25b3f4fc15"(e,a,s){s.a(e,async(e,a)=>{try{var t=s("c614c5e30b0d"),n=s("0d662e4d7d63"),o=s("c0450586011d"),i=s("fbe0570fcc69"),l=s("98e26702f55a"),r=s("788779012d8a"),m=e([n,o,i,r]);[n,o,i,r]=m.then?(await m)():m;var d=s.n(i);const f=".sf-country-code",u=Array.isArray(t?.items)?t.items:[];class c extends(d()){static get props(){return{size:{default:"1"},label:{default:""},required:{type:Boolean,default:!1},name:{default:""},form:{default:""},hint:{default:""},value:{default:""},placeholder:{default:"+7(___)___-__-__"},disabled:{type:Boolean,default:!1},open:{type:Boolean,default:!1},locale:{default:""},useMask:{type:Boolean,default:!1},useCountryMasks:{type:Boolean,default:!0},showCode:{type:Boolean,default:!0},maskStyle:{default:"native"},multiCountry:{type:Boolean,default:!0},iso2:{default:""},dialCode:{default:""},maskPattern:{default:""},flagBase:{default:""},lazyFlags:{type:Boolean,default:!0},showMaskPlaceholder:{type:Boolean,default:!1},maskPlaceholderChar:{default:"_"},maxItems:{type:Number,default:0}}}constructor(){super(),this._countries=null,this._boundRoot=null,this._renderAttributes=new Set}get size(){return(0,l.id)(this.getAttribute("size")||"1","sf-country-code")}get label(){return this.getAttribute("label")||""}get required(){return this.getBooleanAttr("required",!1)}get hint(){return this.getAttribute("hint")||""}get value(){return this.getAttribute("value")||""}get placeholder(){return this.getAttribute("placeholder")||"+7(___)___-__-__"}get disabled(){return this.getBooleanAttr("disabled",!1)}get open(){return this.getBooleanAttr("open",!1)||this.getBooleanAttr("active",!1)}get locale(){return"ru"===String(this.getAttribute("locale")||(0,n.pageLanguage)(this)).toLowerCase()?"ru":"en"}get useMask(){return this.getBooleanAttr("use-mask",!1)}get useCountryMasks(){return this.getBooleanAttr("use-country-masks",!0)}get showCode(){return this.getBooleanAttr("show-code",!0)}get maskStyle(){return"brackets"===String(this.getAttribute("mask-style")||"native").toLowerCase()?"brackets":"native"}get multiCountry(){return this.getBooleanAttr("multi-country",!0)}get iso2(){return(0,o.Xx)(this.getAttribute("iso2"))}get dialCode(){return String(this.getAttribute("dial-code")||"").trim()}get maskPattern(){return String(this.getAttribute("mask-pattern")||"").trim()}get flagBase(){return String(this.getAttribute("flag-base")||"").trim()||(0,o.Dk)()}get lazyFlags(){return this.getBooleanAttr("lazy-flags",!0)}get showMaskPlaceholder(){return this.getBooleanAttr("show-mask-placeholder",!1)}get maskPlaceholderChar(){return String(this.getAttribute("mask-placeholder-char")||"_")}get maxItems(){return Math.trunc(this.getNumberAttr("max-items",0))}get countries(){return(0,o.Ue)(this._countries,this.locale,this.maxItems)}set countries(e){this._countries=Array.isArray(e)?e:null,this.requestComponentUpdate("countries")}templateContext(){const e=this.getPropsContext(),a=this._boundRoot,s=a&&!this._renderAttributes.has("open")&&!this._renderAttributes.has("active"),t=a&&!this._renderAttributes.has("disabled");return this.createTemplateContext({...e,open:s?a.classList.contains("open"):this.open,disabled:t?!!a.querySelector("input")?.disabled||a.classList.contains("disabled"):this.disabled,countries:this.countries.length?this.countries:(0,o.Ue)(u,this.locale,this.maxItems),locale:this.locale,maskStyle:this.maskStyle,iso2:this.iso2,flagBase:this.flagBase,maxItems:this.maxItems})}onDisconnected(){this._boundRoot&&((0,o._i)(this._boundRoot),this._boundRoot=null)}beforeRender(e=[]){this._renderAttributes=new Set(e)}afterRender(e){if("function"==typeof e)return super.afterRender(e);this._boundRoot&&((0,o._i)(this._boundRoot),this._boundRoot=null),this._boundRoot=this.querySelector(f),this._boundRoot&&(0,o.nD)(this._boundRoot,{resetCountry:this._renderAttributes.has("iso2")||this._renderAttributes.has("dial-code"),countries:this.countries,maskPattern:this.maskPattern})}template(){return(0,r.o)(this.templateContext())}get state(){const e=this.querySelector(f),a=e?.querySelector?.(".sf-country-code-field input")||null;return{value:a?.value||"",iso2:e?.dataset?.iso2||"",dialCode:e?.dataset?.dialCode||"",open:e?.classList?.contains("open")||!1,disabled:e?.classList?.contains("disabled")||!1}}setState(e={}){const a=this.querySelector(f);return(0,o.nK)(a,e)}}c.define("sf-country-code"),a()}catch(e){a(e)}})},"788779012d8a"(e,a,s){s.a(e,async(e,t)=>{try{s.d(a,{o:()=>r});var n=s("ddf1cdb42ecc"),o=e([n]),i=o.then?(await o)():o;n=i[0];function l(e,a=""){const s=String(e?.iso2||"").trim().toLowerCase(),t=e?.flagEmoji||"",o=s&&a?`${a}/${s}.svg`:"";return o?n.html`
2
2
  <img
3
3
  alt=${e?.iso2?`${e.iso2} flag`:"flag"}
4
4
  decoding="async"
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";var t={"98e26702f55a"(t,e,a){function s(){const t=globalThis.SF=globalThis.SF||{};return t.__deprecationNotes instanceof Map||Object.defineProperty(t,"__deprecationNotes",{value:new Map,configurable:!0}),t.__deprecationNotes}function n({component:t="",kind:e="attribute",attribute:a="",from:n,to:r=null}={}){if(!n)return;const i=[t,e,a,n].join("|"),o=s(),l=o.get(i);if(l)l.count+=1;else if(o.set(i,{component:t,kind:e,attribute:a,from:n,to:r,count:1}),function(){const t=globalThis.document?.documentElement;return"warn"===t?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const s=t?`${t}: `:"",i="value"===e?`${a}="${n}"`:`${e} ${n}`;globalThis.console?.warn?.(`[Simai Framework] ${s}${i} is a legacy name${r?`; write ${r}`:""}. See contracts/changes/journal.json.`)}}if(a.d(e,{id:()=>l}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const t=globalThis.SF.deprecations||{};t.list=function(){return[...s().values()].map(t=>({...t}))},t.clear=function(){s().clear()},t.note=n,globalThis.SF.deprecations=t}const r=Object.freeze(["1/2","1","2"]),i=Object.freeze({"1/3":"1/2",3:"2"}),o=new Set;function l(t,e="field",a="1"){const s=String(t??"").trim().toLowerCase();if(r.includes(s))return s;if(Object.hasOwn(i,s)){const t=i[s];n({component:e,kind:"value",attribute:"size",from:s,to:t});const a=`${e}:${s}`;return o.has(a)||"undefined"==typeof console||(o.add(a),console.warn(`[Simai Framework] ${e}: size ${s} is retired for form fields; rendering size ${t}.`)),t}return a}},b9b65955223a(t,e,a){a.a(t,async(t,e)=>{try{var s=a("fbe0570fcc69"),n=a("98e26702f55a"),r=a("77b2f4107e3b"),i=a("5c1dc214bb5e"),o=a("0d662e4d7d63"),l=t([s,r,i,o]);[s,r,i,o]=l.then?(await l)():l;var u=a.n(s),h=a.n(i);const c=/^(\d{4})-(\d{2})-(\d{2})$/,d=18;let p=0;function g(t){return String(t).padStart(2,"0")}function m(t){return`${t.getFullYear()}-${g(t.getMonth()+1)}-${g(t.getDate())}`}function f(t,e="YYYY.MM.DD"){if(!t)return"";const a={YYYY:String(t.getFullYear()),YY:String(t.getFullYear()).slice(-2),MM:g(t.getMonth()+1),DD:g(t.getDate())};return String(e||"YYYY.MM.DD").replace(/YYYY|YY|MM|DD/g,t=>a[t]||t)}function b(t){return t instanceof Date&&!Number.isNaN(t.getTime())}function y(t){if(!t)return null;const e=String(t).match(c);if(!e)return null;const[,a,s,n]=e,r=new Date(Number(a),Number(s)-1,Number(n));return r.getFullYear()!==Number(a)||r.getMonth()!==Number(s)-1||r.getDate()!==Number(n)?null:r}function D(t,e="DD.MM.YYYY"){if(!t)return null;if(t instanceof Date)return b(t)?new Date(t.getFullYear(),t.getMonth(),t.getDate()):null;const a=String(t).trim(),s=y(a);if(s)return s;const n=a.match(/\d+/g),r=String(e||"DD.MM.YYYY").match(/YYYY|YY|MM|DD/g);if(!n||!r||n.length<3||r.length<3)return null;const i={};r.slice(0,3).forEach((t,e)=>{i[t]=Number(n[e])});let o=i.YYYY;!o&&i.YY&&(o=i.YY+2e3);const l=i.MM,u=i.DD;if(!o||!l||!u)return null;const h=new Date(o,l-1,u);return h.getFullYear()!==o||h.getMonth()!==l-1||h.getDate()!==u?null:h}function v(t,e=0){const a=(0,s.toNumber)(t,e);return Number.isFinite(a)?Math.max(0,Math.min(11,a)):e}function k(t,e){return t&&e&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function w(t,e){if(!t||!e)return 0;return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function S(t,e){const a=new Date(t.getFullYear(),t.getMonth()+e,1),s=new Date(a.getFullYear(),a.getMonth()+1,0).getDate();return a.setDate(Math.min(t.getDate(),s)),a}function M(t,e,a){return!!(t&&e&&a)&&(w(t,e)>0&&w(t,a)<0)}function $(t="",e=null){const a=String(t||"").trim();return a||(0,o.pageLocale)(e??globalThis.document?.documentElement??null)}function x(t=""){const e=String(t||"");return e?`${e.charAt(0).toLocaleUpperCase()}${e.slice(1)}`:""}function P(t,e){try{return x(new Intl.DateTimeFormat(e,{month:"long"}).format(new Date(2026,t,1)))}catch{return String(t+1)}}function Y(t,e){try{return new Intl.DateTimeFormat(e,{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(t)}catch{return m(t)}}function A(t,e=1){const a=new Date(2026,0,4);return Array.from({length:7},(s,n)=>{const r=new Date(a);r.setDate(a.getDate()+(e+n)%7);try{return new Intl.DateTimeFormat(t,{weekday:"short"}).format(r)}catch{return String((e+n)%7)}})}const V=["today","yesterday","last-7-days","last-30-days","this-week","this-month","last-month"];function _(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function F(t,e,a=1){const s=new Date(e.getFullYear(),e.getMonth(),e.getDate());switch(t){case"today":return[s,s];case"yesterday":return[_(s,-1),_(s,-1)];case"last-7-days":return[_(s,-6),s];case"last-30-days":return[_(s,-29),s];case"this-week":return[_(s,-(s.getDay()-a+7)%7),s];case"this-month":return[new Date(s.getFullYear(),s.getMonth(),1),s];case"last-month":return[new Date(s.getFullYear(),s.getMonth()-1,1),new Date(s.getFullYear(),s.getMonth(),0)];default:return null}}const T={en:{previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",presets:"Quick ranges",customRange:"Custom range",preset_today:"Today",preset_yesterday:"Yesterday",preset_last7Days:"Last 7 days",preset_last30Days:"Last 30 days",preset_thisWeek:"This week",preset_thisMonth:"This month",preset_lastMonth:"Last month"},ru:{previousMonth:"Предыдущий месяц",nextMonth:"Следующий месяц",previousYears:"Предыдущие годы",nextYears:"Следующие годы",chooseMonth:"Выберите месяц",chooseYear:"Выберите год",presets:"Быстрый выбор",customRange:"Свой период",preset_today:"Сегодня",preset_yesterday:"Вчера",preset_last7Days:"Последние 7 дней",preset_last30Days:"Последние 30 дней",preset_thisWeek:"Эта неделя",preset_thisMonth:"Этот месяц",preset_lastMonth:"Прошлый месяц"}};class C extends(u()){constructor(){super(),this._input=null,this._documentClickHandler=this.handleDocumentClick.bind(this),this._documentKeydownHandler=this.handleDocumentKeydown.bind(this),this._viewportHandler=this.positionPanel.bind(this),this._focusCalendarOnOpen=!1,this._focusDateAfterRender=!1,this._panelId="sf-datepicker-panel-"+ ++p,this.state={openAbove:!1,yearPageStart:null,activeDate:""},this.refs={input:this.createRef(),datePickerRoot:this.createRef(),datePickerPanel:this.createRef()}}static get props(){return{templateName:{attribute:"template",default:"default"},value:{default:""},date:{default:""},startValue:{attribute:"start-value",default:""},endValue:{attribute:"end-value",default:""},maxDate:{default:""},minDate:{default:""},range:{type:Boolean,default:!1},month:{type:Number,default:null},year:{type:Number,default:null},context:{default:""},weekStart:{type:Number,default:null},locale:{default:""},format:{default:"DD.MM.YYYY"},rootClass:{default:""},closeOnSelect:{type:Boolean,default:!0},input:{type:Boolean,default:!0},open:{type:Boolean,default:!1},portal:{type:Boolean,default:!0},inputType:{attribute:"input-type",default:"bordered"},size:{default:"1"},inputSize:{attribute:"input-size",default:"1"},inputName:{attribute:"input-name",default:""},name:{attribute:"name",default:""},placeholder:{default:""},label:{default:""},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},iconStart:{type:String,attribute:"icon-start",default:null},leftIcon:{attribute:"left-icon",default:"calendar_today"},inputRootClass:{attribute:"input-root-class",default:""},mask:{type:Boolean,default:!1},maskPattern:{attribute:"mask-pattern",default:""},maskLazy:{attribute:"mask-lazy",default:!1},maskPlaceholderChar:{attribute:"mask-placeholder-char",default:"_"},maskOptions:{attribute:"mask-options",default:""},presets:{default:""},preset:{default:""}}}connectedCallback(){this.upgradeProperty("value"),this.upgradeProperty("presets"),super.connectedCallback()}upgradeProperty(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const e=this[t];delete this[t],this[t]=e}get componentName(){return"datepicker"}get templateName(){return this.getAttribute("template")||"default"}get selectedDate(){return D(this.date,this.format)}get primaryDate(){const t=this.activePreset;return t?t.to:this.selectedDate||this.startDate}get presets(){return this._presetList??(this.getAttribute("presets")||"")}set presets(t){if(Array.isArray(t))return this._presetList=t,void this.requestComponentUpdate("presets");this._presetList=null,this.setState({presets:t?String(t):""})}get preset(){return this.getAttribute("preset")||""}set preset(t){this.setState({preset:t?String(t):""})}get presetItems(){if(!this.range)return[];const t=Array.isArray(this.presets)?this.presets:String(this.presets).split(/[\s,]+/).filter(Boolean),e=new Date,a=this.setMinDate(),s=this.setMaxDate();return t.map(t=>{const n="string"==typeof t?{id:t,relative:t}:{...t};if(!n?.id)return null;let r=null;if(n.relative)r=F(n.relative,e,this.weekStart);else if(Array.isArray(n.range)){const t=D(n.range[0],this.format),e=D(n.range[1],this.format);t&&e&&(r=w(t,e)<=0?[t,e]:[e,t])}if(!r)return null;let[i,l]=r;a&&w(i,a)<0&&(i=a),s&&w(l,s)>0&&(l=s);const u=w(i,l)>0,h=n.label||(V.includes(n.id)?(0,o.pageText)(T,(c=n.id,`preset_${String(c).replace(/-([a-z0-9])/g,(t,e)=>e.toUpperCase())}`),this,"sf-datepicker"):n.id);var c;return{id:String(n.id),label:h,relative:n.relative||null,from:i,to:l,disabled:u,pressed:this.preset===String(n.id)}}).filter(Boolean)}get activePreset(){const t=this.preset;if(!t||!this.range)return null;const e=this.presetItems.find(e=>e.id===t);return e&&!e.disabled?e:null}get startDate(){return D(this.startValue,this.format)}get endDate(){return D(this.endValue,this.format)}get date(){return this.getAttribute("date")||this.getAttribute("value")||""}get value(){return this.range?[this.startValue,this.endValue]:this.date}set value(t){if(Array.isArray(t)){const[e="",a=""]=t;return void this.setState({date:e||"",startValue:e||"",endValue:a||""})}if(t&&"object"==typeof t){const e=t.start||t.startValue||t.date||"",a=t.end||t.endValue||"";return void this.setState({date:t.date||e||"",startValue:e,endValue:a})}this.setState({date:t?String(t):"",startValue:"",endValue:""})}setMaxDate(){return D(this.maxDate,this.format)}setMinDate(){return D(this.minDate,this.format)}get maxDate(){return this.getAttribute("max-date")||""}get minDate(){return this.getAttribute("min-date")||""}set date(t){this.setState({date:t?String(t):""})}get startValue(){const t=this.activePreset;return t?m(t.from):this.getAttribute("start-value")||""}set startValue(t){this.setState({startValue:t?String(t):""})}get endValue(){const t=this.activePreset;return t?m(t.to):this.getAttribute("end-value")||""}set endValue(t){this.setState({endValue:t?String(t):""})}get range(){return this.getBooleanAttr("range",!1)}get input(){return this.getBooleanAttr("input",!0)}get open(){return this.getBooleanAttr("open",!1)}get portal(){return this.getBooleanAttr("portal",!0)}get inputType(){return this.getAttribute("input-type")||"bordered"}get size(){return(0,n.id)(this.getAttribute("size")||this.getAttribute("input-size")||"1","sf-datepicker")}get inputSize(){return this.size}get inputName(){return this.getAttribute("input-name")||this.getAttribute("name")||""}get placeholder(){return this.getAttribute("placeholder")||""}get label(){return this.getAttribute("label")||""}get disabled(){return this.getBooleanAttr("disabled",!1)}get required(){return this.getBooleanAttr("required",!1)}get closeOnSelect(){return this.getBooleanAttr("close-on-select",!0)}get leftIcon(){return this.hasAttribute("icon-start")?this.getAttribute("icon-start"):this.getAttribute("left-icon")||"calendar_today"}get iconStart(){return this.leftIcon}get inputRootClass(){return this.getAttribute("input-root-class")||""}get mask(){return this.getBooleanAttr("mask",!1)}get maskPattern(){return this.getAttribute("mask-pattern")||this.formatToMask(this.format)}get maskLazy(){return!!this.hasAttribute("mask-lazy")&&this.getBooleanAttr("mask-lazy",!1)}get maskPlaceholderChar(){return this.getAttribute("mask-placeholder-char")||"_"}get maskOptions(){return this.getAttribute("mask-options")||""}get year(){const t=this.primaryDate,e=t?t.getFullYear():(new Date).getFullYear();return this.hasAttribute("year")?this.getNumberAttr("year",e):e}set year(t){this.setState({year:null==t||""===t?"":String((0,s.toNumber)(t,(new Date).getFullYear()))})}get month(){const t=this.primaryDate,e=t?t.getMonth():(new Date).getMonth();return this.hasAttribute("month")?v(this.getAttribute("month"),e):e}set month(t){this.setState({month:null==t||""===t?"":String(v(t,(new Date).getMonth()))})}get contextMode(){return this.getEnumAttr("context",["month","year",""],"")}get weekStart(){if(this.hasAttribute("week-start")){const t=this.getNumberAttr("week-start",1);return Number.isInteger(t)&&t>=0&&t<=7?t%7:1}try{const t=new Intl.Locale(this.locale),e="function"==typeof t.getWeekInfo?t.getWeekInfo():t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}get locale(){return $(this.getAttribute("locale"),this)}get format(){return this.getAttribute("format")||"DD.MM.YYYY"}get formattedValue(){return f(this.selectedDate,this.format)}get formattedStartValue(){return f(this.startDate,this.format)}get formattedEndValue(){return f(this.endDate,this.format)}get displayValue(){return this.range?this.formattedStartValue&&this.formattedEndValue?`${this.formattedStartValue} - ${this.formattedEndValue}`:this.formattedStartValue||this.formattedEndValue||"":this.formattedValue}get displayDate(){return new Date(this.year,this.month,1)}get isRtl(){return"rtl"===(this.closest("[dir]")?.getAttribute("dir")||document.documentElement?.dir)}get labels(){return t=this,Object.fromEntries(["previousMonth","nextMonth","previousYears","nextYears","chooseMonth","chooseYear","presets","customRange"].map(e=>[e,(0,o.pageText)(T,e,t,"sf-datepicker")]));var t}get weekdays(){return A(this.locale,this.weekStart)}get calendarLabel(){try{return new Intl.DateTimeFormat(this.locale,{month:"long",year:"numeric"}).format(this.displayDate)}catch{return`${this.month+1}.${this.year}`}}get activeDate(){const t=y(this.state.activeDate)||this.primaryDate||this.displayDate,e=this.setMinDate(),a=this.setMaxDate();return e&&w(t,e)<0?e:a&&w(t,a)>0?a:t}get normalizedRange(){const t=this.startDate,e=this.endDate;return t&&e?w(t,e)<=0?{startDate:t,endDate:e}:{startDate:e,endDate:t}:{startDate:t,endDate:e}}get days(){const t=(new Date(this.year,this.month,1).getDay()-this.weekStart+7)%7,e=new Date(this.year,this.month,1-t),{startDate:a,endDate:s}=this.normalizedRange,n=Boolean(this.startValue&&this.endValue),r=this.setMinDate(),i=this.setMaxDate(),o=this.activeDate,l=new Date;return Array.from({length:42}).map((t,u)=>{const h=new Date(e.getFullYear(),e.getMonth(),e.getDate()+u),c=h.getTime(),d=Boolean(r&&c<r.getTime()||i&&c>i.getTime());return{date:h,value:m(h),formattedValue:f(h,this.format),label:Y(h,this.locale),day:h.getDate(),today:k(h,l),currentMonth:h.getMonth()===this.month,weekend:[0,6].includes(h.getDay()),disabled:d,selected:this.range?k(h,a)||k(h,s):k(h,this.selectedDate),rangeStart:this.range&&n&&k(h,a),rangeEnd:this.range&&n&&k(h,s),rangeSelected:this.range&&n&&M(h,a,s),tabIndex:!d&&k(h,o)?0:-1}})}get months(){const t=this.setMinDate(),e=this.setMaxDate(),a=t?new Date(t.getFullYear(),t.getMonth(),1):null,s=e?new Date(e.getFullYear(),e.getMonth(),1):null;return Array.from({length:12}).map((t,e)=>{const n=new Date(this.year,e,1).getTime(),r=Boolean(a&&n<a.getTime()||s&&n>s.getTime());return{index:e,label:P(e,this.locale),selected:e===this.month,disabled:r}})}get years(){const t=this.setMinDate(),e=this.setMaxDate(),a=this.yearPageStart;return Array.from({length:d}).map((s,n)=>{const r=a+n;return{year:r,disabled:Boolean(t&&r<t.getFullYear()||e&&r>e.getFullYear()),selected:r===this.year}})}get yearPageStart(){return this.state.yearPageStart??this.getYearPageStart(this.year)}get yearPageEnd(){return this.yearPageStart+d-1}getYearPageStart(t=this.year){const e=(0,s.toNumber)(t,(new Date).getFullYear());return e-e%d}formatToMask=t=>{let e=String(t).replace(/[A-Za-z]/g,"0");return this.range&&(e+=` - ${e}`),e};setContext(t=""){return this.setState({context:t||""}),this}toggleContext(t){const e=this.contextMode===t?"":t,a={context:e};return"year"===e&&(a.yearPageStart=this.getYearPageStart(this.year)),this.setState(a),this}shiftYearPage(t=1){return this.set({yearPageStart:this.yearPageStart+d*t}),this}shiftMonth(t=1){const e=new Date(this.year,this.month+t,1),a=this.setMinDate(),s=this.setMaxDate();return a&&e<new Date(a.getFullYear(),a.getMonth(),1)||s&&e>new Date(s.getFullYear(),s.getMonth(),1)||(this.setState({year:e.getFullYear(),month:e.getMonth(),context:""}),this.set({activeDate:m(e)})),this}setActiveDate(t){const e=y(t);return e&&this.state.activeDate!==t?(this.set({activeDate:m(e)}),this):this}moveActiveDate(t){const e=new Date(this.activeDate);e.setDate(e.getDate()+t);const a=this.setMinDate(),s=this.setMaxDate();return a&&w(e,a)<0||s&&w(e,s)>0||(this._focusDateAfterRender=!0,this.setState({year:e.getFullYear(),month:e.getMonth(),context:""}),this.set({activeDate:m(e)})),this}openPanel({focusCalendar:t=!1}={}){return this.disabled?this:(this._focusCalendarOnOpen=t,this.state.activeDate||this.set({activeDate:m(this.activeDate)}),this.open?(this.positionPanel(),this):(this.setState({open:!0}),this))}closePanel({restoreFocus:t=!1}={}){return this.open?(this.setState({open:!1,context:""}),t&&requestAnimationFrame(()=>this._input?.focus?.()),this):this}togglePanel(){return this.open?this.closePanel():this.openPanel()}handleInputClick(t){t?.preventDefault?.(),t?.stopPropagation?.(),this.openPanel()}handleInputKeydown(t){["ArrowDown","Enter"," "].includes(t.key)&&(t.preventDefault(),this.openPanel({focusCalendar:!0}))}handleDayKeydown(t,e){const a=this.isRtl?-1:1,s={ArrowLeft:-a,ArrowRight:a,ArrowUp:-7,ArrowDown:7};if(Object.prototype.hasOwnProperty.call(s,t.key))return t.preventDefault(),void this.moveActiveDate(s[t.key]);if("Home"===t.key||"End"===t.key){t.preventDefault();const a=((e?.date||this.activeDate).getDay()-this.weekStart+7)%7;return void this.moveActiveDate("Home"===t.key?-a:6-a)}if("PageUp"===t.key||"PageDown"===t.key){t.preventDefault();const e="PageUp"===t.key?-1:1;let a=S(this.activeDate,e);const s=this.setMinDate(),n=this.setMaxDate();s&&w(a,s)<0&&(a=s),n&&w(a,n)>0&&(a=n),this._focusDateAfterRender=!0,this.setState({year:a.getFullYear(),month:a.getMonth()}),this.set({activeDate:m(a)})}}handlePanelClick(t){t?.stopPropagation?.()}handleDocumentClick(t){if(!this.open)return;const e=t.target;this.contains(e)||this.refs.datePickerPanel.value?.contains?.(e)||this.closePanel()}handleDocumentKeydown(t){this.open&&"Escape"===t.key&&(t.preventDefault(),this.contextMode?this.setContext(""):(this.closePanel(),requestAnimationFrame(()=>this._input?.focus?.())))}syncOverlayListeners(){if(this.input&&this.open)return document.addEventListener("click",this._documentClickHandler),void document.addEventListener("keydown",this._documentKeydownHandler);this.removeOverlayListeners()}removeOverlayListeners(){document.removeEventListener("click",this._documentClickHandler),document.removeEventListener("keydown",this._documentKeydownHandler),this.stopPanelPosition(),window.removeEventListener("resize",this._viewportHandler),document.removeEventListener("scroll",this._viewportHandler,!0),window.visualViewport?.removeEventListener("resize",this._viewportHandler),window.visualViewport?.removeEventListener("scroll",this._viewportHandler)}positionPanel(){const t=this.refs.datePickerPanel.value,e=this._input?.closest(".sf-input-field")||this._input||this.querySelector("sf-input");if(this.isConnected&&this.input&&this.portal&&this.open&&t?.isConnected&&e)return this._panelAnchor&&this._panelAnchorPanel===t&&this._panelAnchorTrigger===e?void this._panelAnchor.update():(this.stopPanelPosition(),Object.assign(t.style,{overflowY:"auto",zIndex:"var(--sf-z-index-9)"}),this._panelAnchorPanel=t,this._panelAnchorTrigger=e,void(this._panelAnchor=(globalThis.SF?.Position||h()).anchor(e,t,{side:"block-end",align:"start",onPosition:({side:t})=>{const e="block-start"===t;Boolean(this.state.openAbove)!==e&&this.set({openAbove:e})}})));this.stopPanelPosition()}stopPanelPosition(){this._panelAnchor?.stop(),this._panelAnchor=null,this._panelAnchorPanel=null,this._panelAnchorTrigger=null}selectDate(t){return!t?.date||t.disabled?this:this.range?(this.selectRangeDate(t),this):(this.setState({year:t.date.getFullYear(),month:t.date.getMonth(),date:t.value,context:""}),this.set({activeDate:t.value}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this)}selectRangeDate(t){if(!this.startValue||this.startValue&&this.endValue)return this.setState({year:t.date.getFullYear(),month:t.date.getMonth(),startValue:t.value,endValue:"",date:t.value,context:"",preset:""}),this.set({activeDate:t.value}),this.emitChange(),this;const e=this.startDate,a={year:t.date.getFullYear(),month:t.date.getMonth(),context:"",preset:""};return e&&w(t.date,e)<0?(a.startValue=t.value,a.endValue=this.startValue,a.date=t.value):(a.endValue=t.value,a.date=this.startValue),this.setState(a),this.set({activeDate:t.value}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this}choosePreset(t){if(!t||t.disabled)return this;const e=m(t.from),a=m(t.to);return this.setState({preset:t.id,startValue:e,endValue:a,date:e,year:t.to.getFullYear(),month:t.to.getMonth(),context:""}),this.set({activeDate:a}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this}chooseCustomRange(){return this.preset&&this.setState({preset:"",startValue:"",endValue:"",date:""}),this._focusDateAfterRender=!0,this.requestComponentUpdate("custom-range"),this}handlePresetKeydown(t){const e={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};if(!(t.key in e)&&"Home"!==t.key&&"End"!==t.key)return;const a=[...t.currentTarget.querySelectorAll("button:not(:disabled)")];if(!a.length)return;t.preventDefault();const s=a.indexOf(t.target);let n="Home"===t.key?0:"End"===t.key?a.length-1:s+e[t.key];!this.isRtl||"ArrowRight"!==t.key&&"ArrowLeft"!==t.key||(n=s-e[t.key]),n=(n+a.length)%a.length,a.forEach((t,e)=>t.setAttribute("tabindex",e===n?"0":"-1")),a[n].focus()}selectMonth(t){return!t||t.disabled||(this.setState({month:t.index,context:""}),this.set({activeDate:m(new Date(this.year,t.index,1))})),this}selectYear(t){if(!t||t.disabled)return this;const e={year:t.year,context:""},a=this.getClosestEnabledMonth(t.year,this.month);return a!==this.month&&(e.month=a),this.setState(e),this.set({activeDate:m(new Date(t.year,a,1))}),this}getClosestEnabledMonth(t,e){const a=this.setMinDate(),s=this.setMaxDate();return a&&t===a.getFullYear()&&e<a.getMonth()?a.getMonth():s&&t===s.getFullYear()&&e>s.getMonth()?s.getMonth():e}emitChange(){const t=this.startValue&&this.endValue?`${this.startValue}/${this.endValue}`:this.startValue||"",e=this.range?{value:[this.startValue,this.endValue],date:t,startValue:this.startValue,endValue:this.endValue,formattedValue:this.displayValue,formattedStartValue:this.formattedStartValue,formattedEndValue:this.formattedEndValue,isoValue:t,startIsoValue:this.startValue,endIsoValue:this.endValue,range:!0,format:this.format,preset:this.activePreset?this.activePreset.relative?{id:this.activePreset.id,relative:this.activePreset.relative}:{id:this.activePreset.id}:null}:{value:this.date,date:this.date,formattedValue:this.formattedValue,isoValue:this.date,range:!1,format:this.format};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:e})),this.dispatchEvent(new CustomEvent("sf-datepicker-change",{bubbles:!0,composed:!0,detail:e})),this.emitComponentEvent("change",e)}templateContext(){const t=this.getPropsContext();return this.createTemplateContext({...t,component:this,date:this.date,formattedValue:this.formattedValue,displayValue:this.displayValue,startValue:this.startValue,formattedStartValue:this.formattedStartValue,endValue:this.endValue,formattedEndValue:this.formattedEndValue,range:this.range,format:this.format,selectedDate:this.selectedDate,startDate:this.startDate,endDate:this.endDate,year:this.year,month:this.month,monthLabel:P(this.month,this.locale),calendarLabel:this.calendarLabel,labels:this.labels,weekdays:this.weekdays,panelId:this._panelId,previousIcon:this.isRtl?"chevron_right":"chevron_left",nextIcon:this.isRtl?"chevron_left":"chevron_right",context:this.contextMode,locale:this.locale,days:this.days,presetItems:this.presetItems,months:this.months,years:this.years,yearPageStart:this.yearPageStart,yearPageEnd:this.yearPageEnd,rootClass:this.getRootClass(),rootStyle:this.getRootStyle(),openAbove:Boolean(this.state.openAbove),input:this.input,open:this.open,portal:this.portal,inputType:this.inputType,inputSize:this.inputSize,inputName:this.inputName,placeholder:this.placeholder,label:this.label,disabled:this.disabled,required:this.required,leftIcon:this.leftIcon,iconStart:this.leftIcon,inputRootClass:this.inputRootClass,mask:this.mask,maskPattern:this.maskPattern,maskLazy:this.maskLazy,maskPlaceholderChar:this.maskPlaceholderChar,maskOptions:this.maskOptions})}template(){return(0,r.P)(this.templateContext())}afterRender(){this._input=this.refs.input?.value?.querySelector("input")||null,this._input&&(this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded",this.open?"true":"false"),this._input.setAttribute("aria-controls",this._panelId));const t=this.querySelector(".sf-datepicker-month-toggle button"),e=this.querySelector(".sf-datepicker-year-toggle button");t?.setAttribute("aria-expanded","month"===this.contextMode?"true":"false"),e?.setAttribute("aria-expanded","year"===this.contextMode?"true":"false"),this.syncOverlayListeners(),requestAnimationFrame(()=>{if(this.positionPanel(),this._focusCalendarOnOpen||this._focusDateAfterRender){const t=this.querySelector(`.sf-datepicker-day[data-date="${m(this.activeDate)}"]`);t?.focus?.(),this._focusCalendarOnOpen=!1,this._focusDateAfterRender=!1}})}onDisconnected(){this.removeOverlayListeners(),super.onDisconnected()}get data(){return{value:this.value,date:this.date,formattedValue:this.formattedValue,displayValue:this.displayValue,startValue:this.startValue,formattedStartValue:this.formattedStartValue,endValue:this.endValue,formattedEndValue:this.formattedEndValue,range:this.range,format:this.format,year:this.year,month:this.month,context:this.contextMode,maxDate:this.maxDate,minDate:this.minDate,locale:this.locale,input:this.input,open:this.open,portal:this.portal,mask:this.mask,maskPattern:this.maskPattern,maskOptions:this.maskOptions,presets:this.presetItems.map(({id:t,label:e,relative:a,disabled:s})=>({id:t,label:e,relative:a,disabled:s})),preset:this.preset}}}C.define("sf-datepicker"),e()}catch(E){e(E)}})},"77b2f4107e3b"(t,e,a){a.a(t,async(t,s)=>{try{a.d(e,{P:()=>b});var n=a("ddf1cdb42ecc"),r=a("5a8eddcd589d"),i=t([n,r]);[n,r]=i.then?(await i)():i;function o(...t){return t.flat().filter(Boolean).join(" ")}function l(t){return n.html`
1
+ (()=>{"use strict";var t={"98e26702f55a"(t,e,a){function s(){const t=globalThis.SF=globalThis.SF||{};return t.__deprecationNotes instanceof Map||Object.defineProperty(t,"__deprecationNotes",{value:new Map,configurable:!0}),t.__deprecationNotes}function n({component:t="",kind:e="attribute",attribute:a="",from:n,to:r=null}={}){if(!n)return;const i=[t,e,a,n].join("|"),o=s(),l=o.get(i);if(l)l.count+=1;else if(o.set(i,{component:t,kind:e,attribute:a,from:n,to:r,count:1}),function(){const t=globalThis.document?.documentElement;return"warn"===t?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const s=t?`${t}: `:"",i="value"===e?`${a}="${n}"`:`${e} ${n}`;globalThis.console?.warn?.(`[SIMAI Framework] ${s}${i} is a legacy name${r?`; write ${r}`:""}. See contracts/changes/journal.json.`)}}if(a.d(e,{id:()=>l}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const t=globalThis.SF.deprecations||{};t.list=function(){return[...s().values()].map(t=>({...t}))},t.clear=function(){s().clear()},t.note=n,globalThis.SF.deprecations=t}const r=Object.freeze(["1/2","1","2"]),i=Object.freeze({"1/3":"1/2",3:"2"}),o=new Set;function l(t,e="field",a="1"){const s=String(t??"").trim().toLowerCase();if(r.includes(s))return s;if(Object.hasOwn(i,s)){const t=i[s];n({component:e,kind:"value",attribute:"size",from:s,to:t});const a=`${e}:${s}`;return o.has(a)||"undefined"==typeof console||(o.add(a),console.warn(`[SIMAI Framework] ${e}: size ${s} is retired for form fields; rendering size ${t}.`)),t}return a}},b9b65955223a(t,e,a){a.a(t,async(t,e)=>{try{var s=a("fbe0570fcc69"),n=a("98e26702f55a"),r=a("77b2f4107e3b"),i=a("5c1dc214bb5e"),o=a("0d662e4d7d63"),l=t([s,r,i,o]);[s,r,i,o]=l.then?(await l)():l;var u=a.n(s),h=a.n(i);const c=/^(\d{4})-(\d{2})-(\d{2})$/,d=18;let p=0;function g(t){return String(t).padStart(2,"0")}function m(t){return`${t.getFullYear()}-${g(t.getMonth()+1)}-${g(t.getDate())}`}function f(t,e="YYYY.MM.DD"){if(!t)return"";const a={YYYY:String(t.getFullYear()),YY:String(t.getFullYear()).slice(-2),MM:g(t.getMonth()+1),DD:g(t.getDate())};return String(e||"YYYY.MM.DD").replace(/YYYY|YY|MM|DD/g,t=>a[t]||t)}function b(t){return t instanceof Date&&!Number.isNaN(t.getTime())}function y(t){if(!t)return null;const e=String(t).match(c);if(!e)return null;const[,a,s,n]=e,r=new Date(Number(a),Number(s)-1,Number(n));return r.getFullYear()!==Number(a)||r.getMonth()!==Number(s)-1||r.getDate()!==Number(n)?null:r}function D(t,e="DD.MM.YYYY"){if(!t)return null;if(t instanceof Date)return b(t)?new Date(t.getFullYear(),t.getMonth(),t.getDate()):null;const a=String(t).trim(),s=y(a);if(s)return s;const n=a.match(/\d+/g),r=String(e||"DD.MM.YYYY").match(/YYYY|YY|MM|DD/g);if(!n||!r||n.length<3||r.length<3)return null;const i={};r.slice(0,3).forEach((t,e)=>{i[t]=Number(n[e])});let o=i.YYYY;!o&&i.YY&&(o=i.YY+2e3);const l=i.MM,u=i.DD;if(!o||!l||!u)return null;const h=new Date(o,l-1,u);return h.getFullYear()!==o||h.getMonth()!==l-1||h.getDate()!==u?null:h}function v(t,e=0){const a=(0,s.toNumber)(t,e);return Number.isFinite(a)?Math.max(0,Math.min(11,a)):e}function k(t,e){return t&&e&&t.getFullYear()===e.getFullYear()&&t.getMonth()===e.getMonth()&&t.getDate()===e.getDate()}function w(t,e){if(!t||!e)return 0;return new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()-new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function S(t,e){const a=new Date(t.getFullYear(),t.getMonth()+e,1),s=new Date(a.getFullYear(),a.getMonth()+1,0).getDate();return a.setDate(Math.min(t.getDate(),s)),a}function M(t,e,a){return!!(t&&e&&a)&&(w(t,e)>0&&w(t,a)<0)}function $(t="",e=null){const a=String(t||"").trim();return a||(0,o.pageLocale)(e??globalThis.document?.documentElement??null)}function x(t=""){const e=String(t||"");return e?`${e.charAt(0).toLocaleUpperCase()}${e.slice(1)}`:""}function P(t,e){try{return x(new Intl.DateTimeFormat(e,{month:"long"}).format(new Date(2026,t,1)))}catch{return String(t+1)}}function A(t,e){try{return new Intl.DateTimeFormat(e,{weekday:"long",year:"numeric",month:"long",day:"numeric"}).format(t)}catch{return m(t)}}function Y(t,e=1){const a=new Date(2026,0,4);return Array.from({length:7},(s,n)=>{const r=new Date(a);r.setDate(a.getDate()+(e+n)%7);try{return new Intl.DateTimeFormat(t,{weekday:"short"}).format(r)}catch{return String((e+n)%7)}})}const V=["today","yesterday","last-7-days","last-30-days","this-week","this-month","last-month"];function _(t,e){return new Date(t.getFullYear(),t.getMonth(),t.getDate()+e)}function F(t,e,a=1){const s=new Date(e.getFullYear(),e.getMonth(),e.getDate());switch(t){case"today":return[s,s];case"yesterday":return[_(s,-1),_(s,-1)];case"last-7-days":return[_(s,-6),s];case"last-30-days":return[_(s,-29),s];case"this-week":return[_(s,-(s.getDay()-a+7)%7),s];case"this-month":return[new Date(s.getFullYear(),s.getMonth(),1),s];case"last-month":return[new Date(s.getFullYear(),s.getMonth()-1,1),new Date(s.getFullYear(),s.getMonth(),0)];default:return null}}const T={en:{previousMonth:"Previous month",nextMonth:"Next month",previousYears:"Previous years",nextYears:"Next years",chooseMonth:"Choose a month",chooseYear:"Choose a year",presets:"Quick ranges",customRange:"Custom range",preset_today:"Today",preset_yesterday:"Yesterday",preset_last7Days:"Last 7 days",preset_last30Days:"Last 30 days",preset_thisWeek:"This week",preset_thisMonth:"This month",preset_lastMonth:"Last month"},ru:{previousMonth:"Предыдущий месяц",nextMonth:"Следующий месяц",previousYears:"Предыдущие годы",nextYears:"Следующие годы",chooseMonth:"Выберите месяц",chooseYear:"Выберите год",presets:"Быстрый выбор",customRange:"Свой период",preset_today:"Сегодня",preset_yesterday:"Вчера",preset_last7Days:"Последние 7 дней",preset_last30Days:"Последние 30 дней",preset_thisWeek:"Эта неделя",preset_thisMonth:"Этот месяц",preset_lastMonth:"Прошлый месяц"}};class C extends(u()){constructor(){super(),this._input=null,this._documentClickHandler=this.handleDocumentClick.bind(this),this._documentKeydownHandler=this.handleDocumentKeydown.bind(this),this._viewportHandler=this.positionPanel.bind(this),this._focusCalendarOnOpen=!1,this._focusDateAfterRender=!1,this._panelId="sf-datepicker-panel-"+ ++p,this.state={openAbove:!1,yearPageStart:null,activeDate:""},this.refs={input:this.createRef(),datePickerRoot:this.createRef(),datePickerPanel:this.createRef()}}static get props(){return{templateName:{attribute:"template",default:"default"},value:{default:""},date:{default:""},startValue:{attribute:"start-value",default:""},endValue:{attribute:"end-value",default:""},maxDate:{default:""},minDate:{default:""},range:{type:Boolean,default:!1},month:{type:Number,default:null},year:{type:Number,default:null},context:{default:""},weekStart:{type:Number,default:null},locale:{default:""},format:{default:"DD.MM.YYYY"},rootClass:{default:""},closeOnSelect:{type:Boolean,default:!0},input:{type:Boolean,default:!0},open:{type:Boolean,default:!1},portal:{type:Boolean,default:!0},inputType:{attribute:"input-type",default:"bordered"},size:{default:"1"},inputSize:{attribute:"input-size",default:"1"},inputName:{attribute:"input-name",default:""},name:{attribute:"name",default:""},placeholder:{default:""},label:{default:""},disabled:{type:Boolean,default:!1},required:{type:Boolean,default:!1},iconStart:{type:String,attribute:"icon-start",default:null},leftIcon:{attribute:"left-icon",default:"calendar_today"},inputRootClass:{attribute:"input-root-class",default:""},mask:{type:Boolean,default:!1},maskPattern:{attribute:"mask-pattern",default:""},maskLazy:{attribute:"mask-lazy",default:!1},maskPlaceholderChar:{attribute:"mask-placeholder-char",default:"_"},maskOptions:{attribute:"mask-options",default:""},presets:{default:""},preset:{default:""}}}connectedCallback(){this.upgradeProperty("value"),this.upgradeProperty("presets"),super.connectedCallback()}upgradeProperty(t){if(!Object.prototype.hasOwnProperty.call(this,t))return;const e=this[t];delete this[t],this[t]=e}get componentName(){return"datepicker"}get templateName(){return this.getAttribute("template")||"default"}get selectedDate(){return D(this.date,this.format)}get primaryDate(){const t=this.activePreset;return t?t.to:this.selectedDate||this.startDate}get presets(){return this._presetList??(this.getAttribute("presets")||"")}set presets(t){if(Array.isArray(t))return this._presetList=t,void this.requestComponentUpdate("presets");this._presetList=null,this.setState({presets:t?String(t):""})}get preset(){return this.getAttribute("preset")||""}set preset(t){this.setState({preset:t?String(t):""})}get presetItems(){if(!this.range)return[];const t=Array.isArray(this.presets)?this.presets:String(this.presets).split(/[\s,]+/).filter(Boolean),e=new Date,a=this.setMinDate(),s=this.setMaxDate();return t.map(t=>{const n="string"==typeof t?{id:t,relative:t}:{...t};if(!n?.id)return null;let r=null;if(n.relative)r=F(n.relative,e,this.weekStart);else if(Array.isArray(n.range)){const t=D(n.range[0],this.format),e=D(n.range[1],this.format);t&&e&&(r=w(t,e)<=0?[t,e]:[e,t])}if(!r)return null;let[i,l]=r;a&&w(i,a)<0&&(i=a),s&&w(l,s)>0&&(l=s);const u=w(i,l)>0,h=n.label||(V.includes(n.id)?(0,o.pageText)(T,(c=n.id,`preset_${String(c).replace(/-([a-z0-9])/g,(t,e)=>e.toUpperCase())}`),this,"sf-datepicker"):n.id);var c;return{id:String(n.id),label:h,relative:n.relative||null,from:i,to:l,disabled:u,pressed:this.preset===String(n.id)}}).filter(Boolean)}get activePreset(){const t=this.preset;if(!t||!this.range)return null;const e=this.presetItems.find(e=>e.id===t);return e&&!e.disabled?e:null}get startDate(){return D(this.startValue,this.format)}get endDate(){return D(this.endValue,this.format)}get date(){return this.getAttribute("date")||this.getAttribute("value")||""}get value(){return this.range?[this.startValue,this.endValue]:this.date}set value(t){if(Array.isArray(t)){const[e="",a=""]=t;return void this.setState({date:e||"",startValue:e||"",endValue:a||""})}if(t&&"object"==typeof t){const e=t.start||t.startValue||t.date||"",a=t.end||t.endValue||"";return void this.setState({date:t.date||e||"",startValue:e,endValue:a})}this.setState({date:t?String(t):"",startValue:"",endValue:""})}setMaxDate(){return D(this.maxDate,this.format)}setMinDate(){return D(this.minDate,this.format)}get maxDate(){return this.getAttribute("max-date")||""}get minDate(){return this.getAttribute("min-date")||""}set date(t){this.setState({date:t?String(t):""})}get startValue(){const t=this.activePreset;return t?m(t.from):this.getAttribute("start-value")||""}set startValue(t){this.setState({startValue:t?String(t):""})}get endValue(){const t=this.activePreset;return t?m(t.to):this.getAttribute("end-value")||""}set endValue(t){this.setState({endValue:t?String(t):""})}get range(){return this.getBooleanAttr("range",!1)}get input(){return this.getBooleanAttr("input",!0)}get open(){return this.getBooleanAttr("open",!1)}get portal(){return this.getBooleanAttr("portal",!0)}get inputType(){return this.getAttribute("input-type")||"bordered"}get size(){return(0,n.id)(this.getAttribute("size")||this.getAttribute("input-size")||"1","sf-datepicker")}get inputSize(){return this.size}get inputName(){return this.getAttribute("input-name")||this.getAttribute("name")||""}get placeholder(){return this.getAttribute("placeholder")||""}get label(){return this.getAttribute("label")||""}get disabled(){return this.getBooleanAttr("disabled",!1)}get required(){return this.getBooleanAttr("required",!1)}get closeOnSelect(){return this.getBooleanAttr("close-on-select",!0)}get leftIcon(){return this.hasAttribute("icon-start")?this.getAttribute("icon-start"):this.getAttribute("left-icon")||"calendar_today"}get iconStart(){return this.leftIcon}get inputRootClass(){return this.getAttribute("input-root-class")||""}get mask(){return this.getBooleanAttr("mask",!1)}get maskPattern(){return this.getAttribute("mask-pattern")||this.formatToMask(this.format)}get maskLazy(){return!!this.hasAttribute("mask-lazy")&&this.getBooleanAttr("mask-lazy",!1)}get maskPlaceholderChar(){return this.getAttribute("mask-placeholder-char")||"_"}get maskOptions(){return this.getAttribute("mask-options")||""}get year(){const t=this.primaryDate,e=t?t.getFullYear():(new Date).getFullYear();return this.hasAttribute("year")?this.getNumberAttr("year",e):e}set year(t){this.setState({year:null==t||""===t?"":String((0,s.toNumber)(t,(new Date).getFullYear()))})}get month(){const t=this.primaryDate,e=t?t.getMonth():(new Date).getMonth();return this.hasAttribute("month")?v(this.getAttribute("month"),e):e}set month(t){this.setState({month:null==t||""===t?"":String(v(t,(new Date).getMonth()))})}get contextMode(){return this.getEnumAttr("context",["month","year",""],"")}get weekStart(){if(this.hasAttribute("week-start")){const t=this.getNumberAttr("week-start",1);return Number.isInteger(t)&&t>=0&&t<=7?t%7:1}try{const t=new Intl.Locale(this.locale),e="function"==typeof t.getWeekInfo?t.getWeekInfo():t.weekInfo;if(e?.firstDay)return e.firstDay%7}catch{}return 1}get locale(){return $(this.getAttribute("locale"),this)}get format(){return this.getAttribute("format")||"DD.MM.YYYY"}get formattedValue(){return f(this.selectedDate,this.format)}get formattedStartValue(){return f(this.startDate,this.format)}get formattedEndValue(){return f(this.endDate,this.format)}get displayValue(){return this.range?this.formattedStartValue&&this.formattedEndValue?`${this.formattedStartValue} - ${this.formattedEndValue}`:this.formattedStartValue||this.formattedEndValue||"":this.formattedValue}get displayDate(){return new Date(this.year,this.month,1)}get isRtl(){return"rtl"===(this.closest("[dir]")?.getAttribute("dir")||document.documentElement?.dir)}get labels(){return t=this,Object.fromEntries(["previousMonth","nextMonth","previousYears","nextYears","chooseMonth","chooseYear","presets","customRange"].map(e=>[e,(0,o.pageText)(T,e,t,"sf-datepicker")]));var t}get weekdays(){return Y(this.locale,this.weekStart)}get calendarLabel(){try{return new Intl.DateTimeFormat(this.locale,{month:"long",year:"numeric"}).format(this.displayDate)}catch{return`${this.month+1}.${this.year}`}}get activeDate(){const t=y(this.state.activeDate)||this.primaryDate||this.displayDate,e=this.setMinDate(),a=this.setMaxDate();return e&&w(t,e)<0?e:a&&w(t,a)>0?a:t}get normalizedRange(){const t=this.startDate,e=this.endDate;return t&&e?w(t,e)<=0?{startDate:t,endDate:e}:{startDate:e,endDate:t}:{startDate:t,endDate:e}}get days(){const t=(new Date(this.year,this.month,1).getDay()-this.weekStart+7)%7,e=new Date(this.year,this.month,1-t),{startDate:a,endDate:s}=this.normalizedRange,n=Boolean(this.startValue&&this.endValue),r=this.setMinDate(),i=this.setMaxDate(),o=this.activeDate,l=new Date;return Array.from({length:42}).map((t,u)=>{const h=new Date(e.getFullYear(),e.getMonth(),e.getDate()+u),c=h.getTime(),d=Boolean(r&&c<r.getTime()||i&&c>i.getTime());return{date:h,value:m(h),formattedValue:f(h,this.format),label:A(h,this.locale),day:h.getDate(),today:k(h,l),currentMonth:h.getMonth()===this.month,weekend:[0,6].includes(h.getDay()),disabled:d,selected:this.range?k(h,a)||k(h,s):k(h,this.selectedDate),rangeStart:this.range&&n&&k(h,a),rangeEnd:this.range&&n&&k(h,s),rangeSelected:this.range&&n&&M(h,a,s),tabIndex:!d&&k(h,o)?0:-1}})}get months(){const t=this.setMinDate(),e=this.setMaxDate(),a=t?new Date(t.getFullYear(),t.getMonth(),1):null,s=e?new Date(e.getFullYear(),e.getMonth(),1):null;return Array.from({length:12}).map((t,e)=>{const n=new Date(this.year,e,1).getTime(),r=Boolean(a&&n<a.getTime()||s&&n>s.getTime());return{index:e,label:P(e,this.locale),selected:e===this.month,disabled:r}})}get years(){const t=this.setMinDate(),e=this.setMaxDate(),a=this.yearPageStart;return Array.from({length:d}).map((s,n)=>{const r=a+n;return{year:r,disabled:Boolean(t&&r<t.getFullYear()||e&&r>e.getFullYear()),selected:r===this.year}})}get yearPageStart(){return this.state.yearPageStart??this.getYearPageStart(this.year)}get yearPageEnd(){return this.yearPageStart+d-1}getYearPageStart(t=this.year){const e=(0,s.toNumber)(t,(new Date).getFullYear());return e-e%d}formatToMask=t=>{let e=String(t).replace(/[A-Za-z]/g,"0");return this.range&&(e+=` - ${e}`),e};setContext(t=""){return this.setState({context:t||""}),this}toggleContext(t){const e=this.contextMode===t?"":t,a={context:e};return"year"===e&&(a.yearPageStart=this.getYearPageStart(this.year)),this.setState(a),this}shiftYearPage(t=1){return this.set({yearPageStart:this.yearPageStart+d*t}),this}shiftMonth(t=1){const e=new Date(this.year,this.month+t,1),a=this.setMinDate(),s=this.setMaxDate();return a&&e<new Date(a.getFullYear(),a.getMonth(),1)||s&&e>new Date(s.getFullYear(),s.getMonth(),1)||(this.setState({year:e.getFullYear(),month:e.getMonth(),context:""}),this.set({activeDate:m(e)})),this}setActiveDate(t){const e=y(t);return e&&this.state.activeDate!==t?(this.set({activeDate:m(e)}),this):this}moveActiveDate(t){const e=new Date(this.activeDate);e.setDate(e.getDate()+t);const a=this.setMinDate(),s=this.setMaxDate();return a&&w(e,a)<0||s&&w(e,s)>0||(this._focusDateAfterRender=!0,this.setState({year:e.getFullYear(),month:e.getMonth(),context:""}),this.set({activeDate:m(e)})),this}openPanel({focusCalendar:t=!1}={}){return this.disabled?this:(this._focusCalendarOnOpen=t,this.state.activeDate||this.set({activeDate:m(this.activeDate)}),this.open?(this.positionPanel(),this):(this.setState({open:!0}),this))}closePanel({restoreFocus:t=!1}={}){return this.open?(this.setState({open:!1,context:""}),t&&requestAnimationFrame(()=>this._input?.focus?.()),this):this}togglePanel(){return this.open?this.closePanel():this.openPanel()}handleInputClick(t){t?.preventDefault?.(),t?.stopPropagation?.(),this.openPanel()}handleInputKeydown(t){["ArrowDown","Enter"," "].includes(t.key)&&(t.preventDefault(),this.openPanel({focusCalendar:!0}))}handleDayKeydown(t,e){const a=this.isRtl?-1:1,s={ArrowLeft:-a,ArrowRight:a,ArrowUp:-7,ArrowDown:7};if(Object.prototype.hasOwnProperty.call(s,t.key))return t.preventDefault(),void this.moveActiveDate(s[t.key]);if("Home"===t.key||"End"===t.key){t.preventDefault();const a=((e?.date||this.activeDate).getDay()-this.weekStart+7)%7;return void this.moveActiveDate("Home"===t.key?-a:6-a)}if("PageUp"===t.key||"PageDown"===t.key){t.preventDefault();const e="PageUp"===t.key?-1:1;let a=S(this.activeDate,e);const s=this.setMinDate(),n=this.setMaxDate();s&&w(a,s)<0&&(a=s),n&&w(a,n)>0&&(a=n),this._focusDateAfterRender=!0,this.setState({year:a.getFullYear(),month:a.getMonth()}),this.set({activeDate:m(a)})}}handlePanelClick(t){t?.stopPropagation?.()}handleDocumentClick(t){if(!this.open)return;const e=t.target;this.contains(e)||this.refs.datePickerPanel.value?.contains?.(e)||this.closePanel()}handleDocumentKeydown(t){this.open&&"Escape"===t.key&&(t.preventDefault(),this.contextMode?this.setContext(""):(this.closePanel(),requestAnimationFrame(()=>this._input?.focus?.())))}syncOverlayListeners(){if(this.input&&this.open)return document.addEventListener("click",this._documentClickHandler),void document.addEventListener("keydown",this._documentKeydownHandler);this.removeOverlayListeners()}removeOverlayListeners(){document.removeEventListener("click",this._documentClickHandler),document.removeEventListener("keydown",this._documentKeydownHandler),this.stopPanelPosition(),window.removeEventListener("resize",this._viewportHandler),document.removeEventListener("scroll",this._viewportHandler,!0),window.visualViewport?.removeEventListener("resize",this._viewportHandler),window.visualViewport?.removeEventListener("scroll",this._viewportHandler)}positionPanel(){const t=this.refs.datePickerPanel.value,e=this._input?.closest(".sf-input-field")||this._input||this.querySelector("sf-input");if(this.isConnected&&this.input&&this.portal&&this.open&&t?.isConnected&&e)return this._panelAnchor&&this._panelAnchorPanel===t&&this._panelAnchorTrigger===e?void this._panelAnchor.update():(this.stopPanelPosition(),Object.assign(t.style,{overflowY:"auto",zIndex:"var(--sf-z-index-9)"}),this._panelAnchorPanel=t,this._panelAnchorTrigger=e,void(this._panelAnchor=(globalThis.SF?.Position||h()).anchor(e,t,{side:"block-end",align:"start",onPosition:({side:t})=>{const e="block-start"===t;Boolean(this.state.openAbove)!==e&&this.set({openAbove:e})}})));this.stopPanelPosition()}stopPanelPosition(){this._panelAnchor?.stop(),this._panelAnchor=null,this._panelAnchorPanel=null,this._panelAnchorTrigger=null}selectDate(t){return!t?.date||t.disabled?this:this.range?(this.selectRangeDate(t),this):(this.setState({year:t.date.getFullYear(),month:t.date.getMonth(),date:t.value,context:""}),this.set({activeDate:t.value}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this)}selectRangeDate(t){if(!this.startValue||this.startValue&&this.endValue)return this.setState({year:t.date.getFullYear(),month:t.date.getMonth(),startValue:t.value,endValue:"",date:t.value,context:"",preset:""}),this.set({activeDate:t.value}),this.emitChange(),this;const e=this.startDate,a={year:t.date.getFullYear(),month:t.date.getMonth(),context:"",preset:""};return e&&w(t.date,e)<0?(a.startValue=t.value,a.endValue=this.startValue,a.date=t.value):(a.endValue=t.value,a.date=this.startValue),this.setState(a),this.set({activeDate:t.value}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this}choosePreset(t){if(!t||t.disabled)return this;const e=m(t.from),a=m(t.to);return this.setState({preset:t.id,startValue:e,endValue:a,date:e,year:t.to.getFullYear(),month:t.to.getMonth(),context:""}),this.set({activeDate:a}),this.emitChange(),this.closeOnSelect&&this.closePanel({restoreFocus:!0}),this}chooseCustomRange(){return this.preset&&this.setState({preset:"",startValue:"",endValue:"",date:""}),this._focusDateAfterRender=!0,this.requestComponentUpdate("custom-range"),this}handlePresetKeydown(t){const e={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};if(!(t.key in e)&&"Home"!==t.key&&"End"!==t.key)return;const a=[...t.currentTarget.querySelectorAll("button:not(:disabled)")];if(!a.length)return;t.preventDefault();const s=a.indexOf(t.target);let n="Home"===t.key?0:"End"===t.key?a.length-1:s+e[t.key];!this.isRtl||"ArrowRight"!==t.key&&"ArrowLeft"!==t.key||(n=s-e[t.key]),n=(n+a.length)%a.length,a.forEach((t,e)=>t.setAttribute("tabindex",e===n?"0":"-1")),a[n].focus()}selectMonth(t){return!t||t.disabled||(this.setState({month:t.index,context:""}),this.set({activeDate:m(new Date(this.year,t.index,1))})),this}selectYear(t){if(!t||t.disabled)return this;const e={year:t.year,context:""},a=this.getClosestEnabledMonth(t.year,this.month);return a!==this.month&&(e.month=a),this.setState(e),this.set({activeDate:m(new Date(t.year,a,1))}),this}getClosestEnabledMonth(t,e){const a=this.setMinDate(),s=this.setMaxDate();return a&&t===a.getFullYear()&&e<a.getMonth()?a.getMonth():s&&t===s.getFullYear()&&e>s.getMonth()?s.getMonth():e}emitChange(){const t=this.startValue&&this.endValue?`${this.startValue}/${this.endValue}`:this.startValue||"",e=this.range?{value:[this.startValue,this.endValue],date:t,startValue:this.startValue,endValue:this.endValue,formattedValue:this.displayValue,formattedStartValue:this.formattedStartValue,formattedEndValue:this.formattedEndValue,isoValue:t,startIsoValue:this.startValue,endIsoValue:this.endValue,range:!0,format:this.format,preset:this.activePreset?this.activePreset.relative?{id:this.activePreset.id,relative:this.activePreset.relative}:{id:this.activePreset.id}:null}:{value:this.date,date:this.date,formattedValue:this.formattedValue,isoValue:this.date,range:!1,format:this.format};this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:e})),this.dispatchEvent(new CustomEvent("sf-datepicker-change",{bubbles:!0,composed:!0,detail:e})),this.emitComponentEvent("change",e)}templateContext(){const t=this.getPropsContext();return this.createTemplateContext({...t,component:this,date:this.date,formattedValue:this.formattedValue,displayValue:this.displayValue,startValue:this.startValue,formattedStartValue:this.formattedStartValue,endValue:this.endValue,formattedEndValue:this.formattedEndValue,range:this.range,format:this.format,selectedDate:this.selectedDate,startDate:this.startDate,endDate:this.endDate,year:this.year,month:this.month,monthLabel:P(this.month,this.locale),calendarLabel:this.calendarLabel,labels:this.labels,weekdays:this.weekdays,panelId:this._panelId,previousIcon:this.isRtl?"chevron_right":"chevron_left",nextIcon:this.isRtl?"chevron_left":"chevron_right",context:this.contextMode,locale:this.locale,days:this.days,presetItems:this.presetItems,months:this.months,years:this.years,yearPageStart:this.yearPageStart,yearPageEnd:this.yearPageEnd,rootClass:this.getRootClass(),rootStyle:this.getRootStyle(),openAbove:Boolean(this.state.openAbove),input:this.input,open:this.open,portal:this.portal,inputType:this.inputType,inputSize:this.inputSize,inputName:this.inputName,placeholder:this.placeholder,label:this.label,disabled:this.disabled,required:this.required,leftIcon:this.leftIcon,iconStart:this.leftIcon,inputRootClass:this.inputRootClass,mask:this.mask,maskPattern:this.maskPattern,maskLazy:this.maskLazy,maskPlaceholderChar:this.maskPlaceholderChar,maskOptions:this.maskOptions})}template(){return(0,r.P)(this.templateContext())}afterRender(){this._input=this.refs.input?.value?.querySelector("input")||null,this._input&&(this._input.setAttribute("aria-haspopup","dialog"),this._input.setAttribute("aria-expanded",this.open?"true":"false"),this._input.setAttribute("aria-controls",this._panelId));const t=this.querySelector(".sf-datepicker-month-toggle button"),e=this.querySelector(".sf-datepicker-year-toggle button");t?.setAttribute("aria-expanded","month"===this.contextMode?"true":"false"),e?.setAttribute("aria-expanded","year"===this.contextMode?"true":"false"),this.syncOverlayListeners(),requestAnimationFrame(()=>{if(this.positionPanel(),this._focusCalendarOnOpen||this._focusDateAfterRender){const t=this.querySelector(`.sf-datepicker-day[data-date="${m(this.activeDate)}"]`);t?.focus?.(),this._focusCalendarOnOpen=!1,this._focusDateAfterRender=!1}})}onDisconnected(){this.removeOverlayListeners(),super.onDisconnected()}get data(){return{value:this.value,date:this.date,formattedValue:this.formattedValue,displayValue:this.displayValue,startValue:this.startValue,formattedStartValue:this.formattedStartValue,endValue:this.endValue,formattedEndValue:this.formattedEndValue,range:this.range,format:this.format,year:this.year,month:this.month,context:this.contextMode,maxDate:this.maxDate,minDate:this.minDate,locale:this.locale,input:this.input,open:this.open,portal:this.portal,mask:this.mask,maskPattern:this.maskPattern,maskOptions:this.maskOptions,presets:this.presetItems.map(({id:t,label:e,relative:a,disabled:s})=>({id:t,label:e,relative:a,disabled:s})),preset:this.preset}}}C.define("sf-datepicker"),e()}catch(E){e(E)}})},"77b2f4107e3b"(t,e,a){a.a(t,async(t,s)=>{try{a.d(e,{P:()=>b});var n=a("ddf1cdb42ecc"),r=a("5a8eddcd589d"),i=t([n,r]);[n,r]=i.then?(await i)():i;function o(...t){return t.flat().filter(Boolean).join(" ")}function l(t){return n.html`
2
2
  <div class="sf-datepicker-top flex content-main-between items-cross-center">
3
3
  <sf-icon-button appearance="link" scheme="on-surface" size="1"
4
4
  icon=${t.previousIcon} aria-label=${t.labels.previousYears}
@@ -1,4 +1,4 @@
1
- (()=>{"use strict";var e={"3a03d4610486"(e,t,i){i.d(t,{Q:()=>o});let s=0;function n(e,t){if(!e.id){let i;do{i=`${t}-${++s}`}while(document.getElementById(i));e.id=i}return e.id}function o(e,t){let i=null,s=null,o=null,r=!1;const a=new WeakMap,l=(e,t,i)=>{const s=a.get(e)||{};void 0!==s[t]&&e.getAttribute(t)===s[t]&&e.removeAttribute(t),delete s[t],!e.hasAttribute(t)&&i&&(e.setAttribute(t,i),s[t]=i),a.set(e,s)},c=()=>e.querySelector(".sf-dropdown-field, .sf-dropdown-trigger"),d=()=>c()?.querySelector(":scope > button")||c(),u=()=>c()?.querySelector('input:not([type="hidden"])'),p=()=>t.getList()?.querySelector(".sf-input input"),h=()=>[...t.getList()?.querySelectorAll(".sf-list-item")||[]],f=()=>h().filter(e=>!e.hidden&&!e.classList.contains("disabled")&&"true"!==e.getAttribute("aria-disabled")&&"true"!==e.getAttribute("aria-hidden")),g=e=>e.querySelector(".sf-list-item-container, .sf-avatar-label-group-title, .sf-tag-container")?.textContent?.trim()||e.dataset.value||"",b=e=>{e&&!e.disabled&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}))},m=()=>{s="trigger",b(d()),t.close(),x()},v=e=>{if(t.isDisabled()||e.altKey||e.ctrlKey||e.metaKey)return;const i=e.target,n=i.closest?.(".sf-list-item"),o=t.getList()?.contains(i),r=i===d()||i===u()||i===c();let a=!1;if("Escape"===e.key&&t.isOpen())m(),a=!0;else{if("Tab"===e.key&&t.isOpen())return o&&b(d()),t.close(),void x();if(r&&["ArrowDown","ArrowUp","Enter"," "].includes(e.key))t.isOpen()&&["Enter"," "].includes(e.key)?m():(e=>{s=e,t.open(),x()})("ArrowUp"===e.key?"last":"search"),a=!0;else if(o&&["ArrowDown","ArrowUp"].includes(e.key)){const t=f(),i=t.indexOf(n),s=i<0?"ArrowUp"===e.key?t.length-1:0:Math.max(0,Math.min(t.length-1,i+("ArrowUp"===e.key?-1:1)));b(t[s]),a=!0}else if(n&&o&&["Home","End"].includes(e.key)){const t=f();b("Home"===e.key?t[0]:t.at(-1)),a=!0}else n&&o&&["Enter"," "].includes(e.key)&&(f().includes(n)&&(s=t.isMultiple()?{value:n.dataset.value}:"trigger",t.select(n),x()),a=!0)}a&&(e.preventDefault(),e.stopImmediatePropagation())},y=()=>{null!==o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{var i;o=null,r||!t.isOpen()||s||(i=document.activeElement)&&(e.contains(i)||t.getList()?.contains(i))||(t.close(),x())})};let w=document.createElement("span");w.className="sf-dropdown-value",e.append(w),n(w,"sf-dropdown-value");const x=()=>{if(r)return;const o=t.getList();i!==o&&(i?.removeEventListener("keydown",v,!0),i?.removeEventListener("focusout",y),i=o,i?.addEventListener("keydown",v,!0),i?.addEventListener("focusout",y));const m=d(),x=i?.querySelector(".sf-list-container");if(!m||!x)return;w.isConnected||e.append(w);const _=e.querySelector(".sf-dropdown-label .sf-dropdown-text"),$=t.owner||e,S=_?.textContent.trim()?n(_,"sf-dropdown-label"):"",A=$.getAttribute("aria-label")||e.getAttribute("aria-label"),k=$.getAttribute("aria-labelledby")||e.getAttribute("aria-labelledby"),C=n(m,"sf-dropdown-trigger"),L=m.hasAttribute("aria-label")&&a.get(m)?.["aria-label"]!==m.getAttribute("aria-label");l(m,"aria-labelledby",k||(!A&&S?L?`${C} ${S}`:S:"")),l(m,"aria-label",A),"BUTTON"!==m.tagName&&m.setAttribute("role","button"),m.tabIndex=t.isDisabled()?-1:0,m.setAttribute("aria-expanded",String(t.isOpen())),m.setAttribute("aria-haspopup","listbox"),m.setAttribute("aria-controls",n(x,"sf-dropdown-listbox")),m.querySelectorAll(".sf-icon").forEach(e=>e.setAttribute("aria-hidden","true")),c()!==m&&(c().tabIndex=-1),u()&&(u().tabIndex=-1),x.setAttribute("role","listbox"),x.setAttribute("aria-multiselectable",String(t.isMultiple())),l(x,"aria-labelledby",k||S||C);const z=p();z&&(z.setAttribute("role","searchbox"),z.setAttribute("aria-controls",x.id),l(z,"aria-labelledby",z.hasAttribute("aria-label")?"":k||S||C)),h().forEach(e=>{e.setAttribute("role","option"),e.tabIndex=-1,e.setAttribute("aria-selected",String(e.classList.contains("selected"))),l(e,"aria-disabled",e.classList.contains("disabled")?"true":""),function(e,t){const i=e.querySelector('.sf-checkbox input[type="checkbox"]');if(!i)return;const s=e.querySelector(".sf-checkbox-box sf-icon, .sf-checkbox-box .sf-icon"),n="sf-icon"===s?.tagName?.toLowerCase()?s.getAttribute("icon")||"":s?.textContent;(i.checked!==t||i.indeterminate||s&&n!==(t?"check":""))&&(i.checked=t,i.indeterminate=!1,globalThis.SF?.Checkbox?.setState?.(i,{checked:t,indeterminate:!1}))}(e,e.classList.contains("selected")),e.querySelectorAll(".sf-checkbox").forEach(e=>{"true"!==e.getAttribute("aria-hidden")&&e.setAttribute("aria-hidden","true")}),e.querySelectorAll(".sf-icon, sf-icon").forEach(e=>{"true"!==e.getAttribute("aria-hidden")&&e.setAttribute("aria-hidden","true")}),e.querySelectorAll("input, button, a[href], [tabindex]").forEach(e=>{e.tabIndex=-1})});const V=t.selectedLabels?.()||h().filter(e=>e.classList.contains("selected")).map(g);w.textContent=V.join(", ")||u()?.value||u()?.placeholder||"";const T=new Set((m.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));T.add(w.id),m.setAttribute("aria-describedby",[...T].join(" ")),(()=>{if(!s)return;if("trigger"===s)return s=null,void b(d());if(!t.isOpen()||t.getList()?.hidden)return;const e=f(),i="search"===s?p()||e[0]||d():"last"===s?e.at(-1):"object"==typeof s?e.find(e=>e.dataset.value===s.value):e[0];s=null,b(i)})()};return e.addEventListener("keydown",v,!0),e.addEventListener("focusout",y),x(),{refresh:x,beforeClose:()=>{t.getList()?.contains(document.activeElement)&&(s="trigger")},release(){r=!0,null!==o&&cancelAnimationFrame(o),e.removeEventListener("keydown",v,!0),e.removeEventListener("focusout",y),i?.removeEventListener("keydown",v,!0),i?.removeEventListener("focusout",y);const t=d();if(t){const e=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(e=>e&&e!==w.id);e.length?t.setAttribute("aria-describedby",e.join(" ")):t.removeAttribute("aria-describedby")}w.remove()}}}},a0f23dca0b37(e,t,i){i.a(e,async(e,s)=>{try{i.d(t,{AL:()=>g,GD:()=>f});var n=i("5c1dc214bb5e"),o=e([n]);n=(o.then?(await o)():o)[0];var r=i.n(n);const a=()=>globalThis.SF?.Position||r(),l=new WeakMap,c=["position","inset","margin","width","max-width","max-height","overflow","left","top","right","bottom","z-index"],d=["font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-optical-sizing","font-kerning","line-height","letter-spacing","word-spacing","text-transform","text-indent","white-space","word-break","overflow-wrap","text-rendering","direction","writing-mode","text-orientation","color","color-scheme","text-align"];function u(e,t){if(!t.context)return;const i=t.context,s=getComputedStyle(e),n=["sf-dropdown",...Array.from(e.classList).filter(e=>e.startsWith("sf-dropdown--")&&!["sf-dropdown--open","sf-dropdown--drop-up","sf-dropdown--drop-down"].includes(e))].join(" ");i.className!==n&&(i.className=n);const o=[...Array.from(s).filter(e=>e.startsWith("--sf-")),...d],r=new Set(o);for(const e of t.contextProperties||[])r.has(e)||i.style.removeProperty(e);for(const e of o){const t=s.getPropertyValue(e);i.style.getPropertyValue(e)!==t&&i.style.setProperty(e,t)}t.contextProperties=o}function p(e){return e?.querySelector(".sf-dropdown-field, .sf-dropdown-trigger")??null}function h(e,t){const i=l.get(t);if(!i||!e.isConnected||t.hidden)return!1;const s=p(e);return!!s&&(e.closest('[hidden], [inert], [aria-hidden="true"], dialog:not([open])')||!s.getClientRects().length||["hidden","collapse"].includes(getComputedStyle(s).visibility)?(i.onUnavailable?.(),!1):(u(e,i),i.wrap&&(i.wrap.style.minHeight="0",i.wrap.style.overflowY="auto"),i.anchor||(i.anchor=a().anchor(s,t,{side:"block-end",align:"start",matchWidth:s.classList.contains("sf-dropdown-field"),fitHeight:!0,autoUpdate:!1,onPosition:({side:i})=>{const s="block-start"===i;t.dataset.placement=e.dataset.placement=s?"top":"bottom",e.classList.toggle("sf-dropdown--drop-up",s),e.classList.toggle("sf-dropdown--drop-down",!s)}})),i.anchor.update(),!0))}function f(e,t,i){if(!t?.isConnected||!p(e))return!1;const s=t.contains(document.activeElement)?document.activeElement:null;if(!l.has(t)){const s=c.map(e=>[e,t.style.getPropertyValue(e),t.style.getPropertyPriority(e)]),n={root:e,saved:s,onUnavailable:i,popover:t.getAttribute("popover"),frame:0,native:"function"==typeof t.showPopover};if(n.wrap=t.querySelector(".sf-list-container-wrap"),n.wrapStyles=n.wrap?["min-height","overflow-y"].map(e=>[e,n.wrap.style.getPropertyValue(e),n.wrap.style.getPropertyPriority(e)]):[],n.schedule=()=>{n.frame||(n.frame=requestAnimationFrame(()=>{n.frame=0,h(e,t)}))},l.set(t,n),e.__sfDropdownPortalList=t,n.native)t.setAttribute("popover","manual");else{n.parent=t.parentNode,n.next=t.nextSibling,n.context=document.createElement("div"),n.context.style.cssText="display:contents;position:static",u(e,n);(e.closest('dialog[open], [role="dialog"][aria-modal="true"]')||document.body).append(n.context),n.context.append(t),t.style.zIndex="var(--sf-z-index-9)"}n.inheritance=new MutationObserver(n.schedule);for(let t=e;t;t=t.parentElement)n.inheritance.observe(t,{attributes:!0,attributeFilter:["class","style","dir","hidden","inert","aria-hidden","open"]});Object.assign(t.style,{position:"fixed",inset:"auto",margin:"0",overflow:n.wrap?"hidden":"auto"}),"function"==typeof ResizeObserver&&(n.resize=new ResizeObserver(n.schedule),n.resize.observe(p(e)),n.resize.observe(t)),window.visualViewport?.addEventListener("resize",n.schedule),window.visualViewport?.addEventListener("scroll",n.schedule)}return t.hidden=!1,l.get(t).native&&!t.matches(":popover-open")&&t.showPopover(),!!h(e,t)&&(s&&document.activeElement!==s&&s.focus({preventScroll:!0}),!0)}function g(e){const t=l.get(e);if(!t)return!1;const i=e.contains(document.activeElement)?document.activeElement:null;t.anchor?.stop(),t.resize?.disconnect(),cancelAnimationFrame(t.frame),t.inheritance?.disconnect(),window.visualViewport?.removeEventListener("resize",t.schedule),window.visualViewport?.removeEventListener("scroll",t.schedule),t.native?(e.matches(":popover-open")&&e.hidePopover(),null===t.popover?e.removeAttribute("popover"):e.setAttribute("popover",t.popover)):(t.next?.parentNode===t.parent?t.parent.insertBefore(e,t.next):t.parent.append(e),t.context.remove());for(const[i,s,n]of t.saved)s?e.style.setProperty(i,s,n):e.style.removeProperty(i);for(const[e,i,s]of t.wrapStyles)i?t.wrap.style.setProperty(e,i,s):t.wrap.style.removeProperty(e);return delete e.dataset.placement,delete t.root.dataset.placement,t.root.classList.remove("sf-dropdown--drop-up","sf-dropdown--drop-down"),t.root.__sfDropdownPortalList===e&&delete t.root.__sfDropdownPortalList,l.delete(e),i&&!e.hidden&&t.root.isConnected&&document.activeElement!==i&&i.focus({preventScroll:!0}),!0}s()}catch(b){s(b)}})},"98e26702f55a"(e,t,i){function s(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function n({component:e="",kind:t="attribute",attribute:i="",from:n,to:o=null}={}){if(!n)return;const r=[e,t,i,n].join("|"),a=s(),l=a.get(r);if(l)l.count+=1;else if(a.set(r,{component:e,kind:t,attribute:i,from:n,to:o,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const s=e?`${e}: `:"",r="value"===t?`${i}="${n}"`:`${t} ${n}`;globalThis.console?.warn?.(`[Simai Framework] ${s}${r} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(i.d(t,{id:()=>c,kA:()=>l}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const e=globalThis.SF.deprecations||{};e.list=function(){return[...s().values()].map(e=>({...e}))},e.clear=function(){s().clear()},e.note=n,globalThis.SF.deprecations=e}const o=Object.freeze(["1/2","1","2"]),r=Object.freeze({"1/3":"1/2",3:"2"}),a=new Set;function l(e){const t=String(e??"").trim().toLowerCase();return o.includes(t)?t:Object.hasOwn(r,t)?r[t]:"1"}function c(e,t="field",i="1"){const s=String(e??"").trim().toLowerCase();if(o.includes(s))return s;if(Object.hasOwn(r,s)){const e=r[s];n({component:t,kind:"value",attribute:"size",from:s,to:e});const i=`${t}:${s}`;return a.has(i)||"undefined"==typeof console||(a.add(i),console.warn(`[Simai Framework] ${t}: size ${s} is retired for form fields; rendering size ${e}.`)),e}return i}},"67eed2647f47"(e,t,i){i.d(t,{z:()=>o});const s=new WeakMap,n=new WeakSet;function o(e,t){const i=e.ownerDocument;n.has(i)||(i.addEventListener("reset",e=>{const t=e.target;if("FORM"!==t?.tagName)return;const i=Array.from(t.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of i)if(e.isConnected&&e.form===t)for(const t of s.get(e)||[])t()},0)},!0),n.add(i));let o=s.get(e);return o||s.set(e,o=new Set),o.add(t),()=>o.delete(t)}},"50a1017ded91"(e,t,i){i.a(e,async(e,t)=>{try{var s=i("fbe0570fcc69"),n=i("0d662e4d7d63"),o=i("98e26702f55a"),r=i("5429d6e80991"),a=i("3a03d4610486"),l=i("67eed2647f47"),c=i("a0f23dca0b37"),d=e([s,n,r,c]);[s,n,r,c]=d.then?(await d)():d;var u=i.n(s);const p={en:{search:"Search"},ru:{search:"Поиск"}};function h(e){return(0,o.id)(e,"sf-dropdown")}function f(e){const t=String(e||"").toLowerCase();return["text","icon","checkbox","avatar","color"].includes(t)?t:"text"}function g(e,t="1"){return e instanceof HTMLElement?"sf-list-item"!==e.tagName.toLowerCase()?null:{type:f(e.getAttribute("kind")||e.getAttribute("type")),size:h(e.getAttribute("size")||t),text:e.getAttribute("text")||"",icon:e.getAttribute("icon")||"person",checked:e.hasAttribute("checked")||(0,s.toBoolean)(e.getAttribute("checked")),selected:e.hasAttribute("selected")||(0,s.toBoolean)(e.getAttribute("selected")),disabled:e.hasAttribute("disabled")||(0,s.toBoolean)(e.getAttribute("disabled")),colorClass:e.getAttribute("color-class")||"bg-tertiary",avatarImageUrl:e.getAttribute("avatar-image-url")||"",avatarTitle:e.getAttribute("avatar-title")||e.getAttribute("text")||"",value:e.getAttribute("value")??e.getAttribute("text")??"",ariaLabel:e.getAttribute("aria-label")||"",group:e.getAttribute("group")||""}:null}function b(e,t="1"){if(!e||"object"!=typeof e)return null;const i=void 0===e.text||null===e.text?"":String(e.text),n=void 0===e.value||null===e.value?i:String(e.value);return""===i&&""===n?null:{type:f(e.kind||e.type),size:h(e.size||t),text:i,icon:e.icon?String(e.icon):"person",checked:(0,s.toBoolean)(e.checked),selected:(0,s.toBoolean)(e.selected),disabled:(0,s.toBoolean)(e.disabled),colorClass:e.colorClass?String(e.colorClass):"bg-tertiary",avatarImageUrl:e.avatarImageUrl?String(e.avatarImageUrl):"",avatarTitle:e.avatarTitle?String(e.avatarTitle):i,value:n,ariaLabel:e.ariaLabel?String(e.ariaLabel):"",group:e.group?String(e.group):""}}function m(e,t="1"){let i=e;if("string"==typeof i){const e=i.trim();if(""===e)return[];try{i=JSON.parse(e)}catch{return[]}}return Array.isArray(i)?i.map(e=>b("string"==typeof e||"number"==typeof e?{text:String(e),value:String(e)}:e,t)).filter(Boolean):[]}function v(e=""){return String(e||"").split(",").map(e=>e.trim()).filter(Boolean)}function y(e=[]){return e.map(e=>String(e)).join(",")}function w(e={}){return"avatar"===e.type?e.avatarTitle||e.text||e.value||"":e.text||e.avatarTitle||e.value||""}class x extends(u()){constructor(){super(),this._options=[],this._optionsCaptured=!1,this._optionsFromData=!1,this._open=!1,this._searchValue="",this._selectedValues=[],this._dropdownRoot=null,this._list=null,this._documentClickHandler=this.handleDocumentClick.bind(this),this._viewportHandler=this.positionPortalList.bind(this)}static get props(){return{templateName:{attribute:"template",default:"default"},size:{default:"1"},appearance:{default:"outlined",values:["filled","outlined"],aliases:["type"]},mode:{default:"select",values:["tag","select"]},multiple:{type:Boolean,default:!1},portal:{type:Boolean,default:!0},value:{default:""},name:{default:""},label:{default:""},required:{type:Boolean,default:!1},placeholder:{default:""},searchPlaceholder:{default:""},search:{type:Boolean,default:!0},layout:{default:"list",values:["list","grid"]},columns:{default:"6"},disabled:{type:Boolean,default:!1},ariaLabel:{default:""}}}connectedCallback(){this.captureOptions(),Object.prototype.hasOwnProperty.call(this,"_resetValues")||(this._resetValues=[...this.selectedValues]),super.connectedCallback()}attributeChangedCallback(e,t,i){t!==i&&("value"===e&&(this._selectedValues=v(i)),"disabled"===e&&this.disabled&&(this._open=!1,this._searchValue="")),super.attributeChangedCallback(e,t,i)}get componentName(){return"dropdown"}get templateName(){return this.getAttribute("template")||"default"}get size(){return h(this.getAttribute("size"))}get appearance(){return this.getProp("appearance")}get type(){return this.appearance}get mode(){return this.getEnumAttr("mode",["tag","select"],"select")}get multiple(){return this.hasAttribute("multiple")?this.getBooleanAttr("multiple",!0):"tag"===this.mode}get portal(){return this.getBooleanAttr("portal",!0)}get name(){return this.getAttribute("name")||""}get selectedValue(){return this.getAttribute("value")||""}get label(){return this.getAttribute("label")||""}get required(){return this.getBooleanAttr("required",!1)}get placeholder(){return this.getAttribute("placeholder")||""}get searchPlaceholder(){return this.getAttribute("search-placeholder")||(0,n.pageText)(p,"search",this)}get layout(){return this.getEnumAttr("layout",["list","grid"],"list")}get columns(){const e=Number.parseInt(this.getAttribute("columns")??"",10);return Number.isFinite(e)&&e>0?String(e):"6"}get search(){return this.getBooleanAttr("search",!0)}get disabled(){return this.getBooleanAttr("disabled",!1)}get ariaLabel(){return this.getAttribute("aria-label")||""}get selectedValues(){return this.hasAttribute("value")?v(this.selectedValue):this._selectedValues}get selectedOptions(){const e=this.options;return[...new Set(this.selectedValues)].map(t=>e.find(e=>String(e.value)===t)).filter(Boolean)}get triggerText(){if("tag"===this.mode)return"";return(this.multiple?this.selectedOptions:this.selectedOptions.slice(0,1)).map(w).join(", ")}get hiddenValue(){return this.selectedValues.join(",")}captureOptions(){if(this._optionsFromData)return;const e=Array.from(this.children).filter(e=>e instanceof HTMLElement&&"sf-list-item"===e.tagName.toLowerCase());e.length&&(this._options=e.map(e=>g(e,this.size)).filter(Boolean),this._optionsCaptured=!0,this.selectedValue||this._selectedValues.length||(this._selectedValues=this._options.filter(e=>e.selected).map(e=>String(e.value))),e.forEach(e=>e.remove()))}set options(e){const t=m(e,this.size);this._optionsFromData=!0,this._options=t,this._optionsCaptured=!0,this.selectedValue||this._selectedValues.length||(this._selectedValues=t.filter(e=>e.selected).map(e=>String(e.value))),this.requestComponentUpdate("options")}get options(){if(!Array.isArray(this._options)||!this._options.length)return[];const e=new Set(this.selectedValues);return this._options.map(t=>({...t,size:h(t.size||this.size),selected:e.has(String(t.value))}))}get visibleOptions(){const e=String(this._searchValue||"").trim().toLowerCase();return e?this.options.filter(t=>w(t).toLowerCase().includes(e)):this.options}templateContext(){const e=this.getPropsContext();return this.createTemplateContext({...e,component:this,open:this._open,multiple:this.multiple,value:this.hiddenValue,triggerText:this.triggerText,searchValue:this._searchValue,searchPlaceholder:this.searchPlaceholder,selectedValues:this.selectedValues,selectedOptions:this.selectedOptions,options:this.visibleOptions})}template(){return(0,r.g)(this.templateContext())}beforeRender(){this.captureOptions()}afterRender(){const e=this._dropdownRoot,t=this._list;this._dropdownRoot=this.querySelector(".sf-dropdown"),this._list=this.querySelector(".sf-list")||(e===this._dropdownRoot?t:null),t!==this._list&&(0,c.AL)(t),this.syncDocumentListeners(),this.syncPortalListeners(),this.positionPortalList(),e!==this._dropdownRoot&&(this._interaction?.release(),this._interaction=null),this._dropdownRoot&&!this._interaction&&(this._interaction=(0,a.Q)(this._dropdownRoot,{owner:this,getList:()=>this._list,isOpen:()=>this._open,isDisabled:()=>this.disabled,isMultiple:()=>this.multiple,open:()=>this.openDropdown(),close:()=>this.closeDropdown(),select:e=>this.selectValue(e.dataset.value||""),selectedLabels:()=>this.selectedOptions.map(w)})),this._interaction?.refresh();const i=this.querySelector(".sf-dropdown-hidden-input")||this.querySelector(".sf-dropdown-field > button");this._resetControl!==i&&(this._releaseReset?.(),this._resetControl=i,this._releaseReset=i?(0,l.z)(i,()=>{this._interaction?.beforeClose(),this._selectedValues=[...this._resetValues],this.setAttributeValue("value",y(this._selectedValues)),this._open=!1,this._searchValue="";const e=this.querySelector('.sf-dropdown-field input:not([type="hidden"])');e&&(e.value=this.triggerText),this.requestComponentUpdate("reset")}):null)}onDisconnected(){(0,c.AL)(this._list),this._releaseReset?.(),this._releaseReset=null,this._resetControl=null,this._interaction?.release(),this._interaction=null,this.removeDocumentListeners(),this.removePortalListeners(),super.onDisconnected()}openDropdown(){return this.disabled||this._open||(this._open=!0,this.requestComponentUpdate("open")),this}closeDropdown(){return this._open?(this._interaction?.beforeClose(),this._open=!1,this._searchValue="",this.requestComponentUpdate("close"),this):this}toggleDropdown(){return this._open?this.closeDropdown():this.openDropdown()}handleTriggerClick(e){this.disabled||(e?.preventDefault?.(),this.toggleDropdown())}handleSearchInput(e){this._searchValue=e?.target?.value||"",this.requestComponentUpdate("search")}handleOptionClick(e){if(this.disabled)return;const t=e.target?.closest?.(".sf-list-item");t&&(this.contains(t)||this._list?.contains(t))&&!t.classList.contains("disabled")&&(e.preventDefault(),this.selectValue(t.dataset.value||""))}handleOptionKeydown(e){"Enter"!==e.key&&" "!==e.key||this.handleOptionClick(e)}handleDocumentClick(e){!this._open||this.contains(e.target)||this._list?.contains(e.target)||this.closeDropdown()}selectValue(e=""){if(this.disabled)return this;const t=this.options.find(t=>String(t.value)===String(e));if(!t||t.disabled)return this;const i=!this.multiple&&1===this.selectedValues.length&&this.selectedValues[0]===String(t.value);if(this.multiple){const e=new Set(this.selectedValues);e.has(String(t.value))?e.delete(String(t.value)):e.add(String(t.value)),this._selectedValues=Array.from(e)}else this._selectedValues=[String(t.value)];const s=[...this._selectedValues];return this.setAttributeValue("value",y(s)),i||this.dispatchDropdownChange(t,s),this.multiple||(this._interaction?.beforeClose(),this._open=!1,this._searchValue=""),this.requestComponentUpdate("select"),this}removeSelectedValue(e=""){if(this.disabled)return this;const t=new Set(this.selectedValues);t.delete(String(e)),this._selectedValues=Array.from(t);const i=[...this._selectedValues];return this.setAttributeValue("value",y(i)),this.dispatchDropdownChange(null,i),this.requestComponentUpdate("remove-tag"),this}dispatchDropdownChange(e=null,t=this.selectedValues){const i={value:e?.value||"",label:e?w(e):"",values:t,item:e,root:this,multiple:this.multiple};this.dispatchEvent(new CustomEvent("sf-dropdown:change",{bubbles:!0,composed:!0,detail:i})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:i}))}syncDocumentListeners(){this._open?document.addEventListener("click",this._documentClickHandler):this.removeDocumentListeners()}removeDocumentListeners(){document.removeEventListener("click",this._documentClickHandler)}syncPortalListeners(){if(this._open&&this.portal)return window.addEventListener("resize",this._viewportHandler),void document.addEventListener("scroll",this._viewportHandler,!0);this.removePortalListeners()}removePortalListeners(){window.removeEventListener("resize",this._viewportHandler),document.removeEventListener("scroll",this._viewportHandler,!0)}positionPortalList(){this._list&&this._dropdownRoot&&this.portal&&this._open?(0,c.GD)(this._dropdownRoot,this._list,()=>this.closeDropdown()):(0,c.AL)(this._list)}get value(){return this.hiddenValue}set value(e){if(e&&"object"==typeof e&&!Array.isArray(e))return void this.setValueAttributes(e);const t=Array.isArray(e)?e.map(String):v(null==e?"":String(e));this.setAttributeValue("value",y(t))}}x.define("sf-dropdown"),t()}catch(_){t(_)}})},"5429d6e80991"(e,t,i){i.a(e,async(e,s)=>{try{i.d(t,{g:()=>h});var n=i("ddf1cdb42ecc"),o=i("c22590307c6c"),r=e([n,o]);[n,o]=r.then?(await r)():r;function a(e={}){return"avatar"===e.type?e.avatarTitle||e.text||e.value||"":e.text||e.avatarTitle||e.value||""}function l(e=[]){const t=[];let i=null;for(const s of e){const e=s.group?String(s.group):"";e!==i&&(i=e,e&&t.push((0,o.aU)(e,s.size))),t.push((0,o.lN)(s))}return t}const c=Object.freeze({"1/2":{size:"1/3",spacing:""},1:{size:"1",spacing:"compact"},2:{size:"2",spacing:"compact"}});function d(e){if(e.multiple||1!==e.selectedOptions?.length)return n.nothing;const t=e.selectedOptions[0];return"icon"===t.type&&t.icon?n.html`<i class="sf-icon sf-dropdown-field-visual" aria-hidden="true">${t.icon}</i>`:"color"===t.type&&t.colorClass?n.html`<span class="sf-tag-color-icon sf-dropdown-field-visual ${t.colorClass}" aria-hidden="true"></span>`:"avatar"===t.type&&t.avatarImageUrl?n.html`<span class="sf-avatar sf-avatar--size-1/2 bg-cover sf-dropdown-field-visual" aria-hidden="true" style=${`background-image: url(${t.avatarImageUrl});`}></span>`:n.nothing}function u(e,t){const i=a(t),s=c[e.size]||c[1],o=s.size,r=s.spacing?` spacing-${s.spacing}`:"",l="color"===t.type?"color":"avatar"===t.type?"avatar":"icon";return n.html`
1
+ (()=>{"use strict";var e={"3a03d4610486"(e,t,i){i.d(t,{Q:()=>o});let s=0;function n(e,t){if(!e.id){let i;do{i=`${t}-${++s}`}while(document.getElementById(i));e.id=i}return e.id}function o(e,t){let i=null,s=null,o=null,r=!1;const a=new WeakMap,l=(e,t,i)=>{const s=a.get(e)||{};void 0!==s[t]&&e.getAttribute(t)===s[t]&&e.removeAttribute(t),delete s[t],!e.hasAttribute(t)&&i&&(e.setAttribute(t,i),s[t]=i),a.set(e,s)},c=()=>e.querySelector(".sf-dropdown-field, .sf-dropdown-trigger"),d=()=>c()?.querySelector(":scope > button")||c(),u=()=>c()?.querySelector('input:not([type="hidden"])'),p=()=>t.getList()?.querySelector(".sf-input input"),h=()=>[...t.getList()?.querySelectorAll(".sf-list-item")||[]],f=()=>h().filter(e=>!e.hidden&&!e.classList.contains("disabled")&&"true"!==e.getAttribute("aria-disabled")&&"true"!==e.getAttribute("aria-hidden")),g=e=>e.querySelector(".sf-list-item-container, .sf-avatar-label-group-title, .sf-tag-container")?.textContent?.trim()||e.dataset.value||"",b=e=>{e&&!e.disabled&&(e.focus({preventScroll:!0}),e.scrollIntoView({block:"nearest",inline:"nearest"}))},m=()=>{s="trigger",b(d()),t.close(),x()},v=e=>{if(t.isDisabled()||e.altKey||e.ctrlKey||e.metaKey)return;const i=e.target,n=i.closest?.(".sf-list-item"),o=t.getList()?.contains(i),r=i===d()||i===u()||i===c();let a=!1;if("Escape"===e.key&&t.isOpen())m(),a=!0;else{if("Tab"===e.key&&t.isOpen())return o&&b(d()),t.close(),void x();if(r&&["ArrowDown","ArrowUp","Enter"," "].includes(e.key))t.isOpen()&&["Enter"," "].includes(e.key)?m():(e=>{s=e,t.open(),x()})("ArrowUp"===e.key?"last":"search"),a=!0;else if(o&&["ArrowDown","ArrowUp"].includes(e.key)){const t=f(),i=t.indexOf(n),s=i<0?"ArrowUp"===e.key?t.length-1:0:Math.max(0,Math.min(t.length-1,i+("ArrowUp"===e.key?-1:1)));b(t[s]),a=!0}else if(n&&o&&["Home","End"].includes(e.key)){const t=f();b("Home"===e.key?t[0]:t.at(-1)),a=!0}else n&&o&&["Enter"," "].includes(e.key)&&(f().includes(n)&&(s=t.isMultiple()?{value:n.dataset.value}:"trigger",t.select(n),x()),a=!0)}a&&(e.preventDefault(),e.stopImmediatePropagation())},y=()=>{null!==o&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{var i;o=null,r||!t.isOpen()||s||(i=document.activeElement)&&(e.contains(i)||t.getList()?.contains(i))||(t.close(),x())})};let w=document.createElement("span");w.className="sf-dropdown-value",e.append(w),n(w,"sf-dropdown-value");const x=()=>{if(r)return;const o=t.getList();i!==o&&(i?.removeEventListener("keydown",v,!0),i?.removeEventListener("focusout",y),i=o,i?.addEventListener("keydown",v,!0),i?.addEventListener("focusout",y));const m=d(),x=i?.querySelector(".sf-list-container");if(!m||!x)return;w.isConnected||e.append(w);const _=e.querySelector(".sf-dropdown-label .sf-dropdown-text"),$=t.owner||e,S=_?.textContent.trim()?n(_,"sf-dropdown-label"):"",A=$.getAttribute("aria-label")||e.getAttribute("aria-label"),k=$.getAttribute("aria-labelledby")||e.getAttribute("aria-labelledby"),C=n(m,"sf-dropdown-trigger"),L=m.hasAttribute("aria-label")&&a.get(m)?.["aria-label"]!==m.getAttribute("aria-label");l(m,"aria-labelledby",k||(!A&&S?L?`${C} ${S}`:S:"")),l(m,"aria-label",A),"BUTTON"!==m.tagName&&m.setAttribute("role","button"),m.tabIndex=t.isDisabled()?-1:0,m.setAttribute("aria-expanded",String(t.isOpen())),m.setAttribute("aria-haspopup","listbox"),m.setAttribute("aria-controls",n(x,"sf-dropdown-listbox")),m.querySelectorAll(".sf-icon").forEach(e=>e.setAttribute("aria-hidden","true")),c()!==m&&(c().tabIndex=-1),u()&&(u().tabIndex=-1),x.setAttribute("role","listbox"),x.setAttribute("aria-multiselectable",String(t.isMultiple())),l(x,"aria-labelledby",k||S||C);const z=p();z&&(z.setAttribute("role","searchbox"),z.setAttribute("aria-controls",x.id),l(z,"aria-labelledby",z.hasAttribute("aria-label")?"":k||S||C)),h().forEach(e=>{e.setAttribute("role","option"),e.tabIndex=-1,e.setAttribute("aria-selected",String(e.classList.contains("selected"))),l(e,"aria-disabled",e.classList.contains("disabled")?"true":""),function(e,t){const i=e.querySelector('.sf-checkbox input[type="checkbox"]');if(!i)return;const s=e.querySelector(".sf-checkbox-box sf-icon, .sf-checkbox-box .sf-icon"),n="sf-icon"===s?.tagName?.toLowerCase()?s.getAttribute("icon")||"":s?.textContent;(i.checked!==t||i.indeterminate||s&&n!==(t?"check":""))&&(i.checked=t,i.indeterminate=!1,globalThis.SF?.Checkbox?.setState?.(i,{checked:t,indeterminate:!1}))}(e,e.classList.contains("selected")),e.querySelectorAll(".sf-checkbox").forEach(e=>{"true"!==e.getAttribute("aria-hidden")&&e.setAttribute("aria-hidden","true")}),e.querySelectorAll(".sf-icon, sf-icon").forEach(e=>{"true"!==e.getAttribute("aria-hidden")&&e.setAttribute("aria-hidden","true")}),e.querySelectorAll("input, button, a[href], [tabindex]").forEach(e=>{e.tabIndex=-1})});const V=t.selectedLabels?.()||h().filter(e=>e.classList.contains("selected")).map(g);w.textContent=V.join(", ")||u()?.value||u()?.placeholder||"";const T=new Set((m.getAttribute("aria-describedby")||"").split(/\s+/).filter(Boolean));T.add(w.id),m.setAttribute("aria-describedby",[...T].join(" ")),(()=>{if(!s)return;if("trigger"===s)return s=null,void b(d());if(!t.isOpen()||t.getList()?.hidden)return;const e=f(),i="search"===s?p()||e[0]||d():"last"===s?e.at(-1):"object"==typeof s?e.find(e=>e.dataset.value===s.value):e[0];s=null,b(i)})()};return e.addEventListener("keydown",v,!0),e.addEventListener("focusout",y),x(),{refresh:x,beforeClose:()=>{t.getList()?.contains(document.activeElement)&&(s="trigger")},release(){r=!0,null!==o&&cancelAnimationFrame(o),e.removeEventListener("keydown",v,!0),e.removeEventListener("focusout",y),i?.removeEventListener("keydown",v,!0),i?.removeEventListener("focusout",y);const t=d();if(t){const e=(t.getAttribute("aria-describedby")||"").split(/\s+/).filter(e=>e&&e!==w.id);e.length?t.setAttribute("aria-describedby",e.join(" ")):t.removeAttribute("aria-describedby")}w.remove()}}}},a0f23dca0b37(e,t,i){i.a(e,async(e,s)=>{try{i.d(t,{AL:()=>g,GD:()=>f});var n=i("5c1dc214bb5e"),o=e([n]);n=(o.then?(await o)():o)[0];var r=i.n(n);const a=()=>globalThis.SF?.Position||r(),l=new WeakMap,c=["position","inset","margin","width","max-width","max-height","overflow","left","top","right","bottom","z-index"],d=["font-family","font-size","font-weight","font-style","font-stretch","font-variant","font-feature-settings","font-variation-settings","font-optical-sizing","font-kerning","line-height","letter-spacing","word-spacing","text-transform","text-indent","white-space","word-break","overflow-wrap","text-rendering","direction","writing-mode","text-orientation","color","color-scheme","text-align"];function u(e,t){if(!t.context)return;const i=t.context,s=getComputedStyle(e),n=["sf-dropdown",...Array.from(e.classList).filter(e=>e.startsWith("sf-dropdown--")&&!["sf-dropdown--open","sf-dropdown--drop-up","sf-dropdown--drop-down"].includes(e))].join(" ");i.className!==n&&(i.className=n);const o=[...Array.from(s).filter(e=>e.startsWith("--sf-")),...d],r=new Set(o);for(const e of t.contextProperties||[])r.has(e)||i.style.removeProperty(e);for(const e of o){const t=s.getPropertyValue(e);i.style.getPropertyValue(e)!==t&&i.style.setProperty(e,t)}t.contextProperties=o}function p(e){return e?.querySelector(".sf-dropdown-field, .sf-dropdown-trigger")??null}function h(e,t){const i=l.get(t);if(!i||!e.isConnected||t.hidden)return!1;const s=p(e);return!!s&&(e.closest('[hidden], [inert], [aria-hidden="true"], dialog:not([open])')||!s.getClientRects().length||["hidden","collapse"].includes(getComputedStyle(s).visibility)?(i.onUnavailable?.(),!1):(u(e,i),i.wrap&&(i.wrap.style.minHeight="0",i.wrap.style.overflowY="auto"),i.anchor||(i.anchor=a().anchor(s,t,{side:"block-end",align:"start",matchWidth:s.classList.contains("sf-dropdown-field"),fitHeight:!0,autoUpdate:!1,onPosition:({side:i})=>{const s="block-start"===i;t.dataset.placement=e.dataset.placement=s?"top":"bottom",e.classList.toggle("sf-dropdown--drop-up",s),e.classList.toggle("sf-dropdown--drop-down",!s)}})),i.anchor.update(),!0))}function f(e,t,i){if(!t?.isConnected||!p(e))return!1;const s=t.contains(document.activeElement)?document.activeElement:null;if(!l.has(t)){const s=c.map(e=>[e,t.style.getPropertyValue(e),t.style.getPropertyPriority(e)]),n={root:e,saved:s,onUnavailable:i,popover:t.getAttribute("popover"),frame:0,native:"function"==typeof t.showPopover};if(n.wrap=t.querySelector(".sf-list-container-wrap"),n.wrapStyles=n.wrap?["min-height","overflow-y"].map(e=>[e,n.wrap.style.getPropertyValue(e),n.wrap.style.getPropertyPriority(e)]):[],n.schedule=()=>{n.frame||(n.frame=requestAnimationFrame(()=>{n.frame=0,h(e,t)}))},l.set(t,n),e.__sfDropdownPortalList=t,n.native)t.setAttribute("popover","manual");else{n.parent=t.parentNode,n.next=t.nextSibling,n.context=document.createElement("div"),n.context.style.cssText="display:contents;position:static",u(e,n);(e.closest('dialog[open], [role="dialog"][aria-modal="true"]')||document.body).append(n.context),n.context.append(t),t.style.zIndex="var(--sf-z-index-9)"}n.inheritance=new MutationObserver(n.schedule);for(let t=e;t;t=t.parentElement)n.inheritance.observe(t,{attributes:!0,attributeFilter:["class","style","dir","hidden","inert","aria-hidden","open"]});Object.assign(t.style,{position:"fixed",inset:"auto",margin:"0",overflow:n.wrap?"hidden":"auto"}),"function"==typeof ResizeObserver&&(n.resize=new ResizeObserver(n.schedule),n.resize.observe(p(e)),n.resize.observe(t)),window.visualViewport?.addEventListener("resize",n.schedule),window.visualViewport?.addEventListener("scroll",n.schedule)}return t.hidden=!1,l.get(t).native&&!t.matches(":popover-open")&&t.showPopover(),!!h(e,t)&&(s&&document.activeElement!==s&&s.focus({preventScroll:!0}),!0)}function g(e){const t=l.get(e);if(!t)return!1;const i=e.contains(document.activeElement)?document.activeElement:null;t.anchor?.stop(),t.resize?.disconnect(),cancelAnimationFrame(t.frame),t.inheritance?.disconnect(),window.visualViewport?.removeEventListener("resize",t.schedule),window.visualViewport?.removeEventListener("scroll",t.schedule),t.native?(e.matches(":popover-open")&&e.hidePopover(),null===t.popover?e.removeAttribute("popover"):e.setAttribute("popover",t.popover)):(t.next?.parentNode===t.parent?t.parent.insertBefore(e,t.next):t.parent.append(e),t.context.remove());for(const[i,s,n]of t.saved)s?e.style.setProperty(i,s,n):e.style.removeProperty(i);for(const[e,i,s]of t.wrapStyles)i?t.wrap.style.setProperty(e,i,s):t.wrap.style.removeProperty(e);return delete e.dataset.placement,delete t.root.dataset.placement,t.root.classList.remove("sf-dropdown--drop-up","sf-dropdown--drop-down"),t.root.__sfDropdownPortalList===e&&delete t.root.__sfDropdownPortalList,l.delete(e),i&&!e.hidden&&t.root.isConnected&&document.activeElement!==i&&i.focus({preventScroll:!0}),!0}s()}catch(b){s(b)}})},"98e26702f55a"(e,t,i){function s(){const e=globalThis.SF=globalThis.SF||{};return e.__deprecationNotes instanceof Map||Object.defineProperty(e,"__deprecationNotes",{value:new Map,configurable:!0}),e.__deprecationNotes}function n({component:e="",kind:t="attribute",attribute:i="",from:n,to:o=null}={}){if(!n)return;const r=[e,t,i,n].join("|"),a=s(),l=a.get(r);if(l)l.count+=1;else if(a.set(r,{component:e,kind:t,attribute:i,from:n,to:o,count:1}),function(){const e=globalThis.document?.documentElement;return"warn"===e?.dataset?.sfDeprecations||!0===globalThis.SF?.deprecations?.warn}()){const s=e?`${e}: `:"",r="value"===t?`${i}="${n}"`:`${t} ${n}`;globalThis.console?.warn?.(`[SIMAI Framework] ${s}${r} is a legacy name${o?`; write ${o}`:""}. See contracts/changes/journal.json.`)}}if(i.d(t,{id:()=>c,kA:()=>l}),"undefined"!=typeof globalThis){globalThis.SF=globalThis.SF||{};const e=globalThis.SF.deprecations||{};e.list=function(){return[...s().values()].map(e=>({...e}))},e.clear=function(){s().clear()},e.note=n,globalThis.SF.deprecations=e}const o=Object.freeze(["1/2","1","2"]),r=Object.freeze({"1/3":"1/2",3:"2"}),a=new Set;function l(e){const t=String(e??"").trim().toLowerCase();return o.includes(t)?t:Object.hasOwn(r,t)?r[t]:"1"}function c(e,t="field",i="1"){const s=String(e??"").trim().toLowerCase();if(o.includes(s))return s;if(Object.hasOwn(r,s)){const e=r[s];n({component:t,kind:"value",attribute:"size",from:s,to:e});const i=`${t}:${s}`;return a.has(i)||"undefined"==typeof console||(a.add(i),console.warn(`[SIMAI Framework] ${t}: size ${s} is retired for form fields; rendering size ${e}.`)),e}return i}},"67eed2647f47"(e,t,i){i.d(t,{z:()=>o});const s=new WeakMap,n=new WeakSet;function o(e,t){const i=e.ownerDocument;n.has(i)||(i.addEventListener("reset",e=>{const t=e.target;if("FORM"!==t?.tagName)return;const i=Array.from(t.elements);setTimeout(()=>{if(!e.defaultPrevented)for(const e of i)if(e.isConnected&&e.form===t)for(const t of s.get(e)||[])t()},0)},!0),n.add(i));let o=s.get(e);return o||s.set(e,o=new Set),o.add(t),()=>o.delete(t)}},"50a1017ded91"(e,t,i){i.a(e,async(e,t)=>{try{var s=i("fbe0570fcc69"),n=i("0d662e4d7d63"),o=i("98e26702f55a"),r=i("5429d6e80991"),a=i("3a03d4610486"),l=i("67eed2647f47"),c=i("a0f23dca0b37"),d=e([s,n,r,c]);[s,n,r,c]=d.then?(await d)():d;var u=i.n(s);const p={en:{search:"Search"},ru:{search:"Поиск"}};function h(e){return(0,o.id)(e,"sf-dropdown")}function f(e){const t=String(e||"").toLowerCase();return["text","icon","checkbox","avatar","color"].includes(t)?t:"text"}function g(e,t="1"){return e instanceof HTMLElement?"sf-list-item"!==e.tagName.toLowerCase()?null:{type:f(e.getAttribute("kind")||e.getAttribute("type")),size:h(e.getAttribute("size")||t),text:e.getAttribute("text")||"",icon:e.getAttribute("icon")||"person",checked:e.hasAttribute("checked")||(0,s.toBoolean)(e.getAttribute("checked")),selected:e.hasAttribute("selected")||(0,s.toBoolean)(e.getAttribute("selected")),disabled:e.hasAttribute("disabled")||(0,s.toBoolean)(e.getAttribute("disabled")),colorClass:e.getAttribute("color-class")||"bg-tertiary",avatarImageUrl:e.getAttribute("avatar-image-url")||"",avatarTitle:e.getAttribute("avatar-title")||e.getAttribute("text")||"",value:e.getAttribute("value")??e.getAttribute("text")??"",ariaLabel:e.getAttribute("aria-label")||"",group:e.getAttribute("group")||""}:null}function b(e,t="1"){if(!e||"object"!=typeof e)return null;const i=void 0===e.text||null===e.text?"":String(e.text),n=void 0===e.value||null===e.value?i:String(e.value);return""===i&&""===n?null:{type:f(e.kind||e.type),size:h(e.size||t),text:i,icon:e.icon?String(e.icon):"person",checked:(0,s.toBoolean)(e.checked),selected:(0,s.toBoolean)(e.selected),disabled:(0,s.toBoolean)(e.disabled),colorClass:e.colorClass?String(e.colorClass):"bg-tertiary",avatarImageUrl:e.avatarImageUrl?String(e.avatarImageUrl):"",avatarTitle:e.avatarTitle?String(e.avatarTitle):i,value:n,ariaLabel:e.ariaLabel?String(e.ariaLabel):"",group:e.group?String(e.group):""}}function m(e,t="1"){let i=e;if("string"==typeof i){const e=i.trim();if(""===e)return[];try{i=JSON.parse(e)}catch{return[]}}return Array.isArray(i)?i.map(e=>b("string"==typeof e||"number"==typeof e?{text:String(e),value:String(e)}:e,t)).filter(Boolean):[]}function v(e=""){return String(e||"").split(",").map(e=>e.trim()).filter(Boolean)}function y(e=[]){return e.map(e=>String(e)).join(",")}function w(e={}){return"avatar"===e.type?e.avatarTitle||e.text||e.value||"":e.text||e.avatarTitle||e.value||""}class x extends(u()){constructor(){super(),this._options=[],this._optionsCaptured=!1,this._optionsFromData=!1,this._open=!1,this._searchValue="",this._selectedValues=[],this._dropdownRoot=null,this._list=null,this._documentClickHandler=this.handleDocumentClick.bind(this),this._viewportHandler=this.positionPortalList.bind(this)}static get props(){return{templateName:{attribute:"template",default:"default"},size:{default:"1"},appearance:{default:"outlined",values:["filled","outlined"],aliases:["type"]},mode:{default:"select",values:["tag","select"]},multiple:{type:Boolean,default:!1},portal:{type:Boolean,default:!0},value:{default:""},name:{default:""},label:{default:""},required:{type:Boolean,default:!1},placeholder:{default:""},searchPlaceholder:{default:""},search:{type:Boolean,default:!0},layout:{default:"list",values:["list","grid"]},columns:{default:"6"},disabled:{type:Boolean,default:!1},ariaLabel:{default:""}}}connectedCallback(){this.captureOptions(),Object.prototype.hasOwnProperty.call(this,"_resetValues")||(this._resetValues=[...this.selectedValues]),super.connectedCallback()}attributeChangedCallback(e,t,i){t!==i&&("value"===e&&(this._selectedValues=v(i)),"disabled"===e&&this.disabled&&(this._open=!1,this._searchValue="")),super.attributeChangedCallback(e,t,i)}get componentName(){return"dropdown"}get templateName(){return this.getAttribute("template")||"default"}get size(){return h(this.getAttribute("size"))}get appearance(){return this.getProp("appearance")}get type(){return this.appearance}get mode(){return this.getEnumAttr("mode",["tag","select"],"select")}get multiple(){return this.hasAttribute("multiple")?this.getBooleanAttr("multiple",!0):"tag"===this.mode}get portal(){return this.getBooleanAttr("portal",!0)}get name(){return this.getAttribute("name")||""}get selectedValue(){return this.getAttribute("value")||""}get label(){return this.getAttribute("label")||""}get required(){return this.getBooleanAttr("required",!1)}get placeholder(){return this.getAttribute("placeholder")||""}get searchPlaceholder(){return this.getAttribute("search-placeholder")||(0,n.pageText)(p,"search",this)}get layout(){return this.getEnumAttr("layout",["list","grid"],"list")}get columns(){const e=Number.parseInt(this.getAttribute("columns")??"",10);return Number.isFinite(e)&&e>0?String(e):"6"}get search(){return this.getBooleanAttr("search",!0)}get disabled(){return this.getBooleanAttr("disabled",!1)}get ariaLabel(){return this.getAttribute("aria-label")||""}get selectedValues(){return this.hasAttribute("value")?v(this.selectedValue):this._selectedValues}get selectedOptions(){const e=this.options;return[...new Set(this.selectedValues)].map(t=>e.find(e=>String(e.value)===t)).filter(Boolean)}get triggerText(){if("tag"===this.mode)return"";return(this.multiple?this.selectedOptions:this.selectedOptions.slice(0,1)).map(w).join(", ")}get hiddenValue(){return this.selectedValues.join(",")}captureOptions(){if(this._optionsFromData)return;const e=Array.from(this.children).filter(e=>e instanceof HTMLElement&&"sf-list-item"===e.tagName.toLowerCase());e.length&&(this._options=e.map(e=>g(e,this.size)).filter(Boolean),this._optionsCaptured=!0,this.selectedValue||this._selectedValues.length||(this._selectedValues=this._options.filter(e=>e.selected).map(e=>String(e.value))),e.forEach(e=>e.remove()))}set options(e){const t=m(e,this.size);this._optionsFromData=!0,this._options=t,this._optionsCaptured=!0,this.selectedValue||this._selectedValues.length||(this._selectedValues=t.filter(e=>e.selected).map(e=>String(e.value))),this.requestComponentUpdate("options")}get options(){if(!Array.isArray(this._options)||!this._options.length)return[];const e=new Set(this.selectedValues);return this._options.map(t=>({...t,size:h(t.size||this.size),selected:e.has(String(t.value))}))}get visibleOptions(){const e=String(this._searchValue||"").trim().toLowerCase();return e?this.options.filter(t=>w(t).toLowerCase().includes(e)):this.options}templateContext(){const e=this.getPropsContext();return this.createTemplateContext({...e,component:this,open:this._open,multiple:this.multiple,value:this.hiddenValue,triggerText:this.triggerText,searchValue:this._searchValue,searchPlaceholder:this.searchPlaceholder,selectedValues:this.selectedValues,selectedOptions:this.selectedOptions,options:this.visibleOptions})}template(){return(0,r.g)(this.templateContext())}beforeRender(){this.captureOptions()}afterRender(){const e=this._dropdownRoot,t=this._list;this._dropdownRoot=this.querySelector(".sf-dropdown"),this._list=this.querySelector(".sf-list")||(e===this._dropdownRoot?t:null),t!==this._list&&(0,c.AL)(t),this.syncDocumentListeners(),this.syncPortalListeners(),this.positionPortalList(),e!==this._dropdownRoot&&(this._interaction?.release(),this._interaction=null),this._dropdownRoot&&!this._interaction&&(this._interaction=(0,a.Q)(this._dropdownRoot,{owner:this,getList:()=>this._list,isOpen:()=>this._open,isDisabled:()=>this.disabled,isMultiple:()=>this.multiple,open:()=>this.openDropdown(),close:()=>this.closeDropdown(),select:e=>this.selectValue(e.dataset.value||""),selectedLabels:()=>this.selectedOptions.map(w)})),this._interaction?.refresh();const i=this.querySelector(".sf-dropdown-hidden-input")||this.querySelector(".sf-dropdown-field > button");this._resetControl!==i&&(this._releaseReset?.(),this._resetControl=i,this._releaseReset=i?(0,l.z)(i,()=>{this._interaction?.beforeClose(),this._selectedValues=[...this._resetValues],this.setAttributeValue("value",y(this._selectedValues)),this._open=!1,this._searchValue="";const e=this.querySelector('.sf-dropdown-field input:not([type="hidden"])');e&&(e.value=this.triggerText),this.requestComponentUpdate("reset")}):null)}onDisconnected(){(0,c.AL)(this._list),this._releaseReset?.(),this._releaseReset=null,this._resetControl=null,this._interaction?.release(),this._interaction=null,this.removeDocumentListeners(),this.removePortalListeners(),super.onDisconnected()}openDropdown(){return this.disabled||this._open||(this._open=!0,this.requestComponentUpdate("open")),this}closeDropdown(){return this._open?(this._interaction?.beforeClose(),this._open=!1,this._searchValue="",this.requestComponentUpdate("close"),this):this}toggleDropdown(){return this._open?this.closeDropdown():this.openDropdown()}handleTriggerClick(e){this.disabled||(e?.preventDefault?.(),this.toggleDropdown())}handleSearchInput(e){this._searchValue=e?.target?.value||"",this.requestComponentUpdate("search")}handleOptionClick(e){if(this.disabled)return;const t=e.target?.closest?.(".sf-list-item");t&&(this.contains(t)||this._list?.contains(t))&&!t.classList.contains("disabled")&&(e.preventDefault(),this.selectValue(t.dataset.value||""))}handleOptionKeydown(e){"Enter"!==e.key&&" "!==e.key||this.handleOptionClick(e)}handleDocumentClick(e){!this._open||this.contains(e.target)||this._list?.contains(e.target)||this.closeDropdown()}selectValue(e=""){if(this.disabled)return this;const t=this.options.find(t=>String(t.value)===String(e));if(!t||t.disabled)return this;const i=!this.multiple&&1===this.selectedValues.length&&this.selectedValues[0]===String(t.value);if(this.multiple){const e=new Set(this.selectedValues);e.has(String(t.value))?e.delete(String(t.value)):e.add(String(t.value)),this._selectedValues=Array.from(e)}else this._selectedValues=[String(t.value)];const s=[...this._selectedValues];return this.setAttributeValue("value",y(s)),i||this.dispatchDropdownChange(t,s),this.multiple||(this._interaction?.beforeClose(),this._open=!1,this._searchValue=""),this.requestComponentUpdate("select"),this}removeSelectedValue(e=""){if(this.disabled)return this;const t=new Set(this.selectedValues);t.delete(String(e)),this._selectedValues=Array.from(t);const i=[...this._selectedValues];return this.setAttributeValue("value",y(i)),this.dispatchDropdownChange(null,i),this.requestComponentUpdate("remove-tag"),this}dispatchDropdownChange(e=null,t=this.selectedValues){const i={value:e?.value||"",label:e?w(e):"",values:t,item:e,root:this,multiple:this.multiple};this.dispatchEvent(new CustomEvent("sf-dropdown:change",{bubbles:!0,composed:!0,detail:i})),this.dispatchEvent(new CustomEvent("change",{bubbles:!0,composed:!0,detail:i}))}syncDocumentListeners(){this._open?document.addEventListener("click",this._documentClickHandler):this.removeDocumentListeners()}removeDocumentListeners(){document.removeEventListener("click",this._documentClickHandler)}syncPortalListeners(){if(this._open&&this.portal)return window.addEventListener("resize",this._viewportHandler),void document.addEventListener("scroll",this._viewportHandler,!0);this.removePortalListeners()}removePortalListeners(){window.removeEventListener("resize",this._viewportHandler),document.removeEventListener("scroll",this._viewportHandler,!0)}positionPortalList(){this._list&&this._dropdownRoot&&this.portal&&this._open?(0,c.GD)(this._dropdownRoot,this._list,()=>this.closeDropdown()):(0,c.AL)(this._list)}get value(){return this.hiddenValue}set value(e){if(e&&"object"==typeof e&&!Array.isArray(e))return void this.setValueAttributes(e);const t=Array.isArray(e)?e.map(String):v(null==e?"":String(e));this.setAttributeValue("value",y(t))}}x.define("sf-dropdown"),t()}catch(_){t(_)}})},"5429d6e80991"(e,t,i){i.a(e,async(e,s)=>{try{i.d(t,{g:()=>h});var n=i("ddf1cdb42ecc"),o=i("c22590307c6c"),r=e([n,o]);[n,o]=r.then?(await r)():r;function a(e={}){return"avatar"===e.type?e.avatarTitle||e.text||e.value||"":e.text||e.avatarTitle||e.value||""}function l(e=[]){const t=[];let i=null;for(const s of e){const e=s.group?String(s.group):"";e!==i&&(i=e,e&&t.push((0,o.aU)(e,s.size))),t.push((0,o.lN)(s))}return t}const c=Object.freeze({"1/2":{size:"1/3",spacing:""},1:{size:"1",spacing:"compact"},2:{size:"2",spacing:"compact"}});function d(e){if(e.multiple||1!==e.selectedOptions?.length)return n.nothing;const t=e.selectedOptions[0];return"icon"===t.type&&t.icon?n.html`<i class="sf-icon sf-dropdown-field-visual" aria-hidden="true">${t.icon}</i>`:"color"===t.type&&t.colorClass?n.html`<span class="sf-tag-color-icon sf-dropdown-field-visual ${t.colorClass}" aria-hidden="true"></span>`:"avatar"===t.type&&t.avatarImageUrl?n.html`<span class="sf-avatar sf-avatar--size-1/2 bg-cover sf-dropdown-field-visual" aria-hidden="true" style=${`background-image: url(${t.avatarImageUrl});`}></span>`:n.nothing}function u(e,t){const i=a(t),s=c[e.size]||c[1],o=s.size,r=s.spacing?` spacing-${s.spacing}`:"",l="color"===t.type?"color":"avatar"===t.type?"avatar":"icon";return n.html`
2
2
  <div
3
3
  class="sf-tag transition sf-tag--${l} sf-tag--size-${o} sf-tag--inline${r} flex flex-row flex-nowrap items-center active"
4
4
  data-value=${t.value}