@kashi-ui/elements 2.24.1 → 2.26.0
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.
- package/README.md +3 -3
- package/dist/base.d.ts +110 -0
- package/dist/capture.d.ts +75 -0
- package/dist/capture.js +456 -0
- package/dist/cdn/{appointment-DOXBUwIU.js → appointment-BaEWfjSX.js} +1 -1
- package/dist/cdn/base-BqFAMlwG.js +1 -0
- package/dist/cdn/{basic-DuY4RslZ.js → basic-BBvsRt91.js} +1 -1
- package/dist/cdn/{buttons-BaK6bx3w.js → buttons-BmP5wikN.js} +1 -1
- package/dist/cdn/{calendar-BulPeVAJ.js → calendar-CwKogl-G.js} +1 -1
- package/dist/cdn/capture-B48H5hmR.js +24 -0
- package/dist/cdn/{card-BKiwJF34.js → card-C0nariT-.js} +1 -1
- package/dist/cdn/{cards-DKarXHsC.js → cards-D9-wNDK8.js} +1 -1
- package/dist/cdn/{charts-ETYOAJyB.js → charts-Cct32znI.js} +1 -1
- package/dist/cdn/{chat-D5ZIMnNp.js → chat-Dg5CEN6Y.js} +1 -1
- package/dist/cdn/{choice-DBvC2Puo.js → choice-cDqbHUTC.js} +1 -1
- package/dist/cdn/combobox-Drm8K9Zk.js +1 -0
- package/dist/cdn/commerce-JkDctt2h.js +1 -0
- package/dist/cdn/{content-DN3eXLg-.js → content-CqUXcDCi.js} +1 -1
- package/dist/cdn/{controls--OMZkJYe.js → controls-CquzGwtr.js} +1 -1
- package/dist/cdn/{display-BfYWAjNu.js → display-DW5JEQXT.js} +1 -1
- package/dist/cdn/{fields-B-jTUQiI.js → fields-C-ytjZil.js} +1 -1
- package/dist/cdn/forms-CurTYl2V.js +1 -0
- package/dist/cdn/gantt-QfHFG7O8.js +14 -0
- package/dist/cdn/{holidays-Cu6IfbTL.js → holidays-DgmHlqJX.js} +1 -1
- package/dist/cdn/{hours-CeiVqPKD.js → hours-CmICISQO.js} +1 -1
- package/dist/cdn/inputs-DWLKbi57.js +1 -0
- package/dist/cdn/invoice-BUMyjBVi.js +10 -0
- package/dist/cdn/kashi-elements.js +1 -1
- package/dist/cdn/{legal-id-Mt8FX0fV.js → legal-id-B_0kbcQT.js} +1 -1
- package/dist/cdn/lists-D0dao20N.js +1 -0
- package/dist/cdn/{map-TfSt3CjL.js → map-BxlzfCbM.js} +1 -1
- package/dist/cdn/{media-BRBINvzU.js → media-QVgCYQSu.js} +1 -1
- package/dist/cdn/{menu-DTNVFXrb.js → menu-DcFyTTHv.js} +1 -1
- package/dist/cdn/{money-CjGI2VIQ.js → money-BFEbgLJn.js} +1 -1
- package/dist/cdn/{nav-CT5RVOzy.js → nav-Cm8mAT09.js} +1 -1
- package/dist/cdn/{overlay-CS8piW6X.js → overlay-C1nbLv6h.js} +1 -1
- package/dist/cdn/pickers-DQgK1WAX.js +1 -0
- package/dist/cdn/{relative-OC1fV3Xh.js → relative-BoBZPiB7.js} +1 -1
- package/dist/cdn/{rich-text-CS6xEim6.js → rich-text-9IAZ_T8A.js} +1 -1
- package/dist/cdn/search-BvShDz2X.js +1 -0
- package/dist/cdn/{sheets-CVbD98PY.js → sheets-CNF5lSVn.js} +1 -1
- package/dist/cdn/table-D1xiHZCM.js +2 -0
- package/dist/cdn/{text-C6fzEBBh.js → text-DFyW6cuq.js} +1 -1
- package/dist/cdn/{time-CkqqUKJv.js → time-CYZzyy_3.js} +1 -1
- package/dist/cdn/{time-CwOYrtK-.js → time-oyKIQ2bk.js} +1 -1
- package/dist/cdn/{validate-Dr2f6i6s.js → validate-CRU7rfNs.js} +1 -1
- package/dist/cdn/{work-DoNAKgVU.js → work-DS2MbtGM.js} +1 -1
- package/dist/cdn.js +5 -1
- package/dist/combobox.js +4 -4
- package/dist/commerce.js +2 -2
- package/dist/gantt.d.ts +41 -0
- package/dist/gantt.js +179 -0
- package/dist/index.d.ts +18 -3
- package/dist/index.js +8 -3
- package/dist/inputs.d.ts +16 -0
- package/dist/inputs.js +62 -2
- package/dist/invoice.d.ts +52 -0
- package/dist/invoice.js +75 -0
- package/dist/lists.d.ts +57 -0
- package/dist/lists.js +306 -0
- package/dist/manifest.json +168 -3
- package/dist/pickers.d.ts +4 -0
- package/dist/pickers.js +34 -6
- package/dist/table.d.ts +15 -1
- package/dist/table.js +184 -5
- package/package.json +4 -4
- package/dist/cdn/base-D4tCOysh.js +0 -1
- package/dist/cdn/combobox-BGuPAAt3.js +0 -1
- package/dist/cdn/commerce-SzWdpWJG.js +0 -1
- package/dist/cdn/forms-DgRiYmdV.js +0 -1
- package/dist/cdn/inputs-BkJ70Xkc.js +0 -1
- package/dist/cdn/pickers-BwDRsDRo.js +0 -1
- package/dist/cdn/table-tgB4iwcM.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as e,l as t,n,o as r,p as i,t as a}from"./base-
|
|
1
|
+
import{g as e,l as t,n,o as r,p as i,t as a}from"./base-BqFAMlwG.js";let o=1;function s(){let e=document.querySelectorAll(`kashi-toaster`);if(e.length)return e[e.length-1];let t=document.createElement(`kashi-toaster`);return document.body.append(t),t}function c(e){let t=e.id??o++;return s().upsert({...e,id:t}),t}function l(e){return c(typeof e==`string`?{title:e}:e)}l.success=(e,t={})=>l({...t,title:e,tone:`success`}),l.error=(e,t={})=>l({...t,title:e,tone:`error`}),l.warning=(e,t={})=>l({...t,title:e,tone:`warning`}),l.info=(e,t={})=>l({...t,title:e,tone:`info`}),l.dismiss=e=>document.querySelectorAll(`kashi-toaster`).forEach(t=>t.dismiss(e)),l.promise=(e,t)=>{let n=c({title:t.loading,tone:`info`,duration:1/0,loading:!0});return e.then(e=>c({id:n,title:typeof t.success==`function`?t.success(e):t.success,tone:`success`}),e=>c({id:n,title:typeof t.error==`function`?t.error(e):t.error,tone:`error`})),e};var u=class extends a{constructor(){super(...arguments),this.list=null}connectedCallback(){this.list||=(this.innerHTML=`<section><ol class="k-toaster" aria-live="polite"></ol></section>`,this.querySelector(`ol`)),this.decorate()}attributeChangedCallback(){this.list&&this.decorate()}decorate(){let e=this.getAttribute(`placement`)??`bottom-end`;this.list.className=`k-toaster k-toaster--${e}`,this.list.dataset.placement=e,this.querySelector(`section`).setAttribute(`aria-label`,this.getAttribute(`label`)??i().toast.region)}upsert(e){this.list||this.connectedCallback();let t=[...this.list.children].find(t=>t.toastId===e.id),n=d(e,this.getAttribute(`close-label`)??i().toast.close,()=>this.dismiss(e.id));t?(t.stop?.(),t.replaceWith(n)):this.list.append(n);let r=Number(this.getAttribute(`max`))||5;for(;this.list.children.length>r;)this.list.firstElementChild.stop?.(),this.list.firstElementChild.remove()}dismiss(e){let t=[...this.list?.children??[]].find(t=>t.toastId===e);t&&t.dataset.state!==`closing`&&(t.stop?.(),t.dataset.state=`closing`,setTimeout(()=>t.remove(),200))}};u.observedAttributes=[`placement`,`label`];function d(e,r,i){let a=e.duration??(e.action?1/0:5e3),o=e.tone??`neutral`,s=document.createElement(`li`);s.toastId=e.id,s.className=`k-toast${o===`neutral`?``:` k-toast--${o}`}`,s.dataset.state=`open`,s.setAttribute(`role`,o===`error`?`alert`:`status`),s.innerHTML=`<span class="k-toast__icon" aria-hidden="true">${e.loading?`<span class="k-spinner k-spinner--sm" style="color: inherit"></span>`:n[o===`neutral`?`info`:o]}</span><div class="k-toast__content"><p class="k-toast__title">${t(e.title)}</p>${e.description?`<p class="k-toast__description">${t(e.description)}</p>`:``}${e.action?`<button type="button" class="k-btn k-btn--link k-toast__action">${t(e.action.label)}</button>`:``}</div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-toast__close" aria-label="${t(r)}">${n.close}</button>${Number.isFinite(a)?`<span class="k-toast__progress" aria-hidden="true" style="animation-duration: ${a}ms"></span>`:``}`,s.querySelector(`.k-toast__close`).addEventListener(`click`,i),s.querySelector(`.k-toast__action`)?.addEventListener(`click`,()=>{e.action.onClick(),i()}),s.addEventListener(`keydown`,e=>e.key===`Escape`&&i());let c=a,l=0,u,d=()=>{u===void 0&&Number.isFinite(c)&&(l=Date.now(),u=setTimeout(i,c))},f=()=>{u!==void 0&&(clearTimeout(u),u=void 0,c-=Date.now()-l)};return s.addEventListener(`mouseenter`,f),s.addEventListener(`focusin`,f),s.addEventListener(`mouseleave`,d),s.addEventListener(`focusout`,d),s.stop=()=>{clearTimeout(u),c=1/0},d(),s}r(`kashi-toaster`,u),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-toast]`);t&&l({title:t.dataset.kashiToast,description:t.dataset.description,tone:t.dataset.tone??`neutral`})});const f=/* @__PURE__ */ new Set([[[`kashi-national-id`,`kashi-legal-id`,`kashi-mobile`,`kashi-landline`,`kashi-card-number`,`kashi-iban`,`kashi-postal-code`,`kashi-price`,`kashi-sayad`,`kashi-economic-code`,`kashi-tax-id`,`kashi-bill-id`,`kashi-payment-id`],()=>import(`./inputs-DWLKbi57.js`)],[[`kashi-otp`],()=>import(`./fields-C-ytjZil.js`)],[[`kashi-combobox`,`kashi-province-select`,`kashi-city-select`],()=>import(`./combobox-Drm8K9Zk.js`).then(e=>e.t)],[[`kashi-iran-map`,`kashi-address-form`],()=>import(`./map-BxlzfCbM.js`)],[[`kashi-calendar`,`kashi-date-picker`],()=>import(`./calendar-CwKogl-G.js`)],[[`kashi-time-picker`,`kashi-time-clock`],()=>import(`./time-CYZzyy_3.js`)],[[`kashi-money`,`kashi-date`,`kashi-relative-time`,`kashi-countdown`],()=>import(`./display-DW5JEQXT.js`)],[[`kashi-dialog`,`kashi-tabs`,`kashi-tooltip`,`kashi-copy-button`],()=>import(`./overlay-C1nbLv6h.js`)],[[`kashi-dropdown-menu`,`kashi-popover`],()=>import(`./menu-DcFyTTHv.js`)],[[`kashi-tag-input`,`kashi-number-input`,`kashi-rating`,`kashi-pagination`],()=>import(`./controls-CquzGwtr.js`)],[[`kashi-data-table`],()=>import(`./table-D1xiHZCM.js`)],[[`kashi-multi-select`,`kashi-slider`,`kashi-chip-group`,`kashi-password-strength`,`kashi-persian-textarea`,`kashi-keyboard-fix`,`kashi-time-input`,`kashi-plate-input`,`kashi-inline-edit`],()=>import(`./forms-CurTYl2V.js`)],[[`kashi-date-range-picker`,`kashi-month-picker`,`kashi-file-upload`,`kashi-color-picker`],()=>import(`./pickers-DQgK1WAX.js`)],[[`kashi-bar-chart`,`kashi-line-chart`,`kashi-pie-chart`,`kashi-bar-list`,`kashi-proportion-bar`,`kashi-sparkline`,`kashi-activity-heatmap`],()=>import(`./charts-Cct32znI.js`)],[[`kashi-input`,`kashi-textarea`,`kashi-banner`],()=>import(`./basic-BBvsRt91.js`)],[[`kashi-appointment-picker`],()=>import(`./appointment-BaEWfjSX.js`)],[[`kashi-price-range`,`kashi-swatch-group`,`kashi-search-suggest`],()=>import(`./commerce-JkDctt2h.js`)],[[`kashi-command-palette`,`kashi-context-menu`,`kashi-carousel`,`kashi-tree-view`,`kashi-tour`,`kashi-splitter`,`kashi-side-nav`],()=>import(`./nav-Cm8mAT09.js`)],[[`kashi-badge`,`kashi-avatar`,`kashi-avatar-group`,`kashi-divider`,`kashi-skeleton`,`kashi-card`,`kashi-empty-state`,`kashi-stat-card`,`kashi-alert`,`kashi-meter`,`kashi-progress`,`kashi-timeline`,`kashi-stepper`],()=>import(`./content-CqUXcDCi.js`)],[[`kashi-button`,`kashi-button-group`,`kashi-segmented-control`,`kashi-breadcrumb`,`kashi-accordion`],()=>import(`./buttons-BmP5wikN.js`)],[[`kashi-checkbox`,`kashi-switch`,`kashi-radio-group`,`kashi-select`],()=>import(`./choice-cDqbHUTC.js`)],[[`kashi-drawer`,`kashi-bottom-sheet`,`kashi-navbar`,`kashi-notification-list`,`kashi-notification-center`],()=>import(`./sheets-CNF5lSVn.js`)],[[`kashi-chat`,`kashi-chat-message`,`kashi-typing-indicator`,`kashi-chat-composer`,`kashi-streaming-text`,`kashi-code-block`],()=>import(`./chat-Dg5CEN6Y.js`)],[[`kashi-sortable`,`kashi-kanban`,`kashi-scheduler`],()=>import(`./work-DS2MbtGM.js`)],[[`kashi-gallery`,`kashi-qr-code`],()=>import(`./media-QVgCYQSu.js`)],[[`kashi-rich-text`],()=>import(`./rich-text-9IAZ_T8A.js`)],[[`kashi-form`],()=>import(`./validate-CRU7rfNs.js`)],[[`kashi-bank-card`,`kashi-receipt`,`kashi-date-tile`],()=>import(`./cards-D9-wNDK8.js`)],[[`kashi-business-hours`],()=>import(`./hours-CmICISQO.js`)],[[`kashi-signature-pad`,`kashi-image-cropper`],()=>import(`./capture-B48H5hmR.js`)],[[`kashi-gantt`],()=>import(`./gantt-QfHFG7O8.js`)],[[`kashi-invoice`],()=>import(`./invoice-BUMyjBVi.js`)],[[`kashi-virtual-list`,`kashi-infinite-scroll`],()=>import(`./lists-D0dao20N.js`)]]);function p(){for(let e of f)document.querySelector(e[0].join(`,`))&&(f.delete(e),e[1]().catch(e=>console.error(`[kashi] بارگذاری نشد:`,e)));f.size||h?.disconnect()}function m(){let e=[...f].map(([,e])=>e());return f.clear(),h?.disconnect(),Promise.all(e)}let h=null;typeof document<`u`&&(p(),h=new MutationObserver(p),h.observe(document.documentElement,{childList:!0,subtree:!0}));export{m as loadAll,e as setLocale,l as toast};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{M as e,N as t}from"./base-
|
|
1
|
+
import{M as e,N as t}from"./base-BqFAMlwG.js";function n(t){let n=e(t);if(!/^\d{10}$/.test(n)||/^(\d)\1{9}$/.test(n))return!1;let r=Number(n[9]),i=0;for(let e=0;e<9;e++)i+=Number(n[e])*(10-e);let a=i%11;return a<2?r===a:r===11-a}const r={"010":{name:`بانک مرکزی`,slug:`markazi`},"011":{name:`بانک صنعت و معدن`,slug:`bim`},"012":{name:`بانک ملت`,slug:`mellat`},"013":{name:`بانک رفاه`,slug:`refah`},"014":{name:`بانک مسکن`,slug:`maskan`},"015":{name:`بانک سپه`,slug:`sepah`},"016":{name:`بانک کشاورزی`,slug:`keshavarzi`},"017":{name:`بانک ملی`,slug:`melli`},"018":{name:`بانک تجارت`,slug:`tejarat`},"019":{name:`بانک صادرات`,slug:`saderat`},"020":{name:`بانک توسعه صادرات`,slug:`edbi`},"021":{name:`پست بانک`,slug:`postbank`},"022":{name:`بانک توسعه تعاون`,slug:`tosee-taavon`},"053":{name:`بانک کارآفرین`,slug:`karafarin`},"054":{name:`بانک پارسیان`,slug:`parsian`},"055":{name:`بانک اقتصاد نوین`,slug:`eghtesad-novin`},"056":{name:`بانک سامان`,slug:`saman`},"057":{name:`بانک پاسارگاد`,slug:`pasargad`},"058":{name:`بانک سرمایه`,slug:`sarmayeh`},"059":{name:`بانک سینا`,slug:`sina`},"060":{name:`بانک قرضالحسنه مهر ایران`,slug:`mehr-iran`},"061":{name:`بانک شهر`,slug:`shahr`},"062":{name:`بانک آینده`,slug:`ayandeh`},"064":{name:`بانک گردشگری`,slug:`gardeshgari`},"066":{name:`بانک دی`,slug:`dey`},"069":{name:`بانک ایران زمین`,slug:`iran-zamin`},"070":{name:`بانک قرضالحسنه رسالت`,slug:`resalat`},"078":{name:`بانک خاورمیانه`,slug:`khavarmianeh`}};function i(e){return t(e).toUpperCase().replace(/^\s*IR/,``).replace(/\D/g,``).slice(0,24)}function a(e){let t=0;for(let n=0;n<e.length;n+=7)t=Number(String(t)+e.slice(n,n+7))%97;return t}function o(e){let n=t(e).toUpperCase().replace(/[\s-]/g,``),r=n.startsWith(`IR`)?n.slice(2):n;return/^\d{24}$/.test(r)?a(r.slice(2)+`1827`+r.slice(0,2))===1:!1}function s(e){let t=i(e);return t.length>=5?r[t.slice(2,5)]??null:null}function c(e){let t=i(e);return t?`IR${t}`.replace(/(.{4})(?=.)/g,`$1 `):``}const l={name:`همراه اول`,slug:`mci`},u={name:`ایرانسل`,slug:`irancell`},d={name:`رایتل`,slug:`rightel`},f={mci:`Hamrah-e Aval`,irancell:`Irancell`,rightel:`RighTel`},p=(e,t=`fa`)=>t===`en`?f[e.slug]:e.name,m={...Object.fromEntries([`10`,`11`,`12`,`13`,`14`,`15`,`16`,`17`,`18`,`19`,`90`,`91`,`92`,`93`,`94`].map(e=>[e,l])),...Object.fromEntries([`01`,`02`,`03`,`04`,`05`,`30`,`33`,`35`,`36`,`37`,`38`,`39`,`41`].map(e=>[e,u])),...Object.fromEntries([`20`,`21`,`22`].map(e=>[e,d]))};function h(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):n.startsWith(`9`)&&n.length===10&&(n=`0`+n),n}function g(e){return/^09\d{9}$/.test(h(e))}function _(e){let t=h(e);return t.length>=4&&t.startsWith(`09`)?m[t.slice(2,4)]??null:null}function v(e){let t=h(e).slice(0,11);return[t.slice(0,4),t.slice(4,7),t.slice(7,11)].filter(Boolean).join(` `)}function y(t){let n=e(t);return/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/.test(n)}function b(t){let n=e(t).slice(0,10);return n.length>5?`${n.slice(0,5)}-${n.slice(5)}`:n}const x={11:`مازندران`,13:`گیلان`,17:`گلستان`,21:`تهران`,23:`سمنان`,24:`زنجان`,25:`قم`,26:`البرز`,28:`قزوین`,31:`اصفهان`,34:`کرمان`,35:`یزد`,38:`چهارمحال و بختیاری`,41:`آذربایجان شرقی`,44:`آذربایجان غربی`,45:`اردبیل`,51:`خراسان رضوی`,54:`سیستان و بلوچستان`,56:`خراسان جنوبی`,58:`خراسان شمالی`,61:`خوزستان`,66:`لرستان`,71:`فارس`,74:`کهگیلویه و بویراحمد`,76:`هرمزگان`,77:`بوشهر`,81:`همدان`,83:`کرمانشاه`,84:`ایلام`,86:`مرکزی`,87:`کردستان`};function S(t){let n=e(t);return n.startsWith(`0098`)?n=`0`+n.slice(4):n.startsWith(`98`)&&n.length===12?n=`0`+n.slice(2):/^[1-8]/.test(n)&&n.length===10&&(n=`0`+n),n}function C(e){let t=S(e);return t.length>=3&&t[0]===`0`?x[t.slice(1,3)]??null:null}function w(e){let t=S(e);return/^0\d{2}[2-9]\d{7}$/.test(t)&&C(t)!==null}function T(e){let t=S(e).slice(0,11);return[t.slice(0,3),t.slice(3,7),t.slice(7,11)].filter(Boolean).join(` `)}const E=[29,27,23,19,17,29,27,23,19,17];function D(t){let n=e(t);if(!/^\d{11}$/.test(n)||/^0+$/.test(n.slice(3,9)))return!1;let r=[...n].map(Number),i=r[9]+2,a=0;for(let e=0;e<10;e++)a+=(r[e]+i)*E[e];let o=a%11;return(o===10?0:o)===r[10]}export{S as a,v as c,h as d,p as f,n as g,o as h,w as i,_ as l,s as m,T as n,b as o,c as p,C as r,y as s,D as t,g as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,i as t,l as n,m as r,o as i,p as a,t as o}from"./base-BqFAMlwG.js";import{u as s}from"./parts-5fVaWtRe.js";var c=class extends o{constructor(){super(...arguments),this.list=[],this.render_=null,this.sizes=/* @__PURE__ */ new Map,this.offsets=/* @__PURE__ */ new Float64Array(1),this.box=null,this.space=null,this.ro=null,this.frame=0,this.endFired=-1}connectedCallback(){this.box||this.build(),this.update()}disconnectedCallback(){this.ro?.disconnect()}attributeChangedCallback(){this.box&&(this.applyAttrs(),this.measureAll())}get items(){return this.list}set items(e){this.list=e??[],this.sizes.clear(),this.endFired=-1,this.box&&this.measureAll()}get renderItem(){return this.render_}set renderItem(e){this.render_=e,this.space&&(this.space.textContent=``,this.update())}build(){this.box=document.createElement(`div`),this.box.className=`k-vlist`,this.box.tabIndex=0,this.box.setAttribute(`role`,`list`),this.space=document.createElement(`div`),this.space.className=`k-vlist__space`,this.box.append(this.space),this.replaceChildren(this.box),this.box.addEventListener(`scroll`,()=>this.schedule(),{passive:!0}),typeof ResizeObserver<`u`&&(this.ro=new ResizeObserver(e=>{let t=!1;for(let n of e){let e=n.target;if(e===this.box){t=!0;continue}let r=Number(e.dataset.index),i=e.offsetHeight;Math.abs((this.sizes.get(r)??-1)-i)>.5&&(this.sizes.set(r,i),t=!0)}t&&(this.computeOffsets(),this.schedule())}),this.ro.observe(this.box)),this.applyAttrs(),this.computeOffsets()}applyAttrs(){let e=this.getAttribute(`height`);this.box.style.blockSize=e??``,this.box.setAttribute(`aria-label`,this.getAttribute(`label`)??a().virtualList.label(r(this,this.list.length)))}measureAll(){this.computeOffsets(),this.space.textContent=``,this.applyAttrs(),this.update()}computeOffsets(){let e=s(this,`estimate-size`,48),t=new Float64Array(this.list.length+1);for(let n=0;n<this.list.length;n++)t[n+1]=t[n]+(this.sizes.get(n)??e);this.offsets=t,this.space&&(this.space.style.blockSize=`${t[this.list.length]}px`)}schedule(){this.frame||=requestAnimationFrame(()=>{this.frame=0,this.update()})}find(e){let t=0,n=this.list.length;for(;t<n;){let r=t+n>>1;this.offsets[r+1]<=e?t=r+1:n=r}return t}update(){if(!this.box||!this.space)return;let t=this.box.scrollTop,r=this.box.clientHeight||600,i=s(this,`overscan`,6),a=Math.max(0,this.find(t)-i),o=Math.min(this.list.length,this.find(t+r)+1+i),c=/* @__PURE__ */ new Set;for(let e of[...this.space.children]){let t=Number(e.dataset.index);t<a||t>=o?(this.ro?.unobserve(e),e.remove()):(c.add(t),e.style.transform=`translateY(${this.offsets[t]}px)`)}for(let e=a;e<o;e++){if(c.has(e))continue;let t=document.createElement(`div`);t.className=`k-vlist__item`,t.setAttribute(`role`,`listitem`),t.dataset.index=String(e),t.setAttribute(`aria-posinset`,String(e+1)),t.setAttribute(`aria-setsize`,String(this.list.length)),t.style.transform=`translateY(${this.offsets[e]}px)`;let r=this.render_?this.render_(this.list[e],e):n(String(this.list[e]??``));typeof r==`string`?t.innerHTML=r:t.append(r),this.space.append(t),this.ro?.observe(t)}this.list.length&&o>=this.list.length-5&&this.endFired!==this.list.length&&(this.endFired=this.list.length,e(this,`kashi-end-reached`,{count:this.list.length}))}scrollToIndex(e,t=`start`){let n=this.box;if(!n)return;let r=Math.max(0,Math.min(this.list.length-1,e)),i=this.offsets[r],a=this.offsets[r+1]-i;n.scrollTo({top:t===`start`?i:t===`end`?i-n.clientHeight+a:i-(n.clientHeight-a)/2})}};c.observedAttributes=[`estimate-size`,`overscan`,`height`,`label`];var l=class extends o{constructor(){super(...arguments),this.items=null,this.footer=null,this.sentinel=null,this.liveEl=null,this.io=null,this.count=0}connectedCallback(){this.items||this.build(),this.paint()}disconnectedCallback(){this.io?.disconnect()}attributeChangedCallback(e,t,n){this.items&&t!==n&&(e===`loading`&&t!==null&&n===null&&this.announce(),this.paint())}build(){let e=[...this.childNodes];this.items=document.createElement(`div`),this.items.className=`k-infinite__items`,this.items.append(...e),this.footer=document.createElement(`div`),this.footer.style.display=`contents`,this.sentinel=document.createElement(`div`),this.sentinel.className=`k-infinite__sentinel`,this.sentinel.setAttribute(`aria-hidden`,`true`),this.liveEl=document.createElement(`span`),this.liveEl.className=`k-sr-only`,this.liveEl.setAttribute(`aria-live`,`polite`);let t=document.createElement(`div`);t.className=`k-infinite`,t.append(this.items,this.footer,this.sentinel,this.liveEl),this.replaceChildren(t),typeof MutationObserver<`u`&&new MutationObserver(e=>{for(let n of e)for(let e of n.addedNodes)e!==t&&this.items.append(e)}).observe(this,{childList:!0}),this.count=this.items.children.length}get list(){return this.items||this.build(),this.items}announce(){let e=this.items.children.length;e>this.count&&this.count>0&&(this.liveEl.textContent=a().infinite.loaded(r(this,e-this.count))),this.count=e}more(){e(this,`kashi-load-more`,{count:this.items.children.length})}paint(){let e=a().infinite,r=this.firstElementChild,i=this.getAttribute(`max-height`);r.classList.toggle(`k-infinite--scroll`,!!i),r.style.maxBlockSize=i??``,i?(r.tabIndex=0,r.setAttribute(`role`,`region`),r.setAttribute(`aria-label`,this.getAttribute(`label`)??``)):(r.removeAttribute(`tabindex`),r.removeAttribute(`role`));let o=[...this.items.children],s=this.getAttribute(`role-items`)??(o.length&&o.every(e=>e.tagName===`ARTICLE`)?`feed`:null);s?this.items.setAttribute(`role`,s):this.items.removeAttribute(`role`),this.getAttribute(`label`)&&s?this.items.setAttribute(`aria-label`,this.getAttribute(`label`)):this.items.removeAttribute(`aria-label`);let c=t(this,`has-more`),l=this.hasAttribute(`loading`),u=this.hasAttribute(`error`);this.items.toggleAttribute(`aria-busy`,l);let d=this.getAttribute(`mode`)===`button`,f=``;l?f+=`<div class="k-infinite__loader" aria-hidden="true">${`<span class="k-skeleton k-infinite__sk"></span>`.repeat(3)}</div><span class="k-sr-only" role="status">${n(e.loading)}</span>`:u?f+=`<div class="k-infinite__error" role="alert"><span>${n(this.getAttribute(`error`)||e.error)}</span><button type="button" class="k-btn k-btn--secondary k-btn--sm" data-retry>${n(e.retry)}</button></div>`:c&&d?f+=`<div class="k-infinite__more"><button type="button" class="k-btn k-btn--secondary" data-more>${n(e.loadMore)}</button></div>`:!c&&this.getAttribute(`end-message`)!==``&&(f+=`<p class="k-infinite__end">${n(this.getAttribute(`end-message`)??e.end)}</p>`),this.footer.innerHTML=f,this.footer.querySelector(`[data-retry]`)?.addEventListener(`click`,()=>this.more()),this.footer.querySelector(`[data-more]`)?.addEventListener(`click`,()=>this.more()),this.io?.disconnect(),this.io=null,!d&&c&&!l&&!u&&typeof IntersectionObserver<`u`&&(this.io=new IntersectionObserver(e=>{e.some(e=>e.isIntersecting)&&this.more()},{root:i?r:null,rootMargin:this.getAttribute(`root-margin`)??`320px`}),this.io.observe(this.sentinel))}};l.observedAttributes=[`has-more`,`loading`,`error`,`mode`,`root-margin`,`max-height`,`end-message`,`label`],i(`kashi-virtual-list`,c,`block`),i(`kashi-infinite-scroll`,l,`block`);export{l as KashiInfiniteScroll,c as KashiVirtualList};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,i as t,r as n}from"./combobox-BGuPAAt3.js";import{c as r,i,j as a,l as o,o as s,p as c,r as l,s as u,t as d,y as f}from"./base-D4tCOysh.js";import"./inputs-BkJ70Xkc.js";const p=`0 0 1000 907`,m={"آذربایجان شرقی":{x:123,y:128,d:`M163 199l1-7l10-12l11-8l17-2l20 2l7-4l-13-8l-2-7l-12-7l-1-7l2-10l-8-10l-5-17l-15 0l-10-6l10-13l7 0l2-16l-6-22l-13 8l-12 19l-8-2l-10 4l-5-5l5-9l5 1l12-6l6-7l-4-9l-8 1l-15 18l-10-1l-13 4l-33-8l-6 6l-3 10l0 14l-9 9l-3 10l5 7l4 34l4 7l2 15l16 10l12 1l8 8l11 7l5-7l13-5l8 5l2 13l7 3z`},"آذربایجان غربی":{x:39,y:59,d:`M75 53l-8-13l-9-3l-6-11l-5-4l-4-11l-17-11l-5 5l-3 17l-7 4l-11-1l1 13l6 4l-3 10l7 10l-1 8l2 7l0 15l7 1l-5 18l-6 9l0 6l8 1l4 6l8 3l-2 18l13 10l-3 12l7 5l-3 16l9 3l2 6l-3 7l7 9l6 0l6 20l1 7l7-2l12-15l8-3l4-8l4-2l13 2l27-3l6 6l11 2l10-11l-7-16l-12 1l-7-3l-2-13l-8-5l-13 5l-5 7l-11-7l-8-8l-12-1l-16-10l-2-15l-4-7l-4-34l-5-7l3-10l9-9l0-14l3-10z`},اردبیل:{x:202,y:87,d:`M229 168l7 5l3-4l12 1l-1-10l-8-8l-8-13l-5-13l3-13l12-14l-7-7l-9-12l-7-2l-5-9l-10-6l2-8l10-2l3-5l-8-9l-1-8l11-5l-15-18l-11-3l-29 21l-10 5l-4 8l4 9l-6 7l-12 6l-5-1l-5 9l5 5l10-4l8 2l12-19l13-8l6 22l-2 16l-7 0l-10 13l10 6l15 0l5 17l8 10l-2 10l1 7l12 7l2 7z`},اصفهان:{x:414,y:418,d:`M296 467l10-6l9-1l6 4l10 0l6-4l15-2l6 10l1 10l15 12l4 11l-4 7l-1 18l5 16l0 7l3 11l14 12l5-1l0-11l7-21l-9-7l6-6l17-11l4 10l16 2l18-5l-3-9l5-25l-2-19l15-11l9-2l16 4l55-19l9-6l6-19l3-4l12-5l6-12l-1-42l-4-3l-125 4l-25-8l-23 0l-10-6l-17 5l-15 1l-8 6l-2 12l3 3l-7 19l-12 5l-22 6l-13 8l-1 9l-7 14l-8 2l-4 11l-8 7l2 6l13 3z`},البرز:{x:353,y:249,d:`M351 227l-12-1l-8 2l11 9l-5 13l-12 7l-3 7l2 5l16 1l11 3l13-13l4-11l12-3l0-6l-3-4l-14-6z`},ایلام:{x:143,y:429,d:`M87 397l8 0l8 16l6 7l1 6l-4 13l9 0l11 4l12 8l21 18l12 1l3 7l9 14l9-7l-1-7l9-16l-10-20l-13-15l-11-5l-22-20l7-9l18-5l6-6l-2-9l-11 1l1 12l-24 1l-13-4l-7-5l-16-5l-11 1z`},بوشهر:{x:387,y:698,d:`M312 606l4 5l1 11l5 5l8 12l13 12l0 19l10 0l4 4l-5 9l3 5l9 6l1 10l4 10l6 7l0 7l6 10l11 8l7 1l15 0l12 9l9 2l8 6l2 11l4 2l2-3l13-1l-10-7l-14-15l-7-16l-9-8l-9-27l-24-44l-8-6l-14-19l-21-5l-6-9l-1-7l-9-4l-11-2z`},تهران:{x:384,y:274,d:`M380 240l0 6l-12 3l-4 11l-13 13l4 10l-5 14l15 1l13 3l29 18l5-16l-8-12l2-15l6 1l13 8l24 5l11-5l8-7l2-6l-3-14l-11-2l-22-7l-11 12l-12-1l-10-13l-15-4z`},"چهارمحال و بختیاری":{x:346,y:499,d:`M323 529l12 6l5 0l19 17l8 1l11-4l0-7l-5-16l1-18l4-7l-4-11l-15-12l-1-10l-6-10l-15 2l-6 4l-10 0l-6-4l-9 1l-10 6l1 5l9 17l6 4l6 14l8 9l1 6z`},"خراسان جنوبی":{x:802,y:473,d:`M734 452l-3 11l7 13l-3 13l-7 9l-11 22l59 27l8 5l21 30l40-12l18 10l12 15l10-4l-3-12l1-20l6-17l0-11l-16-2l-3-33l3-14l-13-45l0-10l13-16l3-9l-12 0l-7-5l0-13l-2-15l-36 1l-7-3l-8-10l-10 4l-16 3l-2 2l-14-2l-3 22l-2 6l4 8l8 6l-7 11l-16 11l-7 11z`},"خراسان رضوی":{x:784,y:272,d:`M657 206l6 6l-4 10l0 19l4 12l15 14l0 4l-13 22l-11 4l-13 10l-8 10l21-5l21-10l13-4l6 2l15 12l1 8l-5 5l-21 14l-3 6l-7 20l0 11l3 18l2 4l11 1l13-3l4 7l4 26l3 7l14 8l6 8l5-13l7-11l16-11l7-11l-8-6l-4-8l2-6l3-22l14 2l2-2l16-3l10-4l8 10l7 3l36-1l2-7l7-7l12-1l-9-14l12-6l6-11l3-16l0-13l9-18l-3-7l1-14l-4-8l3-7l-4-19l2-11l-6-4l-38 1l-17-26l-27-10l-7-9l-1-11l-7-2l-9-6l-9-4l-8 2l-10-3l-8 4l-8-3l-2-7l-23-8l-8 6l0 9l24 1l7 11l-1 9l-7 21l11 9l-4 5l1 9l-5 3l-15-2l-34-20l-9 0l-12 10z`},"خراسان شمالی":{x:674,y:152,d:`M712 124l-20-4l0-8l-7-12l-9 5l-16-5l-8 2l-8-1l-14 11l0 21l7 5l-2 8l-15 6l-5 8l12 16l-2 15l13 14l11 3l8-2l3-11l12-10l9 0l34 20l15 2l5-3l-1-9l4-5l-11-9l7-21l1-9l-7-11l-24-1l0-9z`},خوزستان:{x:253,y:524,d:`M183 491l13 21l-8 22l0 25l18 1l0 31l7 2l13 12l3 14l8 2l1-5l13 1l3-3l-1-10l-3-6l6-10l10 0l-9 12l13 9l12 0l6 8l17-11l7 0l9-2l11 2l-4-19l2-10l-8-5l-6-7l-9 2l0-9l-2-9l2-7l6-3l10-10l4-7l-1-6l-8-9l-6-14l-6-4l-9-17l-1-5l0-10l-13-3l-2-6l-11 0l-12-8l-12-1l-11-5l-22 2l-3 2l-10 23l-9 16l1 7z`},زنجان:{x:228,y:211,d:`M170 215l2 1l26 6l4 7l1 15l-3 11l14 8l3 4l4 5l11 0l9 4l6-5l-11-12l10-5l13-3l9-6l9-3l0-8l-4-11l-8-3l-6-11l1-9l10-5l-3-11l-8-9l-8-5l-12-1l-3 4l-7-5l-7 4l-20-2l-17 2l-11 8l-10 12l-1 7z`},سمنان:{x:554,y:286,d:`M615 160l-12 17l-10 22l-18-3l-14 6l-12 11l-7 3l-18 0l-10 4l-6 8l-2 9l-10 12l-6 4l-8 1l-15 4l3 14l-2 6l-8 7l-11 5l-24-5l-13-8l-6-1l-2 15l8 12l-5 16l1 8l-6 13l10 6l23 0l25 8l125-4l4 3l19-1l6-3l19-32l8-10l13-10l11-4l13-22l0-4l-15-14l-4-12l0-19l4-10l-6-6l-8 2l-11-3l-13-14l2-15z`},"سیستان و بلوچستان":{x:863,y:770,d:`M805 582l-11 50l0 5l5 8l2 12l-2 11l-4 7l0 13l2 7l-16 11l-9 3l8 10l-7 13l-1 27l-6 23l3 21l6 10l-3 7l0 9l3 8l-4 16l-2 4l13 11l9 14l0 4l11-2l4 4l12 0l7 4l9-2l7 2l8 0l3-5l7-2l4 10l21 4l8 5l12 3l4-8l6-5l2-27l6-4l2-19l3-5l20-6l2-9l7-3l9-1l8-4l21 1l2-12l4-3l-2-10l1-9l-4-3l-13 3l-6-1l-2-7l3-8l-2-20l-3-10l2-12l-10-1l-11-12l-16-3l-8-4l-13-12l-4-7l-5-13l-7-10l-3-9l-23-27l49-58l2-13l-4-16l-5-5l-27-4l0 11l-6 17l-1 20l3 12l-10 4l-12-15l-18-10z`},فارس:{x:473,y:666,d:`M464 773l5 7l12 1l8 5l5-1l16 2l5-2l3-13l8-5l27-2l14 2l9-5l4-8l17-6l2-5l-7-8l2-14l0-10l-16-15l1-6l-3-9l-10-26l-17-4l-9-20l-19-11l-3-17l-11-14l-8-16l-12-30l-15-16l-13-5l-18 5l-16-2l-4-10l-17 11l-6 6l9 7l-7 21l0 11l-5 1l0 13l-6 2l-16-7l-5-1l4 16l-1 6l-14 8l-16 1l1 7l6 9l21 5l14 19l8 6l24 44l9 27l9 8l7 16l14 15z`},قزوین:{x:304,y:239,d:`M270 195l-10 5l-1 9l6 11l8 3l4 11l0 8l-9 3l-9 6l-13 3l-10 5l11 12l8-1l8 10l17 3l9 0l4-5l31-9l-2-5l3-7l12-7l5-13l-11-9l8-2l12 1l-1-3l-25-20l-11 1l-15 6l-17-4z`},قم:{x:368,y:323,d:`M407 319l-29-18l-13-3l-15-1l-3 7l-2 13l-28 8l1 7l-6 6l13 9l1 7l6 6l14 1l17 6l-3-3l2-12l8-6l15-1l17-5l6-13z`},کردستان:{x:152,y:265,d:`M75 247l16 13l13-3l9 9l-10 1l-4 13l8 13l12 8l12 17l5 9l14-1l4-8l12-5l1-5l7-1l1-5l11 3l8 9l3 0l13-1l3-8l-1-6l-8-7l-9-18l8 1l14-8l-3-4l-14-8l3-11l-1-15l-4-7l-26-6l-2-1l-10 11l-11-2l-6-6l-27 3l-13-2l-4 2l-4 8l-8 3z`},کرمان:{x:697,y:622,d:`M717 520l-56-24l-6-1l-4 4l-14 10l-28 15l-2 4l-2 24l-9 4l-9 1l-11-1l-30 5l-7 10l-1 7l11 23l-1 19l2 8l-10 3l9 20l17 4l10 26l14 3l7 7l7 2l11-8l9-1l1 33l4 6l10 7l6 1l10-4l10-9l8 3l2 16l6 4l8 11l-2 6l5 10l3 25l21 11l9-5l11 9l-3 3l-4 30l16-1l7 2l5 8l7-2l7 5l4-16l-3-8l0-9l3-7l-6-10l-3-21l6-23l1-27l7-13l-8-10l9-3l16-11l-2-7l0-13l4-7l2-11l-2-12l-5-8l0-5l11-50l-21-30l-8-5z`},کرمانشاه:{x:139,y:357,d:`M107 293l3 6l-9 8l-7 3l-2 8l-8 5l-2 6l3 11l-10-3l-3 14l6 4l-1 11l-6 8l12 20l4 3l5-24l11-1l16 5l7 5l13 4l24-1l-1-12l11-1l1-8l9-3l0-8l6-1l3-4l13-1l0-7l-19-6l11-20l-3 0l-8-9l-11-3l-1 5l-7 1l-1 5l-12 5l-4 8l-14 1l-5-9l-12-17z`},"کهگیلویه و بویراحمد":{x:348,y:570,d:`M332 606l9 4l16-1l14-8l1-6l-4-16l5 1l16 7l6-2l0-13l-14-12l-3-11l-11 4l-8-1l-19-17l-5 0l-12-6l-10 10l-6 3l-2 7l2 9l0 9l9-2l6 7l8 5l-2 10z`},گلستان:{x:577,y:168,d:`M630 112l-9 1l-14-3l-15 3l-16 8l-14 12l-3 8l-1 8l-8 6l-23 7l-14-1l6 25l-1 9l-16 0l3 6l11 6l8 9l18 0l7-3l12-11l14-6l18 3l10-22l12-17l5-8l15-6l2-8l-7-5z`},گیلان:{x:295,y:181,d:`M251 170l8 5l8 9l3 11l12 12l17 4l15-6l11-1l7-12l7-8l-13-11l-9-16l-11-4l-26-2l-16-9l-6-7l-6-23l-1-23l-14 3l7 7l-12 14l-3 13l5 13l8 13l8 8z`},لرستان:{x:221,y:403,d:`M173 372l2 9l-6 6l-18 5l-7 9l22 20l11 5l13 15l10 20l10-23l3-2l22-2l11 5l12 1l12 8l11 0l8-7l4-11l8-2l7-14l1-9l-9-10l-4 6l-9-8l1-6l-7-6l-7 4l-7 9l-14-4l3-15l-15-6l-10 3l-15-2l-27-18l-6 1l0 8l-9 3z`},مازندران:{x:467,y:227,d:`M325 204l25 20l1 3l12 3l14 6l3 4l6 3l15 4l10 13l12 1l11-12l22 7l11 2l15-4l8-1l6-4l10-12l2-9l6-8l10-4l-8-9l-11-6l-3-6l-2-4l-9-1l-20 5l-17 5l-45 10l-43-10l-27-16l-7 8z`},مرکزی:{x:294,y:357,d:`M280 283l2 8l-8 0l4 11l-7 7l11 4l5 13l-8-2l-1-7l-14 0l-2 10l0 9l-7 2l1 11l4 7l2 11l-6 8l-3 15l14 4l7-9l7-4l7 6l-1 6l9 8l4-6l9 10l13-8l22-6l12-5l7-19l-17-6l-14-1l-6-6l-1-7l-13-9l6-6l-1-7l28-8l2-13l3-7l5-14l-4-10l-11-3l-16-1l-31 9l-4 5z`},هرمزگان:{x:651,y:758,d:`M771 853l-7-5l-7 2l-5-8l-7-2l-16 1l4-30l3-3l-11-9l-9 5l-21-11l-3-25l-5-10l2-6l-8-11l-6-4l-2-16l-8-3l-10 9l-10 4l-6-1l-10-7l-4-6l-1-33l-9 1l-11 8l-7-2l-7-7l-14-3l3 9l-1 6l16 15l0 10l-2 14l7 8l-2 5l-17 6l-4 8l-9 5l-14-2l-27 2l-8 5l-3 13l-5 2l-16-2l-5 1l-8-5l-12-1l-5-7l-13 1l-2 3l20 13l18 6l4 8l12 8l14-2l17 2l4 6l9 2l3 4l9 1l25-17l6 1l8-2l3-9l4-3l14-1l9-8l12-2l12 3l12 0l8 10l6 21l0 10l3 10l4 6l-3 4l9 18l23 3l1 5l9-3l6 7l24-1l14 1l10 9l6 1l7-2l0-4l-9-14l-13-11zM633 795l-9 2l-13 8l-3 3l-20 8l8 3l10-6l9-3l4 3l7-5z`},همدان:{x:235,y:319,d:`M197 314l-11 20l19 6l0 7l-13 1l-3 4l27 18l15 2l10-3l15 6l6-8l-2-11l-4-7l-1-11l7-2l0-9l2-10l14 0l1 7l8 2l-5-13l-11-4l7-7l-4-11l8 0l-2-8l-17-3l-8-10l-8 1l-6 5l-9-4l-11 0l-4-5l-14 8l-8-1l9 18l8 7l1 6l-3 8z`},یزد:{x:615,y:452,d:`M633 317l-19 32l-6 3l-19 1l1 42l-6 12l-12 5l-3 4l-6 19l-9 6l-55 19l-16-4l-9 2l-15 11l2 19l-5 25l3 9l13 5l15 16l12 30l8 16l11 14l3 17l19 11l10-3l-2-8l1-19l-11-23l1-7l7-10l30-5l11 1l9-1l9-4l2-24l2-4l28-15l14-10l4-4l6 1l56 24l11-22l7-9l3-13l-7-13l3-11l-6-8l-14-8l-3-7l-4-26l-4-7l-13 3l-11-1l-2-4l-3-18l0-11l7-20l3-6l21-14l5-5l-1-8l-15-12l-6-2l-13 4l-21 10z`}},h=e.map(e=>e.name),g=Object.fromEntries(e.map(e=>[e.name,e.capital])),[,,_,v]=p.split(` `).map(Number);var y=class extends d{constructor(){super(...arguments),this.values=null,this.selected=[],this.active=0,this.rendered=!1,this.valueSet=!1,this.key=f(`kashi-map`)}connectedCallback(){this.rendered||(this.valueSet||(this.selected=(this.getAttribute(`value`)??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e))),this.values===null&&(this.values=this.parseData(this.getAttribute(`data`)))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`data`&&(this.values=this.parseData(n)),e===`value`?this.value=n??``:this.render())}parseData(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}get data(){return this.values}set data(e){this.values=e,this.rendered&&this.render()}get value(){return this.selected.join(`,`)}set value(e){this.valueSet=!0,this.selected=String(e??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e)),this.multiple||(this.selected=this.selected.slice(0,1)),this.rendered&&this.paint()}get selectedProvinces(){return[...this.selected]}get multiple(){return i(this,`multiple`)}get selectable(){return this.multiple||i(this,`selectable`)||this.hasAttribute(`value`)||this.hasAttribute(`name`)}fmt(e){return a(e,{digits:u(this)})}level(e){let t=this.values,n=t?.[e];if(typeof n!=`number`||!t)return;let r=this.steps,i=h.map(e=>t[e]).filter(e=>typeof e==`number`),a=Math.min(...i),o=Math.max(...i);if(o===a)return r;if(this.getAttribute(`scale`)!==`linear`){let e=[...i].sort((e,t)=>e-t);return 1+Math.round(e.indexOf(n)*(r-1)/(e.length-1))}return Math.min(r,1+Math.floor((n-a)/(o-a)*r))}get steps(){return Number(this.getAttribute(`steps`))||5}shade(e){return`${Math.round(12+88*e/this.steps)}%`}describe(e){let t=this.values?.[e],n=this.getAttribute(`unit`);return typeof t==`number`?`${e}: ${this.fmt(t)}${n?` ${n}`:``}`:e}render(){let e=this.getAttribute(`label`)??c().iranMap.label,t=this.selectable,n=this.multiple,r=this.values,a=this.getAttribute(`unit`),s=h.map((e,r)=>{let i=this.level(e);return`<path d="${m[e].d}" class="k-iran-map__province" data-i="${r}"${i?` data-l="${i}" style="--_p: ${this.shade(i)}"`:``}${t?` role="${n?`checkbox`:`radio`}" aria-label="${o(this.describe(e))}"`:``}></path>`}).join(``),l=r?h.map(e=>r[e]).filter(e=>typeof e==`number`):[],u=(this.hasAttribute(`legend`)?i(this,`legend`):r)&&l.length?`<figcaption class="k-iran-map__legend"><span>${this.fmt(Math.min(...l))}</span><span class="k-iran-map__scale" aria-hidden="true">${Array.from({length:this.steps},(e,t)=>`<i style="--_p: ${this.shade(t+1)}"></i>`).join(``)}</span><span>${this.fmt(Math.max(...l))}${a?` ${o(a)}`:``}</span></figcaption>`:``,d=r?`<table class="k-sr-only"><caption>${o(e)}</caption><tbody>${h.filter(e=>typeof r[e]==`number`).sort((e,t)=>r[t]-r[e]).map(e=>`<tr><th scope="row">${o(e)}</th><td>${this.fmt(r[e])}${a?` ${o(a)}`:``}</td></tr>`).join(``)}</tbody></table>`:``;this.innerHTML=`<figure class="k-iran-map${t?` k-iran-map--selectable`:``}"><div class="k-iran-map__canvas" style="block-size: auto; aspect-ratio: ${_} / ${v}"><svg viewBox="${p}" class="k-iran-map__svg" role="${t?n?`group`:`radiogroup`:`img`}" aria-label="${o(t?e:`${e}${r?c().iranMap.tableNote:``}`)}">${s}</svg><div class="k-chart__tip" aria-hidden="true" style="display: none"></div></div>${u}${d}</figure>`;let f=this.querySelector(`svg`),g=this.querySelector(`figure`);f.addEventListener(`pointerover`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&this.tip(Number(t))}),g.addEventListener(`pointerleave`,()=>this.tip(null)),t&&(f.addEventListener(`click`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.toggle(h[this.active]))}),f.addEventListener(`keydown`,e=>this.onKey(e)),f.addEventListener(`focusin`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.tip(this.active))}),f.addEventListener(`focusout`,()=>this.tip(null))),this.rendered=!0,this.paint()}paint(){let e=this.selectable,t=h.findIndex(e=>this.selected.includes(e)),n=this.contains(document.activeElement)||t<0?this.active:t;this.querySelectorAll(`.k-iran-map__province`).forEach((t,r)=>{let i=this.selected.includes(h[r]);t.toggleAttribute(`data-selected`,i),e&&(t.setAttribute(`aria-checked`,String(i)),t.setAttribute(`tabindex`,r===n?`0`:`-1`))});let r=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),r)for(let e of this.multiple?this.selected:[this.selected[0]??``]){let t=document.createElement(`input`);t.type=`hidden`,t.name=r,t.value=e,this.append(t)}}toggle(e){this.selected=this.multiple?this.selected.includes(e)?this.selected.filter(t=>t!==e):[...this.selected,e]:this.selected[0]===e?[]:[e],this.paint(),r(this,`kashi-change`,{value:this.multiple?[...this.selected]:this.selected[0]??null})}onKey(e){let t=this.active,n={ArrowLeft:1,ArrowDown:1,ArrowRight:-1,ArrowUp:-1}[e.key],r=t;if(n)r=(t+n+h.length)%h.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=h.length-1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.toggle(h[t]);return}else return;e.preventDefault(),this.active=r,this.paint(),this.querySelector(`[data-i="${r}"]`)?.focus()}tip(e){let t=this.querySelector(`.k-chart__tip`);if(!t)return;if(this.querySelector(`.k-iran-map__province[data-active]`)?.removeAttribute(`data-active`),e===null){t.style.display=`none`;return}let n=h[e];this.querySelector(`[data-i="${e}"]`)?.setAttribute(`data-active`,``);let r=m[n],i=this.querySelector(`figure`).clientWidth||_,a=this.values?.[n],s=this.getAttribute(`unit`),l=typeof a==`number`?`${this.fmt(a)}${s?` ${s}`:``}`:c().province.capital(g[n]);t.innerHTML=`<span class="k-chart__tip-title">${o(n)}</span><span class="k-chart__tip-row"><strong>${o(l)}</strong></span>`,t.style.left=`${Math.min(Math.max(r.x/_*i,80),i-80)}px`,t.style.top=`${Math.max(64,r.y/v*(v/_*i)-6)}px`,t.style.display=``}};y.observedAttributes=[`data`,`value`,`label`,`unit`,`steps`,`scale`,`legend`,`selectable`,`multiple`,`name`];const b=()=>{let e=c().address;return{province:e.province,city:e.city,street:e.street,plaque:e.plaque,unit:e.unit,postalCode:e.postalCode}};var x=class extends d{constructor(){super(...arguments),this.address={...n},this.built=!1,this.key=f(`kashi-address`)}connectedCallback(){l(()=>{if(this.isConnected){if(!this.built){let e=Object.prototype.hasOwnProperty.call(this,`value`)?this.value:null;delete this.value;let t=this.getAttribute(`value`),r=e??{};if(!e&&t)try{r=JSON.parse(t)}catch{}this.address={...n,...r}}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return{...this.address}}set value(e){this.address={...n,...e},this.built&&this.render()}set errors(e){for(let t of Object.keys(b())){let n=this.querySelector(`[data-field="${t}"]`);n&&(n.matches(`kashi-province-select, kashi-city-select, kashi-postal-code`)?e[t]?n.setAttribute(`error`,e[t]):n.removeAttribute(`error`):this.fieldError(n,e[t]??null))}}label(e){return this.getAttribute(`label-${e===`postalCode`?`postal-code`:e}`)??b()[e]}render(){let e=this.address,n=this.getAttribute(`name`),r=e=>n?` name="${o(`${n}[${e}]`)}"`:``,a=i(this,`required`,!0),s=a?` required`:``,l=i(this,`map`),u=this.key,d=a?`<span class="k-label__required" aria-hidden="true">*</span>`:``,f=this.getAttribute(`legend`)??c().address.legend;this.innerHTML=`<fieldset class="k-address${l?` k-address--map`:``}"${this.hasAttribute(`disabled`)?` disabled`:``}>
|
|
1
|
+
import{a as e,i as t,r as n}from"./combobox-Drm8K9Zk.js";import{c as r,i,j as a,l as o,o as s,p as c,r as l,s as u,t as d,y as f}from"./base-BqFAMlwG.js";import"./inputs-DWLKbi57.js";const p=`0 0 1000 907`,m={"آذربایجان شرقی":{x:123,y:128,d:`M163 199l1-7l10-12l11-8l17-2l20 2l7-4l-13-8l-2-7l-12-7l-1-7l2-10l-8-10l-5-17l-15 0l-10-6l10-13l7 0l2-16l-6-22l-13 8l-12 19l-8-2l-10 4l-5-5l5-9l5 1l12-6l6-7l-4-9l-8 1l-15 18l-10-1l-13 4l-33-8l-6 6l-3 10l0 14l-9 9l-3 10l5 7l4 34l4 7l2 15l16 10l12 1l8 8l11 7l5-7l13-5l8 5l2 13l7 3z`},"آذربایجان غربی":{x:39,y:59,d:`M75 53l-8-13l-9-3l-6-11l-5-4l-4-11l-17-11l-5 5l-3 17l-7 4l-11-1l1 13l6 4l-3 10l7 10l-1 8l2 7l0 15l7 1l-5 18l-6 9l0 6l8 1l4 6l8 3l-2 18l13 10l-3 12l7 5l-3 16l9 3l2 6l-3 7l7 9l6 0l6 20l1 7l7-2l12-15l8-3l4-8l4-2l13 2l27-3l6 6l11 2l10-11l-7-16l-12 1l-7-3l-2-13l-8-5l-13 5l-5 7l-11-7l-8-8l-12-1l-16-10l-2-15l-4-7l-4-34l-5-7l3-10l9-9l0-14l3-10z`},اردبیل:{x:202,y:87,d:`M229 168l7 5l3-4l12 1l-1-10l-8-8l-8-13l-5-13l3-13l12-14l-7-7l-9-12l-7-2l-5-9l-10-6l2-8l10-2l3-5l-8-9l-1-8l11-5l-15-18l-11-3l-29 21l-10 5l-4 8l4 9l-6 7l-12 6l-5-1l-5 9l5 5l10-4l8 2l12-19l13-8l6 22l-2 16l-7 0l-10 13l10 6l15 0l5 17l8 10l-2 10l1 7l12 7l2 7z`},اصفهان:{x:414,y:418,d:`M296 467l10-6l9-1l6 4l10 0l6-4l15-2l6 10l1 10l15 12l4 11l-4 7l-1 18l5 16l0 7l3 11l14 12l5-1l0-11l7-21l-9-7l6-6l17-11l4 10l16 2l18-5l-3-9l5-25l-2-19l15-11l9-2l16 4l55-19l9-6l6-19l3-4l12-5l6-12l-1-42l-4-3l-125 4l-25-8l-23 0l-10-6l-17 5l-15 1l-8 6l-2 12l3 3l-7 19l-12 5l-22 6l-13 8l-1 9l-7 14l-8 2l-4 11l-8 7l2 6l13 3z`},البرز:{x:353,y:249,d:`M351 227l-12-1l-8 2l11 9l-5 13l-12 7l-3 7l2 5l16 1l11 3l13-13l4-11l12-3l0-6l-3-4l-14-6z`},ایلام:{x:143,y:429,d:`M87 397l8 0l8 16l6 7l1 6l-4 13l9 0l11 4l12 8l21 18l12 1l3 7l9 14l9-7l-1-7l9-16l-10-20l-13-15l-11-5l-22-20l7-9l18-5l6-6l-2-9l-11 1l1 12l-24 1l-13-4l-7-5l-16-5l-11 1z`},بوشهر:{x:387,y:698,d:`M312 606l4 5l1 11l5 5l8 12l13 12l0 19l10 0l4 4l-5 9l3 5l9 6l1 10l4 10l6 7l0 7l6 10l11 8l7 1l15 0l12 9l9 2l8 6l2 11l4 2l2-3l13-1l-10-7l-14-15l-7-16l-9-8l-9-27l-24-44l-8-6l-14-19l-21-5l-6-9l-1-7l-9-4l-11-2z`},تهران:{x:384,y:274,d:`M380 240l0 6l-12 3l-4 11l-13 13l4 10l-5 14l15 1l13 3l29 18l5-16l-8-12l2-15l6 1l13 8l24 5l11-5l8-7l2-6l-3-14l-11-2l-22-7l-11 12l-12-1l-10-13l-15-4z`},"چهارمحال و بختیاری":{x:346,y:499,d:`M323 529l12 6l5 0l19 17l8 1l11-4l0-7l-5-16l1-18l4-7l-4-11l-15-12l-1-10l-6-10l-15 2l-6 4l-10 0l-6-4l-9 1l-10 6l1 5l9 17l6 4l6 14l8 9l1 6z`},"خراسان جنوبی":{x:802,y:473,d:`M734 452l-3 11l7 13l-3 13l-7 9l-11 22l59 27l8 5l21 30l40-12l18 10l12 15l10-4l-3-12l1-20l6-17l0-11l-16-2l-3-33l3-14l-13-45l0-10l13-16l3-9l-12 0l-7-5l0-13l-2-15l-36 1l-7-3l-8-10l-10 4l-16 3l-2 2l-14-2l-3 22l-2 6l4 8l8 6l-7 11l-16 11l-7 11z`},"خراسان رضوی":{x:784,y:272,d:`M657 206l6 6l-4 10l0 19l4 12l15 14l0 4l-13 22l-11 4l-13 10l-8 10l21-5l21-10l13-4l6 2l15 12l1 8l-5 5l-21 14l-3 6l-7 20l0 11l3 18l2 4l11 1l13-3l4 7l4 26l3 7l14 8l6 8l5-13l7-11l16-11l7-11l-8-6l-4-8l2-6l3-22l14 2l2-2l16-3l10-4l8 10l7 3l36-1l2-7l7-7l12-1l-9-14l12-6l6-11l3-16l0-13l9-18l-3-7l1-14l-4-8l3-7l-4-19l2-11l-6-4l-38 1l-17-26l-27-10l-7-9l-1-11l-7-2l-9-6l-9-4l-8 2l-10-3l-8 4l-8-3l-2-7l-23-8l-8 6l0 9l24 1l7 11l-1 9l-7 21l11 9l-4 5l1 9l-5 3l-15-2l-34-20l-9 0l-12 10z`},"خراسان شمالی":{x:674,y:152,d:`M712 124l-20-4l0-8l-7-12l-9 5l-16-5l-8 2l-8-1l-14 11l0 21l7 5l-2 8l-15 6l-5 8l12 16l-2 15l13 14l11 3l8-2l3-11l12-10l9 0l34 20l15 2l5-3l-1-9l4-5l-11-9l7-21l1-9l-7-11l-24-1l0-9z`},خوزستان:{x:253,y:524,d:`M183 491l13 21l-8 22l0 25l18 1l0 31l7 2l13 12l3 14l8 2l1-5l13 1l3-3l-1-10l-3-6l6-10l10 0l-9 12l13 9l12 0l6 8l17-11l7 0l9-2l11 2l-4-19l2-10l-8-5l-6-7l-9 2l0-9l-2-9l2-7l6-3l10-10l4-7l-1-6l-8-9l-6-14l-6-4l-9-17l-1-5l0-10l-13-3l-2-6l-11 0l-12-8l-12-1l-11-5l-22 2l-3 2l-10 23l-9 16l1 7z`},زنجان:{x:228,y:211,d:`M170 215l2 1l26 6l4 7l1 15l-3 11l14 8l3 4l4 5l11 0l9 4l6-5l-11-12l10-5l13-3l9-6l9-3l0-8l-4-11l-8-3l-6-11l1-9l10-5l-3-11l-8-9l-8-5l-12-1l-3 4l-7-5l-7 4l-20-2l-17 2l-11 8l-10 12l-1 7z`},سمنان:{x:554,y:286,d:`M615 160l-12 17l-10 22l-18-3l-14 6l-12 11l-7 3l-18 0l-10 4l-6 8l-2 9l-10 12l-6 4l-8 1l-15 4l3 14l-2 6l-8 7l-11 5l-24-5l-13-8l-6-1l-2 15l8 12l-5 16l1 8l-6 13l10 6l23 0l25 8l125-4l4 3l19-1l6-3l19-32l8-10l13-10l11-4l13-22l0-4l-15-14l-4-12l0-19l4-10l-6-6l-8 2l-11-3l-13-14l2-15z`},"سیستان و بلوچستان":{x:863,y:770,d:`M805 582l-11 50l0 5l5 8l2 12l-2 11l-4 7l0 13l2 7l-16 11l-9 3l8 10l-7 13l-1 27l-6 23l3 21l6 10l-3 7l0 9l3 8l-4 16l-2 4l13 11l9 14l0 4l11-2l4 4l12 0l7 4l9-2l7 2l8 0l3-5l7-2l4 10l21 4l8 5l12 3l4-8l6-5l2-27l6-4l2-19l3-5l20-6l2-9l7-3l9-1l8-4l21 1l2-12l4-3l-2-10l1-9l-4-3l-13 3l-6-1l-2-7l3-8l-2-20l-3-10l2-12l-10-1l-11-12l-16-3l-8-4l-13-12l-4-7l-5-13l-7-10l-3-9l-23-27l49-58l2-13l-4-16l-5-5l-27-4l0 11l-6 17l-1 20l3 12l-10 4l-12-15l-18-10z`},فارس:{x:473,y:666,d:`M464 773l5 7l12 1l8 5l5-1l16 2l5-2l3-13l8-5l27-2l14 2l9-5l4-8l17-6l2-5l-7-8l2-14l0-10l-16-15l1-6l-3-9l-10-26l-17-4l-9-20l-19-11l-3-17l-11-14l-8-16l-12-30l-15-16l-13-5l-18 5l-16-2l-4-10l-17 11l-6 6l9 7l-7 21l0 11l-5 1l0 13l-6 2l-16-7l-5-1l4 16l-1 6l-14 8l-16 1l1 7l6 9l21 5l14 19l8 6l24 44l9 27l9 8l7 16l14 15z`},قزوین:{x:304,y:239,d:`M270 195l-10 5l-1 9l6 11l8 3l4 11l0 8l-9 3l-9 6l-13 3l-10 5l11 12l8-1l8 10l17 3l9 0l4-5l31-9l-2-5l3-7l12-7l5-13l-11-9l8-2l12 1l-1-3l-25-20l-11 1l-15 6l-17-4z`},قم:{x:368,y:323,d:`M407 319l-29-18l-13-3l-15-1l-3 7l-2 13l-28 8l1 7l-6 6l13 9l1 7l6 6l14 1l17 6l-3-3l2-12l8-6l15-1l17-5l6-13z`},کردستان:{x:152,y:265,d:`M75 247l16 13l13-3l9 9l-10 1l-4 13l8 13l12 8l12 17l5 9l14-1l4-8l12-5l1-5l7-1l1-5l11 3l8 9l3 0l13-1l3-8l-1-6l-8-7l-9-18l8 1l14-8l-3-4l-14-8l3-11l-1-15l-4-7l-26-6l-2-1l-10 11l-11-2l-6-6l-27 3l-13-2l-4 2l-4 8l-8 3z`},کرمان:{x:697,y:622,d:`M717 520l-56-24l-6-1l-4 4l-14 10l-28 15l-2 4l-2 24l-9 4l-9 1l-11-1l-30 5l-7 10l-1 7l11 23l-1 19l2 8l-10 3l9 20l17 4l10 26l14 3l7 7l7 2l11-8l9-1l1 33l4 6l10 7l6 1l10-4l10-9l8 3l2 16l6 4l8 11l-2 6l5 10l3 25l21 11l9-5l11 9l-3 3l-4 30l16-1l7 2l5 8l7-2l7 5l4-16l-3-8l0-9l3-7l-6-10l-3-21l6-23l1-27l7-13l-8-10l9-3l16-11l-2-7l0-13l4-7l2-11l-2-12l-5-8l0-5l11-50l-21-30l-8-5z`},کرمانشاه:{x:139,y:357,d:`M107 293l3 6l-9 8l-7 3l-2 8l-8 5l-2 6l3 11l-10-3l-3 14l6 4l-1 11l-6 8l12 20l4 3l5-24l11-1l16 5l7 5l13 4l24-1l-1-12l11-1l1-8l9-3l0-8l6-1l3-4l13-1l0-7l-19-6l11-20l-3 0l-8-9l-11-3l-1 5l-7 1l-1 5l-12 5l-4 8l-14 1l-5-9l-12-17z`},"کهگیلویه و بویراحمد":{x:348,y:570,d:`M332 606l9 4l16-1l14-8l1-6l-4-16l5 1l16 7l6-2l0-13l-14-12l-3-11l-11 4l-8-1l-19-17l-5 0l-12-6l-10 10l-6 3l-2 7l2 9l0 9l9-2l6 7l8 5l-2 10z`},گلستان:{x:577,y:168,d:`M630 112l-9 1l-14-3l-15 3l-16 8l-14 12l-3 8l-1 8l-8 6l-23 7l-14-1l6 25l-1 9l-16 0l3 6l11 6l8 9l18 0l7-3l12-11l14-6l18 3l10-22l12-17l5-8l15-6l2-8l-7-5z`},گیلان:{x:295,y:181,d:`M251 170l8 5l8 9l3 11l12 12l17 4l15-6l11-1l7-12l7-8l-13-11l-9-16l-11-4l-26-2l-16-9l-6-7l-6-23l-1-23l-14 3l7 7l-12 14l-3 13l5 13l8 13l8 8z`},لرستان:{x:221,y:403,d:`M173 372l2 9l-6 6l-18 5l-7 9l22 20l11 5l13 15l10 20l10-23l3-2l22-2l11 5l12 1l12 8l11 0l8-7l4-11l8-2l7-14l1-9l-9-10l-4 6l-9-8l1-6l-7-6l-7 4l-7 9l-14-4l3-15l-15-6l-10 3l-15-2l-27-18l-6 1l0 8l-9 3z`},مازندران:{x:467,y:227,d:`M325 204l25 20l1 3l12 3l14 6l3 4l6 3l15 4l10 13l12 1l11-12l22 7l11 2l15-4l8-1l6-4l10-12l2-9l6-8l10-4l-8-9l-11-6l-3-6l-2-4l-9-1l-20 5l-17 5l-45 10l-43-10l-27-16l-7 8z`},مرکزی:{x:294,y:357,d:`M280 283l2 8l-8 0l4 11l-7 7l11 4l5 13l-8-2l-1-7l-14 0l-2 10l0 9l-7 2l1 11l4 7l2 11l-6 8l-3 15l14 4l7-9l7-4l7 6l-1 6l9 8l4-6l9 10l13-8l22-6l12-5l7-19l-17-6l-14-1l-6-6l-1-7l-13-9l6-6l-1-7l28-8l2-13l3-7l5-14l-4-10l-11-3l-16-1l-31 9l-4 5z`},هرمزگان:{x:651,y:758,d:`M771 853l-7-5l-7 2l-5-8l-7-2l-16 1l4-30l3-3l-11-9l-9 5l-21-11l-3-25l-5-10l2-6l-8-11l-6-4l-2-16l-8-3l-10 9l-10 4l-6-1l-10-7l-4-6l-1-33l-9 1l-11 8l-7-2l-7-7l-14-3l3 9l-1 6l16 15l0 10l-2 14l7 8l-2 5l-17 6l-4 8l-9 5l-14-2l-27 2l-8 5l-3 13l-5 2l-16-2l-5 1l-8-5l-12-1l-5-7l-13 1l-2 3l20 13l18 6l4 8l12 8l14-2l17 2l4 6l9 2l3 4l9 1l25-17l6 1l8-2l3-9l4-3l14-1l9-8l12-2l12 3l12 0l8 10l6 21l0 10l3 10l4 6l-3 4l9 18l23 3l1 5l9-3l6 7l24-1l14 1l10 9l6 1l7-2l0-4l-9-14l-13-11zM633 795l-9 2l-13 8l-3 3l-20 8l8 3l10-6l9-3l4 3l7-5z`},همدان:{x:235,y:319,d:`M197 314l-11 20l19 6l0 7l-13 1l-3 4l27 18l15 2l10-3l15 6l6-8l-2-11l-4-7l-1-11l7-2l0-9l2-10l14 0l1 7l8 2l-5-13l-11-4l7-7l-4-11l8 0l-2-8l-17-3l-8-10l-8 1l-6 5l-9-4l-11 0l-4-5l-14 8l-8-1l9 18l8 7l1 6l-3 8z`},یزد:{x:615,y:452,d:`M633 317l-19 32l-6 3l-19 1l1 42l-6 12l-12 5l-3 4l-6 19l-9 6l-55 19l-16-4l-9 2l-15 11l2 19l-5 25l3 9l13 5l15 16l12 30l8 16l11 14l3 17l19 11l10-3l-2-8l1-19l-11-23l1-7l7-10l30-5l11 1l9-1l9-4l2-24l2-4l28-15l14-10l4-4l6 1l56 24l11-22l7-9l3-13l-7-13l3-11l-6-8l-14-8l-3-7l-4-26l-4-7l-13 3l-11-1l-2-4l-3-18l0-11l7-20l3-6l21-14l5-5l-1-8l-15-12l-6-2l-13 4l-21 10z`}},h=e.map(e=>e.name),g=Object.fromEntries(e.map(e=>[e.name,e.capital])),[,,_,v]=p.split(` `).map(Number);var y=class extends d{constructor(){super(...arguments),this.values=null,this.selected=[],this.active=0,this.rendered=!1,this.valueSet=!1,this.key=f(`kashi-map`)}connectedCallback(){this.rendered||(this.valueSet||(this.selected=(this.getAttribute(`value`)??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e))),this.values===null&&(this.values=this.parseData(this.getAttribute(`data`)))),this.render()}attributeChangedCallback(e,t,n){this.rendered&&t!==n&&(e===`data`&&(this.values=this.parseData(n)),e===`value`?this.value=n??``:this.render())}parseData(e){if(!e)return null;try{return JSON.parse(e)}catch{return null}}get data(){return this.values}set data(e){this.values=e,this.rendered&&this.render()}get value(){return this.selected.join(`,`)}set value(e){this.valueSet=!0,this.selected=String(e??``).split(/[,،]/).map(e=>e.trim()).filter(e=>h.includes(e)),this.multiple||(this.selected=this.selected.slice(0,1)),this.rendered&&this.paint()}get selectedProvinces(){return[...this.selected]}get multiple(){return i(this,`multiple`)}get selectable(){return this.multiple||i(this,`selectable`)||this.hasAttribute(`value`)||this.hasAttribute(`name`)}fmt(e){return a(e,{digits:u(this)})}level(e){let t=this.values,n=t?.[e];if(typeof n!=`number`||!t)return;let r=this.steps,i=h.map(e=>t[e]).filter(e=>typeof e==`number`),a=Math.min(...i),o=Math.max(...i);if(o===a)return r;if(this.getAttribute(`scale`)!==`linear`){let e=[...i].sort((e,t)=>e-t);return 1+Math.round(e.indexOf(n)*(r-1)/(e.length-1))}return Math.min(r,1+Math.floor((n-a)/(o-a)*r))}get steps(){return Number(this.getAttribute(`steps`))||5}shade(e){return`${Math.round(12+88*e/this.steps)}%`}describe(e){let t=this.values?.[e],n=this.getAttribute(`unit`);return typeof t==`number`?`${e}: ${this.fmt(t)}${n?` ${n}`:``}`:e}render(){let e=this.getAttribute(`label`)??c().iranMap.label,t=this.selectable,n=this.multiple,r=this.values,a=this.getAttribute(`unit`),s=h.map((e,r)=>{let i=this.level(e);return`<path d="${m[e].d}" class="k-iran-map__province" data-i="${r}"${i?` data-l="${i}" style="--_p: ${this.shade(i)}"`:``}${t?` role="${n?`checkbox`:`radio`}" aria-label="${o(this.describe(e))}"`:``}></path>`}).join(``),l=r?h.map(e=>r[e]).filter(e=>typeof e==`number`):[],u=(this.hasAttribute(`legend`)?i(this,`legend`):r)&&l.length?`<figcaption class="k-iran-map__legend"><span>${this.fmt(Math.min(...l))}</span><span class="k-iran-map__scale" aria-hidden="true">${Array.from({length:this.steps},(e,t)=>`<i style="--_p: ${this.shade(t+1)}"></i>`).join(``)}</span><span>${this.fmt(Math.max(...l))}${a?` ${o(a)}`:``}</span></figcaption>`:``,d=r?`<table class="k-sr-only"><caption>${o(e)}</caption><tbody>${h.filter(e=>typeof r[e]==`number`).sort((e,t)=>r[t]-r[e]).map(e=>`<tr><th scope="row">${o(e)}</th><td>${this.fmt(r[e])}${a?` ${o(a)}`:``}</td></tr>`).join(``)}</tbody></table>`:``;this.innerHTML=`<figure class="k-iran-map${t?` k-iran-map--selectable`:``}"><div class="k-iran-map__canvas" style="block-size: auto; aspect-ratio: ${_} / ${v}"><svg viewBox="${p}" class="k-iran-map__svg" role="${t?n?`group`:`radiogroup`:`img`}" aria-label="${o(t?e:`${e}${r?c().iranMap.tableNote:``}`)}">${s}</svg><div class="k-chart__tip" aria-hidden="true" style="display: none"></div></div>${u}${d}</figure>`;let f=this.querySelector(`svg`),g=this.querySelector(`figure`);f.addEventListener(`pointerover`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&this.tip(Number(t))}),g.addEventListener(`pointerleave`,()=>this.tip(null)),t&&(f.addEventListener(`click`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.toggle(h[this.active]))}),f.addEventListener(`keydown`,e=>this.onKey(e)),f.addEventListener(`focusin`,e=>{let t=e.target.getAttribute?.(`data-i`);t!=null&&(this.active=Number(t),this.tip(this.active))}),f.addEventListener(`focusout`,()=>this.tip(null))),this.rendered=!0,this.paint()}paint(){let e=this.selectable,t=h.findIndex(e=>this.selected.includes(e)),n=this.contains(document.activeElement)||t<0?this.active:t;this.querySelectorAll(`.k-iran-map__province`).forEach((t,r)=>{let i=this.selected.includes(h[r]);t.toggleAttribute(`data-selected`,i),e&&(t.setAttribute(`aria-checked`,String(i)),t.setAttribute(`tabindex`,r===n?`0`:`-1`))});let r=this.getAttribute(`name`);if(this.querySelectorAll(`:scope > input[type=hidden]`).forEach(e=>e.remove()),r)for(let e of this.multiple?this.selected:[this.selected[0]??``]){let t=document.createElement(`input`);t.type=`hidden`,t.name=r,t.value=e,this.append(t)}}toggle(e){this.selected=this.multiple?this.selected.includes(e)?this.selected.filter(t=>t!==e):[...this.selected,e]:this.selected[0]===e?[]:[e],this.paint(),r(this,`kashi-change`,{value:this.multiple?[...this.selected]:this.selected[0]??null})}onKey(e){let t=this.active,n={ArrowLeft:1,ArrowDown:1,ArrowRight:-1,ArrowUp:-1}[e.key],r=t;if(n)r=(t+n+h.length)%h.length;else if(e.key===`Home`)r=0;else if(e.key===`End`)r=h.length-1;else if(e.key===`Enter`||e.key===` `){e.preventDefault(),this.toggle(h[t]);return}else return;e.preventDefault(),this.active=r,this.paint(),this.querySelector(`[data-i="${r}"]`)?.focus()}tip(e){let t=this.querySelector(`.k-chart__tip`);if(!t)return;if(this.querySelector(`.k-iran-map__province[data-active]`)?.removeAttribute(`data-active`),e===null){t.style.display=`none`;return}let n=h[e];this.querySelector(`[data-i="${e}"]`)?.setAttribute(`data-active`,``);let r=m[n],i=this.querySelector(`figure`).clientWidth||_,a=this.values?.[n],s=this.getAttribute(`unit`),l=typeof a==`number`?`${this.fmt(a)}${s?` ${s}`:``}`:c().province.capital(g[n]);t.innerHTML=`<span class="k-chart__tip-title">${o(n)}</span><span class="k-chart__tip-row"><strong>${o(l)}</strong></span>`,t.style.left=`${Math.min(Math.max(r.x/_*i,80),i-80)}px`,t.style.top=`${Math.max(64,r.y/v*(v/_*i)-6)}px`,t.style.display=``}};y.observedAttributes=[`data`,`value`,`label`,`unit`,`steps`,`scale`,`legend`,`selectable`,`multiple`,`name`];const b=()=>{let e=c().address;return{province:e.province,city:e.city,street:e.street,plaque:e.plaque,unit:e.unit,postalCode:e.postalCode}};var x=class extends d{constructor(){super(...arguments),this.address={...n},this.built=!1,this.key=f(`kashi-address`)}connectedCallback(){l(()=>{if(this.isConnected){if(!this.built){let e=Object.prototype.hasOwnProperty.call(this,`value`)?this.value:null;delete this.value;let t=this.getAttribute(`value`),r=e??{};if(!e&&t)try{r=JSON.parse(t)}catch{}this.address={...n,...r}}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return{...this.address}}set value(e){this.address={...n,...e},this.built&&this.render()}set errors(e){for(let t of Object.keys(b())){let n=this.querySelector(`[data-field="${t}"]`);n&&(n.matches(`kashi-province-select, kashi-city-select, kashi-postal-code`)?e[t]?n.setAttribute(`error`,e[t]):n.removeAttribute(`error`):this.fieldError(n,e[t]??null))}}label(e){return this.getAttribute(`label-${e===`postalCode`?`postal-code`:e}`)??b()[e]}render(){let e=this.address,n=this.getAttribute(`name`),r=e=>n?` name="${o(`${n}[${e}]`)}"`:``,a=i(this,`required`,!0),s=a?` required`:``,l=i(this,`map`),u=this.key,d=a?`<span class="k-label__required" aria-hidden="true">*</span>`:``,f=this.getAttribute(`legend`)??c().address.legend;this.innerHTML=`<fieldset class="k-address${l?` k-address--map`:``}"${this.hasAttribute(`disabled`)?` disabled`:``}>
|
|
2
2
|
${f?`<legend class="k-address__legend">${o(f)}</legend>`:``}
|
|
3
3
|
<div class="k-address__fields">
|
|
4
4
|
<kashi-province-select class="k-address__province" data-field="province" label="${o(this.label(`province`))}" show-capital="false" placeholder="${o(c().address.provinceSearch)}"${r(`province`)}${s}></kashi-province-select>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,i as t,l as n,m as r,o as i,p as a,r as o,t as s}from"./base-D4tCOysh.js";import{c,f as l,l as u,n as d,s as f,u as p}from"./parts-5fVaWtRe.js";const m={L:[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],M:[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],Q:[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],H:[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},h={L:[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],M:[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Q:[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],H:[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},g={L:1,M:0,Q:3,H:2},_=e=>{let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t},v=(e,t)=>Math.floor(_(e)/8)-m[t][e]*h[t][e],y=(e,t)=>{let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n&255},b=e=>{let t=Array(e).fill(0);t[e-1]=1;let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=y(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=y(n,2)}return t},x=(e,t)=>{let n=Array(t.length).fill(0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=y(t,e))}return n},S=e=>{if(e===1)return[];let t=Math.floor(e/7)+2,n=e===32?26:Math.ceil((e*4+4)/(t*2-2))*2,r=[6];for(let i=e*4+10;r.length<t;i-=n)r.splice(1,0,i);return r},C=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,e=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0];function w(e){let t=e.length,n=0,r=e=>{for(let r=0;r<t;r++){let i=1;for(let a=1;a<=t;a++)a<t&&e(r,a)===e(r,a-1)?i++:(i>=5&&(n+=i-2),i=1);for(let i=0;i+10<t;i++){let t=Array.from({length:11},(t,n)=>e(r,i+n)),a=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1];(t.every((e,t)=>e===a[t])||t.every((e,t)=>e===a[10-t]))&&(n+=40)}}};r((t,n)=>e[t][n]),r((t,n)=>e[n][t]);let i=0;for(let r=0;r<t;r++)for(let a=0;a<t;a++)e[r][a]&&i++,a<t-1&&r<t-1&&e[r][a]===e[r][a+1]&&e[r][a]===e[r+1][a]&&e[r][a]===e[r+1][a+1]&&(n+=3);let a=t*t;return n+=(Math.ceil(Math.abs(i*20-a*10)/a)-1)*10,n}function T(e,t=`M`){let n=Array.from(new TextEncoder().encode(e)),r=0;for(let e=1;e<=40;e++)if(4+(e<=9?8:16)+n.length*8<=v(e,t)*8){r=e;break}if(!r)return null;let i=[],a=(e,t)=>{for(let n=t-1;n>=0;n--)i.push(e>>>n&1)};a(4,4),a(n.length,r<=9?8:16);for(let e of n)a(e,8);let o=v(r,t)*8;a(0,Math.min(4,o-i.length)),a(0,(8-i.length%8)%8);for(let e=236;i.length<o;e^=253)a(e,8);let s=[];for(let e=0;e<i.length;e+=8)s.push(parseInt(i.slice(e,e+8).join(``),2));let c=h[t][r],l=m[t][r],u=Math.floor(_(r)/8),d=c-u%c,f=Math.floor(u/c),p=b(l),y=[];for(let e=0,t=0;e<c;e++){let n=f-l+(e<d?0:1),r=s.slice(t,t+n);t+=n;let i=x(r,p);e<d&&r.push(0),y.push(r.concat(i))}let T=[];for(let e=0;e<y[0].length;e++)for(let t=0;t<c;t++)(e!==f-l||t>=d)&&T.push(y[t][e]);let E=r*4+17,D=Array.from({length:E},()=>Array(E).fill(!1)),O=Array.from({length:E},()=>Array(E).fill(!1)),k=(e,t,n)=>{D[t][e]=n,O[t][e]=!0};for(let e=0;e<E;e++)k(6,e,e%2==0),k(e,6,e%2==0);for(let[e,t]of[[3,3],[E-4,3],[3,E-4]])for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=e+r,a=t+n;if(i>=0&&i<E&&a>=0&&a<E){let e=Math.max(Math.abs(r),Math.abs(n));k(i,a,e!==2&&e!==4)}}let A=S(r);A.forEach((e,t)=>A.forEach((n,r)=>{if(!(t===0&&r===0||t===0&&r===A.length-1||t===A.length-1&&r===0))for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++)k(e+r,n+t,Math.max(Math.abs(r),Math.abs(t))!==1)}));let j=e=>{let n=g[t]<<3|e,r=n;for(let e=0;e<10;e++)r=r<<1^(r>>>9)*1335;let i=(n<<10|r)^21522,a=e=>(i>>>e&1)==1;for(let e=0;e<=5;e++)k(8,e,a(e));k(8,7,a(6)),k(8,8,a(7)),k(7,8,a(8));for(let e=9;e<15;e++)k(14-e,8,a(e));for(let e=0;e<8;e++)k(E-1-e,8,a(e));for(let e=8;e<15;e++)k(8,E-15+e,a(e));k(8,E-8,!0)};if(j(0),r>=7){let e=r;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=r<<12|e;for(let e=0;e<18;e++){let n=(t>>>e&1)==1,r=E-11+e%3,i=Math.floor(e/3);k(r,i,n),k(i,r,n)}}let M=0;for(let e=E-1;e>=1;e-=2){e===6&&(e=5);for(let t=0;t<E;t++)for(let n=0;n<2;n++){let r=e-n,i=e+1&2?t:E-1-t;!O[i][r]&&M<T.length*8&&(D[i][r]=(T[M>>>3]>>>7-(M&7)&1)==1,M++)}}let N=e=>{for(let t=0;t<E;t++)for(let n=0;n<E;n++)!O[t][n]&&C[e](n,t)&&(D[t][n]=!D[t][n])},P=0,F=1/0;for(let e=0;e<8;e++){N(e),j(e);let t=w(D);t<F&&([P,F]=[e,t]),N(e)}return N(P),j(P),D}const E=e=>f(`<path d="${e}"/>`,1.8),D=E(`M8.5 14a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11ZM17 17l-4.2-4.2M6 8.5h5M8.5 6v5`),O=E(`M8.5 14a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11ZM17 17l-4.2-4.2M6 8.5h5`);var k=class extends s{constructor(){super(...arguments),this.data=null,this.grid=null,this.box=null,this.index=0,this.zoom=null,this.swipe=null,this.dx=0,this.opener=null}connectedCallback(){o(()=>{this.isConnected&&(this.grid||(this.data===null&&!this.hasAttribute(`images`)&&(this.data=[...this.querySelectorAll(`:scope > img`)].map(e=>({src:e.dataset.full??e.getAttribute(`src`)??``,thumb:e.dataset.full?e.getAttribute(`src`)??void 0:void 0,alt:e.alt,caption:e.dataset.caption,width:e.width||void 0,height:e.height||void 0}))),this.grid=document.createElement(`ul`),this.grid.className=`k-gallery`,this.replaceChildren(this.grid),this.grid.addEventListener(`click`,e=>{let t=e.target.closest(`.k-gallery__item`);t&&this.openAt(Number(t.dataset.index),t)})),this.render())})}attributeChangedCallback(e,t,n){t!==n&&(e===`images`&&(this.data=null),this.grid&&this.render())}get images(){return this.data??u(this,`images`,[])}set images(e){this.data=[...e??[]],this.grid&&this.render()}render(){let e=a().lightbox,t=this.images,i=p(this,`max`),o=i&&t.length>i?t.slice(0,i):t,s=t.length-o.length,c=this.grid;c.setAttribute(`aria-label`,this.getAttribute(`label`)??e.gallery);let l=p(this,`columns`);l?c.style.setProperty(`--k-gallery-cols`,String(l)):c.style.removeProperty(`--k-gallery-cols`),c.style.setProperty(`--k-gallery-aspect`,this.getAttribute(`aspect`)??`1 / 1`),c.innerHTML=o.map((t,i)=>{let a=s>0&&i===o.length-1;return`<li><button type="button" class="k-gallery__item" data-index="${i}" aria-label="${n(a?`${e.open(t.alt)} +${r(this,s)}`:e.open(t.alt))}"><img src="${n(t.thumb??t.src)}" alt="" loading="lazy"${t.width?` width="${t.width}"`:``}${t.height?` height="${t.height}"`:``}>${a?`<span class="k-gallery__more" aria-hidden="true">+${r(this,s)}</span>`:``}</button></li>`}).join(``)}openAt(t,n){if(!this.images.length)return;this.opener=n??document.activeElement,this.index=Math.max(0,Math.min(t,this.images.length-1)),this.zoom=null,this.box||this.buildBox(),this.paintBox(0);let r=this.box;r.removeAttribute(`data-closing`),r.open||r.showModal?.(),r.querySelector(`[data-act=close]`).focus(),e(this,`kashi-open`,{index:this.index})}close(){this.box?.open&&d(this.box)}buildBox(){let t=document.createElement(`dialog`);t.className=`k-lightbox`,t.setAttribute(`aria-labelledby`,``),t.innerHTML=`<h2 class="k-sr-only"></h2><div class="k-lightbox__bar"><span class="k-lightbox__counter" aria-live="polite"></span><button type="button" class="k-lightbox__btn" data-act="zoom"></button><button type="button" class="k-lightbox__btn" data-act="close">${E(`M5 5l10 10M15 5 5 15`)}</button></div><div class="k-lightbox__stage"><figure class="k-lightbox__figure"><img class="k-lightbox__img" draggable="false" alt=""><figcaption class="k-lightbox__caption" dir="auto"></figcaption></figure><button type="button" class="k-lightbox__nav k-lightbox__nav--prev" data-act="prev">${E(`m8 5 5 5-5 5`)}</button><button type="button" class="k-lightbox__nav k-lightbox__nav--next" data-act="next">${E(`m12 5-5 5 5 5`)}</button></div><div class="k-lightbox__thumbs"></div>`;let n=t.querySelector(`h2`);n.id=`${this.tagName.toLowerCase()}-lb-${Math.random().toString(36).slice(2,8)}`,t.setAttribute(`aria-labelledby`,n.id),this.append(t),this.box=t,t.addEventListener(`cancel`,e=>{e.preventDefault(),this.zoom?(this.zoom=null,this.paintBox(0)):this.close()}),t.addEventListener(`close`,()=>{this.opener?.focus?.(),e(this,`kashi-close`,{})}),t.addEventListener(`keydown`,e=>{let n=c(t),r=this.images.length;if(e.key===`ArrowRight`)this.go(this.index+(n?-1:1));else if(e.key===`ArrowLeft`)this.go(this.index+(n?1:-1));else if(e.key===`Home`)this.go(0);else if(e.key===`End`)this.go(r-1);else return;e.preventDefault()}),t.addEventListener(`click`,e=>{let n=e.target;if(n===t||n.classList.contains(`k-lightbox__stage`))return this.close();let r=n.closest(`[data-act]`)?.dataset.act;r===`close`?this.close():r===`zoom`?(this.zoom=this.zoom?null:{x:50,y:50},this.paintBox(0)):r===`prev`?this.go(this.index-1):r===`next`&&this.go(this.index+1);let i=n.closest(`[data-thumb]`);i&&this.go(Number(i.dataset.thumb))});let r=t.querySelector(`.k-lightbox__img`);r.addEventListener(`click`,e=>{if(Math.abs(this.dx)>4)return;let t=r.getBoundingClientRect();this.zoom=this.zoom?null:{x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},this.paintBox(0)}),r.addEventListener(`pointermove`,e=>{if(!this.zoom||e.pointerType===`touch`)return;let t=r.getBoundingClientRect();this.zoom={x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},r.style.transformOrigin=`${this.zoom.x}% ${this.zoom.y}%`});let i=t.querySelector(`.k-lightbox__stage`),a=t.querySelector(`.k-lightbox__figure`);i.addEventListener(`pointerdown`,e=>{this.zoom||e.target.closest(`button`)||(this.swipe={x:e.clientX,y:e.clientY,id:e.pointerId})}),i.addEventListener(`pointermove`,e=>{this.swipe?.id===e.pointerId&&(this.dx=e.clientX-this.swipe.x,a.style.translate=`${this.dx}px 0`,a.style.transition=`none`)});let o=e=>{let n=this.swipe;this.swipe=null,a.style.translate=``,a.style.transition=``;let r=this.dx;setTimeout(()=>this.dx=0,0),n&&n.id===e.pointerId&&Math.abs(r)>60&&Math.abs(r)>Math.abs(e.clientY-n.y)&&this.go(this.index+(r<0===c(t)?-1:1))};i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,o)}go(n){let r=this.images.length;if(!r)return;let i=t(this,`loop`)?(n+r)%r:Math.max(0,Math.min(r-1,n));if(i===this.index)return;let a=i>this.index?1:-1;this.index=i,this.zoom=null,this.paintBox(a),e(this,`kashi-change`,{index:i})}paintBox(e){let i=a().lightbox,o=this.box,s=this.images,c=s.length,l=this.index,u=s[l],d=t(this,`loop`);o.querySelector(`h2`).textContent=i.label,o.querySelector(`.k-lightbox__counter`).textContent=i.counter(r(this,l+1),r(this,c));let f=o.querySelector(`[data-act=zoom]`);f.innerHTML=this.zoom?O:D,f.setAttribute(`aria-label`,this.zoom?i.zoomOut:i.zoomIn),f.setAttribute(`aria-pressed`,String(!!this.zoom)),o.querySelector(`[data-act=close]`).setAttribute(`aria-label`,i.close);let p=o.querySelector(`.k-lightbox__figure`),m=p.querySelector(`img`);e&&(p.dataset.dir=e>0?`next`:`prev`,p.style.animation=`none`,p.offsetWidth,p.style.animation=``),m.getAttribute(`src`)!==u.src&&(m.src=u.src),m.alt=u.alt,u.width?m.width=u.width:m.removeAttribute(`width`),u.height?m.height=u.height:m.removeAttribute(`height`),m.toggleAttribute(`data-zoom`,!!this.zoom),m.style.transformOrigin=this.zoom?`${this.zoom.x}% ${this.zoom.y}%`:``;let h=p.querySelector(`figcaption`);h.textContent=u.caption??``,h.hidden=!u.caption;let g=o.querySelector(`[data-act=prev]`),_=o.querySelector(`[data-act=next]`);g.hidden=_.hidden=c<2,g.setAttribute(`aria-label`,i.prev),_.setAttribute(`aria-label`,i.next),g.disabled=!d&&l===0,_.disabled=!d&&l===c-1;let v=o.querySelector(`.k-lightbox__thumbs`),y=this.getAttribute(`thumbnails`)!==`false`&&c>1;v.hidden=!y,y&&(v.children.length!==c&&(v.innerHTML=s.map((e,t)=>`<button type="button" class="k-lightbox__thumb" data-thumb="${t}" aria-label="${n(e.alt)}"><img src="${n(e.thumb??e.src)}" alt="" loading="lazy" draggable="false"></button>`).join(``)),v.querySelectorAll(`[data-thumb]`).forEach((e,t)=>{t===l?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}),v.querySelector(`[data-thumb="${l}"]`)?.scrollIntoView?.({block:`nearest`,inline:`center`}));for(let e of[l-1,l+1]){let t=s[(e+c)%c]?.src;t&&typeof Image==`function`&&(new Image().src=t)}}};k.observedAttributes=[`images`,`columns`,`aspect`,`max`,`loop`,`label`,`thumbnails`];var A=class extends s{constructor(){super(...arguments),this.logo=null,this.built=!1}connectedCallback(){o(()=>{this.isConnected&&(this.built||(this.built=!0,this.logo=l(this,`logo`)[0]??null),this.render())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,String(e??``))}render(){let e=a(),t=this.value,r=p(this,`size`,160),i=Math.max(0,p(this,`margin`,4)),o=this.getAttribute(`rounded`)!==`false`,s=this.logo?`H`:(this.getAttribute(`level`)??`M`).toUpperCase(),c=T(t,[`L`,`M`,`Q`,`H`].includes(s)?s:`M`);if(!c){this.innerHTML=`<p class="k-hint k-hint--error">${n(e.qr.tooLong)}</p>`;return}let l=c.length,u=l+i*2,d=(e,t)=>e<7&&t<7||e>=l-7&&t<7||e<7&&t>=l-7,f=this.logo?Math.ceil(l*.22)|1:0,m=(l-f)/2,h=(e,t)=>f>0&&e>=m-.5&&e<m+f-.5&&t>=m-.5&&t<m+f-.5,g=``;for(let e=0;e<l;e++)for(let t=0;t<l;t++)c[e][t]&&!d(t,e)&&!h(t,e)&&(g+=`M${t+i} ${e+i}h1v1h-1z`);let _=+!!o,v=(e,t)=>{let n=e+i,r=t+i,a=_*1.6,o=7-_*3.2;return`<g><path fill-rule="evenodd" d="M${n+a} ${r}h${o}a${a} ${a} 0 0 1 ${a} ${a}v${o}a${a} ${a} 0 0 1 -${a} ${a}h-${o}a${a} ${a} 0 0 1 -${a} -${a}v-${o}a${a} ${a} 0 0 1 ${a} -${a}zM${n+1} ${r+1}v5h5v-5z"/><rect x="${n+2}" y="${r+2}" width="3" height="3" rx="${_*.8}"/></g>`};if(this.innerHTML=`<span class="k-qr" style="inline-size: ${r}px; block-size: ${r}px"><svg viewBox="0 0 ${u} ${u}" width="${r}" height="${r}" role="img" aria-label="${n(this.getAttribute(`label`)??e.qr.label(t))}"${o?``:` shape-rendering="crispEdges"`}><rect width="${u}" height="${u}" class="k-qr__bg" rx="${o?2:0}"/><g class="k-qr__fg"><path d="${g}"/>${v(0,0)}${v(l-7,0)}${v(0,l-7)}</g></svg></span>`,this.logo){let e=document.createElement(`span`);e.className=`k-qr__logo`,e.style.inlineSize=`${f/u*100*.9}%`,e.append(this.logo),this.querySelector(`.k-qr`).append(e)}}};A.observedAttributes=[`value`,`size`,`level`,`margin`,`rounded`,`label`],i(`kashi-gallery`,k,`block`),i(`kashi-qr-code`,A);export{k as KashiGallery,A as KashiQrCode};
|
|
1
|
+
import{c as e,i as t,l as n,m as r,o as i,p as a,r as o,t as s}from"./base-BqFAMlwG.js";import{c,f as l,l as u,n as d,s as f,u as p}from"./parts-5fVaWtRe.js";const m={L:[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],M:[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],Q:[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],H:[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]},h={L:[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],M:[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],Q:[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],H:[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]},g={L:1,M:0,Q:3,H:2},_=e=>{let t=(16*e+128)*e+64;if(e>=2){let n=Math.floor(e/7)+2;t-=(25*n-10)*n-55,e>=7&&(t-=36)}return t},v=(e,t)=>Math.floor(_(e)/8)-m[t][e]*h[t][e],y=(e,t)=>{let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return n&255},b=e=>{let t=Array(e).fill(0);t[e-1]=1;let n=1;for(let r=0;r<e;r++){for(let e=0;e<t.length;e++)t[e]=y(t[e],n),e+1<t.length&&(t[e]^=t[e+1]);n=y(n,2)}return t},x=(e,t)=>{let n=Array(t.length).fill(0);for(let r of e){let e=r^n.shift();n.push(0),t.forEach((t,r)=>n[r]^=y(t,e))}return n},S=e=>{if(e===1)return[];let t=Math.floor(e/7)+2,n=e===32?26:Math.ceil((e*4+4)/(t*2-2))*2,r=[6];for(let i=e*4+10;r.length<t;i-=n)r.splice(1,0,i);return r},C=[(e,t)=>(e+t)%2==0,(e,t)=>t%2==0,e=>e%3==0,(e,t)=>(e+t)%3==0,(e,t)=>(Math.floor(e/3)+Math.floor(t/2))%2==0,(e,t)=>e*t%2+e*t%3==0,(e,t)=>(e*t%2+e*t%3)%2==0,(e,t)=>((e+t)%2+e*t%3)%2==0];function w(e){let t=e.length,n=0,r=e=>{for(let r=0;r<t;r++){let i=1;for(let a=1;a<=t;a++)a<t&&e(r,a)===e(r,a-1)?i++:(i>=5&&(n+=i-2),i=1);for(let i=0;i+10<t;i++){let t=Array.from({length:11},(t,n)=>e(r,i+n)),a=[!0,!1,!0,!0,!0,!1,!0,!1,!1,!1,!1];(t.every((e,t)=>e===a[t])||t.every((e,t)=>e===a[10-t]))&&(n+=40)}}};r((t,n)=>e[t][n]),r((t,n)=>e[n][t]);let i=0;for(let r=0;r<t;r++)for(let a=0;a<t;a++)e[r][a]&&i++,a<t-1&&r<t-1&&e[r][a]===e[r][a+1]&&e[r][a]===e[r+1][a]&&e[r][a]===e[r+1][a+1]&&(n+=3);let a=t*t;return n+=(Math.ceil(Math.abs(i*20-a*10)/a)-1)*10,n}function T(e,t=`M`){let n=Array.from(new TextEncoder().encode(e)),r=0;for(let e=1;e<=40;e++)if(4+(e<=9?8:16)+n.length*8<=v(e,t)*8){r=e;break}if(!r)return null;let i=[],a=(e,t)=>{for(let n=t-1;n>=0;n--)i.push(e>>>n&1)};a(4,4),a(n.length,r<=9?8:16);for(let e of n)a(e,8);let o=v(r,t)*8;a(0,Math.min(4,o-i.length)),a(0,(8-i.length%8)%8);for(let e=236;i.length<o;e^=253)a(e,8);let s=[];for(let e=0;e<i.length;e+=8)s.push(parseInt(i.slice(e,e+8).join(``),2));let c=h[t][r],l=m[t][r],u=Math.floor(_(r)/8),d=c-u%c,f=Math.floor(u/c),p=b(l),y=[];for(let e=0,t=0;e<c;e++){let n=f-l+(e<d?0:1),r=s.slice(t,t+n);t+=n;let i=x(r,p);e<d&&r.push(0),y.push(r.concat(i))}let T=[];for(let e=0;e<y[0].length;e++)for(let t=0;t<c;t++)(e!==f-l||t>=d)&&T.push(y[t][e]);let E=r*4+17,D=Array.from({length:E},()=>Array(E).fill(!1)),O=Array.from({length:E},()=>Array(E).fill(!1)),k=(e,t,n)=>{D[t][e]=n,O[t][e]=!0};for(let e=0;e<E;e++)k(6,e,e%2==0),k(e,6,e%2==0);for(let[e,t]of[[3,3],[E-4,3],[3,E-4]])for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=e+r,a=t+n;if(i>=0&&i<E&&a>=0&&a<E){let e=Math.max(Math.abs(r),Math.abs(n));k(i,a,e!==2&&e!==4)}}let A=S(r);A.forEach((e,t)=>A.forEach((n,r)=>{if(!(t===0&&r===0||t===0&&r===A.length-1||t===A.length-1&&r===0))for(let t=-2;t<=2;t++)for(let r=-2;r<=2;r++)k(e+r,n+t,Math.max(Math.abs(r),Math.abs(t))!==1)}));let j=e=>{let n=g[t]<<3|e,r=n;for(let e=0;e<10;e++)r=r<<1^(r>>>9)*1335;let i=(n<<10|r)^21522,a=e=>(i>>>e&1)==1;for(let e=0;e<=5;e++)k(8,e,a(e));k(8,7,a(6)),k(8,8,a(7)),k(7,8,a(8));for(let e=9;e<15;e++)k(14-e,8,a(e));for(let e=0;e<8;e++)k(E-1-e,8,a(e));for(let e=8;e<15;e++)k(8,E-15+e,a(e));k(8,E-8,!0)};if(j(0),r>=7){let e=r;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=r<<12|e;for(let e=0;e<18;e++){let n=(t>>>e&1)==1,r=E-11+e%3,i=Math.floor(e/3);k(r,i,n),k(i,r,n)}}let M=0;for(let e=E-1;e>=1;e-=2){e===6&&(e=5);for(let t=0;t<E;t++)for(let n=0;n<2;n++){let r=e-n,i=e+1&2?t:E-1-t;!O[i][r]&&M<T.length*8&&(D[i][r]=(T[M>>>3]>>>7-(M&7)&1)==1,M++)}}let N=e=>{for(let t=0;t<E;t++)for(let n=0;n<E;n++)!O[t][n]&&C[e](n,t)&&(D[t][n]=!D[t][n])},P=0,F=1/0;for(let e=0;e<8;e++){N(e),j(e);let t=w(D);t<F&&([P,F]=[e,t]),N(e)}return N(P),j(P),D}const E=e=>f(`<path d="${e}"/>`,1.8),D=E(`M8.5 14a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11ZM17 17l-4.2-4.2M6 8.5h5M8.5 6v5`),O=E(`M8.5 14a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11ZM17 17l-4.2-4.2M6 8.5h5`);var k=class extends s{constructor(){super(...arguments),this.data=null,this.grid=null,this.box=null,this.index=0,this.zoom=null,this.swipe=null,this.dx=0,this.opener=null}connectedCallback(){o(()=>{this.isConnected&&(this.grid||(this.data===null&&!this.hasAttribute(`images`)&&(this.data=[...this.querySelectorAll(`:scope > img`)].map(e=>({src:e.dataset.full??e.getAttribute(`src`)??``,thumb:e.dataset.full?e.getAttribute(`src`)??void 0:void 0,alt:e.alt,caption:e.dataset.caption,width:e.width||void 0,height:e.height||void 0}))),this.grid=document.createElement(`ul`),this.grid.className=`k-gallery`,this.replaceChildren(this.grid),this.grid.addEventListener(`click`,e=>{let t=e.target.closest(`.k-gallery__item`);t&&this.openAt(Number(t.dataset.index),t)})),this.render())})}attributeChangedCallback(e,t,n){t!==n&&(e===`images`&&(this.data=null),this.grid&&this.render())}get images(){return this.data??u(this,`images`,[])}set images(e){this.data=[...e??[]],this.grid&&this.render()}render(){let e=a().lightbox,t=this.images,i=p(this,`max`),o=i&&t.length>i?t.slice(0,i):t,s=t.length-o.length,c=this.grid;c.setAttribute(`aria-label`,this.getAttribute(`label`)??e.gallery);let l=p(this,`columns`);l?c.style.setProperty(`--k-gallery-cols`,String(l)):c.style.removeProperty(`--k-gallery-cols`),c.style.setProperty(`--k-gallery-aspect`,this.getAttribute(`aspect`)??`1 / 1`),c.innerHTML=o.map((t,i)=>{let a=s>0&&i===o.length-1;return`<li><button type="button" class="k-gallery__item" data-index="${i}" aria-label="${n(a?`${e.open(t.alt)} +${r(this,s)}`:e.open(t.alt))}"><img src="${n(t.thumb??t.src)}" alt="" loading="lazy"${t.width?` width="${t.width}"`:``}${t.height?` height="${t.height}"`:``}>${a?`<span class="k-gallery__more" aria-hidden="true">+${r(this,s)}</span>`:``}</button></li>`}).join(``)}openAt(t,n){if(!this.images.length)return;this.opener=n??document.activeElement,this.index=Math.max(0,Math.min(t,this.images.length-1)),this.zoom=null,this.box||this.buildBox(),this.paintBox(0);let r=this.box;r.removeAttribute(`data-closing`),r.open||r.showModal?.(),r.querySelector(`[data-act=close]`).focus(),e(this,`kashi-open`,{index:this.index})}close(){this.box?.open&&d(this.box)}buildBox(){let t=document.createElement(`dialog`);t.className=`k-lightbox`,t.setAttribute(`aria-labelledby`,``),t.innerHTML=`<h2 class="k-sr-only"></h2><div class="k-lightbox__bar"><span class="k-lightbox__counter" aria-live="polite"></span><button type="button" class="k-lightbox__btn" data-act="zoom"></button><button type="button" class="k-lightbox__btn" data-act="close">${E(`M5 5l10 10M15 5 5 15`)}</button></div><div class="k-lightbox__stage"><figure class="k-lightbox__figure"><img class="k-lightbox__img" draggable="false" alt=""><figcaption class="k-lightbox__caption" dir="auto"></figcaption></figure><button type="button" class="k-lightbox__nav k-lightbox__nav--prev" data-act="prev">${E(`m8 5 5 5-5 5`)}</button><button type="button" class="k-lightbox__nav k-lightbox__nav--next" data-act="next">${E(`m12 5-5 5 5 5`)}</button></div><div class="k-lightbox__thumbs"></div>`;let n=t.querySelector(`h2`);n.id=`${this.tagName.toLowerCase()}-lb-${Math.random().toString(36).slice(2,8)}`,t.setAttribute(`aria-labelledby`,n.id),this.append(t),this.box=t,t.addEventListener(`cancel`,e=>{e.preventDefault(),this.zoom?(this.zoom=null,this.paintBox(0)):this.close()}),t.addEventListener(`close`,()=>{this.opener?.focus?.(),e(this,`kashi-close`,{})}),t.addEventListener(`keydown`,e=>{let n=c(t),r=this.images.length;if(e.key===`ArrowRight`)this.go(this.index+(n?-1:1));else if(e.key===`ArrowLeft`)this.go(this.index+(n?1:-1));else if(e.key===`Home`)this.go(0);else if(e.key===`End`)this.go(r-1);else return;e.preventDefault()}),t.addEventListener(`click`,e=>{let n=e.target;if(n===t||n.classList.contains(`k-lightbox__stage`))return this.close();let r=n.closest(`[data-act]`)?.dataset.act;r===`close`?this.close():r===`zoom`?(this.zoom=this.zoom?null:{x:50,y:50},this.paintBox(0)):r===`prev`?this.go(this.index-1):r===`next`&&this.go(this.index+1);let i=n.closest(`[data-thumb]`);i&&this.go(Number(i.dataset.thumb))});let r=t.querySelector(`.k-lightbox__img`);r.addEventListener(`click`,e=>{if(Math.abs(this.dx)>4)return;let t=r.getBoundingClientRect();this.zoom=this.zoom?null:{x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},this.paintBox(0)}),r.addEventListener(`pointermove`,e=>{if(!this.zoom||e.pointerType===`touch`)return;let t=r.getBoundingClientRect();this.zoom={x:(e.clientX-t.left)/t.width*100,y:(e.clientY-t.top)/t.height*100},r.style.transformOrigin=`${this.zoom.x}% ${this.zoom.y}%`});let i=t.querySelector(`.k-lightbox__stage`),a=t.querySelector(`.k-lightbox__figure`);i.addEventListener(`pointerdown`,e=>{this.zoom||e.target.closest(`button`)||(this.swipe={x:e.clientX,y:e.clientY,id:e.pointerId})}),i.addEventListener(`pointermove`,e=>{this.swipe?.id===e.pointerId&&(this.dx=e.clientX-this.swipe.x,a.style.translate=`${this.dx}px 0`,a.style.transition=`none`)});let o=e=>{let n=this.swipe;this.swipe=null,a.style.translate=``,a.style.transition=``;let r=this.dx;setTimeout(()=>this.dx=0,0),n&&n.id===e.pointerId&&Math.abs(r)>60&&Math.abs(r)>Math.abs(e.clientY-n.y)&&this.go(this.index+(r<0===c(t)?-1:1))};i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,o)}go(n){let r=this.images.length;if(!r)return;let i=t(this,`loop`)?(n+r)%r:Math.max(0,Math.min(r-1,n));if(i===this.index)return;let a=i>this.index?1:-1;this.index=i,this.zoom=null,this.paintBox(a),e(this,`kashi-change`,{index:i})}paintBox(e){let i=a().lightbox,o=this.box,s=this.images,c=s.length,l=this.index,u=s[l],d=t(this,`loop`);o.querySelector(`h2`).textContent=i.label,o.querySelector(`.k-lightbox__counter`).textContent=i.counter(r(this,l+1),r(this,c));let f=o.querySelector(`[data-act=zoom]`);f.innerHTML=this.zoom?O:D,f.setAttribute(`aria-label`,this.zoom?i.zoomOut:i.zoomIn),f.setAttribute(`aria-pressed`,String(!!this.zoom)),o.querySelector(`[data-act=close]`).setAttribute(`aria-label`,i.close);let p=o.querySelector(`.k-lightbox__figure`),m=p.querySelector(`img`);e&&(p.dataset.dir=e>0?`next`:`prev`,p.style.animation=`none`,p.offsetWidth,p.style.animation=``),m.getAttribute(`src`)!==u.src&&(m.src=u.src),m.alt=u.alt,u.width?m.width=u.width:m.removeAttribute(`width`),u.height?m.height=u.height:m.removeAttribute(`height`),m.toggleAttribute(`data-zoom`,!!this.zoom),m.style.transformOrigin=this.zoom?`${this.zoom.x}% ${this.zoom.y}%`:``;let h=p.querySelector(`figcaption`);h.textContent=u.caption??``,h.hidden=!u.caption;let g=o.querySelector(`[data-act=prev]`),_=o.querySelector(`[data-act=next]`);g.hidden=_.hidden=c<2,g.setAttribute(`aria-label`,i.prev),_.setAttribute(`aria-label`,i.next),g.disabled=!d&&l===0,_.disabled=!d&&l===c-1;let v=o.querySelector(`.k-lightbox__thumbs`),y=this.getAttribute(`thumbnails`)!==`false`&&c>1;v.hidden=!y,y&&(v.children.length!==c&&(v.innerHTML=s.map((e,t)=>`<button type="button" class="k-lightbox__thumb" data-thumb="${t}" aria-label="${n(e.alt)}"><img src="${n(e.thumb??e.src)}" alt="" loading="lazy" draggable="false"></button>`).join(``)),v.querySelectorAll(`[data-thumb]`).forEach((e,t)=>{t===l?e.setAttribute(`aria-current`,`true`):e.removeAttribute(`aria-current`)}),v.querySelector(`[data-thumb="${l}"]`)?.scrollIntoView?.({block:`nearest`,inline:`center`}));for(let e of[l-1,l+1]){let t=s[(e+c)%c]?.src;t&&typeof Image==`function`&&(new Image().src=t)}}};k.observedAttributes=[`images`,`columns`,`aspect`,`max`,`loop`,`label`,`thumbnails`];var A=class extends s{constructor(){super(...arguments),this.logo=null,this.built=!1}connectedCallback(){o(()=>{this.isConnected&&(this.built||(this.built=!0,this.logo=l(this,`logo`)[0]??null),this.render())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&this.render()}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,String(e??``))}render(){let e=a(),t=this.value,r=p(this,`size`,160),i=Math.max(0,p(this,`margin`,4)),o=this.getAttribute(`rounded`)!==`false`,s=this.logo?`H`:(this.getAttribute(`level`)??`M`).toUpperCase(),c=T(t,[`L`,`M`,`Q`,`H`].includes(s)?s:`M`);if(!c){this.innerHTML=`<p class="k-hint k-hint--error">${n(e.qr.tooLong)}</p>`;return}let l=c.length,u=l+i*2,d=(e,t)=>e<7&&t<7||e>=l-7&&t<7||e<7&&t>=l-7,f=this.logo?Math.ceil(l*.22)|1:0,m=(l-f)/2,h=(e,t)=>f>0&&e>=m-.5&&e<m+f-.5&&t>=m-.5&&t<m+f-.5,g=``;for(let e=0;e<l;e++)for(let t=0;t<l;t++)c[e][t]&&!d(t,e)&&!h(t,e)&&(g+=`M${t+i} ${e+i}h1v1h-1z`);let _=+!!o,v=(e,t)=>{let n=e+i,r=t+i,a=_*1.6,o=7-_*3.2;return`<g><path fill-rule="evenodd" d="M${n+a} ${r}h${o}a${a} ${a} 0 0 1 ${a} ${a}v${o}a${a} ${a} 0 0 1 -${a} ${a}h-${o}a${a} ${a} 0 0 1 -${a} -${a}v-${o}a${a} ${a} 0 0 1 ${a} -${a}zM${n+1} ${r+1}v5h5v-5z"/><rect x="${n+2}" y="${r+2}" width="3" height="3" rx="${_*.8}"/></g>`};if(this.innerHTML=`<span class="k-qr" style="inline-size: ${r}px; block-size: ${r}px"><svg viewBox="0 0 ${u} ${u}" width="${r}" height="${r}" role="img" aria-label="${n(this.getAttribute(`label`)??e.qr.label(t))}"${o?``:` shape-rendering="crispEdges"`}><rect width="${u}" height="${u}" class="k-qr__bg" rx="${o?2:0}"/><g class="k-qr__fg"><path d="${g}"/>${v(0,0)}${v(l-7,0)}${v(0,l-7)}</g></svg></span>`,this.logo){let e=document.createElement(`span`);e.className=`k-qr__logo`,e.style.inlineSize=`${f/u*100*.9}%`,e.append(this.logo),this.querySelector(`.k-qr`).append(e)}}};A.observedAttributes=[`value`,`size`,`level`,`margin`,`rounded`,`label`],i(`kashi-gallery`,k,`block`),i(`kashi-qr-code`,A);export{k as KashiGallery,A as KashiQrCode};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,l as t,o as n,r,t as i,y as a}from"./base-
|
|
1
|
+
import{c as e,l as t,o as n,r,t as i,y as a}from"./base-BqFAMlwG.js";const o=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var s=class extends i{constructor(){super(...arguments),this.menu=null,this.trigger=null,this.key=a(`kashi-menu`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.menu&&this.decorate()}get open(){return!!this.menu&&!this.menu.hidden}build(){let[n,...r]=[...this.children];if(!n)return;this.classList.add(`k-menu-anchor`),this.trigger=n,n.id||=`${this.key}-trigger`,n.setAttribute(`aria-haspopup`,`menu`),n.setAttribute(`aria-expanded`,`false`);let i=document.createElement(`ul`);i.id=`${this.key}-menu`,i.setAttribute(`role`,`menu`),i.hidden=!0;for(let e of r){let n=document.createElement(`li`);if(e.tagName===`HR`)n.setAttribute(`role`,`separator`),n.className=`k-menu__separator`,e.remove();else if(e.hasAttribute(`data-label`))n.setAttribute(`role`,`presentation`),n.className=`k-menu__label`,n.textContent=e.textContent,e.remove();else{n.setAttribute(`role`,`none`);let r=e.hasAttribute(`data-checked`);e.setAttribute(`role`,r?`menuitemcheckbox`:`menuitem`),e.tabIndex=-1,e.classList.add(`k-menu__item`),e.dataset.tone===`danger`&&e.classList.add(`k-menu__item--danger`),e instanceof HTMLButtonElement&&(e.type=`button`,e.disabled&&(e.disabled=!1,e.setAttribute(`aria-disabled`,`true`)));let i=e.innerHTML;e.innerHTML=`${r?`<span class="k-menu__check" aria-hidden="true"></span>`:``}<span>${i}</span>${e.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${t(e.dataset.shortcut)}</span>`:``}`,r&&this.paintCheck(e),n.append(e)}i.append(n)}this.append(i),this.menu=i,this.decorate(),n.addEventListener(`click`,()=>this.open?this.close(!1):this.show(`first`)),n.addEventListener(`keydown`,e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),this.show(e.key===`ArrowUp`?`last`:`first`))}),i.addEventListener(`keydown`,e=>this.onKey(e)),i.addEventListener(`click`,t=>{let n=t.target.closest(`[role^="menuitem"]`);n&&n.getAttribute(`aria-disabled`)!==`true`&&(n.getAttribute(`role`)===`menuitemcheckbox`&&(n.dataset.checked=String(n.dataset.checked!==`true`),this.paintCheck(n)),e(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``,checked:n.dataset.checked===void 0?void 0:n.dataset.checked===`true`}),n.getAttribute(`role`)===`menuitem`&&this.close(n.tagName!==`A`))})}paintCheck(e){let t=e.dataset.checked===`true`;e.setAttribute(`aria-checked`,String(t)),e.querySelector(`.k-menu__check`).innerHTML=t?`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m5 10.5 3.2 3L15 7"/></svg>`:``}decorate(){let e=this.getAttribute(`label`);this.menu.className=`k-menu${this.getAttribute(`align`)===`end`?` k-menu--end`:``}`,e?(this.menu.setAttribute(`aria-label`,e),this.menu.removeAttribute(`aria-labelledby`)):(this.menu.setAttribute(`aria-labelledby`,this.trigger.id),this.menu.removeAttribute(`aria-label`))}show(e=`first`){if(!this.menu)return;this.menu.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.menu.id);let t=o(this.menu);(e===`last`?t.at(-1):t[0])?.focus(),document.addEventListener(`pointerdown`,this.onOutside)}close(e=!0){this.menu&&!this.menu.hidden&&(this.menu.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),e&&this.trigger.focus())}onKey(e){let t=o(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else if(e.key.length===1&&/\S/.test(e.key)){let r=e.key.toLowerCase();[...t.slice(n+1),...t.slice(0,n+1)].find(e=>e.textContent?.trim().toLowerCase().startsWith(r))?.focus()}else return;e.preventDefault()}};s.observedAttributes=[`label`,`align`];var c=class extends i{constructor(){super(...arguments),this.panel=null,this.trigger=null,this.key=a(`kashi-pop`),this.onOutside=e=>{this.contains(e.target)||this.close(!1)}}connectedCallback(){r(()=>this.isConnected&&!this.panel&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}attributeChangedCallback(){this.panel&&this.decorate()}get open(){return!!this.panel&&!this.panel.hidden}set open(e){e?this.show():this.close(!1)}build(){let[e,...t]=[...this.childNodes].filter(e=>e.nodeType===1||e.textContent?.trim());if(!e)return;this.classList.add(`k-popover-anchor`),this.trigger=e,e.setAttribute(`aria-haspopup`,`dialog`),e.setAttribute(`aria-expanded`,`false`);let n=document.createElement(`div`);n.id=`${this.key}-panel`,n.setAttribute(`role`,`dialog`),n.tabIndex=-1,n.hidden=!0,n.innerHTML=`<p class="k-popover__title" id="${this.key}-title"></p><div class="k-popover__body"></div>`,n.querySelector(`.k-popover__body`).append(...t),this.append(n),this.panel=n,this.decorate(),e.addEventListener(`click`,()=>this.open?this.close(!1):this.show()),n.addEventListener(`keydown`,e=>{e.key===`Escape`&&(e.stopPropagation(),this.close(!0))}),n.addEventListener(`focusout`,e=>{let t=e.relatedTarget;t&&!this.contains(t)&&this.close(!1)})}decorate(){let e=this.panel,[t,n]=(this.getAttribute(`placement`)??`bottom-start`).split(`-`);e.className=[`k-popover`,t===`top`&&`k-popover--top`,n===`end`&&`k-popover--end`].filter(Boolean).join(` `);let r=this.getAttribute(`heading`),i=e.querySelector(`.k-popover__title`);i.textContent=r??``,i.hidden=!r,r?(e.setAttribute(`aria-labelledby`,i.id),e.removeAttribute(`aria-label`)):(e.removeAttribute(`aria-labelledby`),e.setAttribute(`aria-label`,this.getAttribute(`label`)??``))}show(){this.panel&&!this.open&&(this.panel.hidden=!1,this.trigger.setAttribute(`aria-expanded`,`true`),this.trigger.setAttribute(`aria-controls`,this.panel.id),(this.panel.querySelector(`.k-popover__body :is(a[href], button:not([disabled]), input:not([disabled]), select, textarea, [tabindex]:not([tabindex="-1"]))`)??this.panel).focus(),document.addEventListener(`pointerdown`,this.onOutside),e(this,`kashi-open`,{}))}close(t=!0){this.panel&&!this.panel.hidden&&(this.panel.hidden=!0,this.trigger.setAttribute(`aria-expanded`,`false`),this.trigger.removeAttribute(`aria-controls`),document.removeEventListener(`pointerdown`,this.onOutside),t&&this.trigger.focus(),e(this,`kashi-close`,{}))}};c.observedAttributes=[`heading`,`placement`,`label`],n(`kashi-dropdown-menu`,s),n(`kashi-popover`,c);export{s as KashiDropdownMenu,c as KashiPopover};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e,j as t}from"./base-
|
|
1
|
+
import{P as e,j as t}from"./base-BqFAMlwG.js";const n={همت:`trillion`,میلیارد:`billion`,میلیون:`million`,هزار:`thousand`},r=[[1e12,`همت`],[1e9,`میلیارد`],[1e6,`میلیون`],[1e3,`هزار`]],i=e=>Math.round(e/10),a=e=>e*10;function o(o,{unit:s=`toman`,from:c=`toman`,compact:l=!1,showUnit:u=!0,locale:d=`fa`,digits:f=d===`en`?`latin`:`fa`}={}){let p=d===`en`,m=c===s?o:c===`rial`?i(o):a(o),h=m<0?`−`:``;m=Math.abs(m);let g=t(Math.round(m),{digits:f}),_=p?s===`toman`?`Toman`:`Rial`:s===`toman`?`تومان`:`ریال`;if(l){let t=r.find(([e,t])=>m>=e&&(t!==`همت`||s===`toman`&&!p));if(t){let r=Math.round(m/t[0]*100)/100,i=String(r).replace(`.`,f===`fa`?`٫`:`.`);g=`${f===`fa`?e(i):i} ${p?n[t[1]]:t[1]}`,t[1]===`همت`&&(_=``)}}return`${h}${g}${u&&_?` ${_}`:``}`}export{i as n,a as r,o as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e}from"./text-C6fzEBBh.js";import{c as t,i as n,l as r,m as i,o as a,p as o,r as s,t as c,y as l}from"./base-D4tCOysh.js";const u=t=>e(t,{digits:`latin`}).toLowerCase(),d=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var f=class extends c{constructor(){super(...arguments),this.list=null,this.dialog=null,this.query=``,this.active=0,this.opener=null,this.key=l(`kashi-cmd`),this.onShortcut=e=>{this.getAttribute(`shortcut`)!==`false`&&(e.ctrlKey||e.metaKey)&&(e.key===`k`||e.key===`K`||e.code===`KeyK`)&&(e.preventDefault(),this.dialog?.open?this.close():this.show())}}connectedCallback(){s(()=>{this.isConnected&&(this.list===null&&(this.list=this.readItems()),this.dialog||this.build(),document.addEventListener(`keydown`,this.onShortcut))})}disconnectedCallback(){document.removeEventListener(`keydown`,this.onShortcut)}get items(){return this.list??[]}set items(e){this.list=[...e],this.dialog?.open&&this.paint()}readItems(){let e=[...this.querySelectorAll(`:scope > a, :scope > button`)].map((e,t)=>({id:e.dataset.value??`${t}`,label:e.textContent?.trim()??``,group:e.dataset.group,description:e.dataset.description,shortcut:e.dataset.shortcut,keywords:e.dataset.keywords?.split(/[,،]\s*/),href:e instanceof HTMLAnchorElement?e.getAttribute(`href`)??void 0:void 0}));return this.querySelectorAll(`:scope > a, :scope > button`).forEach(e=>e.remove()),e}build(){let e=document.createElement(`dialog`);e.className=`k-dialog k-command`;let t=o(),n=this.getAttribute(`label`)??t.command.title;e.setAttribute(`aria-label`,n),e.innerHTML=`<div class="k-input"><span class="k-input__addon"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" aria-hidden="true"><circle cx="9" cy="9" r="5.5"/><path d="m13.5 13.5 3 3"/></svg></span><input class="k-input__control" type="text" role="combobox" aria-expanded="true" aria-controls="${this.key}-list" aria-autocomplete="list" aria-label="${r(n)}" placeholder="${r(this.getAttribute(`placeholder`)??t.command.placeholder)}" autocomplete="off"></div><ul id="${this.key}-list" role="listbox" aria-label="${r(n)}" class="k-listbox k-listbox--inline k-command__list"></ul><div class="k-command__footer" aria-hidden="true"><span><kbd class="k-kbd">↑</kbd><kbd class="k-kbd">↓</kbd>${r(t.command.navigate)}</span><span><kbd class="k-kbd">Enter</kbd>${r(t.command.select)}</span><span><kbd class="k-kbd">Esc</kbd>${r(t.common.close)}</span></div><span class="k-sr-only" aria-live="polite"></span>`,this.append(e),this.dialog=e;let i=e.querySelector(`input`);i.addEventListener(`input`,()=>{this.query=i.value,this.active=0,this.paint()}),i.addEventListener(`keydown`,e=>{let t=this.filtered().length;if(t){if(e.key===`ArrowDown`)this.active=(this.active+1)%t;else if(e.key===`ArrowUp`)this.active=(this.active-1+t)%t;else if(e.key===`Home`)this.active=0;else if(e.key===`End`)this.active=t-1;else if(e.key===`Enter`)return this.run(this.filtered()[this.active]);else return;e.preventDefault(),this.paint()}});let a=e.querySelector(`ul`);a.addEventListener(`pointerdown`,e=>e.preventDefault()),a.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&this.run(this.filtered()[Number(t.dataset.i)])}),e.addEventListener(`click`,t=>t.target===e&&this.close()),e.addEventListener(`close`,()=>this.opener?.focus?.())}filtered(){let e=u(this.query.trim());return this.items.filter(t=>!e||[t.label,t.description??``,...t.keywords??[]].some(t=>u(t).includes(e)))}show(){this.dialog&&(this.opener=document.activeElement,this.query=``,this.active=0,this.dialog.querySelector(`input`).value=``,this.dialog.showModal?.(),this.paint(),this.dialog.querySelector(`input`).focus())}close(){this.dialog?.open&&this.dialog.close()}run(e){e&&(this.close(),e.href?location.href=e.href:t(this,`kashi-select`,{value:e.id,item:e}))}paint(){let e=this.dialog,t=this.filtered(),n=u(this.query.trim()),a=e=>{let t=n?u(e).indexOf(n):-1;return t<0?r(e):`${r(e.slice(0,t))}<mark>${r(e.slice(t,t+n.length))}</mark>${r(e.slice(t+n.length))}`},s;e.querySelector(`ul`).innerHTML=t.length?t.map((e,t)=>{let n=e.group&&e.group!==s?`<li role="presentation" class="k-listbox__group">${r(e.group)}</li>`:``;return s=e.group,`${n}<li id="${this.key}-list-${t}" data-i="${t}" role="option" aria-selected="${t===this.active}"${t===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${a(e.label)}</span>${e.description?`<span class="k-option__desc">${r(e.description)}</span>`:``}</span>${e.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${r(e.shortcut)}</span>`:``}</li>`}).join(``):`<li role="presentation" class="k-listbox__empty">${r(o().command.empty)}</li>`;let c=e.querySelector(`input`);t.length?c.setAttribute(`aria-activedescendant`,`${this.key}-list-${this.active}`):c.removeAttribute(`aria-activedescendant`),e.querySelector(`#${this.key}-list-${this.active}`)?.scrollIntoView?.({block:`nearest`}),e.querySelector(`:scope > .k-sr-only`).textContent=this.query?o().common.results(i(this,t.length)):``}};f.observedAttributes=[`placeholder`,`label`,`shortcut`];var p=class extends c{constructor(){super(...arguments),this.menu=null,this.returnTo=null,this.key=l(`kashi-ctx`),this.onOutside=e=>{this.menu?.contains(e.target)||this.close(!1)},this.onScroll=()=>this.close(!1)}connectedCallback(){s(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}build(){let e=this.querySelector(`:scope > [data-menu]`);this.classList.add(`k-context-area`),this.setAttribute(`aria-haspopup`,`menu`),this.setAttribute(`aria-describedby`,`${this.key}-hint`);let n=document.createElement(`ul`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,this.getAttribute(`label`)??o().contextMenu.label),n.className=`k-menu k-menu--context`,n.hidden=!0;for(let t of[...e?.children??[]]){let e=document.createElement(`li`);t.tagName===`HR`?(e.setAttribute(`role`,`separator`),e.className=`k-menu__separator`):t.hasAttribute(`data-label`)?(e.setAttribute(`role`,`presentation`),e.className=`k-menu__label`,e.textContent=t.textContent):(e.setAttribute(`role`,`none`),t.setAttribute(`role`,`menuitem`),t.tabIndex=-1,t.classList.add(`k-menu__item`),t.dataset.tone===`danger`&&t.classList.add(`k-menu__item--danger`),t instanceof HTMLButtonElement&&(t.type=`button`),t.innerHTML=`<span>${t.innerHTML}</span>${t.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${r(t.dataset.shortcut)}</span>`:``}`,e.append(t)),n.append(e)}e?.remove(),this.insertAdjacentHTML(`beforeend`,`<span id="${this.key}-hint" class="k-sr-only">${r(o().contextMenu.hint)}</span>`),this.append(n),this.menu=n,this.addEventListener(`contextmenu`,e=>{n.contains(e.target)||(e.preventDefault(),this.openAt(e.clientX,e.clientY))});let i=null,a=()=>{i&&clearTimeout(i.t),i=null};this.addEventListener(`pointerdown`,e=>{if(e.pointerType!==`touch`||n.contains(e.target))return;a();let{clientX:t,clientY:r}=e;i={x:t,y:r,t:setTimeout(()=>{i=null,this.openAt(t,r)},500)}}),this.addEventListener(`pointermove`,e=>{i&&Math.hypot(e.clientX-i.x,e.clientY-i.y)>10&&a()}),this.addEventListener(`pointerup`,a),this.addEventListener(`pointercancel`,a),this.addEventListener(`keydown`,e=>{if(n.contains(e.target))return this.onMenuKey(e);if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault();let t=document.activeElement.getBoundingClientRect();this.openAt(t.left+t.width/2,t.top+t.height/2)}}),n.addEventListener(`click`,e=>{let n=e.target.closest(`[role="menuitem"]`);n&&(t(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``}),this.close(n.tagName!==`A`))})}openAt(e,t){let n=this.menu;this.returnTo=document.activeElement??this,n.hidden=!1;let r=n;r.showPopover&&(n.hasAttribute(`popover`)||n.setAttribute(`popover`,`manual`),n.matches(`:popover-open`)||r.showPopover());let i=n.getBoundingClientRect(),a=getComputedStyle(this).direction===`rtl`,o=a?e-i.width:e;o<8&&(o=a?e:8),o=Math.max(8,Math.min(o,innerWidth-i.width-8));let s=Math.max(8,Math.min(t+i.height>innerHeight-8?t-i.height:t,innerHeight-i.height-8));n.style.setProperty(`--_x`,`${o}px`),n.style.setProperty(`--_y`,`${s}px`),d(n)[0]?.focus({preventScroll:!0}),document.addEventListener(`pointerdown`,this.onOutside),setTimeout(()=>addEventListener(`scroll`,this.onScroll,{passive:!0,once:!0}),150)}close(e=!0){let t=this.menu;if(!t||t.hidden)return;let n=t;t.matches?.(`:popover-open`)&&n.hidePopover?.(),t.hidden=!0,document.removeEventListener(`pointerdown`,this.onOutside),removeEventListener(`scroll`,this.onScroll),e&&this.returnTo?.focus()}onMenuKey(e){let t=d(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else return;e.preventDefault()}};p.observedAttributes=[`label`];const m=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-k-mirror=""><path d="${e?`m8 5 5 5-5 5`:`m12 5-5 5 5 5`}"/></svg>`,h=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e?`<path d="M7.5 5v10M12.5 5v10"/>`:`<path d="M7 4.8v10.4a.6.6 0 0 0 .9.5l8-5.2a.6.6 0 0 0 0-1L7.9 4.3a.6.6 0 0 0-.9.5Z"/>`}</svg>`,g=e=>getComputedStyle(e).direction===`rtl`;function _(e,t){let n=null;e.addEventListener(`pointerdown`,e=>{e.pointerType!==`mouse`&&(n={x:e.clientX,y:e.clientY})}),e.addEventListener(`pointercancel`,()=>n=null),e.addEventListener(`pointerup`,r=>{let i=n;if(n=null,!i)return;let a=r.clientX-i.x,o=r.clientY-i.y;Math.abs(a)<40||Math.abs(a)<Math.abs(o)*1.2||t(a<0===g(e)?-1:1)})}var v=class extends c{constructor(){super(...arguments),this.track=null,this.section=null,this.index=0,this.io=null,this.key=l(`kashi-carousel`),this.left=0,this.startedAt=0,this.playing=!1,this.holds=/* @__PURE__ */ new Set,this.box=null,this.boxIndex=0,this.onVisibility=()=>this.hold(`hidden`,document.hidden)}connectedCallback(){s(()=>this.isConnected&&!this.track&&this.build())}disconnectedCallback(){this.io?.disconnect(),clearTimeout(this.timer),document.removeEventListener(`visibilitychange`,this.onVisibility)}get fade(){return this.getAttribute(`effect`)===`fade`}get perView(){return this.fade?1:Math.max(1,Number(this.getAttribute(`per-view`))||1)}get interval(){if(!this.hasAttribute(`autoplay`))return 0;let e=Number(this.getAttribute(`autoplay`));return e>0?e:5e3}get slides(){return[...this.track?.children??[]]}get pages(){return Math.max(1,this.slides.length-this.perView+1)}build(){let e=o(),t=this.getAttribute(`label`)??e.carousel.slider,n=[...this.children],a=this.hasAttribute(`lightbox`),s=document.createElement(`section`);s.className=`k-carousel${this.fade?` k-carousel--fade`:``}`,s.setAttribute(`aria-roledescription`,e.carousel.slider),s.setAttribute(`aria-label`,t),a&&s.setAttribute(`data-lightbox`,``),s.style.setProperty(`--k-carousel-per-view`,String(this.perView));let c=document.createElement(`div`);c.className=`k-carousel__track`,c.tabIndex=0,c.setAttribute(`aria-live`,`polite`);let l=[];n.forEach((t,r)=>{let a=document.createElement(`div`);a.className=`k-carousel__slide`,a.setAttribute(`role`,`group`),a.setAttribute(`aria-roledescription`,e.carousel.slide),a.setAttribute(`aria-label`,e.carousel.slideOf(i(this,r+1),i(this,n.length))),a.id=`${this.key}-s${r}`;let o=t.getAttribute(`data-thumb`)??(t.tagName===`IMG`?t.getAttribute(`src`):null);o&&(l[r]=o),a.append(t),c.append(a)}),s.append(c),this.replaceChildren(s),this.track=c,this.section=s;let u=this.interval;if(u&&this.pages>1&&s.insertAdjacentHTML(`beforeend`,`<span class="k-carousel__progress" aria-hidden="true"><span class="k-carousel__progress-bar" style="--_d: ${u}ms"></span></span>`),n.some(e=>e.hasAttribute(`data-thumb`))&&s.insertAdjacentHTML(`beforeend`,`<div class="k-carousel__thumbs" role="group" aria-label="${r(e.carousel.thumbnails(t))}">${n.map((t,a)=>`<button type="button" class="k-carousel__thumb" data-go="${a}" aria-label="${r(e.carousel.slideOf(i(this,a+1),i(this,n.length)))}" aria-controls="${this.key}-s${a}">${l[a]?`<img src="${r(l[a])}" alt="" loading="lazy">`:``}</button>`).join(``)}</div>`),this.pages>1||a){let n=this.getAttribute(`dots`)!==`false`&&this.pages>1,o=`${u&&this.pages>1?`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-act="play"></button>`:``}${a?`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-act="expand" aria-haspopup="dialog" aria-label="${r(e.carousel.expand)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3.5h4.5V8M8 16.5H3.5V12M16.5 3.5 11.5 8.5M3.5 16.5l5-5"/></svg></button>`:``}${this.pages>1?`<button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="-1" aria-label="${r(e.common.prev)}">${m(!1)}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="1" aria-label="${r(e.common.next)}">${m(!0)}</button>`:``}`;s.insertAdjacentHTML(`beforeend`,`<div class="k-carousel__bar">${n?`<ul class="k-carousel__dots" aria-label="${r(e.carousel.slides(t))}">${Array.from({length:this.pages},(t,n)=>`<li><button type="button" class="k-carousel__dot" data-go="${n}" aria-label="${r(e.carousel.slideOf(i(this,n+1),i(this,this.pages)))}" aria-controls="${this.key}-s${n}"></button></li>`).join(``)}</ul>`:`<span></span>`}<div class="k-carousel__nav">${o}</div></div>`)}s.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(t&&!this.box?.contains(t))return t.dataset.act===`play`?this.setPlaying(!this.playing):t.dataset.act===`expand`?this.openBox(this.index):t.dataset.go===void 0?t.dataset.step?this.go(this.index+Number(t.dataset.step)):void 0:this.go(Number(t.dataset.go));let n=e.target.closest(`.k-carousel__slide`);a&&n&&c.contains(n)&&!e.target.closest(`a, input, select, textarea, [tabindex]:not(.k-carousel__track)`)&&this.openBox(this.slides.indexOf(n))}),c.addEventListener(`keydown`,e=>{let t=g(c),n={ArrowLeft:t?1:-1,ArrowRight:t?-1:1}[e.key];n?(e.preventDefault(),this.go(this.index+n)):e.key===`Home`?this.go(0):e.key===`End`?this.go(this.pages-1):a&&e.key===`Enter`&&e.target===c&&this.openBox(this.index)}),this.fade?_(c,e=>this.go(this.index+e)):typeof IntersectionObserver<`u`&&(this.io=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting&&e.intersectionRatio>.6).map(e=>this.slides.indexOf(e.target));t.length&&this.setIndex(Math.min(...t))},{root:c,threshold:[.6,1]}),this.slides.forEach(e=>this.io.observe(e))),s.addEventListener(`mouseenter`,()=>this.hold(`hover`,!0)),s.addEventListener(`mouseleave`,()=>this.hold(`hover`,!1)),s.addEventListener(`focusin`,()=>this.hold(`focus`,!0)),s.addEventListener(`focusout`,e=>!s.contains(e.relatedTarget)&&this.hold(`focus`,!1)),document.addEventListener(`visibilitychange`,this.onVisibility),this.index=-1,this.setIndex(0),this.left=u,this.setPlaying(u>0&&!matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)}hold(e,t){t?this.holds.add(e):this.holds.delete(e),this.schedule()}setPlaying(e){this.playing=e;let t=this.querySelector(`[data-act="play"]`);t&&(t.innerHTML=h(e),t.setAttribute(`aria-label`,e?o().carousel.pause:o().carousel.play),t.setAttribute(`aria-pressed`,String(!e))),this.schedule()}schedule(){let e=this.interval>0&&this.pages>1&&this.playing&&this.holds.size===0;this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0,this.left=Math.max(0,this.left-(Date.now()-this.startedAt))),this.track?.setAttribute(`aria-live`,e?`off`:`polite`),this.querySelector(`.k-carousel__progress-bar`)?.toggleAttribute(`data-paused`,!e),e&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.timer=void 0,this.go((this.index+1)%this.pages)},this.left))}go(e){let t=Math.max(0,Math.min(this.pages-1,e)),n=this.slides[t],r=this.track;if(n&&r){if(!this.fade){let e=g(r)?-(r.getBoundingClientRect().right-n.getBoundingClientRect().right)+r.scrollLeft:n.getBoundingClientRect().left-r.getBoundingClientRect().left+r.scrollLeft;r.scrollTo?.({left:e})}this.setIndex(t)}}setIndex(e){let n=e!==this.index;this.index=e,this.querySelectorAll(`.k-carousel__dot`).forEach((t,n)=>t.setAttribute(`aria-current`,String(n===e)));let r=this.querySelectorAll(`.k-carousel__thumb`);r.forEach((t,n)=>t.setAttribute(`aria-current`,String(n===e)));let i=this.querySelector(`.k-carousel__thumbs`),a=r[e];if(i&&a){let e=i.getBoundingClientRect(),t=a.getBoundingClientRect();(t.left<e.left||t.right>e.right)&&i.scrollTo?.({left:i.scrollLeft+(t.left+t.width/2)-(e.left+e.width/2)})}this.fade&&this.slides.forEach((t,n)=>{t.toggleAttribute(`data-active`,n===e),t.toggleAttribute(`inert`,n!==e),n===e?t.removeAttribute(`aria-hidden`):t.setAttribute(`aria-hidden`,`true`)});let[o,s]=this.querySelectorAll(`.k-carousel__bar [data-step]`);if(o&&(o.disabled=e===0),s&&(s.disabled=e>=this.pages-1),!n)return;let c=this.querySelector(`.k-carousel__progress-bar`);c&&c.replaceWith(c.cloneNode(!0)),this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.left=this.interval,this.section&&this.schedule(),t(this,`kashi-change`,{index:e})}openBox(e){let t=o();if(!this.box){let e=document.createElement(`dialog`);e.className=`k-carousel__lightbox`,e.setAttribute(`aria-label`,t.carousel.lightbox(this.getAttribute(`label`)??t.carousel.slider)),e.innerHTML=`<div class="k-carousel__lightbox-head"><span class="k-carousel__lightbox-count" aria-live="polite"></span><button type="button" class="k-btn k-btn--tertiary k-btn--icon" data-box="close" aria-label="${r(t.common.close)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="m5.5 5.5 9 9m0-9-9 9"/></svg></button></div><div class="k-carousel__lightbox-stage">${this.slides.map(e=>`<div class="k-carousel__lightbox-slide">${e.innerHTML}</div>`).join(``)}</div>${this.slides.length>1?`<div class="k-carousel__lightbox-nav"><button type="button" class="k-btn k-btn--secondary k-btn--icon" data-box="-1" aria-label="${r(t.common.prev)}">${m(!1)}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon" data-box="1" aria-label="${r(t.common.next)}">${m(!0)}</button></div>`:``}`,e.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),e.addEventListener(`click`,t=>{let n=t.target.closest(`[data-box]`);n?.dataset.box===`close`||t.target===e?e.close():n&&this.boxGo(this.boxIndex+Number(n.dataset.box))}),e.addEventListener(`keydown`,t=>{let n=g(e),r={ArrowLeft:n?1:-1,ArrowRight:n?-1:1}[t.key];r&&(t.preventDefault(),this.boxGo(this.boxIndex+r))}),e.addEventListener(`close`,()=>{this.hold(`box`,!1),this.go(Math.min(this.boxIndex,this.pages-1))}),_(e.querySelector(`.k-carousel__lightbox-stage`),e=>this.boxGo(this.boxIndex+e)),this.section.append(e),this.box=e}this.hold(`box`,!0),this.boxGo(e),this.box.showModal?.(),this.box.querySelector(`[data-box="close"]`)?.focus()}boxGo(e){let t=this.slides.length;this.boxIndex=(e+t)%t,this.box.querySelectorAll(`.k-carousel__lightbox-slide`).forEach((e,t)=>{e.toggleAttribute(`data-active`,t===this.boxIndex),e.toggleAttribute(`inert`,t!==this.boxIndex),t===this.boxIndex?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)}),this.box.querySelector(`.k-carousel__lightbox-count`).textContent=o().carousel.slideOf(i(this,this.boxIndex+1),i(this,t))}};v.observedAttributes=[`label`,`per-view`,`dots`,`effect`,`autoplay`,`lightbox`];var y=class extends c{constructor(){super(...arguments),this.nodes=null,this.open=/* @__PURE__ */ new Set,this.sel=null,this.focusId=null,this.built=!1}connectedCallback(){s(()=>{if(this.isConnected){if(this.nodes===null){let e=this.querySelector(`:scope > ul`);this.nodes=e?this.parse(e):[]}if(!this.built){this.sel=this.getAttribute(`selected`);for(let e of(this.getAttribute(`expanded`)??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean))this.open.add(e);this.built=!0}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`selected`&&(this.sel=n),this.render())}get items(){return this.nodes??[]}set items(e){this.nodes=e,this.built&&this.render()}get value(){return this.sel??``}parse(e){return[...e.children].filter(e=>e.tagName===`LI`).map((e,t)=>{let n=e.querySelector(`:scope > ul`),r=[...e.childNodes].filter(e=>e!==n).map(e=>e.textContent).join(``).trim(),i=e;return{id:i.dataset.id??`${r}-${t}`,label:r,meta:i.dataset.meta,disabled:i.hasAttribute(`data-disabled`),children:n?this.parse(n):void 0}})}visible(){let e=[],t=(n,r)=>{for(let i of n)e.push({node:i,parent:r}),i.children?.length&&this.open.has(i.id)&&t(i.children,i.id)};return t(this.items,null),e}render(e=!1){let t=this.visible(),n=this.focusId&&t.some(e=>e.node.id===this.focusId)?this.focusId:this.sel&&t.some(e=>e.node.id===this.sel)?this.sel:t[0]?.node.id,i=(e,t)=>e.map(e=>{let a=!!e.children?.length,o=this.open.has(e.id);return`<li role="treeitem" data-id="${r(e.id)}" class="k-tree__item" aria-level="${t}"${a?` aria-expanded="${o}"`:``} aria-selected="${this.sel===e.id}"${e.disabled?` aria-disabled="true"`:``} tabindex="${n===e.id?0:-1}"><div class="k-tree__row">${a?`<span class="k-tree__toggle" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m8 5 5 5-5 5"/></svg></span>`:`<span class="k-tree__spacer"></span>`}<span class="k-tree__label">${r(e.label)}</span>${e.meta?`<span class="k-tree__meta">${r(e.meta)}</span>`:``}</div>${a&&o?`<ul role="group">${i(e.children,t+1)}</ul>`:``}</li>`}).join(``);this.innerHTML=`<ul role="tree" class="k-tree"${this.getAttribute(`label`)?` aria-label="${r(this.getAttribute(`label`))}"`:``}>${i(this.items,1)}</ul>`;let a=this.querySelector(`ul`);a.addEventListener(`click`,e=>{let t=e.target.closest(`[role="treeitem"]`);if(!t||!e.target.closest(`.k-tree__row`))return;let n=this.find(t.dataset.id);n&&(n.children?.length&&this.toggle(n.id),this.focusId=n.id,this.choose(n))}),a.addEventListener(`keydown`,e=>this.onKey(e)),e&&n&&[...this.querySelectorAll(`[data-id]`)].find(e=>e.dataset.id===n)?.focus()}find(e,t=this.items){for(let n of t){if(n.id===e)return n;let t=n.children&&this.find(e,n.children);if(t)return t}return null}toggle(e,n=!this.open.has(e)){n?this.open.add(e):this.open.delete(e),t(this,`kashi-expand`,{expanded:[...this.open]})}choose(e){e.disabled||(this.sel=e.id,t(this,`kashi-change`,{value:e.id,node:e})),this.render(!0)}onKey(e){let t=this.visible(),n=document.activeElement?.dataset?.id,r=t.findIndex(e=>e.node.id===n),i=t[r];if(!i)return;let a=getComputedStyle(this).direction===`rtl`,o=!!i.node.children?.length,s=this.open.has(i.node.id),c=e=>{this.focusId=e,this.render(!0)};if(e.key===`ArrowDown`)t[r+1]&&c(t[r+1].node.id);else if(e.key===`ArrowUp`)t[r-1]&&c(t[r-1].node.id);else if(e.key===`Home`)c(t[0].node.id);else if(e.key===`End`)c(t[t.length-1].node.id);else if(e.key===(a?`ArrowLeft`:`ArrowRight`))o&&!s?(this.toggle(i.node.id,!0),c(i.node.id)):o&&c(i.node.children[0].id);else if(e.key===(a?`ArrowRight`:`ArrowLeft`))o&&s?(this.toggle(i.node.id,!1),c(i.node.id)):i.parent&&c(i.parent);else if(e.key===`Enter`||e.key===` `)this.focusId=i.node.id,this.choose(i.node);else return;e.preventDefault()}};y.observedAttributes=[`label`,`selected`,`expanded`];var b=class extends c{constructor(){super(...arguments),this.list=null,this.i=0,this.spot=null,this.card=null,this.returnTo=null,this.key=l(`kashi-tour`),this.place=()=>{let e=this.card;if(!e)return;let t=document.querySelector(this.steps[this.i].target)?.getBoundingClientRect()??null;t?(this.spot||(this.spot=document.createElement(`div`),this.spot.className=`k-tour__spot`,this.spot.setAttribute(`aria-hidden`,`true`),document.body.append(this.spot)),Object.assign(this.spot.style,{top:`${t.top-6}px`,left:`${t.left-6}px`,inlineSize:`${t.width+12}px`,blockSize:`${t.height+12}px`})):(this.spot?.remove(),this.spot=null);let n=e.getBoundingClientRect();if(!t){Object.assign(e.style,{top:`${innerHeight/2-n.height/2}px`,left:`${innerWidth/2-n.width/2}px`});return}let r=t.bottom+12+n.height<innerHeight?t.bottom+12:Math.max(12,t.top-12-n.height),i=Math.min(innerWidth-n.width-12,Math.max(12,t.left+t.width/2-n.width/2));Object.assign(e.style,{top:`${r}px`,left:`${i}px`})}}connectedCallback(){s(()=>{this.isConnected&&this.list===null&&(this.list=[...this.querySelectorAll(`:scope > [data-target]`)].map(e=>({target:e.dataset.target,title:e.dataset.title??``,content:e.textContent?.trim()??``})),this.replaceChildren())})}disconnectedCallback(){this.stop(!1)}get steps(){return this.list??[]}set steps(e){this.list=[...e]}start(){this.steps.length&&(this.returnTo=document.activeElement,this.i=0,addEventListener(`scroll`,this.place,{passive:!0}),addEventListener(`resize`,this.place),this.show())}stop(e=!0){this.spot?.remove(),this.card?.remove(),this.spot=this.card=null,removeEventListener(`scroll`,this.place),removeEventListener(`resize`,this.place),e&&this.returnTo?.focus?.()}show(){let e=this.steps[this.i],n=this.steps.length,a=this.i===n-1;this.card||(this.card=document.createElement(`div`),this.card.className=`k-tour__card`,this.card.setAttribute(`role`,`dialog`),this.card.setAttribute(`aria-modal`,`false`),this.card.setAttribute(`aria-labelledby`,`${this.key}-t`),this.card.setAttribute(`aria-describedby`,`${this.key}-b`),this.card.tabIndex=-1,this.card.addEventListener(`click`,e=>{let n=e.target.closest(`[data-act]`);if(!n)return;let r=n.dataset.act;r===`skip`?this.stop():r===`prev`?this.step(-1):r===`next`?this.step(1):r===`done`&&(this.stop(),t(this,`kashi-finish`,{}))}),this.card.addEventListener(`keydown`,e=>{let t=getComputedStyle(this.card).direction===`rtl`;e.key===`Escape`?this.stop():e.key===(t?`ArrowLeft`:`ArrowRight`)&&this.i<this.steps.length-1?this.step(1):e.key===(t?`ArrowRight`:`ArrowLeft`)&&this.i>0&&this.step(-1)}),document.body.append(this.card)),this.card.innerHTML=`<span class="k-tour__step">${r(o().tour.step(i(this,this.i+1),i(this,n)))}</span><p class="k-tour__title" id="${this.key}-t">${r(e.title)}</p><p class="k-tour__body" id="${this.key}-b">${r(e.content)}</p><div class="k-tour__actions"><button type="button" class="k-btn k-btn--link k-tour__skip" data-act="skip">${r(o().tour.skip)}</button><span class="k-tour__progress" aria-hidden="true">${this.steps.map((e,t)=>`<span${t<=this.i?` data-on=""`:``}></span>`).join(``)}</span>${this.i>0?'<button type="button" class="k-btn k-btn--secondary k-btn--sm" data-act="prev">${esc(msg().common.prev)}</button>':``}<button type="button" class="k-btn k-btn--primary k-btn--sm" data-act="${a?`done`:`next`}">${r(a?o().tour.done:o().common.next)}</button></div>`;let s=document.querySelector(e.target),c=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;s?.scrollIntoView?.({block:`center`,behavior:c?`auto`:`smooth`}),this.place(),setTimeout(this.place,400),this.card.focus({preventScroll:!0})}step(e){this.i=Math.max(0,Math.min(this.steps.length-1,this.i+e)),this.show()}},x=class extends c{constructor(){super(...arguments),this.current=40,this.built=!1,this.dragging=!1}connectedCallback(){s(()=>{this.isConnected&&!this.built&&(this.current=this.num(`size`,40),this.build())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`size`?this.set(Number(n)||40,!1):this.decorate())}get value(){return this.current}set value(e){this.set(e,!1)}num(e,t){let n=Number(this.getAttribute(e));return Number.isFinite(n)&&this.getAttribute(e)!==null?n:t}get vertical(){return this.getAttribute(`orientation`)===`vertical`}build(){let[e,t]=[...this.children],n=document.createElement(`div`),r=document.createElement(`div`);r.className=`k-splitter__pane`,e&&r.append(e);let i=document.createElement(`div`);i.className=`k-splitter__handle`,i.setAttribute(`role`,`separator`),i.tabIndex=0;let a=document.createElement(`div`);a.className=`k-splitter__pane`,t&&a.append(t),n.append(r,i,a),this.replaceChildren(n),this.built=!0,i.addEventListener(`pointerdown`,e=>{i.setPointerCapture?.(e.pointerId),this.dragging=!0,n.toggleAttribute(`data-dragging`,!0),i.toggleAttribute(`data-dragging`,!0)}),i.addEventListener(`pointermove`,e=>{if(!this.dragging)return;let t=n.getBoundingClientRect();if(this.vertical)return this.set((e.clientY-t.top)/t.height*100);let r=getComputedStyle(n).direction===`rtl`;this.set((r?t.right-e.clientX:e.clientX-t.left)/t.width*100)});let o=()=>{this.dragging=!1,n.removeAttribute(`data-dragging`),i.removeAttribute(`data-dragging`)};i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,o),i.addEventListener(`dblclick`,()=>this.set(this.num(`size`,40))),i.addEventListener(`keydown`,e=>{let t=getComputedStyle(i).direction===`rtl`,n=this.vertical?{ArrowUp:-5,ArrowDown:5}:{ArrowLeft:t?5:-5,ArrowRight:t?-5:5};if(e.key in n)this.set(this.current+n[e.key]);else if(e.key===`Home`)this.set(this.num(`min`,15));else if(e.key===`End`)this.set(this.num(`max`,85));else return;e.preventDefault()}),this.decorate()}decorate(){let e=this.firstElementChild;e.className=`k-splitter${this.vertical?` k-splitter--vertical`:``}`;let t=this.getAttribute(`height`);e.style.blockSize=t??``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-orientation`,this.vertical?`horizontal`:`vertical`),n.setAttribute(`aria-valuemin`,String(this.num(`min`,15))),n.setAttribute(`aria-valuemax`,String(this.num(`max`,85))),n.setAttribute(`aria-label`,this.getAttribute(`label`)??o().splitter.label),this.paint()}set(e,n=!0){let r=Math.round(Math.min(this.num(`max`,85),Math.max(this.num(`min`,15),e))*10)/10,i=r!==this.current;this.current=r,this.built&&this.paint(),n&&i&&t(this,`kashi-change`,{value:r})}paint(){let e=this.firstElementChild,t=e.querySelector(`.k-splitter__pane`);t.style.inlineSize=this.vertical?``:`${this.current}%`,t.style.blockSize=this.vertical?`${this.current}%`:``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-valuenow`,String(this.current)),n.setAttribute(`aria-valuetext`,o().common.percent(i(this,Math.round(this.current))))}};x.observedAttributes=[`size`,`min`,`max`,`orientation`,`label`,`height`];var S=class extends c{constructor(){super(...arguments),this.built=!1}connectedCallback(){s(()=>{this.isConnected&&!this.built&&(this.built=!0,this.addEventListener(`click`,e=>{let n=e.target.closest(`button[aria-controls][aria-expanded]`);if(!n||!this.contains(n))return;let r=document.getElementById(n.getAttribute(`aria-controls`)),i=n.getAttribute(`aria-expanded`)!==`true`;n.setAttribute(`aria-expanded`,String(i)),r&&(r.hidden=!i),t(this,`kashi-toggle`,{id:r?.id??``,open:i})}),this.decorate())})}attributeChangedCallback(){this.built&&this.decorate()}decorate(){let e=this.querySelector(`.k-sidenav`),t=n(this,`collapsed`);e?.classList.toggle(`k-sidenav--collapsed`,t),this.querySelectorAll(`.k-sidenav__item`).forEach(e=>{let n=e.querySelector(`.k-sidenav__text`)?.textContent?.trim();n&&(t?(e.setAttribute(`aria-label`,n),e.setAttribute(`title`,n)):(e.removeAttribute(`aria-label`),e.removeAttribute(`title`)))})}};S.observedAttributes=[`collapsed`],typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target,n=t?.closest?.(`[data-kashi-tour]`),r=n?document.getElementById(n.getAttribute(`data-kashi-tour`)):null;r?.start&&r.start();let i=t?.closest?.(`[data-kashi-command]`),a=i?document.getElementById(i.getAttribute(`data-kashi-command`)):null;a?.show&&a.show()}),a(`kashi-command-palette`,f,`contents`),a(`kashi-context-menu`,p,`block`),a(`kashi-carousel`,v,`block`),a(`kashi-tree-view`,y,`block`),a(`kashi-tour`,b,`contents`),a(`kashi-splitter`,x,`block`),a(`kashi-side-nav`,S,`block`);export{v as KashiCarousel,f as KashiCommandPalette,p as KashiContextMenu,S as KashiSideNav,x as KashiSplitter,b as KashiTour,y as KashiTreeView};
|
|
1
|
+
import{n as e}from"./text-DFyW6cuq.js";import{c as t,i as n,l as r,m as i,o as a,p as o,r as s,t as c,y as l}from"./base-BqFAMlwG.js";const u=t=>e(t,{digits:`latin`}).toLowerCase(),d=e=>[...e.querySelectorAll(`[role^="menuitem"]:not([aria-disabled="true"])`)];var f=class extends c{constructor(){super(...arguments),this.list=null,this.dialog=null,this.query=``,this.active=0,this.opener=null,this.key=l(`kashi-cmd`),this.onShortcut=e=>{this.getAttribute(`shortcut`)!==`false`&&(e.ctrlKey||e.metaKey)&&(e.key===`k`||e.key===`K`||e.code===`KeyK`)&&(e.preventDefault(),this.dialog?.open?this.close():this.show())}}connectedCallback(){s(()=>{this.isConnected&&(this.list===null&&(this.list=this.readItems()),this.dialog||this.build(),document.addEventListener(`keydown`,this.onShortcut))})}disconnectedCallback(){document.removeEventListener(`keydown`,this.onShortcut)}get items(){return this.list??[]}set items(e){this.list=[...e],this.dialog?.open&&this.paint()}readItems(){let e=[...this.querySelectorAll(`:scope > a, :scope > button`)].map((e,t)=>({id:e.dataset.value??`${t}`,label:e.textContent?.trim()??``,group:e.dataset.group,description:e.dataset.description,shortcut:e.dataset.shortcut,keywords:e.dataset.keywords?.split(/[,،]\s*/),href:e instanceof HTMLAnchorElement?e.getAttribute(`href`)??void 0:void 0}));return this.querySelectorAll(`:scope > a, :scope > button`).forEach(e=>e.remove()),e}build(){let e=document.createElement(`dialog`);e.className=`k-dialog k-command`;let t=o(),n=this.getAttribute(`label`)??t.command.title;e.setAttribute(`aria-label`,n),e.innerHTML=`<div class="k-input"><span class="k-input__addon"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" aria-hidden="true"><circle cx="9" cy="9" r="5.5"/><path d="m13.5 13.5 3 3"/></svg></span><input class="k-input__control" type="text" role="combobox" aria-expanded="true" aria-controls="${this.key}-list" aria-autocomplete="list" aria-label="${r(n)}" placeholder="${r(this.getAttribute(`placeholder`)??t.command.placeholder)}" autocomplete="off"></div><ul id="${this.key}-list" role="listbox" aria-label="${r(n)}" class="k-listbox k-listbox--inline k-command__list"></ul><div class="k-command__footer" aria-hidden="true"><span><kbd class="k-kbd">↑</kbd><kbd class="k-kbd">↓</kbd>${r(t.command.navigate)}</span><span><kbd class="k-kbd">Enter</kbd>${r(t.command.select)}</span><span><kbd class="k-kbd">Esc</kbd>${r(t.common.close)}</span></div><span class="k-sr-only" aria-live="polite"></span>`,this.append(e),this.dialog=e;let i=e.querySelector(`input`);i.addEventListener(`input`,()=>{this.query=i.value,this.active=0,this.paint()}),i.addEventListener(`keydown`,e=>{let t=this.filtered().length;if(t){if(e.key===`ArrowDown`)this.active=(this.active+1)%t;else if(e.key===`ArrowUp`)this.active=(this.active-1+t)%t;else if(e.key===`Home`)this.active=0;else if(e.key===`End`)this.active=t-1;else if(e.key===`Enter`)return this.run(this.filtered()[this.active]);else return;e.preventDefault(),this.paint()}});let a=e.querySelector(`ul`);a.addEventListener(`pointerdown`,e=>e.preventDefault()),a.addEventListener(`click`,e=>{let t=e.target.closest(`[role="option"]`);t&&this.run(this.filtered()[Number(t.dataset.i)])}),e.addEventListener(`click`,t=>t.target===e&&this.close()),e.addEventListener(`close`,()=>this.opener?.focus?.())}filtered(){let e=u(this.query.trim());return this.items.filter(t=>!e||[t.label,t.description??``,...t.keywords??[]].some(t=>u(t).includes(e)))}show(){this.dialog&&(this.opener=document.activeElement,this.query=``,this.active=0,this.dialog.querySelector(`input`).value=``,this.dialog.showModal?.(),this.paint(),this.dialog.querySelector(`input`).focus())}close(){this.dialog?.open&&this.dialog.close()}run(e){e&&(this.close(),e.href?location.href=e.href:t(this,`kashi-select`,{value:e.id,item:e}))}paint(){let e=this.dialog,t=this.filtered(),n=u(this.query.trim()),a=e=>{let t=n?u(e).indexOf(n):-1;return t<0?r(e):`${r(e.slice(0,t))}<mark>${r(e.slice(t,t+n.length))}</mark>${r(e.slice(t+n.length))}`},s;e.querySelector(`ul`).innerHTML=t.length?t.map((e,t)=>{let n=e.group&&e.group!==s?`<li role="presentation" class="k-listbox__group">${r(e.group)}</li>`:``;return s=e.group,`${n}<li id="${this.key}-list-${t}" data-i="${t}" role="option" aria-selected="${t===this.active}"${t===this.active?` data-active`:``} class="k-option"><span class="k-option__body"><span>${a(e.label)}</span>${e.description?`<span class="k-option__desc">${r(e.description)}</span>`:``}</span>${e.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${r(e.shortcut)}</span>`:``}</li>`}).join(``):`<li role="presentation" class="k-listbox__empty">${r(o().command.empty)}</li>`;let c=e.querySelector(`input`);t.length?c.setAttribute(`aria-activedescendant`,`${this.key}-list-${this.active}`):c.removeAttribute(`aria-activedescendant`),e.querySelector(`#${this.key}-list-${this.active}`)?.scrollIntoView?.({block:`nearest`}),e.querySelector(`:scope > .k-sr-only`).textContent=this.query?o().common.results(i(this,t.length)):``}};f.observedAttributes=[`placeholder`,`label`,`shortcut`];var p=class extends c{constructor(){super(...arguments),this.menu=null,this.returnTo=null,this.key=l(`kashi-ctx`),this.onOutside=e=>{this.menu?.contains(e.target)||this.close(!1)},this.onScroll=()=>this.close(!1)}connectedCallback(){s(()=>this.isConnected&&!this.menu&&this.build())}disconnectedCallback(){document.removeEventListener(`pointerdown`,this.onOutside)}build(){let e=this.querySelector(`:scope > [data-menu]`);this.classList.add(`k-context-area`),this.setAttribute(`aria-haspopup`,`menu`),this.setAttribute(`aria-describedby`,`${this.key}-hint`);let n=document.createElement(`ul`);n.setAttribute(`role`,`menu`),n.setAttribute(`aria-label`,this.getAttribute(`label`)??o().contextMenu.label),n.className=`k-menu k-menu--context`,n.hidden=!0;for(let t of[...e?.children??[]]){let e=document.createElement(`li`);t.tagName===`HR`?(e.setAttribute(`role`,`separator`),e.className=`k-menu__separator`):t.hasAttribute(`data-label`)?(e.setAttribute(`role`,`presentation`),e.className=`k-menu__label`,e.textContent=t.textContent):(e.setAttribute(`role`,`none`),t.setAttribute(`role`,`menuitem`),t.tabIndex=-1,t.classList.add(`k-menu__item`),t.dataset.tone===`danger`&&t.classList.add(`k-menu__item--danger`),t instanceof HTMLButtonElement&&(t.type=`button`),t.innerHTML=`<span>${t.innerHTML}</span>${t.dataset.shortcut?`<span class="k-menu__shortcut" aria-hidden="true">${r(t.dataset.shortcut)}</span>`:``}`,e.append(t)),n.append(e)}e?.remove(),this.insertAdjacentHTML(`beforeend`,`<span id="${this.key}-hint" class="k-sr-only">${r(o().contextMenu.hint)}</span>`),this.append(n),this.menu=n,this.addEventListener(`contextmenu`,e=>{n.contains(e.target)||(e.preventDefault(),this.openAt(e.clientX,e.clientY))});let i=null,a=()=>{i&&clearTimeout(i.t),i=null};this.addEventListener(`pointerdown`,e=>{if(e.pointerType!==`touch`||n.contains(e.target))return;a();let{clientX:t,clientY:r}=e;i={x:t,y:r,t:setTimeout(()=>{i=null,this.openAt(t,r)},500)}}),this.addEventListener(`pointermove`,e=>{i&&Math.hypot(e.clientX-i.x,e.clientY-i.y)>10&&a()}),this.addEventListener(`pointerup`,a),this.addEventListener(`pointercancel`,a),this.addEventListener(`keydown`,e=>{if(n.contains(e.target))return this.onMenuKey(e);if(e.key===`ContextMenu`||e.shiftKey&&e.key===`F10`){e.preventDefault();let t=document.activeElement.getBoundingClientRect();this.openAt(t.left+t.width/2,t.top+t.height/2)}}),n.addEventListener(`click`,e=>{let n=e.target.closest(`[role="menuitem"]`);n&&(t(this,`kashi-select`,{value:n.dataset.value??n.textContent?.trim()??``}),this.close(n.tagName!==`A`))})}openAt(e,t){let n=this.menu;this.returnTo=document.activeElement??this,n.hidden=!1;let r=n;r.showPopover&&(n.hasAttribute(`popover`)||n.setAttribute(`popover`,`manual`),n.matches(`:popover-open`)||r.showPopover());let i=n.getBoundingClientRect(),a=getComputedStyle(this).direction===`rtl`,o=a?e-i.width:e;o<8&&(o=a?e:8),o=Math.max(8,Math.min(o,innerWidth-i.width-8));let s=Math.max(8,Math.min(t+i.height>innerHeight-8?t-i.height:t,innerHeight-i.height-8));n.style.setProperty(`--_x`,`${o}px`),n.style.setProperty(`--_y`,`${s}px`),d(n)[0]?.focus({preventScroll:!0}),document.addEventListener(`pointerdown`,this.onOutside),setTimeout(()=>addEventListener(`scroll`,this.onScroll,{passive:!0,once:!0}),150)}close(e=!0){let t=this.menu;if(!t||t.hidden)return;let n=t;t.matches?.(`:popover-open`)&&n.hidePopover?.(),t.hidden=!0,document.removeEventListener(`pointerdown`,this.onOutside),removeEventListener(`scroll`,this.onScroll),e&&this.returnTo?.focus()}onMenuKey(e){let t=d(this.menu),n=t.indexOf(document.activeElement),r=e=>t[(e+t.length)%t.length]?.focus();if(e.key===`ArrowDown`)r(n+1);else if(e.key===`ArrowUp`)r(n-1);else if(e.key===`Home`)r(0);else if(e.key===`End`)r(t.length-1);else if(e.key===`Escape`)this.close();else if(e.key===`Tab`)return this.close(!1);else return;e.preventDefault()}};p.observedAttributes=[`label`];const m=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" data-k-mirror=""><path d="${e?`m8 5 5 5-5 5`:`m12 5-5 5 5 5`}"/></svg>`,h=e=>`<svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e?`<path d="M7.5 5v10M12.5 5v10"/>`:`<path d="M7 4.8v10.4a.6.6 0 0 0 .9.5l8-5.2a.6.6 0 0 0 0-1L7.9 4.3a.6.6 0 0 0-.9.5Z"/>`}</svg>`,g=e=>getComputedStyle(e).direction===`rtl`;function _(e,t){let n=null;e.addEventListener(`pointerdown`,e=>{e.pointerType!==`mouse`&&(n={x:e.clientX,y:e.clientY})}),e.addEventListener(`pointercancel`,()=>n=null),e.addEventListener(`pointerup`,r=>{let i=n;if(n=null,!i)return;let a=r.clientX-i.x,o=r.clientY-i.y;Math.abs(a)<40||Math.abs(a)<Math.abs(o)*1.2||t(a<0===g(e)?-1:1)})}var v=class extends c{constructor(){super(...arguments),this.track=null,this.section=null,this.index=0,this.io=null,this.key=l(`kashi-carousel`),this.left=0,this.startedAt=0,this.playing=!1,this.holds=/* @__PURE__ */ new Set,this.box=null,this.boxIndex=0,this.onVisibility=()=>this.hold(`hidden`,document.hidden)}connectedCallback(){s(()=>this.isConnected&&!this.track&&this.build())}disconnectedCallback(){this.io?.disconnect(),clearTimeout(this.timer),document.removeEventListener(`visibilitychange`,this.onVisibility)}get fade(){return this.getAttribute(`effect`)===`fade`}get perView(){return this.fade?1:Math.max(1,Number(this.getAttribute(`per-view`))||1)}get interval(){if(!this.hasAttribute(`autoplay`))return 0;let e=Number(this.getAttribute(`autoplay`));return e>0?e:5e3}get slides(){return[...this.track?.children??[]]}get pages(){return Math.max(1,this.slides.length-this.perView+1)}build(){let e=o(),t=this.getAttribute(`label`)??e.carousel.slider,n=[...this.children],a=this.hasAttribute(`lightbox`),s=document.createElement(`section`);s.className=`k-carousel${this.fade?` k-carousel--fade`:``}`,s.setAttribute(`aria-roledescription`,e.carousel.slider),s.setAttribute(`aria-label`,t),a&&s.setAttribute(`data-lightbox`,``),s.style.setProperty(`--k-carousel-per-view`,String(this.perView));let c=document.createElement(`div`);c.className=`k-carousel__track`,c.tabIndex=0,c.setAttribute(`aria-live`,`polite`);let l=[];n.forEach((t,r)=>{let a=document.createElement(`div`);a.className=`k-carousel__slide`,a.setAttribute(`role`,`group`),a.setAttribute(`aria-roledescription`,e.carousel.slide),a.setAttribute(`aria-label`,e.carousel.slideOf(i(this,r+1),i(this,n.length))),a.id=`${this.key}-s${r}`;let o=t.getAttribute(`data-thumb`)??(t.tagName===`IMG`?t.getAttribute(`src`):null);o&&(l[r]=o),a.append(t),c.append(a)}),s.append(c),this.replaceChildren(s),this.track=c,this.section=s;let u=this.interval;if(u&&this.pages>1&&s.insertAdjacentHTML(`beforeend`,`<span class="k-carousel__progress" aria-hidden="true"><span class="k-carousel__progress-bar" style="--_d: ${u}ms"></span></span>`),n.some(e=>e.hasAttribute(`data-thumb`))&&s.insertAdjacentHTML(`beforeend`,`<div class="k-carousel__thumbs" role="group" aria-label="${r(e.carousel.thumbnails(t))}">${n.map((t,a)=>`<button type="button" class="k-carousel__thumb" data-go="${a}" aria-label="${r(e.carousel.slideOf(i(this,a+1),i(this,n.length)))}" aria-controls="${this.key}-s${a}">${l[a]?`<img src="${r(l[a])}" alt="" loading="lazy">`:``}</button>`).join(``)}</div>`),this.pages>1||a){let n=this.getAttribute(`dots`)!==`false`&&this.pages>1,o=`${u&&this.pages>1?`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-act="play"></button>`:``}${a?`<button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm" data-act="expand" aria-haspopup="dialog" aria-label="${r(e.carousel.expand)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M12 3.5h4.5V8M8 16.5H3.5V12M16.5 3.5 11.5 8.5M3.5 16.5l5-5"/></svg></button>`:``}${this.pages>1?`<button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="-1" aria-label="${r(e.common.prev)}">${m(!1)}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon k-btn--sm" data-step="1" aria-label="${r(e.common.next)}">${m(!0)}</button>`:``}`;s.insertAdjacentHTML(`beforeend`,`<div class="k-carousel__bar">${n?`<ul class="k-carousel__dots" aria-label="${r(e.carousel.slides(t))}">${Array.from({length:this.pages},(t,n)=>`<li><button type="button" class="k-carousel__dot" data-go="${n}" aria-label="${r(e.carousel.slideOf(i(this,n+1),i(this,this.pages)))}" aria-controls="${this.key}-s${n}"></button></li>`).join(``)}</ul>`:`<span></span>`}<div class="k-carousel__nav">${o}</div></div>`)}s.addEventListener(`click`,e=>{let t=e.target.closest(`button`);if(t&&!this.box?.contains(t))return t.dataset.act===`play`?this.setPlaying(!this.playing):t.dataset.act===`expand`?this.openBox(this.index):t.dataset.go===void 0?t.dataset.step?this.go(this.index+Number(t.dataset.step)):void 0:this.go(Number(t.dataset.go));let n=e.target.closest(`.k-carousel__slide`);a&&n&&c.contains(n)&&!e.target.closest(`a, input, select, textarea, [tabindex]:not(.k-carousel__track)`)&&this.openBox(this.slides.indexOf(n))}),c.addEventListener(`keydown`,e=>{let t=g(c),n={ArrowLeft:t?1:-1,ArrowRight:t?-1:1}[e.key];n?(e.preventDefault(),this.go(this.index+n)):e.key===`Home`?this.go(0):e.key===`End`?this.go(this.pages-1):a&&e.key===`Enter`&&e.target===c&&this.openBox(this.index)}),this.fade?_(c,e=>this.go(this.index+e)):typeof IntersectionObserver<`u`&&(this.io=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting&&e.intersectionRatio>.6).map(e=>this.slides.indexOf(e.target));t.length&&this.setIndex(Math.min(...t))},{root:c,threshold:[.6,1]}),this.slides.forEach(e=>this.io.observe(e))),s.addEventListener(`mouseenter`,()=>this.hold(`hover`,!0)),s.addEventListener(`mouseleave`,()=>this.hold(`hover`,!1)),s.addEventListener(`focusin`,()=>this.hold(`focus`,!0)),s.addEventListener(`focusout`,e=>!s.contains(e.relatedTarget)&&this.hold(`focus`,!1)),document.addEventListener(`visibilitychange`,this.onVisibility),this.index=-1,this.setIndex(0),this.left=u,this.setPlaying(u>0&&!matchMedia?.(`(prefers-reduced-motion: reduce)`).matches)}hold(e,t){t?this.holds.add(e):this.holds.delete(e),this.schedule()}setPlaying(e){this.playing=e;let t=this.querySelector(`[data-act="play"]`);t&&(t.innerHTML=h(e),t.setAttribute(`aria-label`,e?o().carousel.pause:o().carousel.play),t.setAttribute(`aria-pressed`,String(!e))),this.schedule()}schedule(){let e=this.interval>0&&this.pages>1&&this.playing&&this.holds.size===0;this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0,this.left=Math.max(0,this.left-(Date.now()-this.startedAt))),this.track?.setAttribute(`aria-live`,e?`off`:`polite`),this.querySelector(`.k-carousel__progress-bar`)?.toggleAttribute(`data-paused`,!e),e&&(this.startedAt=Date.now(),this.timer=setTimeout(()=>{this.timer=void 0,this.go((this.index+1)%this.pages)},this.left))}go(e){let t=Math.max(0,Math.min(this.pages-1,e)),n=this.slides[t],r=this.track;if(n&&r){if(!this.fade){let e=g(r)?-(r.getBoundingClientRect().right-n.getBoundingClientRect().right)+r.scrollLeft:n.getBoundingClientRect().left-r.getBoundingClientRect().left+r.scrollLeft;r.scrollTo?.({left:e})}this.setIndex(t)}}setIndex(e){let n=e!==this.index;this.index=e,this.querySelectorAll(`.k-carousel__dot`).forEach((t,n)=>t.setAttribute(`aria-current`,String(n===e)));let r=this.querySelectorAll(`.k-carousel__thumb`);r.forEach((t,n)=>t.setAttribute(`aria-current`,String(n===e)));let i=this.querySelector(`.k-carousel__thumbs`),a=r[e];if(i&&a){let e=i.getBoundingClientRect(),t=a.getBoundingClientRect();(t.left<e.left||t.right>e.right)&&i.scrollTo?.({left:i.scrollLeft+(t.left+t.width/2)-(e.left+e.width/2)})}this.fade&&this.slides.forEach((t,n)=>{t.toggleAttribute(`data-active`,n===e),t.toggleAttribute(`inert`,n!==e),n===e?t.removeAttribute(`aria-hidden`):t.setAttribute(`aria-hidden`,`true`)});let[o,s]=this.querySelectorAll(`.k-carousel__bar [data-step]`);if(o&&(o.disabled=e===0),s&&(s.disabled=e>=this.pages-1),!n)return;let c=this.querySelector(`.k-carousel__progress-bar`);c&&c.replaceWith(c.cloneNode(!0)),this.timer!==void 0&&clearTimeout(this.timer),this.timer=void 0,this.left=this.interval,this.section&&this.schedule(),t(this,`kashi-change`,{index:e})}openBox(e){let t=o();if(!this.box){let e=document.createElement(`dialog`);e.className=`k-carousel__lightbox`,e.setAttribute(`aria-label`,t.carousel.lightbox(this.getAttribute(`label`)??t.carousel.slider)),e.innerHTML=`<div class="k-carousel__lightbox-head"><span class="k-carousel__lightbox-count" aria-live="polite"></span><button type="button" class="k-btn k-btn--tertiary k-btn--icon" data-box="close" aria-label="${r(t.common.close)}"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" aria-hidden="true"><path d="m5.5 5.5 9 9m0-9-9 9"/></svg></button></div><div class="k-carousel__lightbox-stage">${this.slides.map(e=>`<div class="k-carousel__lightbox-slide">${e.innerHTML}</div>`).join(``)}</div>${this.slides.length>1?`<div class="k-carousel__lightbox-nav"><button type="button" class="k-btn k-btn--secondary k-btn--icon" data-box="-1" aria-label="${r(t.common.prev)}">${m(!1)}</button><button type="button" class="k-btn k-btn--secondary k-btn--icon" data-box="1" aria-label="${r(t.common.next)}">${m(!0)}</button></div>`:``}`,e.querySelectorAll(`[id]`).forEach(e=>e.removeAttribute(`id`)),e.addEventListener(`click`,t=>{let n=t.target.closest(`[data-box]`);n?.dataset.box===`close`||t.target===e?e.close():n&&this.boxGo(this.boxIndex+Number(n.dataset.box))}),e.addEventListener(`keydown`,t=>{let n=g(e),r={ArrowLeft:n?1:-1,ArrowRight:n?-1:1}[t.key];r&&(t.preventDefault(),this.boxGo(this.boxIndex+r))}),e.addEventListener(`close`,()=>{this.hold(`box`,!1),this.go(Math.min(this.boxIndex,this.pages-1))}),_(e.querySelector(`.k-carousel__lightbox-stage`),e=>this.boxGo(this.boxIndex+e)),this.section.append(e),this.box=e}this.hold(`box`,!0),this.boxGo(e),this.box.showModal?.(),this.box.querySelector(`[data-box="close"]`)?.focus()}boxGo(e){let t=this.slides.length;this.boxIndex=(e+t)%t,this.box.querySelectorAll(`.k-carousel__lightbox-slide`).forEach((e,t)=>{e.toggleAttribute(`data-active`,t===this.boxIndex),e.toggleAttribute(`inert`,t!==this.boxIndex),t===this.boxIndex?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,`true`)}),this.box.querySelector(`.k-carousel__lightbox-count`).textContent=o().carousel.slideOf(i(this,this.boxIndex+1),i(this,t))}};v.observedAttributes=[`label`,`per-view`,`dots`,`effect`,`autoplay`,`lightbox`];var y=class extends c{constructor(){super(...arguments),this.nodes=null,this.open=/* @__PURE__ */ new Set,this.sel=null,this.focusId=null,this.built=!1}connectedCallback(){s(()=>{if(this.isConnected){if(this.nodes===null){let e=this.querySelector(`:scope > ul`);this.nodes=e?this.parse(e):[]}if(!this.built){this.sel=this.getAttribute(`selected`);for(let e of(this.getAttribute(`expanded`)??``).split(/[,،]/).map(e=>e.trim()).filter(Boolean))this.open.add(e);this.built=!0}this.render()}})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`selected`&&(this.sel=n),this.render())}get items(){return this.nodes??[]}set items(e){this.nodes=e,this.built&&this.render()}get value(){return this.sel??``}parse(e){return[...e.children].filter(e=>e.tagName===`LI`).map((e,t)=>{let n=e.querySelector(`:scope > ul`),r=[...e.childNodes].filter(e=>e!==n).map(e=>e.textContent).join(``).trim(),i=e;return{id:i.dataset.id??`${r}-${t}`,label:r,meta:i.dataset.meta,disabled:i.hasAttribute(`data-disabled`),children:n?this.parse(n):void 0}})}visible(){let e=[],t=(n,r)=>{for(let i of n)e.push({node:i,parent:r}),i.children?.length&&this.open.has(i.id)&&t(i.children,i.id)};return t(this.items,null),e}render(e=!1){let t=this.visible(),n=this.focusId&&t.some(e=>e.node.id===this.focusId)?this.focusId:this.sel&&t.some(e=>e.node.id===this.sel)?this.sel:t[0]?.node.id,i=(e,t)=>e.map(e=>{let a=!!e.children?.length,o=this.open.has(e.id);return`<li role="treeitem" data-id="${r(e.id)}" class="k-tree__item" aria-level="${t}"${a?` aria-expanded="${o}"`:``} aria-selected="${this.sel===e.id}"${e.disabled?` aria-disabled="true"`:``} tabindex="${n===e.id?0:-1}"><div class="k-tree__row">${a?`<span class="k-tree__toggle" aria-hidden="true"><svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m8 5 5 5-5 5"/></svg></span>`:`<span class="k-tree__spacer"></span>`}<span class="k-tree__label">${r(e.label)}</span>${e.meta?`<span class="k-tree__meta">${r(e.meta)}</span>`:``}</div>${a&&o?`<ul role="group">${i(e.children,t+1)}</ul>`:``}</li>`}).join(``);this.innerHTML=`<ul role="tree" class="k-tree"${this.getAttribute(`label`)?` aria-label="${r(this.getAttribute(`label`))}"`:``}>${i(this.items,1)}</ul>`;let a=this.querySelector(`ul`);a.addEventListener(`click`,e=>{let t=e.target.closest(`[role="treeitem"]`);if(!t||!e.target.closest(`.k-tree__row`))return;let n=this.find(t.dataset.id);n&&(n.children?.length&&this.toggle(n.id),this.focusId=n.id,this.choose(n))}),a.addEventListener(`keydown`,e=>this.onKey(e)),e&&n&&[...this.querySelectorAll(`[data-id]`)].find(e=>e.dataset.id===n)?.focus()}find(e,t=this.items){for(let n of t){if(n.id===e)return n;let t=n.children&&this.find(e,n.children);if(t)return t}return null}toggle(e,n=!this.open.has(e)){n?this.open.add(e):this.open.delete(e),t(this,`kashi-expand`,{expanded:[...this.open]})}choose(e){e.disabled||(this.sel=e.id,t(this,`kashi-change`,{value:e.id,node:e})),this.render(!0)}onKey(e){let t=this.visible(),n=document.activeElement?.dataset?.id,r=t.findIndex(e=>e.node.id===n),i=t[r];if(!i)return;let a=getComputedStyle(this).direction===`rtl`,o=!!i.node.children?.length,s=this.open.has(i.node.id),c=e=>{this.focusId=e,this.render(!0)};if(e.key===`ArrowDown`)t[r+1]&&c(t[r+1].node.id);else if(e.key===`ArrowUp`)t[r-1]&&c(t[r-1].node.id);else if(e.key===`Home`)c(t[0].node.id);else if(e.key===`End`)c(t[t.length-1].node.id);else if(e.key===(a?`ArrowLeft`:`ArrowRight`))o&&!s?(this.toggle(i.node.id,!0),c(i.node.id)):o&&c(i.node.children[0].id);else if(e.key===(a?`ArrowRight`:`ArrowLeft`))o&&s?(this.toggle(i.node.id,!1),c(i.node.id)):i.parent&&c(i.parent);else if(e.key===`Enter`||e.key===` `)this.focusId=i.node.id,this.choose(i.node);else return;e.preventDefault()}};y.observedAttributes=[`label`,`selected`,`expanded`];var b=class extends c{constructor(){super(...arguments),this.list=null,this.i=0,this.spot=null,this.card=null,this.returnTo=null,this.key=l(`kashi-tour`),this.place=()=>{let e=this.card;if(!e)return;let t=document.querySelector(this.steps[this.i].target)?.getBoundingClientRect()??null;t?(this.spot||(this.spot=document.createElement(`div`),this.spot.className=`k-tour__spot`,this.spot.setAttribute(`aria-hidden`,`true`),document.body.append(this.spot)),Object.assign(this.spot.style,{top:`${t.top-6}px`,left:`${t.left-6}px`,inlineSize:`${t.width+12}px`,blockSize:`${t.height+12}px`})):(this.spot?.remove(),this.spot=null);let n=e.getBoundingClientRect();if(!t){Object.assign(e.style,{top:`${innerHeight/2-n.height/2}px`,left:`${innerWidth/2-n.width/2}px`});return}let r=t.bottom+12+n.height<innerHeight?t.bottom+12:Math.max(12,t.top-12-n.height),i=Math.min(innerWidth-n.width-12,Math.max(12,t.left+t.width/2-n.width/2));Object.assign(e.style,{top:`${r}px`,left:`${i}px`})}}connectedCallback(){s(()=>{this.isConnected&&this.list===null&&(this.list=[...this.querySelectorAll(`:scope > [data-target]`)].map(e=>({target:e.dataset.target,title:e.dataset.title??``,content:e.textContent?.trim()??``})),this.replaceChildren())})}disconnectedCallback(){this.stop(!1)}get steps(){return this.list??[]}set steps(e){this.list=[...e]}start(){this.steps.length&&(this.returnTo=document.activeElement,this.i=0,addEventListener(`scroll`,this.place,{passive:!0}),addEventListener(`resize`,this.place),this.show())}stop(e=!0){this.spot?.remove(),this.card?.remove(),this.spot=this.card=null,removeEventListener(`scroll`,this.place),removeEventListener(`resize`,this.place),e&&this.returnTo?.focus?.()}show(){let e=this.steps[this.i],n=this.steps.length,a=this.i===n-1;this.card||(this.card=document.createElement(`div`),this.card.className=`k-tour__card`,this.card.setAttribute(`role`,`dialog`),this.card.setAttribute(`aria-modal`,`false`),this.card.setAttribute(`aria-labelledby`,`${this.key}-t`),this.card.setAttribute(`aria-describedby`,`${this.key}-b`),this.card.tabIndex=-1,this.card.addEventListener(`click`,e=>{let n=e.target.closest(`[data-act]`);if(!n)return;let r=n.dataset.act;r===`skip`?this.stop():r===`prev`?this.step(-1):r===`next`?this.step(1):r===`done`&&(this.stop(),t(this,`kashi-finish`,{}))}),this.card.addEventListener(`keydown`,e=>{let t=getComputedStyle(this.card).direction===`rtl`;e.key===`Escape`?this.stop():e.key===(t?`ArrowLeft`:`ArrowRight`)&&this.i<this.steps.length-1?this.step(1):e.key===(t?`ArrowRight`:`ArrowLeft`)&&this.i>0&&this.step(-1)}),document.body.append(this.card)),this.card.innerHTML=`<span class="k-tour__step">${r(o().tour.step(i(this,this.i+1),i(this,n)))}</span><p class="k-tour__title" id="${this.key}-t">${r(e.title)}</p><p class="k-tour__body" id="${this.key}-b">${r(e.content)}</p><div class="k-tour__actions"><button type="button" class="k-btn k-btn--link k-tour__skip" data-act="skip">${r(o().tour.skip)}</button><span class="k-tour__progress" aria-hidden="true">${this.steps.map((e,t)=>`<span${t<=this.i?` data-on=""`:``}></span>`).join(``)}</span>${this.i>0?'<button type="button" class="k-btn k-btn--secondary k-btn--sm" data-act="prev">${esc(msg().common.prev)}</button>':``}<button type="button" class="k-btn k-btn--primary k-btn--sm" data-act="${a?`done`:`next`}">${r(a?o().tour.done:o().common.next)}</button></div>`;let s=document.querySelector(e.target),c=typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches;s?.scrollIntoView?.({block:`center`,behavior:c?`auto`:`smooth`}),this.place(),setTimeout(this.place,400),this.card.focus({preventScroll:!0})}step(e){this.i=Math.max(0,Math.min(this.steps.length-1,this.i+e)),this.show()}},x=class extends c{constructor(){super(...arguments),this.current=40,this.built=!1,this.dragging=!1}connectedCallback(){s(()=>{this.isConnected&&!this.built&&(this.current=this.num(`size`,40),this.build())})}attributeChangedCallback(e,t,n){this.built&&t!==n&&(e===`size`?this.set(Number(n)||40,!1):this.decorate())}get value(){return this.current}set value(e){this.set(e,!1)}num(e,t){let n=Number(this.getAttribute(e));return Number.isFinite(n)&&this.getAttribute(e)!==null?n:t}get vertical(){return this.getAttribute(`orientation`)===`vertical`}build(){let[e,t]=[...this.children],n=document.createElement(`div`),r=document.createElement(`div`);r.className=`k-splitter__pane`,e&&r.append(e);let i=document.createElement(`div`);i.className=`k-splitter__handle`,i.setAttribute(`role`,`separator`),i.tabIndex=0;let a=document.createElement(`div`);a.className=`k-splitter__pane`,t&&a.append(t),n.append(r,i,a),this.replaceChildren(n),this.built=!0,i.addEventListener(`pointerdown`,e=>{i.setPointerCapture?.(e.pointerId),this.dragging=!0,n.toggleAttribute(`data-dragging`,!0),i.toggleAttribute(`data-dragging`,!0)}),i.addEventListener(`pointermove`,e=>{if(!this.dragging)return;let t=n.getBoundingClientRect();if(this.vertical)return this.set((e.clientY-t.top)/t.height*100);let r=getComputedStyle(n).direction===`rtl`;this.set((r?t.right-e.clientX:e.clientX-t.left)/t.width*100)});let o=()=>{this.dragging=!1,n.removeAttribute(`data-dragging`),i.removeAttribute(`data-dragging`)};i.addEventListener(`pointerup`,o),i.addEventListener(`pointercancel`,o),i.addEventListener(`dblclick`,()=>this.set(this.num(`size`,40))),i.addEventListener(`keydown`,e=>{let t=getComputedStyle(i).direction===`rtl`,n=this.vertical?{ArrowUp:-5,ArrowDown:5}:{ArrowLeft:t?5:-5,ArrowRight:t?-5:5};if(e.key in n)this.set(this.current+n[e.key]);else if(e.key===`Home`)this.set(this.num(`min`,15));else if(e.key===`End`)this.set(this.num(`max`,85));else return;e.preventDefault()}),this.decorate()}decorate(){let e=this.firstElementChild;e.className=`k-splitter${this.vertical?` k-splitter--vertical`:``}`;let t=this.getAttribute(`height`);e.style.blockSize=t??``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-orientation`,this.vertical?`horizontal`:`vertical`),n.setAttribute(`aria-valuemin`,String(this.num(`min`,15))),n.setAttribute(`aria-valuemax`,String(this.num(`max`,85))),n.setAttribute(`aria-label`,this.getAttribute(`label`)??o().splitter.label),this.paint()}set(e,n=!0){let r=Math.round(Math.min(this.num(`max`,85),Math.max(this.num(`min`,15),e))*10)/10,i=r!==this.current;this.current=r,this.built&&this.paint(),n&&i&&t(this,`kashi-change`,{value:r})}paint(){let e=this.firstElementChild,t=e.querySelector(`.k-splitter__pane`);t.style.inlineSize=this.vertical?``:`${this.current}%`,t.style.blockSize=this.vertical?`${this.current}%`:``;let n=e.querySelector(`.k-splitter__handle`);n.setAttribute(`aria-valuenow`,String(this.current)),n.setAttribute(`aria-valuetext`,o().common.percent(i(this,Math.round(this.current))))}};x.observedAttributes=[`size`,`min`,`max`,`orientation`,`label`,`height`];var S=class extends c{constructor(){super(...arguments),this.built=!1}connectedCallback(){s(()=>{this.isConnected&&!this.built&&(this.built=!0,this.addEventListener(`click`,e=>{let n=e.target.closest(`button[aria-controls][aria-expanded]`);if(!n||!this.contains(n))return;let r=document.getElementById(n.getAttribute(`aria-controls`)),i=n.getAttribute(`aria-expanded`)!==`true`;n.setAttribute(`aria-expanded`,String(i)),r&&(r.hidden=!i),t(this,`kashi-toggle`,{id:r?.id??``,open:i})}),this.decorate())})}attributeChangedCallback(){this.built&&this.decorate()}decorate(){let e=this.querySelector(`.k-sidenav`),t=n(this,`collapsed`);e?.classList.toggle(`k-sidenav--collapsed`,t),this.querySelectorAll(`.k-sidenav__item`).forEach(e=>{let n=e.querySelector(`.k-sidenav__text`)?.textContent?.trim();n&&(t?(e.setAttribute(`aria-label`,n),e.setAttribute(`title`,n)):(e.removeAttribute(`aria-label`),e.removeAttribute(`title`)))})}};S.observedAttributes=[`collapsed`],typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target,n=t?.closest?.(`[data-kashi-tour]`),r=n?document.getElementById(n.getAttribute(`data-kashi-tour`)):null;r?.start&&r.start();let i=t?.closest?.(`[data-kashi-command]`),a=i?document.getElementById(i.getAttribute(`data-kashi-command`)):null;a?.show&&a.show()}),a(`kashi-command-palette`,f,`contents`),a(`kashi-context-menu`,p,`block`),a(`kashi-carousel`,v,`block`),a(`kashi-tree-view`,y,`block`),a(`kashi-tour`,b,`contents`),a(`kashi-splitter`,x,`block`),a(`kashi-side-nav`,S,`block`);export{v as KashiCarousel,f as KashiCommandPalette,p as KashiContextMenu,S as KashiSideNav,x as KashiSplitter,b as KashiTour,y as KashiTreeView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as e,c as t,h as n,i as r,l as i,n as a,o,p as s,r as c,t as l,y as u}from"./base-D4tCOysh.js";var d=class extends l{constructor(){super(...arguments),this.dialog=null,this.opener=null,this.key=u(`kashi-dialog`)}connectedCallback(){c(()=>{this.isConnected&&(this.dialog||this.build(),this.sync())})}attributeChangedCallback(e,t,n){this.dialog&&t!==n&&(e===`open`?this.sync():this.decorate())}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,!!e)}show(){this.open=!0}close(e){this.dialog?.open?this.dialog.close(e):this.open=!1}build(){let e=[...this.children].filter(e=>e.getAttribute(`slot`)===`footer`),n=[...this.childNodes].filter(t=>!e.includes(t)),i=document.createElement(`dialog`);if(i.setAttribute(`aria-labelledby`,`${this.key}-title`),i.innerHTML=`<div class="k-dialog__header"><div class="k-dialog__heading"><h2 class="k-dialog__title" id="${this.key}-title"></h2><p class="k-dialog__description" id="${this.key}-desc"></p></div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-dialog__close">${a.close}</button></div>`,n.some(e=>e.nodeType===1||e.textContent?.trim())){let e=document.createElement(`div`);e.className=`k-dialog__body`,e.append(...n),i.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-dialog__footer`;for(let n of e)n.removeAttribute(`slot`),t.append(n);i.append(t)}this.replaceChildren(i),this.dialog=i,i.querySelector(`.k-dialog__close`).addEventListener(`click`,()=>this.close()),i.addEventListener(`click`,e=>{e.target===i&&r(this,`dismissible`,!0)&&this.close();let t=e.target.closest(`[data-kashi-close]`);t&&i.contains(t)&&this.close(t.getAttribute(`data-kashi-close`)||void 0)}),i.addEventListener(`close`,()=>{this.removeAttribute(`open`),this.opener?.focus?.(),t(this,`kashi-close`,{returnValue:i.returnValue})}),this.decorate()}decorate(){let e=this.dialog,t=this.getAttribute(`size`)??`md`,n=this.getAttribute(`placement`)??`center`;e.className=[`k-dialog`,t!==`md`&&`k-dialog--${t}`,n!==`center`&&`k-dialog--${n}`,this.getAttribute(`tone`)===`danger`&&`k-dialog--danger`].filter(Boolean).join(` `),e.dataset.placement=n,e.querySelector(`.k-dialog__title`).textContent=this.getAttribute(`heading`)??``;let r=e.querySelector(`.k-dialog__description`),i=this.getAttribute(`description`);r.textContent=i??``,r.hidden=!i,i?e.setAttribute(`aria-describedby`,r.id):e.removeAttribute(`aria-describedby`),e.querySelector(`.k-dialog__close`).setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().common.close)}sync(){let e=this.dialog;e&&this.isConnected&&(this.open&&!e.open?(this.opener=document.activeElement,e.showModal?.(),t(this,`kashi-open`,{})):!this.open&&e.open&&e.close())}};d.observedAttributes=[`open`,`heading`,`description`,`tone`,`size`,`placement`,`close-label`];var f=class extends l{constructor(){super(...arguments),this.list=null,this.key=u(`kashi-tabs`),this.ro=null}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){this.list||this.build(),this.decorate(),this.select(this.getAttribute(`value`)??this.panels[0]?.dataset.value??``,!1),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.list))}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`value`?this.select(n??``,!1):this.decorate())}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,e)}get panels(){return[...this.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-tab`))}build(){let e=document.createElement(`div`);e.setAttribute(`role`,`tablist`),e.className=`k-tabs__list`,this.panels.forEach((t,n)=>{let r=t.dataset.value||String(n+1);t.dataset.value=r;let i=document.createElement(`button`);i.type=`button`,i.setAttribute(`role`,`tab`),i.className=`k-tabs__tab`,i.id=`${this.key}-tab-${n}`,i.dataset.value=r,i.textContent=t.dataset.tab??``,t.hasAttribute(`data-disabled`)&&(i.disabled=!0),t.id||=`${this.key}-panel-${n}`,i.setAttribute(`aria-controls`,t.id),t.setAttribute(`role`,`tabpanel`),t.setAttribute(`aria-labelledby`,i.id),t.tabIndex=0,t.classList.add(`k-tabs__panel`),e.append(i)});let t=document.createElement(`span`);t.className=`k-tabs__indicator`,t.setAttribute(`aria-hidden`,`true`),e.append(t),e.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"]`);t&&!t.disabled&&this.select(t.dataset.value,!0)}),e.addEventListener(`keydown`,e=>this.onKey(e)),this.prepend(e),this.list=e}decorate(){let e=this.getAttribute(`variant`)??`line`,t=this.getAttribute(`orientation`)===`vertical`;for(let e of[...this.classList])e.startsWith(`k-tabs`)&&this.classList.remove(e);this.classList.add(`k-tabs`,`k-tabs--${e}`),r(this,`block`)&&this.classList.add(`k-tabs--block`),t&&this.classList.add(`k-tabs--vertical`),this.getAttribute(`size`)===`sm`&&this.classList.add(`k-tabs--sm`),this.dataset.orientation=t?`vertical`:`horizontal`,this.list.setAttribute(`aria-orientation`,t?`vertical`:`horizontal`);let n=this.getAttribute(`label`);n&&this.list.setAttribute(`aria-label`,n),this.measure()}select(e,n){let r=[...this.list.querySelectorAll(`[role="tab"]`)];r.some(t=>t.dataset.value===e)||(e=r[0]?.dataset.value??``);for(let t of r){let n=t.dataset.value===e;t.setAttribute(`aria-selected`,String(n)),t.tabIndex=n?0:-1}for(let t of this.panels)t.hidden=t.dataset.value!==e;this.getAttribute(`value`)!==e&&this.setAttribute(`value`,e),this.measure(),n&&t(this,`kashi-change`,{value:e})}measure(){let e=this.list,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);!e||!t||!t.offsetWidth?e?.removeAttribute(`data-indicator`):(e.setAttribute(`data-indicator`,``),e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iy`,`${t.offsetTop}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.style.setProperty(`--_ih`,`${t.offsetHeight}px`))}onKey(e){let t=[...this.list.querySelectorAll(`[role="tab"]:not(:disabled)`)],n=t.indexOf(document.activeElement);if(n<0)return;let r=getComputedStyle(this.list).direction===`rtl`,i=this.getAttribute(`orientation`)===`vertical`?{ArrowDown:n+1,ArrowUp:n-1,Home:0,End:t.length-1}:{ArrowLeft:r?n+1:n-1,ArrowRight:r?n-1:n+1,Home:0,End:t.length-1};if(!(e.key in i))return;e.preventDefault();let a=t[(i[e.key]+t.length)%t.length];a.focus(),this.select(a.dataset.value,!0)}};f.observedAttributes=[`value`,`variant`,`block`,`orientation`,`size`,`label`];var p=class extends l{constructor(){super(...arguments),this.tip=null,this.key=u(`kashi-tip`),this.trigger=null,this.place=()=>n(this,this.tip,this.getAttribute(`placement`)||`top`),this.onKey=e=>{e.key===`Escape`&&(clearTimeout(this.timer),this.close())}}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){if(!this.tip){this.classList.add(`k-tooltip-anchor`);let e=document.createElement(`span`);e.setAttribute(`role`,`tooltip`),e.id=this.key,e.hidden=!0,e.setAttribute(`popover`,`manual`),this.append(e),this.tip=e;let t=this.firstElementChild===e?null:this.firstElementChild;this.addEventListener(`mouseenter`,()=>this.show(Number(this.getAttribute(`delay`)??300))),this.trigger=t,this.addEventListener(`mouseleave`,()=>this.hide()),this.addEventListener(`focusin`,()=>this.show(0)),this.addEventListener(`focusout`,()=>this.hide())}this.decorate(),this.hasAttribute(`open`)&&this.open()}disconnectedCallback(){clearTimeout(this.timer),this.close()}attributeChangedCallback(e){this.tip&&(this.decorate(),(e===`open`||e===`disabled`)&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)?this.open():this.close()),this.tip.hidden||this.place())}open(){let e=this.tip;e.hidden&&!this.hasAttribute(`disabled`)&&(e.hidden=!1,t(this,`kashi-toggle`,{open:!0}),this.place(),document.addEventListener(`keydown`,this.onKey),addEventListener(`scroll`,this.place,{capture:!0,passive:!0}),addEventListener(`resize`,this.place))}close(){this.tip&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)&&this.isConnected||(this.tip.hidden||t(this,`kashi-toggle`,{open:!1}),this.tip.hidden=!0,e(this.tip),document.removeEventListener(`keydown`,this.onKey),removeEventListener(`scroll`,this.place,{capture:!0}),removeEventListener(`resize`,this.place)))}decorate(){let e=this.tip,t=this.getAttribute(`placement`),n=this.getAttribute(`heading`),r=this.getAttribute(`shortcut`);e.className=`k-tooltip${t&&t!==`top`?` k-tooltip--${t}`:``}${n?` k-tooltip--rich`:``}`;let a=i(this.getAttribute(`content`)??``);e.innerHTML=(n?`<span class="k-tooltip__title">${i(n)}</span><span class="k-tooltip__body">${a}</span>`:a)+(r?`<kbd class="k-tooltip__kbd" dir="ltr">${i(r)}</kbd>`:``);let o=this.trigger;if(o){let e=(o.getAttribute(`aria-describedby`)??``).split(` `).filter(e=>e&&e!==this.key);this.hasAttribute(`disabled`)||e.push(this.key),e.length?o.setAttribute(`aria-describedby`,e.join(` `)):o.removeAttribute(`aria-describedby`)}}show(e){clearTimeout(this.timer),this.timer=setTimeout(()=>this.open(),e)}hide(){clearTimeout(this.timer),this.timer=setTimeout(()=>this.close(),Number(this.getAttribute(`close-delay`)??100))}};p.observedAttributes=[`content`,`placement`,`heading`,`shortcut`,`disabled`,`open`];var m=class extends l{constructor(){super(...arguments),this.state=`idle`,this.built=!1}connectedCallback(){this.built||(this.built=!0,this.addEventListener(`click`,e=>{e.target.closest(`button`)&&this.copy()})),this.render()}disconnectedCallback(){clearTimeout(this.timer)}attributeChangedCallback(){this.built&&this.render()}get text(){let e=this.getAttribute(`value`);if(e!==null)return e;let t=this.getAttribute(`target`),n=t?document.querySelector(t):null;return n?typeof n.value==`string`?n.value:(n.textContent??``).trim():``}async copy(){try{await navigator.clipboard.writeText(this.text),this.state=`copied`,t(this,`kashi-copy`,{value:this.text})}catch{this.state=`failed`}this.render(),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.state=`idle`,this.render()},Number(this.getAttribute(`timeout`))||2e3)}render(){let e=this.getAttribute(`label`)??s().copy.copy,t=this.getAttribute(`copied-label`)??s().copy.copied,n=this.state===`copied`?t:this.state===`failed`?s().copy.failed:e,o=r(this,`icon-only`),c=this.state===`copied`?a.check:a.copy,l=this.getAttribute(`variant`)??`secondary`,u=this.getAttribute(`size`)??`sm`,d=this.contains(document.activeElement);this.innerHTML=`<button type="button" class="k-btn k-btn--${i(l)}${u===`md`?``:` k-btn--${i(u)}`}${o?` k-btn--icon`:``}" data-variant="${i(l)}" data-size="${i(u)}"${o?` aria-label="${i(n)}"`:``}${this.state===`copied`?` data-copied=""`:``}>${c}${o?``:i(n)}</button><span class="k-sr-only" aria-live="polite">${this.state===`idle`?``:i(n)}</span>`,d&&this.querySelector(`button`).focus()}};m.observedAttributes=[`value`,`target`,`label`,`copied-label`,`icon-only`,`variant`,`size`],o(`kashi-dialog`,d,`contents`),o(`kashi-tabs`,f,`block`),o(`kashi-tooltip`,p),o(`kashi-copy-button`,m),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-open]`);if(t){let n=document.getElementById(t.getAttribute(`data-kashi-open`));n?.show&&(e.preventDefault(),n.show())}});export{m as KashiCopyButton,d as KashiDialog,f as KashiTabs,p as KashiTooltip};
|
|
1
|
+
import{b as e,c as t,h as n,i as r,l as i,n as a,o,p as s,r as c,t as l,y as u}from"./base-BqFAMlwG.js";var d=class extends l{constructor(){super(...arguments),this.dialog=null,this.opener=null,this.key=u(`kashi-dialog`)}connectedCallback(){c(()=>{this.isConnected&&(this.dialog||this.build(),this.sync())})}attributeChangedCallback(e,t,n){this.dialog&&t!==n&&(e===`open`?this.sync():this.decorate())}get open(){return this.hasAttribute(`open`)}set open(e){this.toggleAttribute(`open`,!!e)}show(){this.open=!0}close(e){this.dialog?.open?this.dialog.close(e):this.open=!1}build(){let e=[...this.children].filter(e=>e.getAttribute(`slot`)===`footer`),n=[...this.childNodes].filter(t=>!e.includes(t)),i=document.createElement(`dialog`);if(i.setAttribute(`aria-labelledby`,`${this.key}-title`),i.innerHTML=`<div class="k-dialog__header"><div class="k-dialog__heading"><h2 class="k-dialog__title" id="${this.key}-title"></h2><p class="k-dialog__description" id="${this.key}-desc"></p></div><button type="button" class="k-btn k-btn--tertiary k-btn--icon k-btn--sm k-dialog__close">${a.close}</button></div>`,n.some(e=>e.nodeType===1||e.textContent?.trim())){let e=document.createElement(`div`);e.className=`k-dialog__body`,e.append(...n),i.append(e)}if(e.length){let t=document.createElement(`div`);t.className=`k-dialog__footer`;for(let n of e)n.removeAttribute(`slot`),t.append(n);i.append(t)}this.replaceChildren(i),this.dialog=i,i.querySelector(`.k-dialog__close`).addEventListener(`click`,()=>this.close()),i.addEventListener(`click`,e=>{e.target===i&&r(this,`dismissible`,!0)&&this.close();let t=e.target.closest(`[data-kashi-close]`);t&&i.contains(t)&&this.close(t.getAttribute(`data-kashi-close`)||void 0)}),i.addEventListener(`close`,()=>{this.removeAttribute(`open`),this.opener?.focus?.(),t(this,`kashi-close`,{returnValue:i.returnValue})}),this.decorate()}decorate(){let e=this.dialog,t=this.getAttribute(`size`)??`md`,n=this.getAttribute(`placement`)??`center`;e.className=[`k-dialog`,t!==`md`&&`k-dialog--${t}`,n!==`center`&&`k-dialog--${n}`,this.getAttribute(`tone`)===`danger`&&`k-dialog--danger`].filter(Boolean).join(` `),e.dataset.placement=n,e.querySelector(`.k-dialog__title`).textContent=this.getAttribute(`heading`)??``;let r=e.querySelector(`.k-dialog__description`),i=this.getAttribute(`description`);r.textContent=i??``,r.hidden=!i,i?e.setAttribute(`aria-describedby`,r.id):e.removeAttribute(`aria-describedby`),e.querySelector(`.k-dialog__close`).setAttribute(`aria-label`,this.getAttribute(`close-label`)??s().common.close)}sync(){let e=this.dialog;e&&this.isConnected&&(this.open&&!e.open?(this.opener=document.activeElement,e.showModal?.(),t(this,`kashi-open`,{})):!this.open&&e.open&&e.close())}};d.observedAttributes=[`open`,`heading`,`description`,`tone`,`size`,`placement`,`close-label`];var f=class extends l{constructor(){super(...arguments),this.list=null,this.key=u(`kashi-tabs`),this.ro=null}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){this.list||this.build(),this.decorate(),this.select(this.getAttribute(`value`)??this.panels[0]?.dataset.value??``,!1),typeof ResizeObserver<`u`&&!this.ro&&(this.ro=new ResizeObserver(()=>this.measure()),this.ro.observe(this.list))}disconnectedCallback(){this.ro?.disconnect(),this.ro=null}attributeChangedCallback(e,t,n){this.list&&t!==n&&(e===`value`?this.select(n??``,!1):this.decorate())}get value(){return this.getAttribute(`value`)??``}set value(e){this.setAttribute(`value`,e)}get panels(){return[...this.children].filter(e=>e instanceof HTMLElement&&e.hasAttribute(`data-tab`))}build(){let e=document.createElement(`div`);e.setAttribute(`role`,`tablist`),e.className=`k-tabs__list`,this.panels.forEach((t,n)=>{let r=t.dataset.value||String(n+1);t.dataset.value=r;let i=document.createElement(`button`);i.type=`button`,i.setAttribute(`role`,`tab`),i.className=`k-tabs__tab`,i.id=`${this.key}-tab-${n}`,i.dataset.value=r,i.textContent=t.dataset.tab??``,t.hasAttribute(`data-disabled`)&&(i.disabled=!0),t.id||=`${this.key}-panel-${n}`,i.setAttribute(`aria-controls`,t.id),t.setAttribute(`role`,`tabpanel`),t.setAttribute(`aria-labelledby`,i.id),t.tabIndex=0,t.classList.add(`k-tabs__panel`),e.append(i)});let t=document.createElement(`span`);t.className=`k-tabs__indicator`,t.setAttribute(`aria-hidden`,`true`),e.append(t),e.addEventListener(`click`,e=>{let t=e.target.closest(`[role="tab"]`);t&&!t.disabled&&this.select(t.dataset.value,!0)}),e.addEventListener(`keydown`,e=>this.onKey(e)),this.prepend(e),this.list=e}decorate(){let e=this.getAttribute(`variant`)??`line`,t=this.getAttribute(`orientation`)===`vertical`;for(let e of[...this.classList])e.startsWith(`k-tabs`)&&this.classList.remove(e);this.classList.add(`k-tabs`,`k-tabs--${e}`),r(this,`block`)&&this.classList.add(`k-tabs--block`),t&&this.classList.add(`k-tabs--vertical`),this.getAttribute(`size`)===`sm`&&this.classList.add(`k-tabs--sm`),this.dataset.orientation=t?`vertical`:`horizontal`,this.list.setAttribute(`aria-orientation`,t?`vertical`:`horizontal`);let n=this.getAttribute(`label`);n&&this.list.setAttribute(`aria-label`,n),this.measure()}select(e,n){let r=[...this.list.querySelectorAll(`[role="tab"]`)];r.some(t=>t.dataset.value===e)||(e=r[0]?.dataset.value??``);for(let t of r){let n=t.dataset.value===e;t.setAttribute(`aria-selected`,String(n)),t.tabIndex=n?0:-1}for(let t of this.panels)t.hidden=t.dataset.value!==e;this.getAttribute(`value`)!==e&&this.setAttribute(`value`,e),this.measure(),n&&t(this,`kashi-change`,{value:e})}measure(){let e=this.list,t=e?.querySelector(`[role="tab"][aria-selected="true"]`);!e||!t||!t.offsetWidth?e?.removeAttribute(`data-indicator`):(e.setAttribute(`data-indicator`,``),e.style.setProperty(`--_ix`,`${t.offsetLeft}px`),e.style.setProperty(`--_iy`,`${t.offsetTop}px`),e.style.setProperty(`--_iw`,`${t.offsetWidth}px`),e.style.setProperty(`--_ih`,`${t.offsetHeight}px`))}onKey(e){let t=[...this.list.querySelectorAll(`[role="tab"]:not(:disabled)`)],n=t.indexOf(document.activeElement);if(n<0)return;let r=getComputedStyle(this.list).direction===`rtl`,i=this.getAttribute(`orientation`)===`vertical`?{ArrowDown:n+1,ArrowUp:n-1,Home:0,End:t.length-1}:{ArrowLeft:r?n+1:n-1,ArrowRight:r?n-1:n+1,Home:0,End:t.length-1};if(!(e.key in i))return;e.preventDefault();let a=t[(i[e.key]+t.length)%t.length];a.focus(),this.select(a.dataset.value,!0)}};f.observedAttributes=[`value`,`variant`,`block`,`orientation`,`size`,`label`];var p=class extends l{constructor(){super(...arguments),this.tip=null,this.key=u(`kashi-tip`),this.trigger=null,this.place=()=>n(this,this.tip,this.getAttribute(`placement`)||`top`),this.onKey=e=>{e.key===`Escape`&&(clearTimeout(this.timer),this.close())}}connectedCallback(){c(()=>this.isConnected&&this.setup())}setup(){if(!this.tip){this.classList.add(`k-tooltip-anchor`);let e=document.createElement(`span`);e.setAttribute(`role`,`tooltip`),e.id=this.key,e.hidden=!0,e.setAttribute(`popover`,`manual`),this.append(e),this.tip=e;let t=this.firstElementChild===e?null:this.firstElementChild;this.addEventListener(`mouseenter`,()=>this.show(Number(this.getAttribute(`delay`)??300))),this.trigger=t,this.addEventListener(`mouseleave`,()=>this.hide()),this.addEventListener(`focusin`,()=>this.show(0)),this.addEventListener(`focusout`,()=>this.hide())}this.decorate(),this.hasAttribute(`open`)&&this.open()}disconnectedCallback(){clearTimeout(this.timer),this.close()}attributeChangedCallback(e){this.tip&&(this.decorate(),(e===`open`||e===`disabled`)&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)?this.open():this.close()),this.tip.hidden||this.place())}open(){let e=this.tip;e.hidden&&!this.hasAttribute(`disabled`)&&(e.hidden=!1,t(this,`kashi-toggle`,{open:!0}),this.place(),document.addEventListener(`keydown`,this.onKey),addEventListener(`scroll`,this.place,{capture:!0,passive:!0}),addEventListener(`resize`,this.place))}close(){this.tip&&(this.hasAttribute(`open`)&&!this.hasAttribute(`disabled`)&&this.isConnected||(this.tip.hidden||t(this,`kashi-toggle`,{open:!1}),this.tip.hidden=!0,e(this.tip),document.removeEventListener(`keydown`,this.onKey),removeEventListener(`scroll`,this.place,{capture:!0}),removeEventListener(`resize`,this.place)))}decorate(){let e=this.tip,t=this.getAttribute(`placement`),n=this.getAttribute(`heading`),r=this.getAttribute(`shortcut`);e.className=`k-tooltip${t&&t!==`top`?` k-tooltip--${t}`:``}${n?` k-tooltip--rich`:``}`;let a=i(this.getAttribute(`content`)??``);e.innerHTML=(n?`<span class="k-tooltip__title">${i(n)}</span><span class="k-tooltip__body">${a}</span>`:a)+(r?`<kbd class="k-tooltip__kbd" dir="ltr">${i(r)}</kbd>`:``);let o=this.trigger;if(o){let e=(o.getAttribute(`aria-describedby`)??``).split(` `).filter(e=>e&&e!==this.key);this.hasAttribute(`disabled`)||e.push(this.key),e.length?o.setAttribute(`aria-describedby`,e.join(` `)):o.removeAttribute(`aria-describedby`)}}show(e){clearTimeout(this.timer),this.timer=setTimeout(()=>this.open(),e)}hide(){clearTimeout(this.timer),this.timer=setTimeout(()=>this.close(),Number(this.getAttribute(`close-delay`)??100))}};p.observedAttributes=[`content`,`placement`,`heading`,`shortcut`,`disabled`,`open`];var m=class extends l{constructor(){super(...arguments),this.state=`idle`,this.built=!1}connectedCallback(){this.built||(this.built=!0,this.addEventListener(`click`,e=>{e.target.closest(`button`)&&this.copy()})),this.render()}disconnectedCallback(){clearTimeout(this.timer)}attributeChangedCallback(){this.built&&this.render()}get text(){let e=this.getAttribute(`value`);if(e!==null)return e;let t=this.getAttribute(`target`),n=t?document.querySelector(t):null;return n?typeof n.value==`string`?n.value:(n.textContent??``).trim():``}async copy(){try{await navigator.clipboard.writeText(this.text),this.state=`copied`,t(this,`kashi-copy`,{value:this.text})}catch{this.state=`failed`}this.render(),clearTimeout(this.timer),this.timer=setTimeout(()=>{this.state=`idle`,this.render()},Number(this.getAttribute(`timeout`))||2e3)}render(){let e=this.getAttribute(`label`)??s().copy.copy,t=this.getAttribute(`copied-label`)??s().copy.copied,n=this.state===`copied`?t:this.state===`failed`?s().copy.failed:e,o=r(this,`icon-only`),c=this.state===`copied`?a.check:a.copy,l=this.getAttribute(`variant`)??`secondary`,u=this.getAttribute(`size`)??`sm`,d=this.contains(document.activeElement);this.innerHTML=`<button type="button" class="k-btn k-btn--${i(l)}${u===`md`?``:` k-btn--${i(u)}`}${o?` k-btn--icon`:``}" data-variant="${i(l)}" data-size="${i(u)}"${o?` aria-label="${i(n)}"`:``}${this.state===`copied`?` data-copied=""`:``}>${c}${o?``:i(n)}</button><span class="k-sr-only" aria-live="polite">${this.state===`idle`?``:i(n)}</span>`,d&&this.querySelector(`button`).focus()}};m.observedAttributes=[`value`,`target`,`label`,`copied-label`,`icon-only`,`variant`,`size`],o(`kashi-dialog`,d,`contents`),o(`kashi-tabs`,f,`block`),o(`kashi-tooltip`,p),o(`kashi-copy-button`,m),typeof document<`u`&&document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`[data-kashi-open]`);if(t){let n=document.getElementById(t.getAttribute(`data-kashi-open`));n?.show&&(e.preventDefault(),n.show())}});export{m as KashiCopyButton,d as KashiDialog,f as KashiTabs,p as KashiTooltip};
|