@ihabdevteam/core 0.9.4 → 0.9.6

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/dist/hooks.cjs.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var l=require("react"),gt=require("react-i18next"),V=require("react/jsx-runtime"),Bo=require("react-dom"),Pn=typeof document<"u"?document.currentScript:null;function gr({storageKey:e="fontScale",baseFont:t=20,minScale:n=.8,maxScale:o=1.4,step:u=.1,lineHeightRatio:r=1.4}={}){const i=E=>Math.max(n,Math.min(o,Number(E))),[s,c]=l.useState(()=>{try{const E=localStorage.getItem(e),g=E?Number(E):1;return Number.isFinite(g)?g:1}catch{return 1}});l.useEffect(()=>{try{localStorage.setItem(e,String(s))}catch{}},[e,s]);const C=E=>{c(typeof E=="function"?g=>i(E(g)):i(E))},f=()=>C(E=>+(E+u).toFixed(6)),p=()=>C(E=>+(E-u).toFixed(6)),d=s<o-Number.EPSILON,m=s>n+Number.EPSILON,k=Math.round(t*s),w=Math.round(k*r);return{scale:s,setScale:C,increase:f,decrease:p,canIncrease:d,canDecrease:m,fontSize:k,lineHeight:w}}const Do=l.createContext(null);function _r(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}function Er(e){const t=l.useContext(Do),n=r=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(r).matches,[o,u]=l.useState(n(e));return l.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e),i=c=>u(c.matches),s=r;return s.addEventListener?s.addEventListener("change",i):s.addListener&&s.addListener(i),u(r.matches),()=>{s.removeEventListener?s.removeEventListener("change",i):s.removeListener&&s.removeListener(i)}},[e]),t&&typeof t.mobile=="boolean"&&_r(e)?t.mobile:o}function vo(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),t}function Oo(e,t){const n=vo(t);l.useEffect(()=>{const o=()=>n.current();try{window.addEventListener(e,o)}catch{}return()=>{try{window.removeEventListener(e,o)}catch{}}},[e,n])}const $n=" \xB7 ",Lo=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes($n)?e.split($n).pop()??e:e})(),Ro=l.createContext(!1);function br(e){const t=l.useContext(Ro);l.useEffect(()=>{if(t||typeof e!="string"||!e)return;const n=document.title;return document.title=Lo?`${e}${$n}${Lo}`:e,()=>{document.title=n}},[e,t])}function Sr(){const{t:e}=gt.useTranslation();return l.useCallback(t=>{if(!t)return"";const n=new Date(t).getTime();if(Number.isNaN(n))return"";const o=Math.floor((Date.now()-n)/864e5);return o<=0?e("myHomework.relativeDay.today","\uC624\uB298"):o===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n:o})},[e])}function kr(e){const[t,n]=l.useState({current:"",next:"",confirm:""}),[o,u]=l.useState(null),[r,i]=l.useState(!1),s=l.useRef(null);l.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);const c=l.useCallback(()=>{n({current:"",next:"",confirm:""}),u(null)},[]),C=l.useCallback(async()=>{if(!t.current){u({type:"error",text:"\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(!t.next){u({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(t.next!==t.confirm){u({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."});return}i(!0);const f=e?await e(t.current,t.next):null;if(i(!1),f){u({type:"error",text:f});return}u({type:"success",text:"\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}),n({current:"",next:"",confirm:""}),s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>u(null),1500)},[t,e]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:u,pwLoading:r,handleChangePw:C,reset:c}}const ke=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],rt=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],Fe=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function le(e){if(!e)return null;const t=e.charCodeAt(0)-44032;return t<0||t>=11172?null:{cho:Math.floor(t/588),jung:Math.floor(t%588/28),jong:t%28}}function Ar(){const e=new Map;return t=>{let n=e.get(t);return n||(n=[...t].map(o=>le(o)),e.set(t,n)),n}}function _t(e,t,n=0){return String.fromCharCode(44032+(e*21+t)*28+n)}function wr(e,t){if(!e||!t||e===t||e.length!==t.length)return"random";let n=0,o=null;for(let u=0;u<e.length;u++){const r=le(e[u]),i=le(t[u]);if(!r||!i)return"random";if(r.cho===i.cho&&r.jung===i.jung&&r.jong===i.jong)continue;n++;const s=r.cho!==i.cho,c=r.jung!==i.jung,C=r.jong!==i.jong;(s?1:0)+(c?1:0)+(C?1:0)>1?o="multi":s?o="cho":c?o="jung":o="jong"}return n!==1?"random":o==="cho"?"cho":o==="jung"?"jung":o==="jong"?"jong":"random"}const $t={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries($t).map(([e,t])=>[t.join(""),Fe[Number(e)]]));function Mr(e,t){if(!e||!t)return!1;for(const n of e){const o=le(n);if(o){if(ke[o.cho]===t)return!0;if(o.jong>0){if(Fe[o.jong]===t)return!0;const u=$t[o.jong];if(u&&u.includes(t))return!0}}}return!1}function pn(e){if(!e)return 0;let t=0;for(const n of e)le(n)&&t++;return t}function Nr(e){if(!e)return!1;let t=!1;for(const n of e){const o=le(n);if(o&&(t=!0,o.jong>0))return!1}return t}function Tr(e,t){if(e.jong<=0)return!1;if(t.includes(Fe[e.jong]))return!0;const n=$t[e.jong];return!!n&&n.some(o=>t.includes(o))}function xr(e,t,n){if(!e)return!1;const o=[...e],u=r=>{const i=le(o[r]);if(!i||t.cho&&!t.cho.includes(ke[i.cho])||t.jung&&!t.jung.includes(rt[i.jung]))return!1;if(t.jongNone){if(i.jong>0)return!1}else if(t.jong&&!Tr(i,t.jong))return!1;return!0};if(n==="head")return u(0);if(n==="tail")return u(o.length-1);if(n==="mid"){for(let r=1;r<o.length-1;r++)if(u(r))return!0;return!1}for(let r=0;r<o.length;r++)if(u(r))return!0;return!1}const Br={cho:ke.length,jung:rt.length,jong:Fe.length};function Dr(e,t,n,o,u=1/0){if(!e||n<1)return[];const r=[...e].map(p=>le(p));if(r.some(p=>!p))return[];const i=r,s=i.length;if(n>s)return[];const c=Br[t],C=new Set,f=[];(function p(d,m){if(m.length===n){f.push([...m]);return}for(let k=d;k<s;k++)m.push(k),p(k+1,m),m.pop()})(0,[]);for(const p of f)if((function d(m,k){if(C.size>=u)return;if(m===p.length){const g=k.map(S=>_t(S.cho,S.jung,S.jong)).join("");g!==e&&o.has(g)&&C.add(g);return}const w=p[m],E=i[w][t];for(let g=0;g<c;g++){if(g===E)continue;const S=k.slice();if(S[w]={...k[w],[t]:g},d(m+1,S),C.size>=u)return}})(0,i),C.size>=u)break;return[...C]}function vr(e,t){if(!e||!t||e.length!==t.length)return-1;let n=0;for(let o=0;o<e.length;o++){const u=le(e[o]),r=le(t[o]);if(!u||!r)return-1;u.cho!==r.cho&&n++,u.jung!==r.jung&&n++,u.jong!==r.jong&&n++}return n}const Io="word_pair_index_v2",jo="word_pair_index_sig_v2";let Ft=null;function Or(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem(Io),t=localStorage.getItem(jo);return!e||!t?null:{index:JSON.parse(e),sig:t}}catch{return null}}function Ht(){if(Ft)return Ft;const e=Or();return e?(Ft=e.index,e.sig,Ft):null}function Lr(){Ft=null;try{typeof localStorage<"u"&&(localStorage.removeItem(Io),localStorage.removeItem(jo))}catch{}}const Po="word_image_existence_map_v1";let Bt=null;function $o(){if(Bt)return Bt;try{const e=typeof localStorage<"u"?localStorage.getItem(Po):null;Bt=e?JSON.parse(e):{}}catch{Bt={}}return Bt}function Rr(e,t){return`${e}_${t??1}`}function Ir(e,t){const n=$o(),o=Rr(e,t);return o in n?n[o]:void 0}function Fo(){const e=$o(),t=Object.values(e);return t.length===0?null:{total:t.length,exists:t.filter(Boolean).length}}function jr(){Bt={};try{typeof localStorage<"u"&&localStorage.removeItem(Po)}catch{}}const Ho=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function zo(e){return e.reduce((t,n)=>{try{const o=localStorage.getItem(n);return t+(o?new Blob([o]).size:0)}catch{return t}},0)}function Pr(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function $r(e){const{t}=gt.useTranslation(),[n,o]=l.useState({}),[u,r]=l.useState(null),[i,s]=l.useState(null),[c,C]=l.useState(null),f=l.useCallback(()=>{const d={};Ho.forEach(m=>{d[m.id]=zo([...m.keys])}),o(d),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(m=>{C({usage:m.usage??0,quota:m.quota??0})}).catch(()=>{})},[]);l.useEffect(()=>{f()},[f]);const p=l.useCallback(async d=>{r(d);try{d==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):d==="pairIndex"?Lr():d==="imageCache"&&jr(),f(),e?.(t("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{r(null)}},[f,e,t]);return{cacheSizes:n,clearingId:u,confirmCacheId:i,setConfirmCacheId:s,storageEstimate:c,refreshCacheSizes:f,handleClearCache:p}}function Fr(e){const[t,n]=l.useState(null),[o,u]=l.useState(null),r=l.useCallback(()=>{const i=Ht();if(i){const c=Object.values(i),C=c.filter(f=>f.cho.length+f.jung.length+f.jong.length>0).length;n({matched:C,total:c.length})}else n(null);const s=Fo();u(s?{exists:s.exists,total:s.total}:null)},[]);return l.useEffect(()=>{r();const i=setTimeout(r,1e3);return()=>clearTimeout(i)},[e,r]),{pairStats:t,imgStats:o,setPairStats:n,setImgStats:u,refreshStats:r}}function Vo(e,t=[]){const[n,o]=l.useState(t),[u,r]=l.useState(null),[i,s]=l.useState(!1),[c,C]=l.useState(e),f=l.useRef(i);l.useEffect(()=>{f.current=i});const p=l.useRef(null);l.useEffect(()=>{if(f.current)return;const g=p.current;g!==null&&g.length===t.length&&g.every((S,A)=>S===t[A])||(p.current=t,o(t))},[t]);const d=l.useCallback(g=>{r(g),s(!1),C({...g})},[]),m=l.useCallback(()=>s(!0),[]),k=l.useCallback(()=>s(!1),[]),w=l.useCallback((g,S)=>{o(g),r(S),s(!1)},[]),E=l.useCallback(g=>{o(S=>S.filter(A=>A!==g)),r(null)},[]);return{list:n,setList:o,selected:u,setSelected:r,isEditing:i,setIsEditing:s,editForm:c,setEditForm:C,openDetail:d,startEditing:m,cancelEditing:k,commitEdit:w,remove:E}}const zt=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},Hr={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function zr(e=[]){const{list:t,setList:n,selected:o,setSelected:u,isEditing:r,setIsEditing:i,editForm:s,setEditForm:c,openDetail:C,commitEdit:f}=Vo(Hr,e),{year:p,month:d,day:m}=zt(),[k,w]=l.useState({year:p,month:d,day:m,hour:"09",minute:"00",memo:""});return{visitHistory:t,visitForm:k,setVisitForm:w,setVisit:E=>g=>w(S=>({...S,[E]:g})),selectedVisit:o,setSelectedVisit:u,isEditingVisit:r,setIsEditingVisit:i,editVisitForm:s,setEditVisitForm:c,openVisitDetail:C,handleVisitSave:E=>{n(B=>[k,...B]);const{year:g,month:S,day:A}=zt();w({year:g,month:S,day:A,hour:"09",minute:"00",memo:""}),E?.()},handleVisitEditSave:()=>{f(E=>E.map(g=>g===o?s:g),s)},addVisit:E=>{n(g=>[E,...g])},removeVisit:E=>{n(g=>g.filter(S=>S!==E))},revertVisitEdit:(E,g)=>{n(S=>S.map(A=>A===g?E:A)),u(S=>S===g?E:S)}}}const Uo=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,Cn=e=>[...e].sort((t,n)=>{const o=Uo(t),u=Uo(n);return o<u?-1:o>u?1:0}),Vr={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Ur(e,t=[]){const n=l.useMemo(()=>Cn(t),[t]),{list:o,setList:u,selected:r,setSelected:i,isEditing:s,setIsEditing:c,editForm:C,setEditForm:f,openDetail:p,commitEdit:d,remove:m}=Vo(Vr,n),[k,w]=l.useState([]),{year:E,month:g,day:S}=zt(),[A,B]=l.useState({year:E,month:g,day:S,hour:"09",minute:"00",memo:""}),L=F=>x=>B(v=>({...v,[F]:x})),D=F=>{u(Z=>Cn([...Z,A]));const{year:x,month:v,day:ye}=zt();B({year:x,month:v,day:ye,hour:"09",minute:"00",memo:""}),F?.()},I=()=>{d(F=>Cn(F.map(x=>x===r?C:x)),C)},$=l.useCallback(F=>{m(F)},[m]),G=l.useCallback(F=>{e({year:F.year,month:F.month,day:F.day,hour:F.hour,minute:F.minute,memo:F.memo}),m(F)},[e,m]),P=l.useCallback(F=>{u(x=>x.filter(v=>v!==F)),w(x=>[F,...x]),i(null)},[u,i]),Q=l.useCallback(F=>{u(x=>Cn([...x,F]))},[u]),Y=l.useCallback(F=>{u(x=>x.filter(v=>v!==F))},[u]),W=l.useCallback((F,x)=>{u(v=>v.map(ye=>ye===x?F:ye)),i(v=>v===x?F:v)},[u,i]);return{scheduleList:o,noShowList:k,addSchedule:Q,removeSchedule:Y,revertScheduleEdit:W,scheduleForm:A,setScheduleForm:B,setSchedule:L,selectedSchedule:r,setSelectedSchedule:i,isEditingSchedule:s,setIsEditingSchedule:c,editScheduleForm:C,setEditScheduleForm:f,openScheduleDetail:p,handleScheduleSave:D,handleScheduleEditSave:I,handleScheduleDelete:$,handleScheduleToVisit:G,handleScheduleNoVisit:P}}const Go=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function Gr(e){const[t,n]=l.useState(""),[o,u]=l.useState("25"),[r,i]=l.useState("all"),[s,c]=l.useState(1),C=l.useMemo(()=>e.filter(({item:m,status:k})=>!(t&&!m.memo.includes(t)||r!=="all"&&k!==r)),[e,t,r]),f=Math.max(1,Math.ceil(C.length/Number(o))),p=Math.min(s,f),d=l.useMemo(()=>C.slice((p-1)*Number(o),p*Number(o)),[C,p,o]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:u,vapStatus:r,setVapStatus:i,vapPage:p,setVapPage:c,vapFiltered:C,vapTotal:f,vapPageItems:d}}function Yr(e,t){const{t:n}=gt.useTranslation(),[o,u]=l.useState("25"),[r,i]=l.useState(1),[s,c]=l.useState(t);s!==t&&(c(t),r!==1&&i(1));const C=l.useMemo(()=>Go.map(m=>({...m,label:n("visits.showN",{n:m.value})})),[n]),f=l.useCallback(m=>{u(m),i(1)},[]),p=Math.max(1,Math.ceil(e.length/Number(o))),d=Math.min(r,p);return{pageRows:l.useMemo(()=>e.slice((d-1)*Number(o),d*Number(o)),[e,d,o]),pageSizeProps:{options:C,value:o,onChange:f},paginationProps:{page:d,total:p,onChange:i},setPage:i}}function qr(){const[e,t]=l.useState(null),n=l.useCallback(u=>{t(r=>r?.key===u?{key:u,asc:!r.asc}:{key:u,asc:!0})},[]),o=l.useCallback((u,r)=>({label:u,sortDir:e?.key===r?e.asc?"asc":"desc":null,onClick:()=>n(r)}),[e,n]);return{\uC815\uB82C:e,\uCE78:o}}function Wr(){const[e,t]=l.useState(!1),[n,o]=l.useState("\uC88C"),[u,r]=l.useState({\uC88C:null,\uC6B0:null}),[i,s]=l.useState({\uC88C:[],\uC6B0:[]}),[c,C]=l.useState(!1),[f,p]=l.useState("\uC88C"),d=l.useCallback(k=>{const w=k.direction;r(E=>({...E,[w]:k})),s(E=>({...E,[w]:[k,...E[w]]})),t(!1)},[]),m=l.useCallback(k=>{const w=k.direction;r(E=>({...E,[w]:k})),C(!1)},[]);return{showDevice:e,setShowDevice:t,deviceDirection:n,setDeviceDirection:o,devices:u,setDevices:r,deviceHistory:i,setDeviceHistory:s,showDeviceList:c,setShowDeviceList:C,listForSide:f,setListForSide:p,handleDeviceSubmit:d,handleSelectFromList:m}}const Kr="__ihab_core_word_pool__";function yn(){return globalThis[Kr]??null}function re(e,t=Math.random){const n=e.slice();for(let o=n.length-1;o>0;o--){const u=Math.floor(t()*(o+1));[n[o],n[u]]=[n[u],n[o]]}return n}function at(e,t,n=Math.random){return!Array.isArray(e)||e.length===0||t<=0?[]:t>=e.length?re(e,n):re(e,n).slice(0,t)}const Fn={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},Xr=ke.indexOf("\u3147"),Yo={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==Xr},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},Zr={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},Jr={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function qo(e){return Zr[e]??e}const Hn={cho:ke,jung:rt,jong:Fe},_e=e=>Array.isArray(e)?e.length>0:!!e;function zn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const o=e[n],u=t[n];if(!(!o||!u)&&(o.cho!==u.cho&&ke[o.cho]==="\u3147"!=(ke[u.cho]==="\u3147")||o.jong!==u.jong&&o.jong===0!=(u.jong===0)))return!0}return!1}function Qr(e,t,n){const o=n.pronOf(e),u=n.decompOf,r=n.sameStructureOnly&&u?u(o):null,i=[];for(const s of t)s!==e&&(n.okSet&&!n.okSet.has(s)||n.pronOf(s)!==o&&(r&&u&&zn(r,u(n.pronOf(s)))||i.push(s)));return i}function Wo(e,t,n){const o=t?.[e];if(!o)return[];const u=n.kind?o[n.kind]??[]:[...o.cho??[],...o.jung??[],...o.jong??[]];return Qr(e,u,n)}function ea(e,t,n,o,u,r,i){const s=["cho","jung","jong"].filter(d=>_e(e[d])),c={};for(const d of s){const m=e[d];c[d]=new Set(Array.isArray(m)?m:[m])}const C=u==="pron",f=new Map;for(const d of t){const m=n(r(d));if(m.some(g=>!g))continue;let k=m;if(!C&&(k=n(d),k.length!==m.length||k.some(g=>!g)))continue;const w=m.length,E=f.get(w);E?E.push({w:d,dPron:m,dPos:k}):f.set(w,[{w:d,dPron:m,dPos:k}])}const p=new Map;for(const[d,m]of f){const k=new Map,w=(E,g)=>{const S=E.dPos[g];return S!=null&&s.every(A=>c[A].has(Hn[A][S[A]]))};for(const E of m){let g;if(i==="head")g=w(E,0)?0:-1;else if(i==="tail")g=w(E,d-1)?d-1:-1;else if(i==="mid"){g=-1;for(let A=1;A<d-1;A++)if(w(E,A)){g=A;break}}else g=E.dPos.findIndex(A=>A!=null&&s.every(B=>c[B].has(Hn[B][A[B]])));if(g<0)continue;const S=k.get(g);S?S.push(E):k.set(g,[E])}for(const[E,g]of k){const S=new Set(s.map(L=>E+":"+L)),A=L=>{let D="";for(let I=0;I<d;I++){const $=L[I];for(const G of["cho","jung","jong"])D+=(S.has(I+":"+G)?"*":$[G])+"."}return D},B=new Map;for(const L of m){const D=A(L.dPron),I=B.get(D);I?I.push(L):B.set(D,[L])}for(const L of g){const D=B.get(A(L.dPron))??[],I=[];for(const $ of D){if($.w===L.w)continue;let G=!0;for(const P of s){const Q=L.dPron[E][P],Y=$.dPron[E][P];if(Y===Q){G=!1;break}if(C&&c[P].has(Hn[P][Y])){G=!1;break}}G&&(o&&zn(L.dPron,$.dPron)||I.push($.w))}p.set(L.w,I)}}}return p}const ta=e=>e==null?[]:Array.isArray(e)?e:[e];function na(e){if([...e].length!==1)return"";const t=le(e);if(!t)return"";const n=qo(Fe[t.jong]),o=n===""?0:Fe.indexOf(n);return _t(t.cho,t.jung,o<0?0:o)}function Ko(e,t){return t.get(e)||na(e)||e}function Vn(e){return e?_e(e.cho)?"cho":_e(e.jung)?"jung":_e(e.jong)?"jong":null:null}function Dt(e,t){const n=(o,u)=>!_e(o)||ta(o).includes(u);return n(t.cho,ke[e.cho])&&n(t.jung,rt[e.jung])&&n(t.jong,Fe[e.jong])}function Vt(e,t,n){const o=[...e];if(n!=="pron")return o.map(r=>le(r));const u=[...t.get(e)||e];return u.length!==o.length?o.map(r=>le(r)):u.map(r=>le(r))}function Ut(e,t,n,o,u){const r=t==="cho"?ke:t==="jung"?rt:Fe,i=e[t],s=[],c=new Set([Ko(n,u)]),C=re(r.map((f,p)=>p).filter(f=>f!==i&&(t!=="cho"||r[f]!=="\u3147")&&(t!=="jong"||f!==0)));for(const f of C){if(s.length>=o)break;const p=t==="cho"?_t(f,e.jung,e.jong):t==="jung"?_t(e.cho,f,e.jong):_t(e.cho,e.jung,f),d=Ko(p,u);c.has(d)||(c.add(d),s.push(p))}return s}function oa(e,t,n,o,u,r=null){const i=[...e];if(i.length!==2)return null;const s=i.map(p=>le(p));if(s.some(p=>!p))return null;const c=Vt(e,n,o);if(c.some(p=>!p))return null;const C=Vn(t);let f=C&&t?c.map((p,d)=>Dt(p,t)?d:-1).filter(p=>p>=0):[0,1];if(r!=null&&(f=f.filter(p=>p!==r)),!f.length)return null;for(const p of re(f)){const d=i[p];if(!u.has(d))continue;const m=Ut(s[p],C??"cho",d,40,n),k=[];for(const w of m)if(w!==d&&u.has(w)&&!k.includes(w)&&k.push(w),k.length>=2)break;if(!(k.length<2))return{question:e,distractors:[d,...k]}}return null}function ua(e,t,n,o,u,r=null){const i=[...e];if(i.length!==3)return null;const s=i.map(p=>le(p));if(s.some(p=>!p))return null;const c=Vt(e,n,o);if(c.some(p=>!p))return null;const C=Vn(t),f=C&&t?c.map((p,d)=>Dt(p,t)?d:-1).filter(p=>p>=0):[0,1,2];if(!f.length)return null;for(const p of re(f))for(const d of re([0,1,2].filter(m=>m!==p&&(r==null||m===r)))){const m=[0,1,2].filter(S=>S!==d),k=m.map(S=>i[S]).join("");if(!u.has(k))continue;const w=m.indexOf(p),E=Ut(s[p],C??"cho",i[p],40,n),g=[];for(const S of E){const A=m.map(L=>i[L]);A[w]=S;const B=A.join("");if(B!==k&&u.has(B)&&!g.includes(B)&&g.push(B),g.length>=2)break}if(!(g.length<2))return{question:e,distractors:[k,...g]}}return null}function ra(e,t,n,o,u,r=null){const i=[...e],s=i.length;if(s<2)return null;const c=[];for(let f=1;f<=s-1;f++)c.push({remain:i.slice(0,f).join(""),dropped:i.slice(f).join(""),droppedEnd:1}),c.push({remain:i.slice(s-f).join(""),dropped:i.slice(0,s-f).join(""),droppedEnd:0});const C=Vn(t);for(const{remain:f,dropped:p,droppedEnd:d}of re(c)){if(r!=null&&d!==r||f===e||!u.has(f)||!u.has(p))continue;const m=[...f],k=m.map(g=>le(g));if(k.some(g=>!g))continue;const w=Vt(f,n,o);if(w.some(g=>!g))continue;const E=C&&t?w.map((g,S)=>Dt(g,t)?S:-1).filter(g=>g>=0):m.map((g,S)=>S);if(E.length)for(const g of re(E)){const S=Ut(k[g],C??"cho",m[g],40,n),A=[];for(const B of S){const L=[...m];L[g]=B;const D=L.join("");if(D!==f&&u.has(D)&&!A.includes(D)&&A.push(D),A.length>=2)break}if(A.length>=2)return{question:e,distractors:[f,...A]}}}return null}function aa(e,t,n,o,u,r=null){if([...e].length!==1)return null;const i=le(n.get(e)||e);if(!i||i.jong===0)return null;const s=_t(i.cho,i.jung,0),c=Ut({cho:i.cho,jung:i.jung,jong:0},"cho",s,2,n);return c.length<2?null:{question:e,distractors:[s,...c]}}const Un=ke.indexOf("\u3147");function ia(e,t,n,o,u,r=null){if([...e].length!==1)return null;const i=le(n.get(e)||e);if(!i||i.jong!==0||i.cho===Un)return null;const s=_t(Un,i.jung,0),c=Ut({cho:Un,jung:i.jung,jong:0},"jung",s,2,n);return c.length<2?null:{question:e,distractors:[s,...c]}}function sa(e){const t=new Map;for(const n of e){const o=[...n],u=o.length;if(!(u<2||u>3))for(let r=0;r<u;r++){let i=u+"|"+r+"|";for(let c=0;c<u;c++)i+=c===r?"*":o[c];const s=t.get(i);s?s.push(n):t.set(i,[n])}}return t}function la(e,t,n,o,u,r=null,i=null,s=2){const c=[...e],C=c.length;if(C<2||C>3)return null;const f=c.map(S=>le(S));if(f.some(S=>!S))return null;const p=Vt(e,n,o);if(p.some(S=>!S))return null;const d=S=>n.get(S)??S,m=d(e),k=!!t&&(_e(t.cho)||_e(t.jung)||_e(t.jong)),w=!!i&&(_e(i.cho)||_e(i.jung)||_e(i.jong)),E=S=>{let A=C+"|"+S+"|";for(let B=0;B<C;B++)A+=B===S?"*":c[B];return A};let g;if(r!=null){if(r>=C||k&&!Dt(p[r],t))return null;g=[r]}else k?g=p.map((S,A)=>Dt(S,t)?A:-1).filter(S=>S>=0):g=Array.from({length:C},(S,A)=>A);for(const S of re(g)){const A=u.get(E(S))??[],B=[],L=[];for(const P of A){if(P===e)continue;const Q=[...P].map(x=>le(x)),Y=f[S],W=Q[S];if(!Y||!W)continue;let F=0;if(Y.cho!==W.cho&&F++,Y.jung!==W.jung&&F++,Y.jong!==W.jong&&F++,!(F<s||d(P)===m))if(w){const x=Vt(P,n,o)[S];x&&Dt(x,i)?B.push(P):L.push(P)}else B.push(P)}if(!B.length)continue;const D=re(B)[0],I=[],$=new Set([m,d(D)]),G=w?L:B.filter(P=>P!==D);for(const P of re(G)){const Q=d(P);if(!$.has(Q)&&($.add(Q),I.push(P),I.length>=2))break}if(!w&&I.length<2)for(const P of re(A)){if(P===e||P===D)continue;const Q=d(P);if(!$.has(Q)&&($.add(Q),I.push(P),I.length>=2))break}if(!(I.length<2))return{question:e,distractors:[D,...I]}}return null}let mn=null,Xo=null,Zo=null;function ca(){const e=yn();if(e&&e.entries.length>0){const t=Ht();if(mn&&Xo===e&&Zo===t)return mn;const n=new Set,o=[];for(const u of e.entries)!u.word||n.has(u.word)||(n.add(u.word),o.push({w:u.word,s:u.syllables,p:t?.[u.word]?[...t[u.word].cho??[],...t[u.word].jung??[],...t[u.word].jong??[]]:[],pron:u.pronunciation||u.word,grade:u.grade}));return mn=o,Xo=e,Zo=t,mn}return[]}const Ge=new Proxy([],{get(e,t){const n=ca(),o=n[t];return typeof o=="function"?o.bind(n):o}});function gn(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function Ye(e,t){if(t>=e.length)return re(e);if(t===0)return[];const n=e.slice();for(let o=0;o<t;o++){const u=o+Math.floor(Math.random()*(n.length-o)),r=n[o];n[o]=n[u],n[u]=r}return n.slice(0,t)}let Gn=null,Jo=null;function Et(){const e=yn();if(Gn&&Jo===e)return Gn;const t=new Map;for(const n of Ge)n.w&&t.set(n.w,n.pron);return Gn=t,Jo=e,t}function Oe(e){return Et().get(e)||e}function Yn(e,t,n=new Set){const o=[];for(const u of re(e)){if(o.length>=t)break;const r=Oe(u);n.has(r)||(n.add(r),o.push(u))}return o}let da=0;function Ae(e){return`${e}-rt-${++da}`}function Gt(e){const t=Fo();if(!t||t.total===0){const o=new Set;for(const u of e)o.add(u);return o}const n=new Set;for(const o of e)Ir(o)===!0&&n.add(o);return n}const _n=new Map;let Qo=null,eu=null;function Yt(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function tu(e){const t=Yt(e.choseong),n=e.composition,o=n?.syllable==null?"":Array.isArray(n.syllable)?n.syllable.slice().sort().join(","):String(n.syllable),u=n?`${Yt(n.cho)}/${Yt(n.jung)}/${Yt(n.jong)}/${n.jongNone?"N":""}/${o}`:"",r=Yt(e.grade);return`${e.difficulty??""}|${t}|${u}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${r}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function Le(e){const t=yn(),n=Ht();(t!==Qo||n!==eu)&&(_n.clear(),Qo=t,eu=n);const o=tu(e);return _n.has(o)||_n.set(o,fa(e)),_n.get(o)}function ha(e){if(!e)return null;const t=i=>i==null?null:Array.isArray(i)?i.length?i:null:[i],n=t(e.cho),o=t(e.jung),u=!!e.jongNone,r=u?null:t(e.jong);return n||o||r||u?u&&!n&&!o&&!r?i=>Nr(i):i=>xr(i,{cho:n,jung:o,jong:r,jongNone:u}):null}async function fa(e){const{difficulty:t=null,choseong:n=null,composition:o=null,targetSyllable:u=null,excludeNoImage:r=!1}=e,i=e.grade&&e.grade.length>0?new Set(e.grade):null,s=e.sameStructureOnly??!0,c=e.phonemeView==="pron"?"pron":"char",C=Math.max(1,e.contrastCount??1),f=t==="cho"||t==="jung"||t==="jong",p=f&&C>=2,d=t==="count",m=n?new Set(Array.isArray(n)?n:[n]):null,k=o?.syllable!=null?new Set(Array.isArray(o.syllable)?o.syllable:[o.syllable]):null,w=o?[ha(o),k?M=>k.has(pn(M)):null].filter(M=>M!=null):[],E=t==="random"||t===null,g=E||d,S=E||p||d;let A=Ge.filter(M=>!M.w||i&&(!M.grade||!i.has(M.grade))?!1:S?!0:Array.isArray(M.p)&&M.p.length>0);m&&(A=A.filter(M=>{for(const j of m)if(Mr(M.w,j))return!0;return!1})),w.length>0&&(A=A.filter(M=>{const j=c==="pron"?Oe(M.w):M.w;return w.every(ae=>ae(j))})),u&&(A=A.filter(M=>M.w[0]===u));let B;if(r){const M=new Set;for(const j of A)if(M.add(j.w),Array.isArray(j.p))for(const ae of j.p)M.add(ae);if(g)for(const j of Ge)j.w&&M.add(j.w);B=Gt(M)}else{const M=new Set;for(const j of A)if(M.add(j.w),Array.isArray(j.p))for(const ae of j.p)M.add(ae);if(g)for(const j of Ge)j.w&&M.add(j.w);B=M}let L=null;if(p){const M=new Set;for(const j of Ge)j.w&&M.add(j.w);L=r?Gt(M):M}const D=A.filter(M=>B.has(M.w)),I=600,$=Array.from(B),G=$.length>I?Ye($,I):$,P=d&&o!=null&&(_e(o.cho)||_e(o.jung)||_e(o.jong)),Q=2500,Y=new Map;if(d&&!P&&C>=2){for(const M of $){const j=pn(M),ae=Y.get(j);ae?ae.push(M):Y.set(j,[M])}for(const[M,j]of Y)j.length>Q&&Y.set(M,Ye(j,Q))}const W=Ar(),F=P?ea(o,$,W,s,c,Oe):null,x=500,v=1500,ye=e.fullCount?D:t==="random"?D.length>x?Ye(D,x):D:D.length>v?Ye(D,v):D,Z=Ht(),ee=[];for(const M of ye){let j;const ae=Oe(M.w);if(p)j=Dr(M.w,t,C,L,24).filter(ne=>Oe(ne)!==ae);else if(d)P?j=(F.get(M.w)??[]).filter(ne=>Oe(ne)!==ae):C<=1?j=Wo(M.w,Z,{okSet:B,pronOf:Oe,decompOf:W,sameStructureOnly:!1}):j=(Y.get(pn(M.w))??[]).filter(ne=>{if(ne===M.w||Oe(ne)===ae)return!1;const q=vr(M.w,ne);return C>=5?q>=5:q===C});else if(E)j=G.filter(ne=>ne!==M.w&&ne.length===M.w.length&&Oe(ne)!==ae);else{const ne=t;j=Wo(M.w,Z,{kind:ne,okSet:B,pronOf:Oe,decompOf:W,sameStructureOnly:!1}),j.length===0&&(j=(G.length>30?Ye(G,30):G).filter(q=>q!==M.w&&wr(M.w,q)===t&&Oe(q)!==ae))}if(s&&j.length>0&&(f||d&&!P)){const ne=W(Oe(M.w));j=j.filter(q=>!zn(ne,W(Oe(q))))}j.length!==0&&ee.push({word:M,usable:j})}return ee}async function nu(e,t){const{choicesPerItem:n=3,count:o=10}=t,u=n-1,r=(await Le(t)).filter(s=>s.usable.length>=u),i=[];for(const s of re(r)){if(i.length>=o)break;const c=Yn(s.usable,u);if(c.length<u)continue;const C=re([s.word.w,...c]);i.push({id:Ae(e+"-item"),index:i.length+1,word:s.word.w,syllables:s.word.s,choices:C,answerIndex:C.indexOf(s.word.w)})}return i}async function pa(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,u=await Le({...e,difficulty:null});if(u.length<t)return[];const r=[],i=re([...u]);for(const s of i){if(r.length>=n)break;const c=s.word.w,C=[...s.word.pron||c],f=gn(C);if(!f)continue;const p=u.filter(k=>k.word.w!==c&&k.word.s===s.word.s&&!(k.word.pron||k.word.w).includes(f)&&k.word.pron!==s.word.pron);if(p.length<o)continue;const d=Yn(p.map(k=>k.word.w),o);if(d.length<o)continue;const m=re([c,...d]);r.push({id:Ae("HPI-item"),index:r.length+1,targetSyllable:f,word:c,choices:m,answerIndex:m.indexOf(c)})}return r}async function Ca(e){const{count:t=10}=e,n=(await Le(e)).filter(o=>o.usable.length>=1);return Array.from({length:t},(o,u)=>{const r=gn(n);if(!r)return null;const i=u%2===0;let s;if(i)s=[r.word.w,r.word.w];else{const c=gn(r.usable);s=Math.random()<.5?[r.word.w,c]:[c,r.word.w]}return{id:Ae("SOD-item"),index:u+1,word:r.word.w,pair:s,same:i}}).filter(o=>!!o)}async function ya(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,u=await Le({...e,difficulty:null});if(u.length<t+1)return[];const r=u.map(d=>d.word.w),i=new Map(u.map(d=>[d.word.w,d.word.pron])),s=d=>(i.get(d)||d)[0]??"",c={};for(const d of u){const m=s(d.word.w);m&&(c[m]||(c[m]=[]),c[m].push(d.word.w))}const C=Object.entries(c).filter(([,d])=>d.length>=2).map(([d])=>d);if(C.length===0)return[];const f=[],p=re([...C]);for(let d=0;f.length<n&&d<n*4;d++){const m=p[d%p.length],k=c[m];if(k.length<2)continue;const w=re([...k]),E=w[0],g=w[1];if(!E||!g||E===g||(i.get(E)||E)===(i.get(g)||g))continue;const S=i.get(g)||g,A=r.filter(D=>s(D)!==m&&D!==E&&D!==g&&D.length===g.length&&(i.get(D)||D)!==S);if(A.length<o)continue;const B=Yn(A,o);if(B.length<o)continue;const L=re([g,...B]);f.push({id:Ae("SWS-item"),index:f.length+1,sourceWord:E,targetSyllable:m,word:g,choices:L,answerIndex:L.indexOf(g)})}return f}function ou(e,t,n){return Ye(e,t).map((o,u)=>{const r=gn(o.usable)??"",i=[...o.word.w],s=[...r],c=i.findIndex((f,p)=>f!==s[p]),C=re(o.usable.filter(f=>f&&f!==r)).slice(0,2);return{id:Ae(n),index:u+1,word:o.word.w,original:o.word.w,changed:r,changedFrom:c>=0?i[c]:"",changedTo:c>=0?s[c]:"",distractors:C}})}async function uu(e,t,n){const{count:o=10}=t,u=Et(),r=Ge.filter(m=>m.w&&m.s===e),i=t.excludeNoImage?Gt(r.map(m=>m.w)):null,s=i?r.filter(m=>i.has(m.w)):r,c=new Set(s.map(m=>m.w)),C=sa(c),f=t.phonemeView??"char",p=t.composition??null,d=[];for(const m of re(s)){if(d.length>=o)break;const k=la(m.w,p,u,f,C,null,null);if(!k)continue;const w=k.distractors[0],E=[...m.w],g=[...w],S=E.findIndex((A,B)=>A!==g[B]);d.push({id:Ae(n),index:d.length+1,word:m.w,original:m.w,changed:w,changedFrom:S>=0?E[S]:"",changedTo:S>=0?g[S]:"",distractors:k.distractors.slice(1)})}return d}async function ma(e){return uu(2,e,"CS2-item")}async function ga(e){return uu(3,e,"CS3-item")}async function _a(e){const t=(await Le({...e,difficulty:"count",contrastCount:1})).filter(n=>n.word.s===1&&n.usable.length>=1);return ou(t,e.count??10,"CP1-item")}async function Ea(e){const t=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",n=(await Le({...e,difficulty:t,contrastCount:1})).filter(o=>o.word.s===2&&o.usable.length>=1);return ou(n,e.count??10,"CP2-item")}async function ba(e){const{count:t=10}=e,n=(await Le({...e})).filter(o=>o.word.s===2);return Ye(n,t).map((o,u)=>({id:Ae("M2S-item"),index:u+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function Sa(e){const{count:t=10}=e,n=(await Le({...e})).filter(o=>o.word.s===3);return Ye(n,t).map((o,u)=>({id:Ae("M3S-item"),index:u+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function ka(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s===2),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=oa(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=[...s.word.w],d=p[0]===C?p[1]:p[0];i.push({id:Ae("D2-item"),index:i.length+1,original:s.word.w,word:s.word.w,dropped:d,missingResult:C,distractors:f})}return i}async function Aa(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s===3),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=ua(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=[...s.word.w];let d="";for(let m=0;m<p.length;m++)if(p.filter((k,w)=>w!==m).join("")===C){d=p[m];break}i.push({id:Ae("D3-item"),index:i.length+1,original:s.word.w,word:s.word.w,dropped:d,missingResult:C,distractors:f})}return i}async function wa(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s>=2),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=ra(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=s.word.w,d=p.startsWith(C)?p.slice(C.length):p.endsWith(C)?p.slice(0,p.length-C.length):"";i.push({id:Ae("DPC-item"),index:i.length+1,original:p,word:p,dropped:d,missingResult:C,distractors:f})}return i}async function Ma(e){const{count:t=10}=e,n=(await Le({...e})).map(o=>o.word.w);return n.length<3?[]:Array.from({length:t},(o,u)=>{const r=Ye(n,3);return{id:Ae("LRO-item"),index:u+1,sequence:r,choices:re(r)}})}function En(e,t,n){const o=Ge.filter(i=>i.w&&i.s===e),u=t?Gt(o.map(i=>i.w)):null,r=[];for(const i of o)if(!(u&&!u.has(i.w))){if(n){const s=le(i.w);if(!s||!n(s))continue}r.push(i)}return r}function Na(e){const t=En(1,e.excludeNoImage??!1,n=>n.jong===0);return Ye(t,e.count??10).map((n,o)=>{const u=le(n.w);return{id:Ae("M2P-item"),index:o+1,parts:[ke[u.cho],rt[u.jung]],answer:n.w,word:n.w}})}function Ta(e){const t=En(1,e.excludeNoImage??!1,n=>n.jong>0&&!$t[n.jong]);return Ye(t,e.count??10).map((n,o)=>{const u=le(n.w);return{id:Ae("M3P-item"),index:o+1,parts:[ke[u.cho],rt[u.jung],Fe[u.jong]],answer:n.w,word:n.w}})}function xa(e){const t=Yo.DROP_FINAL_CONSONANT_FROM_1SYLL,n=En(t.syllables,e.excludeNoImage??!1,t.syllable),o=Et(),u=[];for(const r of re(n)){if(u.length>=(e.count??10))break;const i=aa(r.w,null,o);if(!i)continue;const[s,...c]=i.distractors;u.push({id:Ae("DFC-item"),index:u.length+1,original:r.w,word:r.w,result:s,distractors:c})}return u}function Ba(e){const t=Yo.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,n=En(t.syllables,e.excludeNoImage??!1,t.syllable),o=Et(),u=[];for(const r of re(n)){if(u.length>=(e.count??10))break;const i=ia(r.w,null,o);if(!i)continue;const s=le(o.get(r.w)||r.w);if(!s)continue;const[c,...C]=i.distractors;u.push({id:Ae("RCP-item"),index:u.length+1,base:r.w,word:r.w,missingConsonant:ke[s.cho],remaining:c,distractors:C})}return u}const bn=new Map;let ru=null,au=null;async function iu(e,t={}){const n=yn(),o=Ht();(n!==ru||o!==au)&&(bn.clear(),ru=n,au=o);const u=`${e}:${tu(t)}`;if(bn.has(u))return bn.get(u);const r=await va(e,t);return bn.set(u,r),r}const Da={SAME_SOUND_PICK:e=>nu("SSP",e),HEAR_AND_PICK_SAME:e=>nu("HPS",e),HEAR_AND_PICK_INCLUDED:e=>pa(e),SAME_OR_DIFF:e=>Ca(e),STARTS_WITH_SAME_SOUND:e=>ya(e),LISTEN_AND_REMEMBER_ORDER:e=>Ma(e),MERGE_2_SYLLABLES:e=>ba(e),MERGE_3_SYLLABLES:e=>Sa(e),MERGE_2_PHONEMES:e=>Na(e),MERGE_3_PHONEMES:e=>Ta(e),DROP_1_FROM_2SYLL:e=>ka(e),DROP_1_FROM_3SYLL:e=>Aa(e),DROP_PART_FROM_COMPOUND:e=>wa(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>xa(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>Ba(e),CHANGE_1_SYLL_IN_2SYLL:e=>ma(e),CHANGE_1_SYLL_IN_3SYLL:e=>ga(e),CHANGE_1_PHONEME_IN_1SYLL:e=>_a(e),CHANGE_1_PHONEME_IN_2SYLL:e=>Ea(e)};async function va(e,t={}){const n=Da[e];return n?await n(t):[]}async function Oa(e){const t=[null,"count"],n=Object.keys(Fn);let o=0;for(const u of t)for(const r of n){const i=Fn[r];iu(r,{difficulty:i.difficulty?u:null,choseong:null,count:10,excludeNoImage:e}).catch(()=>{}),++o%6===0&&await new Promise(s=>setTimeout(s,0))}}async function La(e){return(await Le({...e,fullCount:!0})).length}async function Ra(e={}){const t=[];for(const s of Ge)s.w&&t.push(s.w);const n=e.excludeNoImage?Gt(t):t,o=new Set,u=new Set,r=new Set,i=new Set;for(const s of n){i.add(pn(s));for(const c of s){const C=le(c);if(C&&(ke[C.cho]!=="\u3147"&&o.add(ke[C.cho]),u.add(rt[C.jung]),C.jong>0)){r.add(Fe[C.jong]);const f=$t[C.jong];f&&f.forEach(p=>r.add(p))}}}return{cho:o,jung:u,jong:r,syllable:i}}const bt="\uC804\uCCB4";function Ia(...e){return e.filter(Boolean).join(" ")}/**
1
+ "use strict";var l=require("react"),gt=require("react-i18next"),V=require("react/jsx-runtime"),Bo=require("react-dom"),Pn=typeof document<"u"?document.currentScript:null;function gr({storageKey:e="fontScale",baseFont:t=20,minScale:n=.8,maxScale:o=1.4,step:u=.1,lineHeightRatio:r=1.4}={}){const i=E=>Math.max(n,Math.min(o,Number(E))),[s,c]=l.useState(()=>{try{const E=localStorage.getItem(e),g=E?Number(E):1;return Number.isFinite(g)?g:1}catch{return 1}});l.useEffect(()=>{try{localStorage.setItem(e,String(s))}catch{}},[e,s]);const C=E=>{c(typeof E=="function"?g=>i(E(g)):i(E))},f=()=>C(E=>+(E+u).toFixed(6)),p=()=>C(E=>+(E-u).toFixed(6)),d=s<o-Number.EPSILON,m=s>n+Number.EPSILON,k=Math.round(t*s),w=Math.round(k*r);return{scale:s,setScale:C,increase:f,decrease:p,canIncrease:d,canDecrease:m,fontSize:k,lineHeight:w}}const Do=l.createContext(null);function _r(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}function Er(e){const t=l.useContext(Do),n=r=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(r).matches,[o,u]=l.useState(n(e));return l.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const r=window.matchMedia(e),i=c=>u(c.matches),s=r;return s.addEventListener?s.addEventListener("change",i):s.addListener&&s.addListener(i),u(r.matches),()=>{s.removeEventListener?s.removeEventListener("change",i):s.removeListener&&s.removeListener(i)}},[e]),t&&typeof t.mobile=="boolean"&&_r(e)?t.mobile:o}function vo(e){const t=l.useRef(e);return l.useEffect(()=>{t.current=e}),t}function Oo(e,t){const n=vo(t);l.useEffect(()=>{const o=()=>n.current();try{window.addEventListener(e,o)}catch{}return()=>{try{window.removeEventListener(e,o)}catch{}}},[e,n])}const $n=" \xB7 ",Lo=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes($n)?e.split($n).pop()??e:e})(),Ro=l.createContext(!1);function br(e){const t=l.useContext(Ro);l.useEffect(()=>{if(t||typeof e!="string"||!e)return;const n=document.title;return document.title=Lo?`${e}${$n}${Lo}`:e,()=>{document.title=n}},[e,t])}function Sr(){const{t:e}=gt.useTranslation();return l.useCallback(t=>{if(!t)return"";const n=new Date(t).getTime();if(Number.isNaN(n))return"";const o=Math.floor((Date.now()-n)/864e5);return o<=0?e("myHomework.relativeDay.today","\uC624\uB298"):o===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n:o})},[e])}function kr(e){const[t,n]=l.useState({current:"",next:"",confirm:""}),[o,u]=l.useState(null),[r,i]=l.useState(!1),s=l.useRef(null);l.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]);const c=l.useCallback(()=>{n({current:"",next:"",confirm:""}),u(null)},[]),C=l.useCallback(async()=>{if(!t.current){u({type:"error",text:"\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(!t.next){u({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(t.next!==t.confirm){u({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."});return}i(!0);const f=e?await e(t.current,t.next):null;if(i(!1),f){u({type:"error",text:f});return}u({type:"success",text:"\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}),n({current:"",next:"",confirm:""}),s.current!==null&&clearTimeout(s.current),s.current=setTimeout(()=>u(null),1500)},[t,e]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:u,pwLoading:r,handleChangePw:C,reset:c}}const ke=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],rt=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],Fe=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function le(e){if(!e)return null;const t=e.charCodeAt(0)-44032;return t<0||t>=11172?null:{cho:Math.floor(t/588),jung:Math.floor(t%588/28),jong:t%28}}function Ar(){const e=new Map;return t=>{let n=e.get(t);return n||(n=[...t].map(o=>le(o)),e.set(t,n)),n}}function _t(e,t,n=0){return String.fromCharCode(44032+(e*21+t)*28+n)}function wr(e,t){if(!e||!t||e===t||e.length!==t.length)return"random";let n=0,o=null;for(let u=0;u<e.length;u++){const r=le(e[u]),i=le(t[u]);if(!r||!i)return"random";if(r.cho===i.cho&&r.jung===i.jung&&r.jong===i.jong)continue;n++;const s=r.cho!==i.cho,c=r.jung!==i.jung,C=r.jong!==i.jong;(s?1:0)+(c?1:0)+(C?1:0)>1?o="multi":s?o="cho":c?o="jung":o="jong"}return n!==1?"random":o==="cho"?"cho":o==="jung"?"jung":o==="jong"?"jong":"random"}const $t={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries($t).map(([e,t])=>[t.join(""),Fe[Number(e)]]));function Mr(e,t){if(!e||!t)return!1;for(const n of e){const o=le(n);if(o){if(ke[o.cho]===t)return!0;if(o.jong>0){if(Fe[o.jong]===t)return!0;const u=$t[o.jong];if(u&&u.includes(t))return!0}}}return!1}function pn(e){if(!e)return 0;let t=0;for(const n of e)le(n)&&t++;return t}function Nr(e){if(!e)return!1;let t=!1;for(const n of e){const o=le(n);if(o&&(t=!0,o.jong>0))return!1}return t}function Tr(e,t){if(e.jong<=0)return!1;if(t.includes(Fe[e.jong]))return!0;const n=$t[e.jong];return!!n&&n.some(o=>t.includes(o))}function xr(e,t,n){if(!e)return!1;const o=[...e],u=r=>{const i=le(o[r]);if(!i||t.cho&&!t.cho.includes(ke[i.cho])||t.jung&&!t.jung.includes(rt[i.jung]))return!1;if(t.jongNone){if(i.jong>0)return!1}else if(t.jong&&!Tr(i,t.jong))return!1;return!0};if(n==="head")return u(0);if(n==="tail")return u(o.length-1);if(n==="mid"){for(let r=1;r<o.length-1;r++)if(u(r))return!0;return!1}for(let r=0;r<o.length;r++)if(u(r))return!0;return!1}const Br={cho:ke.length,jung:rt.length,jong:Fe.length};function Dr(e,t,n,o,u=1/0){if(!e||n<1)return[];const r=[...e].map(p=>le(p));if(r.some(p=>!p))return[];const i=r,s=i.length;if(n>s)return[];const c=Br[t],C=new Set,f=[];(function p(d,m){if(m.length===n){f.push([...m]);return}for(let k=d;k<s;k++)m.push(k),p(k+1,m),m.pop()})(0,[]);for(const p of f)if((function d(m,k){if(C.size>=u)return;if(m===p.length){const g=k.map(S=>_t(S.cho,S.jung,S.jong)).join("");g!==e&&o.has(g)&&C.add(g);return}const w=p[m],E=i[w][t];for(let g=0;g<c;g++){if(g===E)continue;const S=k.slice();if(S[w]={...k[w],[t]:g},d(m+1,S),C.size>=u)return}})(0,i),C.size>=u)break;return[...C]}function vr(e,t){if(!e||!t||e.length!==t.length)return-1;let n=0;for(let o=0;o<e.length;o++){const u=le(e[o]),r=le(t[o]);if(!u||!r)return-1;u.cho!==r.cho&&n++,u.jung!==r.jung&&n++,u.jong!==r.jong&&n++}return n}const Io="word_pair_index_v2",jo="word_pair_index_sig_v2";let Ft=null;function Or(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem(Io),t=localStorage.getItem(jo);return!e||!t?null:{index:JSON.parse(e),sig:t}}catch{return null}}function Ht(){if(Ft)return Ft;const e=Or();return e?(Ft=e.index,e.sig,Ft):null}function Lr(){Ft=null;try{typeof localStorage<"u"&&(localStorage.removeItem(Io),localStorage.removeItem(jo))}catch{}}const Po="word_image_existence_map_v1";let Bt=null;function $o(){if(Bt)return Bt;try{const e=typeof localStorage<"u"?localStorage.getItem(Po):null;Bt=e?JSON.parse(e):{}}catch{Bt={}}return Bt}function Rr(e,t){return`${e}_${t??1}`}function Ir(e,t){const n=$o(),o=Rr(e,t);return o in n?n[o]:void 0}function Fo(){const e=$o(),t=Object.values(e);return t.length===0?null:{total:t.length,exists:t.filter(Boolean).length}}function jr(){Bt={};try{typeof localStorage<"u"&&localStorage.removeItem(Po)}catch{}}const Ho=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function zo(e){return e.reduce((t,n)=>{try{const o=localStorage.getItem(n);return t+(o?new Blob([o]).size:0)}catch{return t}},0)}function Pr(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function $r(e){const{t}=gt.useTranslation(),[n,o]=l.useState({}),[u,r]=l.useState(null),[i,s]=l.useState(null),[c,C]=l.useState(null),f=l.useCallback(()=>{const d={};Ho.forEach(m=>{d[m.id]=zo([...m.keys])}),o(d),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(m=>{C({usage:m.usage??0,quota:m.quota??0})}).catch(()=>{})},[]);l.useEffect(()=>{f()},[f]);const p=l.useCallback(async d=>{r(d);try{d==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):d==="pairIndex"?Lr():d==="imageCache"&&jr(),f(),e?.(t("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{r(null)}},[f,e,t]);return{cacheSizes:n,clearingId:u,confirmCacheId:i,setConfirmCacheId:s,storageEstimate:c,refreshCacheSizes:f,handleClearCache:p}}function Fr(e){const[t,n]=l.useState(null),[o,u]=l.useState(null),r=l.useCallback(()=>{const i=Ht();if(i){const c=Object.values(i),C=c.filter(f=>f.cho.length+f.jung.length+f.jong.length>0).length;n({matched:C,total:c.length})}else n(null);const s=Fo();u(s?{exists:s.exists,total:s.total}:null)},[]);return l.useEffect(()=>{r();const i=setTimeout(r,1e3);return()=>clearTimeout(i)},[e?.length,r]),{pairStats:t,imgStats:o,setPairStats:n,setImgStats:u,refreshStats:r}}function Vo(e,t=[]){const[n,o]=l.useState(t),[u,r]=l.useState(null),[i,s]=l.useState(!1),[c,C]=l.useState(e),f=l.useRef(i);l.useEffect(()=>{f.current=i});const p=l.useRef(null);l.useEffect(()=>{if(f.current)return;const g=p.current;g!==null&&g.length===t.length&&g.every((S,A)=>S===t[A])||(p.current=t,o(t))},[t]);const d=l.useCallback(g=>{r(g),s(!1),C({...g})},[]),m=l.useCallback(()=>s(!0),[]),k=l.useCallback(()=>s(!1),[]),w=l.useCallback((g,S)=>{o(g),r(S),s(!1)},[]),E=l.useCallback(g=>{o(S=>S.filter(A=>A!==g)),r(null)},[]);return{list:n,setList:o,selected:u,setSelected:r,isEditing:i,setIsEditing:s,editForm:c,setEditForm:C,openDetail:d,startEditing:m,cancelEditing:k,commitEdit:w,remove:E}}const zt=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},Hr={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function zr(e=[]){const{list:t,setList:n,selected:o,setSelected:u,isEditing:r,setIsEditing:i,editForm:s,setEditForm:c,openDetail:C,commitEdit:f}=Vo(Hr,e),{year:p,month:d,day:m}=zt(),[k,w]=l.useState({year:p,month:d,day:m,hour:"09",minute:"00",memo:""});return{visitHistory:t,visitForm:k,setVisitForm:w,setVisit:E=>g=>w(S=>({...S,[E]:g})),selectedVisit:o,setSelectedVisit:u,isEditingVisit:r,setIsEditingVisit:i,editVisitForm:s,setEditVisitForm:c,openVisitDetail:C,handleVisitSave:E=>{n(B=>[k,...B]);const{year:g,month:S,day:A}=zt();w({year:g,month:S,day:A,hour:"09",minute:"00",memo:""}),E?.()},handleVisitEditSave:()=>{f(E=>E.map(g=>g===o?s:g),s)},addVisit:E=>{n(g=>[E,...g])},removeVisit:E=>{n(g=>g.filter(S=>S!==E))},revertVisitEdit:(E,g)=>{n(S=>S.map(A=>A===g?E:A)),u(S=>S===g?E:S)}}}const Uo=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,Cn=e=>[...e].sort((t,n)=>{const o=Uo(t),u=Uo(n);return o<u?-1:o>u?1:0}),Vr={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Ur(e,t=[]){const n=l.useMemo(()=>Cn(t),[t]),{list:o,setList:u,selected:r,setSelected:i,isEditing:s,setIsEditing:c,editForm:C,setEditForm:f,openDetail:p,commitEdit:d,remove:m}=Vo(Vr,n),[k,w]=l.useState([]),{year:E,month:g,day:S}=zt(),[A,B]=l.useState({year:E,month:g,day:S,hour:"09",minute:"00",memo:""}),L=F=>x=>B(v=>({...v,[F]:x})),D=F=>{u(Z=>Cn([...Z,A]));const{year:x,month:v,day:ye}=zt();B({year:x,month:v,day:ye,hour:"09",minute:"00",memo:""}),F?.()},I=()=>{d(F=>Cn(F.map(x=>x===r?C:x)),C)},$=l.useCallback(F=>{m(F)},[m]),G=l.useCallback(F=>{e({year:F.year,month:F.month,day:F.day,hour:F.hour,minute:F.minute,memo:F.memo}),m(F)},[e,m]),P=l.useCallback(F=>{u(x=>x.filter(v=>v!==F)),w(x=>[F,...x]),i(null)},[u,i]),Q=l.useCallback(F=>{u(x=>Cn([...x,F]))},[u]),Y=l.useCallback(F=>{u(x=>x.filter(v=>v!==F))},[u]),W=l.useCallback((F,x)=>{u(v=>v.map(ye=>ye===x?F:ye)),i(v=>v===x?F:v)},[u,i]);return{scheduleList:o,noShowList:k,addSchedule:Q,removeSchedule:Y,revertScheduleEdit:W,scheduleForm:A,setScheduleForm:B,setSchedule:L,selectedSchedule:r,setSelectedSchedule:i,isEditingSchedule:s,setIsEditingSchedule:c,editScheduleForm:C,setEditScheduleForm:f,openScheduleDetail:p,handleScheduleSave:D,handleScheduleEditSave:I,handleScheduleDelete:$,handleScheduleToVisit:G,handleScheduleNoVisit:P}}const Go=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function Gr(e){const[t,n]=l.useState(""),[o,u]=l.useState("25"),[r,i]=l.useState("all"),[s,c]=l.useState(1),C=l.useMemo(()=>e.filter(({item:m,status:k})=>!(t&&!m.memo.includes(t)||r!=="all"&&k!==r)),[e,t,r]),f=Math.max(1,Math.ceil(C.length/Number(o))),p=Math.min(s,f),d=l.useMemo(()=>C.slice((p-1)*Number(o),p*Number(o)),[C,p,o]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:u,vapStatus:r,setVapStatus:i,vapPage:p,setVapPage:c,vapFiltered:C,vapTotal:f,vapPageItems:d}}function Yr(e,t){const{t:n}=gt.useTranslation(),[o,u]=l.useState("25"),[r,i]=l.useState(1),[s,c]=l.useState(t);s!==t&&(c(t),r!==1&&i(1));const C=l.useMemo(()=>Go.map(m=>({...m,label:n("visits.showN",{n:m.value})})),[n]),f=l.useCallback(m=>{u(m),i(1)},[]),p=Math.max(1,Math.ceil(e.length/Number(o))),d=Math.min(r,p);return{pageRows:l.useMemo(()=>e.slice((d-1)*Number(o),d*Number(o)),[e,d,o]),pageSizeProps:{options:C,value:o,onChange:f},paginationProps:{page:d,total:p,onChange:i},setPage:i}}function qr(){const[e,t]=l.useState(null),n=l.useCallback(u=>{t(r=>r?.key===u?{key:u,asc:!r.asc}:{key:u,asc:!0})},[]),o=l.useCallback((u,r)=>({label:u,sortDir:e?.key===r?e.asc?"asc":"desc":null,onClick:()=>n(r)}),[e,n]);return{\uC815\uB82C:e,\uCE78:o}}function Wr(){const[e,t]=l.useState(!1),[n,o]=l.useState("\uC88C"),[u,r]=l.useState({\uC88C:null,\uC6B0:null}),[i,s]=l.useState({\uC88C:[],\uC6B0:[]}),[c,C]=l.useState(!1),[f,p]=l.useState("\uC88C"),d=l.useCallback(k=>{const w=k.direction;r(E=>({...E,[w]:k})),s(E=>({...E,[w]:[k,...E[w]]})),t(!1)},[]),m=l.useCallback(k=>{const w=k.direction;r(E=>({...E,[w]:k})),C(!1)},[]);return{showDevice:e,setShowDevice:t,deviceDirection:n,setDeviceDirection:o,devices:u,setDevices:r,deviceHistory:i,setDeviceHistory:s,showDeviceList:c,setShowDeviceList:C,listForSide:f,setListForSide:p,handleDeviceSubmit:d,handleSelectFromList:m}}const Kr="__ihab_core_word_pool__";function yn(){return globalThis[Kr]??null}function re(e,t=Math.random){const n=e.slice();for(let o=n.length-1;o>0;o--){const u=Math.floor(t()*(o+1));[n[o],n[u]]=[n[u],n[o]]}return n}function at(e,t,n=Math.random){return!Array.isArray(e)||e.length===0||t<=0?[]:t>=e.length?re(e,n):re(e,n).slice(0,t)}const Fn={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},Xr=ke.indexOf("\u3147"),Yo={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==Xr},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},Zr={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},Jr={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function qo(e){return Zr[e]??e}const Hn={cho:ke,jung:rt,jong:Fe},_e=e=>Array.isArray(e)?e.length>0:!!e;function zn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const o=e[n],u=t[n];if(!(!o||!u)&&(o.cho!==u.cho&&ke[o.cho]==="\u3147"!=(ke[u.cho]==="\u3147")||o.jong!==u.jong&&o.jong===0!=(u.jong===0)))return!0}return!1}function Qr(e,t,n){const o=n.pronOf(e),u=n.decompOf,r=n.sameStructureOnly&&u?u(o):null,i=[];for(const s of t)s!==e&&(n.okSet&&!n.okSet.has(s)||n.pronOf(s)!==o&&(r&&u&&zn(r,u(n.pronOf(s)))||i.push(s)));return i}function Wo(e,t,n){const o=t?.[e];if(!o)return[];const u=n.kind?o[n.kind]??[]:[...o.cho??[],...o.jung??[],...o.jong??[]];return Qr(e,u,n)}function ea(e,t,n,o,u,r,i){const s=["cho","jung","jong"].filter(d=>_e(e[d])),c={};for(const d of s){const m=e[d];c[d]=new Set(Array.isArray(m)?m:[m])}const C=u==="pron",f=new Map;for(const d of t){const m=n(r(d));if(m.some(g=>!g))continue;let k=m;if(!C&&(k=n(d),k.length!==m.length||k.some(g=>!g)))continue;const w=m.length,E=f.get(w);E?E.push({w:d,dPron:m,dPos:k}):f.set(w,[{w:d,dPron:m,dPos:k}])}const p=new Map;for(const[d,m]of f){const k=new Map,w=(E,g)=>{const S=E.dPos[g];return S!=null&&s.every(A=>c[A].has(Hn[A][S[A]]))};for(const E of m){let g;if(i==="head")g=w(E,0)?0:-1;else if(i==="tail")g=w(E,d-1)?d-1:-1;else if(i==="mid"){g=-1;for(let A=1;A<d-1;A++)if(w(E,A)){g=A;break}}else g=E.dPos.findIndex(A=>A!=null&&s.every(B=>c[B].has(Hn[B][A[B]])));if(g<0)continue;const S=k.get(g);S?S.push(E):k.set(g,[E])}for(const[E,g]of k){const S=new Set(s.map(L=>E+":"+L)),A=L=>{let D="";for(let I=0;I<d;I++){const $=L[I];for(const G of["cho","jung","jong"])D+=(S.has(I+":"+G)?"*":$[G])+"."}return D},B=new Map;for(const L of m){const D=A(L.dPron),I=B.get(D);I?I.push(L):B.set(D,[L])}for(const L of g){const D=B.get(A(L.dPron))??[],I=[];for(const $ of D){if($.w===L.w)continue;let G=!0;for(const P of s){const Q=L.dPron[E][P],Y=$.dPron[E][P];if(Y===Q){G=!1;break}if(C&&c[P].has(Hn[P][Y])){G=!1;break}}G&&(o&&zn(L.dPron,$.dPron)||I.push($.w))}p.set(L.w,I)}}}return p}const ta=e=>e==null?[]:Array.isArray(e)?e:[e];function na(e){if([...e].length!==1)return"";const t=le(e);if(!t)return"";const n=qo(Fe[t.jong]),o=n===""?0:Fe.indexOf(n);return _t(t.cho,t.jung,o<0?0:o)}function Ko(e,t){return t.get(e)||na(e)||e}function Vn(e){return e?_e(e.cho)?"cho":_e(e.jung)?"jung":_e(e.jong)?"jong":null:null}function Dt(e,t){const n=(o,u)=>!_e(o)||ta(o).includes(u);return n(t.cho,ke[e.cho])&&n(t.jung,rt[e.jung])&&n(t.jong,Fe[e.jong])}function Vt(e,t,n){const o=[...e];if(n!=="pron")return o.map(r=>le(r));const u=[...t.get(e)||e];return u.length!==o.length?o.map(r=>le(r)):u.map(r=>le(r))}function Ut(e,t,n,o,u){const r=t==="cho"?ke:t==="jung"?rt:Fe,i=e[t],s=[],c=new Set([Ko(n,u)]),C=re(r.map((f,p)=>p).filter(f=>f!==i&&(t!=="cho"||r[f]!=="\u3147")&&(t!=="jong"||f!==0)));for(const f of C){if(s.length>=o)break;const p=t==="cho"?_t(f,e.jung,e.jong):t==="jung"?_t(e.cho,f,e.jong):_t(e.cho,e.jung,f),d=Ko(p,u);c.has(d)||(c.add(d),s.push(p))}return s}function oa(e,t,n,o,u,r=null){const i=[...e];if(i.length!==2)return null;const s=i.map(p=>le(p));if(s.some(p=>!p))return null;const c=Vt(e,n,o);if(c.some(p=>!p))return null;const C=Vn(t);let f=C&&t?c.map((p,d)=>Dt(p,t)?d:-1).filter(p=>p>=0):[0,1];if(r!=null&&(f=f.filter(p=>p!==r)),!f.length)return null;for(const p of re(f)){const d=i[p];if(!u.has(d))continue;const m=Ut(s[p],C??"cho",d,40,n),k=[];for(const w of m)if(w!==d&&u.has(w)&&!k.includes(w)&&k.push(w),k.length>=2)break;if(!(k.length<2))return{question:e,distractors:[d,...k]}}return null}function ua(e,t,n,o,u,r=null){const i=[...e];if(i.length!==3)return null;const s=i.map(p=>le(p));if(s.some(p=>!p))return null;const c=Vt(e,n,o);if(c.some(p=>!p))return null;const C=Vn(t),f=C&&t?c.map((p,d)=>Dt(p,t)?d:-1).filter(p=>p>=0):[0,1,2];if(!f.length)return null;for(const p of re(f))for(const d of re([0,1,2].filter(m=>m!==p&&(r==null||m===r)))){const m=[0,1,2].filter(S=>S!==d),k=m.map(S=>i[S]).join("");if(!u.has(k))continue;const w=m.indexOf(p),E=Ut(s[p],C??"cho",i[p],40,n),g=[];for(const S of E){const A=m.map(L=>i[L]);A[w]=S;const B=A.join("");if(B!==k&&u.has(B)&&!g.includes(B)&&g.push(B),g.length>=2)break}if(!(g.length<2))return{question:e,distractors:[k,...g]}}return null}function ra(e,t,n,o,u,r=null){const i=[...e],s=i.length;if(s<2)return null;const c=[];for(let f=1;f<=s-1;f++)c.push({remain:i.slice(0,f).join(""),dropped:i.slice(f).join(""),droppedEnd:1}),c.push({remain:i.slice(s-f).join(""),dropped:i.slice(0,s-f).join(""),droppedEnd:0});const C=Vn(t);for(const{remain:f,dropped:p,droppedEnd:d}of re(c)){if(r!=null&&d!==r||f===e||!u.has(f)||!u.has(p))continue;const m=[...f],k=m.map(g=>le(g));if(k.some(g=>!g))continue;const w=Vt(f,n,o);if(w.some(g=>!g))continue;const E=C&&t?w.map((g,S)=>Dt(g,t)?S:-1).filter(g=>g>=0):m.map((g,S)=>S);if(E.length)for(const g of re(E)){const S=Ut(k[g],C??"cho",m[g],40,n),A=[];for(const B of S){const L=[...m];L[g]=B;const D=L.join("");if(D!==f&&u.has(D)&&!A.includes(D)&&A.push(D),A.length>=2)break}if(A.length>=2)return{question:e,distractors:[f,...A]}}}return null}function aa(e,t,n,o,u,r=null){if([...e].length!==1)return null;const i=le(n.get(e)||e);if(!i||i.jong===0)return null;const s=_t(i.cho,i.jung,0),c=Ut({cho:i.cho,jung:i.jung,jong:0},"cho",s,2,n);return c.length<2?null:{question:e,distractors:[s,...c]}}const Un=ke.indexOf("\u3147");function ia(e,t,n,o,u,r=null){if([...e].length!==1)return null;const i=le(n.get(e)||e);if(!i||i.jong!==0||i.cho===Un)return null;const s=_t(Un,i.jung,0),c=Ut({cho:Un,jung:i.jung,jong:0},"jung",s,2,n);return c.length<2?null:{question:e,distractors:[s,...c]}}function sa(e){const t=new Map;for(const n of e){const o=[...n],u=o.length;if(!(u<2||u>3))for(let r=0;r<u;r++){let i=u+"|"+r+"|";for(let c=0;c<u;c++)i+=c===r?"*":o[c];const s=t.get(i);s?s.push(n):t.set(i,[n])}}return t}function la(e,t,n,o,u,r=null,i=null,s=2){const c=[...e],C=c.length;if(C<2||C>3)return null;const f=c.map(S=>le(S));if(f.some(S=>!S))return null;const p=Vt(e,n,o);if(p.some(S=>!S))return null;const d=S=>n.get(S)??S,m=d(e),k=!!t&&(_e(t.cho)||_e(t.jung)||_e(t.jong)),w=!!i&&(_e(i.cho)||_e(i.jung)||_e(i.jong)),E=S=>{let A=C+"|"+S+"|";for(let B=0;B<C;B++)A+=B===S?"*":c[B];return A};let g;if(r!=null){if(r>=C||k&&!Dt(p[r],t))return null;g=[r]}else k?g=p.map((S,A)=>Dt(S,t)?A:-1).filter(S=>S>=0):g=Array.from({length:C},(S,A)=>A);for(const S of re(g)){const A=u.get(E(S))??[],B=[],L=[];for(const P of A){if(P===e)continue;const Q=[...P].map(x=>le(x)),Y=f[S],W=Q[S];if(!Y||!W)continue;let F=0;if(Y.cho!==W.cho&&F++,Y.jung!==W.jung&&F++,Y.jong!==W.jong&&F++,!(F<s||d(P)===m))if(w){const x=Vt(P,n,o)[S];x&&Dt(x,i)?B.push(P):L.push(P)}else B.push(P)}if(!B.length)continue;const D=re(B)[0],I=[],$=new Set([m,d(D)]),G=w?L:B.filter(P=>P!==D);for(const P of re(G)){const Q=d(P);if(!$.has(Q)&&($.add(Q),I.push(P),I.length>=2))break}if(!w&&I.length<2)for(const P of re(A)){if(P===e||P===D)continue;const Q=d(P);if(!$.has(Q)&&($.add(Q),I.push(P),I.length>=2))break}if(!(I.length<2))return{question:e,distractors:[D,...I]}}return null}let mn=null,Xo=null,Zo=null;function ca(){const e=yn();if(e&&e.entries.length>0){const t=Ht();if(mn&&Xo===e&&Zo===t)return mn;const n=new Set,o=[];for(const u of e.entries)!u.word||n.has(u.word)||(n.add(u.word),o.push({w:u.word,s:u.syllables,p:t?.[u.word]?[...t[u.word].cho??[],...t[u.word].jung??[],...t[u.word].jong??[]]:[],pron:u.pronunciation||u.word,grade:u.grade}));return mn=o,Xo=e,Zo=t,mn}return[]}const Ge=new Proxy([],{get(e,t){const n=ca(),o=n[t];return typeof o=="function"?o.bind(n):o}});function gn(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function Ye(e,t){if(t>=e.length)return re(e);if(t===0)return[];const n=e.slice();for(let o=0;o<t;o++){const u=o+Math.floor(Math.random()*(n.length-o)),r=n[o];n[o]=n[u],n[u]=r}return n.slice(0,t)}let Gn=null,Jo=null;function Et(){const e=yn();if(Gn&&Jo===e)return Gn;const t=new Map;for(const n of Ge)n.w&&t.set(n.w,n.pron);return Gn=t,Jo=e,t}function Oe(e){return Et().get(e)||e}function Yn(e,t,n=new Set){const o=[];for(const u of re(e)){if(o.length>=t)break;const r=Oe(u);n.has(r)||(n.add(r),o.push(u))}return o}let da=0;function Ae(e){return`${e}-rt-${++da}`}function Gt(e){const t=Fo();if(!t||t.total===0){const o=new Set;for(const u of e)o.add(u);return o}const n=new Set;for(const o of e)Ir(o)===!0&&n.add(o);return n}const _n=new Map;let Qo=null,eu=null;function Yt(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function tu(e){const t=Yt(e.choseong),n=e.composition,o=n?.syllable==null?"":Array.isArray(n.syllable)?n.syllable.slice().sort().join(","):String(n.syllable),u=n?`${Yt(n.cho)}/${Yt(n.jung)}/${Yt(n.jong)}/${n.jongNone?"N":""}/${o}`:"",r=Yt(e.grade);return`${e.difficulty??""}|${t}|${u}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${r}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function Le(e){const t=yn(),n=Ht();(t!==Qo||n!==eu)&&(_n.clear(),Qo=t,eu=n);const o=tu(e);return _n.has(o)||_n.set(o,fa(e)),_n.get(o)}function ha(e){if(!e)return null;const t=i=>i==null?null:Array.isArray(i)?i.length?i:null:[i],n=t(e.cho),o=t(e.jung),u=!!e.jongNone,r=u?null:t(e.jong);return n||o||r||u?u&&!n&&!o&&!r?i=>Nr(i):i=>xr(i,{cho:n,jung:o,jong:r,jongNone:u}):null}async function fa(e){const{difficulty:t=null,choseong:n=null,composition:o=null,targetSyllable:u=null,excludeNoImage:r=!1}=e,i=e.grade&&e.grade.length>0?new Set(e.grade):null,s=e.sameStructureOnly??!0,c=e.phonemeView==="pron"?"pron":"char",C=Math.max(1,e.contrastCount??1),f=t==="cho"||t==="jung"||t==="jong",p=f&&C>=2,d=t==="count",m=n?new Set(Array.isArray(n)?n:[n]):null,k=o?.syllable!=null?new Set(Array.isArray(o.syllable)?o.syllable:[o.syllable]):null,w=o?[ha(o),k?M=>k.has(pn(M)):null].filter(M=>M!=null):[],E=t==="random"||t===null,g=E||d,S=E||p||d;let A=Ge.filter(M=>!M.w||i&&(!M.grade||!i.has(M.grade))?!1:S?!0:Array.isArray(M.p)&&M.p.length>0);m&&(A=A.filter(M=>{for(const j of m)if(Mr(M.w,j))return!0;return!1})),w.length>0&&(A=A.filter(M=>{const j=c==="pron"?Oe(M.w):M.w;return w.every(ae=>ae(j))})),u&&(A=A.filter(M=>M.w[0]===u));let B;if(r){const M=new Set;for(const j of A)if(M.add(j.w),Array.isArray(j.p))for(const ae of j.p)M.add(ae);if(g)for(const j of Ge)j.w&&M.add(j.w);B=Gt(M)}else{const M=new Set;for(const j of A)if(M.add(j.w),Array.isArray(j.p))for(const ae of j.p)M.add(ae);if(g)for(const j of Ge)j.w&&M.add(j.w);B=M}let L=null;if(p){const M=new Set;for(const j of Ge)j.w&&M.add(j.w);L=r?Gt(M):M}const D=A.filter(M=>B.has(M.w)),I=600,$=Array.from(B),G=$.length>I?Ye($,I):$,P=d&&o!=null&&(_e(o.cho)||_e(o.jung)||_e(o.jong)),Q=2500,Y=new Map;if(d&&!P&&C>=2){for(const M of $){const j=pn(M),ae=Y.get(j);ae?ae.push(M):Y.set(j,[M])}for(const[M,j]of Y)j.length>Q&&Y.set(M,Ye(j,Q))}const W=Ar(),F=P?ea(o,$,W,s,c,Oe):null,x=500,v=1500,ye=e.fullCount?D:t==="random"?D.length>x?Ye(D,x):D:D.length>v?Ye(D,v):D,Z=Ht(),ee=[];for(const M of ye){let j;const ae=Oe(M.w);if(p)j=Dr(M.w,t,C,L,24).filter(ne=>Oe(ne)!==ae);else if(d)P?j=(F.get(M.w)??[]).filter(ne=>Oe(ne)!==ae):C<=1?j=Wo(M.w,Z,{okSet:B,pronOf:Oe,decompOf:W,sameStructureOnly:!1}):j=(Y.get(pn(M.w))??[]).filter(ne=>{if(ne===M.w||Oe(ne)===ae)return!1;const q=vr(M.w,ne);return C>=5?q>=5:q===C});else if(E)j=G.filter(ne=>ne!==M.w&&ne.length===M.w.length&&Oe(ne)!==ae);else{const ne=t;j=Wo(M.w,Z,{kind:ne,okSet:B,pronOf:Oe,decompOf:W,sameStructureOnly:!1}),j.length===0&&(j=(G.length>30?Ye(G,30):G).filter(q=>q!==M.w&&wr(M.w,q)===t&&Oe(q)!==ae))}if(s&&j.length>0&&(f||d&&!P)){const ne=W(Oe(M.w));j=j.filter(q=>!zn(ne,W(Oe(q))))}j.length!==0&&ee.push({word:M,usable:j})}return ee}async function nu(e,t){const{choicesPerItem:n=3,count:o=10}=t,u=n-1,r=(await Le(t)).filter(s=>s.usable.length>=u),i=[];for(const s of re(r)){if(i.length>=o)break;const c=Yn(s.usable,u);if(c.length<u)continue;const C=re([s.word.w,...c]);i.push({id:Ae(e+"-item"),index:i.length+1,word:s.word.w,syllables:s.word.s,choices:C,answerIndex:C.indexOf(s.word.w)})}return i}async function pa(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,u=await Le({...e,difficulty:null});if(u.length<t)return[];const r=[],i=re([...u]);for(const s of i){if(r.length>=n)break;const c=s.word.w,C=[...s.word.pron||c],f=gn(C);if(!f)continue;const p=u.filter(k=>k.word.w!==c&&k.word.s===s.word.s&&!(k.word.pron||k.word.w).includes(f)&&k.word.pron!==s.word.pron);if(p.length<o)continue;const d=Yn(p.map(k=>k.word.w),o);if(d.length<o)continue;const m=re([c,...d]);r.push({id:Ae("HPI-item"),index:r.length+1,targetSyllable:f,word:c,choices:m,answerIndex:m.indexOf(c)})}return r}async function Ca(e){const{count:t=10}=e,n=(await Le(e)).filter(o=>o.usable.length>=1);return Array.from({length:t},(o,u)=>{const r=gn(n);if(!r)return null;const i=u%2===0;let s;if(i)s=[r.word.w,r.word.w];else{const c=gn(r.usable);s=Math.random()<.5?[r.word.w,c]:[c,r.word.w]}return{id:Ae("SOD-item"),index:u+1,word:r.word.w,pair:s,same:i}}).filter(o=>!!o)}async function ya(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,u=await Le({...e,difficulty:null});if(u.length<t+1)return[];const r=u.map(d=>d.word.w),i=new Map(u.map(d=>[d.word.w,d.word.pron])),s=d=>(i.get(d)||d)[0]??"",c={};for(const d of u){const m=s(d.word.w);m&&(c[m]||(c[m]=[]),c[m].push(d.word.w))}const C=Object.entries(c).filter(([,d])=>d.length>=2).map(([d])=>d);if(C.length===0)return[];const f=[],p=re([...C]);for(let d=0;f.length<n&&d<n*4;d++){const m=p[d%p.length],k=c[m];if(k.length<2)continue;const w=re([...k]),E=w[0],g=w[1];if(!E||!g||E===g||(i.get(E)||E)===(i.get(g)||g))continue;const S=i.get(g)||g,A=r.filter(D=>s(D)!==m&&D!==E&&D!==g&&D.length===g.length&&(i.get(D)||D)!==S);if(A.length<o)continue;const B=Yn(A,o);if(B.length<o)continue;const L=re([g,...B]);f.push({id:Ae("SWS-item"),index:f.length+1,sourceWord:E,targetSyllable:m,word:g,choices:L,answerIndex:L.indexOf(g)})}return f}function ou(e,t,n){return Ye(e,t).map((o,u)=>{const r=gn(o.usable)??"",i=[...o.word.w],s=[...r],c=i.findIndex((f,p)=>f!==s[p]),C=re(o.usable.filter(f=>f&&f!==r)).slice(0,2);return{id:Ae(n),index:u+1,word:o.word.w,original:o.word.w,changed:r,changedFrom:c>=0?i[c]:"",changedTo:c>=0?s[c]:"",distractors:C}})}async function uu(e,t,n){const{count:o=10}=t,u=Et(),r=Ge.filter(m=>m.w&&m.s===e),i=t.excludeNoImage?Gt(r.map(m=>m.w)):null,s=i?r.filter(m=>i.has(m.w)):r,c=new Set(s.map(m=>m.w)),C=sa(c),f=t.phonemeView??"char",p=t.composition??null,d=[];for(const m of re(s)){if(d.length>=o)break;const k=la(m.w,p,u,f,C,null,null);if(!k)continue;const w=k.distractors[0],E=[...m.w],g=[...w],S=E.findIndex((A,B)=>A!==g[B]);d.push({id:Ae(n),index:d.length+1,word:m.w,original:m.w,changed:w,changedFrom:S>=0?E[S]:"",changedTo:S>=0?g[S]:"",distractors:k.distractors.slice(1)})}return d}async function ma(e){return uu(2,e,"CS2-item")}async function ga(e){return uu(3,e,"CS3-item")}async function _a(e){const t=(await Le({...e,difficulty:"count",contrastCount:1})).filter(n=>n.word.s===1&&n.usable.length>=1);return ou(t,e.count??10,"CP1-item")}async function Ea(e){const t=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",n=(await Le({...e,difficulty:t,contrastCount:1})).filter(o=>o.word.s===2&&o.usable.length>=1);return ou(n,e.count??10,"CP2-item")}async function ba(e){const{count:t=10}=e,n=(await Le({...e})).filter(o=>o.word.s===2);return Ye(n,t).map((o,u)=>({id:Ae("M2S-item"),index:u+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function Sa(e){const{count:t=10}=e,n=(await Le({...e})).filter(o=>o.word.s===3);return Ye(n,t).map((o,u)=>({id:Ae("M3S-item"),index:u+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function ka(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s===2),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=oa(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=[...s.word.w],d=p[0]===C?p[1]:p[0];i.push({id:Ae("D2-item"),index:i.length+1,original:s.word.w,word:s.word.w,dropped:d,missingResult:C,distractors:f})}return i}async function Aa(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s===3),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=ua(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=[...s.word.w];let d="";for(let m=0;m<p.length;m++)if(p.filter((k,w)=>w!==m).join("")===C){d=p[m];break}i.push({id:Ae("D3-item"),index:i.length+1,original:s.word.w,word:s.word.w,dropped:d,missingResult:C,distractors:f})}return i}async function wa(e){const{count:t=10}=e,n=(await Le({...e})).filter(s=>s.word.s>=2),o=Et(),u=new Set(Ge.map(s=>s.w)),r=e.phonemeView??"char",i=[];for(const s of re(n)){if(i.length>=t)break;const c=ra(s.word.w,e.composition??null,o,r,u);if(!c)continue;const[C,...f]=c.distractors,p=s.word.w,d=p.startsWith(C)?p.slice(C.length):p.endsWith(C)?p.slice(0,p.length-C.length):"";i.push({id:Ae("DPC-item"),index:i.length+1,original:p,word:p,dropped:d,missingResult:C,distractors:f})}return i}async function Ma(e){const{count:t=10}=e,n=(await Le({...e})).map(o=>o.word.w);return n.length<3?[]:Array.from({length:t},(o,u)=>{const r=Ye(n,3);return{id:Ae("LRO-item"),index:u+1,sequence:r,choices:re(r)}})}function En(e,t,n){const o=Ge.filter(i=>i.w&&i.s===e),u=t?Gt(o.map(i=>i.w)):null,r=[];for(const i of o)if(!(u&&!u.has(i.w))){if(n){const s=le(i.w);if(!s||!n(s))continue}r.push(i)}return r}function Na(e){const t=En(1,e.excludeNoImage??!1,n=>n.jong===0);return Ye(t,e.count??10).map((n,o)=>{const u=le(n.w);return{id:Ae("M2P-item"),index:o+1,parts:[ke[u.cho],rt[u.jung]],answer:n.w,word:n.w}})}function Ta(e){const t=En(1,e.excludeNoImage??!1,n=>n.jong>0&&!$t[n.jong]);return Ye(t,e.count??10).map((n,o)=>{const u=le(n.w);return{id:Ae("M3P-item"),index:o+1,parts:[ke[u.cho],rt[u.jung],Fe[u.jong]],answer:n.w,word:n.w}})}function xa(e){const t=Yo.DROP_FINAL_CONSONANT_FROM_1SYLL,n=En(t.syllables,e.excludeNoImage??!1,t.syllable),o=Et(),u=[];for(const r of re(n)){if(u.length>=(e.count??10))break;const i=aa(r.w,null,o);if(!i)continue;const[s,...c]=i.distractors;u.push({id:Ae("DFC-item"),index:u.length+1,original:r.w,word:r.w,result:s,distractors:c})}return u}function Ba(e){const t=Yo.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,n=En(t.syllables,e.excludeNoImage??!1,t.syllable),o=Et(),u=[];for(const r of re(n)){if(u.length>=(e.count??10))break;const i=ia(r.w,null,o);if(!i)continue;const s=le(o.get(r.w)||r.w);if(!s)continue;const[c,...C]=i.distractors;u.push({id:Ae("RCP-item"),index:u.length+1,base:r.w,word:r.w,missingConsonant:ke[s.cho],remaining:c,distractors:C})}return u}const bn=new Map;let ru=null,au=null;async function iu(e,t={}){const n=yn(),o=Ht();(n!==ru||o!==au)&&(bn.clear(),ru=n,au=o);const u=`${e}:${tu(t)}`;if(bn.has(u))return bn.get(u);const r=await va(e,t);return bn.set(u,r),r}const Da={SAME_SOUND_PICK:e=>nu("SSP",e),HEAR_AND_PICK_SAME:e=>nu("HPS",e),HEAR_AND_PICK_INCLUDED:e=>pa(e),SAME_OR_DIFF:e=>Ca(e),STARTS_WITH_SAME_SOUND:e=>ya(e),LISTEN_AND_REMEMBER_ORDER:e=>Ma(e),MERGE_2_SYLLABLES:e=>ba(e),MERGE_3_SYLLABLES:e=>Sa(e),MERGE_2_PHONEMES:e=>Na(e),MERGE_3_PHONEMES:e=>Ta(e),DROP_1_FROM_2SYLL:e=>ka(e),DROP_1_FROM_3SYLL:e=>Aa(e),DROP_PART_FROM_COMPOUND:e=>wa(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>xa(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>Ba(e),CHANGE_1_SYLL_IN_2SYLL:e=>ma(e),CHANGE_1_SYLL_IN_3SYLL:e=>ga(e),CHANGE_1_PHONEME_IN_1SYLL:e=>_a(e),CHANGE_1_PHONEME_IN_2SYLL:e=>Ea(e)};async function va(e,t={}){const n=Da[e];return n?await n(t):[]}async function Oa(e){const t=[null,"count"],n=Object.keys(Fn);let o=0;for(const u of t)for(const r of n){const i=Fn[r];iu(r,{difficulty:i.difficulty?u:null,choseong:null,count:10,excludeNoImage:e}).catch(()=>{}),++o%6===0&&await new Promise(s=>setTimeout(s,0))}}async function La(e){return(await Le({...e,fullCount:!0})).length}async function Ra(e={}){const t=[];for(const s of Ge)s.w&&t.push(s.w);const n=e.excludeNoImage?Gt(t):t,o=new Set,u=new Set,r=new Set,i=new Set;for(const s of n){i.add(pn(s));for(const c of s){const C=le(c);if(C&&(ke[C.cho]!=="\u3147"&&o.add(ke[C.cho]),u.add(rt[C.jung]),C.jong>0)){r.add(Fe[C.jong]);const f=$t[C.jong];f&&f.forEach(p=>r.add(p))}}}return{cho:o,jung:u,jong:r,syllable:i}}const bt="\uC804\uCCB4";function Ia(...e){return e.filter(Boolean).join(" ")}/**
2
2
  * @license lucide-react v1.38.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
package/dist/hooks.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{useState as T,useEffect as X,createContext as Gn,useContext as Yn,useRef as Le,useCallback as q,useMemo as Se,forwardRef as Po,createElement as Ut,useLayoutEffect as Mu}from"react";import{useTranslation as kt}from"react-i18next";import{jsx as re,jsxs as je,Fragment as Gt}from"react/jsx-runtime";import{createPortal as $o}from"react-dom";function Tu({storageKey:e="fontScale",baseFont:t=20,minScale:n=.8,maxScale:o=1.4,step:r=.1,lineHeightRatio:u=1.4}={}){const i=_=>Math.max(n,Math.min(o,Number(_))),[l,c]=T(()=>{try{const _=localStorage.getItem(e),m=_?Number(_):1;return Number.isFinite(m)?m:1}catch{return 1}});X(()=>{try{localStorage.setItem(e,String(l))}catch{}},[e,l]);const f=_=>{c(typeof _=="function"?m=>i(_(m)):i(_))},h=()=>f(_=>+(_+r).toFixed(6)),p=()=>f(_=>+(_-r).toFixed(6)),s=l<o-Number.EPSILON,y=l>n+Number.EPSILON,A=Math.round(t*l),w=Math.round(A*u);return{scale:l,setScale:f,increase:h,decrease:p,canIncrease:s,canDecrease:y,fontSize:A,lineHeight:w}}const Fo=Gn(null);function Bu(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}function Du(e){const t=Yn(Fo),n=u=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(u).matches,[o,r]=T(n(e));return X(()=>{if(typeof window>"u"||!window.matchMedia)return;const u=window.matchMedia(e),i=c=>r(c.matches),l=u;return l.addEventListener?l.addEventListener("change",i):l.addListener&&l.addListener(i),r(u.matches),()=>{l.removeEventListener?l.removeEventListener("change",i):l.removeListener&&l.removeListener(i)}},[e]),t&&typeof t.mobile=="boolean"&&Bu(e)?t.mobile:o}function Ho(e){const t=Le(e);return X(()=>{t.current=e}),t}function zo(e,t){const n=Ho(t);X(()=>{const o=()=>n.current();try{window.addEventListener(e,o)}catch{}return()=>{try{window.removeEventListener(e,o)}catch{}}},[e,n])}const qn=" \xB7 ",Vo=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes(qn)?e.split(qn).pop()??e:e})(),Uo=Gn(!1);function xu(e){const t=Yn(Uo);X(()=>{if(t||typeof e!="string"||!e)return;const n=document.title;return document.title=Vo?`${e}${qn}${Vo}`:e,()=>{document.title=n}},[e,t])}function vu(){const{t:e}=kt();return q(t=>{if(!t)return"";const n=new Date(t).getTime();if(Number.isNaN(n))return"";const o=Math.floor((Date.now()-n)/864e5);return o<=0?e("myHomework.relativeDay.today","\uC624\uB298"):o===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n:o})},[e])}function Ou(e){const[t,n]=T({current:"",next:"",confirm:""}),[o,r]=T(null),[u,i]=T(!1),l=Le(null);X(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);const c=q(()=>{n({current:"",next:"",confirm:""}),r(null)},[]),f=q(async()=>{if(!t.current){r({type:"error",text:"\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(!t.next){r({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(t.next!==t.confirm){r({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."});return}i(!0);const h=e?await e(t.current,t.next):null;if(i(!1),h){r({type:"error",text:h});return}r({type:"success",text:"\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}),n({current:"",next:"",confirm:""}),l.current!==null&&clearTimeout(l.current),l.current=setTimeout(()=>r(null),1500)},[t,e]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:r,pwLoading:u,handleChangePw:f,reset:c}}const Ne=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],st=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],Ge=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function de(e){if(!e)return null;const t=e.charCodeAt(0)-44032;return t<0||t>=11172?null:{cho:Math.floor(t/588),jung:Math.floor(t%588/28),jong:t%28}}function Lu(){const e=new Map;return t=>{let n=e.get(t);return n||(n=[...t].map(o=>de(o)),e.set(t,n)),n}}function wt(e,t,n=0){return String.fromCharCode(44032+(e*21+t)*28+n)}function Ru(e,t){if(!e||!t||e===t||e.length!==t.length)return"random";let n=0,o=null;for(let r=0;r<e.length;r++){const u=de(e[r]),i=de(t[r]);if(!u||!i)return"random";if(u.cho===i.cho&&u.jung===i.jung&&u.jong===i.jong)continue;n++;const l=u.cho!==i.cho,c=u.jung!==i.jung,f=u.jong!==i.jong;(l?1:0)+(c?1:0)+(f?1:0)>1?o="multi":l?o="cho":c?o="jung":o="jong"}return n!==1?"random":o==="cho"?"cho":o==="jung"?"jung":o==="jong"?"jong":"random"}const Yt={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries(Yt).map(([e,t])=>[t.join(""),Ge[Number(e)]]));function Iu(e,t){if(!e||!t)return!1;for(const n of e){const o=de(n);if(o){if(Ne[o.cho]===t)return!0;if(o.jong>0){if(Ge[o.jong]===t)return!0;const r=Yt[o.jong];if(r&&r.includes(t))return!0}}}return!1}function bn(e){if(!e)return 0;let t=0;for(const n of e)de(n)&&t++;return t}function ju(e){if(!e)return!1;let t=!1;for(const n of e){const o=de(n);if(o&&(t=!0,o.jong>0))return!1}return t}function Pu(e,t){if(e.jong<=0)return!1;if(t.includes(Ge[e.jong]))return!0;const n=Yt[e.jong];return!!n&&n.some(o=>t.includes(o))}function $u(e,t,n){if(!e)return!1;const o=[...e],r=u=>{const i=de(o[u]);if(!i||t.cho&&!t.cho.includes(Ne[i.cho])||t.jung&&!t.jung.includes(st[i.jung]))return!1;if(t.jongNone){if(i.jong>0)return!1}else if(t.jong&&!Pu(i,t.jong))return!1;return!0};if(n==="head")return r(0);if(n==="tail")return r(o.length-1);if(n==="mid"){for(let u=1;u<o.length-1;u++)if(r(u))return!0;return!1}for(let u=0;u<o.length;u++)if(r(u))return!0;return!1}const Fu={cho:Ne.length,jung:st.length,jong:Ge.length};function Hu(e,t,n,o,r=1/0){if(!e||n<1)return[];const u=[...e].map(p=>de(p));if(u.some(p=>!p))return[];const i=u,l=i.length;if(n>l)return[];const c=Fu[t],f=new Set,h=[];(function p(s,y){if(y.length===n){h.push([...y]);return}for(let A=s;A<l;A++)y.push(A),p(A+1,y),y.pop()})(0,[]);for(const p of h)if((function s(y,A){if(f.size>=r)return;if(y===p.length){const m=A.map(b=>wt(b.cho,b.jung,b.jong)).join("");m!==e&&o.has(m)&&f.add(m);return}const w=p[y],_=i[w][t];for(let m=0;m<c;m++){if(m===_)continue;const b=A.slice();if(b[w]={...A[w],[t]:m},s(y+1,b),f.size>=r)return}})(0,i),f.size>=r)break;return[...f]}function zu(e,t){if(!e||!t||e.length!==t.length)return-1;let n=0;for(let o=0;o<e.length;o++){const r=de(e[o]),u=de(t[o]);if(!r||!u)return-1;r.cho!==u.cho&&n++,r.jung!==u.jung&&n++,r.jong!==u.jong&&n++}return n}const Go="word_pair_index_v2",Yo="word_pair_index_sig_v2";let qt=null;function Vu(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem(Go),t=localStorage.getItem(Yo);return!e||!t?null:{index:JSON.parse(e),sig:t}}catch{return null}}function Wt(){if(qt)return qt;const e=Vu();return e?(qt=e.index,e.sig,qt):null}function Uu(){qt=null;try{typeof localStorage<"u"&&(localStorage.removeItem(Go),localStorage.removeItem(Yo))}catch{}}const qo="word_image_existence_map_v1";let Rt=null;function Wo(){if(Rt)return Rt;try{const e=typeof localStorage<"u"?localStorage.getItem(qo):null;Rt=e?JSON.parse(e):{}}catch{Rt={}}return Rt}function Gu(e,t){return`${e}_${t??1}`}function Yu(e,t){const n=Wo(),o=Gu(e,t);return o in n?n[o]:void 0}function Ko(){const e=Wo(),t=Object.values(e);return t.length===0?null:{total:t.length,exists:t.filter(Boolean).length}}function qu(){Rt={};try{typeof localStorage<"u"&&localStorage.removeItem(qo)}catch{}}const Xo=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function Zo(e){return e.reduce((t,n)=>{try{const o=localStorage.getItem(n);return t+(o?new Blob([o]).size:0)}catch{return t}},0)}function Wu(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function Ku(e){const{t}=kt(),[n,o]=T({}),[r,u]=T(null),[i,l]=T(null),[c,f]=T(null),h=q(()=>{const s={};Xo.forEach(y=>{s[y.id]=Zo([...y.keys])}),o(s),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(y=>{f({usage:y.usage??0,quota:y.quota??0})}).catch(()=>{})},[]);X(()=>{h()},[h]);const p=q(async s=>{u(s);try{s==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):s==="pairIndex"?Uu():s==="imageCache"&&qu(),h(),e?.(t("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{u(null)}},[h,e,t]);return{cacheSizes:n,clearingId:r,confirmCacheId:i,setConfirmCacheId:l,storageEstimate:c,refreshCacheSizes:h,handleClearCache:p}}function Xu(e){const[t,n]=T(null),[o,r]=T(null),u=q(()=>{const i=Wt();if(i){const c=Object.values(i),f=c.filter(h=>h.cho.length+h.jung.length+h.jong.length>0).length;n({matched:f,total:c.length})}else n(null);const l=Ko();r(l?{exists:l.exists,total:l.total}:null)},[]);return X(()=>{u();const i=setTimeout(u,1e3);return()=>clearTimeout(i)},[e,u]),{pairStats:t,imgStats:o,setPairStats:n,setImgStats:r,refreshStats:u}}function Jo(e,t=[]){const[n,o]=T(t),[r,u]=T(null),[i,l]=T(!1),[c,f]=T(e),h=Le(i);X(()=>{h.current=i});const p=Le(null);X(()=>{if(h.current)return;const m=p.current;m!==null&&m.length===t.length&&m.every((b,k)=>b===t[k])||(p.current=t,o(t))},[t]);const s=q(m=>{u(m),l(!1),f({...m})},[]),y=q(()=>l(!0),[]),A=q(()=>l(!1),[]),w=q((m,b)=>{o(m),u(b),l(!1)},[]),_=q(m=>{o(b=>b.filter(k=>k!==m)),u(null)},[]);return{list:n,setList:o,selected:r,setSelected:u,isEditing:i,setIsEditing:l,editForm:c,setEditForm:f,openDetail:s,startEditing:y,cancelEditing:A,commitEdit:w,remove:_}}const Kt=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},Zu={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Ju(e=[]){const{list:t,setList:n,selected:o,setSelected:r,isEditing:u,setIsEditing:i,editForm:l,setEditForm:c,openDetail:f,commitEdit:h}=Jo(Zu,e),{year:p,month:s,day:y}=Kt(),[A,w]=T({year:p,month:s,day:y,hour:"09",minute:"00",memo:""});return{visitHistory:t,visitForm:A,setVisitForm:w,setVisit:_=>m=>w(b=>({...b,[_]:m})),selectedVisit:o,setSelectedVisit:r,isEditingVisit:u,setIsEditingVisit:i,editVisitForm:l,setEditVisitForm:c,openVisitDetail:f,handleVisitSave:_=>{n(D=>[A,...D]);const{year:m,month:b,day:k}=Kt();w({year:m,month:b,day:k,hour:"09",minute:"00",memo:""}),_?.()},handleVisitEditSave:()=>{h(_=>_.map(m=>m===o?l:m),l)},addVisit:_=>{n(m=>[_,...m])},removeVisit:_=>{n(m=>m.filter(b=>b!==_))},revertVisitEdit:(_,m)=>{n(b=>b.map(k=>k===m?_:k)),r(b=>b===m?_:b)}}}const Qo=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,An=e=>[...e].sort((t,n)=>{const o=Qo(t),r=Qo(n);return o<r?-1:o>r?1:0}),Qu={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function ea(e,t=[]){const n=Se(()=>An(t),[t]),{list:o,setList:r,selected:u,setSelected:i,isEditing:l,setIsEditing:c,editForm:f,setEditForm:h,openDetail:p,commitEdit:s,remove:y}=Jo(Qu,n),[A,w]=T([]),{year:_,month:m,day:b}=Kt(),[k,D]=T({year:_,month:m,day:b,hour:"09",minute:"00",memo:""}),L=F=>B=>D(v=>({...v,[F]:B})),x=F=>{r(J=>An([...J,k]));const{year:B,month:v,day:ge}=Kt();D({year:B,month:v,day:ge,hour:"09",minute:"00",memo:""}),F?.()},I=()=>{s(F=>An(F.map(B=>B===u?f:B)),f)},$=q(F=>{y(F)},[y]),U=q(F=>{e({year:F.year,month:F.month,day:F.day,hour:F.hour,minute:F.minute,memo:F.memo}),y(F)},[e,y]),P=q(F=>{r(B=>B.filter(v=>v!==F)),w(B=>[F,...B]),i(null)},[r,i]),ee=q(F=>{r(B=>An([...B,F]))},[r]),G=q(F=>{r(B=>B.filter(v=>v!==F))},[r]),W=q((F,B)=>{r(v=>v.map(ge=>ge===B?F:ge)),i(v=>v===B?F:v)},[r,i]);return{scheduleList:o,noShowList:A,addSchedule:ee,removeSchedule:G,revertScheduleEdit:W,scheduleForm:k,setScheduleForm:D,setSchedule:L,selectedSchedule:u,setSelectedSchedule:i,isEditingSchedule:l,setIsEditingSchedule:c,editScheduleForm:f,setEditScheduleForm:h,openScheduleDetail:p,handleScheduleSave:x,handleScheduleEditSave:I,handleScheduleDelete:$,handleScheduleToVisit:U,handleScheduleNoVisit:P}}const er=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function ta(e){const[t,n]=T(""),[o,r]=T("25"),[u,i]=T("all"),[l,c]=T(1),f=Se(()=>e.filter(({item:y,status:A})=>!(t&&!y.memo.includes(t)||u!=="all"&&A!==u)),[e,t,u]),h=Math.max(1,Math.ceil(f.length/Number(o))),p=Math.min(l,h),s=Se(()=>f.slice((p-1)*Number(o),p*Number(o)),[f,p,o]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:r,vapStatus:u,setVapStatus:i,vapPage:p,setVapPage:c,vapFiltered:f,vapTotal:h,vapPageItems:s}}function na(e,t){const{t:n}=kt(),[o,r]=T("25"),[u,i]=T(1),[l,c]=T(t);l!==t&&(c(t),u!==1&&i(1));const f=Se(()=>er.map(y=>({...y,label:n("visits.showN",{n:y.value})})),[n]),h=q(y=>{r(y),i(1)},[]),p=Math.max(1,Math.ceil(e.length/Number(o))),s=Math.min(u,p);return{pageRows:Se(()=>e.slice((s-1)*Number(o),s*Number(o)),[e,s,o]),pageSizeProps:{options:f,value:o,onChange:h},paginationProps:{page:s,total:p,onChange:i},setPage:i}}function oa(){const[e,t]=T(null),n=q(r=>{t(u=>u?.key===r?{key:r,asc:!u.asc}:{key:r,asc:!0})},[]),o=q((r,u)=>({label:r,sortDir:e?.key===u?e.asc?"asc":"desc":null,onClick:()=>n(u)}),[e,n]);return{\uC815\uB82C:e,\uCE78:o}}function ra(){const[e,t]=T(!1),[n,o]=T("\uC88C"),[r,u]=T({\uC88C:null,\uC6B0:null}),[i,l]=T({\uC88C:[],\uC6B0:[]}),[c,f]=T(!1),[h,p]=T("\uC88C"),s=q(A=>{const w=A.direction;u(_=>({..._,[w]:A})),l(_=>({..._,[w]:[A,..._[w]]})),t(!1)},[]),y=q(A=>{const w=A.direction;u(_=>({..._,[w]:A})),f(!1)},[]);return{showDevice:e,setShowDevice:t,deviceDirection:n,setDeviceDirection:o,devices:r,setDevices:u,deviceHistory:i,setDeviceHistory:l,showDeviceList:c,setShowDeviceList:f,listForSide:h,setListForSide:p,handleDeviceSubmit:s,handleSelectFromList:y}}const ua="__ihab_core_word_pool__";function kn(){return globalThis[ua]??null}function ie(e,t=Math.random){const n=e.slice();for(let o=n.length-1;o>0;o--){const r=Math.floor(t()*(o+1));[n[o],n[r]]=[n[r],n[o]]}return n}function dt(e,t,n=Math.random){return!Array.isArray(e)||e.length===0||t<=0?[]:t>=e.length?ie(e,n):ie(e,n).slice(0,t)}const Wn={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},aa=Ne.indexOf("\u3147"),tr={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==aa},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},ia={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},la={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function nr(e){return ia[e]??e}const Kn={cho:Ne,jung:st,jong:Ge},be=e=>Array.isArray(e)?e.length>0:!!e;function Xn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const o=e[n],r=t[n];if(!(!o||!r)&&(o.cho!==r.cho&&Ne[o.cho]==="\u3147"!=(Ne[r.cho]==="\u3147")||o.jong!==r.jong&&o.jong===0!=(r.jong===0)))return!0}return!1}function ca(e,t,n){const o=n.pronOf(e),r=n.decompOf,u=n.sameStructureOnly&&r?r(o):null,i=[];for(const l of t)l!==e&&(n.okSet&&!n.okSet.has(l)||n.pronOf(l)!==o&&(u&&r&&Xn(u,r(n.pronOf(l)))||i.push(l)));return i}function or(e,t,n){const o=t?.[e];if(!o)return[];const r=n.kind?o[n.kind]??[]:[...o.cho??[],...o.jung??[],...o.jong??[]];return ca(e,r,n)}function sa(e,t,n,o,r,u,i){const l=["cho","jung","jong"].filter(s=>be(e[s])),c={};for(const s of l){const y=e[s];c[s]=new Set(Array.isArray(y)?y:[y])}const f=r==="pron",h=new Map;for(const s of t){const y=n(u(s));if(y.some(m=>!m))continue;let A=y;if(!f&&(A=n(s),A.length!==y.length||A.some(m=>!m)))continue;const w=y.length,_=h.get(w);_?_.push({w:s,dPron:y,dPos:A}):h.set(w,[{w:s,dPron:y,dPos:A}])}const p=new Map;for(const[s,y]of h){const A=new Map,w=(_,m)=>{const b=_.dPos[m];return b!=null&&l.every(k=>c[k].has(Kn[k][b[k]]))};for(const _ of y){let m;if(i==="head")m=w(_,0)?0:-1;else if(i==="tail")m=w(_,s-1)?s-1:-1;else if(i==="mid"){m=-1;for(let k=1;k<s-1;k++)if(w(_,k)){m=k;break}}else m=_.dPos.findIndex(k=>k!=null&&l.every(D=>c[D].has(Kn[D][k[D]])));if(m<0)continue;const b=A.get(m);b?b.push(_):A.set(m,[_])}for(const[_,m]of A){const b=new Set(l.map(L=>_+":"+L)),k=L=>{let x="";for(let I=0;I<s;I++){const $=L[I];for(const U of["cho","jung","jong"])x+=(b.has(I+":"+U)?"*":$[U])+"."}return x},D=new Map;for(const L of y){const x=k(L.dPron),I=D.get(x);I?I.push(L):D.set(x,[L])}for(const L of m){const x=D.get(k(L.dPron))??[],I=[];for(const $ of x){if($.w===L.w)continue;let U=!0;for(const P of l){const ee=L.dPron[_][P],G=$.dPron[_][P];if(G===ee){U=!1;break}if(f&&c[P].has(Kn[P][G])){U=!1;break}}U&&(o&&Xn(L.dPron,$.dPron)||I.push($.w))}p.set(L.w,I)}}}return p}const da=e=>e==null?[]:Array.isArray(e)?e:[e];function ha(e){if([...e].length!==1)return"";const t=de(e);if(!t)return"";const n=nr(Ge[t.jong]),o=n===""?0:Ge.indexOf(n);return wt(t.cho,t.jung,o<0?0:o)}function rr(e,t){return t.get(e)||ha(e)||e}function Zn(e){return e?be(e.cho)?"cho":be(e.jung)?"jung":be(e.jong)?"jong":null:null}function It(e,t){const n=(o,r)=>!be(o)||da(o).includes(r);return n(t.cho,Ne[e.cho])&&n(t.jung,st[e.jung])&&n(t.jong,Ge[e.jong])}function Xt(e,t,n){const o=[...e];if(n!=="pron")return o.map(u=>de(u));const r=[...t.get(e)||e];return r.length!==o.length?o.map(u=>de(u)):r.map(u=>de(u))}function Zt(e,t,n,o,r){const u=t==="cho"?Ne:t==="jung"?st:Ge,i=e[t],l=[],c=new Set([rr(n,r)]),f=ie(u.map((h,p)=>p).filter(h=>h!==i&&(t!=="cho"||u[h]!=="\u3147")&&(t!=="jong"||h!==0)));for(const h of f){if(l.length>=o)break;const p=t==="cho"?wt(h,e.jung,e.jong):t==="jung"?wt(e.cho,h,e.jong):wt(e.cho,e.jung,h),s=rr(p,r);c.has(s)||(c.add(s),l.push(p))}return l}function pa(e,t,n,o,r,u=null){const i=[...e];if(i.length!==2)return null;const l=i.map(p=>de(p));if(l.some(p=>!p))return null;const c=Xt(e,n,o);if(c.some(p=>!p))return null;const f=Zn(t);let h=f&&t?c.map((p,s)=>It(p,t)?s:-1).filter(p=>p>=0):[0,1];if(u!=null&&(h=h.filter(p=>p!==u)),!h.length)return null;for(const p of ie(h)){const s=i[p];if(!r.has(s))continue;const y=Zt(l[p],f??"cho",s,40,n),A=[];for(const w of y)if(w!==s&&r.has(w)&&!A.includes(w)&&A.push(w),A.length>=2)break;if(!(A.length<2))return{question:e,distractors:[s,...A]}}return null}function fa(e,t,n,o,r,u=null){const i=[...e];if(i.length!==3)return null;const l=i.map(p=>de(p));if(l.some(p=>!p))return null;const c=Xt(e,n,o);if(c.some(p=>!p))return null;const f=Zn(t),h=f&&t?c.map((p,s)=>It(p,t)?s:-1).filter(p=>p>=0):[0,1,2];if(!h.length)return null;for(const p of ie(h))for(const s of ie([0,1,2].filter(y=>y!==p&&(u==null||y===u)))){const y=[0,1,2].filter(b=>b!==s),A=y.map(b=>i[b]).join("");if(!r.has(A))continue;const w=y.indexOf(p),_=Zt(l[p],f??"cho",i[p],40,n),m=[];for(const b of _){const k=y.map(L=>i[L]);k[w]=b;const D=k.join("");if(D!==A&&r.has(D)&&!m.includes(D)&&m.push(D),m.length>=2)break}if(!(m.length<2))return{question:e,distractors:[A,...m]}}return null}function Ca(e,t,n,o,r,u=null){const i=[...e],l=i.length;if(l<2)return null;const c=[];for(let h=1;h<=l-1;h++)c.push({remain:i.slice(0,h).join(""),dropped:i.slice(h).join(""),droppedEnd:1}),c.push({remain:i.slice(l-h).join(""),dropped:i.slice(0,l-h).join(""),droppedEnd:0});const f=Zn(t);for(const{remain:h,dropped:p,droppedEnd:s}of ie(c)){if(u!=null&&s!==u||h===e||!r.has(h)||!r.has(p))continue;const y=[...h],A=y.map(m=>de(m));if(A.some(m=>!m))continue;const w=Xt(h,n,o);if(w.some(m=>!m))continue;const _=f&&t?w.map((m,b)=>It(m,t)?b:-1).filter(m=>m>=0):y.map((m,b)=>b);if(_.length)for(const m of ie(_)){const b=Zt(A[m],f??"cho",y[m],40,n),k=[];for(const D of b){const L=[...y];L[m]=D;const x=L.join("");if(x!==h&&r.has(x)&&!k.includes(x)&&k.push(x),k.length>=2)break}if(k.length>=2)return{question:e,distractors:[h,...k]}}}return null}function ya(e,t,n,o,r,u=null){if([...e].length!==1)return null;const i=de(n.get(e)||e);if(!i||i.jong===0)return null;const l=wt(i.cho,i.jung,0),c=Zt({cho:i.cho,jung:i.jung,jong:0},"cho",l,2,n);return c.length<2?null:{question:e,distractors:[l,...c]}}const Jn=Ne.indexOf("\u3147");function ma(e,t,n,o,r,u=null){if([...e].length!==1)return null;const i=de(n.get(e)||e);if(!i||i.jong!==0||i.cho===Jn)return null;const l=wt(Jn,i.jung,0),c=Zt({cho:Jn,jung:i.jung,jong:0},"jung",l,2,n);return c.length<2?null:{question:e,distractors:[l,...c]}}function ga(e){const t=new Map;for(const n of e){const o=[...n],r=o.length;if(!(r<2||r>3))for(let u=0;u<r;u++){let i=r+"|"+u+"|";for(let c=0;c<r;c++)i+=c===u?"*":o[c];const l=t.get(i);l?l.push(n):t.set(i,[n])}}return t}function _a(e,t,n,o,r,u=null,i=null,l=2){const c=[...e],f=c.length;if(f<2||f>3)return null;const h=c.map(b=>de(b));if(h.some(b=>!b))return null;const p=Xt(e,n,o);if(p.some(b=>!b))return null;const s=b=>n.get(b)??b,y=s(e),A=!!t&&(be(t.cho)||be(t.jung)||be(t.jong)),w=!!i&&(be(i.cho)||be(i.jung)||be(i.jong)),_=b=>{let k=f+"|"+b+"|";for(let D=0;D<f;D++)k+=D===b?"*":c[D];return k};let m;if(u!=null){if(u>=f||A&&!It(p[u],t))return null;m=[u]}else A?m=p.map((b,k)=>It(b,t)?k:-1).filter(b=>b>=0):m=Array.from({length:f},(b,k)=>k);for(const b of ie(m)){const k=r.get(_(b))??[],D=[],L=[];for(const P of k){if(P===e)continue;const ee=[...P].map(B=>de(B)),G=h[b],W=ee[b];if(!G||!W)continue;let F=0;if(G.cho!==W.cho&&F++,G.jung!==W.jung&&F++,G.jong!==W.jong&&F++,!(F<l||s(P)===y))if(w){const B=Xt(P,n,o)[b];B&&It(B,i)?D.push(P):L.push(P)}else D.push(P)}if(!D.length)continue;const x=ie(D)[0],I=[],$=new Set([y,s(x)]),U=w?L:D.filter(P=>P!==x);for(const P of ie(U)){const ee=s(P);if(!$.has(ee)&&($.add(ee),I.push(P),I.length>=2))break}if(!w&&I.length<2)for(const P of ie(k)){if(P===e||P===x)continue;const ee=s(P);if(!$.has(ee)&&($.add(ee),I.push(P),I.length>=2))break}if(!(I.length<2))return{question:e,distractors:[x,...I]}}return null}let wn=null,ur=null,ar=null;function Ea(){const e=kn();if(e&&e.entries.length>0){const t=Wt();if(wn&&ur===e&&ar===t)return wn;const n=new Set,o=[];for(const r of e.entries)!r.word||n.has(r.word)||(n.add(r.word),o.push({w:r.word,s:r.syllables,p:t?.[r.word]?[...t[r.word].cho??[],...t[r.word].jung??[],...t[r.word].jong??[]]:[],pron:r.pronunciation||r.word,grade:r.grade}));return wn=o,ur=e,ar=t,wn}return[]}const Xe=new Proxy([],{get(e,t){const n=Ea(),o=n[t];return typeof o=="function"?o.bind(n):o}});function Sn(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function Ze(e,t){if(t>=e.length)return ie(e);if(t===0)return[];const n=e.slice();for(let o=0;o<t;o++){const r=o+Math.floor(Math.random()*(n.length-o)),u=n[o];n[o]=n[r],n[r]=u}return n.slice(0,t)}let Qn=null,ir=null;function St(){const e=kn();if(Qn&&ir===e)return Qn;const t=new Map;for(const n of Xe)n.w&&t.set(n.w,n.pron);return Qn=t,ir=e,t}function Pe(e){return St().get(e)||e}function eo(e,t,n=new Set){const o=[];for(const r of ie(e)){if(o.length>=t)break;const u=Pe(r);n.has(u)||(n.add(u),o.push(r))}return o}let ba=0;function Me(e){return`${e}-rt-${++ba}`}function Jt(e){const t=Ko();if(!t||t.total===0){const o=new Set;for(const r of e)o.add(r);return o}const n=new Set;for(const o of e)Yu(o)===!0&&n.add(o);return n}const Nn=new Map;let lr=null,cr=null;function Qt(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function sr(e){const t=Qt(e.choseong),n=e.composition,o=n?.syllable==null?"":Array.isArray(n.syllable)?n.syllable.slice().sort().join(","):String(n.syllable),r=n?`${Qt(n.cho)}/${Qt(n.jung)}/${Qt(n.jong)}/${n.jongNone?"N":""}/${o}`:"",u=Qt(e.grade);return`${e.difficulty??""}|${t}|${r}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${u}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function $e(e){const t=kn(),n=Wt();(t!==lr||n!==cr)&&(Nn.clear(),lr=t,cr=n);const o=sr(e);return Nn.has(o)||Nn.set(o,ka(e)),Nn.get(o)}function Aa(e){if(!e)return null;const t=i=>i==null?null:Array.isArray(i)?i.length?i:null:[i],n=t(e.cho),o=t(e.jung),r=!!e.jongNone,u=r?null:t(e.jong);return n||o||u||r?r&&!n&&!o&&!u?i=>ju(i):i=>$u(i,{cho:n,jung:o,jong:u,jongNone:r}):null}async function ka(e){const{difficulty:t=null,choseong:n=null,composition:o=null,targetSyllable:r=null,excludeNoImage:u=!1}=e,i=e.grade&&e.grade.length>0?new Set(e.grade):null,l=e.sameStructureOnly??!0,c=e.phonemeView==="pron"?"pron":"char",f=Math.max(1,e.contrastCount??1),h=t==="cho"||t==="jung"||t==="jong",p=h&&f>=2,s=t==="count",y=n?new Set(Array.isArray(n)?n:[n]):null,A=o?.syllable!=null?new Set(Array.isArray(o.syllable)?o.syllable:[o.syllable]):null,w=o?[Aa(o),A?S=>A.has(bn(S)):null].filter(S=>S!=null):[],_=t==="random"||t===null,m=_||s,b=_||p||s;let k=Xe.filter(S=>!S.w||i&&(!S.grade||!i.has(S.grade))?!1:b?!0:Array.isArray(S.p)&&S.p.length>0);y&&(k=k.filter(S=>{for(const j of y)if(Iu(S.w,j))return!0;return!1})),w.length>0&&(k=k.filter(S=>{const j=c==="pron"?Pe(S.w):S.w;return w.every(le=>le(j))})),r&&(k=k.filter(S=>S.w[0]===r));let D;if(u){const S=new Set;for(const j of k)if(S.add(j.w),Array.isArray(j.p))for(const le of j.p)S.add(le);if(m)for(const j of Xe)j.w&&S.add(j.w);D=Jt(S)}else{const S=new Set;for(const j of k)if(S.add(j.w),Array.isArray(j.p))for(const le of j.p)S.add(le);if(m)for(const j of Xe)j.w&&S.add(j.w);D=S}let L=null;if(p){const S=new Set;for(const j of Xe)j.w&&S.add(j.w);L=u?Jt(S):S}const x=k.filter(S=>D.has(S.w)),I=600,$=Array.from(D),U=$.length>I?Ze($,I):$,P=s&&o!=null&&(be(o.cho)||be(o.jung)||be(o.jong)),ee=2500,G=new Map;if(s&&!P&&f>=2){for(const S of $){const j=bn(S),le=G.get(j);le?le.push(S):G.set(j,[S])}for(const[S,j]of G)j.length>ee&&G.set(S,Ze(j,ee))}const W=Lu(),F=P?sa(o,$,W,l,c,Pe):null,B=500,v=1500,ge=e.fullCount?x:t==="random"?x.length>B?Ze(x,B):x:x.length>v?Ze(x,v):x,J=Wt(),te=[];for(const S of ge){let j;const le=Pe(S.w);if(p)j=Hu(S.w,t,f,L,24).filter(oe=>Pe(oe)!==le);else if(s)P?j=(F.get(S.w)??[]).filter(oe=>Pe(oe)!==le):f<=1?j=or(S.w,J,{okSet:D,pronOf:Pe,decompOf:W,sameStructureOnly:!1}):j=(G.get(bn(S.w))??[]).filter(oe=>{if(oe===S.w||Pe(oe)===le)return!1;const Y=zu(S.w,oe);return f>=5?Y>=5:Y===f});else if(_)j=U.filter(oe=>oe!==S.w&&oe.length===S.w.length&&Pe(oe)!==le);else{const oe=t;j=or(S.w,J,{kind:oe,okSet:D,pronOf:Pe,decompOf:W,sameStructureOnly:!1}),j.length===0&&(j=(U.length>30?Ze(U,30):U).filter(Y=>Y!==S.w&&Ru(S.w,Y)===t&&Pe(Y)!==le))}if(l&&j.length>0&&(h||s&&!P)){const oe=W(Pe(S.w));j=j.filter(Y=>!Xn(oe,W(Pe(Y))))}j.length!==0&&te.push({word:S,usable:j})}return te}async function dr(e,t){const{choicesPerItem:n=3,count:o=10}=t,r=n-1,u=(await $e(t)).filter(l=>l.usable.length>=r),i=[];for(const l of ie(u)){if(i.length>=o)break;const c=eo(l.usable,r);if(c.length<r)continue;const f=ie([l.word.w,...c]);i.push({id:Me(e+"-item"),index:i.length+1,word:l.word.w,syllables:l.word.s,choices:f,answerIndex:f.indexOf(l.word.w)})}return i}async function wa(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,r=await $e({...e,difficulty:null});if(r.length<t)return[];const u=[],i=ie([...r]);for(const l of i){if(u.length>=n)break;const c=l.word.w,f=[...l.word.pron||c],h=Sn(f);if(!h)continue;const p=r.filter(A=>A.word.w!==c&&A.word.s===l.word.s&&!(A.word.pron||A.word.w).includes(h)&&A.word.pron!==l.word.pron);if(p.length<o)continue;const s=eo(p.map(A=>A.word.w),o);if(s.length<o)continue;const y=ie([c,...s]);u.push({id:Me("HPI-item"),index:u.length+1,targetSyllable:h,word:c,choices:y,answerIndex:y.indexOf(c)})}return u}async function Sa(e){const{count:t=10}=e,n=(await $e(e)).filter(o=>o.usable.length>=1);return Array.from({length:t},(o,r)=>{const u=Sn(n);if(!u)return null;const i=r%2===0;let l;if(i)l=[u.word.w,u.word.w];else{const c=Sn(u.usable);l=Math.random()<.5?[u.word.w,c]:[c,u.word.w]}return{id:Me("SOD-item"),index:r+1,word:u.word.w,pair:l,same:i}}).filter(o=>!!o)}async function Na(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,r=await $e({...e,difficulty:null});if(r.length<t+1)return[];const u=r.map(s=>s.word.w),i=new Map(r.map(s=>[s.word.w,s.word.pron])),l=s=>(i.get(s)||s)[0]??"",c={};for(const s of r){const y=l(s.word.w);y&&(c[y]||(c[y]=[]),c[y].push(s.word.w))}const f=Object.entries(c).filter(([,s])=>s.length>=2).map(([s])=>s);if(f.length===0)return[];const h=[],p=ie([...f]);for(let s=0;h.length<n&&s<n*4;s++){const y=p[s%p.length],A=c[y];if(A.length<2)continue;const w=ie([...A]),_=w[0],m=w[1];if(!_||!m||_===m||(i.get(_)||_)===(i.get(m)||m))continue;const b=i.get(m)||m,k=u.filter(x=>l(x)!==y&&x!==_&&x!==m&&x.length===m.length&&(i.get(x)||x)!==b);if(k.length<o)continue;const D=eo(k,o);if(D.length<o)continue;const L=ie([m,...D]);h.push({id:Me("SWS-item"),index:h.length+1,sourceWord:_,targetSyllable:y,word:m,choices:L,answerIndex:L.indexOf(m)})}return h}function hr(e,t,n){return Ze(e,t).map((o,r)=>{const u=Sn(o.usable)??"",i=[...o.word.w],l=[...u],c=i.findIndex((h,p)=>h!==l[p]),f=ie(o.usable.filter(h=>h&&h!==u)).slice(0,2);return{id:Me(n),index:r+1,word:o.word.w,original:o.word.w,changed:u,changedFrom:c>=0?i[c]:"",changedTo:c>=0?l[c]:"",distractors:f}})}async function pr(e,t,n){const{count:o=10}=t,r=St(),u=Xe.filter(y=>y.w&&y.s===e),i=t.excludeNoImage?Jt(u.map(y=>y.w)):null,l=i?u.filter(y=>i.has(y.w)):u,c=new Set(l.map(y=>y.w)),f=ga(c),h=t.phonemeView??"char",p=t.composition??null,s=[];for(const y of ie(l)){if(s.length>=o)break;const A=_a(y.w,p,r,h,f,null,null);if(!A)continue;const w=A.distractors[0],_=[...y.w],m=[...w],b=_.findIndex((k,D)=>k!==m[D]);s.push({id:Me(n),index:s.length+1,word:y.w,original:y.w,changed:w,changedFrom:b>=0?_[b]:"",changedTo:b>=0?m[b]:"",distractors:A.distractors.slice(1)})}return s}async function Ma(e){return pr(2,e,"CS2-item")}async function Ta(e){return pr(3,e,"CS3-item")}async function Ba(e){const t=(await $e({...e,difficulty:"count",contrastCount:1})).filter(n=>n.word.s===1&&n.usable.length>=1);return hr(t,e.count??10,"CP1-item")}async function Da(e){const t=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",n=(await $e({...e,difficulty:t,contrastCount:1})).filter(o=>o.word.s===2&&o.usable.length>=1);return hr(n,e.count??10,"CP2-item")}async function xa(e){const{count:t=10}=e,n=(await $e({...e})).filter(o=>o.word.s===2);return Ze(n,t).map((o,r)=>({id:Me("M2S-item"),index:r+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function va(e){const{count:t=10}=e,n=(await $e({...e})).filter(o=>o.word.s===3);return Ze(n,t).map((o,r)=>({id:Me("M3S-item"),index:r+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function Oa(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s===2),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=pa(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=[...l.word.w],s=p[0]===f?p[1]:p[0];i.push({id:Me("D2-item"),index:i.length+1,original:l.word.w,word:l.word.w,dropped:s,missingResult:f,distractors:h})}return i}async function La(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s===3),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=fa(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=[...l.word.w];let s="";for(let y=0;y<p.length;y++)if(p.filter((A,w)=>w!==y).join("")===f){s=p[y];break}i.push({id:Me("D3-item"),index:i.length+1,original:l.word.w,word:l.word.w,dropped:s,missingResult:f,distractors:h})}return i}async function Ra(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s>=2),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=Ca(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=l.word.w,s=p.startsWith(f)?p.slice(f.length):p.endsWith(f)?p.slice(0,p.length-f.length):"";i.push({id:Me("DPC-item"),index:i.length+1,original:p,word:p,dropped:s,missingResult:f,distractors:h})}return i}async function Ia(e){const{count:t=10}=e,n=(await $e({...e})).map(o=>o.word.w);return n.length<3?[]:Array.from({length:t},(o,r)=>{const u=Ze(n,3);return{id:Me("LRO-item"),index:r+1,sequence:u,choices:ie(u)}})}function Mn(e,t,n){const o=Xe.filter(i=>i.w&&i.s===e),r=t?Jt(o.map(i=>i.w)):null,u=[];for(const i of o)if(!(r&&!r.has(i.w))){if(n){const l=de(i.w);if(!l||!n(l))continue}u.push(i)}return u}function ja(e){const t=Mn(1,e.excludeNoImage??!1,n=>n.jong===0);return Ze(t,e.count??10).map((n,o)=>{const r=de(n.w);return{id:Me("M2P-item"),index:o+1,parts:[Ne[r.cho],st[r.jung]],answer:n.w,word:n.w}})}function Pa(e){const t=Mn(1,e.excludeNoImage??!1,n=>n.jong>0&&!Yt[n.jong]);return Ze(t,e.count??10).map((n,o)=>{const r=de(n.w);return{id:Me("M3P-item"),index:o+1,parts:[Ne[r.cho],st[r.jung],Ge[r.jong]],answer:n.w,word:n.w}})}function $a(e){const t=tr.DROP_FINAL_CONSONANT_FROM_1SYLL,n=Mn(t.syllables,e.excludeNoImage??!1,t.syllable),o=St(),r=[];for(const u of ie(n)){if(r.length>=(e.count??10))break;const i=ya(u.w,null,o);if(!i)continue;const[l,...c]=i.distractors;r.push({id:Me("DFC-item"),index:r.length+1,original:u.w,word:u.w,result:l,distractors:c})}return r}function Fa(e){const t=tr.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,n=Mn(t.syllables,e.excludeNoImage??!1,t.syllable),o=St(),r=[];for(const u of ie(n)){if(r.length>=(e.count??10))break;const i=ma(u.w,null,o);if(!i)continue;const l=de(o.get(u.w)||u.w);if(!l)continue;const[c,...f]=i.distractors;r.push({id:Me("RCP-item"),index:r.length+1,base:u.w,word:u.w,missingConsonant:Ne[l.cho],remaining:c,distractors:f})}return r}const Tn=new Map;let fr=null,Cr=null;async function yr(e,t={}){const n=kn(),o=Wt();(n!==fr||o!==Cr)&&(Tn.clear(),fr=n,Cr=o);const r=`${e}:${sr(t)}`;if(Tn.has(r))return Tn.get(r);const u=await za(e,t);return Tn.set(r,u),u}const Ha={SAME_SOUND_PICK:e=>dr("SSP",e),HEAR_AND_PICK_SAME:e=>dr("HPS",e),HEAR_AND_PICK_INCLUDED:e=>wa(e),SAME_OR_DIFF:e=>Sa(e),STARTS_WITH_SAME_SOUND:e=>Na(e),LISTEN_AND_REMEMBER_ORDER:e=>Ia(e),MERGE_2_SYLLABLES:e=>xa(e),MERGE_3_SYLLABLES:e=>va(e),MERGE_2_PHONEMES:e=>ja(e),MERGE_3_PHONEMES:e=>Pa(e),DROP_1_FROM_2SYLL:e=>Oa(e),DROP_1_FROM_3SYLL:e=>La(e),DROP_PART_FROM_COMPOUND:e=>Ra(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>$a(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>Fa(e),CHANGE_1_SYLL_IN_2SYLL:e=>Ma(e),CHANGE_1_SYLL_IN_3SYLL:e=>Ta(e),CHANGE_1_PHONEME_IN_1SYLL:e=>Ba(e),CHANGE_1_PHONEME_IN_2SYLL:e=>Da(e)};async function za(e,t={}){const n=Ha[e];return n?await n(t):[]}async function Va(e){const t=[null,"count"],n=Object.keys(Wn);let o=0;for(const r of t)for(const u of n){const i=Wn[u];yr(u,{difficulty:i.difficulty?r:null,choseong:null,count:10,excludeNoImage:e}).catch(()=>{}),++o%6===0&&await new Promise(l=>setTimeout(l,0))}}async function Ua(e){return(await $e({...e,fullCount:!0})).length}async function Ga(e={}){const t=[];for(const l of Xe)l.w&&t.push(l.w);const n=e.excludeNoImage?Jt(t):t,o=new Set,r=new Set,u=new Set,i=new Set;for(const l of n){i.add(bn(l));for(const c of l){const f=de(c);if(f&&(Ne[f.cho]!=="\u3147"&&o.add(Ne[f.cho]),r.add(st[f.jung]),f.jong>0)){u.add(Ge[f.jong]);const h=Yt[f.jong];h&&h.forEach(p=>u.add(p))}}}return{cho:o,jung:r,jong:u,syllable:i}}const Nt="\uC804\uCCB4";function Ya(...e){return e.filter(Boolean).join(" ")}/**
1
+ import{useState as T,useEffect as X,createContext as Gn,useContext as Yn,useRef as Le,useCallback as q,useMemo as Se,forwardRef as Po,createElement as Ut,useLayoutEffect as Mu}from"react";import{useTranslation as kt}from"react-i18next";import{jsx as re,jsxs as je,Fragment as Gt}from"react/jsx-runtime";import{createPortal as $o}from"react-dom";function Tu({storageKey:e="fontScale",baseFont:t=20,minScale:n=.8,maxScale:o=1.4,step:r=.1,lineHeightRatio:u=1.4}={}){const i=_=>Math.max(n,Math.min(o,Number(_))),[l,c]=T(()=>{try{const _=localStorage.getItem(e),m=_?Number(_):1;return Number.isFinite(m)?m:1}catch{return 1}});X(()=>{try{localStorage.setItem(e,String(l))}catch{}},[e,l]);const f=_=>{c(typeof _=="function"?m=>i(_(m)):i(_))},h=()=>f(_=>+(_+r).toFixed(6)),p=()=>f(_=>+(_-r).toFixed(6)),s=l<o-Number.EPSILON,y=l>n+Number.EPSILON,A=Math.round(t*l),w=Math.round(A*u);return{scale:l,setScale:f,increase:h,decrease:p,canIncrease:s,canDecrease:y,fontSize:A,lineHeight:w}}const Fo=Gn(null);function Bu(e){return/max-width:\s*7[0-9][0-9]px/.test(e)}function Du(e){const t=Yn(Fo),n=u=>typeof window>"u"||!window.matchMedia?!1:window.matchMedia(u).matches,[o,r]=T(n(e));return X(()=>{if(typeof window>"u"||!window.matchMedia)return;const u=window.matchMedia(e),i=c=>r(c.matches),l=u;return l.addEventListener?l.addEventListener("change",i):l.addListener&&l.addListener(i),r(u.matches),()=>{l.removeEventListener?l.removeEventListener("change",i):l.removeListener&&l.removeListener(i)}},[e]),t&&typeof t.mobile=="boolean"&&Bu(e)?t.mobile:o}function Ho(e){const t=Le(e);return X(()=>{t.current=e}),t}function zo(e,t){const n=Ho(t);X(()=>{const o=()=>n.current();try{window.addEventListener(e,o)}catch{}return()=>{try{window.removeEventListener(e,o)}catch{}}},[e,n])}const qn=" \xB7 ",Vo=(()=>{if(typeof document>"u")return"";const e=document.title;return e.includes(qn)?e.split(qn).pop()??e:e})(),Uo=Gn(!1);function xu(e){const t=Yn(Uo);X(()=>{if(t||typeof e!="string"||!e)return;const n=document.title;return document.title=Vo?`${e}${qn}${Vo}`:e,()=>{document.title=n}},[e,t])}function vu(){const{t:e}=kt();return q(t=>{if(!t)return"";const n=new Date(t).getTime();if(Number.isNaN(n))return"";const o=Math.floor((Date.now()-n)/864e5);return o<=0?e("myHomework.relativeDay.today","\uC624\uB298"):o===1?e("myHomework.relativeDay.yesterday","\uC5B4\uC81C"):e("myHomework.relativeDay.daysAgo",{n:o})},[e])}function Ou(e){const[t,n]=T({current:"",next:"",confirm:""}),[o,r]=T(null),[u,i]=T(!1),l=Le(null);X(()=>()=>{l.current!==null&&clearTimeout(l.current)},[]);const c=q(()=>{n({current:"",next:"",confirm:""}),r(null)},[]),f=q(async()=>{if(!t.current){r({type:"error",text:"\uD604\uC7AC \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(!t.next){r({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uB97C \uC785\uB825\uD558\uC138\uC694."});return}if(t.next!==t.confirm){r({type:"error",text:"\uC0C8 \uBE44\uBC00\uBC88\uD638\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4."});return}i(!0);const h=e?await e(t.current,t.next):null;if(i(!1),h){r({type:"error",text:h});return}r({type:"success",text:"\uBE44\uBC00\uBC88\uD638\uAC00 \uBCC0\uACBD\uB418\uC5C8\uC2B5\uB2C8\uB2E4."}),n({current:"",next:"",confirm:""}),l.current!==null&&clearTimeout(l.current),l.current=setTimeout(()=>r(null),1500)},[t,e]);return{pw:t,setPw:n,pwMsg:o,setPwMsg:r,pwLoading:u,handleChangePw:f,reset:c}}const Ne=["\u3131","\u3132","\u3134","\u3137","\u3138","\u3139","\u3141","\u3142","\u3143","\u3145","\u3146","\u3147","\u3148","\u3149","\u314A","\u314B","\u314C","\u314D","\u314E"],st=["\u314F","\u3150","\u3151","\u3152","\u3153","\u3154","\u3155","\u3156","\u3157","\u3158","\u3159","\u315A","\u315B","\u315C","\u315D","\u315E","\u315F","\u3160","\u3161","\u3162","\u3163"],Ge=["","\u3131","\u3132","\u3133","\u3134","\u3135","\u3136","\u3137","\u3139","\u313A","\u313B","\u313C","\u313D","\u313E","\u313F","\u3140","\u3141","\u3142","\u3144","\u3145","\u3146","\u3147","\u3148","\u314A","\u314B","\u314C","\u314D","\u314E"];function de(e){if(!e)return null;const t=e.charCodeAt(0)-44032;return t<0||t>=11172?null:{cho:Math.floor(t/588),jung:Math.floor(t%588/28),jong:t%28}}function Lu(){const e=new Map;return t=>{let n=e.get(t);return n||(n=[...t].map(o=>de(o)),e.set(t,n)),n}}function wt(e,t,n=0){return String.fromCharCode(44032+(e*21+t)*28+n)}function Ru(e,t){if(!e||!t||e===t||e.length!==t.length)return"random";let n=0,o=null;for(let r=0;r<e.length;r++){const u=de(e[r]),i=de(t[r]);if(!u||!i)return"random";if(u.cho===i.cho&&u.jung===i.jung&&u.jong===i.jong)continue;n++;const l=u.cho!==i.cho,c=u.jung!==i.jung,f=u.jong!==i.jong;(l?1:0)+(c?1:0)+(f?1:0)>1?o="multi":l?o="cho":c?o="jung":o="jong"}return n!==1?"random":o==="cho"?"cho":o==="jung"?"jung":o==="jong"?"jong":"random"}const Yt={3:["\u3131","\u3145"],5:["\u3134","\u3148"],6:["\u3134","\u314E"],9:["\u3139","\u3131"],10:["\u3139","\u3141"],11:["\u3139","\u3142"],12:["\u3139","\u3145"],13:["\u3139","\u314C"],14:["\u3139","\u314D"],15:["\u3139","\u314E"],18:["\u3142","\u3145"]};Object.fromEntries(Object.entries(Yt).map(([e,t])=>[t.join(""),Ge[Number(e)]]));function Iu(e,t){if(!e||!t)return!1;for(const n of e){const o=de(n);if(o){if(Ne[o.cho]===t)return!0;if(o.jong>0){if(Ge[o.jong]===t)return!0;const r=Yt[o.jong];if(r&&r.includes(t))return!0}}}return!1}function bn(e){if(!e)return 0;let t=0;for(const n of e)de(n)&&t++;return t}function ju(e){if(!e)return!1;let t=!1;for(const n of e){const o=de(n);if(o&&(t=!0,o.jong>0))return!1}return t}function Pu(e,t){if(e.jong<=0)return!1;if(t.includes(Ge[e.jong]))return!0;const n=Yt[e.jong];return!!n&&n.some(o=>t.includes(o))}function $u(e,t,n){if(!e)return!1;const o=[...e],r=u=>{const i=de(o[u]);if(!i||t.cho&&!t.cho.includes(Ne[i.cho])||t.jung&&!t.jung.includes(st[i.jung]))return!1;if(t.jongNone){if(i.jong>0)return!1}else if(t.jong&&!Pu(i,t.jong))return!1;return!0};if(n==="head")return r(0);if(n==="tail")return r(o.length-1);if(n==="mid"){for(let u=1;u<o.length-1;u++)if(r(u))return!0;return!1}for(let u=0;u<o.length;u++)if(r(u))return!0;return!1}const Fu={cho:Ne.length,jung:st.length,jong:Ge.length};function Hu(e,t,n,o,r=1/0){if(!e||n<1)return[];const u=[...e].map(p=>de(p));if(u.some(p=>!p))return[];const i=u,l=i.length;if(n>l)return[];const c=Fu[t],f=new Set,h=[];(function p(s,y){if(y.length===n){h.push([...y]);return}for(let A=s;A<l;A++)y.push(A),p(A+1,y),y.pop()})(0,[]);for(const p of h)if((function s(y,A){if(f.size>=r)return;if(y===p.length){const m=A.map(b=>wt(b.cho,b.jung,b.jong)).join("");m!==e&&o.has(m)&&f.add(m);return}const w=p[y],_=i[w][t];for(let m=0;m<c;m++){if(m===_)continue;const b=A.slice();if(b[w]={...A[w],[t]:m},s(y+1,b),f.size>=r)return}})(0,i),f.size>=r)break;return[...f]}function zu(e,t){if(!e||!t||e.length!==t.length)return-1;let n=0;for(let o=0;o<e.length;o++){const r=de(e[o]),u=de(t[o]);if(!r||!u)return-1;r.cho!==u.cho&&n++,r.jung!==u.jung&&n++,r.jong!==u.jong&&n++}return n}const Go="word_pair_index_v2",Yo="word_pair_index_sig_v2";let qt=null;function Vu(){try{if(typeof localStorage>"u")return null;const e=localStorage.getItem(Go),t=localStorage.getItem(Yo);return!e||!t?null:{index:JSON.parse(e),sig:t}}catch{return null}}function Wt(){if(qt)return qt;const e=Vu();return e?(qt=e.index,e.sig,qt):null}function Uu(){qt=null;try{typeof localStorage<"u"&&(localStorage.removeItem(Go),localStorage.removeItem(Yo))}catch{}}const qo="word_image_existence_map_v1";let Rt=null;function Wo(){if(Rt)return Rt;try{const e=typeof localStorage<"u"?localStorage.getItem(qo):null;Rt=e?JSON.parse(e):{}}catch{Rt={}}return Rt}function Gu(e,t){return`${e}_${t??1}`}function Yu(e,t){const n=Wo(),o=Gu(e,t);return o in n?n[o]:void 0}function Ko(){const e=Wo(),t=Object.values(e);return t.length===0?null:{total:t.length,exists:t.filter(Boolean).length}}function qu(){Rt={};try{typeof localStorage<"u"&&localStorage.removeItem(qo)}catch{}}const Xo=[{id:"wordData",labelKey:"settings.cache.group.wordData.label",subKey:"settings.cache.group.wordData.sub",keys:["word_data_cache","word_data_version"]},{id:"pairIndex",labelKey:"settings.cache.group.pairIndex.label",subKey:"settings.cache.group.pairIndex.sub",keys:["word_pair_index_v2","word_pair_index_sig_v2"]},{id:"imageCache",labelKey:"settings.cache.group.imageCache.label",subKey:"settings.cache.group.imageCache.sub",keys:["word_image_existence_map_v1"]}];function Zo(e){return e.reduce((t,n)=>{try{const o=localStorage.getItem(n);return t+(o?new Blob([o]).size:0)}catch{return t}},0)}function Wu(e){return e===0?"0 B":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(2)} MB`:`${(e/(1024*1024*1024)).toFixed(2)} GB`}function Ku(e){const{t}=kt(),[n,o]=T({}),[r,u]=T(null),[i,l]=T(null),[c,f]=T(null),h=q(()=>{const s={};Xo.forEach(y=>{s[y.id]=Zo([...y.keys])}),o(s),typeof navigator<"u"&&navigator.storage?.estimate&&navigator.storage.estimate().then(y=>{f({usage:y.usage??0,quota:y.quota??0})}).catch(()=>{})},[]);X(()=>{h()},[h]);const p=q(async s=>{u(s);try{s==="wordData"?(localStorage.removeItem("word_data_cache"),localStorage.removeItem("word_data_version")):s==="pairIndex"?Uu():s==="imageCache"&&qu(),h(),e?.(t("settings.cache.cleared","\uCE90\uC2DC\uAC00 \uC0AD\uC81C\uB418\uC5C8\uC2B5\uB2C8\uB2E4."))}finally{u(null)}},[h,e,t]);return{cacheSizes:n,clearingId:r,confirmCacheId:i,setConfirmCacheId:l,storageEstimate:c,refreshCacheSizes:h,handleClearCache:p}}function Xu(e){const[t,n]=T(null),[o,r]=T(null),u=q(()=>{const i=Wt();if(i){const c=Object.values(i),f=c.filter(h=>h.cho.length+h.jung.length+h.jong.length>0).length;n({matched:f,total:c.length})}else n(null);const l=Ko();r(l?{exists:l.exists,total:l.total}:null)},[]);return X(()=>{u();const i=setTimeout(u,1e3);return()=>clearTimeout(i)},[e?.length,u]),{pairStats:t,imgStats:o,setPairStats:n,setImgStats:r,refreshStats:u}}function Jo(e,t=[]){const[n,o]=T(t),[r,u]=T(null),[i,l]=T(!1),[c,f]=T(e),h=Le(i);X(()=>{h.current=i});const p=Le(null);X(()=>{if(h.current)return;const m=p.current;m!==null&&m.length===t.length&&m.every((b,k)=>b===t[k])||(p.current=t,o(t))},[t]);const s=q(m=>{u(m),l(!1),f({...m})},[]),y=q(()=>l(!0),[]),A=q(()=>l(!1),[]),w=q((m,b)=>{o(m),u(b),l(!1)},[]),_=q(m=>{o(b=>b.filter(k=>k!==m)),u(null)},[]);return{list:n,setList:o,selected:r,setSelected:u,isEditing:i,setIsEditing:l,editForm:c,setEditForm:f,openDetail:s,startEditing:y,cancelEditing:A,commitEdit:w,remove:_}}const Kt=()=>{const e=new Date;return{year:String(e.getFullYear()),month:String(e.getMonth()+1).padStart(2,"0"),day:String(e.getDate()).padStart(2,"0")}},Zu={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function Ju(e=[]){const{list:t,setList:n,selected:o,setSelected:r,isEditing:u,setIsEditing:i,editForm:l,setEditForm:c,openDetail:f,commitEdit:h}=Jo(Zu,e),{year:p,month:s,day:y}=Kt(),[A,w]=T({year:p,month:s,day:y,hour:"09",minute:"00",memo:""});return{visitHistory:t,visitForm:A,setVisitForm:w,setVisit:_=>m=>w(b=>({...b,[_]:m})),selectedVisit:o,setSelectedVisit:r,isEditingVisit:u,setIsEditingVisit:i,editVisitForm:l,setEditVisitForm:c,openVisitDetail:f,handleVisitSave:_=>{n(D=>[A,...D]);const{year:m,month:b,day:k}=Kt();w({year:m,month:b,day:k,hour:"09",minute:"00",memo:""}),_?.()},handleVisitEditSave:()=>{h(_=>_.map(m=>m===o?l:m),l)},addVisit:_=>{n(m=>[_,...m])},removeVisit:_=>{n(m=>m.filter(b=>b!==_))},revertVisitEdit:(_,m)=>{n(b=>b.map(k=>k===m?_:k)),r(b=>b===m?_:b)}}}const Qo=e=>`${e.year.padStart(4,"0")}-${e.month.padStart(2,"0")}-${e.day.padStart(2,"0")} ${e.hour.padStart(2,"0")}:${e.minute.padStart(2,"0")}`,An=e=>[...e].sort((t,n)=>{const o=Qo(t),r=Qo(n);return o<r?-1:o>r?1:0}),Qu={year:"",month:"",day:"",hour:"09",minute:"00",memo:""};function ea(e,t=[]){const n=Se(()=>An(t),[t]),{list:o,setList:r,selected:u,setSelected:i,isEditing:l,setIsEditing:c,editForm:f,setEditForm:h,openDetail:p,commitEdit:s,remove:y}=Jo(Qu,n),[A,w]=T([]),{year:_,month:m,day:b}=Kt(),[k,D]=T({year:_,month:m,day:b,hour:"09",minute:"00",memo:""}),L=F=>B=>D(v=>({...v,[F]:B})),x=F=>{r(J=>An([...J,k]));const{year:B,month:v,day:ge}=Kt();D({year:B,month:v,day:ge,hour:"09",minute:"00",memo:""}),F?.()},I=()=>{s(F=>An(F.map(B=>B===u?f:B)),f)},$=q(F=>{y(F)},[y]),U=q(F=>{e({year:F.year,month:F.month,day:F.day,hour:F.hour,minute:F.minute,memo:F.memo}),y(F)},[e,y]),P=q(F=>{r(B=>B.filter(v=>v!==F)),w(B=>[F,...B]),i(null)},[r,i]),ee=q(F=>{r(B=>An([...B,F]))},[r]),G=q(F=>{r(B=>B.filter(v=>v!==F))},[r]),W=q((F,B)=>{r(v=>v.map(ge=>ge===B?F:ge)),i(v=>v===B?F:v)},[r,i]);return{scheduleList:o,noShowList:A,addSchedule:ee,removeSchedule:G,revertScheduleEdit:W,scheduleForm:k,setScheduleForm:D,setSchedule:L,selectedSchedule:u,setSelectedSchedule:i,isEditingSchedule:l,setIsEditingSchedule:c,editScheduleForm:f,setEditScheduleForm:h,openScheduleDetail:p,handleScheduleSave:x,handleScheduleEditSave:I,handleScheduleDelete:$,handleScheduleToVisit:U,handleScheduleNoVisit:P}}const er=[{value:"10",label:"10\uAC1C\uC529 \uBCF4\uAE30"},{value:"25",label:"25\uAC1C\uC529 \uBCF4\uAE30"},{value:"50",label:"50\uAC1C\uC529 \uBCF4\uAE30"},{value:"100",label:"100\uAC1C\uC529 \uBCF4\uAE30"}];function ta(e){const[t,n]=T(""),[o,r]=T("25"),[u,i]=T("all"),[l,c]=T(1),f=Se(()=>e.filter(({item:y,status:A})=>!(t&&!y.memo.includes(t)||u!=="all"&&A!==u)),[e,t,u]),h=Math.max(1,Math.ceil(f.length/Number(o))),p=Math.min(l,h),s=Se(()=>f.slice((p-1)*Number(o),p*Number(o)),[f,p,o]);return{vapSearch:t,setVapSearch:n,vapPageSize:o,setVapPageSize:r,vapStatus:u,setVapStatus:i,vapPage:p,setVapPage:c,vapFiltered:f,vapTotal:h,vapPageItems:s}}function na(e,t){const{t:n}=kt(),[o,r]=T("25"),[u,i]=T(1),[l,c]=T(t);l!==t&&(c(t),u!==1&&i(1));const f=Se(()=>er.map(y=>({...y,label:n("visits.showN",{n:y.value})})),[n]),h=q(y=>{r(y),i(1)},[]),p=Math.max(1,Math.ceil(e.length/Number(o))),s=Math.min(u,p);return{pageRows:Se(()=>e.slice((s-1)*Number(o),s*Number(o)),[e,s,o]),pageSizeProps:{options:f,value:o,onChange:h},paginationProps:{page:s,total:p,onChange:i},setPage:i}}function oa(){const[e,t]=T(null),n=q(r=>{t(u=>u?.key===r?{key:r,asc:!u.asc}:{key:r,asc:!0})},[]),o=q((r,u)=>({label:r,sortDir:e?.key===u?e.asc?"asc":"desc":null,onClick:()=>n(u)}),[e,n]);return{\uC815\uB82C:e,\uCE78:o}}function ra(){const[e,t]=T(!1),[n,o]=T("\uC88C"),[r,u]=T({\uC88C:null,\uC6B0:null}),[i,l]=T({\uC88C:[],\uC6B0:[]}),[c,f]=T(!1),[h,p]=T("\uC88C"),s=q(A=>{const w=A.direction;u(_=>({..._,[w]:A})),l(_=>({..._,[w]:[A,..._[w]]})),t(!1)},[]),y=q(A=>{const w=A.direction;u(_=>({..._,[w]:A})),f(!1)},[]);return{showDevice:e,setShowDevice:t,deviceDirection:n,setDeviceDirection:o,devices:r,setDevices:u,deviceHistory:i,setDeviceHistory:l,showDeviceList:c,setShowDeviceList:f,listForSide:h,setListForSide:p,handleDeviceSubmit:s,handleSelectFromList:y}}const ua="__ihab_core_word_pool__";function kn(){return globalThis[ua]??null}function ie(e,t=Math.random){const n=e.slice();for(let o=n.length-1;o>0;o--){const r=Math.floor(t()*(o+1));[n[o],n[r]]=[n[r],n[o]]}return n}function dt(e,t,n=Math.random){return!Array.isArray(e)||e.length===0||t<=0?[]:t>=e.length?ie(e,n):ie(e,n).slice(0,t)}const Wn={SAME_SOUND_PICK:{difficulty:!0,choseong:!0,group:"discrimination"},SAME_OR_DIFF:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_SAME:{difficulty:!0,choseong:!0,group:"discrimination"},HEAR_AND_PICK_INCLUDED:{difficulty:!0,choseong:!0,group:"discrimination"},STARTS_WITH_SAME_SOUND:{difficulty:!1,choseong:!0,group:"discrimination"},LISTEN_AND_REMEMBER_ORDER:{difficulty:!1,choseong:!0,group:"attention"},MERGE_2_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_SYLLABLES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_2_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},MERGE_3_PHONEMES:{difficulty:!1,choseong:!0,group:"synthesis"},DROP_1_FROM_2SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_1_FROM_3SYLL:{difficulty:!1,choseong:!0,group:"deletion"},DROP_PART_FROM_COMPOUND:{difficulty:!1,choseong:!0,group:"deletion"},DROP_FINAL_CONSONANT_FROM_1SYLL:{difficulty:!1,choseong:!0,group:"deletion"},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{difficulty:!1,choseong:!0,group:"deletion"},CHANGE_1_SYLL_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_SYLL_IN_3SYLL:{difficulty:!0,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_1SYLL:{difficulty:!1,choseong:!0,group:"substitution"},CHANGE_1_PHONEME_IN_2SYLL:{difficulty:!0,choseong:!0,group:"substitution"}},aa=Ne.indexOf("\u3147"),tr={DROP_FINAL_CONSONANT_FROM_1SYLL:{syllables:1,syllable:e=>e.jong>0},REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:{syllables:1,syllable:e=>e.jong===0&&e.cho!==aa},MERGE_2_SYLLABLES:{syllables:2,syllable:()=>!0},MERGE_3_SYLLABLES:{syllables:3,syllable:()=>!0},MERGE_2_PHONEMES:{syllables:1,syllable:e=>e.jong===0},MERGE_3_PHONEMES:{syllables:1,syllable:e=>e.jong>0}},ia={\u3131:"\u3131",\u3132:"\u3131",\u314B:"\u3131",\u3133:"\u3131",\u313A:"\u3131",\u3134:"\u3134",\u3135:"\u3134",\u3136:"\u3134",\u3137:"\u3137",\u3145:"\u3137",\u3146:"\u3137",\u3148:"\u3137",\u314A:"\u3137",\u314C:"\u3137",\u314E:"\u3137",\u3139:"\u3139",\u313C:"\u3139",\u313D:"\u3139",\u313E:"\u3139",\u3140:"\u3139",\u3141:"\u3141",\u313B:"\u3141",\u3142:"\u3142",\u314D:"\u3142",\u313F:"\u3142",\u3144:"\u3142",\u3147:"\u3147"},la={\u314F:{nucleus:"\u314F"},\u3151:{glide:"j",nucleus:"\u314F"},\u3153:{nucleus:"\u3153"},\u3155:{glide:"j",nucleus:"\u3153"},\u3157:{nucleus:"\u3157"},\u315B:{glide:"j",nucleus:"\u3157"},\u315C:{nucleus:"\u315C"},\u3160:{glide:"j",nucleus:"\u315C"},\u3161:{nucleus:"\u3161"},\u3163:{nucleus:"\u3163"},\u3150:{nucleus:"\u3154/\u3150"},\u3152:{glide:"j",nucleus:"\u3154/\u3150"},\u3154:{nucleus:"\u3154/\u3150"},\u3156:{glide:"j",nucleus:"\u3154/\u3150"},\u3158:{glide:"w",nucleus:"\u314F"},\u3159:{glide:"w",nucleus:"\u3154/\u3150"},\u315A:{glide:"w",nucleus:"\u3154/\u3150"},\u315D:{glide:"w",nucleus:"\u3153"},\u315E:{glide:"w",nucleus:"\u3154/\u3150"},\u315F:{glide:"w",nucleus:"\u3163"},\u3162:{glide:"\u0270",nucleus:"\u3163"}};function nr(e){return ia[e]??e}const Kn={cho:Ne,jung:st,jong:Ge},be=e=>Array.isArray(e)?e.length>0:!!e;function Xn(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const o=e[n],r=t[n];if(!(!o||!r)&&(o.cho!==r.cho&&Ne[o.cho]==="\u3147"!=(Ne[r.cho]==="\u3147")||o.jong!==r.jong&&o.jong===0!=(r.jong===0)))return!0}return!1}function ca(e,t,n){const o=n.pronOf(e),r=n.decompOf,u=n.sameStructureOnly&&r?r(o):null,i=[];for(const l of t)l!==e&&(n.okSet&&!n.okSet.has(l)||n.pronOf(l)!==o&&(u&&r&&Xn(u,r(n.pronOf(l)))||i.push(l)));return i}function or(e,t,n){const o=t?.[e];if(!o)return[];const r=n.kind?o[n.kind]??[]:[...o.cho??[],...o.jung??[],...o.jong??[]];return ca(e,r,n)}function sa(e,t,n,o,r,u,i){const l=["cho","jung","jong"].filter(s=>be(e[s])),c={};for(const s of l){const y=e[s];c[s]=new Set(Array.isArray(y)?y:[y])}const f=r==="pron",h=new Map;for(const s of t){const y=n(u(s));if(y.some(m=>!m))continue;let A=y;if(!f&&(A=n(s),A.length!==y.length||A.some(m=>!m)))continue;const w=y.length,_=h.get(w);_?_.push({w:s,dPron:y,dPos:A}):h.set(w,[{w:s,dPron:y,dPos:A}])}const p=new Map;for(const[s,y]of h){const A=new Map,w=(_,m)=>{const b=_.dPos[m];return b!=null&&l.every(k=>c[k].has(Kn[k][b[k]]))};for(const _ of y){let m;if(i==="head")m=w(_,0)?0:-1;else if(i==="tail")m=w(_,s-1)?s-1:-1;else if(i==="mid"){m=-1;for(let k=1;k<s-1;k++)if(w(_,k)){m=k;break}}else m=_.dPos.findIndex(k=>k!=null&&l.every(D=>c[D].has(Kn[D][k[D]])));if(m<0)continue;const b=A.get(m);b?b.push(_):A.set(m,[_])}for(const[_,m]of A){const b=new Set(l.map(L=>_+":"+L)),k=L=>{let x="";for(let I=0;I<s;I++){const $=L[I];for(const U of["cho","jung","jong"])x+=(b.has(I+":"+U)?"*":$[U])+"."}return x},D=new Map;for(const L of y){const x=k(L.dPron),I=D.get(x);I?I.push(L):D.set(x,[L])}for(const L of m){const x=D.get(k(L.dPron))??[],I=[];for(const $ of x){if($.w===L.w)continue;let U=!0;for(const P of l){const ee=L.dPron[_][P],G=$.dPron[_][P];if(G===ee){U=!1;break}if(f&&c[P].has(Kn[P][G])){U=!1;break}}U&&(o&&Xn(L.dPron,$.dPron)||I.push($.w))}p.set(L.w,I)}}}return p}const da=e=>e==null?[]:Array.isArray(e)?e:[e];function ha(e){if([...e].length!==1)return"";const t=de(e);if(!t)return"";const n=nr(Ge[t.jong]),o=n===""?0:Ge.indexOf(n);return wt(t.cho,t.jung,o<0?0:o)}function rr(e,t){return t.get(e)||ha(e)||e}function Zn(e){return e?be(e.cho)?"cho":be(e.jung)?"jung":be(e.jong)?"jong":null:null}function It(e,t){const n=(o,r)=>!be(o)||da(o).includes(r);return n(t.cho,Ne[e.cho])&&n(t.jung,st[e.jung])&&n(t.jong,Ge[e.jong])}function Xt(e,t,n){const o=[...e];if(n!=="pron")return o.map(u=>de(u));const r=[...t.get(e)||e];return r.length!==o.length?o.map(u=>de(u)):r.map(u=>de(u))}function Zt(e,t,n,o,r){const u=t==="cho"?Ne:t==="jung"?st:Ge,i=e[t],l=[],c=new Set([rr(n,r)]),f=ie(u.map((h,p)=>p).filter(h=>h!==i&&(t!=="cho"||u[h]!=="\u3147")&&(t!=="jong"||h!==0)));for(const h of f){if(l.length>=o)break;const p=t==="cho"?wt(h,e.jung,e.jong):t==="jung"?wt(e.cho,h,e.jong):wt(e.cho,e.jung,h),s=rr(p,r);c.has(s)||(c.add(s),l.push(p))}return l}function pa(e,t,n,o,r,u=null){const i=[...e];if(i.length!==2)return null;const l=i.map(p=>de(p));if(l.some(p=>!p))return null;const c=Xt(e,n,o);if(c.some(p=>!p))return null;const f=Zn(t);let h=f&&t?c.map((p,s)=>It(p,t)?s:-1).filter(p=>p>=0):[0,1];if(u!=null&&(h=h.filter(p=>p!==u)),!h.length)return null;for(const p of ie(h)){const s=i[p];if(!r.has(s))continue;const y=Zt(l[p],f??"cho",s,40,n),A=[];for(const w of y)if(w!==s&&r.has(w)&&!A.includes(w)&&A.push(w),A.length>=2)break;if(!(A.length<2))return{question:e,distractors:[s,...A]}}return null}function fa(e,t,n,o,r,u=null){const i=[...e];if(i.length!==3)return null;const l=i.map(p=>de(p));if(l.some(p=>!p))return null;const c=Xt(e,n,o);if(c.some(p=>!p))return null;const f=Zn(t),h=f&&t?c.map((p,s)=>It(p,t)?s:-1).filter(p=>p>=0):[0,1,2];if(!h.length)return null;for(const p of ie(h))for(const s of ie([0,1,2].filter(y=>y!==p&&(u==null||y===u)))){const y=[0,1,2].filter(b=>b!==s),A=y.map(b=>i[b]).join("");if(!r.has(A))continue;const w=y.indexOf(p),_=Zt(l[p],f??"cho",i[p],40,n),m=[];for(const b of _){const k=y.map(L=>i[L]);k[w]=b;const D=k.join("");if(D!==A&&r.has(D)&&!m.includes(D)&&m.push(D),m.length>=2)break}if(!(m.length<2))return{question:e,distractors:[A,...m]}}return null}function Ca(e,t,n,o,r,u=null){const i=[...e],l=i.length;if(l<2)return null;const c=[];for(let h=1;h<=l-1;h++)c.push({remain:i.slice(0,h).join(""),dropped:i.slice(h).join(""),droppedEnd:1}),c.push({remain:i.slice(l-h).join(""),dropped:i.slice(0,l-h).join(""),droppedEnd:0});const f=Zn(t);for(const{remain:h,dropped:p,droppedEnd:s}of ie(c)){if(u!=null&&s!==u||h===e||!r.has(h)||!r.has(p))continue;const y=[...h],A=y.map(m=>de(m));if(A.some(m=>!m))continue;const w=Xt(h,n,o);if(w.some(m=>!m))continue;const _=f&&t?w.map((m,b)=>It(m,t)?b:-1).filter(m=>m>=0):y.map((m,b)=>b);if(_.length)for(const m of ie(_)){const b=Zt(A[m],f??"cho",y[m],40,n),k=[];for(const D of b){const L=[...y];L[m]=D;const x=L.join("");if(x!==h&&r.has(x)&&!k.includes(x)&&k.push(x),k.length>=2)break}if(k.length>=2)return{question:e,distractors:[h,...k]}}}return null}function ya(e,t,n,o,r,u=null){if([...e].length!==1)return null;const i=de(n.get(e)||e);if(!i||i.jong===0)return null;const l=wt(i.cho,i.jung,0),c=Zt({cho:i.cho,jung:i.jung,jong:0},"cho",l,2,n);return c.length<2?null:{question:e,distractors:[l,...c]}}const Jn=Ne.indexOf("\u3147");function ma(e,t,n,o,r,u=null){if([...e].length!==1)return null;const i=de(n.get(e)||e);if(!i||i.jong!==0||i.cho===Jn)return null;const l=wt(Jn,i.jung,0),c=Zt({cho:Jn,jung:i.jung,jong:0},"jung",l,2,n);return c.length<2?null:{question:e,distractors:[l,...c]}}function ga(e){const t=new Map;for(const n of e){const o=[...n],r=o.length;if(!(r<2||r>3))for(let u=0;u<r;u++){let i=r+"|"+u+"|";for(let c=0;c<r;c++)i+=c===u?"*":o[c];const l=t.get(i);l?l.push(n):t.set(i,[n])}}return t}function _a(e,t,n,o,r,u=null,i=null,l=2){const c=[...e],f=c.length;if(f<2||f>3)return null;const h=c.map(b=>de(b));if(h.some(b=>!b))return null;const p=Xt(e,n,o);if(p.some(b=>!b))return null;const s=b=>n.get(b)??b,y=s(e),A=!!t&&(be(t.cho)||be(t.jung)||be(t.jong)),w=!!i&&(be(i.cho)||be(i.jung)||be(i.jong)),_=b=>{let k=f+"|"+b+"|";for(let D=0;D<f;D++)k+=D===b?"*":c[D];return k};let m;if(u!=null){if(u>=f||A&&!It(p[u],t))return null;m=[u]}else A?m=p.map((b,k)=>It(b,t)?k:-1).filter(b=>b>=0):m=Array.from({length:f},(b,k)=>k);for(const b of ie(m)){const k=r.get(_(b))??[],D=[],L=[];for(const P of k){if(P===e)continue;const ee=[...P].map(B=>de(B)),G=h[b],W=ee[b];if(!G||!W)continue;let F=0;if(G.cho!==W.cho&&F++,G.jung!==W.jung&&F++,G.jong!==W.jong&&F++,!(F<l||s(P)===y))if(w){const B=Xt(P,n,o)[b];B&&It(B,i)?D.push(P):L.push(P)}else D.push(P)}if(!D.length)continue;const x=ie(D)[0],I=[],$=new Set([y,s(x)]),U=w?L:D.filter(P=>P!==x);for(const P of ie(U)){const ee=s(P);if(!$.has(ee)&&($.add(ee),I.push(P),I.length>=2))break}if(!w&&I.length<2)for(const P of ie(k)){if(P===e||P===x)continue;const ee=s(P);if(!$.has(ee)&&($.add(ee),I.push(P),I.length>=2))break}if(!(I.length<2))return{question:e,distractors:[x,...I]}}return null}let wn=null,ur=null,ar=null;function Ea(){const e=kn();if(e&&e.entries.length>0){const t=Wt();if(wn&&ur===e&&ar===t)return wn;const n=new Set,o=[];for(const r of e.entries)!r.word||n.has(r.word)||(n.add(r.word),o.push({w:r.word,s:r.syllables,p:t?.[r.word]?[...t[r.word].cho??[],...t[r.word].jung??[],...t[r.word].jong??[]]:[],pron:r.pronunciation||r.word,grade:r.grade}));return wn=o,ur=e,ar=t,wn}return[]}const Xe=new Proxy([],{get(e,t){const n=Ea(),o=n[t];return typeof o=="function"?o.bind(n):o}});function Sn(e){return e.length?e[Math.floor(Math.random()*e.length)]:void 0}function Ze(e,t){if(t>=e.length)return ie(e);if(t===0)return[];const n=e.slice();for(let o=0;o<t;o++){const r=o+Math.floor(Math.random()*(n.length-o)),u=n[o];n[o]=n[r],n[r]=u}return n.slice(0,t)}let Qn=null,ir=null;function St(){const e=kn();if(Qn&&ir===e)return Qn;const t=new Map;for(const n of Xe)n.w&&t.set(n.w,n.pron);return Qn=t,ir=e,t}function Pe(e){return St().get(e)||e}function eo(e,t,n=new Set){const o=[];for(const r of ie(e)){if(o.length>=t)break;const u=Pe(r);n.has(u)||(n.add(u),o.push(r))}return o}let ba=0;function Me(e){return`${e}-rt-${++ba}`}function Jt(e){const t=Ko();if(!t||t.total===0){const o=new Set;for(const r of e)o.add(r);return o}const n=new Set;for(const o of e)Yu(o)===!0&&n.add(o);return n}const Nn=new Map;let lr=null,cr=null;function Qt(e){return e==null?"":Array.isArray(e)?e.slice().sort().join(","):e}function sr(e){const t=Qt(e.choseong),n=e.composition,o=n?.syllable==null?"":Array.isArray(n.syllable)?n.syllable.slice().sort().join(","):String(n.syllable),r=n?`${Qt(n.cho)}/${Qt(n.jung)}/${Qt(n.jong)}/${n.jongNone?"N":""}/${o}`:"",u=Qt(e.grade);return`${e.difficulty??""}|${t}|${r}|${e.excludeNoImage?"1":"0"}|${e.count??""}|x${e.contrastCount??1}|${e.fullCount?"F":""}|s${e.sameStructureOnly===!1?"0":"1"}|v${e.phonemeView==="pron"?"p":"c"}|g${u}|t${e.targetSyllable??""}|c${e.choicesPerItem??""}`}async function $e(e){const t=kn(),n=Wt();(t!==lr||n!==cr)&&(Nn.clear(),lr=t,cr=n);const o=sr(e);return Nn.has(o)||Nn.set(o,ka(e)),Nn.get(o)}function Aa(e){if(!e)return null;const t=i=>i==null?null:Array.isArray(i)?i.length?i:null:[i],n=t(e.cho),o=t(e.jung),r=!!e.jongNone,u=r?null:t(e.jong);return n||o||u||r?r&&!n&&!o&&!u?i=>ju(i):i=>$u(i,{cho:n,jung:o,jong:u,jongNone:r}):null}async function ka(e){const{difficulty:t=null,choseong:n=null,composition:o=null,targetSyllable:r=null,excludeNoImage:u=!1}=e,i=e.grade&&e.grade.length>0?new Set(e.grade):null,l=e.sameStructureOnly??!0,c=e.phonemeView==="pron"?"pron":"char",f=Math.max(1,e.contrastCount??1),h=t==="cho"||t==="jung"||t==="jong",p=h&&f>=2,s=t==="count",y=n?new Set(Array.isArray(n)?n:[n]):null,A=o?.syllable!=null?new Set(Array.isArray(o.syllable)?o.syllable:[o.syllable]):null,w=o?[Aa(o),A?S=>A.has(bn(S)):null].filter(S=>S!=null):[],_=t==="random"||t===null,m=_||s,b=_||p||s;let k=Xe.filter(S=>!S.w||i&&(!S.grade||!i.has(S.grade))?!1:b?!0:Array.isArray(S.p)&&S.p.length>0);y&&(k=k.filter(S=>{for(const j of y)if(Iu(S.w,j))return!0;return!1})),w.length>0&&(k=k.filter(S=>{const j=c==="pron"?Pe(S.w):S.w;return w.every(le=>le(j))})),r&&(k=k.filter(S=>S.w[0]===r));let D;if(u){const S=new Set;for(const j of k)if(S.add(j.w),Array.isArray(j.p))for(const le of j.p)S.add(le);if(m)for(const j of Xe)j.w&&S.add(j.w);D=Jt(S)}else{const S=new Set;for(const j of k)if(S.add(j.w),Array.isArray(j.p))for(const le of j.p)S.add(le);if(m)for(const j of Xe)j.w&&S.add(j.w);D=S}let L=null;if(p){const S=new Set;for(const j of Xe)j.w&&S.add(j.w);L=u?Jt(S):S}const x=k.filter(S=>D.has(S.w)),I=600,$=Array.from(D),U=$.length>I?Ze($,I):$,P=s&&o!=null&&(be(o.cho)||be(o.jung)||be(o.jong)),ee=2500,G=new Map;if(s&&!P&&f>=2){for(const S of $){const j=bn(S),le=G.get(j);le?le.push(S):G.set(j,[S])}for(const[S,j]of G)j.length>ee&&G.set(S,Ze(j,ee))}const W=Lu(),F=P?sa(o,$,W,l,c,Pe):null,B=500,v=1500,ge=e.fullCount?x:t==="random"?x.length>B?Ze(x,B):x:x.length>v?Ze(x,v):x,J=Wt(),te=[];for(const S of ge){let j;const le=Pe(S.w);if(p)j=Hu(S.w,t,f,L,24).filter(oe=>Pe(oe)!==le);else if(s)P?j=(F.get(S.w)??[]).filter(oe=>Pe(oe)!==le):f<=1?j=or(S.w,J,{okSet:D,pronOf:Pe,decompOf:W,sameStructureOnly:!1}):j=(G.get(bn(S.w))??[]).filter(oe=>{if(oe===S.w||Pe(oe)===le)return!1;const Y=zu(S.w,oe);return f>=5?Y>=5:Y===f});else if(_)j=U.filter(oe=>oe!==S.w&&oe.length===S.w.length&&Pe(oe)!==le);else{const oe=t;j=or(S.w,J,{kind:oe,okSet:D,pronOf:Pe,decompOf:W,sameStructureOnly:!1}),j.length===0&&(j=(U.length>30?Ze(U,30):U).filter(Y=>Y!==S.w&&Ru(S.w,Y)===t&&Pe(Y)!==le))}if(l&&j.length>0&&(h||s&&!P)){const oe=W(Pe(S.w));j=j.filter(Y=>!Xn(oe,W(Pe(Y))))}j.length!==0&&te.push({word:S,usable:j})}return te}async function dr(e,t){const{choicesPerItem:n=3,count:o=10}=t,r=n-1,u=(await $e(t)).filter(l=>l.usable.length>=r),i=[];for(const l of ie(u)){if(i.length>=o)break;const c=eo(l.usable,r);if(c.length<r)continue;const f=ie([l.word.w,...c]);i.push({id:Me(e+"-item"),index:i.length+1,word:l.word.w,syllables:l.word.s,choices:f,answerIndex:f.indexOf(l.word.w)})}return i}async function wa(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,r=await $e({...e,difficulty:null});if(r.length<t)return[];const u=[],i=ie([...r]);for(const l of i){if(u.length>=n)break;const c=l.word.w,f=[...l.word.pron||c],h=Sn(f);if(!h)continue;const p=r.filter(A=>A.word.w!==c&&A.word.s===l.word.s&&!(A.word.pron||A.word.w).includes(h)&&A.word.pron!==l.word.pron);if(p.length<o)continue;const s=eo(p.map(A=>A.word.w),o);if(s.length<o)continue;const y=ie([c,...s]);u.push({id:Me("HPI-item"),index:u.length+1,targetSyllable:h,word:c,choices:y,answerIndex:y.indexOf(c)})}return u}async function Sa(e){const{count:t=10}=e,n=(await $e(e)).filter(o=>o.usable.length>=1);return Array.from({length:t},(o,r)=>{const u=Sn(n);if(!u)return null;const i=r%2===0;let l;if(i)l=[u.word.w,u.word.w];else{const c=Sn(u.usable);l=Math.random()<.5?[u.word.w,c]:[c,u.word.w]}return{id:Me("SOD-item"),index:r+1,word:u.word.w,pair:l,same:i}}).filter(o=>!!o)}async function Na(e){const{choicesPerItem:t=3,count:n=10}=e,o=t-1,r=await $e({...e,difficulty:null});if(r.length<t+1)return[];const u=r.map(s=>s.word.w),i=new Map(r.map(s=>[s.word.w,s.word.pron])),l=s=>(i.get(s)||s)[0]??"",c={};for(const s of r){const y=l(s.word.w);y&&(c[y]||(c[y]=[]),c[y].push(s.word.w))}const f=Object.entries(c).filter(([,s])=>s.length>=2).map(([s])=>s);if(f.length===0)return[];const h=[],p=ie([...f]);for(let s=0;h.length<n&&s<n*4;s++){const y=p[s%p.length],A=c[y];if(A.length<2)continue;const w=ie([...A]),_=w[0],m=w[1];if(!_||!m||_===m||(i.get(_)||_)===(i.get(m)||m))continue;const b=i.get(m)||m,k=u.filter(x=>l(x)!==y&&x!==_&&x!==m&&x.length===m.length&&(i.get(x)||x)!==b);if(k.length<o)continue;const D=eo(k,o);if(D.length<o)continue;const L=ie([m,...D]);h.push({id:Me("SWS-item"),index:h.length+1,sourceWord:_,targetSyllable:y,word:m,choices:L,answerIndex:L.indexOf(m)})}return h}function hr(e,t,n){return Ze(e,t).map((o,r)=>{const u=Sn(o.usable)??"",i=[...o.word.w],l=[...u],c=i.findIndex((h,p)=>h!==l[p]),f=ie(o.usable.filter(h=>h&&h!==u)).slice(0,2);return{id:Me(n),index:r+1,word:o.word.w,original:o.word.w,changed:u,changedFrom:c>=0?i[c]:"",changedTo:c>=0?l[c]:"",distractors:f}})}async function pr(e,t,n){const{count:o=10}=t,r=St(),u=Xe.filter(y=>y.w&&y.s===e),i=t.excludeNoImage?Jt(u.map(y=>y.w)):null,l=i?u.filter(y=>i.has(y.w)):u,c=new Set(l.map(y=>y.w)),f=ga(c),h=t.phonemeView??"char",p=t.composition??null,s=[];for(const y of ie(l)){if(s.length>=o)break;const A=_a(y.w,p,r,h,f,null,null);if(!A)continue;const w=A.distractors[0],_=[...y.w],m=[...w],b=_.findIndex((k,D)=>k!==m[D]);s.push({id:Me(n),index:s.length+1,word:y.w,original:y.w,changed:w,changedFrom:b>=0?_[b]:"",changedTo:b>=0?m[b]:"",distractors:A.distractors.slice(1)})}return s}async function Ma(e){return pr(2,e,"CS2-item")}async function Ta(e){return pr(3,e,"CS3-item")}async function Ba(e){const t=(await $e({...e,difficulty:"count",contrastCount:1})).filter(n=>n.word.s===1&&n.usable.length>=1);return hr(t,e.count??10,"CP1-item")}async function Da(e){const t=e.difficulty&&e.difficulty!=="random"?e.difficulty:"count",n=(await $e({...e,difficulty:t,contrastCount:1})).filter(o=>o.word.s===2&&o.usable.length>=1);return hr(n,e.count??10,"CP2-item")}async function xa(e){const{count:t=10}=e,n=(await $e({...e})).filter(o=>o.word.s===2);return Ze(n,t).map((o,r)=>({id:Me("M2S-item"),index:r+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function va(e){const{count:t=10}=e,n=(await $e({...e})).filter(o=>o.word.s===3);return Ze(n,t).map((o,r)=>({id:Me("M3S-item"),index:r+1,word:o.word.w,answer:o.word.w,parts:[...o.word.w]}))}async function Oa(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s===2),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=pa(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=[...l.word.w],s=p[0]===f?p[1]:p[0];i.push({id:Me("D2-item"),index:i.length+1,original:l.word.w,word:l.word.w,dropped:s,missingResult:f,distractors:h})}return i}async function La(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s===3),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=fa(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=[...l.word.w];let s="";for(let y=0;y<p.length;y++)if(p.filter((A,w)=>w!==y).join("")===f){s=p[y];break}i.push({id:Me("D3-item"),index:i.length+1,original:l.word.w,word:l.word.w,dropped:s,missingResult:f,distractors:h})}return i}async function Ra(e){const{count:t=10}=e,n=(await $e({...e})).filter(l=>l.word.s>=2),o=St(),r=new Set(Xe.map(l=>l.w)),u=e.phonemeView??"char",i=[];for(const l of ie(n)){if(i.length>=t)break;const c=Ca(l.word.w,e.composition??null,o,u,r);if(!c)continue;const[f,...h]=c.distractors,p=l.word.w,s=p.startsWith(f)?p.slice(f.length):p.endsWith(f)?p.slice(0,p.length-f.length):"";i.push({id:Me("DPC-item"),index:i.length+1,original:p,word:p,dropped:s,missingResult:f,distractors:h})}return i}async function Ia(e){const{count:t=10}=e,n=(await $e({...e})).map(o=>o.word.w);return n.length<3?[]:Array.from({length:t},(o,r)=>{const u=Ze(n,3);return{id:Me("LRO-item"),index:r+1,sequence:u,choices:ie(u)}})}function Mn(e,t,n){const o=Xe.filter(i=>i.w&&i.s===e),r=t?Jt(o.map(i=>i.w)):null,u=[];for(const i of o)if(!(r&&!r.has(i.w))){if(n){const l=de(i.w);if(!l||!n(l))continue}u.push(i)}return u}function ja(e){const t=Mn(1,e.excludeNoImage??!1,n=>n.jong===0);return Ze(t,e.count??10).map((n,o)=>{const r=de(n.w);return{id:Me("M2P-item"),index:o+1,parts:[Ne[r.cho],st[r.jung]],answer:n.w,word:n.w}})}function Pa(e){const t=Mn(1,e.excludeNoImage??!1,n=>n.jong>0&&!Yt[n.jong]);return Ze(t,e.count??10).map((n,o)=>{const r=de(n.w);return{id:Me("M3P-item"),index:o+1,parts:[Ne[r.cho],st[r.jung],Ge[r.jong]],answer:n.w,word:n.w}})}function $a(e){const t=tr.DROP_FINAL_CONSONANT_FROM_1SYLL,n=Mn(t.syllables,e.excludeNoImage??!1,t.syllable),o=St(),r=[];for(const u of ie(n)){if(r.length>=(e.count??10))break;const i=ya(u.w,null,o);if(!i)continue;const[l,...c]=i.distractors;r.push({id:Me("DFC-item"),index:r.length+1,original:u.w,word:u.w,result:l,distractors:c})}return r}function Fa(e){const t=tr.REMOVE_CONSONANT_AND_IDENTIFY_PHONEME,n=Mn(t.syllables,e.excludeNoImage??!1,t.syllable),o=St(),r=[];for(const u of ie(n)){if(r.length>=(e.count??10))break;const i=ma(u.w,null,o);if(!i)continue;const l=de(o.get(u.w)||u.w);if(!l)continue;const[c,...f]=i.distractors;r.push({id:Me("RCP-item"),index:r.length+1,base:u.w,word:u.w,missingConsonant:Ne[l.cho],remaining:c,distractors:f})}return r}const Tn=new Map;let fr=null,Cr=null;async function yr(e,t={}){const n=kn(),o=Wt();(n!==fr||o!==Cr)&&(Tn.clear(),fr=n,Cr=o);const r=`${e}:${sr(t)}`;if(Tn.has(r))return Tn.get(r);const u=await za(e,t);return Tn.set(r,u),u}const Ha={SAME_SOUND_PICK:e=>dr("SSP",e),HEAR_AND_PICK_SAME:e=>dr("HPS",e),HEAR_AND_PICK_INCLUDED:e=>wa(e),SAME_OR_DIFF:e=>Sa(e),STARTS_WITH_SAME_SOUND:e=>Na(e),LISTEN_AND_REMEMBER_ORDER:e=>Ia(e),MERGE_2_SYLLABLES:e=>xa(e),MERGE_3_SYLLABLES:e=>va(e),MERGE_2_PHONEMES:e=>ja(e),MERGE_3_PHONEMES:e=>Pa(e),DROP_1_FROM_2SYLL:e=>Oa(e),DROP_1_FROM_3SYLL:e=>La(e),DROP_PART_FROM_COMPOUND:e=>Ra(e),DROP_FINAL_CONSONANT_FROM_1SYLL:e=>$a(e),REMOVE_CONSONANT_AND_IDENTIFY_PHONEME:e=>Fa(e),CHANGE_1_SYLL_IN_2SYLL:e=>Ma(e),CHANGE_1_SYLL_IN_3SYLL:e=>Ta(e),CHANGE_1_PHONEME_IN_1SYLL:e=>Ba(e),CHANGE_1_PHONEME_IN_2SYLL:e=>Da(e)};async function za(e,t={}){const n=Ha[e];return n?await n(t):[]}async function Va(e){const t=[null,"count"],n=Object.keys(Wn);let o=0;for(const r of t)for(const u of n){const i=Wn[u];yr(u,{difficulty:i.difficulty?r:null,choseong:null,count:10,excludeNoImage:e}).catch(()=>{}),++o%6===0&&await new Promise(l=>setTimeout(l,0))}}async function Ua(e){return(await $e({...e,fullCount:!0})).length}async function Ga(e={}){const t=[];for(const l of Xe)l.w&&t.push(l.w);const n=e.excludeNoImage?Jt(t):t,o=new Set,r=new Set,u=new Set,i=new Set;for(const l of n){i.add(bn(l));for(const c of l){const f=de(c);if(f&&(Ne[f.cho]!=="\u3147"&&o.add(Ne[f.cho]),r.add(st[f.jung]),f.jong>0)){u.add(Ge[f.jong]);const h=Yt[f.jong];h&&h.forEach(p=>u.add(p))}}}return{cho:o,jung:r,jong:u,syllable:i}}const Nt="\uC804\uCCB4";function Ya(...e){return e.filter(Boolean).join(" ")}/**
2
2
  * @license lucide-react v1.38.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.