@project-sunbird/collection-editor-react 1.0.7 → 1.0.9
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/collection-editor.umd.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +7 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -533,7 +533,7 @@ to {
|
|
|
533
533
|
`);return o===-1?"":s.stack.slice(o+1)})();try{if(!n.stack)n.stack=i;else if(i){const o=i.indexOf(`
|
|
534
534
|
`),a=o===-1?-1:i.indexOf(`
|
|
535
535
|
`,o+1),c=a===-1?"":i.slice(a+1);String(n.stack).endsWith(c)||(n.stack+=`
|
|
536
|
-
`+i)}}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=gn(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&Li.assertOptions(n,{silentJSONParsing:St.transitional(St.boolean),forcedJSONParsing:St.transitional(St.boolean),clarifyTimeoutError:St.transitional(St.boolean),legacyInterceptorReqResOrdering:St.transitional(St.boolean),advertiseZstdAcceptEncoding:St.transitional(St.boolean),validateStatusUndefinedResolves:St.transitional(St.boolean)},!1),s!=null&&(L.isFunction(s)?r.paramsSerializer={serialize:s}:Li.assertOptions(s,{encode:St.function,serialize:St.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Li.assertOptions(r,{baseUrl:St.spelling("baseURL"),withXsrfToken:St.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&L.merge(i.common,i[r.method]);i&&L.forEach(["delete","get","head","post","put","patch","query","common"],b=>{delete i[b]}),r.headers=kt.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const v=r.transitional||Ol;v&&v.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let d,f=0,m;if(!c){const b=[eu.bind(this),void 0];for(b.unshift(...a),b.push(...u),m=b.length,d=Promise.resolve(r);f<m;)d=d.then(b[f++],b[f++]);return d}m=a.length;let p=r;for(;f<m;){const b=a[f++],h=a[f++];try{p=b(p)}catch(v){h.call(this,v);break}}try{d=eu.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,m=u.length;f<m;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=gn(this.defaults,t);const r=ch(t.baseURL,t.url,t.allowAbsoluteUrls,t);return sh(r,t.params,t.paramsSerializer)}};L.forEach(["delete","get","head","options"],function(t){hn.prototype[t]=function(r,n){return this.request(gn(n||{},{method:t,url:r,data:n&&L.hasOwnProp(n,"data")?n.data:void 0}))}});L.forEach(["post","put","patch","query"],function(t){function r(n){return function(i,o,a){return this.request(gn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}hn.prototype[t]=r(),t!=="query"&&(hn.prototype[t+"Form"]=r(!0))});let Yx=class hh{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{n.subscribe(a),i=a}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},t(function(i,o,a){n.reason||(n.reason=new si(i,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new hh(function(s){t=s}),cancel:t}}};function Zx(e){return function(r){return e.apply(null,r)}}function Xx(e){return L.isObject(e)&&e.isAxiosError===!0}const Ha={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ha).forEach(([e,t])=>{Ha[t]=e});function ph(e){const t=new hn(e),r=Vf(hn.prototype.request,t);return L.extend(r,hn.prototype,t,{allOwnKeys:!0}),L.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return ph(gn(e,s))},r}const rt=ph(ni);rt.Axios=hn;rt.CanceledError=si;rt.CancelToken=Yx;rt.isCancel=ah;rt.VERSION=jl;rt.toFormData=xo;rt.AxiosError=J;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=Zx;rt.isAxiosError=Xx;rt.mergeConfig=gn;rt.AxiosHeaders=kt;rt.formToJSON=e=>oh(L.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=fh.getAdapter;rt.HttpStatusCode=Ha;rt.default=rt;const{Axios:zq,AxiosError:Vq,CanceledError:Hq,isCancel:Qq,CancelToken:Wq,VERSION:Gq,all:Kq,Cancel:Yq,isAxiosError:Zq,spread:Xq,toFormData:Jq,AxiosHeaders:e$,HttpStatusCode:t$,formToJSON:r$,getAdapter:n$,mergeConfig:s$,create:i$}=rt;let Qa="";function mh(e){Qa=e}const Fe=rt.create({timeout:3e4});function Jx(e,t){if(!e||typeof t!="string"||!t.trim())return e;const r=t.trim().replace(/\/+$/,""),n=r.startsWith("/")?r:`/${r}`;return e.replace(/^\/(action|api|portal)(?=\/|$)/,n)}Fe.interceptors.request.use(async e=>{var s,i,o;const{useEditorStore:t}=await Promise.resolve().then(()=>ub),r=t.getState(),n=(s=r.editorConfig)==null?void 0:s.context;return e.headers=e.headers??{},n!=null&&n.authToken&&(e.headers.Authorization=`Bearer ${n.authToken}`),n!=null&&n.userToken&&(e.headers["X-Authenticated-User-Token"]=n.userToken),n!=null&&n.channel&&(e.headers["X-Channel-Id"]=n.channel),e.url=Jx(e.url,(o=(i=r.editorConfig)==null?void 0:i.config)==null?void 0:o.apiSlug),Qa&&(e.baseURL=Qa),e});const gh="/portal";async function vh(e){var n,s,i,o,a,c,u;const t=await Fe.get(`${gh}/questionset/v2/hierarchy/${e}`,{params:{mode:"edit"}}),r=(s=(n=t.data)==null?void 0:n.result)==null?void 0:s.questionset;if(!r||!r.identifier){const d=((o=(i=t.data)==null?void 0:i.params)==null?void 0:o.errmsg)||((c=(a=t.data)==null?void 0:a.params)==null?void 0:c.err)||((u=t.data)==null?void 0:u.responseCode)||`No questionset returned for "${e}"`;throw new Error(`Unable to load questionset hierarchy: ${d}`)}return r}async function e0(e){var r,n;return e.length?((n=(r=(await Fe.post(`${gh}/question/v2/list`,{request:{search:{identifier:e}}})).data)==null?void 0:r.result)==null?void 0:n.questions)??[]:[]}function Eo(e,t){const r=e??{},n=r.identifier??"",s=r.objectType??"",i=r.mimeType??"",o=r.children,a=Array.isArray(o)?o.map(u=>Eo(u,n)):[],c=i==="application/vnd.ekstep.content-collection"||s.toLowerCase().includes("unit")||s.toLowerCase().includes("textbook")||s.toLowerCase().includes("collection")||s.toLowerCase().includes("course")||s.toLowerCase().includes("lesson")||r.visibility==="Parent"||i==="application/vnd.sunbird.questionset"&&a.length>0;return{id:n,identifier:n,name:r.name??"Untitled",title:r.name??"Untitled",description:r.description,primaryCategory:r.primaryCategory,mimeType:r.mimeType,objectType:s,contentType:r.contentType,visibility:r.visibility,status:r.status,appIcon:r.appIcon,isFolder:c,children:a,metadata:r,parent:t}}async function yh(e){var s,i,o,a,c,u,d;const t=await Fe.get(`/action/collection/v1/hierarchy/${e}`,{params:{mode:"edit"}}),r=(i=(s=t.data)==null?void 0:s.result)==null?void 0:i.content;if(!r||!r.identifier){const f=((a=(o=t.data)==null?void 0:o.params)==null?void 0:a.errmsg)||((u=(c=t.data)==null?void 0:c.params)==null?void 0:u.err)||((d=t.data)==null?void 0:d.responseCode)||`No content returned for "${e}"`;throw new Error(`Unable to load hierarchy: ${f}`)}const n=Eo(r);return{content:r,rootNode:n}}async function t0(e){const t=await vh(e),r=Eo(t);return{content:t,rootNode:r}}async function r0(e,t,r,n){var i;return((i=(await Fe.patch("/action/collection/v1/hierarchy/update",{request:{data:{nodesModified:t,hierarchy:r,...n?{lastUpdatedBy:n}:{}}}})).data)==null?void 0:i.result)??{}}async function n0(e,t=""){await Fe.post(`/action/content/v3/publish/${e}`,{request:{content:{lastPublishedBy:t}}})}async function bh(e){var n,s,i,o,a,c,u;const t=await Fe.get(`/action/course/v1/hierarchy/${e}`,{params:{mode:"edit"}}),r=(s=(n=t.data)==null?void 0:n.result)==null?void 0:s.content;if(!r||!r.identifier){const d=((o=(i=t.data)==null?void 0:i.params)==null?void 0:o.errmsg)||((c=(a=t.data)==null?void 0:a.params)==null?void 0:c.err)||((u=t.data)==null?void 0:u.responseCode)||`No course returned for "${e}"`;throw new Error(`Unable to load course hierarchy: ${d}`)}return r}async function s0(e){var r,n;return(n=(r=(await Fe.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}async function i0(e){await Fe.post(`/action/content/v3/review/${e}`,{request:{content:{}}})}async function o0(e,t){await Fe.post(`/action/content/v3/reject/${e}`,{request:{content:{rejectComment:t}}})}async function a0(e,t){await Fe.patch(`/action/content/v1/collaborator/update/${e}`,{request:{content:{collaborators:t}}})}const l0="application/vnd.sunbird.questionset";function Ch(e){let t=!1,r=!0;function n(s){for(const i of s){const o=i.children??[];if(o.length>0){n(o);continue}t=!0,i.objectType==="QuestionSet"&&i.mimeType===l0||(r=!1)}}return n(e.children??[]),t&&r}const ru=new Map;async function Sh(e){const t=ru.get(e);if(t)return t;const r=await bh(e),{children:n,...s}=r??{},i={qualifies:Ch(r),meta:s};return ru.set(e,i),i}async function _h(e){return(await Sh(e)).qualifies}async function c0(e){var n;const t=e.children??[],r=[];for(let s=0;s<t.length;s++){const i=t[s],o=i.children??[],a=[];for(const c of o){let u=!!((n=c.metadata)!=null&&n.isAssessmentCourse);if(!u){if((c.children??[]).length>0)u=Ch(c);else if(o.length===1&&(s===0||s===t.length-1))try{u=await _h(c.identifier)}catch(d){console.error("[lpStructure] assessment-course check failed on load:",d)}}a.push({...c,isFolder:!1,children:[],metadata:{...c.metadata??{},...u?{isAssessmentCourse:!0}:{}}})}r.push({...i,children:a})}return{...e,children:r}}function lt(e){var r,n;const t=(e==null?void 0:e.children)??[];return t.length===1&&!!((n=(r=t[0])==null?void 0:r.metadata)!=null&&n.isAssessmentCourse)}function u0(e,t,r){return r?e===0?"pre":e===t-1?"post":"levelAssessment":"content"}function d0(e,t){const r=e.findIndex(s=>s.id===t);return r===-1?null:Bs(e,r)?{role:r===0?"pre":"post",levelNumber:null}:{role:"level",levelNumber:e.slice(0,r+1).filter((s,i)=>!Bs(e,i)).length}}function Ms(e,t){return t==="pre"?e.length>0&<(e[0]):e.length>1&<(e[e.length-1])}function Bs(e,t){const r=u0(t,e.length,lt(e[t]));return r==="pre"||r==="post"}function Wa(e,t){const r=t?e.findIndex(n=>n.id===t.id):-1;return r!==-1&&Bs(e,r)}function f0(e){return Ms(e,"pre")?Ms(e,"post")?null:"post":"pre"}function h0(e,t,r){if(t<0||t>=e.length)return!1;const n=lt(e[0])?e[0]:null,s=e.length>1&<(e[e.length-1])?e[e.length-1]:null;if(!n&&!s)return!0;const i=[...e],[o]=i.splice(t,1);return i.splice(r,0,o),!(n&&i[0]!==n||s&&i[i.length-1]!==s)}function nu(e,t,r){return r?!1:t?!((e==null?void 0:e.children)??[]).some(s=>{var i;return!!((i=s.metadata)!=null&&i.isAssessmentCourse)}):!0}function vn(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function wh(e,t){var n,s;return e?((n=t[e.id])==null?void 0:n.framework)??((s=e.metadata)==null?void 0:s.framework):void 0}function xh(e,t){return!!wh(e,t)}function Th(e,t){if(!e||!t)return[];const r=new Set,n=e.children??[];return n.forEach((s,i)=>{var o,a;Bs(n,i)?vn((o=s.children[0].metadata)==null?void 0:o[t]).forEach(c=>r.add(c)):vn((a=s.metadata)==null?void 0:a[t]).forEach(c=>r.add(c))}),Array.from(r)}function p0(e,t,r){var u,d;if(!e||!t)return null;const n=Th(e,t),s=((u=r[e.id])==null?void 0:u[t])??((d=e.metadata)==null?void 0:d[t]),i=vn(s),o=[...n].sort(),a=[...i].sort();return o.length===a.length&&o.every((f,m)=>f===a[m])?null:n}function m0(e,t,r){if(!e||!t||r.length===0)return[];const n=e.children??[];return n.filter((s,i)=>{var a;return Bs(n,i)?!1:vn((a=s.metadata)==null?void 0:a[t]).some(c=>!r.includes(c))})}function Eh(e,t,r){var s;if(!e||!r||t.length===0)return[];const n=new Set;for(const i of e.children??[])vn((s=i.metadata)==null?void 0:s[r]).forEach(o=>n.add(o));return t.filter(i=>!n.has(i))}const Ah=new Set(["adaptive"]);function Rl(e,t,r,n={}){var b,h,v,y;const s=[];if(!e)return s;const i=((b=n[e.id])==null?void 0:b.policy)??((h=e.metadata)==null?void 0:h.policy);i||s.push({code:"policyMissing",message:"Set a consumption policy for this path."});const o=e.children??[],a=o[0],c=o.length>1?o[o.length-1]:void 0,u=lt(a),d=lt(c);!u&&i&&Ah.has(i)&&s.push({code:"priorAssessmentRequired",message:"A Prior Assessment is required for the Adaptive policy."}),[[a,"Prior Assessment"],[c,"Outcome Assessment"]].forEach(([C,S])=>{var x,T;if(!C)return;const _=C.children??[];(_.length!==1||!((T=(x=_[0])==null?void 0:x.metadata)!=null&&T.isAssessmentCourse))&&s.push({code:"slotNotPure",nodeId:C.id,message:`${S} must contain exactly one question-set-only course.`})});const f=new Set,m=(C,S)=>{f.has(C)&&s.push({code:"duplicateCourse",nodeId:S,message:"A course appears more than once in this path."}),f.add(C)},p=o.slice(u?1:0,o.length-(d?1:0));u&&m(a.children[0].id,a.id),d&&m(c.children[0].id,c.id);for(const C of p){const S=C.children??[],_=S.length===0;_&&s.push({code:"emptyLevel",nodeId:C.id,message:`"${C.name}" has no courses yet.`});const x=t?vn((v=C.metadata)==null?void 0:v[t]):[];if(x.length===0)_||s.push({code:"levelMissingSkills",nodeId:C.id,message:`"${C.name}" needs at least one skill selected.`});else{if(r.length>0){const D=x.filter(E=>!r.includes(E));D.length>0&&s.push({code:"levelSkillsOutOfScope",nodeId:C.id,message:`"${C.name}" has skills outside the current scope: ${D.join(", ")}.`})}const T=Eh(C,x,t);T.length>0&&s.push({code:"levelSkillsUncovered",nodeId:C.id,message:`"${C.name}" has no course covering: ${T.join(", ")}.`})}for(const T of S)m(T.id,C.id),(t?vn((y=T.metadata)==null?void 0:y[t]):[]).length===0&&s.push({code:"courseMissingSkillTag",nodeId:T.id,message:`"${T.name}" has no skill tag.`})}return s}async function g0(e){const t=[],r=(e==null?void 0:e.children)??[],n=r[0],s=r.length>1?r[r.length-1]:void 0;for(const[i,o]of[[n,"Prior Assessment"],[s,"Outcome Assessment"]]){if(!i||!lt(i))continue;const a=i.children[0].id;await _h(a)||t.push({code:"slotCourseChanged",nodeId:i.id,message:`${o}'s course is no longer question-set-only — pick a different course.`})}return t}function Nt(e,t){const r=[...e];for(;r.length>0;){const n=r.shift();if(n.id===t)return n;n.children&&r.push(...n.children)}}function kh(e,t,r=0){var n;for(const s of e){if(s.id===t)return r;if((n=s.children)!=null&&n.length){const i=kh(s.children,t,r+1);if(i>=0)return i}}return-1}const su=new Set(["name","appIcon","description","keywords","trackable","qrCodeProcessId","reservedDialcodes"]);function Ih(e,t,r,n){return e.map(s=>{if(s.id===t){const i=r.metadata??{},o=n!=null&&n.length?new Set([...su,...n]):su,a={};for(const c of o)c in r&&(a[c]=r[c]);return{...s,...r,metadata:{...s.metadata??{},...a,...i}}}return s.children&&s.children.length>0?{...s,children:Ih(s.children,t,r,n)}:s})}function Oi(e,t,r){return e.map(n=>n.id===t?{...n,children:[...n.children??[],r]}:n.children&&n.children.length>0?{...n,children:Oi(n.children,t,r)}:n)}function Dh(e,t,r,n){return e.map(s=>{if(s.id===t){const i=[...s.children??[]];return i.splice(n,0,r),{...s,children:i}}return s.children&&s.children.length>0?{...s,children:Dh(s.children,t,r,n)}:s})}function Ga(e,t){return e.filter(r=>r.id!==t).map(r=>({...r,children:r.children?Ga(r.children,t):[]}))}function Ka(e,t,r,n){return e.map(s=>{if(s.id===t){const i=[...s.children??[]],[o]=i.splice(r,1);return i.splice(n,0,o),{...s,children:i}}return s.children&&s.children.length>0?{...s,children:Ka(s.children,t,r,n)}:s})}function Lh(e,t){return e.map(r=>{const n=t[r.id]??r.id,s=r.parent?t[r.parent]??r.parent:r.parent;return{...r,id:n,identifier:n,parent:s,children:r.children?Lh(r.children,t):[]}})}function v0(e){let t=0;const r=[...e];for(;r.length>0;){const n=r.shift();n.isFolder||t++,n.children&&r.push(...n.children)}return t}function y0(e,t){const r=Nt(e,t);if(!r)return[];const n=[];let s=r;for(;s;)n.unshift({id:s.id,name:s.name}),s=s.parent?Nt(e,s.parent):void 0;return n}const re=ei((e,t)=>({treeData:[],selectedNodeId:null,treeCache:{},breadcrumb:[],activeNodeMeta:{},setTreeData:r=>{var s;const n=((s=r[0])==null?void 0:s.id)??null;e({treeData:r,selectedNodeId:n}),n&&setTimeout(()=>t().selectNode(n),0)},selectNode:r=>{const{treeData:n,treeCache:s,getBreadcrumb:i}=t(),o=Nt(n,r),a=i(r),c={...(o==null?void 0:o.metadata)??{},...s[r]??{}};K.getState().setNodeFlags({isFolder:(o==null?void 0:o.isFolder)??!1,isRoot:!(o!=null&&o.parent),isQuml:!1}),yr.getState().setActiveAssessmentSlot(null),e({selectedNodeId:r,breadcrumb:a,activeNodeMeta:c})},updateNode:(r,n,s)=>{if(e(i=>({treeData:Ih(i.treeData,r,n,s),treeCache:{...i.treeCache,[r]:{...i.treeCache[r]??{},...n}}})),t().selectedNodeId===r){const i=Nt(t().treeData,r);e(o=>({activeNodeMeta:{...(i==null?void 0:i.metadata)??{},...o.treeCache[r]??{}}}))}t().markDirty()},addNode:(r,n)=>{var m,p,b;const s=t(),i=K.getState().editorProfile,o=((p=(m=K.getState().editorConfig)==null?void 0:m.config)==null?void 0:p.maxDepth)??i.maxDepth,a=kh(s.treeData,r);if(a>=o)return console.warn(`[tree.store] addNode: depth would exceed maxDepth (${o}). parentDepth=${a}`),"";const c="temp-"+Math.random().toString(36).slice(2),u={id:c,identifier:c,name:i.defaultUnitName,isFolder:!0,children:[],parent:r,metadata:{mimeType:"application/vnd.ekstep.content-collection",code:c,name:i.defaultUnitName,contentType:i.unitContentType,primaryCategory:i.unitPrimaryCategory,visibility:"Parent"}},d=((b=Nt(s.treeData,r))==null?void 0:b.children)??[],f=i.derivedRoles&&Ms(d,"post");return e(h=>({treeData:f?Dh(h.treeData,r,u,d.length-1):Oi(h.treeData,r,u),treeCache:{...h.treeCache,[c]:{...u.metadata,isNew:!0}}})),setTimeout(()=>t().selectNode(c),0),c},deleteNode:r=>{var s;const n=(s=t().treeData[0])==null?void 0:s.id;r!==n&&e(i=>({treeData:Ga(i.treeData,r),selectedNodeId:i.selectedNodeId===r?null:i.selectedNodeId}))},reorderChildren:(r,n,s)=>{var a;const i=K.getState().editorProfile,o=(a=t().treeData[0])==null?void 0:a.id;if(i.derivedRoles&&r===o){const c=Nt(t().treeData,r);if(c!=null&&c.children&&!h0(c.children,n,s))return}e(c=>({treeData:Ka(c.treeData,r,n,s)}))},moveNode:(r,n,s)=>{var u,d,f;const i=K.getState().editorProfile,o=Nt(t().treeData,r),a=Nt(t().treeData,s);if(!(a!=null&&a.isFolder))return;const c=(u=t().treeData[0])==null?void 0:u.id;if(!(i.derivedRoles&&(o!=null&&o.isFolder)&&s!==c)){if(i.derivedRoles&&o&&!o.isFolder){const m=!!((d=o.metadata)!=null&&d.isAssessmentCourse),p=((f=t().treeData[0])==null?void 0:f.children)??[];if(!nu(a,m,Wa(p,a)))return}e(m=>{const p=Nt(m.treeData,r);if(!p)return m;let b=Ga(m.treeData,r);return b=Oi(b,s,{...p,parent:s}),{treeData:b}}),t().markDirty()}},addResource:(r,n,s)=>{var b,h,v,y,C,S;const i=K.getState().editorConfig,o=K.getState().editorProfile,a=(b=t().treeData[0])==null?void 0:b.id,c=!!(s!=null&&s.isAssessmentCourse);if(o.derivedRoles&&n===a){if(!c||Nt(t().treeData,r.identifier))return!1;const _=t().treeData[0],x=(_==null?void 0:_.children)??[],T=(s==null?void 0:s.slot)??f0(x);if(!T||Ms(x,T))return!1;const D=t().addNode(a,"unit");if(!D)return!1;const{learningPath:E}=kl.getState().labelConfig;if(t().updateNode(D,{name:T==="pre"?E.priorAssessmentLabel:E.outcomeAssessmentLabel}),T==="pre"){const j=(((v=(h=t().treeData[0])==null?void 0:h.children)==null?void 0:v.length)??1)-1;e(P=>({treeData:Ka(P.treeData,a,j,0)}))}return t().addResource(r,D,s)}if(!(((y=i==null?void 0:i.config)==null?void 0:y.allowContentUnderRoot)??!1)&&n===a||Nt(t().treeData,r.identifier))return!1;const d=Nt(t().treeData,n);if(!(d!=null&&d.isFolder))return!1;if(o.derivedRoles){const _=((C=t().treeData[0])==null?void 0:C.children)??[];if(!nu(d,c,Wa(_,d)))return!1}const f=((S=i==null?void 0:i.config)==null?void 0:S.maxContentsLimit)??1200;if(v0(t().treeData)>=f)return!1;const p={id:r.identifier,identifier:r.identifier,name:r.name,isFolder:!1,children:[],parent:n,mimeType:r.mimeType,primaryCategory:r.primaryCategory,contentType:r.contentType,appIcon:r.appIcon,status:r.status,metadata:{...r,...c?{isAssessmentCourse:!0}:{}}};return e(_=>({treeData:Oi(_.treeData,n,p)})),t().markDirty(),!0},markDirty:()=>{const{editorMode:r,setIsDirty:n}=K.getState();r==="edit"&&n(!0)},pruneCoursesByFramework:r=>{let n=0;return e(s=>{const i=s.treeData[0];if(!i)return s;const o=[];for(const a of i.children??[]){const c=lt(a),u=(a.children??[]).filter(d=>{var p;if(d.isFolder)return!0;const f=(p=d.metadata)==null?void 0:p.framework,m=!f||(Array.isArray(f)?f.includes(r):f===r);return m||n++,m});c&&u.length===0||o.push(u.length===(a.children??[]).length?a:{...a,children:u})}return n===0?s:{treeData:[{...i,children:o}]}}),n>0&&t().markDirty(),n},clearLevelSkills:r=>{if(!r)return 0;let n=0;return e(s=>{const i=s.treeData[0];if(!i)return s;const o={...s.treeCache},a=(i.children??[]).map(c=>{var m,p;if(!(((m=c.metadata)==null?void 0:m[r])!==void 0||((p=o[c.id])==null?void 0:p[r])!==void 0))return c;n++;const{[r]:d,...f}=c.metadata??{};if(o[c.id]){const{[r]:b,...h}=o[c.id];o[c.id]=h}return{...c,metadata:f}});return n===0?s:{treeData:[{...i,children:a}],treeCache:o}}),n>0&&t().markDirty(),n},replaceNodeIds:r=>{!r||Object.keys(r).length===0||e(n=>{const s=Lh(n.treeData,r),i={};for(const[a,c]of Object.entries(n.treeCache)){const u=r[a]??a,{isNew:d,...f}=c;i[u]=f}const o=n.selectedNodeId?r[n.selectedNodeId]??n.selectedNodeId:null;return{treeData:s,treeCache:i,selectedNodeId:o}})},getNodeById:r=>Nt(t().treeData,r),getChildrenOf:r=>{const n=Nt(t().treeData,r);return(n==null?void 0:n.children)??[]},getBreadcrumb:r=>y0(t().treeData,r)})),b0="_spin_1ah4d_9",C0={spin:b0};function oe(){return kl(e=>e.labelConfig)}const S0=({size:e=16,color:t="currentColor"})=>{const r=oe();return l.jsx("svg",{className:C0.spin,width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-label":r.spinner.loading,role:"status",children:l.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"3",strokeDasharray:"31.4",strokeDashoffset:"10",strokeLinecap:"round"})})},Re=({variant:e="ghost",size:t="md",isLoading:r,disabled:n,onClick:s,children:i,className:o,type:a="button"})=>l.jsxs("button",{type:a,className:`sbx-btn-${e} ${t==="sm"?"sbx-btn-sm":""} ${o??""}`,onClick:s,disabled:r||n,"aria-busy":r?!0:void 0,children:[r?l.jsx(S0,{size:14}):null,i]}),Oh=({size:e=16,...t})=>l.jsxs("svg",{width:e,height:e,viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("circle",{cx:"58",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"4"}),l.jsx("circle",{cx:"8",cy:"58",r:"4",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{d:"M52 12 H24 A12 12 0 0 0 24 36 H40 A12 12 0 0 1 40 60 H12",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]});async function iu(e){var r,n;return(n=(r=(await Fe.get(`/action/framework/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.framework}async function _0(e){var r,n;return((n=(r=(await Fe.post("/action/composite/v3/search",{request:{filters:{objectType:"Framework",status:["Live"],...e.type?{type:e.type}:{},...e.identifier?{identifier:e.identifier}:{},...e.channel?{channel:e.channel}:{},...e.systemDefault?{systemDefault:e.systemDefault}:{}}}})).data)==null?void 0:r.result)==null?void 0:n.Framework)??[]}function Ao(e,t){const r=Jn({queryKey:["framework",e],queryFn:()=>iu(e),enabled:!!e,staleTime:3e5}),n=t==null?void 0:t[0],s=Jn({queryKey:["framework",n],queryFn:()=>iu(n),enabled:!!n,staleTime:300*1e3}),i=s.data?[s.data]:[];return{organisationFramework:r.data,targetFrameworks:i,isLoading:r.isLoading||s.isLoading}}function Nh(e){if(!(e!=null&&e.length))return null;const t=e.reduce((r,n)=>(n.index??-1/0)>(r.index??-1/0)?n:r);return{code:t.code,terms:t.terms??[]}}function w0(e){var n,s,i,o;const t=(n=e==null?void 0:e.children)==null?void 0:n[0];if(!lt(t))return;const r=(o=(i=(s=t==null?void 0:t.children)==null?void 0:s[0])==null?void 0:i.metadata)==null?void 0:o.framework;return Array.isArray(r)?r[0]:r}function lr(){var i;const e=K(o=>o.editorConfig),t=K(o=>o.contentFramework),r=re(o=>o.treeData),n=w0(r[0])??t??((i=e==null?void 0:e.context)==null?void 0:i.framework),{organisationFramework:s}=Ao(n);return Nh(s==null?void 0:s.categories)}function x0(e,t,r){var u,d,f,m;const n={scope:((t==null?void 0:t.terms)??[]).map(p=>p.name),source:"manual"};if(!t)return n;const s=(u=e==null?void 0:e.children)==null?void 0:u[0];if(!lt(s))return n;const i=(d=s==null?void 0:s.children)==null?void 0:d[0];if(!i)return n;const a=((f=r[i.id])==null?void 0:f[t.code])??((m=i.metadata)==null?void 0:m[t.code]);return{scope:Array.isArray(a)?a:a?[a]:[],source:"prior"}}function ii(){const e=lr(),t=re(n=>n.treeData),r=re(n=>n.treeCache);return g.useMemo(()=>x0(t[0],e,r),[t,e,r])}const T0="_overlay_kdzmi_1",E0="_modal_kdzmi_15",A0="_modalHeader_kdzmi_27",k0="_modalHeaderClose_kdzmi_37",I0="_modalBody_kdzmi_55",D0="_modalFooter_kdzmi_62",L0="_checkRow_kdzmi_69",O0="_formGroup_kdzmi_112",N0="_textarea_kdzmi_123",j0="_sliderGroup_kdzmi_144",P0="_sliderValue_kdzmi_156",R0="_sliderLabels_kdzmi_164",F0="_sectionTitle_kdzmi_172",Ae={overlay:T0,modal:E0,modalHeader:A0,modalHeaderClose:k0,modalBody:I0,modalFooter:D0,checkRow:L0,formGroup:O0,textarea:N0,sliderGroup:j0,sliderValue:P0,sliderLabels:R0,sectionTitle:F0},M0=({objectType:e,onConfirm:t,onCancel:r})=>{const n=oe(),s=re(b=>b.treeData[0]),i=re(b=>b.treeCache),o=lr(),{scope:a}=ii(),[c,u]=g.useState(null),d=Rl(s,o==null?void 0:o.code,a,i);g.useEffect(()=>{let b=!1;return u(null),g0(s).then(h=>{b||u(h)}),()=>{b=!0}},[s]);const f=c===null,m=[...d,...c??[]],p=!f&&m.length===0;return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",e]}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:m.length===0?l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:f?n.learningPath.verifyingAssessmentCourses:`${n.publishChecklist.confirmPublishPrefix} ${e}?`}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ae.sectionTitle,children:n.learningPath.resolveBeforePublishing}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:m.map((b,h)=>l.jsx("li",{children:b.message},`${b.code}-${b.nodeId??h}`))})]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(Re,{variant:"primary",onClick:t,disabled:!p,children:n.publishChecklist.yesButton})]})]})})},B0=({contentId:e,onConfirm:t,onCancel:r})=>{const n=oe(),s=K(m=>{var p,b;return(b=(p=m.editorConfig)==null?void 0:p.config)==null?void 0:b.objectType})||"Content",i=K(m=>m.editorProfile.key==="learningPath"),o=K(m=>m.publishChecklist)??[],[a,c]=g.useState({}),u=o.every(m=>a[m.code]),d=o.length===0||u,f=()=>{t()};return i?l.jsx(M0,{objectType:s,onConfirm:t,onCancel:r}):l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",s]}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:o.length===0?l.jsxs("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:[n.publishChecklist.confirmPublishPrefix," ",s,"?"]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ae.sectionTitle,children:n.publishChecklist.checklistInstructions}),o.map(m=>l.jsxs("label",{className:Ae.checkRow,children:[l.jsx("input",{type:"checkbox",checked:!!a[m.code],onChange:p=>c(b=>({...b,[m.code]:p.target.checked}))}),l.jsx("span",{children:m.label})]},m.code))]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(Re,{variant:"primary",onClick:f,disabled:!d,children:n.publishChecklist.yesButton})]})]})})},q0=({contentId:e,action:t,onConfirm:r,onCancel:n})=>{const s=oe(),[i,o]=g.useState(""),[a,c]=g.useState(7),u=t==="approve",d=u?s.qualityParamsModal.reviewQualityTitle:s.qualityParamsModal.rejectContentTitle,f=!u&&i.trim().length===0,m=()=>{u?r(i.trim(),a):r(i.trim())};return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"quality-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"quality-modal-title",children:d}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:n,"aria-label":s.qualityParamsModal.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:u?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ae.formGroup,children:[l.jsx("label",{htmlFor:"quality-score",children:s.qualityParamsModal.qualityScoreLabel}),l.jsxs("div",{className:Ae.sliderGroup,children:[l.jsx("input",{id:"quality-score",type:"range",min:0,max:10,step:1,value:a,onChange:p=>c(Number(p.target.value)),"aria-valuemin":0,"aria-valuemax":10,"aria-valuenow":a}),l.jsx("span",{className:Ae.sliderValue,children:a})]}),l.jsxs("div",{className:Ae.sliderLabels,children:[l.jsx("span",{children:s.qualityParamsModal.scorePoorLabel}),l.jsx("span",{children:s.qualityParamsModal.scoreExcellentLabel})]})]}),l.jsxs("div",{className:Ae.formGroup,children:[l.jsxs("label",{htmlFor:"quality-comment",children:[s.qualityParamsModal.commentLabel," ",l.jsx("span",{style:{fontWeight:400,color:"var(--sbx-gray-400, #9CA3AF)"},children:s.qualityParamsModal.optionalLabel})]}),l.jsx("textarea",{id:"quality-comment",className:Ae.textarea,placeholder:s.qualityParamsModal.commentPlaceholder,value:i,onChange:p=>o(p.target.value),rows:4})]})]}):l.jsxs("div",{className:Ae.formGroup,children:[l.jsxs("label",{htmlFor:"reject-reason",children:[s.qualityParamsModal.rejectionReasonLabel," ",l.jsx("span",{style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("textarea",{id:"reject-reason",className:Ae.textarea,placeholder:s.qualityParamsModal.rejectReasonPlaceholder,value:i,onChange:p=>o(p.target.value),rows:5,required:!0,"aria-required":"true"}),i.trim().length===0&&l.jsx("p",{style:{fontSize:12,color:"var(--sbx-error, #DC2626)",marginTop:4},children:s.qualityParamsModal.rejectionRequiredMessage})]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:n,children:s.qualityParamsModal.cancelButton}),l.jsx(Re,{variant:u?"primary":"danger",onClick:m,disabled:f,children:u?s.qualityParamsModal.approveButton:s.qualityParamsModal.rejectButton})]})]})})},$0=({message:e,onConfirm:t,onCancel:r})=>{const n=oe();return xr.createPortal(l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"confirm-dialog-title",children:n.confirmDialog.title}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.confirmDialog.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:e})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.confirmDialog.cancelButton}),l.jsx(Re,{variant:"danger",onClick:t,children:n.confirmDialog.confirmButton})]})]})}),document.body)},jh=["email","firstName","lastName","identifier","organisations","rootOrgName","phone"];async function U0(e,t={}){var c,u,d,f;const n={"organisations.roles":[((c=t.objectType)==null?void 0:c.toLowerCase())==="textbook"?"BOOK_CREATOR":"CONTENT_CREATOR"]};t.rootOrgId&&(n.rootOrgId=[t.rootOrgId]);const s=e.includes("@"),i=/^\d{10,}$/.test(e.trim()),o={filters:n,fields:jh,offset:0,limit:t.limit??200};return s?n.email=e.trim():i?n.phone=e.trim():o.query=e,((f=(d=(u=(await Fe.post("/action/user/v1/search",{request:o},{params:{fields:"orgName"},headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:u.result)==null?void 0:d.response)==null?void 0:f.content)??[]}async function z0(e){var r,n,s;return e.length?((s=(n=(r=(await Fe.post("/action/user/v1/search",{request:{filters:{userId:e},fields:jh,limit:e.length}},{headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:r.result)==null?void 0:n.response)==null?void 0:s.content)??[]:[]}async function V0(e){var r,n;return((n=(r=(await Fe.get(`/portal/user/v5/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.response)??{}}const H0="_container_1hnn8_1",Q0="_header_1hnn8_13",W0="_title_1hnn8_22",G0="_closeBtn_1hnn8_29",K0="_body_1hnn8_45",Y0="_label_1hnn8_54",Z0="_searchSection_1hnn8_62",X0="_searchRow_1hnn8_68",J0="_searchInput_1hnn8_74",eT="_searchSpinner_1hnn8_89",tT="_resultsList_1hnn8_105",rT="_resultItem_1hnn8_118",nT="_userInfo_1hnn8_133",sT="_userName_1hnn8_141",iT="_userEmail_1hnn8_150",oT="_userOrg_1hnn8_158",aT="_noResults_1hnn8_167",lT="_collabSection_1hnn8_174",cT="_sectionTitle_1hnn8_179",uT="_badge_1hnn8_189",dT="_emptyCollab_1hnn8_203",fT="_collabList_1hnn8_214",hT="_collabItem_1hnn8_223",pT="_userAvatar_1hnn8_237",mT="_error_1hnn8_251",gT="_success_1hnn8_257",vT="_footer_1hnn8_263",Pe={container:H0,header:Q0,title:W0,closeBtn:G0,body:K0,label:Y0,searchSection:Z0,searchRow:X0,searchInput:J0,searchSpinner:eT,resultsList:tT,resultItem:rT,userInfo:nT,userName:sT,userEmail:iT,userOrg:oT,noResults:aT,collabSection:lT,sectionTitle:cT,badge:uT,emptyCollab:dT,collabList:fT,collabItem:hT,userAvatar:pT,error:mT,success:gT,footer:vT},yT=({contentId:e,onClose:t})=>{var j,P;const r=oe(),n=K(O=>O.editorConfig),s=(j=n==null?void 0:n.context)==null?void 0:j.channel,i=(P=n==null?void 0:n.config)==null?void 0:P.objectType,[o,a]=g.useState(""),[c,u]=g.useState([]),[d,f]=g.useState(!1),[m,p]=g.useState([]),[b,h]=g.useState(!1),[v,y]=g.useState(""),[C,S]=g.useState(!1),_=g.useRef(null);g.useEffect(()=>{let O=!1;return(async()=>{try{const N=await s0(e),R=(N==null?void 0:N.collaborators)??[];if(!R.length)return;const M=await z0(R);if(O)return;const $=R.map(ee=>M.find(H=>H.identifier===ee)??{identifier:ee,firstName:ee});p($)}catch{}})(),()=>{O=!0}},[e]),g.useEffect(()=>{_.current&&clearTimeout(_.current);const O=o.trim();if(O.length<2){u([]);return}return _.current=setTimeout(async()=>{f(!0);try{const N=await U0(O,{rootOrgId:s,objectType:i}),R=new Set(m.map(M=>M.identifier));u(N.filter(M=>!R.has(M.identifier)))}catch{u([])}finally{f(!1)}},300),()=>{_.current&&clearTimeout(_.current)}},[o,m,s,i]);const x=g.useCallback(O=>{p(N=>N.find(R=>R.identifier===O.identifier)?N:[...N,O]),u(N=>N.filter(R=>R.identifier!==O.identifier)),S(!1)},[]),T=g.useCallback(O=>{p(N=>N.filter(R=>R.identifier!==O)),S(!1)},[]),D=g.useCallback(async()=>{h(!0),y(""),S(!1);try{await a0(e,m.map(O=>O.identifier)),S(!0)}catch{y(r.manageCollaborators.saveFailed)}finally{h(!1)}},[e,m,r.manageCollaborators.saveFailed]),E=O=>`${O.firstName}${O.lastName?` ${O.lastName}`:""}`;return l.jsxs("div",{className:Pe.container,children:[l.jsxs("div",{className:Pe.header,children:[l.jsx("h2",{className:Pe.title,children:r.manageCollaborators.title}),l.jsx("button",{className:Pe.closeBtn,onClick:t,"aria-label":r.manageCollaborators.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Pe.body,children:[l.jsxs("div",{className:Pe.searchSection,children:[l.jsx("label",{className:Pe.label,htmlFor:"collab-search",children:r.manageCollaborators.searchUsersLabel}),l.jsxs("div",{className:Pe.searchRow,children:[l.jsx("input",{id:"collab-search",type:"text",className:Pe.searchInput,placeholder:r.manageCollaborators.searchPlaceholder,value:o,onChange:O=>a(O.target.value)}),d&&l.jsx("span",{className:Pe.searchSpinner,"aria-label":r.manageCollaborators.searchingAriaLabel})]}),c.length>0&&l.jsx("ul",{className:Pe.resultsList,role:"listbox","aria-label":r.manageCollaborators.searchResultsAriaLabel,children:c.map(O=>{var N,R,M,$;return l.jsxs("li",{className:Pe.resultItem,role:"option","aria-selected":"false",children:[l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:E(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((R=(N=O.organisations)==null?void 0:N[0])==null?void 0:R.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:(($=(M=O.organisations)==null?void 0:M[0])==null?void 0:$.orgName)??O.rootOrgName})]}),l.jsx(Re,{variant:"primary",size:"sm",onClick:()=>x(O),children:r.manageCollaborators.add})]},O.identifier)})}),o.trim().length>=2&&!d&&c.length===0&&l.jsx("p",{className:Pe.noResults,children:r.manageCollaborators.noUsersFound})]}),l.jsxs("div",{className:Pe.collabSection,children:[l.jsxs("h3",{className:Pe.sectionTitle,children:[r.manageCollaborators.currentCollaborators,m.length>0&&l.jsx("span",{className:Pe.badge,children:m.length})]}),m.length===0?l.jsx("p",{className:Pe.emptyCollab,children:r.manageCollaborators.noCollaboratorsYet}):l.jsx("ul",{className:Pe.collabList,children:m.map(O=>{var N,R,M,$;return l.jsxs("li",{className:Pe.collabItem,children:[l.jsx("div",{className:Pe.userAvatar,"aria-hidden":"true",children:E(O).charAt(0).toUpperCase()}),l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:E(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((R=(N=O.organisations)==null?void 0:N[0])==null?void 0:R.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:(($=(M=O.organisations)==null?void 0:M[0])==null?void 0:$.orgName)??O.rootOrgName})]}),l.jsx(Re,{variant:"danger",size:"sm",onClick:()=>T(O.identifier),children:r.manageCollaborators.remove})]},O.identifier)})})]}),v&&l.jsx("p",{className:Pe.error,role:"alert",children:v}),C&&l.jsx("p",{className:Pe.success,role:"status",children:r.manageCollaborators.saveSuccess})]}),l.jsxs("div",{className:Pe.footer,children:[l.jsx(Re,{variant:"ghost",onClick:t,disabled:b,children:r.manageCollaborators.cancel}),l.jsx(Re,{variant:"primary",isLoading:b,onClick:D,children:r.manageCollaborators.save})]})]})};async function bT(e){return(await Fe.post("/api/dialcode/v1/read",{request:{dialcodes:[e]}})).data}async function CT(e,t){var s;const n=((s=(await Fe.post(`/action/dialcode/v1/reserve/${e}`,{request:{dialcodes:{count:t,qrCodeSpec:{errorCorrectionLevel:"H"}}}})).data)==null?void 0:s.result)??{};return{processId:n.processId??"",reservedDialcodes:n.reservedDialcodes??{}}}async function ST(e){var n;const r=((n=(await Fe.get(`/action/dialcode/v1/process/status/${e}`)).data)==null?void 0:n.result)??{status:"PENDING"};return{...r,status:r.status==="PENDING"?"in-process":r.status}}const _T="_topbar_c3y0z_1",wT="_left_c3y0z_15",xT="_right_c3y0z_23",TT="_backBtn_c3y0z_30",ET="_title_c3y0z_49",AT="_profileBadge_c3y0z_61",kT="_statusChip_c3y0z_76",IT="_savedIndicator_c3y0z_88",DT="_unsaved_c3y0z_98",LT="_iconBtn_c3y0z_103",OT="_iconBtnLabel_c3y0z_130",NT="_qrDropdown_c3y0z_134",jT="_qrMenu_c3y0z_138",PT="_reviewBtns_c3y0z_173",RT="_sourcingBtns_c3y0z_182",FT="_modalOverlay_c3y0z_191",MT="_sbOverlay_c3y0z_201",BT="_sbModal_c3y0z_211",qT="_sbModalHeader_c3y0z_222",$T="_sbModalTitle_c3y0z_230",UT="_sbModalClose_c3y0z_237",zT="_sbModalBody_c3y0z_250",VT="_sbLabel_c3y0z_257",HT="_sbTextarea_c3y0z_264",QT="_sbError_c3y0z_281",WT="_sbModalFooter_c3y0z_288",_e={topbar:_T,left:wT,right:xT,backBtn:TT,title:ET,profileBadge:AT,statusChip:kT,savedIndicator:IT,unsaved:DT,iconBtn:LT,iconBtnLabel:OT,qrDropdown:NT,qrMenu:jT,reviewBtns:PT,sourcingBtns:RT,modalOverlay:FT,sbOverlay:MT,sbModal:BT,sbModalHeader:qT,sbModalTitle:$T,sbModalClose:UT,sbModalBody:zT,sbLabel:VT,sbTextarea:HT,sbError:QT,sbModalFooter:WT};function GT(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function KT(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}const YT=({titleText:e,labelText:t,placeholderText:r,submitLabel:n,submitVariant:s="primary",onConfirm:i,onCancel:o})=>{const a=oe(),[c,u]=g.useState(""),d=e.toLowerCase().replace(/\s+/g,"-");return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":`${d}-title`,children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:`${d}-title`,className:_e.sbModalTitle,children:e}),l.jsx("button",{className:_e.sbModalClose,onClick:o,"aria-label":a.reviewCommentModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:_e.sbModalBody,children:[l.jsxs("label",{className:_e.sbLabel,htmlFor:`${d}-comment`,children:[t," ",l.jsx("span",{"aria-hidden":"true",style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("textarea",{id:`${d}-comment`,className:_e.sbTextarea,placeholder:r,value:c,onChange:f=>u(f.target.value),rows:4,required:!0,"aria-required":"true"}),c.trim().length===0&&l.jsx("p",{className:_e.sbError,children:a.reviewCommentModal.fillCommentsError})]}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:o,children:a.reviewCommentModal.cancelButton}),l.jsx(Re,{variant:s,onClick:()=>i(c.trim()),disabled:c.trim().length===0,children:n})]})]})})},ZT=({onConfirm:e,onCancel:t})=>{const r=oe(),[n,s]=g.useState(!1),i=K(m=>m.editorProfile.key==="learningPath"),o=re(m=>m.treeData[0]),a=re(m=>m.treeCache),c=lr(),{scope:u}=ii(),d=i?Rl(o,c==null?void 0:c.code,u,a):[],f=d.length>0;return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"review-confirm-title",children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:"review-confirm-title",className:_e.sbModalTitle,children:r.confirmReviewModal.title}),l.jsx("button",{className:_e.sbModalClose,onClick:t,"aria-label":r.confirmReviewModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsx("div",{className:_e.sbModalBody,children:f?l.jsxs(l.Fragment,{children:[l.jsx("p",{style:{margin:"0 0 8px",fontSize:13,fontWeight:600},children:r.learningPath.resolveBeforeSendingForReview}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:d.map((m,p)=>l.jsx("li",{children:m.message},`${m.code}-${m.nodeId??p}`))})]}):l.jsxs("label",{style:{display:"flex",gap:8,alignItems:"flex-start",fontSize:13,lineHeight:1.55},children:[l.jsx("input",{type:"checkbox",checked:n,onChange:m=>s(m.target.checked),style:{marginTop:2}}),l.jsxs("span",{children:[r.confirmReviewModal.agreementTextPart1," ",l.jsx("a",{className:"sb-color-primary",style:{fontWeight:600},href:"https://creativecommons.org/licenses",target:"_blank",rel:"noreferrer",children:r.confirmReviewModal.creativeCommonsLinkText})," ",r.confirmReviewModal.agreementTextPart2," ",l.jsx("strong",{children:r.confirmReviewModal.contentPolicyText}),r.confirmReviewModal.agreementTextPart3]})]})}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:t,children:r.confirmReviewModal.cancelButton}),!f&&l.jsx(Re,{variant:"primary",onClick:e,disabled:!n,children:r.confirmReviewModal.submitButton})]})]})})},XT=({onConfirm:e,onCancel:t})=>{const r=oe(),[n,s]=g.useState(""),i=parseInt(n,10),o=!isNaN(i)&&i>=2&&i<=250;return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"genqr-title",children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:"genqr-title",className:_e.sbModalTitle,children:r.generateQRModal.title}),l.jsx("button",{className:_e.sbModalClose,onClick:t,"aria-label":r.generateQRModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:_e.sbModalBody,children:[l.jsxs("label",{className:_e.sbLabel,htmlFor:"qr-count",children:[r.generateQRModal.numberOfCodesLabel," ",l.jsx("span",{"aria-hidden":"true",style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("input",{id:"qr-count",type:"number",min:2,max:250,className:_e.sbTextarea,style:{resize:"none",height:"40px"},placeholder:r.generateQRModal.countPlaceholder,value:n,onChange:a=>s(a.target.value)}),n&&!o&&l.jsx("p",{className:_e.sbError,children:r.generateQRModal.countRangeError})]}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:t,children:r.generateQRModal.cancelButton}),l.jsx(Re,{variant:"primary",onClick:()=>e(i),disabled:!o,children:r.generateQRModal.generateButton})]})]})})},JT=({editorMode:e,isSaving:t,isDirty:r,lastSaved:n,isFormValid:s=!0,onToolbarEvent:i})=>{var be,me;const o=oe(),c=re(le=>le.treeData)[0],u=(c==null?void 0:c.name)??o.contextualEditor.untitledPlaceholder,d=KT(((be=c==null?void 0:c.metadata)==null?void 0:be.status)??(c==null?void 0:c.status),o.topbar.draftStatusFallback),f=K(le=>{var ve,Te,Y,ce;return((Te=(ve=le.editorConfig)==null?void 0:ve.context)==null?void 0:Te.contentId)??((ce=(Y=le.editorConfig)==null?void 0:Y.context)==null?void 0:ce.identifier)??""}),{activeModal:m,modalData:p,closeModal:b,openModal:h}=yr(),v=K(le=>le.buttonLoaders),y=K(le=>le.categoryMeta),C=K(le=>le.editorProfile),S=C.key==="learningPath",_=C.features.dialcodes&&(!y||y.schemaDefaults.generateDIALCodes!=="No"),[x,T]=g.useState(!1),[D,E]=g.useState(!1),[j,P]=g.useState(!1),O=g.useRef(null),[N,R]=g.useState(!1);g.useEffect(()=>{if(!j)return;const le=ve=>{var Te;(Te=O.current)!=null&&Te.contains(ve.target)||P(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[j]);const[M,$]=g.useState(!1),[ee,H]=g.useState(!1),{updateNode:te}=re(),de=(me=c==null?void 0:c.metadata)==null?void 0:me.qrCodeProcessId,fe=g.useCallback(async le=>{if(f){R(!1),$(!0);try{const{processId:ve,reservedDialcodes:Te}=await CT(f,le);ve&&c&&te(c.id,{qrCodeProcessId:ve,reservedDialcodes:Te}),Se.success(o.topbar.qrGenerationStartedToast)}catch{Se.error(o.topbar.qrGenerationFailedToast)}finally{$(!1)}}},[f,c,te,o]),pe=g.useCallback(async()=>{if(!de){Se.error(o.topbar.qrCodesNotGeneratedToast);return}H(!0);try{const le=await ST(de);if(le.status==="in-process"){Se(o.topbar.qrGenerationInProgressToast,{icon:l.jsx(Bn,{size:16})});return}const ve=le.url;if(!ve){Se.error(o.topbar.qrCodesNotReadyToast);return}const Te=await fetch(ve).then(We=>We.blob()),Y=await new Promise(We=>{const tt=new FileReader;tt.onloadend=()=>We(tt.result),tt.readAsDataURL(Te)}),ce=(c==null?void 0:c.metadata)??{},Q=We=>Array.isArray(We)?We.join("_"):typeof We=="string"?We:"",Ce=[f,Q(ce.medium),Q(ce.gradeLevel),Q(ce.subject)].filter(Boolean),qe=new Date().toISOString().replace(/[:.]/g,"-"),et=`${Ce.join("_")}_${qe}.zip`,$e=document.createElement("a");$e.href=Y,$e.download=et,$e.style.display="none",document.body.appendChild($e),$e.click(),document.body.removeChild($e),Se.success(o.topbar.qrCodesDownloadedToast)}catch{Se.error(o.topbar.qrCodesDownloadFailedToast)}finally{H(!1)}},[de,c,f,o]),ae=e==="edit",we=e==="review",ye=e==="sourcingreview",F=e==="read",B=g.useCallback((le,ve)=>{i({action:le,data:ve})},[i]),Z=g.useCallback(()=>{b(),B("publish")},[b,B]),he=g.useCallback((le,ve)=>{const Te=p==null?void 0:p.action;b(),Te==="approve"?B("sourcingApprove",{comment:le,score:ve}):B("reject",{comment:le})},[b,B,p]);return l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:_e.topbar,role:"banner",children:[l.jsxs("div",{className:_e.left,children:[l.jsx("button",{className:_e.backBtn,onClick:()=>B("back"),"aria-label":o.topbar.backAriaLabel,type:"button",children:l.jsx(wl,{size:18})}),l.jsx("h1",{className:_e.title,title:u,children:u}),S&&l.jsxs("span",{className:_e.profileBadge,children:[l.jsx(Oh,{size:13,"aria-hidden":"true"}),o.learningPath.profileBadgeLabel]}),l.jsx("span",{className:`sbx-chip ${_e.statusChip}`,"aria-label":`${o.topbar.statusAriaLabelPrefix} ${d}`,children:d})]}),l.jsxs("div",{className:_e.right,children:[t?l.jsx("span",{className:_e.savedIndicator,"aria-live":"polite",children:o.topbar.savingIndicator}):r&&ae?l.jsx("span",{className:`${_e.savedIndicator} ${_e.unsaved}`,"aria-live":"polite",children:o.topbar.unsavedIndicator}):n?l.jsxs("span",{className:_e.savedIndicator,"aria-live":"polite",children:[l.jsx(bn,{size:14,"aria-hidden":"true"}),o.topbar.savedIndicatorPrefix," ",GT(n)]}):null,!F&&!we&&!ye&&d!=="Review"&&l.jsx("span",{title:s?void 0:o.topbar.fillRequiredFieldsTooltip,children:l.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>B("saveCollection"),disabled:!s,children:o.topbar.saveAsDraftButton})}),ae&&l.jsxs(l.Fragment,{children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>E(!0),disabled:v.saveCollection,isLoading:v.saveCollection,children:[l.jsx(qy,{size:14,"aria-hidden":"true"})," ",o.topbar.sendForReviewButton]}),C.features.collaborators&&l.jsx("button",{className:_e.iconBtn,onClick:()=>h("manageCollaborators"),"aria-label":o.topbar.collaboratorsLabel,title:o.topbar.collaboratorsLabel,type:"button",children:l.jsx(Wy,{size:16,"aria-hidden":"true"})}),_&&l.jsxs("div",{className:_e.qrDropdown,ref:O,children:[l.jsxs("button",{className:_e.iconBtn,onClick:()=>P(le=>!le),"aria-label":o.topbar.qrCodesLabel,title:o.topbar.qrCodesLabel,type:"button","aria-haspopup":"true","aria-expanded":j,children:[l.jsx(Ac,{size:16,"aria-hidden":"true"}),l.jsx("span",{className:_e.iconBtnLabel,children:o.topbar.qrCodesLabel}),l.jsx(Cn,{size:14,style:{marginLeft:2},"aria-hidden":"true"})]}),j&&l.jsxs("div",{className:_e.qrMenu,role:"menu",children:[l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{P(!1),R(!0)},disabled:M,children:[l.jsx(Ac,{size:14}),M?o.topbar.generatingEllipsis:o.topbar.generateQrCodesMenuItem]}),l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{P(!1),pe()},disabled:ee||!de,children:[l.jsx(Ey,{size:14}),ee?o.topbar.downloadingEllipsis:o.topbar.downloadQrCodesMenuItem]})]})]})]}),we&&l.jsxs("div",{className:_e.reviewBtns,children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("publishChecklist"),disabled:v.publishCollection,isLoading:v.publishCollection,children:[l.jsx(Pf,{size:14,"aria-hidden":"true"})," ",o.topbar.publishButton]}),l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>T(!0),disabled:v.rejectCollection,isLoading:v.rejectCollection,children:[l.jsx(kc,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]}),ye&&l.jsxs("div",{className:_e.sourcingBtns,children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"approve"}),children:[l.jsx(Uy,{size:14,"aria-hidden":"true"})," ",o.topbar.approveButton]}),l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"reject"}),children:[l.jsx(kc,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]})]})]}),m==="publishChecklist"&&l.jsx(B0,{contentId:f,onConfirm:Z,onCancel:b}),m==="qualityParams"&&l.jsx(q0,{contentId:f,action:(p==null?void 0:p.action)??"reject",onConfirm:he,onCancel:b}),m==="manageCollaborators"&&l.jsx("div",{className:_e.modalOverlay,role:"dialog","aria-modal":"true",children:l.jsx(yT,{contentId:f,onClose:b})}),m==="confirmDelete"&&l.jsx($0,{message:(p==null?void 0:p.message)??"",onConfirm:()=>{const le=p==null?void 0:p.onConfirm;b(),le==null||le()},onCancel:b}),D&&l.jsx(ZT,{onConfirm:()=>{E(!1),B("sendForReview")},onCancel:()=>E(!1)}),x&&l.jsx(YT,{titleText:o.topbar.requestChangesTitle,labelText:o.topbar.changesRequestedLabel,placeholderText:o.topbar.describeChangesPlaceholder,submitLabel:o.topbar.requestForChangesButton,submitVariant:"primary",onConfirm:le=>{T(!1),B("reject",{comment:le})},onCancel:()=>T(!1)}),N&&l.jsx(XT,{onConfirm:fe,onCancel:()=>R(!1)})]})},e1=({onSave:e,onDiscard:t,onCancel:r,isSaving:n})=>{const s=oe();return xr.createPortal(l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"unsaved-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"unsaved-title",children:s.unsavedChangesModal.title}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":s.unsavedChangesModal.closeAriaLabel,disabled:n,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:s.unsavedChangesModal.bodyMessage})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,disabled:n,children:s.unsavedChangesModal.cancelButton}),l.jsx(Re,{variant:"danger",onClick:t,disabled:n,children:s.unsavedChangesModal.discardButton}),l.jsx(Re,{variant:"primary",onClick:e,isLoading:n,disabled:n,children:s.unsavedChangesModal.saveButton})]})]})}),document.body)};var t1=El();const Ph=g.createContext(null);function Ft(){const e=g.useContext(Ph);if(e===null)throw new Error("No Tree Api Provided");return e}const Rh=g.createContext(null);function r1(){const e=g.useContext(Rh);if(e===null)throw new Error("Provide a NodesContext");return e}const Fh=g.createContext(null);function n1(){const e=g.useContext(Fh);if(e===null)throw new Error("Provide a DnDContext");return e}const Mh=g.createContext(0);function Bh(){g.useContext(Mh)}function Ni(e,t,r){return Math.max(Math.min(e,r),t)}function qh(e){return e&&e.isLeaf}function $h(e){return e&&e.isInternal&&!e.isOpen}function Uh(e){var t;return e&&e.isOpen&&!(!((t=e.children)===null||t===void 0)&&t.length)}const zh=(e,t)=>{let r=e;for(;r;){if(r.id===t.id)return!0;r=r.parent}return!1},Vh=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function Fl(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let r of e.children){const n=Fl(r,t);if(n)return n}return null}function eo(e,t){if(t(e),e.children)for(let r of e.children)eo(r,t)}function Hh(e){const t=Wh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=s1(t,n);break}r==null||r.focus()}function Qh(e){const t=Wh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=i1(t,n);break}r==null||r.focus()}function s1(e,t){return t+1<e.length?e[t+1]:e[0]}function i1(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function Wh(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter(t=>t===e||!e.contains(t))}function xs(e,t){return typeof t=="boolean"?t:typeof t=="string"?e[t]:t(e)}function Rn(e){return typeof e=="string"?e:e.id}function o1(e,...t){if(e)return e(...t)}function Gh(e){return new Promise((t,r)=>{let n=0;function s(){n+=1,n===100&&r(),e()?t():setTimeout(s,10)}s()})}function Kh(e){var t,r;const n=e.focusedNode;return n?n.isOpen?0:n.parent?n.childIndex+1:0:(r=(t=e.root.children)===null||t===void 0?void 0:t.length)!==null&&r!==void 0?r:0}function Yh(e){const t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}const a1=Object.freeze(Object.defineProperty({__proto__:null,access:xs,bound:Ni,dfs:Fl,focusNextElement:Hh,focusPrevElement:Qh,getInsertIndex:Kh,getInsertParentId:Yh,identify:Rn,indexOf:Vh,isClosed:$h,isDescendant:zh,isItem:qh,isOpenWithEmptyChildren:Uh,safeRun:o1,waitFor:Gh,walk:eo},Symbol.toStringTag,{value:"Module"})),l1={display:"flex",alignItems:"center",zIndex:1},c1={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},u1={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},d1=g.memo(function({top:t,left:r,indent:n}){const s={position:"absolute",pointerEvents:"none",top:t-2+"px",left:r+"px",right:n+"px"};return l.jsxs("div",{style:Object.assign(Object.assign({},l1),s),children:[l.jsx("div",{style:Object.assign({},u1)}),l.jsx("div",{style:Object.assign({},c1)})]})});function f1({node:e,attrs:t,innerRef:r,children:n}){return l.jsx("div",Object.assign({},t,{ref:r,onFocus:s=>s.stopPropagation(),onClick:e.handleClick,children:n}))}function h1(e){return l.jsxs("div",{ref:e.dragHandle,style:e.style,children:[l.jsx("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"🌳":e.node.isOpen?"🗁":"🗀"})," ",e.node.isEditing?l.jsx(m1,Object.assign({},e)):l.jsx(p1,Object.assign({},e))]})}function p1(e){return l.jsx(l.Fragment,{children:l.jsx("span",{children:e.node.data.name})})}function m1({node:e}){const t=g.useRef();return g.useEffect(()=>{var r,n;(r=t.current)===null||r===void 0||r.focus(),(n=t.current)===null||n===void 0||n.select()},[]),l.jsx("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:r=>{var n;r.key==="Escape"&&e.reset(),r.key==="Enter"&&e.submit(((n=t.current)===null||n===void 0?void 0:n.value)||"")}})}const qs="__REACT_ARBORIST_INTERNAL_ROOT__";function ou(e){var t;function r(i,o,a){const c=e.accessId(i),u=new $s({tree:e,data:i,level:o,parent:a,id:c,children:null,isDraggable:e.isDraggable(i),rowIndex:null}),d=e.accessChildren(i);return d&&(u.children=d.map(f=>r(f,o+1,u))),u}const n=new $s({tree:e,id:qs,data:{id:qs},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null}),s=(t=e.props.data)!==null&&t!==void 0?t:[];return n.children=s.map(i=>r(i,0,n)),n}class $s{constructor(t){this.handleClick=r=>{(r.metaKey||r.ctrlKey)&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():r.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=t.tree,this.id=t.id,this.data=t.data,this.level=t.level,this.children=t.children,this.parent=t.parent,this.isDraggable=t.isDraggable,this.rowIndex=t.rowIndex}get isRoot(){return this.id===qs}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return this.isLeaf?!1:this.tree.isOpen(this.id)}get isClosed(){return this.isLeaf?!1:!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isSelectable(){return this.tree.isSelectable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var t;return this.isSelected&&!(!((t=this.prev)===null||t===void 0)&&t.isSelected)}get isSelectedEnd(){var t;return this.isSelected&&!(!((t=this.next)===null||t===void 0)&&t.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(t=>t.id===this.id):-1}get next(){return this.rowIndex===null?null:this.tree.at(this.rowIndex+1)}get prev(){return this.rowIndex===null?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var t,r;const n=this.childIndex;return(r=(t=this.parent)===null||t===void 0?void 0:t.children[n+1])!==null&&r!==void 0?r:null}isAncestorOf(t){if(!t)return!1;let r=t;for(;r;){if(r.id===this.id)return!0;r=r.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(t){this.tree.submit(this,t)}reset(){this.tree.reset()}clone(){return new $s(Object.assign({},this))}edit(){return this.tree.edit(this)}}function Ko(e){return{type:"EDIT",id:e}}function g1(e={id:null},t){return t.type==="EDIT"?Object.assign(Object.assign({},e),{id:t.id}):e}function En(e){return{type:"FOCUS",id:e}}function v1(){return{type:"TREE_BLUR"}}function y1(e={id:null,treeFocused:!1},t){return t.type==="FOCUS"?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):t.type==="TREE_BLUR"?Object.assign(Object.assign({},e),{treeFocused:!1}):e}const Ya={open(e,t){return{type:"VISIBILITY_OPEN",id:e,filtered:t}},close(e,t){return{type:"VISIBILITY_CLOSE",id:e,filtered:t}},toggle(e,t){return{type:"VISIBILITY_TOGGLE",id:e,filtered:t}},clear(e){return{type:"VISIBILITY_CLEAR",filtered:e}}};function au(e={},t){if(t.type==="VISIBILITY_OPEN")return Object.assign(Object.assign({},e),{[t.id]:!0});if(t.type==="VISIBILITY_CLOSE")return Object.assign(Object.assign({},e),{[t.id]:!1});if(t.type==="VISIBILITY_TOGGLE"){const r=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!r})}else return t.type==="VISIBILITY_CLEAR"?{}:e}function b1(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:au(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:au(e.unfiltered,t)}):e}const rs=e=>{var t;return{nodes:{open:{filtered:{},unfiltered:(t=e==null?void 0:e.initialOpenState)!==null&&t!==void 0?t:{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}},Ir={clear:()=>({type:"SELECTION_CLEAR"}),only:e=>({type:"SELECTION_ONLY",id:Rn(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(Rn)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(Rn)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:e===null?null:Rn(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:e===null?null:Rn(e)})};function C1(e=rs().nodes.selection,t){const r=e.ids;switch(t.type){case"SELECTION_CLEAR":return Object.assign(Object.assign({},e),{ids:new Set});case"SELECTION_ONLY":return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case"SELECTION_ADD":return t.ids.length===0?e:(t.ids.forEach(n=>r.add(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_REMOVE":return t.ids.length===0?e:(t.ids.forEach(n=>r.delete(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}}const ns={cursor(e){return{type:"DND_CURSOR",cursor:e}},dragStart(e,t){return{type:"DND_DRAG_START",id:e,dragIds:t}},dragEnd(){return{type:"DND_DRAG_END"}},hovering(e,t){return{type:"DND_HOVERING",parentId:e,index:t}}};function S1(e=rs().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return rs().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}const _1={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},w1=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t}px, ${r}px)`}},x1=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t+10}px, ${r+10}px)`}};function Zh({offset:e,mouse:t,id:r,dragIds:n,isDragging:s}){return l.jsxs(T1,{isDragging:s,children:[l.jsx(E1,{offset:e,children:l.jsx(k1,{id:r,dragIds:n})}),l.jsx(A1,{mouse:t,count:n.length})]})}const T1=g.memo(function(t){return t.isDragging?l.jsx("div",{style:_1,children:t.children}):null});function E1(e){return l.jsx("div",{className:"row preview",style:w1(e.offset),children:e.children})}function A1(e){const{count:t,mouse:r}=e;return t>1?l.jsx("div",{className:"selected-count",style:x1(r),children:t}):null}const k1=g.memo(function(t){const r=Ft(),n=r.get(t.id);return n?l.jsx(r.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*r.indent,opacity:.2,background:"transparent"},tree:r}):null});function Za(){return Za=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Za.apply(null,arguments)}function lu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Xa(e,t){return Xa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Xa(e,t)}function I1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Xa(e,t)}var cu=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function D1(e,t){return!!(e===t||cu(e)&&cu(t))}function L1(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!D1(e[r],t[r]))return!1;return!0}function Yo(e,t){t===void 0&&(t=L1);var r,n=[],s,i=!1;function o(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return i&&r===this&&t(a,n)||(s=e.apply(this,a),i=!0,r=this,n=a),s}return o}var O1=typeof performance=="object"&&typeof performance.now=="function",uu=O1?function(){return performance.now()}:function(){return Date.now()};function du(e){cancelAnimationFrame(e.id)}function N1(e,t){var r=uu();function n(){uu()-r>=t?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var Zo=-1;function fu(e){if(e===void 0&&(e=!1),Zo===-1||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(t),Zo=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Zo}var An=null;function hu(e){if(e===void 0&&(e=!1),An===null||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";var n=document.createElement("div"),s=n.style;return s.width="100px",s.height="100px",t.appendChild(n),document.body.appendChild(t),t.scrollLeft>0?An="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?An="negative":An="positive-ascending"),document.body.removeChild(t),An}return An}process.env.NODE_ENV;var j1=150,P1=function(t,r){return t},ji=null,Pi=null;process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof window.WeakSet<"u"&&(ji=new WeakSet,Pi=new WeakSet);function Xh(e){var t,r=e.getItemOffset,n=e.getEstimatedTotalSize,s=e.getItemSize,i=e.getOffsetForIndexAndAlignment,o=e.getStartIndexForOffset,a=e.getStopIndexForStartIndex,c=e.initInstanceProps,u=e.shouldResetStyleCacheOnItemSizeChange,d=e.validateProps;return t=(function(f){I1(m,f);function m(b){var h;return h=f.call(this,b)||this,h._instanceProps=c(h.props,lu(h)),h._outerRef=void 0,h._resetIsScrollingTimeoutId=null,h.state={instance:lu(h),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof h.props.initialScrollOffset=="number"?h.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},h._callOnItemsRendered=void 0,h._callOnItemsRendered=Yo(function(v,y,C,S){return h.props.onItemsRendered({overscanStartIndex:v,overscanStopIndex:y,visibleStartIndex:C,visibleStopIndex:S})}),h._callOnScroll=void 0,h._callOnScroll=Yo(function(v,y,C){return h.props.onScroll({scrollDirection:v,scrollOffset:y,scrollUpdateWasRequested:C})}),h._getItemStyle=void 0,h._getItemStyle=function(v){var y=h.props,C=y.direction,S=y.itemSize,_=y.layout,x=h._getItemStyleCache(u&&S,u&&_,u&&C),T;if(x.hasOwnProperty(v))T=x[v];else{var D=r(h.props,v,h._instanceProps),E=s(h.props,v,h._instanceProps),j=C==="horizontal"||_==="horizontal",P=C==="rtl",O=j?D:0;x[v]=T={position:"absolute",left:P?void 0:O,right:P?O:void 0,top:j?0:D,height:j?"100%":E,width:j?E:"100%"}}return T},h._getItemStyleCache=void 0,h._getItemStyleCache=Yo(function(v,y,C){return{}}),h._onScrollHorizontal=function(v){var y=v.currentTarget,C=y.clientWidth,S=y.scrollLeft,_=y.scrollWidth;h.setState(function(x){if(x.scrollOffset===S)return null;var T=h.props.direction,D=S;if(T==="rtl")switch(hu()){case"negative":D=-S;break;case"positive-descending":D=_-C-S;break}return D=Math.max(0,Math.min(D,_-C)),{isScrolling:!0,scrollDirection:x.scrollOffset<D?"forward":"backward",scrollOffset:D,scrollUpdateWasRequested:!1}},h._resetIsScrollingDebounced)},h._onScrollVertical=function(v){var y=v.currentTarget,C=y.clientHeight,S=y.scrollHeight,_=y.scrollTop;h.setState(function(x){if(x.scrollOffset===_)return null;var T=Math.max(0,Math.min(_,S-C));return{isScrolling:!0,scrollDirection:x.scrollOffset<T?"forward":"backward",scrollOffset:T,scrollUpdateWasRequested:!1}},h._resetIsScrollingDebounced)},h._outerRefSetter=function(v){var y=h.props.outerRef;h._outerRef=v,typeof y=="function"?y(v):y!=null&&typeof y=="object"&&y.hasOwnProperty("current")&&(y.current=v)},h._resetIsScrollingDebounced=function(){h._resetIsScrollingTimeoutId!==null&&du(h._resetIsScrollingTimeoutId),h._resetIsScrollingTimeoutId=N1(h._resetIsScrolling,j1)},h._resetIsScrolling=function(){h._resetIsScrollingTimeoutId=null,h.setState({isScrolling:!1},function(){h._getItemStyleCache(-1,null)})},h}m.getDerivedStateFromProps=function(h,v){return R1(h,v),d(h),null};var p=m.prototype;return p.scrollTo=function(h){h=Math.max(0,h),this.setState(function(v){return v.scrollOffset===h?null:{scrollDirection:v.scrollOffset<h?"forward":"backward",scrollOffset:h,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},p.scrollToItem=function(h,v){v===void 0&&(v="auto");var y=this.props,C=y.itemCount,S=y.layout,_=this.state.scrollOffset;h=Math.max(0,Math.min(h,C-1));var x=0;if(this._outerRef){var T=this._outerRef;S==="vertical"?x=T.scrollWidth>T.clientWidth?fu():0:x=T.scrollHeight>T.clientHeight?fu():0}this.scrollTo(i(this.props,h,v,_,this._instanceProps,x))},p.componentDidMount=function(){var h=this.props,v=h.direction,y=h.initialScrollOffset,C=h.layout;if(typeof y=="number"&&this._outerRef!=null){var S=this._outerRef;v==="horizontal"||C==="horizontal"?S.scrollLeft=y:S.scrollTop=y}this._callPropsCallbacks()},p.componentDidUpdate=function(){var h=this.props,v=h.direction,y=h.layout,C=this.state,S=C.scrollOffset,_=C.scrollUpdateWasRequested;if(_&&this._outerRef!=null){var x=this._outerRef;if(v==="horizontal"||y==="horizontal")if(v==="rtl")switch(hu()){case"negative":x.scrollLeft=-S;break;case"positive-ascending":x.scrollLeft=S;break;default:var T=x.clientWidth,D=x.scrollWidth;x.scrollLeft=D-T-S;break}else x.scrollLeft=S;else x.scrollTop=S}this._callPropsCallbacks()},p.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&du(this._resetIsScrollingTimeoutId)},p.render=function(){var h=this.props,v=h.children,y=h.className,C=h.direction,S=h.height,_=h.innerRef,x=h.innerElementType,T=h.innerTagName,D=h.itemCount,E=h.itemData,j=h.itemKey,P=j===void 0?P1:j,O=h.layout,N=h.outerElementType,R=h.outerTagName,M=h.style,$=h.useIsScrolling,ee=h.width,H=this.state.isScrolling,te=C==="horizontal"||O==="horizontal",de=te?this._onScrollHorizontal:this._onScrollVertical,fe=this._getRangeToRender(),pe=fe[0],ae=fe[1],we=[];if(D>0)for(var ye=pe;ye<=ae;ye++)we.push(g.createElement(v,{data:E,key:P(ye,E),index:ye,isScrolling:$?H:void 0,style:this._getItemStyle(ye)}));var F=n(this.props,this._instanceProps);return g.createElement(N||R||"div",{className:y,onScroll:de,ref:this._outerRefSetter,style:Za({position:"relative",height:S,width:ee,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:C},M)},g.createElement(x||T||"div",{children:we,ref:_,style:{height:te?"100%":F,pointerEvents:H?"none":void 0,width:te?F:"100%"}}))},p._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var h=this.props.itemCount;if(h>0){var v=this._getRangeToRender(),y=v[0],C=v[1],S=v[2],_=v[3];this._callOnItemsRendered(y,C,S,_)}}if(typeof this.props.onScroll=="function"){var x=this.state,T=x.scrollDirection,D=x.scrollOffset,E=x.scrollUpdateWasRequested;this._callOnScroll(T,D,E)}},p._getRangeToRender=function(){var h=this.props,v=h.itemCount,y=h.overscanCount,C=this.state,S=C.isScrolling,_=C.scrollDirection,x=C.scrollOffset;if(v===0)return[0,0,0,0];var T=o(this.props,x,this._instanceProps),D=a(this.props,T,x,this._instanceProps),E=!S||_==="backward"?Math.max(1,y):1,j=!S||_==="forward"?Math.max(1,y):1;return[Math.max(0,T-E),Math.max(0,Math.min(v-1,D+j)),T,D]},m})(g.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var R1=function(t,r){var n=t.children,s=t.direction,i=t.height,o=t.layout,a=t.innerTagName,c=t.outerTagName,u=t.width,d=r.instance;if(process.env.NODE_ENV!=="production"){(a!=null||c!=null)&&Pi&&!Pi.has(d)&&(Pi.add(d),console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead."));var f=s==="horizontal"||o==="horizontal";switch(s){case"horizontal":case"vertical":ji&&!ji.has(d)&&(ji.add(d),console.warn('The direction prop should be either "ltr" (default) or "rtl". Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.'));break;case"ltr":case"rtl":break;default:throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". '+('"'+s+'" was specified.'))}switch(o){case"horizontal":case"vertical":break;default:throw Error('An invalid "layout" prop has been specified. Value should be either "horizontal" or "vertical". '+('"'+o+'" was specified.'))}if(n==null)throw Error('An invalid "children" prop has been specified. Value should be a React component. '+('"'+(n===null?"null":typeof n)+'" was specified.'));if(f&&typeof u!="number")throw Error('An invalid "width" prop has been specified. Horizontal lists must specify a number for width. '+('"'+(u===null?"null":typeof u)+'" was specified.'));if(!f&&typeof i!="number")throw Error('An invalid "height" prop has been specified. Vertical lists must specify a number for height. '+('"'+(i===null?"null":typeof i)+'" was specified.'))}},F1=50,Fn=function(t,r,n){var s=t,i=s.itemSize,o=n.itemMetadataMap,a=n.lastMeasuredIndex;if(r>a){var c=0;if(a>=0){var u=o[a];c=u.offset+u.size}for(var d=a+1;d<=r;d++){var f=i(d);o[d]={offset:c,size:f},c+=f}n.lastMeasuredIndex=r}return o[r]},M1=function(t,r,n){var s=r.itemMetadataMap,i=r.lastMeasuredIndex,o=i>0?s[i].offset:0;return o>=n?Jh(t,r,i,0,n):B1(t,r,Math.max(0,i),n)},Jh=function(t,r,n,s,i){for(;s<=n;){var o=s+Math.floor((n-s)/2),a=Fn(t,o,r).offset;if(a===i)return o;a<i?s=o+1:a>i&&(n=o-1)}return s>0?s-1:0},B1=function(t,r,n,s){for(var i=t.itemCount,o=1;n<i&&Fn(t,n,r).offset<s;)n+=o,o*=2;return Jh(t,r,Math.min(n,i-1),Math.floor(n/2),s)},pu=function(t,r){var n=t.itemCount,s=r.itemMetadataMap,i=r.estimatedItemSize,o=r.lastMeasuredIndex,a=0;if(o>=n&&(o=n-1),o>=0){var c=s[o];a=c.offset+c.size}var u=n-o-1,d=u*i;return a+d},q1=Xh({getItemOffset:function(t,r,n){return Fn(t,r,n).offset},getItemSize:function(t,r,n){return n.itemMetadataMap[r].size},getEstimatedTotalSize:pu,getOffsetForIndexAndAlignment:function(t,r,n,s,i,o){var a=t.direction,c=t.height,u=t.layout,d=t.width,f=a==="horizontal"||u==="horizontal",m=f?d:c,p=Fn(t,r,i),b=pu(t,i),h=Math.max(0,Math.min(b-m,p.offset)),v=Math.max(0,p.offset-m+p.size+o);switch(n==="smart"&&(s>=v-m&&s<=h+m?n="auto":n="center"),n){case"start":return h;case"end":return v;case"center":return Math.round(v+(h-v)/2);case"auto":default:return s>=v&&s<=h?s:s<v?v:h}},getStartIndexForOffset:function(t,r,n){return M1(t,n,r)},getStopIndexForStartIndex:function(t,r,n,s){for(var i=t.direction,o=t.height,a=t.itemCount,c=t.layout,u=t.width,d=i==="horizontal"||c==="horizontal",f=d?u:o,m=Fn(t,r,s),p=n+f,b=m.offset+m.size,h=r;h<a-1&&b<p;)h++,b+=Fn(t,h,s).size;return h},initInstanceProps:function(t,r){var n=t,s=n.estimatedItemSize,i={itemMetadataMap:{},estimatedItemSize:s||F1,lastMeasuredIndex:-1};return r.resetAfterIndex=function(o,a){a===void 0&&(a=!0),i.lastMeasuredIndex=Math.min(i.lastMeasuredIndex,o-1),r._getItemStyleCache(-1),a&&r.forceUpdate()},i},shouldResetStyleCacheOnItemSizeChange:!1,validateProps:function(t){var r=t.itemSize;if(process.env.NODE_ENV!=="production"&&typeof r!="function")throw Error('An invalid "itemSize" prop has been specified. Value should be a function. '+('"'+(r===null?"null":typeof r)+'" was specified.'))}}),$1=Xh({getItemOffset:function(t,r){var n=t.itemSize;return r*n},getItemSize:function(t,r){var n=t.itemSize;return n},getEstimatedTotalSize:function(t){var r=t.itemCount,n=t.itemSize;return n*r},getOffsetForIndexAndAlignment:function(t,r,n,s,i,o){var a=t.direction,c=t.height,u=t.itemCount,d=t.itemSize,f=t.layout,m=t.width,p=a==="horizontal"||f==="horizontal",b=p?m:c,h=Math.max(0,u*d-b),v=Math.min(h,r*d),y=Math.max(0,r*d-b+d+o);switch(n==="smart"&&(s>=y-b&&s<=v+b?n="auto":n="center"),n){case"start":return v;case"end":return y;case"center":{var C=Math.round(y+(v-y)/2);return C<Math.ceil(b/2)?0:C>h+Math.floor(b/2)?h:C}case"auto":default:return s>=y&&s<=v?s:s<y?y:v}},getStartIndexForOffset:function(t,r){var n=t.itemCount,s=t.itemSize;return Math.max(0,Math.min(n-1,Math.floor(r/s)))},getStopIndexForStartIndex:function(t,r,n){var s=t.direction,i=t.height,o=t.itemCount,a=t.itemSize,c=t.layout,u=t.width,d=s==="horizontal"||c==="horizontal",f=r*a,m=d?u:i,p=Math.ceil((m+n-f)/a);return Math.max(0,Math.min(o-1,r+p-1))},initInstanceProps:function(t){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(t){var r=t.itemSize;if(process.env.NODE_ENV!=="production"&&typeof r!="number")throw Error('An invalid "itemSize" prop has been specified. Value should be a number. '+('"'+(r===null?"null":typeof r)+'" was specified.'))}});function U1(){var e,t;const r=Ft(),s=n1().cursor;if(!s||s.type!=="line")return null;const i=r.indent,o=r.rowTopPosition(s.index)+((t=(e=r.props.padding)!==null&&e!==void 0?e:r.props.paddingTop)!==null&&t!==void 0?t:0),a=i*s.level,c=r.renderCursor;return l.jsx(c,{top:o,left:a,indent:i})}var z1=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r};const V1=g.forwardRef(function(t,r){const{children:n}=t,s=z1(t,["children"]),i=Ft();return l.jsxs("div",Object.assign({ref:r},s,{onClick:o=>{o.currentTarget===o.target&&i.deselectAll()},children:[l.jsx(H1,{}),n]}))}),H1=()=>{const e=Ft();return l.jsx("div",{style:{height:e.rowTopPosition(e.visibleNodes.length),width:"100%",position:"absolute",left:"0",right:"0"},children:l.jsx(U1,{})})};var Q1=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r};const W1=g.forwardRef(function(t,r){var n,s,i,o,{style:a}=t,c=Q1(t,["style"]);const u=Ft(),d=(s=(n=u.props.padding)!==null&&n!==void 0?n:u.props.paddingTop)!==null&&s!==void 0?s:0,f=(o=(i=u.props.padding)!==null&&i!==void 0?i:u.props.paddingBottom)!==null&&o!==void 0?o:0;return l.jsx("div",Object.assign({ref:r,style:Object.assign(Object.assign({},a),{height:`${parseFloat(a.height)+d+f}px`})},c))});var ep=g.createContext({dragDropManager:void 0}),Xt;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(Xt||(Xt={}));function xe(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s<r;s++)n[s-2]=arguments[s];if(process.env.NODE_ENV!=="production"&&t===void 0)throw new Error("invariant requires an error message argument");if(!e){var i;if(t===void 0)i=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;i=new Error(t.replace(/%s/g,function(){return n[o++]})),i.name="Invariant Violation"}throw i.framesToPop=1,i}}var Ml="dnd-core/INIT_COORDS",ko="dnd-core/BEGIN_DRAG",Bl="dnd-core/PUBLISH_DRAG_SOURCE",Io="dnd-core/HOVER",Do="dnd-core/DROP",Lo="dnd-core/END_DRAG";function mu(e,t){return{type:Ml,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function Ri(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ri=function(r){return typeof r}:Ri=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ri(e)}function G1(e,t,r){return t.split(".").reduce(function(n,s){return n&&n[s]?n[s]:r||null},e)}function K1(e,t){return e.filter(function(r){return r!==t})}function tp(e){return Ri(e)==="object"}function Y1(e,t){var r=new Map,n=function(o){r.set(o,r.has(o)?r.get(o)+1:1)};e.forEach(n),t.forEach(n);var s=[];return r.forEach(function(i,o){i===1&&s.push(o)}),s}function Z1(e,t){return e.filter(function(r){return t.indexOf(r)>-1})}var X1={type:Ml,payload:{clientOffset:null,sourceClientOffset:null}};function J1(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{publishSource:!0},s=n.publishSource,i=s===void 0?!0:s,o=n.clientOffset,a=n.getSourceClientOffset,c=e.getMonitor(),u=e.getRegistry();e.dispatch(mu(o)),eE(r,c,u);var d=nE(r,c);if(d===null){e.dispatch(X1);return}var f=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");tE(a),f=a(d)}e.dispatch(mu(o,f));var m=u.getSource(d),p=m.beginDrag(c,d);if(p!=null){rE(p),u.pinSource(d);var b=u.getSourceType(d);return{type:ko,payload:{itemType:b,item:p,sourceId:d,clientOffset:o||null,sourceClientOffset:f||null,isSourcePublic:!!i}}}}}function eE(e,t,r){xe(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(n){xe(r.getSource(n),"Expected sourceIds to be registered.")})}function tE(e){xe(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function rE(e){xe(tp(e),"Item must be an object.")}function nE(e,t){for(var r=null,n=e.length-1;n>=0;n--)if(t.canDragSource(e[n])){r=e[n];break}return r}function sE(e){return function(){var r=e.getMonitor();if(r.isDragging())return{type:Bl}}}function Ja(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(r){return r===t}):e===t}function iE(e){return function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=n.clientOffset;oE(r);var i=r.slice(0),o=e.getMonitor(),a=e.getRegistry();aE(i,o,a);var c=o.getItemType();return lE(i,a,c),cE(i,o,a),{type:Io,payload:{targetIds:i,clientOffset:s||null}}}}function oE(e){xe(Array.isArray(e),"Expected targetIds to be an array.")}function aE(e,t,r){xe(t.isDragging(),"Cannot call hover while not dragging."),xe(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n<e.length;n++){var s=e[n];xe(e.lastIndexOf(s)===n,"Expected targetIds to be unique in the passed array.");var i=r.getTarget(s);xe(i,"Expected targetIds to be registered.")}}function lE(e,t,r){for(var n=e.length-1;n>=0;n--){var s=e[n],i=t.getTargetType(s);Ja(i,r)||e.splice(n,1)}}function cE(e,t,r){e.forEach(function(n){var s=r.getTarget(n);s.hover(t,n)})}function gu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function vu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?gu(Object(r),!0).forEach(function(n){uE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function uE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function dE(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),s=e.getRegistry();fE(n);var i=mE(n);i.forEach(function(o,a){var c=hE(o,a,s,n),u={type:Do,payload:{dropResult:vu(vu({},r),c)}};e.dispatch(u)})}}function fE(e){xe(e.isDragging(),"Cannot call drop while not dragging."),xe(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function hE(e,t,r,n){var s=r.getTarget(e),i=s?s.drop(n,e):void 0;return pE(i),typeof i>"u"&&(i=t===0?{}:n.getDropResult()),i}function pE(e){xe(typeof e>"u"||tp(e),"Drop result must either be an object or undefined.")}function mE(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function gE(e){return function(){var r=e.getMonitor(),n=e.getRegistry();vE(r);var s=r.getSourceId();if(s!=null){var i=n.getSource(s,!0);i.endDrag(r,s),n.unpinSource()}return{type:Lo}}}function vE(e){xe(e.isDragging(),"Cannot call endDrag while not dragging.")}function yE(e){return{beginDrag:J1(e),publishDragSource:sE(e),hover:iE(e),drop:dE(e),endDrag:gE(e)}}function bE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function CE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function SE(e,t,r){return t&&CE(e.prototype,t),e}function gs(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var _E=(function(){function e(t,r){var n=this;bE(this,e),gs(this,"store",void 0),gs(this,"monitor",void 0),gs(this,"backend",void 0),gs(this,"isSetUp",!1),gs(this,"handleRefCountChange",function(){var s=n.store.getState().refCount>0;n.backend&&(s&&!n.isSetUp?(n.backend.setup(),n.isSetUp=!0):!s&&n.isSetUp&&(n.backend.teardown(),n.isSetUp=!1))}),this.store=t,this.monitor=r,t.subscribe(this.handleRefCountChange)}return SE(e,[{key:"receiveBackend",value:function(r){this.backend=r}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var r=this,n=this.store.dispatch;function s(o){return function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];var d=o.apply(r,c);typeof d<"u"&&n(d)}}var i=yE(this);return Object.keys(i).reduce(function(o,a){var c=i[a];return o[a]=s(c),o},{})}},{key:"dispatch",value:function(r){this.store.dispatch(r)}}]),e})();function Qt(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var yu=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),bu=function(){return Math.random().toString(36).substring(7).split("").join(".")},Cu={INIT:"@@redux/INIT"+bu(),REPLACE:"@@redux/REPLACE"+bu()};function wE(e){if(typeof e!="object"||e===null)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function xE(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(AE(e))return"date";if(EE(e))return"error";var r=TE(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}function TE(e){return typeof e.constructor=="function"?e.constructor.name:null}function EE(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function AE(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function kn(e){var t=typeof e;return process.env.NODE_ENV!=="production"&&(t=xE(e)),t}function rp(e,t,r){var n;if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?Qt(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(1):"Expected the enhancer to be a function. Instead, received: '"+kn(r)+"'");return r(rp)(e,t)}if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(2):"Expected the root reducer to be a function. Instead, received: '"+kn(e)+"'");var s=e,i=t,o=[],a=o,c=!1;function u(){a===o&&(a=o.slice())}function d(){if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function f(h){if(typeof h!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(4):"Expected the listener to be a function. Instead, received: '"+kn(h)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");var v=!0;return u(),a.push(h),function(){if(v){if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");v=!1,u();var C=a.indexOf(h);a.splice(C,1),o=null}}}function m(h){if(!wE(h))throw new Error(process.env.NODE_ENV==="production"?Qt(7):"Actions must be plain objects. Instead, the actual type was: '"+kn(h)+"'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");if(typeof h.type>"u")throw new Error(process.env.NODE_ENV==="production"?Qt(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(9):"Reducers may not dispatch actions.");try{c=!0,i=s(i,h)}finally{c=!1}for(var v=o=a,y=0;y<v.length;y++){var C=v[y];C()}return h}function p(h){if(typeof h!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(10):"Expected the nextReducer to be a function. Instead, received: '"+kn(h));s=h,m({type:Cu.REPLACE})}function b(){var h,v=f;return h={subscribe:function(C){if(typeof C!="object"||C===null)throw new Error(process.env.NODE_ENV==="production"?Qt(11):"Expected the observer to be an object. Instead, received: '"+kn(C)+"'");function S(){C.next&&C.next(d())}S();var _=v(S);return{unsubscribe:_}}},h[yu]=function(){return this},h}return m({type:Cu.INIT}),n={dispatch:m,subscribe:f,getState:d,replaceReducer:p},n[yu]=b,n}var kE=function(t,r){return t===r};function IE(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function DE(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kE;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!r(e[n],t[n]))return!1;return!0}function Su(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function _u(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Su(Object(r),!0).forEach(function(n){LE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Su(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function LE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var wu={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function OE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wu,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Ml:case ko:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case Io:return IE(e.clientOffset,r.clientOffset)?e:_u(_u({},e),{},{clientOffset:r.clientOffset});case Lo:case Do:return wu;default:return e}}var ql="dnd-core/ADD_SOURCE",$l="dnd-core/ADD_TARGET",Ul="dnd-core/REMOVE_SOURCE",Oo="dnd-core/REMOVE_TARGET";function NE(e){return{type:ql,payload:{sourceId:e}}}function jE(e){return{type:$l,payload:{targetId:e}}}function PE(e){return{type:Ul,payload:{sourceId:e}}}function RE(e){return{type:Oo,payload:{targetId:e}}}function xu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function Wt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?xu(Object(r),!0).forEach(function(n){FE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function FE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ME={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function BE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ME,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case ko:return Wt(Wt({},e),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case Bl:return Wt(Wt({},e),{},{isSourcePublic:!0});case Io:return Wt(Wt({},e),{},{targetIds:r.targetIds});case Oo:return e.targetIds.indexOf(r.targetId)===-1?e:Wt(Wt({},e),{},{targetIds:K1(e.targetIds,r.targetId)});case Do:return Wt(Wt({},e),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case Lo:return Wt(Wt({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function qE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case ql:case $l:return e+1;case Ul:case Oo:return e-1;default:return e}}var to=[],zl=[];to.__IS_NONE__=!0;zl.__IS_ALL__=!0;function $E(e,t){if(e===to)return!1;if(e===zl||typeof t>"u")return!0;var r=Z1(t,e);return r.length>0}function UE(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case Io:break;case ql:case $l:case Oo:case Ul:return to;case ko:case Bl:case Lo:case Do:default:return zl}var t=e.payload,r=t.targetIds,n=r===void 0?[]:r,s=t.prevTargetIds,i=s===void 0?[]:s,o=Y1(n,i),a=o.length>0||!DE(n,i);if(!a)return to;var c=i[i.length-1],u=n[n.length-1];return c!==u&&(c&&o.push(c),u&&o.push(u)),o}function zE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e+1}function Tu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function Eu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Tu(Object(r),!0).forEach(function(n){VE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function VE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function HE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:UE(e.dirtyHandlerIds,{type:t.type,payload:Eu(Eu({},t.payload),{},{prevTargetIds:G1(e,"dragOperation.targetIds",[])})}),dragOffset:OE(e.dragOffset,t),refCount:qE(e.refCount,t),dragOperation:BE(e.dragOperation,t),stateId:zE(e.stateId)}}function QE(e,t){return{x:e.x+t.x,y:e.y+t.y}}function np(e,t){return{x:e.x-t.x,y:e.y-t.y}}function WE(e){var t=e.clientOffset,r=e.initialClientOffset,n=e.initialSourceClientOffset;return!t||!r||!n?null:np(QE(t,n),r)}function GE(e){var t=e.clientOffset,r=e.initialClientOffset;return!t||!r?null:np(t,r)}function KE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function YE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ZE(e,t,r){return t&&YE(e.prototype,t),e}function Au(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var XE=(function(){function e(t,r){KE(this,e),Au(this,"store",void 0),Au(this,"registry",void 0),this.store=t,this.registry=r}return ZE(e,[{key:"subscribeToStateChange",value:function(r){var n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{handlerIds:void 0},i=s.handlerIds;xe(typeof r=="function","listener must be a function."),xe(typeof i>"u"||Array.isArray(i),"handlerIds, when specified, must be an array of strings.");var o=this.store.getState().stateId,a=function(){var u=n.store.getState(),d=u.stateId;try{var f=d===o||d===o+1&&!$E(u.dirtyHandlerIds,i);f||r()}finally{o=d}};return this.store.subscribe(a)}},{key:"subscribeToOffsetChange",value:function(r){var n=this;xe(typeof r=="function","listener must be a function.");var s=this.store.getState().dragOffset,i=function(){var a=n.store.getState().dragOffset;a!==s&&(s=a,r())};return this.store.subscribe(i)}},{key:"canDragSource",value:function(r){if(!r)return!1;var n=this.registry.getSource(r);return xe(n,"Expected to find a valid source. sourceId=".concat(r)),this.isDragging()?!1:n.canDrag(this,r)}},{key:"canDropOnTarget",value:function(r){if(!r)return!1;var n=this.registry.getTarget(r);if(xe(n,"Expected to find a valid target. targetId=".concat(r)),!this.isDragging()||this.didDrop())return!1;var s=this.registry.getTargetType(r),i=this.getItemType();return Ja(s,i)&&n.canDrop(this,r)}},{key:"isDragging",value:function(){return!!this.getItemType()}},{key:"isDraggingSource",value:function(r){if(!r)return!1;var n=this.registry.getSource(r,!0);if(xe(n,"Expected to find a valid source. sourceId=".concat(r)),!this.isDragging()||!this.isSourcePublic())return!1;var s=this.registry.getSourceType(r),i=this.getItemType();return s!==i?!1:n.isDragging(this,r)}},{key:"isOverTarget",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shallow:!1};if(!r)return!1;var s=n.shallow;if(!this.isDragging())return!1;var i=this.registry.getTargetType(r),o=this.getItemType();if(o&&!Ja(i,o))return!1;var a=this.getTargetIds();if(!a.length)return!1;var c=a.indexOf(r);return s?c===a.length-1:c>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return WE(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){return GE(this.store.getState().dragOffset)}}]),e})(),JE=0;function eA(){return JE++}function Fi(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fi=function(r){return typeof r}:Fi=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Fi(e)}function tA(e){xe(typeof e.canDrag=="function","Expected canDrag to be a function."),xe(typeof e.beginDrag=="function","Expected beginDrag to be a function."),xe(typeof e.endDrag=="function","Expected endDrag to be a function.")}function rA(e){xe(typeof e.canDrop=="function","Expected canDrop to be a function."),xe(typeof e.hover=="function","Expected hover to be a function."),xe(typeof e.drop=="function","Expected beginDrag to be a function.")}function el(e,t){if(t&&Array.isArray(e)){e.forEach(function(r){return el(r,!1)});return}xe(typeof e=="string"||Fi(e)==="symbol",t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}const ku=typeof global<"u"?global:self,sp=ku.MutationObserver||ku.WebKitMutationObserver;function ip(e){return function(){const r=setTimeout(s,0),n=setInterval(s,50);function s(){clearTimeout(r),clearInterval(n),e()}}}function nA(e){let t=1;const r=new sp(e),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){t=-t,n.data=t}}const sA=typeof sp=="function"?nA:ip;class iA{enqueueTask(t){const{queue:r,requestFlush:n}=this;r.length||(n(),this.flushing=!0),r[r.length]=t}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:t}=this;for(;this.index<t.length;){const r=this.index;if(this.index++,t[r].call(),this.index>this.capacity){for(let n=0,s=t.length-this.index;n<s;n++)t[n]=t[n+this.index];t.length-=this.index,this.index=0}}t.length=0,this.index=0,this.flushing=!1},this.registerPendingError=t=>{this.pendingErrors.push(t),this.requestErrorThrow()},this.requestFlush=sA(this.flush),this.requestErrorThrow=ip(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}}class oA{call(){try{this.task&&this.task()}catch(t){this.onError(t)}finally{this.task=null,this.release(this)}}constructor(t,r){this.onError=t,this.release=r,this.task=null}}class aA{create(t){const r=this.freeTasks,n=r.length?r.pop():new oA(this.onError,s=>r[r.length]=s);return n.task=t,n}constructor(t){this.onError=t,this.freeTasks=[]}}const op=new iA,lA=new aA(op.registerPendingError);function cA(e){op.enqueueTask(lA.create(e))}function uA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function fA(e,t,r){return t&&dA(e.prototype,t),e}function In(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hA(e,t){return vA(e)||gA(e,t)||mA(e,t)||pA()}function pA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
536
|
+
`+i)}}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=gn(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&Li.assertOptions(n,{silentJSONParsing:St.transitional(St.boolean),forcedJSONParsing:St.transitional(St.boolean),clarifyTimeoutError:St.transitional(St.boolean),legacyInterceptorReqResOrdering:St.transitional(St.boolean),advertiseZstdAcceptEncoding:St.transitional(St.boolean),validateStatusUndefinedResolves:St.transitional(St.boolean)},!1),s!=null&&(L.isFunction(s)?r.paramsSerializer={serialize:s}:Li.assertOptions(s,{encode:St.function,serialize:St.function},!0)),r.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?r.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:r.allowAbsoluteUrls=!0),Li.assertOptions(r,{baseUrl:St.spelling("baseURL"),withXsrfToken:St.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&L.merge(i.common,i[r.method]);i&&L.forEach(["delete","get","head","post","put","patch","query","common"],b=>{delete i[b]}),r.headers=kt.concat(o,i);const a=[];let c=!0;this.interceptors.request.forEach(function(h){if(typeof h.runWhen=="function"&&h.runWhen(r)===!1)return;c=c&&h.synchronous;const v=r.transitional||Ol;v&&v.legacyInterceptorReqResOrdering?a.unshift(h.fulfilled,h.rejected):a.push(h.fulfilled,h.rejected)});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let d,f=0,m;if(!c){const b=[eu.bind(this),void 0];for(b.unshift(...a),b.push(...u),m=b.length,d=Promise.resolve(r);f<m;)d=d.then(b[f++],b[f++]);return d}m=a.length;let p=r;for(;f<m;){const b=a[f++],h=a[f++];try{p=b(p)}catch(v){h.call(this,v);break}}try{d=eu.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,m=u.length;f<m;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=gn(this.defaults,t);const r=ch(t.baseURL,t.url,t.allowAbsoluteUrls,t);return sh(r,t.params,t.paramsSerializer)}};L.forEach(["delete","get","head","options"],function(t){hn.prototype[t]=function(r,n){return this.request(gn(n||{},{method:t,url:r,data:n&&L.hasOwnProp(n,"data")?n.data:void 0}))}});L.forEach(["post","put","patch","query"],function(t){function r(n){return function(i,o,a){return this.request(gn(a||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}hn.prototype[t]=r(),t!=="query"&&(hn.prototype[t+"Form"]=r(!0))});let Yx=class hh{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(a=>{n.subscribe(a),i=a}).then(s);return o.cancel=function(){n.unsubscribe(i)},o},t(function(i,o,a){n.reason||(n.reason=new si(i,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new hh(function(s){t=s}),cancel:t}}};function Zx(e){return function(r){return e.apply(null,r)}}function Xx(e){return L.isObject(e)&&e.isAxiosError===!0}const Ha={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ha).forEach(([e,t])=>{Ha[t]=e});function ph(e){const t=new hn(e),r=Vf(hn.prototype.request,t);return L.extend(r,hn.prototype,t,{allOwnKeys:!0}),L.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return ph(gn(e,s))},r}const rt=ph(ni);rt.Axios=hn;rt.CanceledError=si;rt.CancelToken=Yx;rt.isCancel=ah;rt.VERSION=jl;rt.toFormData=xo;rt.AxiosError=J;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=Zx;rt.isAxiosError=Xx;rt.mergeConfig=gn;rt.AxiosHeaders=kt;rt.formToJSON=e=>oh(L.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=fh.getAdapter;rt.HttpStatusCode=Ha;rt.default=rt;const{Axios:zq,AxiosError:Vq,CanceledError:Hq,isCancel:Qq,CancelToken:Wq,VERSION:Gq,all:Kq,Cancel:Yq,isAxiosError:Zq,spread:Xq,toFormData:Jq,AxiosHeaders:e$,HttpStatusCode:t$,formToJSON:r$,getAdapter:n$,mergeConfig:s$,create:i$}=rt;let Qa="";function mh(e){Qa=e}const Fe=rt.create({timeout:3e4});function Jx(e,t){if(!e||typeof t!="string"||!t.trim())return e;const r=t.trim().replace(/\/+$/,""),n=r.startsWith("/")?r:`/${r}`;return e.replace(/^\/(action|api|portal)(?=\/|$)/,n)}Fe.interceptors.request.use(async e=>{var s,i,o;const{useEditorStore:t}=await Promise.resolve().then(()=>ub),r=t.getState(),n=(s=r.editorConfig)==null?void 0:s.context;return e.headers=e.headers??{},n!=null&&n.authToken&&(e.headers.Authorization=`Bearer ${n.authToken}`),n!=null&&n.userToken&&(e.headers["X-Authenticated-User-Token"]=n.userToken),n!=null&&n.channel&&(e.headers["X-Channel-Id"]=n.channel),e.url=Jx(e.url,(o=(i=r.editorConfig)==null?void 0:i.config)==null?void 0:o.apiSlug),Qa&&(e.baseURL=Qa),e});const gh="/portal";async function vh(e){var n,s,i,o,a,c,u;const t=await Fe.get(`${gh}/questionset/v2/hierarchy/${e}`,{params:{mode:"edit"}}),r=(s=(n=t.data)==null?void 0:n.result)==null?void 0:s.questionset;if(!r||!r.identifier){const d=((o=(i=t.data)==null?void 0:i.params)==null?void 0:o.errmsg)||((c=(a=t.data)==null?void 0:a.params)==null?void 0:c.err)||((u=t.data)==null?void 0:u.responseCode)||`No questionset returned for "${e}"`;throw new Error(`Unable to load questionset hierarchy: ${d}`)}return r}async function e0(e){var r,n;return e.length?((n=(r=(await Fe.post(`${gh}/question/v2/list`,{request:{search:{identifier:e}}})).data)==null?void 0:r.result)==null?void 0:n.questions)??[]:[]}function Eo(e,t){const r=e??{},n=r.identifier??"",s=r.objectType??"",i=r.mimeType??"",o=r.children,a=Array.isArray(o)?o.map(u=>Eo(u,n)):[],c=i==="application/vnd.ekstep.content-collection"||s.toLowerCase().includes("unit")||s.toLowerCase().includes("textbook")||s.toLowerCase().includes("collection")||s.toLowerCase().includes("course")||s.toLowerCase().includes("lesson")||r.visibility==="Parent"||i==="application/vnd.sunbird.questionset"&&a.length>0;return{id:n,identifier:n,name:r.name??"Untitled",title:r.name??"Untitled",description:r.description,primaryCategory:r.primaryCategory,mimeType:r.mimeType,objectType:s,contentType:r.contentType,visibility:r.visibility,status:r.status,appIcon:r.appIcon,isFolder:c,children:a,metadata:r,parent:t}}async function yh(e){var s,i,o,a,c,u,d;const t=await Fe.get(`/action/collection/v1/hierarchy/${e}`,{params:{mode:"edit"}}),r=(i=(s=t.data)==null?void 0:s.result)==null?void 0:i.content;if(!r||!r.identifier){const f=((a=(o=t.data)==null?void 0:o.params)==null?void 0:a.errmsg)||((u=(c=t.data)==null?void 0:c.params)==null?void 0:u.err)||((d=t.data)==null?void 0:d.responseCode)||`No content returned for "${e}"`;throw new Error(`Unable to load hierarchy: ${f}`)}const n=Eo(r);return{content:r,rootNode:n}}async function t0(e){const t=await vh(e),r=Eo(t);return{content:t,rootNode:r}}async function r0(e,t,r,n){var i;return((i=(await Fe.patch("/action/collection/v1/hierarchy/update",{request:{data:{nodesModified:t,hierarchy:r,...n?{lastUpdatedBy:n}:{}}}})).data)==null?void 0:i.result)??{}}async function n0(e,t=""){await Fe.post(`/action/collection/v1/publish/${e}`,{request:{content:{lastPublishedBy:t}}})}async function bh(e){var n,s,i,o,a,c,u;const t=await Fe.get(`/action/course/v1/hierarchy/${e}`,{params:{mode:"edit"}}),r=(s=(n=t.data)==null?void 0:n.result)==null?void 0:s.content;if(!r||!r.identifier){const d=((o=(i=t.data)==null?void 0:i.params)==null?void 0:o.errmsg)||((c=(a=t.data)==null?void 0:a.params)==null?void 0:c.err)||((u=t.data)==null?void 0:u.responseCode)||`No course returned for "${e}"`;throw new Error(`Unable to load course hierarchy: ${d}`)}return r}async function s0(e){var r,n;return(n=(r=(await Fe.get(`/action/collection/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}async function i0(e){await Fe.post(`/action/collection/v1/review/${e}`,{request:{content:{}}})}async function o0(e,t){await Fe.post(`/action/collection/v1/reject/${e}`,{request:{content:{rejectComment:t}}})}async function a0(e,t){await Fe.patch(`/action/content/v1/collaborator/update/${e}`,{request:{content:{collaborators:t}}})}const l0="application/vnd.sunbird.questionset";function Ch(e){let t=!1,r=!0;function n(s){for(const i of s){const o=i.children??[];if(o.length>0){n(o);continue}t=!0,i.objectType==="QuestionSet"&&i.mimeType===l0||(r=!1)}}return n(e.children??[]),t&&r}const ru=new Map;async function Sh(e){const t=ru.get(e);if(t)return t;const r=await bh(e),{children:n,...s}=r??{},i={qualifies:Ch(r),meta:s};return ru.set(e,i),i}async function _h(e){return(await Sh(e)).qualifies}async function c0(e){var n;const t=e.children??[],r=[];for(let s=0;s<t.length;s++){const i=t[s],o=i.children??[],a=[];for(const c of o){let u=!!((n=c.metadata)!=null&&n.isAssessmentCourse);if(!u){if((c.children??[]).length>0)u=Ch(c);else if(o.length===1&&(s===0||s===t.length-1))try{u=await _h(c.identifier)}catch(d){console.error("[lpStructure] assessment-course check failed on load:",d)}}a.push({...c,isFolder:!1,children:[],metadata:{...c.metadata??{},...u?{isAssessmentCourse:!0}:{}}})}r.push({...i,children:a})}return{...e,children:r}}function lt(e){var r,n;const t=(e==null?void 0:e.children)??[];return t.length===1&&!!((n=(r=t[0])==null?void 0:r.metadata)!=null&&n.isAssessmentCourse)}function u0(e,t,r){return r?e===0?"pre":e===t-1?"post":"levelAssessment":"content"}function d0(e,t){const r=e.findIndex(s=>s.id===t);return r===-1?null:Bs(e,r)?{role:r===0?"pre":"post",levelNumber:null}:{role:"level",levelNumber:e.slice(0,r+1).filter((s,i)=>!Bs(e,i)).length}}function Ms(e,t){return t==="pre"?e.length>0&<(e[0]):e.length>1&<(e[e.length-1])}function Bs(e,t){const r=u0(t,e.length,lt(e[t]));return r==="pre"||r==="post"}function Wa(e,t){const r=t?e.findIndex(n=>n.id===t.id):-1;return r!==-1&&Bs(e,r)}function f0(e){return Ms(e,"pre")?Ms(e,"post")?null:"post":"pre"}function h0(e,t,r){if(t<0||t>=e.length)return!1;const n=lt(e[0])?e[0]:null,s=e.length>1&<(e[e.length-1])?e[e.length-1]:null;if(!n&&!s)return!0;const i=[...e],[o]=i.splice(t,1);return i.splice(r,0,o),!(n&&i[0]!==n||s&&i[i.length-1]!==s)}function nu(e,t,r){return r?!1:t?!((e==null?void 0:e.children)??[]).some(s=>{var i;return!!((i=s.metadata)!=null&&i.isAssessmentCourse)}):!0}function vn(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function wh(e,t){var n,s;return e?((n=t[e.id])==null?void 0:n.framework)??((s=e.metadata)==null?void 0:s.framework):void 0}function xh(e,t){return!!wh(e,t)}function Th(e,t){if(!e||!t)return[];const r=new Set,n=e.children??[];return n.forEach((s,i)=>{var o,a;Bs(n,i)?vn((o=s.children[0].metadata)==null?void 0:o[t]).forEach(c=>r.add(c)):vn((a=s.metadata)==null?void 0:a[t]).forEach(c=>r.add(c))}),Array.from(r)}function p0(e,t,r){var u,d;if(!e||!t)return null;const n=Th(e,t),s=((u=r[e.id])==null?void 0:u[t])??((d=e.metadata)==null?void 0:d[t]),i=vn(s),o=[...n].sort(),a=[...i].sort();return o.length===a.length&&o.every((f,m)=>f===a[m])?null:n}function m0(e,t,r){if(!e||!t||r.length===0)return[];const n=e.children??[];return n.filter((s,i)=>{var a;return Bs(n,i)?!1:vn((a=s.metadata)==null?void 0:a[t]).some(c=>!r.includes(c))})}function Eh(e,t,r){var s;if(!e||!r||t.length===0)return[];const n=new Set;for(const i of e.children??[])vn((s=i.metadata)==null?void 0:s[r]).forEach(o=>n.add(o));return t.filter(i=>!n.has(i))}const Ah=new Set(["adaptive"]);function Rl(e,t,r,n={}){var b,h,v,y;const s=[];if(!e)return s;const i=((b=n[e.id])==null?void 0:b.policy)??((h=e.metadata)==null?void 0:h.policy);i||s.push({code:"policyMissing",message:"Set a consumption policy for this path."});const o=e.children??[],a=o[0],c=o.length>1?o[o.length-1]:void 0,u=lt(a),d=lt(c);!u&&i&&Ah.has(i)&&s.push({code:"priorAssessmentRequired",message:"A Prior Assessment is required for the Adaptive policy."}),[[a,"Prior Assessment"],[c,"Outcome Assessment"]].forEach(([C,S])=>{var x,T;if(!C)return;const _=C.children??[];(_.length!==1||!((T=(x=_[0])==null?void 0:x.metadata)!=null&&T.isAssessmentCourse))&&s.push({code:"slotNotPure",nodeId:C.id,message:`${S} must contain exactly one question-set-only course.`})});const f=new Set,m=(C,S)=>{f.has(C)&&s.push({code:"duplicateCourse",nodeId:S,message:"A course appears more than once in this path."}),f.add(C)},p=o.slice(u?1:0,o.length-(d?1:0));u&&m(a.children[0].id,a.id),d&&m(c.children[0].id,c.id);for(const C of p){const S=C.children??[],_=S.length===0;_&&s.push({code:"emptyLevel",nodeId:C.id,message:`"${C.name}" has no courses yet.`});const x=t?vn((v=C.metadata)==null?void 0:v[t]):[];if(x.length===0)_||s.push({code:"levelMissingSkills",nodeId:C.id,message:`"${C.name}" needs at least one skill selected.`});else{if(r.length>0){const D=x.filter(E=>!r.includes(E));D.length>0&&s.push({code:"levelSkillsOutOfScope",nodeId:C.id,message:`"${C.name}" has skills outside the current scope: ${D.join(", ")}.`})}const T=Eh(C,x,t);T.length>0&&s.push({code:"levelSkillsUncovered",nodeId:C.id,message:`"${C.name}" has no course covering: ${T.join(", ")}.`})}for(const T of S)m(T.id,C.id),(t?vn((y=T.metadata)==null?void 0:y[t]):[]).length===0&&s.push({code:"courseMissingSkillTag",nodeId:T.id,message:`"${T.name}" has no skill tag.`})}return s}async function g0(e){const t=[],r=(e==null?void 0:e.children)??[],n=r[0],s=r.length>1?r[r.length-1]:void 0;for(const[i,o]of[[n,"Prior Assessment"],[s,"Outcome Assessment"]]){if(!i||!lt(i))continue;const a=i.children[0].id;await _h(a)||t.push({code:"slotCourseChanged",nodeId:i.id,message:`${o}'s course is no longer question-set-only — pick a different course.`})}return t}function Nt(e,t){const r=[...e];for(;r.length>0;){const n=r.shift();if(n.id===t)return n;n.children&&r.push(...n.children)}}function kh(e,t,r=0){var n;for(const s of e){if(s.id===t)return r;if((n=s.children)!=null&&n.length){const i=kh(s.children,t,r+1);if(i>=0)return i}}return-1}const su=new Set(["name","appIcon","description","keywords","trackable","qrCodeProcessId","reservedDialcodes"]);function Ih(e,t,r,n){return e.map(s=>{if(s.id===t){const i=r.metadata??{},o=n!=null&&n.length?new Set([...su,...n]):su,a={};for(const c of o)c in r&&(a[c]=r[c]);return{...s,...r,metadata:{...s.metadata??{},...a,...i}}}return s.children&&s.children.length>0?{...s,children:Ih(s.children,t,r,n)}:s})}function Oi(e,t,r){return e.map(n=>n.id===t?{...n,children:[...n.children??[],r]}:n.children&&n.children.length>0?{...n,children:Oi(n.children,t,r)}:n)}function Dh(e,t,r,n){return e.map(s=>{if(s.id===t){const i=[...s.children??[]];return i.splice(n,0,r),{...s,children:i}}return s.children&&s.children.length>0?{...s,children:Dh(s.children,t,r,n)}:s})}function Ga(e,t){return e.filter(r=>r.id!==t).map(r=>({...r,children:r.children?Ga(r.children,t):[]}))}function Ka(e,t,r,n){return e.map(s=>{if(s.id===t){const i=[...s.children??[]],[o]=i.splice(r,1);return i.splice(n,0,o),{...s,children:i}}return s.children&&s.children.length>0?{...s,children:Ka(s.children,t,r,n)}:s})}function Lh(e,t){return e.map(r=>{const n=t[r.id]??r.id,s=r.parent?t[r.parent]??r.parent:r.parent;return{...r,id:n,identifier:n,parent:s,children:r.children?Lh(r.children,t):[]}})}function v0(e){let t=0;const r=[...e];for(;r.length>0;){const n=r.shift();n.isFolder||t++,n.children&&r.push(...n.children)}return t}function y0(e,t){const r=Nt(e,t);if(!r)return[];const n=[];let s=r;for(;s;)n.unshift({id:s.id,name:s.name}),s=s.parent?Nt(e,s.parent):void 0;return n}const re=ei((e,t)=>({treeData:[],selectedNodeId:null,treeCache:{},breadcrumb:[],activeNodeMeta:{},setTreeData:r=>{var s;const n=((s=r[0])==null?void 0:s.id)??null;e({treeData:r,selectedNodeId:n}),n&&setTimeout(()=>t().selectNode(n),0)},selectNode:r=>{const{treeData:n,treeCache:s,getBreadcrumb:i}=t(),o=Nt(n,r),a=i(r),c={...(o==null?void 0:o.metadata)??{},...s[r]??{}};K.getState().setNodeFlags({isFolder:(o==null?void 0:o.isFolder)??!1,isRoot:!(o!=null&&o.parent),isQuml:!1}),yr.getState().setActiveAssessmentSlot(null),e({selectedNodeId:r,breadcrumb:a,activeNodeMeta:c})},updateNode:(r,n,s)=>{if(e(i=>({treeData:Ih(i.treeData,r,n,s),treeCache:{...i.treeCache,[r]:{...i.treeCache[r]??{},...n}}})),t().selectedNodeId===r){const i=Nt(t().treeData,r);e(o=>({activeNodeMeta:{...(i==null?void 0:i.metadata)??{},...o.treeCache[r]??{}}}))}t().markDirty()},addNode:(r,n)=>{var m,p,b;const s=t(),i=K.getState().editorProfile,o=((p=(m=K.getState().editorConfig)==null?void 0:m.config)==null?void 0:p.maxDepth)??i.maxDepth,a=kh(s.treeData,r);if(a>=o)return console.warn(`[tree.store] addNode: depth would exceed maxDepth (${o}). parentDepth=${a}`),"";const c="temp-"+Math.random().toString(36).slice(2),u={id:c,identifier:c,name:i.defaultUnitName,isFolder:!0,children:[],parent:r,metadata:{mimeType:"application/vnd.ekstep.content-collection",code:c,name:i.defaultUnitName,contentType:i.unitContentType,primaryCategory:i.unitPrimaryCategory,visibility:"Parent"}},d=((b=Nt(s.treeData,r))==null?void 0:b.children)??[],f=i.derivedRoles&&Ms(d,"post");return e(h=>({treeData:f?Dh(h.treeData,r,u,d.length-1):Oi(h.treeData,r,u),treeCache:{...h.treeCache,[c]:{...u.metadata,isNew:!0}}})),setTimeout(()=>t().selectNode(c),0),c},deleteNode:r=>{var s;const n=(s=t().treeData[0])==null?void 0:s.id;r!==n&&e(i=>({treeData:Ga(i.treeData,r),selectedNodeId:i.selectedNodeId===r?null:i.selectedNodeId}))},reorderChildren:(r,n,s)=>{var a;const i=K.getState().editorProfile,o=(a=t().treeData[0])==null?void 0:a.id;if(i.derivedRoles&&r===o){const c=Nt(t().treeData,r);if(c!=null&&c.children&&!h0(c.children,n,s))return}e(c=>({treeData:Ka(c.treeData,r,n,s)}))},moveNode:(r,n,s)=>{var u,d,f;const i=K.getState().editorProfile,o=Nt(t().treeData,r),a=Nt(t().treeData,s);if(!(a!=null&&a.isFolder))return;const c=(u=t().treeData[0])==null?void 0:u.id;if(!(i.derivedRoles&&(o!=null&&o.isFolder)&&s!==c)){if(i.derivedRoles&&o&&!o.isFolder){const m=!!((d=o.metadata)!=null&&d.isAssessmentCourse),p=((f=t().treeData[0])==null?void 0:f.children)??[];if(!nu(a,m,Wa(p,a)))return}e(m=>{const p=Nt(m.treeData,r);if(!p)return m;let b=Ga(m.treeData,r);return b=Oi(b,s,{...p,parent:s}),{treeData:b}}),t().markDirty()}},addResource:(r,n,s)=>{var b,h,v,y,C,S;const i=K.getState().editorConfig,o=K.getState().editorProfile,a=(b=t().treeData[0])==null?void 0:b.id,c=!!(s!=null&&s.isAssessmentCourse);if(o.derivedRoles&&n===a){if(!c||Nt(t().treeData,r.identifier))return!1;const _=t().treeData[0],x=(_==null?void 0:_.children)??[],T=(s==null?void 0:s.slot)??f0(x);if(!T||Ms(x,T))return!1;const D=t().addNode(a,"unit");if(!D)return!1;const{learningPath:E}=kl.getState().labelConfig;if(t().updateNode(D,{name:T==="pre"?E.priorAssessmentLabel:E.outcomeAssessmentLabel}),T==="pre"){const j=(((v=(h=t().treeData[0])==null?void 0:h.children)==null?void 0:v.length)??1)-1;e(P=>({treeData:Ka(P.treeData,a,j,0)}))}return t().addResource(r,D,s)}if(!(((y=i==null?void 0:i.config)==null?void 0:y.allowContentUnderRoot)??!1)&&n===a||Nt(t().treeData,r.identifier))return!1;const d=Nt(t().treeData,n);if(!(d!=null&&d.isFolder))return!1;if(o.derivedRoles){const _=((C=t().treeData[0])==null?void 0:C.children)??[];if(!nu(d,c,Wa(_,d)))return!1}const f=((S=i==null?void 0:i.config)==null?void 0:S.maxContentsLimit)??1200;if(v0(t().treeData)>=f)return!1;const p={id:r.identifier,identifier:r.identifier,name:r.name,isFolder:!1,children:[],parent:n,mimeType:r.mimeType,primaryCategory:r.primaryCategory,contentType:r.contentType,appIcon:r.appIcon,status:r.status,metadata:{...r,...c?{isAssessmentCourse:!0}:{}}};return e(_=>({treeData:Oi(_.treeData,n,p)})),t().markDirty(),!0},markDirty:()=>{const{editorMode:r,setIsDirty:n}=K.getState();r==="edit"&&n(!0)},pruneCoursesByFramework:r=>{let n=0;return e(s=>{const i=s.treeData[0];if(!i)return s;const o=[];for(const a of i.children??[]){const c=lt(a),u=(a.children??[]).filter(d=>{var p;if(d.isFolder)return!0;const f=(p=d.metadata)==null?void 0:p.framework,m=!f||(Array.isArray(f)?f.includes(r):f===r);return m||n++,m});c&&u.length===0||o.push(u.length===(a.children??[]).length?a:{...a,children:u})}return n===0?s:{treeData:[{...i,children:o}]}}),n>0&&t().markDirty(),n},clearLevelSkills:r=>{if(!r)return 0;let n=0;return e(s=>{const i=s.treeData[0];if(!i)return s;const o={...s.treeCache},a=(i.children??[]).map(c=>{var m,p;if(!(((m=c.metadata)==null?void 0:m[r])!==void 0||((p=o[c.id])==null?void 0:p[r])!==void 0))return c;n++;const{[r]:d,...f}=c.metadata??{};if(o[c.id]){const{[r]:b,...h}=o[c.id];o[c.id]=h}return{...c,metadata:f}});return n===0?s:{treeData:[{...i,children:a}],treeCache:o}}),n>0&&t().markDirty(),n},replaceNodeIds:r=>{!r||Object.keys(r).length===0||e(n=>{const s=Lh(n.treeData,r),i={};for(const[a,c]of Object.entries(n.treeCache)){const u=r[a]??a,{isNew:d,...f}=c;i[u]=f}const o=n.selectedNodeId?r[n.selectedNodeId]??n.selectedNodeId:null;return{treeData:s,treeCache:i,selectedNodeId:o}})},getNodeById:r=>Nt(t().treeData,r),getChildrenOf:r=>{const n=Nt(t().treeData,r);return(n==null?void 0:n.children)??[]},getBreadcrumb:r=>y0(t().treeData,r)})),b0="_spin_1ah4d_9",C0={spin:b0};function oe(){return kl(e=>e.labelConfig)}const S0=({size:e=16,color:t="currentColor"})=>{const r=oe();return l.jsx("svg",{className:C0.spin,width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-label":r.spinner.loading,role:"status",children:l.jsx("circle",{cx:"12",cy:"12",r:"10",stroke:t,strokeWidth:"3",strokeDasharray:"31.4",strokeDashoffset:"10",strokeLinecap:"round"})})},Re=({variant:e="ghost",size:t="md",isLoading:r,disabled:n,onClick:s,children:i,className:o,type:a="button"})=>l.jsxs("button",{type:a,className:`sbx-btn-${e} ${t==="sm"?"sbx-btn-sm":""} ${o??""}`,onClick:s,disabled:r||n,"aria-busy":r?!0:void 0,children:[r?l.jsx(S0,{size:14}):null,i]}),Oh=({size:e=16,...t})=>l.jsxs("svg",{width:e,height:e,viewBox:"0 0 64 64",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[l.jsx("circle",{cx:"58",cy:"12",r:"4",stroke:"currentColor",strokeWidth:"4"}),l.jsx("circle",{cx:"8",cy:"58",r:"4",stroke:"currentColor",strokeWidth:"4"}),l.jsx("path",{d:"M52 12 H24 A12 12 0 0 0 24 36 H40 A12 12 0 0 1 40 60 H12",stroke:"currentColor",strokeWidth:"4",strokeLinecap:"round",strokeLinejoin:"round"})]});async function iu(e){var r,n;return(n=(r=(await Fe.get(`/action/framework/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.framework}async function _0(e){var r,n;return((n=(r=(await Fe.post("/action/composite/v3/search",{request:{filters:{objectType:"Framework",status:["Live"],...e.type?{type:e.type}:{},...e.identifier?{identifier:e.identifier}:{},...e.channel?{channel:e.channel}:{},...e.systemDefault?{systemDefault:e.systemDefault}:{}}}})).data)==null?void 0:r.result)==null?void 0:n.Framework)??[]}function Ao(e,t){const r=Jn({queryKey:["framework",e],queryFn:()=>iu(e),enabled:!!e,staleTime:3e5}),n=t==null?void 0:t[0],s=Jn({queryKey:["framework",n],queryFn:()=>iu(n),enabled:!!n,staleTime:300*1e3}),i=s.data?[s.data]:[];return{organisationFramework:r.data,targetFrameworks:i,isLoading:r.isLoading||s.isLoading}}function Nh(e){if(!(e!=null&&e.length))return null;const t=e.reduce((r,n)=>(n.index??-1/0)>(r.index??-1/0)?n:r);return{code:t.code,terms:t.terms??[]}}function w0(e){var n,s,i,o;const t=(n=e==null?void 0:e.children)==null?void 0:n[0];if(!lt(t))return;const r=(o=(i=(s=t==null?void 0:t.children)==null?void 0:s[0])==null?void 0:i.metadata)==null?void 0:o.framework;return Array.isArray(r)?r[0]:r}function lr(){var i;const e=K(o=>o.editorConfig),t=K(o=>o.contentFramework),r=re(o=>o.treeData),n=w0(r[0])??t??((i=e==null?void 0:e.context)==null?void 0:i.framework),{organisationFramework:s}=Ao(n);return Nh(s==null?void 0:s.categories)}function x0(e,t,r){var u,d,f,m;const n={scope:((t==null?void 0:t.terms)??[]).map(p=>p.name),source:"manual"};if(!t)return n;const s=(u=e==null?void 0:e.children)==null?void 0:u[0];if(!lt(s))return n;const i=(d=s==null?void 0:s.children)==null?void 0:d[0];if(!i)return n;const a=((f=r[i.id])==null?void 0:f[t.code])??((m=i.metadata)==null?void 0:m[t.code]);return{scope:Array.isArray(a)?a:a?[a]:[],source:"prior"}}function ii(){const e=lr(),t=re(n=>n.treeData),r=re(n=>n.treeCache);return g.useMemo(()=>x0(t[0],e,r),[t,e,r])}const T0="_overlay_kdzmi_1",E0="_modal_kdzmi_15",A0="_modalHeader_kdzmi_27",k0="_modalHeaderClose_kdzmi_37",I0="_modalBody_kdzmi_55",D0="_modalFooter_kdzmi_62",L0="_checkRow_kdzmi_69",O0="_formGroup_kdzmi_112",N0="_textarea_kdzmi_123",j0="_sliderGroup_kdzmi_144",P0="_sliderValue_kdzmi_156",R0="_sliderLabels_kdzmi_164",F0="_sectionTitle_kdzmi_172",Ae={overlay:T0,modal:E0,modalHeader:A0,modalHeaderClose:k0,modalBody:I0,modalFooter:D0,checkRow:L0,formGroup:O0,textarea:N0,sliderGroup:j0,sliderValue:P0,sliderLabels:R0,sectionTitle:F0},M0=({objectType:e,onConfirm:t,onCancel:r})=>{const n=oe(),s=re(b=>b.treeData[0]),i=re(b=>b.treeCache),o=lr(),{scope:a}=ii(),[c,u]=g.useState(null),d=Rl(s,o==null?void 0:o.code,a,i);g.useEffect(()=>{let b=!1;return u(null),g0(s).then(h=>{b||u(h)}),()=>{b=!0}},[s]);const f=c===null,m=[...d,...c??[]],p=!f&&m.length===0;return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",e]}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:m.length===0?l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:f?n.learningPath.verifyingAssessmentCourses:`${n.publishChecklist.confirmPublishPrefix} ${e}?`}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ae.sectionTitle,children:n.learningPath.resolveBeforePublishing}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:m.map((b,h)=>l.jsx("li",{children:b.message},`${b.code}-${b.nodeId??h}`))})]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(Re,{variant:"primary",onClick:t,disabled:!p,children:n.publishChecklist.yesButton})]})]})})},B0=({contentId:e,onConfirm:t,onCancel:r})=>{const n=oe(),s=K(m=>{var p,b;return(b=(p=m.editorConfig)==null?void 0:p.config)==null?void 0:b.objectType})||"Content",i=K(m=>m.editorProfile.key==="learningPath"),o=K(m=>m.publishChecklist)??[],[a,c]=g.useState({}),u=o.every(m=>a[m.code]),d=o.length===0||u,f=()=>{t()};return i?l.jsx(M0,{objectType:s,onConfirm:t,onCancel:r}):l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",s]}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:o.length===0?l.jsxs("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:[n.publishChecklist.confirmPublishPrefix," ",s,"?"]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ae.sectionTitle,children:n.publishChecklist.checklistInstructions}),o.map(m=>l.jsxs("label",{className:Ae.checkRow,children:[l.jsx("input",{type:"checkbox",checked:!!a[m.code],onChange:p=>c(b=>({...b,[m.code]:p.target.checked}))}),l.jsx("span",{children:m.label})]},m.code))]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(Re,{variant:"primary",onClick:f,disabled:!d,children:n.publishChecklist.yesButton})]})]})})},q0=({contentId:e,action:t,onConfirm:r,onCancel:n})=>{const s=oe(),[i,o]=g.useState(""),[a,c]=g.useState(7),u=t==="approve",d=u?s.qualityParamsModal.reviewQualityTitle:s.qualityParamsModal.rejectContentTitle,f=!u&&i.trim().length===0,m=()=>{u?r(i.trim(),a):r(i.trim())};return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"quality-modal-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"quality-modal-title",children:d}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:n,"aria-label":s.qualityParamsModal.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:u?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ae.formGroup,children:[l.jsx("label",{htmlFor:"quality-score",children:s.qualityParamsModal.qualityScoreLabel}),l.jsxs("div",{className:Ae.sliderGroup,children:[l.jsx("input",{id:"quality-score",type:"range",min:0,max:10,step:1,value:a,onChange:p=>c(Number(p.target.value)),"aria-valuemin":0,"aria-valuemax":10,"aria-valuenow":a}),l.jsx("span",{className:Ae.sliderValue,children:a})]}),l.jsxs("div",{className:Ae.sliderLabels,children:[l.jsx("span",{children:s.qualityParamsModal.scorePoorLabel}),l.jsx("span",{children:s.qualityParamsModal.scoreExcellentLabel})]})]}),l.jsxs("div",{className:Ae.formGroup,children:[l.jsxs("label",{htmlFor:"quality-comment",children:[s.qualityParamsModal.commentLabel," ",l.jsx("span",{style:{fontWeight:400,color:"var(--sbx-gray-400, #9CA3AF)"},children:s.qualityParamsModal.optionalLabel})]}),l.jsx("textarea",{id:"quality-comment",className:Ae.textarea,placeholder:s.qualityParamsModal.commentPlaceholder,value:i,onChange:p=>o(p.target.value),rows:4})]})]}):l.jsxs("div",{className:Ae.formGroup,children:[l.jsxs("label",{htmlFor:"reject-reason",children:[s.qualityParamsModal.rejectionReasonLabel," ",l.jsx("span",{style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("textarea",{id:"reject-reason",className:Ae.textarea,placeholder:s.qualityParamsModal.rejectReasonPlaceholder,value:i,onChange:p=>o(p.target.value),rows:5,required:!0,"aria-required":"true"}),i.trim().length===0&&l.jsx("p",{style:{fontSize:12,color:"var(--sbx-error, #DC2626)",marginTop:4},children:s.qualityParamsModal.rejectionRequiredMessage})]})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:n,children:s.qualityParamsModal.cancelButton}),l.jsx(Re,{variant:u?"primary":"danger",onClick:m,disabled:f,children:u?s.qualityParamsModal.approveButton:s.qualityParamsModal.rejectButton})]})]})})},$0=({message:e,onConfirm:t,onCancel:r})=>{const n=oe();return xr.createPortal(l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"confirm-dialog-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"confirm-dialog-title",children:n.confirmDialog.title}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":n.confirmDialog.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:e})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,children:n.confirmDialog.cancelButton}),l.jsx(Re,{variant:"danger",onClick:t,children:n.confirmDialog.confirmButton})]})]})}),document.body)},jh=["email","firstName","lastName","identifier","organisations","rootOrgName","phone"];async function U0(e,t={}){var c,u,d,f;const n={"organisations.roles":[((c=t.objectType)==null?void 0:c.toLowerCase())==="textbook"?"BOOK_CREATOR":"CONTENT_CREATOR"]};t.rootOrgId&&(n.rootOrgId=[t.rootOrgId]);const s=e.includes("@"),i=/^\d{10,}$/.test(e.trim()),o={filters:n,fields:jh,offset:0,limit:t.limit??200};return s?n.email=e.trim():i?n.phone=e.trim():o.query=e,((f=(d=(u=(await Fe.post("/action/user/v1/search",{request:o},{params:{fields:"orgName"},headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:u.result)==null?void 0:d.response)==null?void 0:f.content)??[]}async function z0(e){var r,n,s;return e.length?((s=(n=(r=(await Fe.post("/action/user/v1/search",{request:{filters:{userId:e},fields:jh,limit:e.length}},{headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:r.result)==null?void 0:n.response)==null?void 0:s.content)??[]:[]}async function V0(e){var r,n;return((n=(r=(await Fe.get(`/portal/user/v5/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.response)??{}}const H0="_container_1hnn8_1",Q0="_header_1hnn8_13",W0="_title_1hnn8_22",G0="_closeBtn_1hnn8_29",K0="_body_1hnn8_45",Y0="_label_1hnn8_54",Z0="_searchSection_1hnn8_62",X0="_searchRow_1hnn8_68",J0="_searchInput_1hnn8_74",eT="_searchSpinner_1hnn8_89",tT="_resultsList_1hnn8_105",rT="_resultItem_1hnn8_118",nT="_userInfo_1hnn8_133",sT="_userName_1hnn8_141",iT="_userEmail_1hnn8_150",oT="_userOrg_1hnn8_158",aT="_noResults_1hnn8_167",lT="_collabSection_1hnn8_174",cT="_sectionTitle_1hnn8_179",uT="_badge_1hnn8_189",dT="_emptyCollab_1hnn8_203",fT="_collabList_1hnn8_214",hT="_collabItem_1hnn8_223",pT="_userAvatar_1hnn8_237",mT="_error_1hnn8_251",gT="_success_1hnn8_257",vT="_footer_1hnn8_263",Pe={container:H0,header:Q0,title:W0,closeBtn:G0,body:K0,label:Y0,searchSection:Z0,searchRow:X0,searchInput:J0,searchSpinner:eT,resultsList:tT,resultItem:rT,userInfo:nT,userName:sT,userEmail:iT,userOrg:oT,noResults:aT,collabSection:lT,sectionTitle:cT,badge:uT,emptyCollab:dT,collabList:fT,collabItem:hT,userAvatar:pT,error:mT,success:gT,footer:vT},yT=({contentId:e,onClose:t})=>{var j,P;const r=oe(),n=K(O=>O.editorConfig),s=(j=n==null?void 0:n.context)==null?void 0:j.channel,i=(P=n==null?void 0:n.config)==null?void 0:P.objectType,[o,a]=g.useState(""),[c,u]=g.useState([]),[d,f]=g.useState(!1),[m,p]=g.useState([]),[b,h]=g.useState(!1),[v,y]=g.useState(""),[C,S]=g.useState(!1),_=g.useRef(null);g.useEffect(()=>{let O=!1;return(async()=>{try{const N=await s0(e),R=(N==null?void 0:N.collaborators)??[];if(!R.length)return;const M=await z0(R);if(O)return;const $=R.map(ee=>M.find(H=>H.identifier===ee)??{identifier:ee,firstName:ee});p($)}catch{}})(),()=>{O=!0}},[e]),g.useEffect(()=>{_.current&&clearTimeout(_.current);const O=o.trim();if(O.length<2){u([]);return}return _.current=setTimeout(async()=>{f(!0);try{const N=await U0(O,{rootOrgId:s,objectType:i}),R=new Set(m.map(M=>M.identifier));u(N.filter(M=>!R.has(M.identifier)))}catch{u([])}finally{f(!1)}},300),()=>{_.current&&clearTimeout(_.current)}},[o,m,s,i]);const x=g.useCallback(O=>{p(N=>N.find(R=>R.identifier===O.identifier)?N:[...N,O]),u(N=>N.filter(R=>R.identifier!==O.identifier)),S(!1)},[]),T=g.useCallback(O=>{p(N=>N.filter(R=>R.identifier!==O)),S(!1)},[]),D=g.useCallback(async()=>{h(!0),y(""),S(!1);try{await a0(e,m.map(O=>O.identifier)),S(!0)}catch{y(r.manageCollaborators.saveFailed)}finally{h(!1)}},[e,m,r.manageCollaborators.saveFailed]),E=O=>`${O.firstName}${O.lastName?` ${O.lastName}`:""}`;return l.jsxs("div",{className:Pe.container,children:[l.jsxs("div",{className:Pe.header,children:[l.jsx("h2",{className:Pe.title,children:r.manageCollaborators.title}),l.jsx("button",{className:Pe.closeBtn,onClick:t,"aria-label":r.manageCollaborators.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Pe.body,children:[l.jsxs("div",{className:Pe.searchSection,children:[l.jsx("label",{className:Pe.label,htmlFor:"collab-search",children:r.manageCollaborators.searchUsersLabel}),l.jsxs("div",{className:Pe.searchRow,children:[l.jsx("input",{id:"collab-search",type:"text",className:Pe.searchInput,placeholder:r.manageCollaborators.searchPlaceholder,value:o,onChange:O=>a(O.target.value)}),d&&l.jsx("span",{className:Pe.searchSpinner,"aria-label":r.manageCollaborators.searchingAriaLabel})]}),c.length>0&&l.jsx("ul",{className:Pe.resultsList,role:"listbox","aria-label":r.manageCollaborators.searchResultsAriaLabel,children:c.map(O=>{var N,R,M,$;return l.jsxs("li",{className:Pe.resultItem,role:"option","aria-selected":"false",children:[l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:E(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((R=(N=O.organisations)==null?void 0:N[0])==null?void 0:R.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:(($=(M=O.organisations)==null?void 0:M[0])==null?void 0:$.orgName)??O.rootOrgName})]}),l.jsx(Re,{variant:"primary",size:"sm",onClick:()=>x(O),children:r.manageCollaborators.add})]},O.identifier)})}),o.trim().length>=2&&!d&&c.length===0&&l.jsx("p",{className:Pe.noResults,children:r.manageCollaborators.noUsersFound})]}),l.jsxs("div",{className:Pe.collabSection,children:[l.jsxs("h3",{className:Pe.sectionTitle,children:[r.manageCollaborators.currentCollaborators,m.length>0&&l.jsx("span",{className:Pe.badge,children:m.length})]}),m.length===0?l.jsx("p",{className:Pe.emptyCollab,children:r.manageCollaborators.noCollaboratorsYet}):l.jsx("ul",{className:Pe.collabList,children:m.map(O=>{var N,R,M,$;return l.jsxs("li",{className:Pe.collabItem,children:[l.jsx("div",{className:Pe.userAvatar,"aria-hidden":"true",children:E(O).charAt(0).toUpperCase()}),l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:E(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((R=(N=O.organisations)==null?void 0:N[0])==null?void 0:R.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:(($=(M=O.organisations)==null?void 0:M[0])==null?void 0:$.orgName)??O.rootOrgName})]}),l.jsx(Re,{variant:"danger",size:"sm",onClick:()=>T(O.identifier),children:r.manageCollaborators.remove})]},O.identifier)})})]}),v&&l.jsx("p",{className:Pe.error,role:"alert",children:v}),C&&l.jsx("p",{className:Pe.success,role:"status",children:r.manageCollaborators.saveSuccess})]}),l.jsxs("div",{className:Pe.footer,children:[l.jsx(Re,{variant:"ghost",onClick:t,disabled:b,children:r.manageCollaborators.cancel}),l.jsx(Re,{variant:"primary",isLoading:b,onClick:D,children:r.manageCollaborators.save})]})]})};async function bT(e){return(await Fe.post("/api/dialcode/v1/read",{request:{dialcodes:[e]}})).data}async function CT(e,t){var s;const n=((s=(await Fe.post(`/action/dialcode/v1/reserve/${e}`,{request:{dialcodes:{count:t,qrCodeSpec:{errorCorrectionLevel:"H"}}}})).data)==null?void 0:s.result)??{};return{processId:n.processId??"",reservedDialcodes:n.reservedDialcodes??{}}}async function ST(e){var n;const r=((n=(await Fe.get(`/action/dialcode/v1/process/status/${e}`)).data)==null?void 0:n.result)??{status:"PENDING"};return{...r,status:r.status==="PENDING"?"in-process":r.status}}const _T="_topbar_c3y0z_1",wT="_left_c3y0z_15",xT="_right_c3y0z_23",TT="_backBtn_c3y0z_30",ET="_title_c3y0z_49",AT="_profileBadge_c3y0z_61",kT="_statusChip_c3y0z_76",IT="_savedIndicator_c3y0z_88",DT="_unsaved_c3y0z_98",LT="_iconBtn_c3y0z_103",OT="_iconBtnLabel_c3y0z_130",NT="_qrDropdown_c3y0z_134",jT="_qrMenu_c3y0z_138",PT="_reviewBtns_c3y0z_173",RT="_sourcingBtns_c3y0z_182",FT="_modalOverlay_c3y0z_191",MT="_sbOverlay_c3y0z_201",BT="_sbModal_c3y0z_211",qT="_sbModalHeader_c3y0z_222",$T="_sbModalTitle_c3y0z_230",UT="_sbModalClose_c3y0z_237",zT="_sbModalBody_c3y0z_250",VT="_sbLabel_c3y0z_257",HT="_sbTextarea_c3y0z_264",QT="_sbError_c3y0z_281",WT="_sbModalFooter_c3y0z_288",_e={topbar:_T,left:wT,right:xT,backBtn:TT,title:ET,profileBadge:AT,statusChip:kT,savedIndicator:IT,unsaved:DT,iconBtn:LT,iconBtnLabel:OT,qrDropdown:NT,qrMenu:jT,reviewBtns:PT,sourcingBtns:RT,modalOverlay:FT,sbOverlay:MT,sbModal:BT,sbModalHeader:qT,sbModalTitle:$T,sbModalClose:UT,sbModalBody:zT,sbLabel:VT,sbTextarea:HT,sbError:QT,sbModalFooter:WT};function GT(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function KT(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}const YT=({titleText:e,labelText:t,placeholderText:r,submitLabel:n,submitVariant:s="primary",onConfirm:i,onCancel:o})=>{const a=oe(),[c,u]=g.useState(""),d=e.toLowerCase().replace(/\s+/g,"-");return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":`${d}-title`,children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:`${d}-title`,className:_e.sbModalTitle,children:e}),l.jsx("button",{className:_e.sbModalClose,onClick:o,"aria-label":a.reviewCommentModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:_e.sbModalBody,children:[l.jsxs("label",{className:_e.sbLabel,htmlFor:`${d}-comment`,children:[t," ",l.jsx("span",{"aria-hidden":"true",style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("textarea",{id:`${d}-comment`,className:_e.sbTextarea,placeholder:r,value:c,onChange:f=>u(f.target.value),rows:4,required:!0,"aria-required":"true"}),c.trim().length===0&&l.jsx("p",{className:_e.sbError,children:a.reviewCommentModal.fillCommentsError})]}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:o,children:a.reviewCommentModal.cancelButton}),l.jsx(Re,{variant:s,onClick:()=>i(c.trim()),disabled:c.trim().length===0,children:n})]})]})})},ZT=({onConfirm:e,onCancel:t})=>{const r=oe(),[n,s]=g.useState(!1),i=K(m=>m.editorProfile.key==="learningPath"),o=re(m=>m.treeData[0]),a=re(m=>m.treeCache),c=lr(),{scope:u}=ii(),d=i?Rl(o,c==null?void 0:c.code,u,a):[],f=d.length>0;return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"review-confirm-title",children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:"review-confirm-title",className:_e.sbModalTitle,children:r.confirmReviewModal.title}),l.jsx("button",{className:_e.sbModalClose,onClick:t,"aria-label":r.confirmReviewModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsx("div",{className:_e.sbModalBody,children:f?l.jsxs(l.Fragment,{children:[l.jsx("p",{style:{margin:"0 0 8px",fontSize:13,fontWeight:600},children:r.learningPath.resolveBeforeSendingForReview}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:d.map((m,p)=>l.jsx("li",{children:m.message},`${m.code}-${m.nodeId??p}`))})]}):l.jsxs("label",{style:{display:"flex",gap:8,alignItems:"flex-start",fontSize:13,lineHeight:1.55},children:[l.jsx("input",{type:"checkbox",checked:n,onChange:m=>s(m.target.checked),style:{marginTop:2}}),l.jsxs("span",{children:[r.confirmReviewModal.agreementTextPart1," ",l.jsx("a",{className:"sb-color-primary",style:{fontWeight:600},href:"https://creativecommons.org/licenses",target:"_blank",rel:"noreferrer",children:r.confirmReviewModal.creativeCommonsLinkText})," ",r.confirmReviewModal.agreementTextPart2," ",l.jsx("strong",{children:r.confirmReviewModal.contentPolicyText}),r.confirmReviewModal.agreementTextPart3]})]})}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:t,children:r.confirmReviewModal.cancelButton}),!f&&l.jsx(Re,{variant:"primary",onClick:e,disabled:!n,children:r.confirmReviewModal.submitButton})]})]})})},XT=({onConfirm:e,onCancel:t})=>{const r=oe(),[n,s]=g.useState(""),i=parseInt(n,10),o=!isNaN(i)&&i>=2&&i<=250;return l.jsx("div",{className:_e.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"genqr-title",children:l.jsxs("div",{className:_e.sbModal,children:[l.jsxs("div",{className:_e.sbModalHeader,children:[l.jsx("span",{id:"genqr-title",className:_e.sbModalTitle,children:r.generateQRModal.title}),l.jsx("button",{className:_e.sbModalClose,onClick:t,"aria-label":r.generateQRModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:_e.sbModalBody,children:[l.jsxs("label",{className:_e.sbLabel,htmlFor:"qr-count",children:[r.generateQRModal.numberOfCodesLabel," ",l.jsx("span",{"aria-hidden":"true",style:{color:"var(--sbx-error, #DC2626)"},children:"*"})]}),l.jsx("input",{id:"qr-count",type:"number",min:2,max:250,className:_e.sbTextarea,style:{resize:"none",height:"40px"},placeholder:r.generateQRModal.countPlaceholder,value:n,onChange:a=>s(a.target.value)}),n&&!o&&l.jsx("p",{className:_e.sbError,children:r.generateQRModal.countRangeError})]}),l.jsxs("div",{className:_e.sbModalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:t,children:r.generateQRModal.cancelButton}),l.jsx(Re,{variant:"primary",onClick:()=>e(i),disabled:!o,children:r.generateQRModal.generateButton})]})]})})},JT=({editorMode:e,isSaving:t,isDirty:r,lastSaved:n,isFormValid:s=!0,onToolbarEvent:i})=>{var be,me;const o=oe(),c=re(le=>le.treeData)[0],u=(c==null?void 0:c.name)??o.contextualEditor.untitledPlaceholder,d=KT(((be=c==null?void 0:c.metadata)==null?void 0:be.status)??(c==null?void 0:c.status),o.topbar.draftStatusFallback),f=K(le=>{var ve,Te,Y,ce;return((Te=(ve=le.editorConfig)==null?void 0:ve.context)==null?void 0:Te.contentId)??((ce=(Y=le.editorConfig)==null?void 0:Y.context)==null?void 0:ce.identifier)??""}),{activeModal:m,modalData:p,closeModal:b,openModal:h}=yr(),v=K(le=>le.buttonLoaders),y=K(le=>le.categoryMeta),C=K(le=>le.editorProfile),S=C.key==="learningPath",_=C.features.dialcodes&&(!y||y.schemaDefaults.generateDIALCodes!=="No"),[x,T]=g.useState(!1),[D,E]=g.useState(!1),[j,P]=g.useState(!1),O=g.useRef(null),[N,R]=g.useState(!1);g.useEffect(()=>{if(!j)return;const le=ve=>{var Te;(Te=O.current)!=null&&Te.contains(ve.target)||P(!1)};return document.addEventListener("mousedown",le),()=>document.removeEventListener("mousedown",le)},[j]);const[M,$]=g.useState(!1),[ee,H]=g.useState(!1),{updateNode:te}=re(),de=(me=c==null?void 0:c.metadata)==null?void 0:me.qrCodeProcessId,fe=g.useCallback(async le=>{if(f){R(!1),$(!0);try{const{processId:ve,reservedDialcodes:Te}=await CT(f,le);ve&&c&&te(c.id,{qrCodeProcessId:ve,reservedDialcodes:Te}),Se.success(o.topbar.qrGenerationStartedToast)}catch{Se.error(o.topbar.qrGenerationFailedToast)}finally{$(!1)}}},[f,c,te,o]),pe=g.useCallback(async()=>{if(!de){Se.error(o.topbar.qrCodesNotGeneratedToast);return}H(!0);try{const le=await ST(de);if(le.status==="in-process"){Se(o.topbar.qrGenerationInProgressToast,{icon:l.jsx(Bn,{size:16})});return}const ve=le.url;if(!ve){Se.error(o.topbar.qrCodesNotReadyToast);return}const Te=await fetch(ve).then(We=>We.blob()),Y=await new Promise(We=>{const tt=new FileReader;tt.onloadend=()=>We(tt.result),tt.readAsDataURL(Te)}),ce=(c==null?void 0:c.metadata)??{},Q=We=>Array.isArray(We)?We.join("_"):typeof We=="string"?We:"",Ce=[f,Q(ce.medium),Q(ce.gradeLevel),Q(ce.subject)].filter(Boolean),qe=new Date().toISOString().replace(/[:.]/g,"-"),et=`${Ce.join("_")}_${qe}.zip`,$e=document.createElement("a");$e.href=Y,$e.download=et,$e.style.display="none",document.body.appendChild($e),$e.click(),document.body.removeChild($e),Se.success(o.topbar.qrCodesDownloadedToast)}catch{Se.error(o.topbar.qrCodesDownloadFailedToast)}finally{H(!1)}},[de,c,f,o]),ae=e==="edit",we=e==="review",ye=e==="sourcingreview",F=e==="read",B=g.useCallback((le,ve)=>{i({action:le,data:ve})},[i]),Z=g.useCallback(()=>{b(),B("publish")},[b,B]),he=g.useCallback((le,ve)=>{const Te=p==null?void 0:p.action;b(),Te==="approve"?B("sourcingApprove",{comment:le,score:ve}):B("reject",{comment:le})},[b,B,p]);return l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:_e.topbar,role:"banner",children:[l.jsxs("div",{className:_e.left,children:[l.jsx("button",{className:_e.backBtn,onClick:()=>B("back"),"aria-label":o.topbar.backAriaLabel,type:"button",children:l.jsx(wl,{size:18})}),l.jsx("h1",{className:_e.title,title:u,children:u}),S&&l.jsxs("span",{className:_e.profileBadge,children:[l.jsx(Oh,{size:13,"aria-hidden":"true"}),o.learningPath.profileBadgeLabel]}),l.jsx("span",{className:`sbx-chip ${_e.statusChip}`,"aria-label":`${o.topbar.statusAriaLabelPrefix} ${d}`,children:d})]}),l.jsxs("div",{className:_e.right,children:[t?l.jsx("span",{className:_e.savedIndicator,"aria-live":"polite",children:o.topbar.savingIndicator}):r&&ae?l.jsx("span",{className:`${_e.savedIndicator} ${_e.unsaved}`,"aria-live":"polite",children:o.topbar.unsavedIndicator}):n?l.jsxs("span",{className:_e.savedIndicator,"aria-live":"polite",children:[l.jsx(bn,{size:14,"aria-hidden":"true"}),o.topbar.savedIndicatorPrefix," ",GT(n)]}):null,!F&&!we&&!ye&&d!=="Review"&&l.jsx("span",{title:s?void 0:o.topbar.fillRequiredFieldsTooltip,children:l.jsx(Re,{variant:"ghost",size:"sm",onClick:()=>B("saveCollection"),disabled:!s,children:o.topbar.saveAsDraftButton})}),ae&&l.jsxs(l.Fragment,{children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>E(!0),disabled:v.saveCollection,isLoading:v.saveCollection,children:[l.jsx(qy,{size:14,"aria-hidden":"true"})," ",o.topbar.sendForReviewButton]}),C.features.collaborators&&l.jsx("button",{className:_e.iconBtn,onClick:()=>h("manageCollaborators"),"aria-label":o.topbar.collaboratorsLabel,title:o.topbar.collaboratorsLabel,type:"button",children:l.jsx(Wy,{size:16,"aria-hidden":"true"})}),_&&l.jsxs("div",{className:_e.qrDropdown,ref:O,children:[l.jsxs("button",{className:_e.iconBtn,onClick:()=>P(le=>!le),"aria-label":o.topbar.qrCodesLabel,title:o.topbar.qrCodesLabel,type:"button","aria-haspopup":"true","aria-expanded":j,children:[l.jsx(Ac,{size:16,"aria-hidden":"true"}),l.jsx("span",{className:_e.iconBtnLabel,children:o.topbar.qrCodesLabel}),l.jsx(Cn,{size:14,style:{marginLeft:2},"aria-hidden":"true"})]}),j&&l.jsxs("div",{className:_e.qrMenu,role:"menu",children:[l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{P(!1),R(!0)},disabled:M,children:[l.jsx(Ac,{size:14}),M?o.topbar.generatingEllipsis:o.topbar.generateQrCodesMenuItem]}),l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{P(!1),pe()},disabled:ee||!de,children:[l.jsx(Ey,{size:14}),ee?o.topbar.downloadingEllipsis:o.topbar.downloadQrCodesMenuItem]})]})]})]}),we&&l.jsxs("div",{className:_e.reviewBtns,children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("publishChecklist"),disabled:v.publishCollection,isLoading:v.publishCollection,children:[l.jsx(Pf,{size:14,"aria-hidden":"true"})," ",o.topbar.publishButton]}),l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>T(!0),disabled:v.rejectCollection,isLoading:v.rejectCollection,children:[l.jsx(kc,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]}),ye&&l.jsxs("div",{className:_e.sourcingBtns,children:[l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"approve"}),children:[l.jsx(Uy,{size:14,"aria-hidden":"true"})," ",o.topbar.approveButton]}),l.jsxs(Re,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"reject"}),children:[l.jsx(kc,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]})]})]}),m==="publishChecklist"&&l.jsx(B0,{contentId:f,onConfirm:Z,onCancel:b}),m==="qualityParams"&&l.jsx(q0,{contentId:f,action:(p==null?void 0:p.action)??"reject",onConfirm:he,onCancel:b}),m==="manageCollaborators"&&l.jsx("div",{className:_e.modalOverlay,role:"dialog","aria-modal":"true",children:l.jsx(yT,{contentId:f,onClose:b})}),m==="confirmDelete"&&l.jsx($0,{message:(p==null?void 0:p.message)??"",onConfirm:()=>{const le=p==null?void 0:p.onConfirm;b(),le==null||le()},onCancel:b}),D&&l.jsx(ZT,{onConfirm:()=>{E(!1),B("sendForReview")},onCancel:()=>E(!1)}),x&&l.jsx(YT,{titleText:o.topbar.requestChangesTitle,labelText:o.topbar.changesRequestedLabel,placeholderText:o.topbar.describeChangesPlaceholder,submitLabel:o.topbar.requestForChangesButton,submitVariant:"primary",onConfirm:le=>{T(!1),B("reject",{comment:le})},onCancel:()=>T(!1)}),N&&l.jsx(XT,{onConfirm:fe,onCancel:()=>R(!1)})]})},e1=({onSave:e,onDiscard:t,onCancel:r,isSaving:n})=>{const s=oe();return xr.createPortal(l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"unsaved-title",children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.modalHeader,children:[l.jsx("span",{id:"unsaved-title",children:s.unsavedChangesModal.title}),l.jsx("button",{className:Ae.modalHeaderClose,onClick:r,"aria-label":s.unsavedChangesModal.closeAriaLabel,disabled:n,children:"×"})]}),l.jsx("div",{className:Ae.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:s.unsavedChangesModal.bodyMessage})}),l.jsxs("div",{className:Ae.modalFooter,children:[l.jsx(Re,{variant:"ghost",onClick:r,disabled:n,children:s.unsavedChangesModal.cancelButton}),l.jsx(Re,{variant:"danger",onClick:t,disabled:n,children:s.unsavedChangesModal.discardButton}),l.jsx(Re,{variant:"primary",onClick:e,isLoading:n,disabled:n,children:s.unsavedChangesModal.saveButton})]})]})}),document.body)};var t1=El();const Ph=g.createContext(null);function Ft(){const e=g.useContext(Ph);if(e===null)throw new Error("No Tree Api Provided");return e}const Rh=g.createContext(null);function r1(){const e=g.useContext(Rh);if(e===null)throw new Error("Provide a NodesContext");return e}const Fh=g.createContext(null);function n1(){const e=g.useContext(Fh);if(e===null)throw new Error("Provide a DnDContext");return e}const Mh=g.createContext(0);function Bh(){g.useContext(Mh)}function Ni(e,t,r){return Math.max(Math.min(e,r),t)}function qh(e){return e&&e.isLeaf}function $h(e){return e&&e.isInternal&&!e.isOpen}function Uh(e){var t;return e&&e.isOpen&&!(!((t=e.children)===null||t===void 0)&&t.length)}const zh=(e,t)=>{let r=e;for(;r;){if(r.id===t.id)return!0;r=r.parent}return!1},Vh=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function Fl(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let r of e.children){const n=Fl(r,t);if(n)return n}return null}function eo(e,t){if(t(e),e.children)for(let r of e.children)eo(r,t)}function Hh(e){const t=Wh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=s1(t,n);break}r==null||r.focus()}function Qh(e){const t=Wh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=i1(t,n);break}r==null||r.focus()}function s1(e,t){return t+1<e.length?e[t+1]:e[0]}function i1(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function Wh(e){return Array.from(document.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"]):not([disabled]), details:not([disabled]), summary:not(:disabled)')).filter(t=>t===e||!e.contains(t))}function xs(e,t){return typeof t=="boolean"?t:typeof t=="string"?e[t]:t(e)}function Rn(e){return typeof e=="string"?e:e.id}function o1(e,...t){if(e)return e(...t)}function Gh(e){return new Promise((t,r)=>{let n=0;function s(){n+=1,n===100&&r(),e()?t():setTimeout(s,10)}s()})}function Kh(e){var t,r;const n=e.focusedNode;return n?n.isOpen?0:n.parent?n.childIndex+1:0:(r=(t=e.root.children)===null||t===void 0?void 0:t.length)!==null&&r!==void 0?r:0}function Yh(e){const t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}const a1=Object.freeze(Object.defineProperty({__proto__:null,access:xs,bound:Ni,dfs:Fl,focusNextElement:Hh,focusPrevElement:Qh,getInsertIndex:Kh,getInsertParentId:Yh,identify:Rn,indexOf:Vh,isClosed:$h,isDescendant:zh,isItem:qh,isOpenWithEmptyChildren:Uh,safeRun:o1,waitFor:Gh,walk:eo},Symbol.toStringTag,{value:"Module"})),l1={display:"flex",alignItems:"center",zIndex:1},c1={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},u1={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},d1=g.memo(function({top:t,left:r,indent:n}){const s={position:"absolute",pointerEvents:"none",top:t-2+"px",left:r+"px",right:n+"px"};return l.jsxs("div",{style:Object.assign(Object.assign({},l1),s),children:[l.jsx("div",{style:Object.assign({},u1)}),l.jsx("div",{style:Object.assign({},c1)})]})});function f1({node:e,attrs:t,innerRef:r,children:n}){return l.jsx("div",Object.assign({},t,{ref:r,onFocus:s=>s.stopPropagation(),onClick:e.handleClick,children:n}))}function h1(e){return l.jsxs("div",{ref:e.dragHandle,style:e.style,children:[l.jsx("span",{onClick:t=>{t.stopPropagation(),e.node.toggle()},children:e.node.isLeaf?"🌳":e.node.isOpen?"🗁":"🗀"})," ",e.node.isEditing?l.jsx(m1,Object.assign({},e)):l.jsx(p1,Object.assign({},e))]})}function p1(e){return l.jsx(l.Fragment,{children:l.jsx("span",{children:e.node.data.name})})}function m1({node:e}){const t=g.useRef();return g.useEffect(()=>{var r,n;(r=t.current)===null||r===void 0||r.focus(),(n=t.current)===null||n===void 0||n.select()},[]),l.jsx("input",{ref:t,defaultValue:e.data.name,onBlur:()=>e.reset(),onKeyDown:r=>{var n;r.key==="Escape"&&e.reset(),r.key==="Enter"&&e.submit(((n=t.current)===null||n===void 0?void 0:n.value)||"")}})}const qs="__REACT_ARBORIST_INTERNAL_ROOT__";function ou(e){var t;function r(i,o,a){const c=e.accessId(i),u=new $s({tree:e,data:i,level:o,parent:a,id:c,children:null,isDraggable:e.isDraggable(i),rowIndex:null}),d=e.accessChildren(i);return d&&(u.children=d.map(f=>r(f,o+1,u))),u}const n=new $s({tree:e,id:qs,data:{id:qs},level:-1,parent:null,children:null,isDraggable:!0,rowIndex:null}),s=(t=e.props.data)!==null&&t!==void 0?t:[];return n.children=s.map(i=>r(i,0,n)),n}class $s{constructor(t){this.handleClick=r=>{(r.metaKey||r.ctrlKey)&&!this.tree.props.disableMultiSelection?this.isSelected?this.deselect():this.selectMulti():r.shiftKey&&!this.tree.props.disableMultiSelection?this.selectContiguous():(this.select(),this.activate())},this.tree=t.tree,this.id=t.id,this.data=t.data,this.level=t.level,this.children=t.children,this.parent=t.parent,this.isDraggable=t.isDraggable,this.rowIndex=t.rowIndex}get isRoot(){return this.id===qs}get isLeaf(){return!Array.isArray(this.children)}get isInternal(){return!this.isLeaf}get isOpen(){return this.isLeaf?!1:this.tree.isOpen(this.id)}get isClosed(){return this.isLeaf?!1:!this.tree.isOpen(this.id)}get isEditable(){return this.tree.isEditable(this.data)}get isSelectable(){return this.tree.isSelectable(this.data)}get isEditing(){return this.tree.editingId===this.id}get isSelected(){return this.tree.isSelected(this.id)}get isOnlySelection(){return this.isSelected&&this.tree.hasOneSelection}get isSelectedStart(){var t;return this.isSelected&&!(!((t=this.prev)===null||t===void 0)&&t.isSelected)}get isSelectedEnd(){var t;return this.isSelected&&!(!((t=this.next)===null||t===void 0)&&t.isSelected)}get isFocused(){return this.tree.isFocused(this.id)}get isDragging(){return this.tree.isDragging(this.id)}get willReceiveDrop(){return this.tree.willReceiveDrop(this.id)}get state(){return{isClosed:this.isClosed,isDragging:this.isDragging,isEditing:this.isEditing,isFocused:this.isFocused,isInternal:this.isInternal,isLeaf:this.isLeaf,isOpen:this.isOpen,isSelected:this.isSelected,isSelectedEnd:this.isSelectedEnd,isSelectedStart:this.isSelectedStart,willReceiveDrop:this.willReceiveDrop}}get childIndex(){return this.parent&&this.parent.children?this.parent.children.findIndex(t=>t.id===this.id):-1}get next(){return this.rowIndex===null?null:this.tree.at(this.rowIndex+1)}get prev(){return this.rowIndex===null?null:this.tree.at(this.rowIndex-1)}get nextSibling(){var t,r;const n=this.childIndex;return(r=(t=this.parent)===null||t===void 0?void 0:t.children[n+1])!==null&&r!==void 0?r:null}isAncestorOf(t){if(!t)return!1;let r=t;for(;r;){if(r.id===this.id)return!0;r=r.parent}return!1}select(){this.tree.select(this)}deselect(){this.tree.deselect(this)}selectMulti(){this.tree.selectMulti(this)}selectContiguous(){this.tree.selectContiguous(this)}activate(){this.tree.activate(this)}focus(){this.tree.focus(this)}toggle(){this.tree.toggle(this)}open(){this.tree.open(this)}openParents(){this.tree.openParents(this)}close(){this.tree.close(this)}submit(t){this.tree.submit(this,t)}reset(){this.tree.reset()}clone(){return new $s(Object.assign({},this))}edit(){return this.tree.edit(this)}}function Ko(e){return{type:"EDIT",id:e}}function g1(e={id:null},t){return t.type==="EDIT"?Object.assign(Object.assign({},e),{id:t.id}):e}function En(e){return{type:"FOCUS",id:e}}function v1(){return{type:"TREE_BLUR"}}function y1(e={id:null,treeFocused:!1},t){return t.type==="FOCUS"?Object.assign(Object.assign({},e),{id:t.id,treeFocused:!0}):t.type==="TREE_BLUR"?Object.assign(Object.assign({},e),{treeFocused:!1}):e}const Ya={open(e,t){return{type:"VISIBILITY_OPEN",id:e,filtered:t}},close(e,t){return{type:"VISIBILITY_CLOSE",id:e,filtered:t}},toggle(e,t){return{type:"VISIBILITY_TOGGLE",id:e,filtered:t}},clear(e){return{type:"VISIBILITY_CLEAR",filtered:e}}};function au(e={},t){if(t.type==="VISIBILITY_OPEN")return Object.assign(Object.assign({},e),{[t.id]:!0});if(t.type==="VISIBILITY_CLOSE")return Object.assign(Object.assign({},e),{[t.id]:!1});if(t.type==="VISIBILITY_TOGGLE"){const r=e[t.id];return Object.assign(Object.assign({},e),{[t.id]:!r})}else return t.type==="VISIBILITY_CLEAR"?{}:e}function b1(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:au(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:au(e.unfiltered,t)}):e}const rs=e=>{var t;return{nodes:{open:{filtered:{},unfiltered:(t=e==null?void 0:e.initialOpenState)!==null&&t!==void 0?t:{}},focus:{id:null,treeFocused:!1},edit:{id:null},drag:{id:null,selectedIds:[],destinationParentId:null,destinationIndex:null},selection:{ids:new Set,anchor:null,mostRecent:null}},dnd:{cursor:{type:"none"},dragId:null,dragIds:[],parentId:null,index:-1}}},Ir={clear:()=>({type:"SELECTION_CLEAR"}),only:e=>({type:"SELECTION_ONLY",id:Rn(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(Rn)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(Rn)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:e===null?null:Rn(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:e===null?null:Rn(e)})};function C1(e=rs().nodes.selection,t){const r=e.ids;switch(t.type){case"SELECTION_CLEAR":return Object.assign(Object.assign({},e),{ids:new Set});case"SELECTION_ONLY":return Object.assign(Object.assign({},e),{ids:new Set([t.id])});case"SELECTION_ADD":return t.ids.length===0?e:(t.ids.forEach(n=>r.add(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_REMOVE":return t.ids.length===0?e:(t.ids.forEach(n=>r.delete(n)),Object.assign(Object.assign({},e),{ids:new Set(r)}));case"SELECTION_SET":return Object.assign(Object.assign({},e),{ids:t.ids,mostRecent:t.mostRecent,anchor:t.anchor});case"SELECTION_MOST_RECENT":return Object.assign(Object.assign({},e),{mostRecent:t.id});case"SELECTION_ANCHOR":return Object.assign(Object.assign({},e),{anchor:t.id});default:return e}}const ns={cursor(e){return{type:"DND_CURSOR",cursor:e}},dragStart(e,t){return{type:"DND_DRAG_START",id:e,dragIds:t}},dragEnd(){return{type:"DND_DRAG_END"}},hovering(e,t){return{type:"DND_HOVERING",parentId:e,index:t}}};function S1(e=rs().dnd,t){switch(t.type){case"DND_CURSOR":return Object.assign(Object.assign({},e),{cursor:t.cursor});case"DND_DRAG_START":return Object.assign(Object.assign({},e),{dragId:t.id,dragIds:t.dragIds});case"DND_DRAG_END":return rs().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}const _1={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},w1=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t}px, ${r}px)`}},x1=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t+10}px, ${r+10}px)`}};function Zh({offset:e,mouse:t,id:r,dragIds:n,isDragging:s}){return l.jsxs(T1,{isDragging:s,children:[l.jsx(E1,{offset:e,children:l.jsx(k1,{id:r,dragIds:n})}),l.jsx(A1,{mouse:t,count:n.length})]})}const T1=g.memo(function(t){return t.isDragging?l.jsx("div",{style:_1,children:t.children}):null});function E1(e){return l.jsx("div",{className:"row preview",style:w1(e.offset),children:e.children})}function A1(e){const{count:t,mouse:r}=e;return t>1?l.jsx("div",{className:"selected-count",style:x1(r),children:t}):null}const k1=g.memo(function(t){const r=Ft(),n=r.get(t.id);return n?l.jsx(r.renderNode,{preview:!0,node:n,style:{paddingLeft:n.level*r.indent,opacity:.2,background:"transparent"},tree:r}):null});function Za(){return Za=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Za.apply(null,arguments)}function lu(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Xa(e,t){return Xa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Xa(e,t)}function I1(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Xa(e,t)}var cu=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function D1(e,t){return!!(e===t||cu(e)&&cu(t))}function L1(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!D1(e[r],t[r]))return!1;return!0}function Yo(e,t){t===void 0&&(t=L1);var r,n=[],s,i=!1;function o(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return i&&r===this&&t(a,n)||(s=e.apply(this,a),i=!0,r=this,n=a),s}return o}var O1=typeof performance=="object"&&typeof performance.now=="function",uu=O1?function(){return performance.now()}:function(){return Date.now()};function du(e){cancelAnimationFrame(e.id)}function N1(e,t){var r=uu();function n(){uu()-r>=t?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var Zo=-1;function fu(e){if(e===void 0&&(e=!1),Zo===-1||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(t),Zo=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Zo}var An=null;function hu(e){if(e===void 0&&(e=!1),An===null||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",r.direction="rtl";var n=document.createElement("div"),s=n.style;return s.width="100px",s.height="100px",t.appendChild(n),document.body.appendChild(t),t.scrollLeft>0?An="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?An="negative":An="positive-ascending"),document.body.removeChild(t),An}return An}process.env.NODE_ENV;var j1=150,P1=function(t,r){return t},ji=null,Pi=null;process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof window.WeakSet<"u"&&(ji=new WeakSet,Pi=new WeakSet);function Xh(e){var t,r=e.getItemOffset,n=e.getEstimatedTotalSize,s=e.getItemSize,i=e.getOffsetForIndexAndAlignment,o=e.getStartIndexForOffset,a=e.getStopIndexForStartIndex,c=e.initInstanceProps,u=e.shouldResetStyleCacheOnItemSizeChange,d=e.validateProps;return t=(function(f){I1(m,f);function m(b){var h;return h=f.call(this,b)||this,h._instanceProps=c(h.props,lu(h)),h._outerRef=void 0,h._resetIsScrollingTimeoutId=null,h.state={instance:lu(h),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof h.props.initialScrollOffset=="number"?h.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},h._callOnItemsRendered=void 0,h._callOnItemsRendered=Yo(function(v,y,C,S){return h.props.onItemsRendered({overscanStartIndex:v,overscanStopIndex:y,visibleStartIndex:C,visibleStopIndex:S})}),h._callOnScroll=void 0,h._callOnScroll=Yo(function(v,y,C){return h.props.onScroll({scrollDirection:v,scrollOffset:y,scrollUpdateWasRequested:C})}),h._getItemStyle=void 0,h._getItemStyle=function(v){var y=h.props,C=y.direction,S=y.itemSize,_=y.layout,x=h._getItemStyleCache(u&&S,u&&_,u&&C),T;if(x.hasOwnProperty(v))T=x[v];else{var D=r(h.props,v,h._instanceProps),E=s(h.props,v,h._instanceProps),j=C==="horizontal"||_==="horizontal",P=C==="rtl",O=j?D:0;x[v]=T={position:"absolute",left:P?void 0:O,right:P?O:void 0,top:j?0:D,height:j?"100%":E,width:j?E:"100%"}}return T},h._getItemStyleCache=void 0,h._getItemStyleCache=Yo(function(v,y,C){return{}}),h._onScrollHorizontal=function(v){var y=v.currentTarget,C=y.clientWidth,S=y.scrollLeft,_=y.scrollWidth;h.setState(function(x){if(x.scrollOffset===S)return null;var T=h.props.direction,D=S;if(T==="rtl")switch(hu()){case"negative":D=-S;break;case"positive-descending":D=_-C-S;break}return D=Math.max(0,Math.min(D,_-C)),{isScrolling:!0,scrollDirection:x.scrollOffset<D?"forward":"backward",scrollOffset:D,scrollUpdateWasRequested:!1}},h._resetIsScrollingDebounced)},h._onScrollVertical=function(v){var y=v.currentTarget,C=y.clientHeight,S=y.scrollHeight,_=y.scrollTop;h.setState(function(x){if(x.scrollOffset===_)return null;var T=Math.max(0,Math.min(_,S-C));return{isScrolling:!0,scrollDirection:x.scrollOffset<T?"forward":"backward",scrollOffset:T,scrollUpdateWasRequested:!1}},h._resetIsScrollingDebounced)},h._outerRefSetter=function(v){var y=h.props.outerRef;h._outerRef=v,typeof y=="function"?y(v):y!=null&&typeof y=="object"&&y.hasOwnProperty("current")&&(y.current=v)},h._resetIsScrollingDebounced=function(){h._resetIsScrollingTimeoutId!==null&&du(h._resetIsScrollingTimeoutId),h._resetIsScrollingTimeoutId=N1(h._resetIsScrolling,j1)},h._resetIsScrolling=function(){h._resetIsScrollingTimeoutId=null,h.setState({isScrolling:!1},function(){h._getItemStyleCache(-1,null)})},h}m.getDerivedStateFromProps=function(h,v){return R1(h,v),d(h),null};var p=m.prototype;return p.scrollTo=function(h){h=Math.max(0,h),this.setState(function(v){return v.scrollOffset===h?null:{scrollDirection:v.scrollOffset<h?"forward":"backward",scrollOffset:h,scrollUpdateWasRequested:!0}},this._resetIsScrollingDebounced)},p.scrollToItem=function(h,v){v===void 0&&(v="auto");var y=this.props,C=y.itemCount,S=y.layout,_=this.state.scrollOffset;h=Math.max(0,Math.min(h,C-1));var x=0;if(this._outerRef){var T=this._outerRef;S==="vertical"?x=T.scrollWidth>T.clientWidth?fu():0:x=T.scrollHeight>T.clientHeight?fu():0}this.scrollTo(i(this.props,h,v,_,this._instanceProps,x))},p.componentDidMount=function(){var h=this.props,v=h.direction,y=h.initialScrollOffset,C=h.layout;if(typeof y=="number"&&this._outerRef!=null){var S=this._outerRef;v==="horizontal"||C==="horizontal"?S.scrollLeft=y:S.scrollTop=y}this._callPropsCallbacks()},p.componentDidUpdate=function(){var h=this.props,v=h.direction,y=h.layout,C=this.state,S=C.scrollOffset,_=C.scrollUpdateWasRequested;if(_&&this._outerRef!=null){var x=this._outerRef;if(v==="horizontal"||y==="horizontal")if(v==="rtl")switch(hu()){case"negative":x.scrollLeft=-S;break;case"positive-ascending":x.scrollLeft=S;break;default:var T=x.clientWidth,D=x.scrollWidth;x.scrollLeft=D-T-S;break}else x.scrollLeft=S;else x.scrollTop=S}this._callPropsCallbacks()},p.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&du(this._resetIsScrollingTimeoutId)},p.render=function(){var h=this.props,v=h.children,y=h.className,C=h.direction,S=h.height,_=h.innerRef,x=h.innerElementType,T=h.innerTagName,D=h.itemCount,E=h.itemData,j=h.itemKey,P=j===void 0?P1:j,O=h.layout,N=h.outerElementType,R=h.outerTagName,M=h.style,$=h.useIsScrolling,ee=h.width,H=this.state.isScrolling,te=C==="horizontal"||O==="horizontal",de=te?this._onScrollHorizontal:this._onScrollVertical,fe=this._getRangeToRender(),pe=fe[0],ae=fe[1],we=[];if(D>0)for(var ye=pe;ye<=ae;ye++)we.push(g.createElement(v,{data:E,key:P(ye,E),index:ye,isScrolling:$?H:void 0,style:this._getItemStyle(ye)}));var F=n(this.props,this._instanceProps);return g.createElement(N||R||"div",{className:y,onScroll:de,ref:this._outerRefSetter,style:Za({position:"relative",height:S,width:ee,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:C},M)},g.createElement(x||T||"div",{children:we,ref:_,style:{height:te?"100%":F,pointerEvents:H?"none":void 0,width:te?F:"100%"}}))},p._callPropsCallbacks=function(){if(typeof this.props.onItemsRendered=="function"){var h=this.props.itemCount;if(h>0){var v=this._getRangeToRender(),y=v[0],C=v[1],S=v[2],_=v[3];this._callOnItemsRendered(y,C,S,_)}}if(typeof this.props.onScroll=="function"){var x=this.state,T=x.scrollDirection,D=x.scrollOffset,E=x.scrollUpdateWasRequested;this._callOnScroll(T,D,E)}},p._getRangeToRender=function(){var h=this.props,v=h.itemCount,y=h.overscanCount,C=this.state,S=C.isScrolling,_=C.scrollDirection,x=C.scrollOffset;if(v===0)return[0,0,0,0];var T=o(this.props,x,this._instanceProps),D=a(this.props,T,x,this._instanceProps),E=!S||_==="backward"?Math.max(1,y):1,j=!S||_==="forward"?Math.max(1,y):1;return[Math.max(0,T-E),Math.max(0,Math.min(v-1,D+j)),T,D]},m})(g.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var R1=function(t,r){var n=t.children,s=t.direction,i=t.height,o=t.layout,a=t.innerTagName,c=t.outerTagName,u=t.width,d=r.instance;if(process.env.NODE_ENV!=="production"){(a!=null||c!=null)&&Pi&&!Pi.has(d)&&(Pi.add(d),console.warn("The innerTagName and outerTagName props have been deprecated. Please use the innerElementType and outerElementType props instead."));var f=s==="horizontal"||o==="horizontal";switch(s){case"horizontal":case"vertical":ji&&!ji.has(d)&&(ji.add(d),console.warn('The direction prop should be either "ltr" (default) or "rtl". Please use the layout prop to specify "vertical" (default) or "horizontal" orientation.'));break;case"ltr":case"rtl":break;default:throw Error('An invalid "direction" prop has been specified. Value should be either "ltr" or "rtl". '+('"'+s+'" was specified.'))}switch(o){case"horizontal":case"vertical":break;default:throw Error('An invalid "layout" prop has been specified. Value should be either "horizontal" or "vertical". '+('"'+o+'" was specified.'))}if(n==null)throw Error('An invalid "children" prop has been specified. Value should be a React component. '+('"'+(n===null?"null":typeof n)+'" was specified.'));if(f&&typeof u!="number")throw Error('An invalid "width" prop has been specified. Horizontal lists must specify a number for width. '+('"'+(u===null?"null":typeof u)+'" was specified.'));if(!f&&typeof i!="number")throw Error('An invalid "height" prop has been specified. Vertical lists must specify a number for height. '+('"'+(i===null?"null":typeof i)+'" was specified.'))}},F1=50,Fn=function(t,r,n){var s=t,i=s.itemSize,o=n.itemMetadataMap,a=n.lastMeasuredIndex;if(r>a){var c=0;if(a>=0){var u=o[a];c=u.offset+u.size}for(var d=a+1;d<=r;d++){var f=i(d);o[d]={offset:c,size:f},c+=f}n.lastMeasuredIndex=r}return o[r]},M1=function(t,r,n){var s=r.itemMetadataMap,i=r.lastMeasuredIndex,o=i>0?s[i].offset:0;return o>=n?Jh(t,r,i,0,n):B1(t,r,Math.max(0,i),n)},Jh=function(t,r,n,s,i){for(;s<=n;){var o=s+Math.floor((n-s)/2),a=Fn(t,o,r).offset;if(a===i)return o;a<i?s=o+1:a>i&&(n=o-1)}return s>0?s-1:0},B1=function(t,r,n,s){for(var i=t.itemCount,o=1;n<i&&Fn(t,n,r).offset<s;)n+=o,o*=2;return Jh(t,r,Math.min(n,i-1),Math.floor(n/2),s)},pu=function(t,r){var n=t.itemCount,s=r.itemMetadataMap,i=r.estimatedItemSize,o=r.lastMeasuredIndex,a=0;if(o>=n&&(o=n-1),o>=0){var c=s[o];a=c.offset+c.size}var u=n-o-1,d=u*i;return a+d},q1=Xh({getItemOffset:function(t,r,n){return Fn(t,r,n).offset},getItemSize:function(t,r,n){return n.itemMetadataMap[r].size},getEstimatedTotalSize:pu,getOffsetForIndexAndAlignment:function(t,r,n,s,i,o){var a=t.direction,c=t.height,u=t.layout,d=t.width,f=a==="horizontal"||u==="horizontal",m=f?d:c,p=Fn(t,r,i),b=pu(t,i),h=Math.max(0,Math.min(b-m,p.offset)),v=Math.max(0,p.offset-m+p.size+o);switch(n==="smart"&&(s>=v-m&&s<=h+m?n="auto":n="center"),n){case"start":return h;case"end":return v;case"center":return Math.round(v+(h-v)/2);case"auto":default:return s>=v&&s<=h?s:s<v?v:h}},getStartIndexForOffset:function(t,r,n){return M1(t,n,r)},getStopIndexForStartIndex:function(t,r,n,s){for(var i=t.direction,o=t.height,a=t.itemCount,c=t.layout,u=t.width,d=i==="horizontal"||c==="horizontal",f=d?u:o,m=Fn(t,r,s),p=n+f,b=m.offset+m.size,h=r;h<a-1&&b<p;)h++,b+=Fn(t,h,s).size;return h},initInstanceProps:function(t,r){var n=t,s=n.estimatedItemSize,i={itemMetadataMap:{},estimatedItemSize:s||F1,lastMeasuredIndex:-1};return r.resetAfterIndex=function(o,a){a===void 0&&(a=!0),i.lastMeasuredIndex=Math.min(i.lastMeasuredIndex,o-1),r._getItemStyleCache(-1),a&&r.forceUpdate()},i},shouldResetStyleCacheOnItemSizeChange:!1,validateProps:function(t){var r=t.itemSize;if(process.env.NODE_ENV!=="production"&&typeof r!="function")throw Error('An invalid "itemSize" prop has been specified. Value should be a function. '+('"'+(r===null?"null":typeof r)+'" was specified.'))}}),$1=Xh({getItemOffset:function(t,r){var n=t.itemSize;return r*n},getItemSize:function(t,r){var n=t.itemSize;return n},getEstimatedTotalSize:function(t){var r=t.itemCount,n=t.itemSize;return n*r},getOffsetForIndexAndAlignment:function(t,r,n,s,i,o){var a=t.direction,c=t.height,u=t.itemCount,d=t.itemSize,f=t.layout,m=t.width,p=a==="horizontal"||f==="horizontal",b=p?m:c,h=Math.max(0,u*d-b),v=Math.min(h,r*d),y=Math.max(0,r*d-b+d+o);switch(n==="smart"&&(s>=y-b&&s<=v+b?n="auto":n="center"),n){case"start":return v;case"end":return y;case"center":{var C=Math.round(y+(v-y)/2);return C<Math.ceil(b/2)?0:C>h+Math.floor(b/2)?h:C}case"auto":default:return s>=y&&s<=v?s:s<y?y:v}},getStartIndexForOffset:function(t,r){var n=t.itemCount,s=t.itemSize;return Math.max(0,Math.min(n-1,Math.floor(r/s)))},getStopIndexForStartIndex:function(t,r,n){var s=t.direction,i=t.height,o=t.itemCount,a=t.itemSize,c=t.layout,u=t.width,d=s==="horizontal"||c==="horizontal",f=r*a,m=d?u:i,p=Math.ceil((m+n-f)/a);return Math.max(0,Math.min(o-1,r+p-1))},initInstanceProps:function(t){},shouldResetStyleCacheOnItemSizeChange:!0,validateProps:function(t){var r=t.itemSize;if(process.env.NODE_ENV!=="production"&&typeof r!="number")throw Error('An invalid "itemSize" prop has been specified. Value should be a number. '+('"'+(r===null?"null":typeof r)+'" was specified.'))}});function U1(){var e,t;const r=Ft(),s=n1().cursor;if(!s||s.type!=="line")return null;const i=r.indent,o=r.rowTopPosition(s.index)+((t=(e=r.props.padding)!==null&&e!==void 0?e:r.props.paddingTop)!==null&&t!==void 0?t:0),a=i*s.level,c=r.renderCursor;return l.jsx(c,{top:o,left:a,indent:i})}var z1=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r};const V1=g.forwardRef(function(t,r){const{children:n}=t,s=z1(t,["children"]),i=Ft();return l.jsxs("div",Object.assign({ref:r},s,{onClick:o=>{o.currentTarget===o.target&&i.deselectAll()},children:[l.jsx(H1,{}),n]}))}),H1=()=>{const e=Ft();return l.jsx("div",{style:{height:e.rowTopPosition(e.visibleNodes.length),width:"100%",position:"absolute",left:"0",right:"0"},children:l.jsx(U1,{})})};var Q1=function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(e);s<n.length;s++)t.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(e,n[s])&&(r[n[s]]=e[n[s]]);return r};const W1=g.forwardRef(function(t,r){var n,s,i,o,{style:a}=t,c=Q1(t,["style"]);const u=Ft(),d=(s=(n=u.props.padding)!==null&&n!==void 0?n:u.props.paddingTop)!==null&&s!==void 0?s:0,f=(o=(i=u.props.padding)!==null&&i!==void 0?i:u.props.paddingBottom)!==null&&o!==void 0?o:0;return l.jsx("div",Object.assign({ref:r,style:Object.assign(Object.assign({},a),{height:`${parseFloat(a.height)+d+f}px`})},c))});var ep=g.createContext({dragDropManager:void 0}),Xt;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(Xt||(Xt={}));function xe(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),s=2;s<r;s++)n[s-2]=arguments[s];if(process.env.NODE_ENV!=="production"&&t===void 0)throw new Error("invariant requires an error message argument");if(!e){var i;if(t===void 0)i=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var o=0;i=new Error(t.replace(/%s/g,function(){return n[o++]})),i.name="Invariant Violation"}throw i.framesToPop=1,i}}var Ml="dnd-core/INIT_COORDS",ko="dnd-core/BEGIN_DRAG",Bl="dnd-core/PUBLISH_DRAG_SOURCE",Io="dnd-core/HOVER",Do="dnd-core/DROP",Lo="dnd-core/END_DRAG";function mu(e,t){return{type:Ml,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function Ri(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ri=function(r){return typeof r}:Ri=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ri(e)}function G1(e,t,r){return t.split(".").reduce(function(n,s){return n&&n[s]?n[s]:r||null},e)}function K1(e,t){return e.filter(function(r){return r!==t})}function tp(e){return Ri(e)==="object"}function Y1(e,t){var r=new Map,n=function(o){r.set(o,r.has(o)?r.get(o)+1:1)};e.forEach(n),t.forEach(n);var s=[];return r.forEach(function(i,o){i===1&&s.push(o)}),s}function Z1(e,t){return e.filter(function(r){return t.indexOf(r)>-1})}var X1={type:Ml,payload:{clientOffset:null,sourceClientOffset:null}};function J1(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{publishSource:!0},s=n.publishSource,i=s===void 0?!0:s,o=n.clientOffset,a=n.getSourceClientOffset,c=e.getMonitor(),u=e.getRegistry();e.dispatch(mu(o)),eE(r,c,u);var d=nE(r,c);if(d===null){e.dispatch(X1);return}var f=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");tE(a),f=a(d)}e.dispatch(mu(o,f));var m=u.getSource(d),p=m.beginDrag(c,d);if(p!=null){rE(p),u.pinSource(d);var b=u.getSourceType(d);return{type:ko,payload:{itemType:b,item:p,sourceId:d,clientOffset:o||null,sourceClientOffset:f||null,isSourcePublic:!!i}}}}}function eE(e,t,r){xe(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(n){xe(r.getSource(n),"Expected sourceIds to be registered.")})}function tE(e){xe(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function rE(e){xe(tp(e),"Item must be an object.")}function nE(e,t){for(var r=null,n=e.length-1;n>=0;n--)if(t.canDragSource(e[n])){r=e[n];break}return r}function sE(e){return function(){var r=e.getMonitor();if(r.isDragging())return{type:Bl}}}function Ja(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(r){return r===t}):e===t}function iE(e){return function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=n.clientOffset;oE(r);var i=r.slice(0),o=e.getMonitor(),a=e.getRegistry();aE(i,o,a);var c=o.getItemType();return lE(i,a,c),cE(i,o,a),{type:Io,payload:{targetIds:i,clientOffset:s||null}}}}function oE(e){xe(Array.isArray(e),"Expected targetIds to be an array.")}function aE(e,t,r){xe(t.isDragging(),"Cannot call hover while not dragging."),xe(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n<e.length;n++){var s=e[n];xe(e.lastIndexOf(s)===n,"Expected targetIds to be unique in the passed array.");var i=r.getTarget(s);xe(i,"Expected targetIds to be registered.")}}function lE(e,t,r){for(var n=e.length-1;n>=0;n--){var s=e[n],i=t.getTargetType(s);Ja(i,r)||e.splice(n,1)}}function cE(e,t,r){e.forEach(function(n){var s=r.getTarget(n);s.hover(t,n)})}function gu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function vu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?gu(Object(r),!0).forEach(function(n){uE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):gu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function uE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function dE(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),s=e.getRegistry();fE(n);var i=mE(n);i.forEach(function(o,a){var c=hE(o,a,s,n),u={type:Do,payload:{dropResult:vu(vu({},r),c)}};e.dispatch(u)})}}function fE(e){xe(e.isDragging(),"Cannot call drop while not dragging."),xe(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function hE(e,t,r,n){var s=r.getTarget(e),i=s?s.drop(n,e):void 0;return pE(i),typeof i>"u"&&(i=t===0?{}:n.getDropResult()),i}function pE(e){xe(typeof e>"u"||tp(e),"Drop result must either be an object or undefined.")}function mE(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function gE(e){return function(){var r=e.getMonitor(),n=e.getRegistry();vE(r);var s=r.getSourceId();if(s!=null){var i=n.getSource(s,!0);i.endDrag(r,s),n.unpinSource()}return{type:Lo}}}function vE(e){xe(e.isDragging(),"Cannot call endDrag while not dragging.")}function yE(e){return{beginDrag:J1(e),publishDragSource:sE(e),hover:iE(e),drop:dE(e),endDrag:gE(e)}}function bE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function CE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function SE(e,t,r){return t&&CE(e.prototype,t),e}function gs(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var _E=(function(){function e(t,r){var n=this;bE(this,e),gs(this,"store",void 0),gs(this,"monitor",void 0),gs(this,"backend",void 0),gs(this,"isSetUp",!1),gs(this,"handleRefCountChange",function(){var s=n.store.getState().refCount>0;n.backend&&(s&&!n.isSetUp?(n.backend.setup(),n.isSetUp=!0):!s&&n.isSetUp&&(n.backend.teardown(),n.isSetUp=!1))}),this.store=t,this.monitor=r,t.subscribe(this.handleRefCountChange)}return SE(e,[{key:"receiveBackend",value:function(r){this.backend=r}},{key:"getMonitor",value:function(){return this.monitor}},{key:"getBackend",value:function(){return this.backend}},{key:"getRegistry",value:function(){return this.monitor.registry}},{key:"getActions",value:function(){var r=this,n=this.store.dispatch;function s(o){return function(){for(var a=arguments.length,c=new Array(a),u=0;u<a;u++)c[u]=arguments[u];var d=o.apply(r,c);typeof d<"u"&&n(d)}}var i=yE(this);return Object.keys(i).reduce(function(o,a){var c=i[a];return o[a]=s(c),o},{})}},{key:"dispatch",value:function(r){this.store.dispatch(r)}}]),e})();function Qt(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var yu=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),bu=function(){return Math.random().toString(36).substring(7).split("").join(".")},Cu={INIT:"@@redux/INIT"+bu(),REPLACE:"@@redux/REPLACE"+bu()};function wE(e){if(typeof e!="object"||e===null)return!1;for(var t=e;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function xE(e){if(e===void 0)return"undefined";if(e===null)return"null";var t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(AE(e))return"date";if(EE(e))return"error";var r=TE(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return t.slice(8,-1).toLowerCase().replace(/\s/g,"")}function TE(e){return typeof e.constructor=="function"?e.constructor.name:null}function EE(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function AE(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function kn(e){var t=typeof e;return process.env.NODE_ENV!=="production"&&(t=xE(e)),t}function rp(e,t,r){var n;if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?Qt(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(1):"Expected the enhancer to be a function. Instead, received: '"+kn(r)+"'");return r(rp)(e,t)}if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(2):"Expected the root reducer to be a function. Instead, received: '"+kn(e)+"'");var s=e,i=t,o=[],a=o,c=!1;function u(){a===o&&(a=o.slice())}function d(){if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function f(h){if(typeof h!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(4):"Expected the listener to be a function. Instead, received: '"+kn(h)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");var v=!0;return u(),a.push(h),function(){if(v){if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");v=!1,u();var C=a.indexOf(h);a.splice(C,1),o=null}}}function m(h){if(!wE(h))throw new Error(process.env.NODE_ENV==="production"?Qt(7):"Actions must be plain objects. Instead, the actual type was: '"+kn(h)+"'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.");if(typeof h.type>"u")throw new Error(process.env.NODE_ENV==="production"?Qt(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(c)throw new Error(process.env.NODE_ENV==="production"?Qt(9):"Reducers may not dispatch actions.");try{c=!0,i=s(i,h)}finally{c=!1}for(var v=o=a,y=0;y<v.length;y++){var C=v[y];C()}return h}function p(h){if(typeof h!="function")throw new Error(process.env.NODE_ENV==="production"?Qt(10):"Expected the nextReducer to be a function. Instead, received: '"+kn(h));s=h,m({type:Cu.REPLACE})}function b(){var h,v=f;return h={subscribe:function(C){if(typeof C!="object"||C===null)throw new Error(process.env.NODE_ENV==="production"?Qt(11):"Expected the observer to be an object. Instead, received: '"+kn(C)+"'");function S(){C.next&&C.next(d())}S();var _=v(S);return{unsubscribe:_}}},h[yu]=function(){return this},h}return m({type:Cu.INIT}),n={dispatch:m,subscribe:f,getState:d,replaceReducer:p},n[yu]=b,n}var kE=function(t,r){return t===r};function IE(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function DE(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kE;if(e.length!==t.length)return!1;for(var n=0;n<e.length;++n)if(!r(e[n],t[n]))return!1;return!0}function Su(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function _u(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Su(Object(r),!0).forEach(function(n){LE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Su(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function LE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var wu={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function OE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:wu,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Ml:case ko:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case Io:return IE(e.clientOffset,r.clientOffset)?e:_u(_u({},e),{},{clientOffset:r.clientOffset});case Lo:case Do:return wu;default:return e}}var ql="dnd-core/ADD_SOURCE",$l="dnd-core/ADD_TARGET",Ul="dnd-core/REMOVE_SOURCE",Oo="dnd-core/REMOVE_TARGET";function NE(e){return{type:ql,payload:{sourceId:e}}}function jE(e){return{type:$l,payload:{targetId:e}}}function PE(e){return{type:Ul,payload:{sourceId:e}}}function RE(e){return{type:Oo,payload:{targetId:e}}}function xu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function Wt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?xu(Object(r),!0).forEach(function(n){FE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):xu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function FE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ME={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function BE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:ME,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case ko:return Wt(Wt({},e),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case Bl:return Wt(Wt({},e),{},{isSourcePublic:!0});case Io:return Wt(Wt({},e),{},{targetIds:r.targetIds});case Oo:return e.targetIds.indexOf(r.targetId)===-1?e:Wt(Wt({},e),{},{targetIds:K1(e.targetIds,r.targetId)});case Do:return Wt(Wt({},e),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case Lo:return Wt(Wt({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function qE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case ql:case $l:return e+1;case Ul:case Oo:return e-1;default:return e}}var to=[],zl=[];to.__IS_NONE__=!0;zl.__IS_ALL__=!0;function $E(e,t){if(e===to)return!1;if(e===zl||typeof t>"u")return!0;var r=Z1(t,e);return r.length>0}function UE(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case Io:break;case ql:case $l:case Oo:case Ul:return to;case ko:case Bl:case Lo:case Do:default:return zl}var t=e.payload,r=t.targetIds,n=r===void 0?[]:r,s=t.prevTargetIds,i=s===void 0?[]:s,o=Y1(n,i),a=o.length>0||!DE(n,i);if(!a)return to;var c=i[i.length-1],u=n[n.length-1];return c!==u&&(c&&o.push(c),u&&o.push(u)),o}function zE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e+1}function Tu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function Eu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Tu(Object(r),!0).forEach(function(n){VE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Tu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function VE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function HE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:UE(e.dirtyHandlerIds,{type:t.type,payload:Eu(Eu({},t.payload),{},{prevTargetIds:G1(e,"dragOperation.targetIds",[])})}),dragOffset:OE(e.dragOffset,t),refCount:qE(e.refCount,t),dragOperation:BE(e.dragOperation,t),stateId:zE(e.stateId)}}function QE(e,t){return{x:e.x+t.x,y:e.y+t.y}}function np(e,t){return{x:e.x-t.x,y:e.y-t.y}}function WE(e){var t=e.clientOffset,r=e.initialClientOffset,n=e.initialSourceClientOffset;return!t||!r||!n?null:np(QE(t,n),r)}function GE(e){var t=e.clientOffset,r=e.initialClientOffset;return!t||!r?null:np(t,r)}function KE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function YE(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ZE(e,t,r){return t&&YE(e.prototype,t),e}function Au(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var XE=(function(){function e(t,r){KE(this,e),Au(this,"store",void 0),Au(this,"registry",void 0),this.store=t,this.registry=r}return ZE(e,[{key:"subscribeToStateChange",value:function(r){var n=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{handlerIds:void 0},i=s.handlerIds;xe(typeof r=="function","listener must be a function."),xe(typeof i>"u"||Array.isArray(i),"handlerIds, when specified, must be an array of strings.");var o=this.store.getState().stateId,a=function(){var u=n.store.getState(),d=u.stateId;try{var f=d===o||d===o+1&&!$E(u.dirtyHandlerIds,i);f||r()}finally{o=d}};return this.store.subscribe(a)}},{key:"subscribeToOffsetChange",value:function(r){var n=this;xe(typeof r=="function","listener must be a function.");var s=this.store.getState().dragOffset,i=function(){var a=n.store.getState().dragOffset;a!==s&&(s=a,r())};return this.store.subscribe(i)}},{key:"canDragSource",value:function(r){if(!r)return!1;var n=this.registry.getSource(r);return xe(n,"Expected to find a valid source. sourceId=".concat(r)),this.isDragging()?!1:n.canDrag(this,r)}},{key:"canDropOnTarget",value:function(r){if(!r)return!1;var n=this.registry.getTarget(r);if(xe(n,"Expected to find a valid target. targetId=".concat(r)),!this.isDragging()||this.didDrop())return!1;var s=this.registry.getTargetType(r),i=this.getItemType();return Ja(s,i)&&n.canDrop(this,r)}},{key:"isDragging",value:function(){return!!this.getItemType()}},{key:"isDraggingSource",value:function(r){if(!r)return!1;var n=this.registry.getSource(r,!0);if(xe(n,"Expected to find a valid source. sourceId=".concat(r)),!this.isDragging()||!this.isSourcePublic())return!1;var s=this.registry.getSourceType(r),i=this.getItemType();return s!==i?!1:n.isDragging(this,r)}},{key:"isOverTarget",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{shallow:!1};if(!r)return!1;var s=n.shallow;if(!this.isDragging())return!1;var i=this.registry.getTargetType(r),o=this.getItemType();if(o&&!Ja(i,o))return!1;var a=this.getTargetIds();if(!a.length)return!1;var c=a.indexOf(r);return s?c===a.length-1:c>-1}},{key:"getItemType",value:function(){return this.store.getState().dragOperation.itemType}},{key:"getItem",value:function(){return this.store.getState().dragOperation.item}},{key:"getSourceId",value:function(){return this.store.getState().dragOperation.sourceId}},{key:"getTargetIds",value:function(){return this.store.getState().dragOperation.targetIds}},{key:"getDropResult",value:function(){return this.store.getState().dragOperation.dropResult}},{key:"didDrop",value:function(){return this.store.getState().dragOperation.didDrop}},{key:"isSourcePublic",value:function(){return!!this.store.getState().dragOperation.isSourcePublic}},{key:"getInitialClientOffset",value:function(){return this.store.getState().dragOffset.initialClientOffset}},{key:"getInitialSourceClientOffset",value:function(){return this.store.getState().dragOffset.initialSourceClientOffset}},{key:"getClientOffset",value:function(){return this.store.getState().dragOffset.clientOffset}},{key:"getSourceClientOffset",value:function(){return WE(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){return GE(this.store.getState().dragOffset)}}]),e})(),JE=0;function eA(){return JE++}function Fi(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Fi=function(r){return typeof r}:Fi=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Fi(e)}function tA(e){xe(typeof e.canDrag=="function","Expected canDrag to be a function."),xe(typeof e.beginDrag=="function","Expected beginDrag to be a function."),xe(typeof e.endDrag=="function","Expected endDrag to be a function.")}function rA(e){xe(typeof e.canDrop=="function","Expected canDrop to be a function."),xe(typeof e.hover=="function","Expected hover to be a function."),xe(typeof e.drop=="function","Expected beginDrag to be a function.")}function el(e,t){if(t&&Array.isArray(e)){e.forEach(function(r){return el(r,!1)});return}xe(typeof e=="string"||Fi(e)==="symbol",t?"Type can only be a string, a symbol, or an array of either.":"Type can only be a string or a symbol.")}const ku=typeof global<"u"?global:self,sp=ku.MutationObserver||ku.WebKitMutationObserver;function ip(e){return function(){const r=setTimeout(s,0),n=setInterval(s,50);function s(){clearTimeout(r),clearInterval(n),e()}}}function nA(e){let t=1;const r=new sp(e),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){t=-t,n.data=t}}const sA=typeof sp=="function"?nA:ip;class iA{enqueueTask(t){const{queue:r,requestFlush:n}=this;r.length||(n(),this.flushing=!0),r[r.length]=t}constructor(){this.queue=[],this.pendingErrors=[],this.flushing=!1,this.index=0,this.capacity=1024,this.flush=()=>{const{queue:t}=this;for(;this.index<t.length;){const r=this.index;if(this.index++,t[r].call(),this.index>this.capacity){for(let n=0,s=t.length-this.index;n<s;n++)t[n]=t[n+this.index];t.length-=this.index,this.index=0}}t.length=0,this.index=0,this.flushing=!1},this.registerPendingError=t=>{this.pendingErrors.push(t),this.requestErrorThrow()},this.requestFlush=sA(this.flush),this.requestErrorThrow=ip(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}}class oA{call(){try{this.task&&this.task()}catch(t){this.onError(t)}finally{this.task=null,this.release(this)}}constructor(t,r){this.onError=t,this.release=r,this.task=null}}class aA{create(t){const r=this.freeTasks,n=r.length?r.pop():new oA(this.onError,s=>r[r.length]=s);return n.task=t,n}constructor(t){this.onError=t,this.freeTasks=[]}}const op=new iA,lA=new aA(op.registerPendingError);function cA(e){op.enqueueTask(lA.create(e))}function uA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function fA(e,t,r){return t&&dA(e.prototype,t),e}function In(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function hA(e,t){return vA(e)||gA(e,t)||mA(e,t)||pA()}function pA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
537
537
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mA(e,t){if(e){if(typeof e=="string")return Iu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Iu(e,t)}}function Iu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function gA(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],s=!0,i=!1,o,a;try{for(r=r.call(e);!(s=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));s=!0);}catch(c){i=!0,a=c}finally{try{!s&&r.return!=null&&r.return()}finally{if(i)throw a}}return n}}function vA(e){if(Array.isArray(e))return e}function yA(e){var t=eA().toString();switch(e){case Xt.SOURCE:return"S".concat(t);case Xt.TARGET:return"T".concat(t);default:throw new Error("Unknown Handler Role: ".concat(e))}}function Du(e){switch(e[0]){case"S":return Xt.SOURCE;case"T":return Xt.TARGET;default:xe(!1,"Cannot parse handler ID: ".concat(e))}}function Lu(e,t){var r=e.entries(),n=!1;do{var s=r.next(),i=s.done,o=hA(s.value,2),a=o[1];if(a===t)return!0;n=!!i}while(!n);return!1}var bA=(function(){function e(t){uA(this,e),In(this,"types",new Map),In(this,"dragSources",new Map),In(this,"dropTargets",new Map),In(this,"pinnedSourceId",null),In(this,"pinnedSource",null),In(this,"store",void 0),this.store=t}return fA(e,[{key:"addSource",value:function(r,n){el(r),tA(n);var s=this.addHandler(Xt.SOURCE,r,n);return this.store.dispatch(NE(s)),s}},{key:"addTarget",value:function(r,n){el(r,!0),rA(n);var s=this.addHandler(Xt.TARGET,r,n);return this.store.dispatch(jE(s)),s}},{key:"containsHandler",value:function(r){return Lu(this.dragSources,r)||Lu(this.dropTargets,r)}},{key:"getSource",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;xe(this.isSourceId(r),"Expected a valid source ID.");var s=n&&r===this.pinnedSourceId,i=s?this.pinnedSource:this.dragSources.get(r);return i}},{key:"getTarget",value:function(r){return xe(this.isTargetId(r),"Expected a valid target ID."),this.dropTargets.get(r)}},{key:"getSourceType",value:function(r){return xe(this.isSourceId(r),"Expected a valid source ID."),this.types.get(r)}},{key:"getTargetType",value:function(r){return xe(this.isTargetId(r),"Expected a valid target ID."),this.types.get(r)}},{key:"isSourceId",value:function(r){var n=Du(r);return n===Xt.SOURCE}},{key:"isTargetId",value:function(r){var n=Du(r);return n===Xt.TARGET}},{key:"removeSource",value:function(r){var n=this;xe(this.getSource(r),"Expected an existing source."),this.store.dispatch(PE(r)),cA(function(){n.dragSources.delete(r),n.types.delete(r)})}},{key:"removeTarget",value:function(r){xe(this.getTarget(r),"Expected an existing target."),this.store.dispatch(RE(r)),this.dropTargets.delete(r),this.types.delete(r)}},{key:"pinSource",value:function(r){var n=this.getSource(r);xe(n,"Expected an existing source."),this.pinnedSourceId=r,this.pinnedSource=n}},{key:"unpinSource",value:function(){xe(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(r,n,s){var i=yA(r);return this.types.set(i,n),r===Xt.SOURCE?this.dragSources.set(i,s):r===Xt.TARGET&&this.dropTargets.set(i,s),i}}]),e})();function CA(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,s=SA(n),i=new XE(s,new bA(s)),o=new _E(s,i),a=e(o,t,r);return o.receiveBackend(a),o}function SA(e){var t=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__;return rp(HE,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}var _A=["children"];function wA(e,t){return AA(e)||EA(e,t)||TA(e,t)||xA()}function xA(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
538
538
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function TA(e,t){if(e){if(typeof e=="string")return Ou(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Ou(e,t)}}function Ou(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function EA(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],s=!0,i=!1,o,a;try{for(r=r.call(e);!(s=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));s=!0);}catch(c){i=!0,a=c}finally{try{!s&&r.return!=null&&r.return()}finally{if(i)throw a}}return n}}function AA(e){if(Array.isArray(e))return e}function kA(e,t){if(e==null)return{};var r=IA(e,t),n,s;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(s=0;s<i.length;s++)n=i[s],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}function IA(e,t){if(e==null)return{};var r={},n=Object.keys(e),s,i;for(i=0;i<n.length;i++)s=n[i],!(t.indexOf(s)>=0)&&(r[s]=e[s]);return r}var Nu=0,Mi=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"),DA=g.memo(function(t){var r=t.children,n=kA(t,_A),s=LA(n),i=wA(s,2),o=i[0],a=i[1];return g.useEffect(function(){if(a){var c=ap();return++Nu,function(){--Nu===0&&(c[Mi]=null)}}},[]),l.jsx(ep.Provider,Object.assign({value:o},{children:r}),void 0)});function LA(e){if("manager"in e){var t={dragDropManager:e.manager};return[t,!1]}var r=OA(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[r,n]}function OA(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ap(),r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,s=t;return s[Mi]||(s[Mi]={dragDropManager:CA(e,t,r,n)}),s[Mi]}function ap(){return typeof global<"u"?global:window}function NA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function PA(e,t,r){return t&&jA(e.prototype,t),e}function ju(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Xo=!1,Jo=!1,RA=(function(){function e(t){NA(this,e),ju(this,"internalMonitor",void 0),ju(this,"sourceId",null),this.internalMonitor=t.getMonitor()}return PA(e,[{key:"receiveHandlerId",value:function(r){this.sourceId=r}},{key:"getHandlerId",value:function(){return this.sourceId}},{key:"canDrag",value:function(){xe(!Xo,"You may not call monitor.canDrag() inside your canDrag() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Xo=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{Xo=!1}}},{key:"isDragging",value:function(){if(!this.sourceId)return!1;xe(!Jo,"You may not call monitor.isDragging() inside your isDragging() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor");try{return Jo=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{Jo=!1}}},{key:"subscribeToStateChange",value:function(r,n){return this.internalMonitor.subscribeToStateChange(r,n)}},{key:"isDraggingSource",value:function(r){return this.internalMonitor.isDraggingSource(r)}},{key:"isOverTarget",value:function(r,n){return this.internalMonitor.isOverTarget(r,n)}},{key:"getTargetIds",value:function(){return this.internalMonitor.getTargetIds()}},{key:"isSourcePublic",value:function(){return this.internalMonitor.isSourcePublic()}},{key:"getSourceId",value:function(){return this.internalMonitor.getSourceId()}},{key:"subscribeToOffsetChange",value:function(r){return this.internalMonitor.subscribeToOffsetChange(r)}},{key:"canDragSource",value:function(r){return this.internalMonitor.canDragSource(r)}},{key:"canDropOnTarget",value:function(r){return this.internalMonitor.canDropOnTarget(r)}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}]),e})();function FA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function MA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function BA(e,t,r){return t&&MA(e.prototype,t),e}function Pu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ea=!1,qA=(function(){function e(t){FA(this,e),Pu(this,"internalMonitor",void 0),Pu(this,"targetId",null),this.internalMonitor=t.getMonitor()}return BA(e,[{key:"receiveHandlerId",value:function(r){this.targetId=r}},{key:"getHandlerId",value:function(){return this.targetId}},{key:"subscribeToStateChange",value:function(r,n){return this.internalMonitor.subscribeToStateChange(r,n)}},{key:"canDrop",value:function(){if(!this.targetId)return!1;xe(!ea,"You may not call monitor.canDrop() inside your canDrop() implementation. Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor");try{return ea=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{ea=!1}}},{key:"isOver",value:function(r){return this.targetId?this.internalMonitor.isOverTarget(this.targetId,r):!1}},{key:"getItemType",value:function(){return this.internalMonitor.getItemType()}},{key:"getItem",value:function(){return this.internalMonitor.getItem()}},{key:"getDropResult",value:function(){return this.internalMonitor.getDropResult()}},{key:"didDrop",value:function(){return this.internalMonitor.didDrop()}},{key:"getInitialClientOffset",value:function(){return this.internalMonitor.getInitialClientOffset()}},{key:"getInitialSourceClientOffset",value:function(){return this.internalMonitor.getInitialSourceClientOffset()}},{key:"getSourceClientOffset",value:function(){return this.internalMonitor.getSourceClientOffset()}},{key:"getClientOffset",value:function(){return this.internalMonitor.getClientOffset()}},{key:"getDifferenceFromInitialOffset",value:function(){return this.internalMonitor.getDifferenceFromInitialOffset()}}]),e})();function $A(e){if(typeof e.type!="string"){var t=e.type.displayName||e.type.name||"the component";throw new Error("Only native element nodes can now be passed to React DnD connectors."+"You can either wrap ".concat(t," into a <div>, or turn it into a ")+"drag source or a drop target itself.")}}function UA(e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:null,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;if(!g.isValidElement(t)){var n=t;return e(n,r),n}var s=t;$A(s);var i=r?function(o){return e(o,r)}:e;return zA(s,i)}}function lp(e){var t={};return Object.keys(e).forEach(function(r){var n=e[r];if(r.endsWith("Ref"))t[r]=e[r];else{var s=UA(n);t[r]=function(){return s}}}),t}function Ru(e,t){typeof e=="function"?e(t):e.current=t}function zA(e,t){var r=e.ref;return xe(typeof r!="string","Cannot connect React DnD to an element with an existing string ref. Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs"),r?g.cloneElement(e,{ref:function(s){Ru(r,s),Ru(t,s)}}):g.cloneElement(e,{ref:t})}function Bi(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Bi=function(r){return typeof r}:Bi=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Bi(e)}function tl(e){return e!==null&&Bi(e)==="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function rl(e,t,r,n){var s=void 0;if(s!==void 0)return!!s;if(e===t)return!0;if(typeof e!="object"||!e||typeof t!="object"||!t)return!1;var i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(var a=Object.prototype.hasOwnProperty.bind(t),c=0;c<i.length;c++){var u=i[c];if(!a(u))return!1;var d=e[u],f=t[u];if(s=void 0,s===!1||s===void 0&&d!==f)return!1}return!0}function VA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function QA(e,t,r){return t&&HA(e.prototype,t),e}function _t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var WA=(function(){function e(t){var r=this;VA(this,e),_t(this,"hooks",lp({dragSource:function(s,i){r.clearDragSource(),r.dragSourceOptions=i||null,tl(s)?r.dragSourceRef=s:r.dragSourceNode=s,r.reconnectDragSource()},dragPreview:function(s,i){r.clearDragPreview(),r.dragPreviewOptions=i||null,tl(s)?r.dragPreviewRef=s:r.dragPreviewNode=s,r.reconnectDragPreview()}})),_t(this,"handlerId",null),_t(this,"dragSourceRef",null),_t(this,"dragSourceNode",void 0),_t(this,"dragSourceOptionsInternal",null),_t(this,"dragSourceUnsubscribe",void 0),_t(this,"dragPreviewRef",null),_t(this,"dragPreviewNode",void 0),_t(this,"dragPreviewOptionsInternal",null),_t(this,"dragPreviewUnsubscribe",void 0),_t(this,"lastConnectedHandlerId",null),_t(this,"lastConnectedDragSource",null),_t(this,"lastConnectedDragSourceOptions",null),_t(this,"lastConnectedDragPreview",null),_t(this,"lastConnectedDragPreviewOptions",null),_t(this,"backend",void 0),this.backend=t}return QA(e,[{key:"receiveHandlerId",value:function(r){this.handlerId!==r&&(this.handlerId=r,this.reconnect())}},{key:"connectTarget",get:function(){return this.dragSource}},{key:"dragSourceOptions",get:function(){return this.dragSourceOptionsInternal},set:function(r){this.dragSourceOptionsInternal=r}},{key:"dragPreviewOptions",get:function(){return this.dragPreviewOptionsInternal},set:function(r){this.dragPreviewOptionsInternal=r}},{key:"reconnect",value:function(){this.reconnectDragSource(),this.reconnectDragPreview()}},{key:"reconnectDragSource",value:function(){var r=this.dragSource,n=this.didHandlerIdChange()||this.didConnectedDragSourceChange()||this.didDragSourceOptionsChange();if(n&&this.disconnectDragSource(),!!this.handlerId){if(!r){this.lastConnectedDragSource=r;return}n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragSource=r,this.lastConnectedDragSourceOptions=this.dragSourceOptions,this.dragSourceUnsubscribe=this.backend.connectDragSource(this.handlerId,r,this.dragSourceOptions))}}},{key:"reconnectDragPreview",value:function(){var r=this.dragPreview,n=this.didHandlerIdChange()||this.didConnectedDragPreviewChange()||this.didDragPreviewOptionsChange();if(n&&this.disconnectDragPreview(),!!this.handlerId){if(!r){this.lastConnectedDragPreview=r;return}n&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDragPreview=r,this.lastConnectedDragPreviewOptions=this.dragPreviewOptions,this.dragPreviewUnsubscribe=this.backend.connectDragPreview(this.handlerId,r,this.dragPreviewOptions))}}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didConnectedDragSourceChange",value:function(){return this.lastConnectedDragSource!==this.dragSource}},{key:"didConnectedDragPreviewChange",value:function(){return this.lastConnectedDragPreview!==this.dragPreview}},{key:"didDragSourceOptionsChange",value:function(){return!rl(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}},{key:"didDragPreviewOptionsChange",value:function(){return!rl(this.lastConnectedDragPreviewOptions,this.dragPreviewOptions)}},{key:"disconnectDragSource",value:function(){this.dragSourceUnsubscribe&&(this.dragSourceUnsubscribe(),this.dragSourceUnsubscribe=void 0)}},{key:"disconnectDragPreview",value:function(){this.dragPreviewUnsubscribe&&(this.dragPreviewUnsubscribe(),this.dragPreviewUnsubscribe=void 0,this.dragPreviewNode=null,this.dragPreviewRef=null)}},{key:"dragSource",get:function(){return this.dragSourceNode||this.dragSourceRef&&this.dragSourceRef.current}},{key:"dragPreview",get:function(){return this.dragPreviewNode||this.dragPreviewRef&&this.dragPreviewRef.current}},{key:"clearDragSource",value:function(){this.dragSourceNode=null,this.dragSourceRef=null}},{key:"clearDragPreview",value:function(){this.dragPreviewNode=null,this.dragPreviewRef=null}}]),e})();function GA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function KA(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function YA(e,t,r){return t&&KA(e.prototype,t),e}function dr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ZA=(function(){function e(t){var r=this;GA(this,e),dr(this,"hooks",lp({dropTarget:function(s,i){r.clearDropTarget(),r.dropTargetOptions=i,tl(s)?r.dropTargetRef=s:r.dropTargetNode=s,r.reconnect()}})),dr(this,"handlerId",null),dr(this,"dropTargetRef",null),dr(this,"dropTargetNode",void 0),dr(this,"dropTargetOptionsInternal",null),dr(this,"unsubscribeDropTarget",void 0),dr(this,"lastConnectedHandlerId",null),dr(this,"lastConnectedDropTarget",null),dr(this,"lastConnectedDropTargetOptions",null),dr(this,"backend",void 0),this.backend=t}return YA(e,[{key:"connectTarget",get:function(){return this.dropTarget}},{key:"reconnect",value:function(){var r=this.didHandlerIdChange()||this.didDropTargetChange()||this.didOptionsChange();r&&this.disconnectDropTarget();var n=this.dropTarget;if(this.handlerId){if(!n){this.lastConnectedDropTarget=n;return}r&&(this.lastConnectedHandlerId=this.handlerId,this.lastConnectedDropTarget=n,this.lastConnectedDropTargetOptions=this.dropTargetOptions,this.unsubscribeDropTarget=this.backend.connectDropTarget(this.handlerId,n,this.dropTargetOptions))}}},{key:"receiveHandlerId",value:function(r){r!==this.handlerId&&(this.handlerId=r,this.reconnect())}},{key:"dropTargetOptions",get:function(){return this.dropTargetOptionsInternal},set:function(r){this.dropTargetOptionsInternal=r}},{key:"didHandlerIdChange",value:function(){return this.lastConnectedHandlerId!==this.handlerId}},{key:"didDropTargetChange",value:function(){return this.lastConnectedDropTarget!==this.dropTarget}},{key:"didOptionsChange",value:function(){return!rl(this.lastConnectedDropTargetOptions,this.dropTargetOptions)}},{key:"disconnectDropTarget",value:function(){this.unsubscribeDropTarget&&(this.unsubscribeDropTarget(),this.unsubscribeDropTarget=void 0)}},{key:"dropTarget",get:function(){return this.dropTargetNode||this.dropTargetRef&&this.dropTargetRef.current}},{key:"clearDropTarget",value:function(){this.dropTargetRef=null,this.dropTargetNode=null}}]),e})();function XA(e,t,r){var n=r.getRegistry(),s=n.addTarget(e,t);return[s,function(){return n.removeTarget(s)}]}function JA(e,t,r){var n=r.getRegistry(),s=n.addSource(e,t);return[s,function(){return n.removeSource(s)}]}var yn=typeof window<"u"?g.useLayoutEffect:g.useEffect;function qi(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?qi=function(r){return typeof r}:qi=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},qi(e)}function ek(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function tk(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rk(e,t,r){return t&&tk(e.prototype,t),e}function ta(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var nk=(function(){function e(t,r,n){ek(this,e),ta(this,"spec",void 0),ta(this,"monitor",void 0),ta(this,"connector",void 0),this.spec=t,this.monitor=r,this.connector=n}return rk(e,[{key:"beginDrag",value:function(){var r,n=this.spec,s=this.monitor,i=null;return qi(n.item)==="object"?i=n.item:typeof n.item=="function"?i=n.item(s):i={},(r=i)!==null&&r!==void 0?r:null}},{key:"canDrag",value:function(){var r=this.spec,n=this.monitor;return typeof r.canDrag=="boolean"?r.canDrag:typeof r.canDrag=="function"?r.canDrag(n):!0}},{key:"isDragging",value:function(r,n){var s=this.spec,i=this.monitor,o=s.isDragging;return o?o(i):n===r.getSourceId()}},{key:"endDrag",value:function(){var r=this.spec,n=this.monitor,s=this.connector,i=r.end;i&&i(n.getItem(),n),s.reconnect()}}]),e})();function sk(e,t,r){var n=g.useMemo(function(){return new nk(e,t,r)},[t,r]);return g.useEffect(function(){n.spec=e},[e]),n}function _n(){var e=g.useContext(ep),t=e.dragDropManager;return xe(t!=null,"Expected drag drop context"),t}function ik(e){return g.useMemo(function(){var t=e.type;return xe(t!=null,"spec.type must be defined"),t},[e])}function ok(e,t){return uk(e)||ck(e,t)||lk(e,t)||ak()}function ak(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
539
539
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function lk(e,t){if(e){if(typeof e=="string")return Fu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Fu(e,t)}}function Fu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function ck(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],s=!0,i=!1,o,a;try{for(r=r.call(e);!(s=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));s=!0);}catch(c){i=!0,a=c}finally{try{!s&&r.return!=null&&r.return()}finally{if(i)throw a}}return n}}function uk(e){if(Array.isArray(e))return e}function dk(e,t,r){var n=_n(),s=sk(e,t,r),i=ik(e);yn(function(){if(i!=null){var a=JA(i,s,n),c=ok(a,2),u=c[0],d=c[1];return t.receiveHandlerId(u),r.receiveHandlerId(u),d}},[n,t,r,s,i])}function fk(e){return gk(e)||mk(e)||pk(e)||hk()}function hk(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
@@ -543,4 +543,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
543
543
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Vk(e,t){if(e){if(typeof e=="string")return Uu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Uu(e,t)}}function Uu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function Hk(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],s=!0,i=!1,o,a;try{for(r=r.call(e);!(s=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));s=!0);}catch(c){i=!0,a=c}finally{try{!s&&r.return!=null&&r.return()}finally{if(i)throw a}}return n}}function Qk(e){if(Array.isArray(e))return e}function Wk(e,t,r){var n=_n(),s=$k(e,t),i=Rk(e);yn(function(){var a=XA(i,s,n),c=Uk(a,2),u=c[0],d=c[1];return t.receiveHandlerId(u),r.receiveHandlerId(u),d},[n,t,s,r,i.map(function(o){return o.toString()}).join("|")])}function Gk(){var e=_n();return g.useMemo(function(){return new qA(e)},[e])}function Kk(e){var t=_n(),r=g.useMemo(function(){return new ZA(t.getBackend())},[t]);return yn(function(){return r.dropTargetOptions=e||null,r.reconnect(),function(){return r.disconnectDropTarget()}},[e]),r}function Yk(e){return g.useMemo(function(){return e.hooks.dropTarget()},[e])}function fp(e,t){var r=cp(e,t),n=Gk(),s=Kk(r.options);return Wk(r,n,s),[dp(r.collect,n,s),Yk(s)]}function Zk(e,t){return tI(e)||eI(e,t)||Jk(e,t)||Xk()}function Xk(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
544
544
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Jk(e,t){if(e){if(typeof e=="string")return zu(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if(r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set")return Array.from(e);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return zu(e,t)}}function zu(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function eI(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var n=[],s=!0,i=!1,o,a;try{for(r=r.call(e);!(s=(o=r.next()).done)&&(n.push(o.value),!(t&&n.length===t));s=!0);}catch(c){i=!0,a=c}finally{try{!s&&r.return!=null&&r.return()}finally{if(i)throw a}}return n}}function tI(e){if(Array.isArray(e))return e}function rI(e){var t=_n(),r=t.getMonitor(),n=up(r,e),s=Zk(n,2),i=s[0],o=s[1];return g.useEffect(function(){return r.subscribeToOffsetChange(o)}),g.useEffect(function(){return r.subscribeToStateChange(o)}),i}function hp(e){var t=null,r=function(){return t==null&&(t=e()),t};return r}function nI(e,t){return e.filter(function(r){return r!==t})}function sI(e,t){var r=new Set,n=function(o){return r.add(o)};e.forEach(n),t.forEach(n);var s=[];return r.forEach(function(i){return s.push(i)}),s}function iI(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oI(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function aI(e,t,r){return t&&oI(e.prototype,t),e}function Vu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var lI=(function(){function e(t){iI(this,e),Vu(this,"entered",[]),Vu(this,"isNodeInDocument",void 0),this.isNodeInDocument=t}return aI(e,[{key:"enter",value:function(r){var n=this,s=this.entered.length,i=function(a){return n.isNodeInDocument(a)&&(!a.contains||a.contains(r))};return this.entered=sI(this.entered.filter(i),[r]),s===0&&this.entered.length>0}},{key:"leave",value:function(r){var n=this.entered.length;return this.entered=nI(this.entered.filter(this.isNodeInDocument),r),n>0&&this.entered.length===0}},{key:"reset",value:function(){this.entered=[]}}]),e})(),cI=hp(function(){return/firefox/i.test(navigator.userAgent)}),pp=hp(function(){return!!window.safari});function uI(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function dI(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function fI(e,t,r){return t&&dI(e.prototype,t),e}function vs(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Hu=(function(){function e(t,r){uI(this,e),vs(this,"xs",void 0),vs(this,"ys",void 0),vs(this,"c1s",void 0),vs(this,"c2s",void 0),vs(this,"c3s",void 0);for(var n=t.length,s=[],i=0;i<n;i++)s.push(i);s.sort(function(E,j){return t[E]<t[j]?-1:1});for(var o=[],a=[],c,u,d=0;d<n-1;d++)c=t[d+1]-t[d],u=r[d+1]-r[d],o.push(c),a.push(u/c);for(var f=[a[0]],m=0;m<o.length-1;m++){var p=a[m],b=a[m+1];if(p*b<=0)f.push(0);else{c=o[m];var h=o[m+1],v=c+h;f.push(3*v/((v+h)/p+(v+c)/b))}}f.push(a[a.length-1]);for(var y=[],C=[],S,_=0;_<f.length-1;_++){S=a[_];var x=f[_],T=1/o[_],D=x+f[_+1]-S-S;y.push((S-x-D)*T),C.push(D*T*T)}this.xs=t,this.ys=r,this.c1s=f,this.c2s=y,this.c3s=C}return fI(e,[{key:"interpolate",value:function(r){var n=this.xs,s=this.ys,i=this.c1s,o=this.c2s,a=this.c3s,c=n.length-1;if(r===n[c])return s[c];for(var u=0,d=a.length-1,f;u<=d;){f=Math.floor(.5*(u+d));var m=n[f];if(m<r)u=f+1;else if(m>r)d=f-1;else return s[f]}c=Math.max(0,d);var p=r-n[c],b=p*p;return s[c]+i[c]*p+o[c]*b+a[c]*p*b}}]),e})(),hI=1;function mp(e){var t=e.nodeType===hI?e:e.parentElement;if(!t)return null;var r=t.getBoundingClientRect(),n=r.top,s=r.left;return{x:s,y:n}}function vi(e){return{x:e.clientX,y:e.clientY}}function pI(e){var t;return e.nodeName==="IMG"&&(cI()||!((t=document.documentElement)!==null&&t!==void 0&&t.contains(e)))}function mI(e,t,r,n){var s=e?t.width:r,i=e?t.height:n;return pp()&&e&&(i/=window.devicePixelRatio,s/=window.devicePixelRatio),{dragPreviewWidth:s,dragPreviewHeight:i}}function gI(e,t,r,n,s){var i=pI(t),o=i?e:t,a=mp(o),c={x:r.x-a.x,y:r.y-a.y},u=e.offsetWidth,d=e.offsetHeight,f=n.anchorX,m=n.anchorY,p=mI(i,t,u,d),b=p.dragPreviewWidth,h=p.dragPreviewHeight,v=function(){var D=new Hu([0,.5,1],[c.y,c.y/d*h,c.y+h-d]),E=D.interpolate(m);return pp()&&i&&(E+=(window.devicePixelRatio-1)*h),E},y=function(){var D=new Hu([0,.5,1],[c.x,c.x/u*b,c.x+b-u]);return D.interpolate(f)},C=s.offsetX,S=s.offsetY,_=C===0||C,x=S===0||S;return{x:_?C:y(),y:x?S:v()}}var gp="__NATIVE_FILE__",vp="__NATIVE_URL__",yp="__NATIVE_TEXT__",bp="__NATIVE_HTML__";const Qu=Object.freeze(Object.defineProperty({__proto__:null,FILE:gp,HTML:bp,TEXT:yp,URL:vp},Symbol.toStringTag,{value:"Module"}));function na(e,t,r){var n=t.reduce(function(s,i){return s||e.getData(i)},"");return n??r}var Dn;function yi(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var sl=(Dn={},yi(Dn,gp,{exposeProperties:{files:function(t){return Array.prototype.slice.call(t.files)},items:function(t){return t.items},dataTransfer:function(t){return t}},matchesTypes:["Files"]}),yi(Dn,bp,{exposeProperties:{html:function(t,r){return na(t,r,"")},dataTransfer:function(t){return t}},matchesTypes:["Html","text/html"]}),yi(Dn,vp,{exposeProperties:{urls:function(t,r){return na(t,r,"").split(`
|
|
545
545
|
`)},dataTransfer:function(t){return t}},matchesTypes:["Url","text/uri-list"]}),yi(Dn,yp,{exposeProperties:{text:function(t,r){return na(t,r,"")},dataTransfer:function(t){return t}},matchesTypes:["Text","text/plain"]}),Dn);function vI(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yI(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function bI(e,t,r){return t&&yI(e.prototype,t),e}function Wu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var CI=(function(){function e(t){vI(this,e),Wu(this,"item",void 0),Wu(this,"config",void 0),this.config=t,this.item={},this.initializeExposedProperties()}return bI(e,[{key:"initializeExposedProperties",value:function(){var r=this;Object.keys(this.config.exposeProperties).forEach(function(n){Object.defineProperty(r.item,n,{configurable:!0,enumerable:!0,get:function(){return console.warn(`Browser doesn't allow reading "`.concat(n,'" until the drop event.')),null}})})}},{key:"loadDataTransfer",value:function(r){var n=this;if(r){var s={};Object.keys(this.config.exposeProperties).forEach(function(i){s[i]={value:n.config.exposeProperties[i](r,n.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,s)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(r,n){return n===r.getSourceId()}},{key:"endDrag",value:function(){}}]),e})();function SI(e,t){var r=new CI(sl[e]);return r.loadDataTransfer(t),r}function sa(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(sl).filter(function(r){var n=sl[r].matchesTypes;return n.some(function(s){return t.indexOf(s)>-1})})[0]||null}function _I(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wI(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function xI(e,t,r){return t&&wI(e.prototype,t),e}function ia(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var TI=(function(){function e(t,r){_I(this,e),ia(this,"ownerDocument",null),ia(this,"globalContext",void 0),ia(this,"optionsArgs",void 0),this.globalContext=t,this.optionsArgs=r}return xI(e,[{key:"window",get:function(){if(this.globalContext)return this.globalContext;if(typeof window<"u")return window}},{key:"document",get:function(){var r;return(r=this.globalContext)!==null&&r!==void 0&&r.document?this.globalContext.document:this.window?this.window.document:void 0}},{key:"rootElement",get:function(){var r;return((r=this.optionsArgs)===null||r===void 0?void 0:r.rootElement)||this.window}}]),e})();function Gu(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),r.push.apply(r,n)}return r}function Ku(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Gu(Object(r),!0).forEach(function(n){Ie(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Gu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function EI(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function AI(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function kI(e,t,r){return t&&AI(e.prototype,t),e}function Ie(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var II=(function(){function e(t,r,n){var s=this;EI(this,e),Ie(this,"options",void 0),Ie(this,"actions",void 0),Ie(this,"monitor",void 0),Ie(this,"registry",void 0),Ie(this,"enterLeaveCounter",void 0),Ie(this,"sourcePreviewNodes",new Map),Ie(this,"sourcePreviewNodeOptions",new Map),Ie(this,"sourceNodes",new Map),Ie(this,"sourceNodeOptions",new Map),Ie(this,"dragStartSourceIds",null),Ie(this,"dropTargetIds",[]),Ie(this,"dragEnterTargetIds",[]),Ie(this,"currentNativeSource",null),Ie(this,"currentNativeHandle",null),Ie(this,"currentDragSourceNode",null),Ie(this,"altKeyPressed",!1),Ie(this,"mouseMoveTimeoutTimer",null),Ie(this,"asyncEndDragFrameId",null),Ie(this,"dragOverTargetIds",null),Ie(this,"lastClientOffset",null),Ie(this,"hoverRafId",null),Ie(this,"getSourceClientOffset",function(i){var o=s.sourceNodes.get(i);return o&&mp(o)||null}),Ie(this,"endDragNativeItem",function(){s.isDraggingNativeItem()&&(s.actions.endDrag(),s.currentNativeHandle&&s.registry.removeSource(s.currentNativeHandle),s.currentNativeHandle=null,s.currentNativeSource=null)}),Ie(this,"isNodeInDocument",function(i){return!!(i&&s.document&&s.document.body&&s.document.body.contains(i))}),Ie(this,"endDragIfSourceWasRemovedFromDOM",function(){var i=s.currentDragSourceNode;i==null||s.isNodeInDocument(i)||s.clearCurrentDragSourceNode()&&s.monitor.isDragging()&&s.actions.endDrag()}),Ie(this,"handleTopDragStartCapture",function(){s.clearCurrentDragSourceNode(),s.dragStartSourceIds=[]}),Ie(this,"handleTopDragStart",function(i){if(!i.defaultPrevented){var o=s.dragStartSourceIds;s.dragStartSourceIds=null;var a=vi(i);s.monitor.isDragging()&&s.actions.endDrag(),s.actions.beginDrag(o||[],{publishSource:!1,getSourceClientOffset:s.getSourceClientOffset,clientOffset:a});var c=i.dataTransfer,u=sa(c);if(s.monitor.isDragging()){if(c&&typeof c.setDragImage=="function"){var d=s.monitor.getSourceId(),f=s.sourceNodes.get(d),m=s.sourcePreviewNodes.get(d)||f;if(m){var p=s.getCurrentSourcePreviewNodeOptions(),b=p.anchorX,h=p.anchorY,v=p.offsetX,y=p.offsetY,C={anchorX:b,anchorY:h},S={offsetX:v,offsetY:y},_=gI(f,m,a,C,S);c.setDragImage(m,_.x,_.y)}}try{c==null||c.setData("application/json",{})}catch{}s.setCurrentDragSourceNode(i.target);var x=s.getCurrentSourcePreviewNodeOptions(),T=x.captureDraggingState;T?s.actions.publishDragSource():setTimeout(function(){return s.actions.publishDragSource()},0)}else if(u)s.beginDragNativeItem(u);else{if(c&&!c.types&&(i.target&&!i.target.hasAttribute||!i.target.hasAttribute("draggable")))return;i.preventDefault()}}}),Ie(this,"handleTopDragEndCapture",function(){s.clearCurrentDragSourceNode()&&s.monitor.isDragging()&&s.actions.endDrag()}),Ie(this,"handleTopDragEnterCapture",function(i){s.dragEnterTargetIds=[];var o=s.enterLeaveCounter.enter(i.target);if(!(!o||s.monitor.isDragging())){var a=i.dataTransfer,c=sa(a);c&&s.beginDragNativeItem(c,a)}}),Ie(this,"handleTopDragEnter",function(i){var o=s.dragEnterTargetIds;if(s.dragEnterTargetIds=[],!!s.monitor.isDragging()){s.altKeyPressed=i.altKey,o.length>0&&s.actions.hover(o,{clientOffset:vi(i)});var a=o.some(function(c){return s.monitor.canDropOnTarget(c)});a&&(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=s.getCurrentDropEffect()))}}),Ie(this,"handleTopDragOverCapture",function(){s.dragOverTargetIds=[]}),Ie(this,"handleTopDragOver",function(i){var o=s.dragOverTargetIds;if(s.dragOverTargetIds=[],!s.monitor.isDragging()){i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="none");return}s.altKeyPressed=i.altKey,s.lastClientOffset=vi(i),s.hoverRafId===null&&typeof requestAnimationFrame<"u"&&(s.hoverRafId=requestAnimationFrame(function(){s.monitor.isDragging()&&s.actions.hover(o||[],{clientOffset:s.lastClientOffset}),s.hoverRafId=null}));var a=(o||[]).some(function(c){return s.monitor.canDropOnTarget(c)});a?(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=s.getCurrentDropEffect())):s.isDraggingNativeItem()?i.preventDefault():(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect="none"))}),Ie(this,"handleTopDragLeaveCapture",function(i){s.isDraggingNativeItem()&&i.preventDefault();var o=s.enterLeaveCounter.leave(i.target);o&&s.isDraggingNativeItem()&&setTimeout(function(){return s.endDragNativeItem()},0)}),Ie(this,"handleTopDropCapture",function(i){if(s.dropTargetIds=[],s.isDraggingNativeItem()){var o;i.preventDefault(),(o=s.currentNativeSource)===null||o===void 0||o.loadDataTransfer(i.dataTransfer)}else sa(i.dataTransfer)&&i.preventDefault();s.enterLeaveCounter.reset()}),Ie(this,"handleTopDrop",function(i){var o=s.dropTargetIds;s.dropTargetIds=[],s.actions.hover(o,{clientOffset:vi(i)}),s.actions.drop({dropEffect:s.getCurrentDropEffect()}),s.isDraggingNativeItem()?s.endDragNativeItem():s.monitor.isDragging()&&s.actions.endDrag()}),Ie(this,"handleSelectStart",function(i){var o=i.target;typeof o.dragDrop=="function"&&(o.tagName==="INPUT"||o.tagName==="SELECT"||o.tagName==="TEXTAREA"||o.isContentEditable||(i.preventDefault(),o.dragDrop()))}),this.options=new TI(r,n),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new lI(this.isNodeInDocument)}return kI(e,[{key:"profile",value:function(){var r,n;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:((r=this.dragStartSourceIds)===null||r===void 0?void 0:r.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:((n=this.dragOverTargetIds)===null||n===void 0?void 0:n.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var r=this.rootElement;if(r!==void 0){if(r.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");r.__isReactDndBackendSetUp=!0,this.addEventListeners(r)}}},{key:"teardown",value:function(){var r=this.rootElement;if(r!==void 0&&(r.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var n;(n=this.window)===null||n===void 0||n.cancelAnimationFrame(this.asyncEndDragFrameId)}}},{key:"connectDragPreview",value:function(r,n,s){var i=this;return this.sourcePreviewNodeOptions.set(r,s),this.sourcePreviewNodes.set(r,n),function(){i.sourcePreviewNodes.delete(r),i.sourcePreviewNodeOptions.delete(r)}}},{key:"connectDragSource",value:function(r,n,s){var i=this;this.sourceNodes.set(r,n),this.sourceNodeOptions.set(r,s);var o=function(u){return i.handleDragStart(u,r)},a=function(u){return i.handleSelectStart(u)};return n.setAttribute("draggable","true"),n.addEventListener("dragstart",o),n.addEventListener("selectstart",a),function(){i.sourceNodes.delete(r),i.sourceNodeOptions.delete(r),n.removeEventListener("dragstart",o),n.removeEventListener("selectstart",a),n.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(r,n){var s=this,i=function(u){return s.handleDragEnter(u,r)},o=function(u){return s.handleDragOver(u,r)},a=function(u){return s.handleDrop(u,r)};return n.addEventListener("dragenter",i),n.addEventListener("dragover",o),n.addEventListener("drop",a),function(){n.removeEventListener("dragenter",i),n.removeEventListener("dragover",o),n.removeEventListener("drop",a)}}},{key:"addEventListeners",value:function(r){r.addEventListener&&(r.addEventListener("dragstart",this.handleTopDragStart),r.addEventListener("dragstart",this.handleTopDragStartCapture,!0),r.addEventListener("dragend",this.handleTopDragEndCapture,!0),r.addEventListener("dragenter",this.handleTopDragEnter),r.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),r.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),r.addEventListener("dragover",this.handleTopDragOver),r.addEventListener("dragover",this.handleTopDragOverCapture,!0),r.addEventListener("drop",this.handleTopDrop),r.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(r){r.removeEventListener&&(r.removeEventListener("dragstart",this.handleTopDragStart),r.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),r.removeEventListener("dragend",this.handleTopDragEndCapture,!0),r.removeEventListener("dragenter",this.handleTopDragEnter),r.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),r.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),r.removeEventListener("dragover",this.handleTopDragOver),r.removeEventListener("dragover",this.handleTopDragOverCapture,!0),r.removeEventListener("drop",this.handleTopDrop),r.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var r=this.monitor.getSourceId(),n=this.sourceNodeOptions.get(r);return Ku({dropEffect:this.altKeyPressed?"copy":"move"},n||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var r=this.monitor.getSourceId(),n=this.sourcePreviewNodeOptions.get(r);return Ku({anchorX:.5,anchorY:.5,captureDraggingState:!1},n||{})}},{key:"isDraggingNativeItem",value:function(){var r=this.monitor.getItemType();return Object.keys(Qu).some(function(n){return Qu[n]===r})}},{key:"beginDragNativeItem",value:function(r,n){this.clearCurrentDragSourceNode(),this.currentNativeSource=SI(r,n),this.currentNativeHandle=this.registry.addSource(r,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(r){var n=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=r;var s=1e3;this.mouseMoveTimeoutTimer=setTimeout(function(){var i;return(i=n.rootElement)===null||i===void 0?void 0:i.addEventListener("mousemove",n.endDragIfSourceWasRemovedFromDOM,!0)},s)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var r;(r=this.window)===null||r===void 0||r.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(r,n){r.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(n))}},{key:"handleDragEnter",value:function(r,n){this.dragEnterTargetIds.unshift(n)}},{key:"handleDragOver",value:function(r,n){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(n)}},{key:"handleDrop",value:function(r,n){this.dropTargetIds.unshift(n)}}]),e})(),bi;function DI(){return bi||(bi=new Image,bi.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),bi}var LI=function(t,r,n){return new II(t,r,n)};function OI(e,t){return typeof e=="function"?e(t):e??"NODE"}function NI(e){return e.isDraggable&&!e.isEditing}function jI(e){const t=Ft(),r=t.selectedIds,[n,s,i]=Pk(()=>({canDrag:()=>NI(e),type:OI(t.props.dragType,e),item:()=>{const o=t.isSelected(e.id)?Array.from(r):[e.id];return t.dispatch(ns.dragStart(e.id,o)),{id:e.id,dragIds:o,data:e.data}},end:()=>{t.hideCursor(),t.redrawList(),t.dispatch(ns.dragEnd())}}),[r,e,t.props.dragType]);return g.useEffect(()=>{i(DI())},[i]),s}function PI(e,t){const r=e.getBoundingClientRect(),n=t.x-Math.round(r.x),s=t.y-Math.round(r.y),i=r.height,o=s<i/2,a=!o,c=i/4,u=s>c&&s<i-c;return{x:n,inTopHalf:o,inBottomHalf:a,inMiddle:u,atTop:!u&&o,atBottom:!u&&a}}function RI(e,t,r,n){return e?e.isInternal?n.atTop?[t,e]:n.inMiddle?[e,e]:[e,r]:n.inTopHalf?[t,e]:[e,r]:[t,null]}function Ci(e,t){return{parentId:e||null,index:t}}function Ln(e,t){return{type:"line",index:e,level:t}}function FI(e){return{type:"highlight",id:e}}function oa(e,t){var r;let n=e;for(;n.parent&&n.level>t;)n=n.parent;const s=((r=n.parent)===null||r===void 0?void 0:r.id)||null,i=Vh(n)+1;return{parentId:s,index:i}}function Cp(e){var t;const r=PI(e.element,e.offset),n=e.indent,s=Math.round(Math.max(0,r.x-n)/n),{node:i,nextNode:o,prevNode:a}=e,[c,u]=RI(i,a,o,r);if(i&&i.isInternal&&r.inMiddle)return{drop:Ci(i.id,null),cursor:FI(i.id)};if(!c)return{drop:Ci((t=u==null?void 0:u.parent)===null||t===void 0?void 0:t.id,0),cursor:Ln(0,0)};if(qh(c)){const d=Ni(s,(u==null?void 0:u.level)||0,c.level);return{drop:oa(c,d),cursor:Ln(c.rowIndex+1,d)}}if($h(c)){const d=Ni(s,(u==null?void 0:u.level)||0,c.level);return{drop:oa(c,d),cursor:Ln(c.rowIndex+1,d)}}if(Uh(c)){const d=Ni(s,0,c.level+1);return d>c.level?{drop:Ci(c.id,0),cursor:Ln(c.rowIndex+1,d)}:{drop:oa(c,d),cursor:Ln(c.rowIndex+1,d)}}return{drop:Ci(c==null?void 0:c.id,0),cursor:Ln(c.rowIndex+1,c.level+1)}}function MI(e,t){const r=Ft(),[n,s]=fp(()=>({accept:"NODE",canDrop:()=>r.canDrop(),hover:(i,o)=>{const a=o.getClientOffset();if(!e.current||!a)return;const{cursor:c,drop:u}=Cp({element:e.current,offset:a,indent:r.indent,node:t,prevNode:t.prev,nextNode:t.next});u&&r.dispatch(ns.hovering(u.parentId,u.index)),o.canDrop()?c&&r.showCursor(c):r.hideCursor()},drop:(i,o)=>{if(!o.canDrop())return null;r.drop()}}),[t,e.current,r.props]);return s}function BI(e){const t=Ft(),r=t.at(e);if(!r)throw new Error(`Could not find node for index: ${e}`);return g.useMemo(()=>{const n=r.clone();return t.visibleNodes[e]=n,n},[...Object.values(r.state),r])}const Yu=g.memo(function({index:t,style:r}){Bh(),r1();const n=Ft(),s=BI(t),i=g.useRef(null),o=jI(s),a=MI(i,s),c=g.useCallback(h=>{i.current=h,a(h)},[a]),u=n.indent*s.level,d=g.useMemo(()=>({paddingLeft:u}),[u]),f=g.useMemo(()=>{var h,v;return Object.assign(Object.assign({},r),{top:parseFloat(r.top)+((v=(h=n.props.padding)!==null&&h!==void 0?h:n.props.paddingTop)!==null&&v!==void 0?v:0),minWidth:"max-content"})},[r,n.props.padding,n.props.paddingTop]),m={role:"treeitem","aria-level":s.level+1,"aria-selected":s.isSelected,"aria-expanded":s.isOpen,style:f,tabIndex:-1,className:n.props.rowClassName};g.useEffect(()=>{var h;!s.isEditing&&s.isFocused&&((h=i.current)===null||h===void 0||h.focus({preventScroll:!0}))},[s.isEditing,s.isFocused,i.current]);const p=n.renderNode,b=n.renderRow;return l.jsx(b,{node:s,innerRef:c,attrs:m,children:l.jsx(p,{node:s,tree:n,style:d,dragHandle:o})})});let aa="",Zu=null;function Sp(){Bh();const e=Ft();return l.jsx("div",{role:"tree","aria-label":e.props["aria-label"],"aria-labelledby":e.props["aria-labelledby"],"aria-multiselectable":!e.props.disableMultiSelection||void 0,style:{height:e.height,width:e.width,minHeight:0,minWidth:0},onContextMenu:e.props.onContextMenu,onClick:e.props.onClick,tabIndex:0,onFocus:t=>{t.currentTarget.contains(t.relatedTarget)||e.onFocus()},onBlur:t=>{t.currentTarget.contains(t.relatedTarget)||e.onBlur()},onKeyDown:t=>{var r;if(e.isEditing)return;if(t.key==="Backspace"){if(!e.props.onDelete)return;const s=Array.from(e.selectedIds);if(s.length>1){let i=e.mostRecentNode;for(;i&&i.isSelected;)i=i.nextSibling;i||(i=e.lastNode),e.focus(i,{scroll:!1}),e.delete(Array.from(s))}else{const i=e.focusedNode;if(i){const o=i.nextSibling,a=i.parent;e.focus(o||a,{scroll:!1}),e.delete(i)}}return}if(t.key==="Tab"&&!t.shiftKey){t.preventDefault(),Hh(t.currentTarget);return}if(t.key==="Tab"&&t.shiftKey){t.preventDefault(),Qh(t.currentTarget);return}if(t.key==="ArrowDown"){t.preventDefault();const s=e.nextNode;if(t.metaKey){e.select(e.focusedNode),e.activate(e.focusedNode);return}else if(!t.shiftKey||e.props.disableMultiSelection){e.focus(s);return}else{if(!s)return;const i=e.focusedNode;i?i.isSelected?e.selectContiguous(s):e.selectMulti(s):e.focus(e.firstNode);return}}if(t.key==="ArrowUp"){t.preventDefault();const s=e.prevNode;if(!t.shiftKey||e.props.disableMultiSelection){e.focus(s);return}else{if(!s)return;const i=e.focusedNode;i?i.isSelected?e.selectContiguous(s):e.selectMulti(s):e.focus(e.lastNode);return}}if(t.key==="ArrowRight"){const s=e.focusedNode;if(!s)return;s.isInternal&&s.isOpen?e.focus(e.nextNode):s.isInternal&&e.open(s.id);return}if(t.key==="ArrowLeft"){const s=e.focusedNode;if(!s||s.isRoot)return;s.isInternal&&s.isOpen?e.close(s.id):!((r=s.parent)===null||r===void 0)&&r.isRoot||e.focus(s.parent);return}if(t.key==="a"&&(t.metaKey||t.ctrlKey)&&!e.props.disableMultiSelection){t.preventDefault(),e.selectAll();return}if(t.key==="a"&&!t.metaKey&&!t.ctrlKey&&e.props.onCreate){e.createLeaf();return}if(t.key==="A"&&!t.metaKey&&!t.ctrlKey){if(!e.props.onCreate)return;e.createInternal();return}if(t.key==="Home"){t.preventDefault(),e.focus(e.firstNode);return}if(t.key==="End"){t.preventDefault(),e.focus(e.lastNode);return}if(t.key==="Enter"){const s=e.focusedNode;if(!s||!s.isEditable||!e.props.onRename)return;setTimeout(()=>{s&&e.edit(s)});return}if(t.key===" "){t.preventDefault();const s=e.focusedNode;if(!s)return;s.isLeaf?(s.select(),s.activate()):s.toggle();return}if(t.key==="*"){const s=e.focusedNode;if(!s)return;e.openSiblings(s);return}if(t.key==="PageUp"){t.preventDefault(),e.pageUp();return}t.key==="PageDown"&&(t.preventDefault(),e.pageDown()),clearTimeout(Zu),aa+=t.key,Zu=setTimeout(()=>{aa=""},600);const n=e.visibleNodes.find(s=>{const i=s.data.name;return typeof i=="string"?i.toLowerCase().startsWith(aa):!1});n&&e.focus(n.id)},children:l.jsx(qI,{})})}function qI(){var e,t;const r=Ft(),n={className:r.props.className,outerRef:r.listEl,itemCount:r.visibleNodes.length,height:r.height,width:r.width,overscanCount:r.overscanCount,itemKey:s=>{var i;return((i=r.visibleNodes[s])===null||i===void 0?void 0:i.id)||s},outerElementType:(e=r.props.outerElementType)!==null&&e!==void 0?e:V1,innerElementType:(t=r.props.innerElementType)!==null&&t!==void 0?t:W1,onScroll:r.props.onScroll,onItemsRendered:r.onItemsRendered.bind(r)};return typeof r.props.rowHeight=="function"?l.jsx(q1,Object.assign({},n,{itemSize:r.rowHeightAt,ref:r.list,children:Yu})):l.jsx($1,Object.assign({},n,{itemSize:r.rowHeight,ref:r.list,children:Yu}))}function Xu(e){return e.isFiltered?UI(e.root,e.isMatch.bind(e)):$I(e.root)}function $I(e){const t=[];function r(n){var s;n.level>=0&&t.push(n),n.isOpen&&((s=n.children)===null||s===void 0||s.forEach(r))}return r(e),t.forEach(_p),t}function UI(e,t){const r={},n=[];function s(o){if(!o.isRoot&&t(o)){r[o.id]=!0;let c=o.parent;for(;c;)r[c.id]=!0,c=c.parent}if(o.children)for(let c of o.children)s(c)}function i(o){var a;o.level>=0&&r[o.id]&&n.push(o),o.isOpen&&((a=o.children)===null||a===void 0||a.forEach(i))}return s(e),i(e),n.forEach(_p),n}function _p(e,t){e.rowIndex=t}const Ju=e=>e.reduce((t,r,n)=>(t[r.id]=n,t),{});var la=function(e,t,r,n){function s(i){return i instanceof r?i:new r(function(o){o(i)})}return new(r||(r=Promise))(function(i,o){function a(d){try{u(n.next(d))}catch(f){o(f)}}function c(d){try{u(n.throw(d))}catch(f){o(f)}}function u(d){d.done?i(d.value):s(d.value).then(a,c)}u((n=n.apply(e,t||[])).next())})};const{safeRun:wt}=a1;class Is{constructor(t,r,n,s){this.store=t,this.props=r,this.list=n,this.listEl=s,this.visibleStartIndex=0,this.visibleStopIndex=0,this.rowOffsets=null,this.rowHeightAt=i=>{const o=this.props.rowHeight;if(typeof o=="function"){const a=this.at(i);return a?o(a):this.rowHeight}return o??24},this.rowTopPosition=i=>{if(typeof this.props.rowHeight!="function")return i*this.rowHeight;const o=this.getRowOffsets(),a=Math.max(0,Math.min(i,o.length-1));return o[a]},this.redrawList=(i=0)=>{this.rowOffsets=null;const o=this.list.current;o&&"resetAfterIndex"in o&&o.resetAfterIndex(Math.max(0,i))},this.root=ou(this),this.visibleNodes=Xu(this),this.idToIndex=Ju(this.visibleNodes)}update(t){this.props=t,this.root=ou(this),this.visibleNodes=Xu(this),this.idToIndex=Ju(this.visibleNodes),this.rowOffsets=null;const r=this.list.current;r&&"resetAfterIndex"in r&&r.resetAfterIndex(0,!1)}dispatch(t){return this.store.dispatch(t)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var t;return(t=this.props.width)!==null&&t!==void 0?t:300}get height(){var t;return(t=this.props.height)!==null&&t!==void 0?t:500}get indent(){var t;return(t=this.props.indent)!==null&&t!==void 0?t:24}get rowHeight(){return typeof this.props.rowHeight=="number"?this.props.rowHeight:24}getRowOffsets(){if(this.rowOffsets)return this.rowOffsets;const t=[0];for(let r=0;r<this.visibleNodes.length;r++)t.push(t[r]+this.rowHeightAt(r));return this.rowOffsets=t,t}get overscanCount(){var t;return(t=this.props.overscanCount)!==null&&t!==void 0?t:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var t;const r=(t=this.props.searchMatch)!==null&&t!==void 0?t:((n,s)=>JSON.stringify(Object.values(n.data)).toLocaleLowerCase().includes(s.toLocaleLowerCase()));return n=>r(n,this.searchTerm)}accessChildren(t){var r;const n=this.props.childrenAccessor||"children";return(r=xs(t,n))!==null&&r!==void 0?r:null}accessId(t){const r=this.props.idAccessor||"id",n=xs(t,r);if(!n)throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");return n}identify(t){if(typeof t=="string")return t;if(t instanceof $s)return t.id;const r=this.props.idAccessor||"id";return xs(t,r)}identifyNull(t){return t==null?null:this.identify(t)}get firstNode(){var t;return(t=this.visibleNodes[0])!==null&&t!==void 0?t:null}get lastNode(){var t;return(t=this.visibleNodes[this.visibleNodes.length-1])!==null&&t!==void 0?t:null}get focusedNode(){var t;return(t=this.get(this.state.nodes.focus.id))!==null&&t!==void 0?t:null}get mostRecentNode(){var t;return(t=this.get(this.state.nodes.selection.mostRecent))!==null&&t!==void 0?t:null}get nextNode(){const t=this.indexOf(this.focusedNode);return t===null?null:this.at(t+1)}get prevNode(){const t=this.indexOf(this.focusedNode);return t===null?null:this.at(t-1)}get(t){return t&&t in this.idToIndex&&this.visibleNodes[this.idToIndex[t]]||null}at(t){return this.visibleNodes[t]||null}nodesBetween(t,r){var n;if(t===null||r===null)return[];const s=(n=this.indexOf(t))!==null&&n!==void 0?n:0,i=this.indexOf(r);if(i===null)return[];const o=Math.min(s,i),a=Math.max(s,i);return this.visibleNodes.slice(o,a+1)}indexOf(t){const r=this.identifyNull(t);return r?this.idToIndex[r]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return la(this,arguments,void 0,function*(t={}){var r,n;const s=t.parentId===void 0?Yh(this):t.parentId,i=(r=t.index)!==null&&r!==void 0?r:Kh(this),o=(n=t.type)!==null&&n!==void 0?n:"leaf",a=yield wt(this.props.onCreate,{type:o,parentId:s,index:i,parentNode:this.get(s)});a&&(this.focus(a),setTimeout(()=>{this.edit(a).then(()=>{this.select(a),this.activate(a)})}))})}delete(t){return la(this,void 0,void 0,function*(){if(!t)return;const n=(Array.isArray(t)?t:[t]).map(o=>this.identify(o)),s=n.map(o=>this.get(o)).filter(o=>!!o),i=s.length?Math.min(...s.map(o=>{var a;return(a=o.rowIndex)!==null&&a!==void 0?a:0})):0;yield wt(this.props.onDelete,{nodes:s,ids:n}),this.redrawList(i)})}edit(t){var r,n;const s=this.identify(t);return this.resolveEdit({cancelled:!0}),this.scrollTo(s),this.dispatch(Ko(s)),this.redrawList((n=(r=this.get(s))===null||r===void 0?void 0:r.rowIndex)!==null&&n!==void 0?n:0),new Promise(i=>{Is.editPromise=i})}submit(t,r){return la(this,void 0,void 0,function*(){var n,s;if(!t)return;const i=this.identify(t);yield wt(this.props.onRename,{id:i,name:r,node:this.get(i)}),this.dispatch(Ko(null)),this.resolveEdit({cancelled:!1,value:r}),this.redrawList((s=(n=this.get(i))===null||n===void 0?void 0:n.rowIndex)!==null&&s!==void 0?s:0),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(Ko(null)),this.resolveEdit({cancelled:!0}),this.redrawList(),setTimeout(()=>this.onFocus())}activate(t){const r=this.get(this.identifyNull(t));r&&wt(this.props.onActivate,r)}resolveEdit(t){const r=Is.editPromise;r&&r(t),Is.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let t=[];for(let r of Array.from(this.selectedIds)){const n=this.get(r);n&&t.push(n)}return t}focus(t,r={}){t&&(this.props.selectionFollowsFocus?this.select(t):(this.dispatch(En(this.identify(t))),r.scroll!==!1&&this.scrollTo(t),this.focusedNode&&wt(this.props.onFocus,this.focusedNode)))}pageUp(){var t,r;const n=this.visibleStartIndex,i=this.visibleStopIndex-n;let o=(r=(t=this.focusedNode)===null||t===void 0?void 0:t.rowIndex)!==null&&r!==void 0?r:0;o>n?o=n:o=Math.max(n-i,0),this.focus(this.at(o))}pageDown(){var t,r;const n=this.visibleStartIndex,s=this.visibleStopIndex,i=s-n;let o=(r=(t=this.focusedNode)===null||t===void 0?void 0:t.rowIndex)!==null&&r!==void 0?r:0;o<s?o=s:o=Math.min(o+i,this.visibleNodes.length-1),this.focus(this.at(o))}select(t,r={}){var n;if(!t)return;const s=r.focus!==!1,i=this.identify(t);s&&this.dispatch(En(i)),!((n=this.get(i))===null||n===void 0)&&n.isSelectable&&this.setSelection({ids:[i],anchor:i,mostRecent:i}),this.scrollTo(i,r.align),this.focusedNode&&s&&wt(this.props.onFocus,this.focusedNode)}deselect(t){if(!t)return;const r=this.identify(t);this.dispatch(Ir.remove(r)),wt(this.props.onSelect,this.selectedNodes)}selectMulti(t,r={}){const n=this.get(this.identifyNull(t));if(!n)return;const s=r.focus!==!1;s&&this.dispatch(En(n.id)),n.isSelectable&&(this.dispatch(Ir.add(n.id)),this.dispatch(Ir.anchor(n.id)),this.dispatch(Ir.mostRecent(n.id))),this.scrollTo(n,r.align),this.focusedNode&&s&&wt(this.props.onFocus,this.focusedNode),wt(this.props.onSelect,this.selectedNodes)}selectContiguous(t){var r;if(!t)return;const n=this.identify(t);if(this.dispatch(En(n)),!((r=this.get(n))===null||r===void 0)&&r.isSelectable){const{anchor:s,mostRecent:i}=this.state.nodes.selection,o=this.filterSelectableNodes(this.nodesBetween(s,this.identifyNull(n)));this.dispatch(Ir.remove(this.nodesBetween(s,i))),this.dispatch(Ir.add(o)),this.dispatch(Ir.mostRecent(n))}this.scrollTo(n),this.focusedNode&&wt(this.props.onFocus,this.focusedNode),wt(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null})}selectAll(){var t,r,n;const s=this.filterSelectableNodes(Object.keys(this.idToIndex));this.setSelection({ids:s,anchor:(t=s[0])!==null&&t!==void 0?t:null,mostRecent:(r=s[s.length-1])!==null&&r!==void 0?r:null}),this.dispatch(En((n=this.lastNode)===null||n===void 0?void 0:n.id)),this.focusedNode&&wt(this.props.onFocus,this.focusedNode)}filterSelectableNodes(t){return t.map(r=>this.get(this.identify(r))).filter(r=>!!r&&r.isSelectable)}setSelection(t){var r;const n=new Set((r=t.ids)===null||r===void 0?void 0:r.map(o=>this.identify(o))),s=this.identifyNull(t.anchor),i=this.identifyNull(t.mostRecent);this.dispatch(Ir.set({ids:n,anchor:s,mostRecent:i})),wt(this.props.onSelect,this.selectedNodes)}get cursorParentId(){const{cursor:t}=this.state.dnd;switch(t.type){case"highlight":return t.id;default:return null}}get cursorOverFolder(){return this.state.dnd.cursor.type==="highlight"}get dragNodes(){return this.state.dnd.dragIds.map(t=>this.get(t)).filter(t=>!!t)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var t;if(this.isFiltered)return!1;const r=(t=this.get(this.state.dnd.parentId))!==null&&t!==void 0?t:this.root,n=this.dragNodes,s=this.props.disableDrop;for(const i of n)if(!i||!r||i.isInternal&&zh(r,i))return!1;return typeof s=="function"?!s({parentNode:r,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof s=="string"?!r.data[s]:typeof s=="boolean"?!s:!0}drop(){const{parentId:t,index:r,dragIds:n}=this.state.dnd;wt(this.props.onMove,{dragIds:n,parentId:t===qs?null:t,index:r===null?0:r,dragNodes:this.dragNodes,parentNode:this.get(t)}),this.open(t)}hideCursor(){this.dispatch(ns.cursor({type:"none"}))}showCursor(t){this.dispatch(ns.cursor(t))}open(t,r=!0){var n,s;const i=this.identifyNull(t);i&&(this.isOpen(i)||(this.dispatch(Ya.open(i,this.isFiltered)),r&&this.redrawList((s=(n=this.get(i))===null||n===void 0?void 0:n.rowIndex)!==null&&s!==void 0?s:0),wt(this.props.onToggle,i)))}close(t,r=!0){var n,s;const i=this.identifyNull(t);i&&this.isOpen(i)&&(this.dispatch(Ya.close(i,this.isFiltered)),r&&this.redrawList((s=(n=this.get(i))===null||n===void 0?void 0:n.rowIndex)!==null&&s!==void 0?s:0),wt(this.props.onToggle,i))}toggle(t){const r=this.identifyNull(t);if(r)return this.isOpen(r)?this.close(r):this.open(r)}openParents(t){const r=this.identifyNull(t);if(!r)return;const n=Fl(this.root,r);let s=n==null?void 0:n.parent;for(;s;)this.open(s.id,!1),s=s.parent;this.redrawList()}openSiblings(t){const r=t.parent;if(!r)this.toggle(t.id);else if(r.children){const n=t.isOpen;for(let s of r.children)s.isInternal&&(n?this.close(s.id,!1):this.open(s.id,!1));this.redrawList(),this.scrollTo(this.focusedNode)}}openAll(){eo(this.root,t=>{t.isInternal&&this.open(t.id,!1)}),this.redrawList()}closeAll(){eo(this.root,t=>{t.isInternal&&this.close(t.id,!1)}),this.redrawList()}scrollTo(t,r="smart"){if(!t)return;const n=this.identify(t);return this.openParents(n),Gh(()=>n in this.idToIndex).then(()=>{var s;const i=this.idToIndex[n];i!==void 0&&((s=this.list.current)===null||s===void 0||s.scrollToItem(i,r))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){var t;return!!(!((t=this.props.searchTerm)===null||t===void 0)&&t.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(t){return t?this.state.nodes.selection.ids.has(t):!1}isOpen(t){var r,n,s;if(!t)return!1;if(t===qs)return!0;const i=(r=this.props.openByDefault)!==null&&r!==void 0?r:!0;return this.isFiltered?(n=this.state.nodes.open.filtered[t])!==null&&n!==void 0?n:!0:(s=this.state.nodes.open.unfiltered[t])!==null&&s!==void 0?s:i}isEditable(t){return this.isActionPossible(t,this.props.disableEdit)}isDraggable(t){return this.isActionPossible(t,this.props.disableDrag)}isSelectable(t){return this.isActionPossible(t,this.props.disableSelect)}isActionPossible(t,r=()=>!1){return!xs(t,r)}isDragging(t){const r=this.identifyNull(t);return r?this.state.nodes.drag.id===r:!1}isFocused(t){return this.hasFocus&&this.state.nodes.focus.id===t}isMatch(t){return this.matchFn(t)}willReceiveDrop(t){const r=this.identifyNull(t);if(!r)return!1;const{destinationParentId:n,destinationIndex:s}=this.state.nodes.drag;return r===n&&s===null}onFocus(){const t=this.focusedNode||this.firstNode;t&&this.dispatch(En(t.id))}onBlur(){this.dispatch(v1())}onItemsRendered(t){this.visibleStartIndex=t.visibleStartIndex,this.visibleStopIndex=t.visibleStopIndex}get renderContainer(){return this.props.renderContainer||Sp}get renderRow(){return this.props.renderRow||f1}get renderNode(){return this.props.children||h1}get renderDragPreview(){return this.props.renderDragPreview||Zh}get renderCursor(){return this.props.renderCursor||d1}}function xt(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var zI=typeof Symbol=="function"&&Symbol.observable||"@@observable",ed=zI,ca=()=>Math.random().toString(36).substring(7).split("").join("."),VI={INIT:`@@redux/INIT${ca()}`,REPLACE:`@@redux/REPLACE${ca()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${ca()}`},pn=VI;function wp(e){if(typeof e!="object"||e===null)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function HI(e){if(e===void 0)return"undefined";if(e===null)return"null";const t=typeof e;switch(t){case"boolean":case"string":case"number":case"symbol":case"function":return t}if(Array.isArray(e))return"array";if(GI(e))return"date";if(WI(e))return"error";const r=QI(e);switch(r){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return r}return Object.prototype.toString.call(e).slice(8,-1).toLowerCase().replace(/\s/g,"")}function QI(e){return typeof e.constructor=="function"?e.constructor.name:null}function WI(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function GI(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Or(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=HI(e)),t}function xp(e,t,r){if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?xt(2):`Expected the root reducer to be a function. Instead, received: '${Or(e)}'`);if(typeof t=="function"&&typeof r=="function"||typeof r=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?xt(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof t=="function"&&typeof r>"u"&&(r=t,t=void 0),typeof r<"u"){if(typeof r!="function")throw new Error(process.env.NODE_ENV==="production"?xt(1):`Expected the enhancer to be a function. Instead, received: '${Or(r)}'`);return r(xp)(e,t)}let n=e,s=t,i=new Map,o=i,a=0,c=!1;function u(){o===i&&(o=new Map,i.forEach((v,y)=>{o.set(y,v)}))}function d(){if(c)throw new Error(process.env.NODE_ENV==="production"?xt(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return s}function f(v){if(typeof v!="function")throw new Error(process.env.NODE_ENV==="production"?xt(4):`Expected the listener to be a function. Instead, received: '${Or(v)}'`);if(c)throw new Error(process.env.NODE_ENV==="production"?xt(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let y=!0;u();const C=a++;return o.set(C,v),function(){if(y){if(c)throw new Error(process.env.NODE_ENV==="production"?xt(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");y=!1,u(),o.delete(C),i=null}}}function m(v){if(!wp(v))throw new Error(process.env.NODE_ENV==="production"?xt(7):`Actions must be plain objects. Instead, the actual type was: '${Or(v)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof v.type>"u")throw new Error(process.env.NODE_ENV==="production"?xt(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof v.type!="string")throw new Error(process.env.NODE_ENV==="production"?xt(17):`Action "type" property must be a string. Instead, the actual type was: '${Or(v.type)}'. Value was: '${v.type}' (stringified)`);if(c)throw new Error(process.env.NODE_ENV==="production"?xt(9):"Reducers may not dispatch actions.");try{c=!0,s=n(s,v)}finally{c=!1}return(i=o).forEach(C=>{C()}),v}function p(v){if(typeof v!="function")throw new Error(process.env.NODE_ENV==="production"?xt(10):`Expected the nextReducer to be a function. Instead, received: '${Or(v)}`);n=v,m({type:pn.REPLACE})}function b(){const v=f;return{subscribe(y){if(typeof y!="object"||y===null)throw new Error(process.env.NODE_ENV==="production"?xt(11):`Expected the observer to be an object. Instead, received: '${Or(y)}'`);function C(){const _=y;_.next&&_.next(d())}return C(),{unsubscribe:v(C)}},[ed](){return this}}}return m({type:pn.INIT}),{dispatch:m,subscribe:f,getState:d,replaceReducer:p,[ed]:b}}function td(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function KI(e,t,r,n){const s=Object.keys(t),i=r&&r.type===pn.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(s.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!wp(e))return`The ${i} has unexpected type of "${Or(e)}". Expected argument to be an object with the following keys: "${s.join('", "')}"`;const o=Object.keys(e).filter(a=>!t.hasOwnProperty(a)&&!n[a]);if(o.forEach(a=>{n[a]=!0}),!(r&&r.type===pn.REPLACE)&&o.length>0)return`Unexpected ${o.length>1?"keys":"key"} "${o.join('", "')}" found in ${i}. Expected to find one of the known reducer keys instead: "${s.join('", "')}". Unexpected keys will be ignored.`}function YI(e){Object.keys(e).forEach(t=>{const r=e[t];if(typeof r(void 0,{type:pn.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?xt(12):`The slice reducer for key "${t}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof r(void 0,{type:pn.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?xt(13):`The slice reducer for key "${t}" returned undefined when probed with a random type. Don't try to handle '${pn.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function rd(e){const t=Object.keys(e),r={};for(let o=0;o<t.length;o++){const a=t[o];process.env.NODE_ENV!=="production"&&typeof e[a]>"u"&&td(`No reducer provided for key "${a}"`),typeof e[a]=="function"&&(r[a]=e[a])}const n=Object.keys(r);let s;process.env.NODE_ENV!=="production"&&(s={});let i;try{YI(r)}catch(o){i=o}return function(a={},c){if(i)throw i;if(process.env.NODE_ENV!=="production"){const f=KI(a,r,c,s);f&&td(f)}let u=!1;const d={};for(let f=0;f<n.length;f++){const m=n[f],p=r[m],b=a[m],h=p(b,c);if(typeof h>"u"){const v=c&&c.type;throw new Error(process.env.NODE_ENV==="production"?xt(14):`When called with an action of type ${v?`"${String(v)}"`:"(unknown type)"}, the slice reducer for key "${m}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}d[m]=h,u=u||h!==b}return u=u||n.length!==Object.keys(a).length,u?d:a}}function ZI(e=rs().nodes.drag,t){switch(t.type){case"DND_DRAG_START":return Object.assign(Object.assign({},e),{id:t.id,selectedIds:t.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},e),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":return t.parentId!==e.destinationParentId||t.index!=e.destinationIndex?Object.assign(Object.assign({},e),{destinationParentId:t.parentId,destinationIndex:t.index}):e;default:return e}}const XI=rd({nodes:rd({focus:y1,edit:g1,open:b1,selection:C1,drag:ZI}),dnd:S1}),JI=rs();function eD({treeProps:e,imperativeHandle:t,children:r}){const n=g.useRef(null),s=g.useRef(null),i=g.useRef(xp(XI,rs(e))),o=t1.useSyncExternalStore(i.current.subscribe,i.current.getState,()=>JI),a=g.useMemo(()=>new Is(i.current,e,n,s),[]),c=g.useRef(0);return g.useMemo(()=>{c.current+=1,a.update(e)},Object.values(e)),g.useMemo(()=>{c.current+=1,a.update(a.props)},[o.nodes.open]),g.useImperativeHandle(t,()=>a),g.useEffect(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),g.useEffect(()=>{a.props.searchTerm||i.current.dispatch(Ya.clear(!0))},[a.props.searchTerm]),l.jsx(Ph.Provider,{value:a,children:l.jsx(Mh.Provider,{value:c.current,children:l.jsx(Rh.Provider,{value:o.nodes,children:l.jsx(Fh.Provider,{value:o.dnd,children:l.jsx(DA,Object.assign({},e.dndManager?{manager:e.dndManager}:{backend:e.dndBackend||LI,options:{rootElement:a.props.dndRootElement||void 0}},{children:r}))})})})})}function tD(){const e=Ft(),[,t]=fp(()=>({accept:"NODE",canDrop:(r,n)=>n.isOver({shallow:!0})?e.canDrop():!1,hover:(r,n)=>{if(!n.isOver({shallow:!0}))return;const s=n.getClientOffset();if(!e.listEl.current||!s)return;const{cursor:i,drop:o}=Cp({element:e.listEl.current,offset:s,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});o&&e.dispatch(ns.hovering(o.parentId,o.index)),n.canDrop()?i&&e.showCursor(i):e.hideCursor()},drop:(r,n)=>{if(!n.isOver({shallow:!0})||!n.canDrop())return null;e.drop()}}),[e]);t(e.listEl)}function rD(e){return tD(),e.children}function nD(){const t=Ft().props.renderContainer||Sp;return l.jsx(l.Fragment,{children:l.jsx(t,{})})}function sD(){const e=Ft(),{offset:t,mouse:r,item:n,isDragging:s}=rI(o=>({offset:o.getSourceClientOffset(),mouse:o.getClientOffset(),item:o.getItem(),isDragging:o.isDragging()})),i=e.props.renderDragPreview||Zh;return l.jsx(i,{offset:t,mouse:r,id:(n==null?void 0:n.id)||null,dragIds:(n==null?void 0:n.dragIds)||[],isDragging:s})}function iD(e={}){var t,r;const n=(t=e.idAccessor)!==null&&t!==void 0?t:"id",s=(r=e.childrenAccessor)!==null&&r!==void 0?r:"children";return{getId:typeof n=="function"?n:i=>i[n],getChildren:typeof s=="function"?s:i=>i[s],childrenKey:typeof s=="string"?s:"children"}}class oD{constructor(t,r={}){this.accessors=iD(r),this.root=aD(t,this.accessors)}get data(){var t,r;return(r=(t=this.root.children)===null||t===void 0?void 0:t.map(n=>n.data))!==null&&r!==void 0?r:[]}create(t){const r=t.parentId?this.find(t.parentId):this.root;if(!r)return null;r.addChild(t.data,t.index)}move(t){const r=this.find(t.id),n=t.parentId?this.find(t.parentId):this.root;!r||!n||(n.addChild(r.data,t.index),r.drop())}update(t){const r=this.find(t.id);r&&r.update(t.changes)}drop(t){const r=this.find(t.id);r&&r.drop()}find(t,r=this.root){if(!r)return null;if(r.id===t)return r;if(r.children){for(let n of r.children){const s=this.find(t,n);if(s)return s}return null}return null}}function aD(e,t){const r=new Tp({},null,t,"ROOT");return r.children=e.map(n=>Vl(n,r,t)),r}function Vl(e,t,r){const n=new Tp(e,t,r),s=r.getChildren(e);return s&&(n.children=s.map(i=>Vl(i,n,r))),n}class Tp{constructor(t,r,n,s){this.data=t,this.parent=r,this.accessors=n,this.id=s??n.getId(t)}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(t,r){var n,s;const i=Vl(t,this,this.accessors);this.children=(n=this.children)!==null&&n!==void 0?n:[],this.children.splice(r,0,i);const o=this.accessors.childrenKey,a=this.data;a[o]=(s=a[o])!==null&&s!==void 0?s:[],a[o].splice(r,0,t)}removeChild(t){var r,n;(r=this.children)===null||r===void 0||r.splice(t,1),(n=this.data[this.accessors.childrenKey])===null||n===void 0||n.splice(t,1)}update(t){if(this.hasParent()){const r=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),t),r),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let lD=0;function cD(e,t={}){const[r,n]=g.useState(e),s=t.idAccessor,i=t.childrenAccessor,o=g.useMemo(()=>new oD(r,{idAccessor:s,childrenAccessor:i}),[r,s,i]),a=b=>{for(const h of b.dragIds)o.move({id:h,parentId:b.parentId,index:b.index});n(o.data)},c=({name:b,id:h})=>{o.update({id:h,changes:{name:b}}),n(o.data)},u=typeof s=="string"?s:"id",d=typeof i=="string"?i:"children";return[r,{onMove:a,onRename:c,onCreate:({parentId:b,index:h,type:v})=>{if(typeof s=="function")throw new Error("React Arborist => initialData can't create nodes when idAccessor is a function: the generated id can't be written under a key the accessor reads. Use a string idAccessor, or the controlled `data` prop with your own onCreate.");if(v==="internal"&&typeof i=="function")throw new Error("React Arborist => initialData can't create folder nodes when childrenAccessor is a function: the new children array can't be written under a key the accessor reads. Use a string childrenAccessor, or the controlled `data` prop with your own onCreate.");const y={[u]:`simple-tree-id-${lD++}`,name:""};return v==="internal"&&(y[d]=[]),o.create({parentId:b,index:h,data:y}),n(o.data),y},onDelete:b=>{b.ids.forEach(h=>o.drop({id:h})),n(o.data)}}]}function uD(e){if(e.initialData&&e.data)throw new Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(e.initialData&&(e.onCreate||e.onDelete||e.onMove||e.onRename))throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
|
|
546
|
-
Use the data prop if you want to provide your own handlers.`);if(e.initialData){const[t,r]=cD(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function dD(e,t){const r=uD(e);return l.jsxs(eD,{treeProps:r,imperativeHandle:t,children:[l.jsx(rD,{children:l.jsx(nD,{})}),l.jsx(sD,{})]})}const fD=g.forwardRef(dD);function Hl(){return re(e=>{var n;const t=e.treeData[0];return(((n=t==null?void 0:t.metadata)==null?void 0:n.status)??(t==null?void 0:t.status)??"Draft").toLowerCase()==="draft"})}function hD(){return re(e=>{var s;if(!e.selectedNodeId)return!1;const t=(s=e.treeData[0])==null?void 0:s.id,r=i=>{var o;for(const a of i){if(a.id===e.selectedNodeId)return a;if((o=a.children)!=null&&o.length){const c=r(a.children);if(c)return c}}},n=r(e.treeData);return!!(n!=null&&n.isFolder)&&n.id!==t})}const nd={video:"#EA580C",pdf:"#DC2626",h5p:"#0D9488",scorm:"#7C3AED",audio:"#DB2777",quiz:"#16A34A",course:"#A85236",default:"#6B7280"},sd={video:"Video",pdf:"FileText",h5p:"Layers",scorm:"Package",audio:"Music",quiz:"HelpCircle",course:"BookOpen",default:"File"},id=["Course Assessment","eTextbook","Exam Question","Explanation Content","Learning Resource","Practice Question Set","SCORM Content","Teacher Resource"],pD=[{label:"All",value:"all"},{label:"Course Assessment",value:"Course Assessment"},{label:"eTextbook",value:"eTextbook"},{label:"Exam Question",value:"Exam Question"},{label:"Explanation Content",value:"Explanation Content"},{label:"Learning Resource",value:"Learning Resource"},{label:"Practice Question Set",value:"Practice Question Set"},{label:"SCORM Content",value:"SCORM Content"},{label:"Teacher Resource",value:"Teacher Resource"}];function mD(e){var r;if((r=e.metadata)!=null&&r.isAssessmentCourse)return"quiz";const t=[e.mimeType??"",e.primaryCategory??"",e.contentType??""].join(" ").toLowerCase();return t.includes("video")?"video":t.includes("pdf")||t.includes("epub")?"pdf":t.includes("h5p")?"h5p":t.includes("scorm")?"scorm":t.includes("audio")||t.includes("mp3")?"audio":t.includes("quiz")||t.includes("question")||t.includes("ecml")?"quiz":e.primaryCategory==="Course"?"course":"default"}function oi(e){const t=mD(e);return{key:t,color:nd[t]??nd.default,bgClass:`sbx-ct-sq--${t}`,badgeClass:`sbx-ct-badge--${t}`,tintClass:`sbx-ct-tint--${t}`,iconName:sd[t]??sd.default,label:t.charAt(0).toUpperCase()+t.slice(1)}}const gD="_row_nm332_1",vD="_grip_nm332_16",yD="_menuBtn_nm332_19",bD="_rowLp_nm332_23",CD="_selected_nm332_27",SD="_title_nm332_32",_D="_dropTarget_nm332_41",wD="_toggle_nm332_58",xD="_ctIcon_nm332_73",TD="_ctIconLp_nm332_85",ED="_folderIcon_nm332_89",AD="_rootIcon_nm332_94",kD="_titleLp_nm332_110",ID="_levelTitle_nm332_114",DD="_renameInput_nm332_119",LD="_dropHere_nm332_128",OD="_menuWrap_nm332_138",ND="_menu_nm332_19",jD="_dangerItem_nm332_190",it={row:gD,grip:vD,menuBtn:yD,rowLp:bD,selected:CD,title:SD,dropTarget:_D,toggle:wD,ctIcon:xD,ctIconLp:TD,folderIcon:ED,rootIcon:AD,titleLp:kD,levelTitle:ID,renameInput:DD,dropHere:LD,menuWrap:OD,menu:ND,dangerItem:jD},PD={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},RD=({node:e,style:t,dragHandle:r,editorMode:n})=>{const[s,i]=g.useState(!1),[o,a]=g.useState(!1),[c,u]=g.useState(e.data.name),d=g.useRef(null),f=oe(),m=K(N=>N.editorProfile),p=n==="edit",b=Hl(),h=oi(e.data),v=PD[h.key]??Wr,y=e.isSelected,C=e.level===0,S=e.data.isFolder??(e.children&&e.children.length>0),_=m.key==="learningPath",x=C?_?Oh:_y:S?_?Oy:Mf:v,T=_&&S&&!C&&!lt(e.data),D=e.level+1<=m.maxDepth,E=_?f.learningPath.addLevelButton:f.treeNode.addSubunitMenuItem,j=_?f.learningPath.addLevelButton:f.treeNode.addSiblingMenuItem;g.useEffect(()=>{if(!s)return;const N=R=>{var M;(M=d.current)!=null&&M.contains(R.target)||i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const P=g.useCallback(()=>{c.trim()&&e.submit(c.trim()),a(!1)},[c,e]),O=g.useCallback(N=>{N.key==="Enter"&&P(),N.key==="Escape"&&(u(e.data.name),a(!1))},[P,e.data.name]);return l.jsxs("div",{className:[it.row,_?it.rowLp:"",y?it.selected:"",e.state.isOver&&S?it.dropTarget:""].filter(Boolean).join(" "),style:t,onClick:()=>e.select(),"data-node-id":e.data.id,"data-droppable":S?"true":void 0,role:"treeitem","aria-selected":y,"aria-expanded":S?!e.isClosed:void 0,children:[p&&l.jsx("span",{ref:r,className:it.grip,"aria-hidden":"true",children:l.jsx(Bf,{size:14})}),l.jsx("button",{className:it.toggle,onClick:N=>{N.stopPropagation(),e.toggle()},"aria-label":e.isClosed?f.treeNode.expandAriaLabel:f.treeNode.collapseAriaLabel,style:{visibility:S?"visible":"hidden"},children:e.isClosed?l.jsx(xl,{size:14}):l.jsx(Cn,{size:14})}),l.jsx("span",{className:[it.ctIcon,C||S?it.folderIcon:h.bgClass,_?it.ctIconLp:"",C&&_?it.rootIcon:""].filter(Boolean).join(" "),"aria-hidden":"true",children:l.jsx(x,{size:C&&_?15:12})}),o?l.jsx("input",{className:it.renameInput,value:c,autoFocus:!0,onChange:N=>u(N.target.value),onBlur:P,onKeyDown:O,onClick:N=>N.stopPropagation()}):l.jsx("span",{className:[it.title,_?it.titleLp:"",T?it.levelTitle:""].filter(Boolean).join(" "),title:e.data.name,onDoubleClick:()=>p&&a(!0),children:e.data.name.length>25?`${e.data.name.slice(0,25)}...`:e.data.name}),e.state.isOver&&S&&l.jsx("span",{className:it.dropHere,"aria-hidden":"true",children:f.treeNode.dropHereLabel}),p&&l.jsxs("div",{className:it.menuWrap,ref:d,children:[l.jsx("button",{className:it.menuBtn,onClick:N=>{N.stopPropagation(),i(R=>!R)},"aria-label":f.treeNode.nodeOptionsAriaLabel,children:l.jsx(Rf,{size:14})}),s&&l.jsxs("div",{className:it.menu,role:"menu",children:[l.jsxs("button",{role:"menuitem",onClick:()=>{a(!0),i(!1)},children:[l.jsx(Ry,{size:13})," ",f.treeNode.renameMenuItem]}),S&&b&&D&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.id}),i(!1)},children:[l.jsx(Ff,{size:13})," ",E]}),e.data.parent&&b&&!_&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.data.parent}),i(!1)},children:[l.jsx(Sn,{size:13})," ",j]}),!C&&l.jsxs("button",{role:"menuitem",className:it.dangerItem,onClick:()=>{e.tree.delete(e.id),i(!1)},children:[l.jsx(So,{size:13})," ",f.treeNode.deleteMenuItem]})]})]})]})};async function FD(e,t){var i,o;const n=((i=(await Fe.post(`/action/content/v3/upload/url/${e}?type=hierarchy`,{request:{content:{fileName:t}}})).data)==null?void 0:i.result)??{},s=((o=n.content)==null?void 0:o.preSignedURL)??n.pre_signed_url??n.preSignedUrl;if(!s)throw new Error("Could not obtain an upload URL");return s}async function MD(e,t){const r=await fetch(e,{method:"PUT",headers:{"x-ms-blob-type":"BlockBlob","Content-Type":"text/csv"},body:t});if(!r.ok)throw new Error(`Blob upload failed (${r.status})`);return e.split("?")[0]}async function BD(e,t){var a;const r=await FD(e,t.name),n=await MD(r,t),s=new FormData;return s.append("fileUrl",n),s.append("mimeType",t.type||"text/csv"),{processId:(((a=(await Fe.post(`/action/collection/v1/import/${e}`,s)).data)==null?void 0:a.result)??{}).processId??""}}async function qD(e){var r;return((r=(await Fe.get(`/action/collection/v1/import/status/${e}`)).data)==null?void 0:r.result)??{status:"PENDING"}}async function Ep(e){var n,s,i;const r=(i=(s=(n=(await Fe.get(`/action/collection/v1/export/${e}`)).data)==null?void 0:n.result)==null?void 0:s.collection)==null?void 0:i.tocUrl;if(!r)throw new Error("No export URL returned");return r}async function $D(e){return Ep(e)}const UD="_container_jw2be_1",zD="_header_jw2be_13",VD="_title_jw2be_22",HD="_closeBtn_jw2be_29",QD="_body_jw2be_45",WD="_dropZone_jw2be_54",GD="_dragOver_jw2be_67",KD="_hasFile_jw2be_72",YD="_hiddenInput_jw2be_78",ZD="_fileInfo_jw2be_82",XD="_fileIcon_jw2be_89",JD="_fileName_jw2be_93",eL="_fileSize_jw2be_100",tL="_dropHint_jw2be_105",rL="_dropIcon_jw2be_112",nL="_dropText_jw2be_117",sL="_dropSubtext_jw2be_124",iL="_sampleLink_jw2be_130",oL="_statusBar_jw2be_145",aL="_status_uploading_jw2be_154",lL="_status_processing_jw2be_154",cL="_status_done_jw2be_159",uL="_status_error_jw2be_164",dL="_successDetail_jw2be_170",fL="_spinner_jw2be_175",hL="_spin_jw2be_175",pL="_errorMsg_jw2be_191",mL="_failedSection_jw2be_197",gL="_failedTitle_jw2be_203",vL="_tableWrap_jw2be_213",yL="_failedTable_jw2be_219",bL="_reasonCell_jw2be_244",CL="_footer_jw2be_248",Ue={container:UD,header:zD,title:VD,closeBtn:HD,body:QD,dropZone:WD,dragOver:GD,hasFile:KD,hiddenInput:YD,fileInfo:ZD,fileIcon:XD,fileName:JD,fileSize:eL,dropHint:tL,dropIcon:rL,dropText:nL,dropSubtext:sL,sampleLink:iL,statusBar:oL,status_uploading:aL,status_processing:lL,status_done:cL,status_error:uL,successDetail:dL,spinner:fL,spin:hL,errorMsg:pL,failedSection:mL,failedTitle:gL,tableWrap:vL,failedTable:yL,reasonCell:bL,footer:CL},SL=({contentId:e,onComplete:t,onClose:r,mode:n="create"})=>{const s=oe(),[i,o]=g.useState(null),[a,c]=g.useState(!1),[u,d]=g.useState("idle"),[f,m]=g.useState(""),[p,b]=g.useState([]),[h,v]=g.useState(null),y=g.useRef(null),C=g.useRef(null),S=g.useCallback(()=>{C.current!==null&&(clearInterval(C.current),C.current=null)},[]);g.useEffect(()=>()=>S(),[S]);const _=O=>O.name.toLowerCase().endsWith(".csv")?O.size>50*1024*1024?(m(s.csvUpload.fileTooLarge),!1):!0:(m(s.csvUpload.invalidFileType),!1),x=g.useCallback(O=>{m(""),b([]),v(null),d("idle"),_(O)&&o(O)},[]),T=g.useCallback(O=>{O.preventDefault(),c(!1);const N=O.dataTransfer.files[0];N&&x(N)},[x]),D=g.useCallback(O=>{var R;const N=(R=O.target.files)==null?void 0:R[0];N&&x(N),O.target.value=""},[x]),E=g.useCallback(async()=>{try{const O=await $D(e),N=document.createElement("a");N.href=O,N.download="sample_hierarchy.csv",N.target="_blank",N.click()}catch{m(s.csvUpload.downloadSampleFailed)}},[e,s.csvUpload.downloadSampleFailed]),j=g.useCallback(async()=>{if(i){d("uploading"),m(""),b([]);try{const{processId:O}=await BD(e,i);if(!O){d("done"),v(null),setTimeout(t,1500);return}d("processing"),C.current=setInterval(async()=>{try{const N=await qD(O);N.status==="COMPLETED"?(S(),d("done"),v(N.successCount??null),N.failedRecords&&N.failedRecords.length>0?b(N.failedRecords):setTimeout(t,1500)):N.status==="FAILED"&&(S(),d("error"),m(s.csvUpload.processingFailed),N.failedRecords&&b(N.failedRecords))}catch{S(),d("error"),m(s.csvUpload.connectionLost)}},2e3)}catch{d("error"),m(s.csvUpload.uploadFailed)}}},[e,i,t,S,s.csvUpload.processingFailed,s.csvUpload.connectionLost,s.csvUpload.uploadFailed]),P={idle:"",uploading:s.csvUpload.statusUploading,processing:s.csvUpload.statusProcessing,done:s.csvUpload.statusDone,error:s.csvUpload.statusError};return l.jsxs("div",{className:Ue.container,children:[l.jsxs("div",{className:Ue.header,children:[l.jsx("h2",{className:Ue.title,children:n==="update"?s.csvUpload.titleUpdate:s.csvUpload.titleCreate}),l.jsx("button",{className:Ue.closeBtn,onClick:r,"aria-label":s.csvUpload.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Ue.body,children:[l.jsxs("div",{className:`${Ue.dropZone} ${a?Ue.dragOver:""} ${i?Ue.hasFile:""}`,onDragEnter:O=>{O.preventDefault(),c(!0)},onDragOver:O=>{O.preventDefault(),c(!0)},onDragLeave:O=>{O.preventDefault(),c(!1)},onDrop:T,onClick:()=>{var O;return(O=y.current)==null?void 0:O.click()},role:"button",tabIndex:0,"aria-label":s.csvUpload.dropZoneAriaLabel,onKeyDown:O=>{var N;return O.key==="Enter"&&((N=y.current)==null?void 0:N.click())},children:[l.jsx("input",{ref:y,type:"file",accept:".csv",className:Ue.hiddenInput,onChange:D,"aria-hidden":"true"}),i?l.jsxs("div",{className:Ue.fileInfo,children:[l.jsx(Js,{size:24,className:Ue.fileIcon}),l.jsx("span",{className:Ue.fileName,children:i.name}),l.jsxs("span",{className:Ue.fileSize,children:["(",(i.size/1024).toFixed(1)," KB)"]})]}):l.jsxs("div",{className:Ue.dropHint,children:[l.jsx(Ma,{size:32,className:Ue.dropIcon}),l.jsx("p",{className:Ue.dropText,children:s.csvUpload.dropText}),l.jsx("p",{className:Ue.dropSubtext,children:s.csvUpload.dropSubtext})]})]}),l.jsx("button",{className:Ue.sampleLink,onClick:E,type:"button",children:s.csvUpload.downloadSample}),u!=="idle"&&l.jsxs("div",{className:`${Ue.statusBar} ${Ue[`status_${u}`]}`,role:"status","aria-live":"polite",children:[u==="processing"&&l.jsx("span",{className:Ue.spinner,"aria-hidden":"true"}),P[u],u==="done"&&h!==null&&l.jsx("span",{className:Ue.successDetail,children:s.csvUpload.itemsImportedSuffix.replace("{count}",String(h))})]}),f&&l.jsx("p",{className:Ue.errorMsg,role:"alert",children:f}),p.length>0&&l.jsxs("div",{className:Ue.failedSection,children:[l.jsx("h4",{className:Ue.failedTitle,children:s.csvUpload.failedRowsTitle.replace("{count}",String(p.length))}),l.jsx("div",{className:Ue.tableWrap,children:l.jsxs("table",{className:Ue.failedTable,children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:s.csvUpload.rowHeader}),l.jsx("th",{children:s.csvUpload.nameHeader}),l.jsx("th",{children:s.csvUpload.reasonHeader})]})}),l.jsx("tbody",{children:p.map((O,N)=>l.jsxs("tr",{children:[l.jsx("td",{children:O.rowNumber??N+1}),l.jsx("td",{children:O.name??"—"}),l.jsx("td",{className:Ue.reasonCell,children:O.reason??s.csvUpload.unknownError})]},N))})]})})]})]}),l.jsxs("div",{className:Ue.footer,children:[l.jsx(Re,{variant:"ghost",onClick:r,disabled:u==="uploading"||u==="processing",children:s.csvUpload.cancel}),l.jsx(Re,{variant:"primary",isLoading:u==="uploading"||u==="processing",disabled:!i||u==="done",onClick:j,children:u==="done"?s.csvUpload.uploaded:s.csvUpload.upload})]})]})};function Ql(){var v,y,C,S,_,x,T;const e=oe(),t=re(D=>D.treeData),r=re(D=>D.treeCache),n=re(D=>D.deleteNode),s=yr(D=>D.activeAssessmentSlot),i=yr(D=>D.setActiveAssessmentSlot),o=yr(D=>D.openModal),a=((v=t[0])==null?void 0:v.children)??[],c=a[0],u=a.length>1?a[a.length-1]:void 0,d=lt(c),f=lt(u),m=t[0],p=m?((y=r[m.id])==null?void 0:y.policy)??((C=m.metadata)==null?void 0:C.policy):void 0,b=!!p&&Ah.has(p),h=D=>{const E=D==="pre"?c:u;if(!E)return;const j=D==="pre"&&b?e.learningPath.deletePriorAssessmentConfirm:e.learningPath.deleteAssessmentSlotConfirm;o("confirmDelete",{message:j,onConfirm:()=>n(E.id)})};return{pre:{level:c,filled:d,courseName:d?(_=(S=c==null?void 0:c.children)==null?void 0:S[0])==null?void 0:_.name:void 0,required:b},post:{level:u,filled:f,courseName:f?(T=(x=u==null?void 0:u.children)==null?void 0:x[0])==null?void 0:T.name:void 0,required:!1},activeAssessmentSlot:s,setActiveAssessmentSlot:i,deleteSlot:h}}const _L="_container_2qylm_1",wL="_header_2qylm_8",xL="_sectionLabel_2qylm_18",TL="_headerActions_2qylm_26",EL="_iconBtn_2qylm_33",AL="_menuWrap_2qylm_51",kL="_dropdownMenu_2qylm_55",IL="_treeWrapper_2qylm_87",DL="_csvModal_2qylm_103",LL="_footer_2qylm_113",tr={container:_L,header:wL,sectionLabel:xL,headerActions:TL,iconBtn:EL,menuWrap:AL,dropdownMenu:kL,treeWrapper:IL,csvModal:DL,footer:LL},OL=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{var Te;const n=oe(),s=g.useRef(null),i=g.useRef(null),o=g.useRef(null),[a,c]=g.useState(400),[u,d]=g.useState(!1),[f,m]=g.useState(!1),[p,b]=g.useState("create"),{treeData:h,selectedNodeId:v,selectNode:y,addNode:C,deleteNode:S,getNodeById:_,reorderChildren:x,moveNode:T,setTreeData:D}=re(),E=yr(Y=>Y.openModal),j=K(Y=>Y.editorProfile),P=j.key==="learningPath",O=e==="edit",N=Hl(),R=O&&N,M=P?n.learningPath.addLevelButton:n.outlineTree.addUnitButton,$=j.maxDepth>1,ee=(((Te=h[0])==null?void 0:Te.children)??[]).some(Y=>Y.isFolder),{pre:H,post:te,deleteSlot:de}=Ql(),{level:fe}=H,{level:pe}=te,ae=K(Y=>{var ce,Q,Ce,qe;return((Q=(ce=Y.editorConfig)==null?void 0:ce.context)==null?void 0:Q.contentId)??((qe=(Ce=Y.editorConfig)==null?void 0:Ce.context)==null?void 0:qe.identifier)??""}),we=K(Y=>{var Q,Ce;const ce=(Ce=(Q=Y.categoryMeta)==null?void 0:Q.sourcingSettings)==null?void 0:Ce.collection;return(ce==null?void 0:ce.enableBulkUpload)!==!1}),ye=j.features.csvUpload&&we;g.useEffect(()=>{const Y=i.current;if(!Y)return;const ce=new ResizeObserver(()=>{c(Y.clientHeight||400)});return ce.observe(Y),c(Y.clientHeight||400),()=>ce.disconnect()},[]),g.useEffect(()=>{if(!u)return;const Y=ce=>{var Q;(Q=o.current)!=null&&Q.contains(ce.target)||d(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[u]);const F=g.useCallback(Y=>{Y.length>0&&y(Y[0].data.id)},[y]),B=g.useCallback(({parentId:Y,index:ce,dragIds:Q})=>{if(!Y)return;const Ce=Q[0],qe=il(h,Ce);if(!qe)return;const et=qe.parent;if(et===Y){const $e=il(h,Y);if(!($e!=null&&$e.children))return;const We=$e.children.findIndex(tt=>tt.id===Ce);if(We<0)return;x(Y,We,ce>We?ce-1:ce)}else T(Ce,et??"",Y)},[h,x,T]),Z=g.useCallback(({ids:Y})=>{if(!P){for(const Q of Y)S(Q);return}if(Y.length===1){const Q=Y[0];if((fe==null?void 0:fe.id)===Q){de("pre");return}if((pe==null?void 0:pe.id)===Q){de("post");return}const Ce=_(Q),qe=Ce!=null&&Ce.isFolder?n.learningPath.deleteLevelConfirm.replace("{name}",Ce.name):n.learningPath.deleteCourseConfirm;E("confirmDelete",{message:qe,onConfirm:()=>S(Q)});return}const ce=n.learningPath.deleteMultipleConfirm.replace("{count}",String(Y.length));E("confirmDelete",{message:ce,onConfirm:()=>{for(const Q of Y)S(Q)}})},[S,de,P,fe,pe,_,E,n]),he=g.useCallback(({parentId:Y})=>{var Ce;const ce=Y??((Ce=h[0])==null?void 0:Ce.id)??"";if(!ce)return{id:crypto.randomUUID()};const Q=C(ce,"unit");return Q?{id:Q}:(Se.error(n.outlineTree.maxDepthReachedToast),{id:crypto.randomUUID()})},[C,h,n]),be=g.useCallback(()=>{var ce;const Y=(ce=h[0])==null?void 0:ce.id;Y&&(C(Y,"unit")||Se.error(n.outlineTree.maxDepthReachedToast))},[h,C,n]),me=g.useCallback(()=>{v&&(C(v,"subunit")||Se.error(n.outlineTree.maxDepthReachedToast))},[v,C,n]),le=g.useCallback(async()=>{if(d(!1),!!ae)try{const Y=await Ep(ae),ce=await fetch(Y).then(qe=>qe.blob()),Q=URL.createObjectURL(ce),Ce=document.createElement("a");Ce.href=Q,Ce.download=`${ae}-folders.csv`,Ce.style.display="none",document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(Q)}catch{Se.error(n.outlineTree.downloadCsvFailedToast)}},[ae,n]),ve=g.useCallback(async()=>{if(m(!1),!!ae)try{const{rootNode:Y}=await yh(ae);D([Y]),Se.success(n.outlineTree.outlineRefreshedToast)}catch{Se.error(n.outlineTree.outlineRefreshFailedToast)}},[ae,D,n]);return l.jsxs("div",{className:tr.container,children:[l.jsxs("div",{className:tr.header,children:[P&&l.jsx("span",{className:tr.sectionLabel,children:n.learningPath.pathStructureLabel}),l.jsxs("div",{className:tr.headerActions,children:[O&&ye&&l.jsxs("div",{className:tr.menuWrap,ref:o,children:[l.jsx("button",{type:"button",className:tr.iconBtn,onClick:()=>d(Y=>!Y),"aria-label":n.outlineTree.moreOptionsAriaLabel,title:n.outlineTree.moreOptionsTitle,"aria-haspopup":"true","aria-expanded":u,children:l.jsx(Rf,{size:15})}),u&&l.jsxs("div",{className:tr.dropdownMenu,role:"menu",children:[l.jsx("button",{role:"menuitem",type:"button",disabled:ee,title:ee?n.outlineTree.foldersExistTitle:void 0,onClick:()=>{d(!1),b("create"),m(!0)},children:n.outlineTree.createFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!ee,title:ee?void 0:n.outlineTree.noFoldersYetTitle,onClick:le,children:n.outlineTree.downloadFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!ee,title:ee?void 0:n.outlineTree.noFoldersYetTitle,onClick:()=>{d(!1),b("update"),m(!0)},children:n.outlineTree.updateFoldersCsvButton})]})]}),r&&l.jsx("button",{type:"button",className:tr.iconBtn,onClick:r,"aria-label":t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,title:t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,children:t?l.jsx(jy,{size:15}):l.jsx(Ny,{size:15})})]})]}),l.jsx("div",{className:tr.treeWrapper,ref:i,children:l.jsx(fD,{ref:s,data:h,idAccessor:"id",childrenAccessor:"children",onSelect:F,onMove:O?B:void 0,onDelete:O?Z:void 0,onCreate:O?he:void 0,disableEdit:!O,disableDrop:!O,selection:v??void 0,rowHeight:40,indent:20,paddingBottom:16,height:a,width:"100%",children:Y=>l.jsx(RD,{...Y,editorMode:e})})}),O&&l.jsxs("div",{className:tr.footer,children:[l.jsxs(Re,{variant:"ghost",size:"sm",onClick:be,disabled:!R,children:[l.jsx(Sn,{size:14})," ",M]}),$&&l.jsxs(Re,{variant:"ghost",size:"sm",onClick:me,disabled:!R||!v,children:[l.jsx(Ff,{size:14})," ",n.outlineTree.addSubunitButton]})]}),f&&l.jsx("div",{className:tr.csvModal,children:l.jsx(SL,{contentId:ae,mode:p,onComplete:ve,onClose:()=>m(!1)})})]})};function il(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=il(r.children,t);if(n)return n}}}const NL="_breadcrumb_zd1aj_1",jL="_crumb_zd1aj_10",PL="_sep_zd1aj_26",RL="_current_zd1aj_31",ys={breadcrumb:NL,crumb:jL,sep:PL,current:RL},FL=({crumbs:e})=>{const t=re(n=>n.selectNode),r=oe();return e.length?l.jsxs("nav",{className:ys.breadcrumb,"aria-label":r.breadcrumb.nodePathAriaLabel,children:[l.jsx("button",{className:ys.crumb,onClick:()=>t(e[0].id),"aria-label":r.breadcrumb.homeAriaLabel,children:l.jsx(Dy,{size:13})}),e.map((n,s)=>l.jsxs(g.Fragment,{children:[l.jsx(xl,{size:13,className:ys.sep}),s<e.length-1?l.jsx("button",{className:ys.crumb,onClick:()=>t(n.id),children:n.name}):l.jsx("span",{className:ys.current,children:n.name})]},n.id))]}):null},ML="_tabBar_qhks1_1",BL="_tab_qhks1_1",qL="_active_qhks1_29",$L="_error_qhks1_35",UL="_errorDot_qhks1_39",bs={tabBar:ML,tab:BL,active:qL,error:$L,errorDot:UL},zL=({activeTab:e,onChange:t,errorTabs:r=[],visibleTabs:n})=>{const s=oe(),i=[{id:"details",label:s.tabBar.detailsTab},{id:"audience",label:s.tabBar.audienceCurriculumTab},{id:"licensing",label:s.tabBar.licensingTab}],o=n?i.filter(a=>n.includes(a.id)):i;return l.jsx("div",{className:bs.tabBar,role:"tablist","aria-label":s.tabBar.metadataSectionsAriaLabel,children:o.map(a=>l.jsxs("button",{role:"tab","aria-selected":e===a.id,"aria-controls":`panel-${a.id}`,className:[bs.tab,e===a.id?bs.active:"",r.includes(a.id)?bs.error:""].join(" "),onClick:()=>t(a.id),children:[a.label,r.includes(a.id)&&l.jsx("span",{className:bs.errorDot,"aria-label":s.tabBar.hasErrorsAriaLabel})]},a.id))})};var ai=e=>e.type==="checkbox",tn=e=>e instanceof Date,vt=e=>e==null;const Ap=e=>typeof e=="object";var Ze=e=>!vt(e)&&!Array.isArray(e)&&Ap(e)&&!tn(e),ol=e=>Ze(e)&&e.target?ai(e.target)?e.target.checked:e.target.value:e,kp=(e,t)=>t.split(".").some((r,n,s)=>!isNaN(Number(r))&&e.has(s.slice(0,n).join("."))),Ip=e=>{const t=e.constructor&&e.constructor.prototype;return Ze(t)&&t.hasOwnProperty("isPrototypeOf")},No=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Xe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(No&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ze(e)&&Ip(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=Xe(e[s]));return n}const jr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},sr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},rr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ua="form",Dp="root",Lp=["__proto__","constructor","prototype"];var li=e=>/^\w*$/.test(e),Qe=e=>e===void 0,jo=e=>e.split(/[.[\]'"]/g).filter(Boolean),G=(e,t,r)=>{if(!t||!Ze(e))return r;const n=li(t)?[t]:jo(t);if(n.some(i=>Lp.includes(i)))return r;const s=n.reduce((i,o)=>vt(i)?void 0:i[o],e);return Qe(s)||s===e?Qe(e[t])?r:e[t]:s},Ut=e=>typeof e=="boolean",Et=e=>typeof e=="function",Ve=(e,t,r)=>{let n=-1;const s=li(t)?[t]:jo(t),i=s.length,o=i-1;for(;++n<i;){const a=s[n];let c=r;if(n!==o){const u=e[a];c=Ze(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(Lp.includes(a))return;e[a]=c,e=e[a]}};const Wl=g.createContext(null);Wl.displayName="HookFormControlContext";const Gl=()=>g.useContext(Wl);var Op=(e,t,r,n=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==sr.all&&(t._proxyFormState[o]=!n||sr.all),r&&(r[o]=!0),e[o]}});return s};const Kl=No?g.useLayoutEffect:g.useEffect;function VL(e){const t=Gl(),{control:r=t,disabled:n,name:s,exact:i}=e||{},[o,a]=g.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=g.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Kl(()=>r._subscribe({name:s,formState:c.current,exact:i,callback:u=>{!n&&a({...r._formState,...u,defaultValues:r._defaultValues})}}),[s,n,i]),g.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),g.useMemo(()=>Op(o,r,c.current,!1),[o,r])}var At=e=>typeof e=="string",al=(e,t,r,n,s)=>At(e)?(n&&t.watch.add(e),G(r,e,s)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),G(r,i))):(n&&(t.watchAll=!0),r),ll=e=>vt(e)||!Ap(e);const od=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ip(e);function zt(e,t,r=new WeakMap){if(e===t)return!0;if(ll(e)||ll(t))return Object.is(e,t);if(tn(e)&&tn(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;if(od(e,n)||od(t,s))return Object.is(e,t);const i=r.get(e);if(i&&i.has(t))return!0;i?i.add(t):r.set(e,new WeakSet([t]));for(const o of n){const a=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(tn(a)&&tn(c)||(Ze(a)||Array.isArray(a))&&(Ze(c)||Array.isArray(c))?!zt(a,c,r):!Object.is(a,c))return!1}}return!0}function HL(e){const t=Gl(),{control:r=t,name:n,defaultValue:s,disabled:i,exact:o,compute:a}=e||{},c=g.useRef(s),u=g.useRef(a),d=g.useRef(void 0),f=g.useRef(r),m=g.useRef(n);u.current=a;const[p,b]=g.useState(()=>{const _=r._getWatch(n,c.current);return u.current?u.current(_):_}),h=g.useCallback(_=>{const x=al(n,r._names,_||r._formValues,!1,c.current);return u.current?u.current(x):x},[r._formValues,r._names,n]),v=g.useCallback(_=>{if(!i){const x=al(n,r._names,_||r._formValues,!1,c.current);if(u.current){const T=u.current(x);zt(T,d.current)||(b(T),d.current=T)}else b(x)}},[r._formValues,r._names,i,n]);Kl(()=>((f.current!==r||!zt(m.current,n))&&(f.current=r,m.current=n,v()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:_=>{v(_.values)}})),[r,o,n,v]),g.useEffect(()=>r._removeUnmounted());const y=f.current!==r,C=m.current,S=g.useMemo(()=>{if(i)return null;const _=!y&&!zt(C,n);return y||_?h():null},[i,y,n,C,h]);return S!==null?S:p}function ci(e){const t=Gl(),{name:r,disabled:n,control:s=t,shouldUnregister:i,defaultValue:o,exact:a=!0}=e,c=kp(s._names.array,r),u=g.useMemo(()=>G(s._formValues,r,G(s._defaultValues,r,o)),[s,r,o]),d=HL({control:s,name:r,defaultValue:u,exact:a}),f=VL({control:s,name:r,exact:a}),m=g.useRef(e),p=g.useRef(null),b=g.useRef(s.register(r,{...e.rules,value:d,...Ut(e.disabled)?{disabled:e.disabled}:{}}));m.current=e;const h=g.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!G(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!G(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!G(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!G(f.validatingFields,r)},error:{enumerable:!0,get:()=>G(f.errors,r)}}),[f,r]),v=g.useCallback(_=>{const x=ol(_);return G(s._fields,r)||(b.current=s.register(r,{...m.current.rules,value:x})),b.current.onChange({target:{value:ol(_),name:r},type:jr.CHANGE})},[r,s]),y=g.useCallback(()=>b.current.onBlur({target:{value:G(s._formValues,r),name:r},type:jr.BLUR}),[r,s._formValues]),C=g.useCallback(_=>{_&&(p.current={focus:()=>Et(_.focus)&&_.focus(),select:()=>Et(_.select)&&_.select(),setCustomValidity:T=>Et(_.setCustomValidity)&&_.setCustomValidity(T),reportValidity:()=>Et(_.reportValidity)&&_.reportValidity()});const x=G(s._fields,r);x&&x._f&&_&&(x._f.ref=p.current)},[s._fields,r]),S=g.useMemo(()=>({name:r,value:d,...Ut(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:v,onBlur:y,ref:C}),[r,n,f.disabled,v,y,C,d]);return g.useEffect(()=>{const _=s._options.shouldUnregister||i;s.register(r,{...m.current.rules,...Ut(m.current.disabled)?{disabled:m.current.disabled}:{}});const x=(T,D)=>{const E=G(s._fields,T);E&&E._f&&(E._f.mount=D)};if(x(r,!0),_){const T=Xe(G(i?s._defaultValues:s._options.values||s._defaultValues,r,G(s._options.defaultValues,r,m.current.defaultValue)));Ve(s._defaultValues,r,T),Qe(G(s._formValues,r))&&Ve(s._formValues,r,T)}if(!c&&s.register(r),p.current){const T=G(s._fields,r);T&&T._f&&(T._f.ref=p.current)}return()=>{(c?_&&!s._state.action:_)?s.unregister(r):x(r,!1)}},[r,s,c,i]),g.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),g.useMemo(()=>({field:S,formState:f,fieldState:h}),[S,f,h])}const QL=e=>e.render(ci(e)),Yl=g.createContext(null);Yl.displayName="HookFormContext";const Jt=()=>g.useContext(Yl),WL=({children:e,watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:m,unregister:p,control:b,register:h,setFocus:v,subscribe:y})=>{const C=g.useMemo(()=>({watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:m,unregister:p,control:b,register:h,setFocus:v,subscribe:y}),[i,b,u,n,r,m,h,f,d,s,v,o,a,y,c,p,t]);return g.createElement(Yl.Provider,{value:C},g.createElement(Wl.Provider,{value:C.control},e))};var GL=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},Np=e=>Array.isArray(e)?e.filter(Boolean):[],$i=e=>Array.isArray(e)?e:[e],ad=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function jp(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],i=t[n];if(s&&Ze(s)&&i){const o=jp(s,i);Ze(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var ft=e=>Ze(e)&&!Object.keys(e).length,Zl=e=>e.type==="file",ro=e=>{if(!No)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Pp=e=>e.type==="select-multiple",Xl=e=>e.type==="radio",KL=e=>Xl(e)||ai(e),da=e=>ro(e)&&e.isConnected;function YL(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if(vt(e)){e=void 0;break}e=e[t[n]],n++}return e}function ZL(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function nt(e,t){if(At(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:li(t)?[t]:jo(t),n=r.length===1?e:YL(e,r),s=r.length-1,i=r[s];return n&&delete n[i],s!==0&&(Ze(n)&&ft(n)||Array.isArray(n)&&ZL(n))&&nt(e,r.slice(0,-1)),e}var XL=e=>{for(const t in e)if(Et(e[t]))return!0;return!1};function Rp(e){return Array.isArray(e)||Ze(e)&&!XL(e)}function cl(e,t={}){for(const r in e){const n=e[r];Rp(n)?(t[r]=Array.isArray(n)?[]:{},cl(n,t[r])):Qe(n)||(t[r]=!0)}return t}function ul(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>ul(r));return t.some(r=>r!==void 0)?t:void 0}if(Ze(e)){const t={};for(const r in e){const n=ul(e[r]);Qe(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function Xr(e,t,r){r||(r=cl(t));for(const n in e){const s=e[n];if(Rp(s))Qe(t)||ll(r[n])?r[n]=cl(s,Array.isArray(s)?[]:{}):Xr(s,vt(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!zt(s,i)}}return ul(r)||{}}const ld={value:!1,isValid:!1},cd={value:!0,isValid:!0};var Fp=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?cd:{value:e[0].value,isValid:!0}:cd:ld}return ld},Mp=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Qe(e)?e:t?e===""?NaN:e&&+e:r&&At(e)?new Date(e):n?n(e):e;const ud={isValid:!1,value:null};var Bp=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,ud):ud;function dd(e){const t=e.ref;return Zl(t)?t.files:Xl(t)?Bp(e.refs).value:Pp(t)?[...t.selectedOptions].map(({value:r})=>r):ai(t)?Fp(e.refs).value:Mp(Qe(t.value)?e.ref.value:t.value,e)}var JL=(e,t,r,n)=>{const s={};for(const i of e){const o=G(t,i);o&&Ve(s,i,o._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},no=e=>e instanceof RegExp,Cs=e=>Qe(e)?e:no(e)?e.source:Ze(e)?no(e.value)?e.value.source:e.value:e,fd=e=>({isOnSubmit:!e||e===sr.onSubmit,isOnBlur:e===sr.onBlur,isOnChange:e===sr.onChange,isOnAll:e===sr.all,isOnTouch:e===sr.onTouched});const hd="AsyncFunction";var eO=e=>!!e&&!!e.validate&&!!(Et(e.validate)&&e.validate.constructor.name===hd||Ze(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===hd)),tO=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),fa=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(`${n}.`)));const Ds=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const i=G(e,s);if(i){const{_f:o,...a}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(Ds(a,t))break}else if(Ze(a)&&Ds(a,t))break}}};function pd(e,t,r){const n=G(e,r);if(n||li(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const i=s.join("."),o=G(t,i),a=G(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:r}}var rO=(e,t,r,n)=>{r(e);const{name:s,...i}=e;return ft(i)||n&&Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!n||sr.all))},nO=(e,t,r)=>!e||!t||e===t||$i(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),sO=(e,t,r,n,s)=>s.isOnAll?!1:!r&&s.isOnTouch?!(t||e):(r?n.isOnBlur:s.isOnBlur)?!e:(r?n.isOnChange:s.isOnChange)?e:!0,iO=(e,t)=>!Np(G(e,t)).length&&nt(e,t),md=(e,t,r)=>{const n=G(e,r),s=Array.isArray(n)?n:[];return Ve(s,Dp,t[r]),Ve(e,r,s),e};function gd(e,t,r="validate"){if(At(e)||Array.isArray(e)&&e.every(At)||Ut(e)&&!e)return{type:r,message:At(e)?e:"",ref:t}}var On=e=>Ze(e)&&!no(e)?e:{value:e,message:""},vd=async(e,t,r,n,s,i)=>{const{ref:o,refs:a,required:c,maxLength:u,minLength:d,min:f,max:m,pattern:p,validate:b,name:h,valueAsNumber:v,mount:y}=e._f,C=G(r,h);if(!y||t.has(h))return{};const S=a?a[0]:o,_=N=>{if(s&&S.reportValidity){const R=Ut(N)?"":N||"";a?a.forEach(M=>M.setCustomValidity(R)):S.setCustomValidity(R),S.reportValidity()}},x={},T=Xl(o),D=ai(o),E=T||D,j=(v||Zl(o))&&Qe(o.value)&&Qe(C)||ro(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,P=GL.bind(null,h,n,x),O=(N,R,M,$=rr.maxLength,ee=rr.minLength)=>{const H=N?R:M;x[h]={type:N?$:ee,message:H,ref:o,...P(N?$:ee,H)}};if(i?!Array.isArray(C)||!C.length:c&&(!E&&(j||vt(C))||Ut(C)&&!C||D&&!Fp(a).isValid||T&&!Bp(a).isValid)){const{value:N,message:R}=At(c)?{value:!!c,message:c}:On(c);if(N&&(x[h]={type:rr.required,message:R,ref:S,...P(rr.required,R)},!n))return _(R),x}if(!j&&(!vt(f)||!vt(m))){let N,R;const M=On(m),$=On(f);if(!vt(C)&&!isNaN(C)){const ee=o.valueAsNumber||C&&+C;vt(M.value)||(N=ee>M.value),vt($.value)||(R=ee<$.value)}else{const ee=o.valueAsDate||new Date(C),H=fe=>new Date(new Date().toDateString()+" "+fe),te=o.type=="time",de=o.type=="week";At(M.value)&&C&&(N=te?H(C)>H(M.value):de?C>M.value:ee>new Date(M.value)),At($.value)&&C&&(R=te?H(C)<H($.value):de?C<$.value:ee<new Date($.value))}if((N||R)&&(O(!!N,M.message,$.message,rr.max,rr.min),!n))return _(x[h].message),x}if((u||d)&&!j&&(At(C)||i&&Array.isArray(C))){const N=On(u),R=On(d),M=!vt(N.value)&&C.length>+N.value,$=!vt(R.value)&&C.length<+R.value;if((M||$)&&(O(M,N.message,R.message),!n))return _(x[h].message),x}if(p&&!j&&At(C)){const{value:N,message:R}=On(p);if(no(N)&&!C.match(N)&&(x[h]={type:rr.pattern,message:R,ref:o,...P(rr.pattern,R)},!n))return _(R),x}if(b){if(Et(b)){const N=await b(C,r),R=gd(N,S);if(R&&(x[h]={...R,...P(rr.validate,R.message)},!n))return _(R.message),x}else if(Ze(b)){let N={};for(const R in b){if(!ft(N)&&!n)break;const M=gd(await b[R](C,r),S,R);M&&(N={...M,...P(R,M.message)},_(M.message),n&&(x[h]=N))}if(!ft(N)&&(x[h]={ref:S,...N},!n))return x}}return _(!0),x};const oO={mode:sr.onSubmit,reValidateMode:sr.onChange,shouldFocusError:!0},qp={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function aO(e={}){let t={...oO,...e},r={...Xe(qp),isLoading:Et(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ze(t.defaultValues)||Ze(t.values)?Xe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:Xe(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let m={...f};const p={array:ad(),state:ad()},b=t.criteriaMode===sr.all,h=w=>A=>{clearTimeout(u),u=setTimeout(w,A)},v=async w=>{if(!o.keepIsValid&&!t.disabled&&(f.isValid||m.isValid||w)){let A;t.resolver?(A=ft((await P()).errors),y()):A=await R({fields:n,onlyCheckValid:!0,eventType:jr.VALID}),A!==r.isValid&&p.state.next({isValid:A})}},y=(w,A)=>{!t.disabled&&(f.isValidating||f.validatingFields||m.isValidating||m.validatingFields)&&((w||Array.from(a.mount)).forEach(I=>{I&&(A?Ve(r.validatingFields,I,A):nt(r.validatingFields,I))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ft(r.validatingFields)}))},C=()=>{r.dirtyFields=Xr(s,i)},S=(w,A=[],I,U,z=!0,W=!0)=>{if(U&&I&&!t.disabled){if(o.action=!0,W&&Array.isArray(G(n,w))){const V=I(G(n,w),U.argA,U.argB);z&&Ve(n,w,V)}if(W&&Array.isArray(G(r.errors,w))){const V=I(G(r.errors,w),U.argA,U.argB);z&&Ve(r.errors,w,V),iO(r.errors,w)}if((f.touchedFields||m.touchedFields)&&W&&Array.isArray(G(r.touchedFields,w))){const V=I(G(r.touchedFields,w),U.argA,U.argB);z&&Ve(r.touchedFields,w,V)}(f.dirtyFields||m.dirtyFields)&&C(),p.state.next({name:w,isDirty:$(w,A),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ve(i,w,A)},_=(w,A)=>{Ve(r.errors,w,A),r.errors={...r.errors},p.state.next({errors:r.errors})},x=w=>{r.errors=w,p.state.next({errors:r.errors,isValid:!1})},T=w=>{const A=li(w)?[w]:jo(w);let I=i,U=s;for(let z=0;z<A.length-1;z++){const W=A[z];if(I=vt(I)?I:I[W],U=vt(U)?U:U[W],I===null&&U!==null)return!0}return!1},D=(w,A,I,U)=>{const z=G(n,w);if(z){if(T(w))return;const W=Qe(G(i,w)),V=G(i,w,Qe(I)?G(s,w):I);Qe(V)||U&&U.defaultChecked||A?Ve(i,w,A?V:dd(z._f)):te(w,V),o.mount&&!o.action&&(v(),W&&r.isDirty&&(f.isDirty||m.isDirty)&&($()||(r.isDirty=!1,p.state.next({...r}))),e.shouldUnregister&&W&&!Qe(G(i,w))&&fa(w,a)&&(o.watch=!0))}},E=(w,A,I,U,z)=>{let W=!1,V=!1;const ne={name:w};if(!t.disabled){if(!I||U){(f.isDirty||m.isDirty)&&(V=r.isDirty,r.isDirty=ne.isDirty=$(),W=V!==ne.isDirty);const se=zt(G(s,w),A);V=!!G(r.dirtyFields,w),se!==r.isDirty?r.dirtyFields=Xr(s,i):se?nt(r.dirtyFields,w):Ve(r.dirtyFields,w,!0),ne.dirtyFields=r.dirtyFields,W=W||(f.dirtyFields||m.dirtyFields)&&V!==!se}if(I){const se=G(r.touchedFields,w);se||(Ve(r.touchedFields,w,I),ne.touchedFields=r.touchedFields,W=W||(f.touchedFields||m.touchedFields)&&se!==I)}W&&z&&p.state.next(ne)}return W?ne:{}},j=(w,A,I,U)=>{const z=G(r.errors,w),W=(f.isValid||m.isValid)&&Ut(A)&&r.isValid!==A;if(t.delayError&&I?(c=h(()=>_(w,I)),c(t.delayError)):(clearTimeout(u),c=null,I?Ve(r.errors,w,I):nt(r.errors,w),r.errors={...r.errors}),(I?!zt(z,I):z)||!ft(U)||W){const V={...U,...W&&Ut(A)?{isValid:A}:{},errors:r.errors,name:w};r={...r,...V},p.state.next(V)}},P=async w=>(y(w,!0),await t.resolver(i,t.context,JL(w||a.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),O=async w=>{const{errors:A}=await P(w);if(y(w),w){for(const I of w){const U=G(A,I);U?a.array.has(I)&&Ze(U)&&!Object.keys(U).some(z=>!Number.isNaN(Number(z)))?md(r.errors,{[I]:U},I):Ve(r.errors,I,U):nt(r.errors,I)}r.errors={...r.errors}}else r.errors=A;return A},N=async({name:w,eventType:A})=>{if(e.validate){const I=await e.validate({formValues:i,formState:r,name:w,eventType:A});if(Ze(I))for(const U in I){const z=I[U];z&&be(`${ua}.${U}`,{message:At(z.message)?z.message:"",type:z.type||rr.validate})}else At(I)||!I?be(ua,{message:I||"",type:rr.validate}):he(ua);return I}return!0},R=async({fields:w,onlyCheckValid:A,name:I,eventType:U,context:z={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(z.runRootValidation=!0,!await N({name:I,eventType:U})&&(z.valid=!1,A)))return z.valid;for(const W in w){const V=w[W];if(V){const{_f:ne,...se}=V;if(ne){const je=a.array.has(ne.name),Ge=V._f&&eO(V._f),st=f.validatingFields||f.isValidating||m.validatingFields||m.isValidating;Ge&&st&&y([ne.name],!0);const Vt=await vd(V,a.disabled,i,b,t.shouldUseNativeValidation&&!A,je);if(Ge&&st&&y([ne.name]),Vt[ne.name]&&(z.valid=!1,A)||(!A&&(G(Vt,ne.name)?je?md(r.errors,Vt,ne.name):Ve(r.errors,ne.name,Vt[ne.name]):nt(r.errors,ne.name)),e.shouldUseNativeValidation&&Vt[ne.name]))break}!ft(se)&&await R({context:z,onlyCheckValid:A,fields:se,name:W,eventType:U})}}return z.valid},M=()=>{for(const w of a.unMount){const A=G(n,w);A&&(A._f.refs?A._f.refs.every(I=>!da(I)):!da(A._f.ref))&&Te(w)}a.unMount=new Set},$=(w,A)=>!t.disabled&&(w&&A&&Ve(i,w,A),!zt(B(),s)),ee=(w,A,I)=>al(w,a,{...o.mount?i:Qe(A)?s:At(w)?{[w]:A}:A},I,A),H=w=>Np(G(o.mount?i:s,w,t.shouldUnregister?G(s,w,[]):[])),te=(w,A,I={},U=!1)=>{const z=G(n,w);let W=A;if(z){const V=z._f;V&&(!V.disabled&&Ve(i,w,Mp(A,V)),W=ro(V.ref)&&vt(A)?"":A,Pp(V.ref)?[...V.ref.options].forEach(ne=>ne.selected=W.includes(ne.value)):V.refs?ai(V.ref)?V.refs.forEach(ne=>{(!ne.defaultChecked||!ne.disabled)&&(Array.isArray(W)?ne.checked=!!W.find(se=>se===ne.value):ne.checked=W===ne.value||!!W)}):V.refs.forEach(ne=>ne.checked=ne.value===W):Zl(V.ref)?V.ref.value="":(V.ref.value=W,V.ref.type||p.state.next({name:w,values:U?i:Xe(i)})))}(I.shouldDirty||I.shouldTouch)&&E(w,W,I.shouldTouch,I.shouldDirty,!0),I.shouldValidate&&F(w)},de=(w,A,I,U=!1)=>{for(const z in A){if(!A.hasOwnProperty(z))return;const W=A[z],V=w+"."+z,ne=G(n,V);(a.array.has(w)||Ze(W)||ne&&!ne._f)&&!tn(W)?de(V,W,I,U):te(V,W,I,U)}},fe=(w,A,I,U)=>{const z=G(n,w),W=a.array.has(w),V=U?A:Xe(A),ne=G(i,w),se=zt(ne,V);if(se||Ve(i,w,V),W)p.array.next({name:w,values:U?i:Xe(i)}),(f.isDirty||f.dirtyFields||m.isDirty||m.dirtyFields)&&I.shouldDirty&&(C(),p.state.next({name:w,dirtyFields:r.dirtyFields,isDirty:$(w,V)}));else{const je=Array.isArray(V)&&!V.length||ft(V);!z||z._f||vt(V)||je?te(w,V,I,U):de(w,V,I,U)}if(!se){const je=fa(w,a),Ge=U?i:Xe(i);p.state.next({...je&&r,name:o.mount||je?w:void 0,values:Ge})}},pe=(w,A,I={})=>fe(w,A,I,!1),ae=(w,A={})=>{const I=Et(w)?w(i):w;if(!zt(i,I)){i={...i,...I};for(const U of a.mount)fe(U,G(I,U),A,!0);p.state.next({...r,name:void 0,type:void 0,values:i}),A.shouldValidate&&v()}},we=async w=>{o.mount=!0;const A=w.target;let I=A.name,U=!0;const z=G(n,I),W=se=>{U=Number.isNaN(se)||tn(se)&&isNaN(se.getTime())||zt(se,G(i,I,se))},V=fd(t.mode),ne=fd(t.reValidateMode);if(z){let se,je;const Ge=A.type?dd(z._f):ol(w),st=w.type===jr.BLUR||w.type===jr.FOCUS_OUT,Vt=!tO(z._f)&&!e.validate&&!t.resolver&&!G(r.errors,I)&&!z._f.deps||sO(st,G(r.touchedFields,I),r.isSubmitted,ne,V),us=fa(I,a,st);Ve(i,I,Ge),st?(!A||!A.readOnly)&&(z._f.onBlur&&z._f.onBlur(w),c&&c(0)):z._f.onChange&&z._f.onChange(w);const Yr=E(I,Ge,st),ct=!ft(Yr)||us;if(!st&&p.state.next({name:I,type:w.type,values:Xe(i)}),Vt)return(f.isValid||m.isValid)&&(t.mode==="onBlur"?st&&v():st||v()),ct&&p.state.next({name:I,...us?{}:Yr});if(!t.resolver&&e.validate&&await N({name:I,eventType:w.type}),!st&&us&&p.state.next({...r}),t.resolver){const{errors:Ct}=await P([I]);if(y([I]),W(Ge),!U){!ft(Yr)&&p.state.next(Yr);return}const It=pd(r.errors,n,I),er=pd(Ct,n,It.name||I);se=er.error,I=er.name,je=ft(Ct)}else y([I],!0),se=(await vd(z,a.disabled,i,b,t.shouldUseNativeValidation))[I],y([I]),W(Ge),U&&(se?je=!1:(f.isValid||m.isValid)&&(je=await R({fields:n,onlyCheckValid:!0,name:I,eventType:w.type})));U&&(z._f.deps&&(!Array.isArray(z._f.deps)||z._f.deps.length>0)&&F(z._f.deps),j(I,je,se,Yr))}},ye=(w,A)=>{if(G(r.errors,A)&&w.focus)return w.focus(),1},F=async(w,A={})=>{let I,U;const z=$i(w);if(t.resolver){const W=await O(Qe(w)?w:z);I=ft(W),U=w?!z.some(V=>G(W,V)):I}else w?(U=(await Promise.all(z.map(async W=>{const V=G(n,W);return await R({fields:V&&V._f?{[W]:V}:V,eventType:jr.TRIGGER})}))).every(Boolean),!(!U&&!r.isValid)&&v()):U=I=await R({fields:n,name:w,eventType:jr.TRIGGER});return p.state.next({...!At(w)||(f.isValid||m.isValid)&&I!==r.isValid?{}:{name:w},...t.resolver||!w?{isValid:I}:{},errors:r.errors}),A.shouldFocus&&!U&&Ds(n,ye,w?z:a.mount),U},B=(w,A)=>{let I={...o.mount?i:s};return A&&(I=jp(A.dirtyFields?r.dirtyFields:r.touchedFields,I)),Qe(w)?I:At(w)?G(I,w):w.map(U=>G(I,U))},Z=(w,A)=>({invalid:!!G((A||r).errors,w),isDirty:!!G((A||r).dirtyFields,w),error:G((A||r).errors,w),isValidating:!!G(r.validatingFields,w),isTouched:!!G((A||r).touchedFields,w)}),he=w=>{const A=w?$i(w):void 0;A==null||A.forEach(I=>nt(r.errors,I)),A?A.forEach(I=>{p.state.next({name:I,errors:r.errors})}):p.state.next({errors:{}})},be=(w,A,I)=>{const U=(G(n,w,{_f:{}})._f||{}).ref,z=G(r.errors,w)||{},{ref:W,message:V,type:ne,...se}=z;Ve(r.errors,w,{...se,...A,ref:U}),p.state.next({name:w,errors:r.errors,isValid:!1}),I&&I.shouldFocus&&U&&U.focus&&U.focus()},me=(w,A)=>Et(w)?p.state.subscribe({next:I=>"values"in I&&w(I.values||ee(void 0,A),I)}):ee(w,A,!0),le=w=>p.state.subscribe({next:A=>{if(nO(w.name,A.name,w.exact)&&rO(A,w.formState||f,Gr,w.reRenderRoot)){const I={...i};w.callback({values:I,...r,...A,defaultValues:s})}}}).unsubscribe,ve=w=>(o.mount=!0,m={...m,...w.formState},le({...w,formState:{...d,...w.formState}})),Te=(w,A={})=>{for(const I of w?$i(w):a.mount)a.mount.delete(I),a.array.delete(I),A.keepValue||(nt(n,I),nt(i,I)),!A.keepError&&nt(r.errors,I),!A.keepDirty&&nt(r.dirtyFields,I),!A.keepTouched&&nt(r.touchedFields,I),!A.keepIsValidating&&nt(r.validatingFields,I),!t.shouldUnregister&&!A.keepDefaultValue&&nt(s,I);p.state.next({values:Xe(i)}),p.state.next({...r,...A.keepDirty?{isDirty:$()}:{}}),!A.keepIsValid&&v()},Y=({disabled:w,name:A})=>{if(Ut(w)&&o.mount||w||a.disabled.has(A)){const z=a.disabled.has(A)!==!!w;w?a.disabled.add(A):a.disabled.delete(A),z&&o.mount&&!o.action&&v()}},ce=(w,A={})=>{let I=G(n,w);const U=Ut(A.disabled)||Ut(t.disabled),z=!a.registerName.has(w)&&I&&I._f&&!I._f.mount;return Ve(n,w,{...I||{},_f:{...I&&I._f?I._f:{ref:{name:w}},name:w,mount:!0,...A}}),a.mount.add(w),I&&!z?Y({disabled:Ut(A.disabled)?A.disabled:t.disabled,name:w}):D(w,!0,A.value),{...U?{disabled:A.disabled||t.disabled}:{},...t.progressive?{required:!!A.required,min:Cs(A.min),max:Cs(A.max),minLength:Cs(A.minLength),maxLength:Cs(A.maxLength),pattern:Cs(A.pattern)}:{},name:w,onChange:we,onBlur:we,ref:W=>{if(W){a.registerName.add(w),ce(w,A),a.registerName.delete(w),I=G(n,w);const V=Qe(W.value)&&W.querySelectorAll&&W.querySelectorAll("input,select,textarea")[0]||W,ne=KL(V),se=I._f.refs||[];if(ne?se.find(je=>je===V):V===I._f.ref)return;Ve(n,w,{_f:{...I._f,...ne?{refs:[...se.filter(da),V,...Array.isArray(G(s,w))?[{}]:[]],ref:{type:V.type,name:w}}:{ref:V}}}),D(w,!1,void 0,V)}else I=G(n,w,{}),I._f&&(I._f.mount=!1),(t.shouldUnregister||A.shouldUnregister)&&!(kp(a.array,w)&&o.action)&&a.unMount.add(w)}}},Q=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Ds(n,ye,a.mount),Ce=w=>{Ut(w)&&(p.state.next({disabled:w}),Ds(n,(A,I)=>{const U=G(n,I);U&&(A.disabled=U._f.disabled||w,Array.isArray(U._f.refs)&&U._f.refs.forEach(z=>{z.disabled=U._f.disabled||w}))},0,!1))},qe=(w,A)=>async I=>{let U;I&&(I.preventDefault&&I.preventDefault(),I.persist&&I.persist());let z=Xe(i);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:V}=await P();y(),r.errors=W,z=Xe(V)}else await R({fields:n,eventType:jr.SUBMIT});if(a.disabled.size)for(const W of a.disabled)nt(z,W);if(nt(r.errors,Dp),ft(r.errors)){p.state.next({errors:{}});try{await w(z,I)}catch(W){U=W}}else A&&await A({...r.errors},I),Q(),setTimeout(Q);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ft(r.errors)&&!U,submitCount:r.submitCount+1,errors:r.errors}),U)throw U},et=(w,A={})=>{G(n,w)&&(Qe(A.defaultValue)?pe(w,Xe(G(s,w))):(pe(w,A.defaultValue),Ve(s,w,Xe(A.defaultValue))),A.keepTouched||nt(r.touchedFields,w),A.keepDirty||(nt(r.dirtyFields,w),r.isDirty=A.defaultValue?$(w,Xe(G(s,w))):$()),A.keepError||(nt(r.errors,w),f.isValid&&v()),p.state.next({...r}))},$e=(w,A={})=>{const I=w?Xe(w):s,U=Xe(I),z=ft(w),W=U;if(A.keepDefaultValues||(s=I),!A.keepValues){if(A.keepDirtyValues){const V=new Set([...a.mount,...Object.keys(Xr(s,i))]);for(const ne of Array.from(V)){const se=G(r.dirtyFields,ne),je=G(i,ne),Ge=G(W,ne);se&&!Qe(je)?Ve(W,ne,je):!se&&!Qe(Ge)&&pe(ne,Ge)}}else{if(No&&Qe(w))for(const V of a.mount){const ne=G(n,V);if(ne&&ne._f){const se=Array.isArray(ne._f.refs)?ne._f.refs[0]:ne._f.ref;if(ro(se)){const je=se.closest("form");if(je){je.reset();break}}}}if(A.keepFieldsRef)for(const V of a.mount)pe(V,G(W,V));else n={}}if(t.shouldUnregister){if(i=A.keepDefaultValues?Xe(s):{},A.keepFieldsRef)for(const V of a.mount)Ve(i,V,G(W,V))}else i=Xe(W);p.array.next({values:{...W}}),p.state.next({values:{...W}})}a={mount:A.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!A.keepIsValid||!!A.keepDirtyValues||!t.shouldUnregister&&!ft(W),o.watch=!!t.shouldUnregister,o.keepIsValid=!!A.keepIsValid,o.action=!1,A.keepErrors||(r.errors={}),p.state.next({submitCount:A.keepSubmitCount?r.submitCount:0,isDirty:z?!1:A.keepDirty?r.isDirty:A.keepValues?$():!!(A.keepDefaultValues&&!zt(w,s)),isSubmitted:A.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:z?{}:A.keepDirtyValues?A.keepDefaultValues&&i?Xr(s,i):r.dirtyFields:A.keepDefaultValues&&w?Xr(s,w):A.keepDirty?r.dirtyFields:{},touchedFields:A.keepTouched?r.touchedFields:{},errors:A.keepErrors?r.errors:{},isSubmitSuccessful:A.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},We=(w,A)=>$e(Et(w)?w(i):w,{...t.resetOptions,...A}),tt=(w,A={})=>{const I=G(n,w),U=I&&I._f;if(U){const z=U.refs?U.refs[0]:U.ref;z.focus&&setTimeout(()=>{z.focus(),A.shouldSelect&&Et(z.select)&&z.select()})}},Gr=w=>{r={...r,...w}},Kr={control:{register:ce,unregister:Te,getFieldState:Z,handleSubmit:qe,setError:be,_subscribe:le,_runSchema:P,_updateIsValidating:y,_focusError:Q,_getWatch:ee,_getDirty:$,_setValid:v,_setFieldArray:S,_setDisabledField:Y,_setErrors:x,_getFieldArray:H,_reset:$e,_resetDefaultValues:()=>Et(t.defaultValues)&&t.defaultValues().then(w=>{We(w,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:Ce,_subjects:p,_proxyFormState:f,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(w){o=w},get _defaultValues(){return s},get _names(){return a},set _names(w){a=w},get _formState(){return r},get _options(){return t},set _options(w){t={...t,...w}}},subscribe:ve,trigger:F,register:ce,handleSubmit:qe,watch:me,setValue:pe,setValues:ae,getValues:B,reset:We,resetField:et,resetDefaultValues:(w,A={})=>{if(s=Xe(w),!A.keepDirty){const I=Xr(s,i);r.dirtyFields=I,r.isDirty=!ft(I)}A.keepIsValid||v(),p.state.next({...r,defaultValues:s})},clearErrors:he,unregister:Te,setError:be,setFocus:tt,getFieldState:Z};return{...Kr,formControl:Kr}}function lO(e={}){const t=g.useRef(void 0),r=g.useRef(void 0),n=g.useRef(e.formControl),[s,i]=g.useState(()=>({...Xe(qp),isLoading:Et(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Et(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!Et(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...c}=aO(e);t.current={...c,formState:s}}const o=t.current.control;return o._options=e,Kl(()=>{const a=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,a},[o]),g.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),g.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),g.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),g.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),g.useEffect(()=>{if(o._proxyFormState.isDirty){const a=o._getDirty();a!==s.isDirty&&o._subjects.state.next({isDirty:a})}},[o,s.isDirty]),g.useEffect(()=>{var a;e.values&&!zt(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((a=o._options.resetOptions)===null||a===void 0)&&a.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),g.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=g.useMemo(()=>Op(s,o),[o,s]),t.current}function cO(e,t,r){const n=e??[],s=new Set(n.map(d=>d.type).filter(Boolean)),i=(t??[]).filter(d=>!s.has(d)),{data:o}=Jn({queryKey:["framework-search",i.sort().join(","),r],queryFn:()=>_0({type:i,systemDefault:"Yes"}),enabled:i.length>0,staleTime:600*1e3}),a=t&&t.length?n.filter(d=>d.type&&t.includes(d.type)):n,c=[...(o??[]).map(d=>({label:d.name,value:d.identifier})),...a.map(d=>({label:d.name,value:d.identifier}))],u=new Set;return c.filter(d=>u.has(d.value)?!1:(u.add(d.value),!0))}async function $p(e){var r,n;return(n=(r=(await Fe.get(`/action/channel/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.channel}function uO(e){var r,n,s,i,o,a,c;const t=Jn({queryKey:["channel",e],queryFn:()=>$p(e),enabled:!!e,staleTime:6e5});return{identifier:((r=t.data)==null?void 0:r.identifier)??e??"",name:(n=t.data)==null?void 0:n.name,frameworks:(s=t.data)==null?void 0:s.frameworks,collectionAdditionalCategories:(i=t.data)==null?void 0:i.collectionAdditionalCategories,contentAdditionalCategories:(o=t.data)==null?void 0:o.contentAdditionalCategories,defaultLicense:(a=t.data)==null?void 0:a.defaultLicense,defaultFramework:(c=t.data)==null?void 0:c.defaultFramework,isLoading:t.isLoading}}function dO(e){const{data:t}=Jn({queryKey:["user","read",e],enabled:!!e,staleTime:1/0,queryFn:()=>V0(e)});return t&&([t.firstName,t.lastName].filter(Boolean).join(" ").trim()||t.userName)||void 0}const Up=[{label:"Strict",value:"strict"},{label:"Adaptive",value:"adaptive"},{label:"Prior learning",value:"priorLearning"}],fO={"First Section":{title:"Basic Information",description:"Core details that define the content identity."},"Second Section":{title:"Categorisation",description:"Category and type classification for the content."},"Third Section":{title:"Categorisation",description:"Category and type classification for the content."},"Organisation Framework Terms":{title:"Curriculum",description:"Framework-aligned categorisation."},"Target Framework Terms":{title:"Target Audience",description:"Curriculum alignment for the intended learners."},"Fourth Section":{title:"Licensing & Attribution",description:"Copyright and usage rights information."},"Sixth Section":{title:"Licensing & Attribution",description:"Copyright and usage rights information."},"Consumption policy":{title:"Consumption policy",description:"How learners move through this path."}},hO=new Set(["review","read","sourcingreview","orgreview"]),Si={"First Section":"details","Second Section":"details","Third Section":"details","Organisation Framework Terms":"details","Target Framework Terms":"audience","Fourth Section":"licensing","Sixth Section":"licensing"},pO={Categorisation:"Second Section","Basic Information":"First Section","Licensing & Attribution":"Fourth Section",Curriculum:"Organisation Framework Terms","Target Audience":"Target Framework Terms"},mO={name:"details",description:"details",keywords:"details",appIcon:"details",primaryCategory:"details",additionalCategories:"details",board:"details",boardIds:"details",subject:"details",subjectIds:"details",medium:"details",framework:"details",topicsIds:"details",topic:"details",dialcodeRequired:"details",dialcodes:"details",audience:"audience",targetBoardIds:"audience",targetMediumIds:"audience",targetGradeLevelIds:"audience",targetSubjectIds:"audience",gradeLevel:"audience",creator:"licensing",author:"licensing",attributions:"licensing",license:"licensing",copyright:"licensing",copyrightYear:"licensing"},ui={board:"board",boardIds:"board",medium:"medium",gradeLevel:"gradeLevel",subject:"subject",subjectIds:"subject",topicsIds:"topic",topic:"topic",targetBoardIds:"board",targetMediumIds:"medium",targetGradeLevelIds:"gradeLevel",targetSubjectIds:"subject"},Jl=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds"]);function zp(e,t,r,n,s={}){if(!(e!=null&&e.length))return yd(jO(t,n,r,s),r,t,n,s);const i=new Map;for(const c of e){const u=c.code;u&&!i.has(u)&&i.set(u,c)}const o=new Set,a=e.filter(c=>{var d;if(n&&(c.code==="dialCode"||c.code==="dialcode")||((d=s.profile)==null?void 0:d.key)==="learningPath"&&Jl.has(c.code)||c.visible===!1)return!1;const u=c.code;return o.has(u)?!1:(o.add(u),!0)}).map(c=>{const u=c.code??"",d=_O(c),f=wO(c,r,t,i,s),m=t[u],p=vO(u,Vp(m,d),d,t,s),b={code:u,label:c.label??u,inputType:d,required:!!(c.required===!0||Array.isArray(c.validations)&&c.validations.some(h=>h.type==="required")),editable:gO(u,c.editable!==!1,s),placeholder:c.placeholder,maxLength:c.maxLength,options:CO(f,p,d,r),depends:c.depends,tab:SO(c),section:c.section,sourceCategory:c.sourceCategory,defaultValue:c.defaultValue??c.default,currentValue:p};if(u==="dialcodes"){const h=t.dialcodeRequired==="Yes";return{...b,required:h,visible:h}}return b});return yd(a,r,t,n,s)}function yd(e,t,r,n,s){var i;return((i=s.profile)==null?void 0:i.key)==="learningPath"?NO(e,t,r,n):OO(e,t,r,n)}function gO(e,t,r){var i;const n=r.editorMode??"edit";if(!hO.has(n))return t!==!1;const s=(i=r.editableFields)==null?void 0:i[n];return!!(s&&s.includes(e))}function vO(e,t,r,n,s){const i=t==null||t===""||Array.isArray(t)&&t.length===0;switch(e){case"license":return i?s.defaultLicense??"":t;case"copyright":return i&&s.channelName?s.channelName:t;case"copyrightYear":return i?String(new Date().getFullYear()):t;case"author":case"creator":return i&&s.userFullName?s.userFullName:t;case"instructions":{const o=n.instructions;return o&&typeof o=="object"&&!Array.isArray(o)?o.default??"":typeof t=="object"&&t!==null?"":t}case"maxTime":case"warningTime":{if(!i)return t;const o=n.timeLimits,a=o==null?void 0:o[e];return a!=null&&a!==""?yO(Number(a)):t}default:return t}}function yO(e){if(!Number.isFinite(e)||e<0)return"";const t=Math.floor(e%60),r=Math.floor(e/60%60),n=Math.floor(e/3600),s=i=>String(i).padStart(2,"0");return n>0?`${s(n)}:${s(r)}:${s(t)}`:`${s(r)}:${s(t)}`}function bO(e){var n,s,i;const t=new Map,r=o=>o==null?void 0:o.forEach(a=>{a.identifier&&t.set(a.identifier,a.name),a.name&&t.set(a.name,a.name)});return(s=(n=e.organisationFramework)==null?void 0:n.categories)==null||s.forEach(o=>r(o.terms)),(i=e.targetFrameworks)==null||i.forEach(o=>{var a;return(a=o.categories)==null?void 0:a.forEach(c=>r(c.terms))}),t}function CO(e,t,r,n){if(r!=="select"&&r!=="multiselect"&&r!=="radio")return e;const s=Array.isArray(t)?t:t!=null&&t!==""?[t]:[];if(!s.length)return e;const i=e?[...e]:[],o=new Set(i.map(c=>c.value)),a=bO(n);for(const c of s){const u=String(c);o.has(u)||(i.push({label:a.get(u)??u,value:u}),o.add(u))}return i}function SO(e){const t=e.section;if(t){if(Si[t])return Si[t];const n=pO[t];if(n&&Si[n])return Si[n]}const r=e.code??"";return mO[r]??"details"}function Vp(e,t){const r=new Set(["multiselect","chips","keywords","tagsinput"]),n=new Set(["select","text","textarea","radio","datepicker","datetime","license"]);return r.has(t)?Array.isArray(e)?e:e!=null&&e!==""?[e]:[]:n.has(t)?Array.isArray(e)?e[0]??"":e??"":e}function _O(e){const t=(e.inputType??e.dataType??"").toLowerCase(),n=(e.dataType??"").toLowerCase()==="list";return t==="select"?"select":t==="framework"||t==="frameworkcategoryselect"?n?"multiselect":"select":t==="topicselector"?"chips":t==="multiselect"||t==="multi-select"?"multiselect":t==="keywords"||e.code==="keywords"||e.code==="topic"||e.code==="topicsIds"?"chips":t==="radio"?"radio":e.code==="appIcon"||t==="appicon"?"appIcon":t==="textarea"||e.code==="description"?"textarea":t==="datepicker"||t==="date"?"datepicker":t==="datetime"||t==="datetime-local"?"datetime":t==="tagsinput"?"tagsinput":t==="nestedselect"||t==="nested-select"?n?"multiselect":"select":t==="license"?"license":t==="dialcode"||t==="dial-code"?"dialcode":"text"}function wO(e,t,r,n,s){var u;const i=e.code??"";if(((u=s.profile)==null?void 0:u.key)==="learningPath"&&i==="policy")return Up;if(i==="maxQuestions"){const d=s.childCount??0;if(d>0)return Array.from({length:d},(f,m)=>({label:String(m+1),value:String(m+1)}))}const o=e.range;if(Array.isArray(o)&&o.length)return typeof o[0]=="string"?o.map(d=>({label:d,value:d})):o.map(d=>({label:d.name,value:d.identifier}));const a=e.enum;if(a!=null&&a.length)return a.map(d=>({label:d,value:d}));if(i==="framework")return t.orgFrameworks;if(i==="additionalCategories"){const f=(s.objectType??"")==="QuestionSet"?s.contentAdditionalCategories??s.collectionAdditionalCategories:s.collectionAdditionalCategories??s.contentAdditionalCategories,m=(f&&f.length?f:s.contextAdditionalCategories)??t.channelAdditionalCategories;return m!=null&&m.length?AO(m).map(p=>({label:p,value:p})):void 0}const c=e.sourceCategory??ui[i];if(c)return Hp(i,c,e,t,r,n)}function xO(e,t){return Jl.has(e)||t.output==="identifier"||typeof t.section=="string"&&t.section.includes("Target")}function TO(e,t){return Jl.has(e)||typeof t.section=="string"&&t.section.includes("Target")}function ha(e,t,r){var i,o,a,c,u;const n=(o=(i=e.organisationFramework)==null?void 0:i.categories)==null?void 0:o.find(d=>d.code===t),s=(u=(c=(a=e.targetFrameworks)==null?void 0:a[0])==null?void 0:c.categories)==null?void 0:u.find(d=>d.code===t);return r?(s==null?void 0:s.terms)??(n==null?void 0:n.terms)??[]:(n==null?void 0:n.terms)??(s==null?void 0:s.terms)??[]}function EO(e){const t=new Set,r=[];for(const n of e){const s=n.identifier??n.name;s&&!t.has(s)&&(t.add(s),r.push(n))}return r}function AO(e){return Array.from(new Set(e))}function kO(e){return Array.isArray(e)?e:e!=null&&e!==""?[e]:[]}function Hp(e,t,r,n,s,i){const o=xO(e,r),a=TO(e,r),c=h=>({label:h.name,value:o?h.identifier:h.name}),u=r.depends;if(!(u!=null&&u.length))return ha(n,t,a).map(c);const d=u.flatMap(h=>kO(s[h])).map(String);if(!d.length)return[];const f=[];for(const h of u){const v=i.get(h),y=(v==null?void 0:v.sourceCategory)??ui[h]??h;f.push(...ha(n,y,a))}const p=f.filter(h=>d.includes(String(h.name))||d.includes(String(h.identifier))||d.includes(String(h.code))).flatMap(h=>h.associations??[]).filter(h=>String(h.category??"").toLowerCase()===t.toLowerCase()),b=EO(p);return b.length?b.map(c):ha(n,t,a).map(c)}function Ss(e,t){const r=ui[e];if(r)return Hp(e,r,{},t,{},new Map)}function Ye(e,t,r){return Vp(e[t],r)}const IO=["board","medium","gradeLevel","subject"];function DO(e){var r;const t=((r=e.organisationFramework)==null?void 0:r.categories)??[];return t.length?t.some(n=>IO.includes(n.code)):!0}function LO(e,t){var r,n,s;return!!((n=(r=e.organisationFramework)==null?void 0:r.categories)!=null&&n.some(i=>i.code===t)||(s=e.targetFrameworks)!=null&&s.some(i=>{var o;return(o=i.categories)==null?void 0:o.some(a=>a.code===t)}))}function OO(e,t,r,n){var c;if(!n||DO(t))return e;const s=e.filter(u=>{const d=u.sourceCategory??ui[u.code];return!d||LO(t,d)}),i=new Set(s.map(u=>u.code)),o=[];for(const u of((c=t.organisationFramework)==null?void 0:c.categories)??[])i.has(u.code)||o.push({code:u.code,label:u.name,inputType:"multiselect",editable:!0,tab:"details",section:"Organisation Framework Terms",options:(u.terms??[]).map(d=>({label:d.name,value:d.name})),currentValue:Ye(r,u.code,"multiselect")});if(!o.length)return s;const a=s.findIndex(u=>u.code==="framework");return a>=0?[...s.slice(0,a+1),...o,...s.slice(a+1)]:[...s,...o]}const pa="Organisation Framework Terms";function NO(e,t,r,n){var m,p;if(!n)return e;const s=[...((m=t.organisationFramework)==null?void 0:m.categories)??[]].sort((b,h)=>(b.index??1/0)-(h.index??1/0));if(!s.length)return e;const i=(p=Nh(s))==null?void 0:p.code,o=b=>b.sourceCategory??ui[b.code];let c=e.filter(b=>{const h=o(b);return h?h!==i&&s.some(v=>v.code===h):!0}).map(b=>o(b)?{...b,section:pa,required:!0,inputType:"select",currentValue:Ye(r,b.code,"select")}:b),u=c.findIndex(b=>b.code==="framework");if(u===-1){const b={code:"framework",label:"Curriculum",inputType:"select",required:!0,editable:!0,tab:"details",section:pa,options:t.orgFrameworks,currentValue:Ye(r,"framework","select")},h=c.findIndex(v=>!!o(v));u=h>=0?h:c.length,c=[...c.slice(0,u),b,...c.slice(u)]}const d=new Set(c.map(b=>b.code)),f=s.filter(b=>b.code!==i&&!d.has(b.code)).map(b=>({code:b.code,label:b.name,inputType:"select",required:!0,editable:!0,tab:"details",section:pa,options:(b.terms??[]).map(h=>({label:h.name,value:h.name})),currentValue:Ye(r,b.code,"select")}));return f.length?[...c.slice(0,u+1),...f,...c.slice(u+1)]:c}function jO(e,t,r,n={}){var i,o;const s=[{code:"name",label:"Title",inputType:"text",required:!0,editable:!0,tab:"details",section:"First Section",maxLength:200,currentValue:Ye(e,"name","text")},{code:"description",label:"Description",inputType:"textarea",editable:!0,tab:"details",section:"First Section",maxLength:2e3,currentValue:Ye(e,"description","textarea")},{code:"keywords",label:"Keywords",inputType:"chips",editable:!0,tab:"details",section:"First Section",currentValue:Ye(e,"keywords","chips")}];return t?((i=n.profile)==null?void 0:i.key)==="learningPath"?(s.push({code:"framework",label:"Curriculum",inputType:"select",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:r.orgFrameworks,currentValue:Ye(e,"framework","select")},{code:"policy",label:"Consumption policy",inputType:"select",required:!0,editable:!0,tab:"details",section:"Consumption policy",options:Up,currentValue:Ye(e,"policy","select")||"strict"}),s):(s.push({code:"primaryCategory",label:"Category",inputType:"select",editable:!1,tab:"details",section:"Second Section",currentValue:Ye(e,"primaryCategory","select")},{code:"additionalCategories",label:"Additional Category",inputType:"multiselect",editable:!0,tab:"details",section:"Second Section",currentValue:Ye(e,"additionalCategories","multiselect"),options:(o=r.channelAdditionalCategories)==null?void 0:o.map(a=>({label:a,value:a}))},{code:"framework",label:"Course Type",inputType:"select",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:r.orgFrameworks,currentValue:Ye(e,"framework","select")},{code:"subjectIds",label:"Subjects covered",inputType:"multiselect",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:Ss("subjectIds",r),currentValue:Ye(e,"subjectIds","multiselect")}),s.push({code:"audience",label:"Audience Type",inputType:"multiselect",editable:!0,tab:"audience",section:"Target Framework Terms",currentValue:Ye(e,"audience","multiselect")},{code:"targetBoardIds",label:"Board/Syllabus of the audience",inputType:"select",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",options:Ss("targetBoardIds",r),currentValue:Ye(e,"targetBoardIds","select")},{code:"targetMediumIds",label:"Medium(s) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetBoardIds"],options:Ss("targetMediumIds",r),currentValue:Ye(e,"targetMediumIds","multiselect")},{code:"targetGradeLevelIds",label:"Class(es) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetMediumIds"],options:Ss("targetGradeLevelIds",r),currentValue:Ye(e,"targetGradeLevelIds","multiselect")},{code:"targetSubjectIds",label:"Subject(s) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetGradeLevelIds"],options:Ss("targetSubjectIds",r),currentValue:Ye(e,"targetSubjectIds","multiselect")}),s.push({code:"creator",label:"Author",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"creator","text")},{code:"attributions",label:"Attributions",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"attributions","text")},{code:"copyright",label:"Copyright",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"copyright","text")},{code:"copyrightYear",label:"Copyright Year",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"copyrightYear","text")},{code:"license",label:"License",inputType:"select",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"license","select")}),s):s}const PO=["allowECM","levels","setPeriod","instances"];function Qp(e){const t={};return e.forEach((r,n)=>{t[`L${n+1}`]={label:r}}),t}function RO(e,t={}){const r={...e};for(const i of PO)delete r[i];const n=e.levels;Array.isArray(n)&&n.length&&(r.outcomeDeclaration={levels:Qp(n)});const s=e.instances;return s!=null&&s!==""&&(r.instances={label:s}),t.isReview&&(r.name===void 0||r.name===null||r.name==="")&&t.nodeTitle&&(r.name=t.nodeTitle),r}function FO(e,t){return e==="allowECM"||e==="setPeriod"?null:e==="levels"?{outcomeDeclaration:{levels:Array.isArray(t)?Qp(t):{}}}:e==="instances"?{instances:t!=null&&t!==""?{label:t}:""}:{[e]:t}}function MO(e,t){const{watch:r,setValue:n}=e,s=g.useRef(!1);g.useEffect(()=>{const i=r((o,{name:a})=>{var c;if(!(!a||s.current)){s.current=!0;try{const u=new Set([a]);let d=!0;for(;d;){d=!1;for(const f of t)u.has(f.code)||(c=f.depends)!=null&&c.some(m=>u.has(m))&&(n(f.code,f.inputType==="multiselect"||f.inputType==="chips"?[]:"",{shouldDirty:!0}),u.add(f.code),d=!0)}}finally{s.current=!1}}});return()=>i.unsubscribe()},[r,n,t])}const BO="_section_qa0tm_1",qO="_header_qa0tm_11",$O="_title_qa0tm_17",UO="_description_qa0tm_24",zO="_divider_qa0tm_30",VO="_fields_qa0tm_36",Nn={section:BO,header:qO,title:$O,description:UO,divider:zO,fields:VO},HO=({title:e,description:t,children:r})=>l.jsxs("div",{className:Nn.section,children:[l.jsxs("div",{className:Nn.header,children:[l.jsx("h3",{className:Nn.title,children:e}),t&&l.jsx("p",{className:Nn.description,children:t})]}),l.jsx("hr",{className:Nn.divider}),l.jsx("div",{className:Nn.fields,children:r})]}),QO="_field_93co8_1",WO="_fullWidth_93co8_7",GO="_label_93co8_11",KO="_required_93co8_19",YO="_input_93co8_24",ZO="_textarea_93co8_45",XO="_inputError_93co8_50",JO="_error_93co8_54",eN="_selectBtn_93co8_59",tN="_selectOpen_93co8_83",rN="_placeholder_93co8_87",nN="_selectedVal_93co8_91",sN="_chevronUp_93co8_95",iN="_dropdown_93co8_100",oN="_option_93co8_116",aN="_optionSelected_93co8_134",lN="_noOpts_93co8_139",cN="_chipGroup_93co8_146",uN="_chipInput_93co8_158",dN="_addChipBtn_93co8_167",fN="_radioGroup_93co8_184",hN="_radioLabel_93co8_191",pN="_iconWrap_93co8_199",mN="_iconPreview_93co8_214",gN="_iconPlaceholder_93co8_220",vN="_removeIconBtn_93co8_233",yN="_tagChip_93co8_252",bN="_tagChipRemove_93co8_264",CN="_nestedSelectRow_93co8_278",SN="_dialcodeRow_93co8_287",_N="_validateBtn_93co8_293",wN="_dialcodeValid_93co8_315",xN="_dialcodeSpinner_93co8_325",q={field:QO,fullWidth:WO,label:GO,required:KO,input:YO,textarea:ZO,inputError:XO,error:JO,selectBtn:eN,selectOpen:tN,placeholder:rN,selectedVal:nN,chevronUp:sN,dropdown:iN,option:oN,optionSelected:aN,noOpts:lN,chipGroup:cN,chipInput:uN,addChipBtn:dN,radioGroup:fN,radioLabel:hN,iconWrap:pN,iconPreview:mN,iconPlaceholder:gN,removeIconBtn:vN,tagChip:yN,tagChipRemove:bN,nestedSelectRow:CN,dialcodeRow:SN,validateBtn:_N,dialcodeValid:wN,dialcodeSpinner:xN},bd=({name:e,label:t,required:r,disabled:n,multiline:s,maxLength:i,placeholder:o})=>{const a=oe(),{register:c,formState:{errors:u}}=Jt(),d=u[e],f={required:r?a.textField.requiredError.replace("{field}",t):!1,maxLength:i?{value:i,message:a.textField.maxLengthError.replace("{max}",String(i))}:void 0};return l.jsxs("div",{className:[q.field,s?q.fullWidth:""].join(" "),children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),s?l.jsx("textarea",{id:e,className:[q.input,q.textarea,d?q.inputError:""].join(" "),disabled:n,placeholder:o,rows:3,...c(e,f)}):l.jsx("input",{id:e,type:"text",className:[q.input,d?q.inputError:""].join(" "),disabled:n,placeholder:o,...c(e,f)}),d&&l.jsx("span",{className:q.error,children:String(d.message)})]})},TN=({name:e,label:t,options:r,required:n,disabled:s})=>{var v;const i=oe(),[o,a]=g.useState(!1),c=g.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:m}}=Jt(),p=d(e),b=((v=r.find(y=>y.value===p))==null?void 0:v.label)??i.selectField.selectPlaceholder,h=m[e];return g.useEffect(()=>{if(!o)return;const y=C=>{var S;(S=c.current)!=null&&S.contains(C.target)||a(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]),l.jsxs("div",{className:q.field,ref:c,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...u(e,{required:n?i.selectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:s,className:[q.selectBtn,h?q.inputError:"",o?q.selectOpen:""].join(" "),onClick:()=>a(y=>!y),children:[l.jsx("span",{className:p?q.selectedVal:q.placeholder,children:b}),l.jsx(Cn,{size:14,className:o?q.chevronUp:""})]}),o&&l.jsxs("div",{className:q.dropdown,children:[r.map(y=>l.jsxs("button",{type:"button",className:[q.option,p===y.value?q.optionSelected:""].join(" "),onClick:()=>{f(e,y.value,{shouldDirty:!0,shouldValidate:!0}),a(!1)},children:[l.jsx("span",{children:y.label}),p===y.value&&l.jsx(bn,{size:13})]},y.value)),!r.length&&l.jsx("span",{className:q.noOpts,children:i.selectField.noOptionsMessage})]}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},EN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=oe(),[o,a]=g.useState(!1),c=g.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:m}}=Jt(),p=d(e)??[],b=m[e],h=p.length?`${p.length} ${i.multiSelectField.selectedCountSuffix}`:i.multiSelectField.selectPlaceholder;g.useEffect(()=>{if(!o)return;const y=C=>{var S;(S=c.current)!=null&&S.contains(C.target)||a(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]);const v=y=>{const C=p.includes(y)?p.filter(S=>S!==y):[...p,y];f(e,C,{shouldDirty:!0,shouldValidate:!0})};return l.jsxs("div",{className:q.field,ref:c,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...u(e,{required:n?i.multiSelectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:s,className:[q.selectBtn,b?q.inputError:"",o?q.selectOpen:""].join(" "),onClick:()=>a(y=>!y),children:[l.jsx("span",{className:p.length?q.selectedVal:q.placeholder,children:h}),l.jsx(Cn,{size:14,className:o?q.chevronUp:""})]}),o&&l.jsxs("div",{className:q.dropdown,children:[r.map(y=>l.jsxs("button",{type:"button",className:[q.option,p.includes(y.value)?q.optionSelected:""].join(" "),onClick:()=>v(y.value),children:[l.jsx(bn,{size:13,style:{opacity:p.includes(y.value)?1:0}}),l.jsx("span",{children:y.label})]},y.value)),!r.length&&l.jsx("span",{className:q.noOpts,children:i.multiSelectField.noOptionsMessage})]}),b&&l.jsx("span",{className:q.error,children:String(b.message)})]})},AN=({name:e,label:t,required:r,disabled:n,placeholder:s})=>{const i=oe(),o=s??i.chipGroupField.addPlaceholder,[a,c]=g.useState(""),[u,d]=g.useState(!1),f=g.useRef(null),{watch:m,setValue:p,formState:{errors:b}}=Jt(),h=m(e)??[],v=b[e],y=()=>{const S=a.trim();S&&!h.includes(S)&&p(e,[...h,S],{shouldDirty:!0}),c(""),d(!1)},C=S=>p(e,h.filter(_=>_!==S),{shouldDirty:!0});return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:q.chipGroup,children:[h.map(S=>l.jsxs("span",{className:"sbx-chip filled",children:[S,!n&&l.jsx("button",{type:"button",className:"sbx-chip-remove",onClick:()=>C(S),"aria-label":`Remove ${S}`,children:"×"})]},S)),!n&&(u?l.jsx("input",{ref:f,autoFocus:!0,className:q.chipInput,value:a,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),y()),S.key==="Escape"&&(c(""),d(!1))},onBlur:y,placeholder:o}):l.jsxs("button",{type:"button",className:q.addChipBtn,onClick:()=>{d(!0),setTimeout(()=>{var S;return(S=f.current)==null?void 0:S.focus()},50)},children:[l.jsx(Sn,{size:12})," ",i.chipGroupField.addButtonLabel]}))]}),v&&l.jsx("span",{className:q.error,children:String(v.message)})]})},kN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=oe(),{register:o,formState:{errors:a}}=Jt(),c=a[e];return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("div",{className:q.radioGroup,children:r.map(u=>l.jsxs("label",{className:q.radioLabel,children:[l.jsx("input",{type:"radio",value:u.value,disabled:s,...o(e,{required:n?i.radioField.requiredError.replace("{field}",t):!1})}),u.label]},u.value))}),c&&l.jsx("span",{className:q.error,children:String(c.message)})]})};async function IN(e,t,r,n){var o,a;const i=(a=(o=(await Fe.post("/action/asset/v1/create",{request:{asset:{primaryCategory:"asset",language:["English"],code:crypto.randomUUID(),name:e,mediaType:"image",mimeType:t,createdBy:r,creator:null,channel:n,keywords:""}}})).data)==null?void 0:o.result)==null?void 0:a.node_id;if(!i)throw new Error("Asset creation failed: no node_id returned");return i}async function DN(e,t){var s,i;const n=(i=(s=(await Fe.post(`/action/content/v3/upload/url/${e}`,{request:{content:{fileName:t}}})).data)==null?void 0:s.result)==null?void 0:i.pre_signed_url;if(!n)throw new Error("Pre-signed URL fetch failed");return n}async function LN(e,t,r={}){const n=await fetch(e,{method:"PUT",body:t,headers:{"x-ms-blob-type":"BlockBlob","Content-Type":"application/octet-stream",...r}});if(!n.ok)throw new Error(`Blob upload failed: ${n.status} ${n.statusText}`)}async function ON(e,t,r){var o,a;const n=new FormData;n.append("fileUrl",t),n.append("mimeType",r);const i=(a=(o=(await Fe.post(`/action/asset/v1/upload/${e}`,n,{params:{enctype:"multipart/form-data",processData:!1,contentType:!1,cache:!1}})).data)==null?void 0:o.result)==null?void 0:a.content_url;if(!i)throw new Error("Asset finalize failed: no content_url returned");return i}const NN="_overlay_1bq5u_1",jN="_modal_1bq5u_12",PN="_header_1bq5u_24",RN="_title_1bq5u_33",FN="_closeBtn_1bq5u_39",MN="_tabs_1bq5u_57",BN="_tab_1bq5u_57",qN="_activeTab_1bq5u_83",$N="_body_1bq5u_88",UN="_searchWrap_1bq5u_99",zN="_searchIcon_1bq5u_104",VN="_searchInput_1bq5u_113",HN="_grid_1bq5u_132",QN="_imgCell_1bq5u_148",WN="_imgCellSelected_1bq5u_166",GN="_thumb_1bq5u_171",KN="_noThumb_1bq5u_177",YN="_checkBadge_1bq5u_183",ZN="_loadMoreBtn_1bq5u_198",XN="_loadingRow_1bq5u_220",JN="_empty_1bq5u_230",ej="_spinner_1bq5u_237",tj="_uploadArea_1bq5u_247",rj="_dropZone_1bq5u_256",nj="_uploadIcon_1bq5u_277",sj="_dropText_1bq5u_281",ij="_dropSubtext_1bq5u_288",oj="_uploadPreview_1bq5u_294",aj="_hiddenInput_1bq5u_301",lj="_fileName_1bq5u_305",cj="_errorText_1bq5u_311",uj="_footer_1bq5u_318",dj="_cancelBtn_1bq5u_328",fj="_confirmBtn_1bq5u_345",Ee={overlay:NN,modal:jN,header:PN,title:RN,closeBtn:FN,tabs:MN,tab:BN,activeTab:qN,body:$N,searchWrap:UN,searchIcon:zN,searchInput:VN,grid:HN,imgCell:QN,imgCellSelected:WN,thumb:GN,noThumb:KN,checkBadge:YN,loadMoreBtn:ZN,loadingRow:XN,empty:JN,spinner:ej,uploadArea:tj,dropZone:rj,uploadIcon:nj,dropText:sj,dropSubtext:ij,uploadPreview:oj,hiddenInput:aj,fileName:lj,errorText:cj,footer:uj,cancelBtn:dj,confirmBtn:fj},Cd=18,Wp=({nodeId:e,currentValue:t,onSelect:r,onClose:n})=>{const s=oe(),[i,o]=g.useState("my"),[a,c]=g.useState(""),[u,d]=g.useState([]),[f,m]=g.useState(0),[p,b]=g.useState(!1),[h,v]=g.useState(null),[y,C]=g.useState(0),[S,_]=g.useState(null),[x,T]=g.useState(""),[D,E]=g.useState(!1),[j,P]=g.useState(""),O=g.useRef(null),N=K(F=>{var B,Z;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.channel)??""}),R=K(F=>{var B,Z;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.uid)??""}),M=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.cloudStorage)==null?void 0:he.presigned_headers)??{}}),$=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.config)==null?void 0:Z.assetConfig)==null?void 0:he.size)??1*1024*1024}),ee=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.config)==null?void 0:Z.assetConfig)==null?void 0:he.accepted)??"image/png,image/jpeg"}),H=g.useCallback(async(F,B,Z=!1)=>{var he;b(!0);try{const be={status:["Live"],mediaType:["image"],mimeType:["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml"]};i==="my"&&R&&(be.createdBy=R),N&&(be.channel=N);const le=((he=(await Fe.post("/action/composite/v3/search",{request:{filters:be,query:F,limit:Cd,offset:B,sort_by:{createdOn:"desc"},fields:["identifier","name","appIcon","artifactUrl","downloadUrl"]}},{headers:{"X-Source":"web"}})).data)==null?void 0:he.result)??{},ve=le.content??[];m(le.count??0),d(Te=>Z?[...Te,...ve]:ve)}catch{}finally{b(!1)}},[i,R,N]);g.useEffect(()=>{i!=="upload"&&(d([]),C(0),H(a,0))},[i]);const te=g.useRef(),de=F=>{c(F),clearTimeout(te.current),te.current=setTimeout(()=>{d([]),C(0),H(F,0)},400)},fe=()=>{const F=y+Cd;C(F),H(a,F,!0)},pe=()=>{const F=(h==null?void 0:h.artifactUrl)??(h==null?void 0:h.appIcon)??(h==null?void 0:h.downloadUrl)??"";F&&r(F)};g.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]);const ae=F=>{var he;const B=(he=F.target.files)==null?void 0:he[0];if(F.target.value="",!B)return;const Z=ee.split(",").map(be=>be.trim());if(!Z.includes(B.type)){const be=Z.map(me=>me.replace("image/","").toUpperCase()).join(", ");P(s.appIconPickerModal.invalidFileTypeError.replace("{types}",be));return}if(B.size>$){const be=($/1048576).toFixed(0);P(s.appIconPickerModal.fileTooLargeError.replace("{size}",be));return}x&&URL.revokeObjectURL(x),_(B),T(URL.createObjectURL(B)),P("")},we=async()=>{if(S){E(!0),P("");try{const F=await IN(S.name.split(".").slice(0,-1).join(".")||S.name,S.type,R,N),B=await DN(F,S.name);await LN(B,S,M);const Z=B.split("?")[0],he=await ON(F,Z,S.type);r(he)}catch(F){P(F instanceof Error?F.message:s.appIconPickerModal.uploadFailedError)}finally{E(!1)}}},ye=u.length<f;return l.jsx("div",{className:Ee.overlay,role:"dialog","aria-modal":"true","aria-label":s.appIconPickerModal.dialogAriaLabel,children:l.jsxs("div",{className:Ee.modal,children:[l.jsxs("div",{className:Ee.header,children:[l.jsx("span",{className:Ee.title,children:s.appIconPickerModal.title}),l.jsx("button",{className:Ee.closeBtn,onClick:n,"aria-label":s.appIconPickerModal.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Ee.tabs,role:"tablist",children:[l.jsx("button",{role:"tab","aria-selected":i==="my",className:`${Ee.tab} ${i==="my"?Ee.activeTab:""}`,onClick:()=>o("my"),children:s.appIconPickerModal.myImagesTab}),l.jsx("button",{role:"tab","aria-selected":i==="all",className:`${Ee.tab} ${i==="all"?Ee.activeTab:""}`,onClick:()=>o("all"),children:s.appIconPickerModal.allImagesTab}),l.jsxs("button",{role:"tab","aria-selected":i==="upload",className:`${Ee.tab} ${i==="upload"?Ee.activeTab:""}`,onClick:()=>o("upload"),children:[l.jsx(Ma,{size:13,style:{marginRight:4}}),s.appIconPickerModal.uploadTab]})]}),l.jsx("div",{className:Ee.body,children:i!=="upload"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ee.searchWrap,children:[l.jsx(Yi,{size:14,className:Ee.searchIcon}),l.jsx("input",{type:"search",className:Ee.searchInput,placeholder:s.appIconPickerModal.searchPlaceholder,value:a,onChange:F=>de(F.target.value)})]}),p&&u.length===0?l.jsxs("div",{className:Ee.loadingRow,children:[l.jsx(ki,{size:20,className:Ee.spinner}),l.jsx("span",{children:s.appIconPickerModal.loadingText})]}):u.length===0?l.jsx("div",{className:Ee.empty,children:s.appIconPickerModal.noImagesFound}):l.jsx("div",{className:Ee.grid,children:u.map(F=>{const B=F.appIcon??F.artifactUrl??F.downloadUrl??"",Z=(h==null?void 0:h.identifier)===F.identifier;return l.jsxs("button",{type:"button",className:`${Ee.imgCell} ${Z?Ee.imgCellSelected:""}`,onClick:()=>v(F),title:F.name,children:[B?l.jsx("img",{src:B,alt:F.name,className:Ee.thumb}):l.jsx("div",{className:Ee.noThumb,children:s.appIconPickerModal.noThumbnailText}),Z&&l.jsx("div",{className:Ee.checkBadge,children:l.jsx(bn,{size:12})})]},F.identifier)})}),ye&&!p&&l.jsx("button",{className:Ee.loadMoreBtn,onClick:fe,children:s.appIconPickerModal.loadMoreButton}),p&&u.length>0&&l.jsx("div",{className:Ee.loadingRow,children:l.jsx(ki,{size:16,className:Ee.spinner})})]}):l.jsxs("div",{className:Ee.uploadArea,children:[l.jsx("div",{className:Ee.dropZone,onClick:()=>{var F;return(F=O.current)==null?void 0:F.click()},onDragOver:F=>F.preventDefault(),onDrop:F=>{F.preventDefault();const B=F.dataTransfer.files[0];B&&ae({target:{files:[B],value:""}})},children:x?l.jsx("img",{src:x,alt:s.appIconPickerModal.previewAlt,className:Ee.uploadPreview}):l.jsxs(l.Fragment,{children:[l.jsx(Ma,{size:32,className:Ee.uploadIcon}),l.jsx("p",{className:Ee.dropText,children:s.appIconPickerModal.dropZoneText}),l.jsx("p",{className:Ee.dropSubtext,children:s.appIconPickerModal.acceptedTypesInfo.replace("{types}",ee.split(",").map(F=>F.replace("image/","").toUpperCase()).join(", ")).replace("{size}",($/(1024*1024)).toFixed(0))})]})}),l.jsx("input",{ref:O,type:"file",accept:ee,className:Ee.hiddenInput,onChange:ae}),S&&l.jsx("p",{className:Ee.fileName,children:S.name}),j&&l.jsx("p",{className:Ee.errorText,children:j})]})}),l.jsxs("div",{className:Ee.footer,children:[l.jsx("button",{className:Ee.cancelBtn,onClick:n,children:s.appIconPickerModal.cancelButton}),i==="upload"?l.jsx("button",{className:Ee.confirmBtn,disabled:!S||D,onClick:we,children:D?l.jsxs(l.Fragment,{children:[l.jsx(ki,{size:14,className:Ee.spinner})," ",s.appIconPickerModal.uploadingText]}):s.appIconPickerModal.uploadAndUseButton}):l.jsx("button",{className:Ee.confirmBtn,disabled:!h,onClick:pe,children:s.appIconPickerModal.useSelectedButton})]})]})})},hj=({name:e,label:t,nodeId:r,required:n,disabled:s})=>{const i=oe(),[o,a]=g.useState(!1),{watch:c,setValue:u,register:d,formState:{errors:f}}=Jt(),m=c(e),p=f[e],b=v=>{u(e,v,{shouldDirty:!0,shouldValidate:!0}),a(!1)},h=()=>{u(e,"",{shouldDirty:!0,shouldValidate:!0})};return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...d(e,{required:n?i.appIconField.requiredError.replace("{field}",t):!1})}),l.jsx("div",{className:q.iconWrap,role:"button",tabIndex:s?-1:0,"aria-label":i.appIconField.selectIconAriaLabel,onClick:()=>!s&&a(!0),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&!s&&a(!0)},children:m?l.jsx("img",{src:m,alt:i.appIconField.iconAlt,className:q.iconPreview}):l.jsxs("div",{className:q.iconPlaceholder,children:[l.jsx(qf,{size:20}),l.jsx("span",{children:i.appIconField.selectIconLabel})]})}),m&&!s&&l.jsxs("button",{type:"button",className:q.removeIconBtn,onClick:h,"aria-label":i.appIconField.removeIconAriaLabel,children:[l.jsx(So,{size:13}),l.jsx("span",{children:i.appIconField.removeLabel})]}),p&&l.jsx("span",{className:q.error,children:String(p.message)}),o&&l.jsx(Wp,{nodeId:r,currentValue:m,onSelect:b,onClose:()=>a(!1)})]})},pj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.dateTimeField.requiredError.replace("{field}",t):!1}});return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{id:e,type:"datetime-local",className:[q.input,a?q.inputError:""].join(" "),disabled:n,value:o.value??"",onChange:o.onChange,onBlur:o.onBlur,ref:o.ref}),a&&l.jsx("span",{className:q.error,children:String(a.message)})]})},mj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.keywordSuggestField.requiredError.replace("{field}",t):!1},defaultValue:[]}),[c,u]=g.useState(""),d=g.useRef(null),f=o.value??[],m=v=>{const y=v.trim();!y||f.includes(y)||o.onChange([...f,y])},p=v=>{o.onChange(f.filter(y=>y!==v))},b=v=>{v.key==="Enter"||v.key===","?(v.preventDefault(),m(c),u("")):v.key==="Backspace"&&c===""&&f.length>0&&p(f[f.length-1])},h=()=>{c.trim()&&(m(c),u("")),o.onBlur()};return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:[q.chipGroup,a?q.inputError:""].join(" "),onClick:()=>{var v;return!n&&((v=d.current)==null?void 0:v.focus())},style:{cursor:n?"not-allowed":"text"},children:[f.map(v=>l.jsxs("span",{className:q.tagChip,children:[v,!n&&l.jsx("button",{type:"button",className:q.tagChipRemove,onClick:y=>{y.stopPropagation(),p(v)},"aria-label":`Remove ${v}`,children:l.jsx(br,{size:11})})]},v)),!n&&l.jsx("input",{ref:d,className:q.chipInput,value:c,onChange:v=>u(v.target.value),onKeyDown:b,onBlur:h,placeholder:f.length===0?s.keywordSuggestField.inputPlaceholder:"",style:{flexGrow:1,minWidth:120}})]}),a&&l.jsx("span",{className:q.error,children:String(a.message)})]})},gj=({name:e,label:t,levels:r,required:n,disabled:s})=>{const i=oe(),{control:o}=Jt(),{field:a,fieldState:{error:c}}=ci({name:e,control:o,rules:{required:n?i.nestedSelectField.requiredError.replace("{field}",t):!1},defaultValue:{}}),u=a.value??{},d=(f,m,p)=>{const b={};for(let h=0;h<m;h++)b[r[h].code]=u[r[h].code]??"";b[f]=p;for(let h=m+1;h<r.length;h++)b[r[h].code]="";a.onChange(b)};return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("div",{className:q.nestedSelectRow,children:r.map((f,m)=>{const p=m>0&&!u[r[m-1].code];return l.jsxs("div",{className:q.field,style:{flex:1},children:[l.jsx("label",{className:q.label,htmlFor:`${e}_${f.code}`,children:f.label}),l.jsxs("select",{id:`${e}_${f.code}`,className:[q.input,c?q.inputError:""].join(" "),disabled:s||p,value:u[f.code]??"",onChange:b=>d(f.code,m,b.target.value),onBlur:a.onBlur,children:[l.jsx("option",{value:"",children:i.nestedSelectField.selectPlaceholder}),f.options.map(b=>l.jsx("option",{value:b.value,children:b.label},b.value))]})]},f.code)})}),c&&l.jsx("span",{className:q.error,children:String(c.message)})]})},Sd=[{label:"CC BY 4.0",value:"CC BY 4.0"},{label:"CC BY-SA 4.0",value:"CC BY-SA 4.0"},{label:"CC BY-NC 4.0",value:"CC BY-NC 4.0"},{label:"CC BY-NC-SA 4.0",value:"CC BY-NC-SA 4.0"},{label:"CC BY-ND 4.0",value:"CC BY-ND 4.0"},{label:"CC0 1.0 (Public Domain)",value:"CC0 1.0"}],vj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),[i,o]=g.useState(!1),a=g.useRef(null),{register:c,watch:u,setValue:d,formState:{errors:f}}=Jt(),m=u(e),p=Sd.find(v=>v.value===m),b=(p==null?void 0:p.label)??s.licenseSelectField.selectPlaceholder,h=f[e];return g.useEffect(()=>{if(!i)return;const v=y=>{var C;(C=a.current)!=null&&C.contains(y.target)||o(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[i]),l.jsxs("div",{className:q.field,ref:a,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...c(e,{required:r?s.licenseSelectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:n,className:[q.selectBtn,h?q.inputError:"",i?q.selectOpen:""].join(" "),onClick:()=>o(v=>!v),"aria-haspopup":"listbox","aria-expanded":i,children:[l.jsx("span",{className:m?q.selectedVal:q.placeholder,children:b}),l.jsx(Cn,{size:14,className:i?q.chevronUp:""})]}),i&&l.jsx("div",{className:q.dropdown,role:"listbox",children:Sd.map(v=>l.jsxs("button",{type:"button",role:"option","aria-selected":m===v.value,className:[q.option,m===v.value?q.optionSelected:""].join(" "),onClick:()=>{d(e,v.value,{shouldDirty:!0,shouldValidate:!0}),o(!1)},children:[l.jsx("span",{children:v.label}),m===v.value&&l.jsx(bn,{size:13})]},v.value))}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},yj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.dialcodeInputField.requiredError.replace("{field}",t):!1},defaultValue:""}),[c,u]=g.useState("idle"),[d,f]=g.useState(""),m=async()=>{const b=(o.value??"").trim();if(!b){u("invalid"),f(s.dialcodeInputField.enterCodeMessage);return}u("loading"),f("");try{const h=await bT(b),v=h==null?void 0:h.result,y=v==null?void 0:v.dialcodes;Array.isArray(y)&&y.length>0?(u("valid"),f(s.dialcodeInputField.validMessage)):(u("invalid"),f(s.dialcodeInputField.notFoundMessage))}catch{u("invalid"),f(s.dialcodeInputField.validationFailedMessage)}},p=()=>c==="loading"?l.jsx(ki,{size:16,className:q.dialcodeSpinner}):c==="valid"?l.jsx(Pf,{size:16,color:"var(--sbx-success, #2e7d32)"}):c==="invalid"?l.jsx(xy,{size:16,color:"var(--sbx-error)"}):null;return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:q.dialcodeRow,children:[l.jsx("input",{id:e,type:"text",className:[q.input,a?q.inputError:""].join(" "),disabled:n,value:o.value??"",onChange:b=>{o.onChange(b),u("idle"),f("")},onBlur:o.onBlur,ref:o.ref,placeholder:s.dialcodeInputField.placeholderExample,style:{flex:1}}),l.jsx("button",{type:"button",className:q.validateBtn,onClick:m,disabled:n||c==="loading","aria-label":s.dialcodeInputField.validateAriaLabel,children:c==="loading"?s.dialcodeInputField.validatingLabel:s.dialcodeInputField.validateButtonLabel}),p()]}),a&&l.jsx("span",{className:q.error,children:String(a.message)}),!a&&d&&l.jsx("span",{className:c==="valid"?q.dialcodeValid:q.error,children:d})]})},bj="_cards_1oc2m_1",Cj="_card_1oc2m_1",Sj="_cardActive_1oc2m_30",_j="_cardIcon_1oc2m_35",wj="_cardIconPrimary_1oc2m_46",xj="_cardIconHover_1oc2m_50",Tj="_radioDot_1oc2m_54",Ej="_radioDotActive_1oc2m_65",Aj="_cardTitle_1oc2m_70",kj="_cardTitleInk_1oc2m_76",Ij="_cardDescription_1oc2m_80",Dj="_cardDescriptionCharcoal_1oc2m_86",Bt={cards:bj,card:Cj,cardActive:Sj,cardIcon:_j,cardIconPrimary:wj,cardIconHover:xj,radioDot:Tj,radioDotActive:Ej,cardTitle:Aj,cardTitleInk:kj,cardDescription:Ij,cardDescriptionCharcoal:Dj},Lj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),o=[{value:"strict",Icon:$f,iconVariant:Bt.cardIconPrimary,title:s.learningPath.policyStrictLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyStrictDescription}),descriptionVariant:""},{value:"adaptive",Icon:Gy,iconVariant:Bt.cardIconPrimary,title:s.learningPath.policyAdaptiveLabel,titleVariant:Bt.cardTitleInk,description:l.jsxs(l.Fragment,{children:[s.learningPath.policyAdaptiveDescriptionPre,l.jsx("span",{className:q.required,children:"*"}),s.learningPath.policyAdaptiveDescriptionPost]}),descriptionVariant:Bt.cardDescriptionCharcoal},{value:"priorLearning",Icon:$y,iconVariant:Bt.cardIconHover,title:s.learningPath.policyPriorLearningLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyPriorLearningDescription}),descriptionVariant:""}];return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx(QL,{name:e,control:i,rules:{required:r?s.selectField.requiredError.replace("{field}",t):!1},render:({field:a})=>l.jsx("div",{className:Bt.cards,children:o.map(({value:c,Icon:u,iconVariant:d,title:f,titleVariant:m,description:p,descriptionVariant:b})=>{const h=a.value===c;return l.jsxs("button",{type:"button",disabled:n,className:[Bt.card,h?Bt.cardActive:""].join(" "),onClick:()=>a.onChange(c),children:[l.jsx("span",{className:[Bt.cardIcon,d].join(" "),children:l.jsx(u,{size:16})}),l.jsx("span",{className:[Bt.radioDot,h?Bt.radioDotActive:""].join(" ")}),l.jsx("span",{className:[Bt.cardTitle,m].join(" "),children:f}),l.jsx("span",{className:[Bt.cardDescription,b].join(" "),children:p})]},c)})})})]})},Oj="_form_lktqh_1",Nj="_formLp_lktqh_7",jj="_ungrouped_lktqh_12",Pj="_ungroupedLp_lktqh_23",Rj="_fullWidthField_lktqh_27",Fj="_noFields_lktqh_31",jn={form:Oj,formLp:Nj,ungrouped:jj,ungroupedLp:Pj,fullWidthField:Rj,noFields:Fj},Mj=({nodeMetadata:e,activeTab:t,isRoot:r,isFolder:n,editorMode:s,onFormValueChange:i,onFormStatusChange:o})=>{var qe,et,$e,We,tt,Gr,wn,cs,Kr;const a=oe(),c=K(w=>w.editorConfig),u=K(w=>w.editorProfile),d=u.key==="learningPath",f=K(w=>w.rootFormConfig),m=K(w=>w.unitFormConfig),p=K(w=>w.categoryMeta),b=K(w=>w.contentFramework),h=K(w=>w.contentTargetFWIds),{organisationFramework:v,targetFrameworks:y,isLoading:C}=Ao(b??((qe=c==null?void 0:c.context)==null?void 0:qe.framework),h??((et=c==null?void 0:c.context)==null?void 0:et.targetFWIds)),{frameworks:S,collectionAdditionalCategories:_,contentAdditionalCategories:x,defaultLicense:T,name:D}=uO(($e=c==null?void 0:c.context)==null?void 0:$e.channel),E=dO(((We=c==null?void 0:c.context)==null?void 0:We.userId)??((tt=c==null?void 0:c.context)==null?void 0:tt.uid)),j=cO(S,(Gr=p==null?void 0:p.frameworkMetadata)==null?void 0:Gr.orgFWType,(wn=c==null?void 0:c.context)==null?void 0:wn.channel),P={organisationFramework:v,targetFrameworks:y,orgFrameworks:j,channelAdditionalCategories:_},O=re(w=>w.selectedNodeId),N=re(w=>w.treeData),R=re(w=>w.treeCache),M=O?R[O]??{}:{},$={...e,...M},ee=g.useMemo(()=>{var A;if(!O)return 0;const w=[...N];for(;w.length;){const I=w.shift();if(I.id===O)return((A=I.children)==null?void 0:A.length)??0;I.children&&w.push(...I.children)}return 0},[N,O]),H=(c==null?void 0:c.config)??{},te=(c==null?void 0:c.context)??{},de={editorMode:s,editableFields:H.editableFields,objectType:H.objectType,setDefaultCopyRight:H.setDefaultCopyRight===!0,defaultLicense:te.defaultLicense??T,contextAdditionalCategories:te.additionalCategories,userFullName:((cs=te.user)==null?void 0:cs.fullName)??E,channelName:D,collectionAdditionalCategories:_,contentAdditionalCategories:x,childCount:ee,profile:u},fe=r?f:m,pe=fe||(((Kr=c==null?void 0:c.config.hierarchy)==null?void 0:Kr.formConfig)??[]),ae=zp(pe,$,P,r,de),we=ae.filter(w=>w.tab===t&&w.inputType!=="appIcon"&&w.visible!==!1),ye=lO({mode:"onChange",defaultValues:Object.fromEntries(ae.map(w=>{const A=["multiselect","chips","keywords","tagsinput"],I=["nestedselect"];return A.includes(w.inputType)?[w.code,w.currentValue??w.defaultValue??[]]:I.includes(w.inputType)?[w.code,w.currentValue??w.defaultValue??{}]:[w.code,w.currentValue??w.defaultValue??""]}))});MO(ye,ae);const{updateNode:F}=re(),B=g.useRef(ae);B.current=ae;const Z=g.useRef(O);Z.current=O;const he=g.useRef(i);he.current=i;const be=g.useRef(o);be.current=o;const me=g.useRef(typeof $.shuffle=="boolean"?$.shuffle:void 0),le=g.useRef($.name??"");le.current=$.name??"";const ve=g.useRef(s);ve.current=s;const Te=lr(),Y=g.useRef(Te==null?void 0:Te.code);Y.current=Te==null?void 0:Te.code;const ce=["review","read","sourcingreview","orgreview"];g.useEffect(()=>{const w=Z.current;if(w){const A=Object.fromEntries(B.current.filter(I=>I.currentValue!==void 0&&I.currentValue!==null).map(I=>[I.code,I.currentValue]));Object.keys(A).length>0&&F(w,A)}ye.trigger().then(()=>{const A=ye.formState.errors,I=B.current,U=Array.from(new Set(Object.keys(A).map(z=>{var W;return(W=I.find(V=>V.code===z))==null?void 0:W.tab}).filter(Boolean)));be.current(Object.keys(A).length===0,U)})},[]),g.useEffect(()=>{const w=ye.watch((A,{name:I})=>{const U=Z.current;if(!U)return;const z=B.current,W=new Set(z.map(se=>se.code));if(I&&W.has(I)){let se=ye.getValues(I);if(I==="dialcodes"&&(se=Array.isArray(se)?se:se?[se]:[]),I==="shuffle"&&(se===!0&&me.current===!1&&Se(a.sparkMetaForm.shuffleEnabledMessage,{icon:l.jsx(Bn,{size:16})}),me.current=se),I==="framework"&&r&&typeof se=="string"&&se){const Ge=K.getState();if(Ge.setContentFramework(se,Ge.contentTargetFWIds),d){const st=re.getState().pruneCoursesByFramework(se);st>0&&Se(a.learningPath.coursesRemovedFrameworkChangeToast.replace("{count}",String(st)),{icon:l.jsx(Bn,{size:16}),duration:5e3});const Vt=re.getState().clearLevelSkills(Y.current);Vt>0&&Se(a.learningPath.levelSkillsResetFrameworkChangeToast.replace("{count}",String(Vt)),{icon:l.jsx(Bn,{size:16}),duration:5e3})}}const je=FO(I,se);je&&(F(U,je),he.current(je))}else if(!I){const se=ye.getValues(),je=Object.fromEntries(Object.entries(se).filter(([st])=>W.has(st))),Ge=RO(je,{isReview:ce.includes(ve.current),nodeTitle:le.current});Object.keys(Ge).length>0&&(F(U,Ge),he.current(Ge))}const V=ye.formState.errors,ne=Array.from(new Set(Object.keys(V).map(se=>{var je;return(je=z.find(Ge=>Ge.code===se))==null?void 0:je.tab}).filter(Boolean)));be.current(Object.keys(V).length===0,ne)});return()=>w.unsubscribe()},[ye]),g.useEffect(()=>{for(const w of["author","creator","copyright","copyrightYear","license"]){const A=B.current.find(U=>U.code===w);if(!A||A.currentValue===void 0||A.currentValue===null||A.currentValue==="")continue;const I=ye.getValues(w);(I==null||I==="")&&ye.setValue(w,A.currentValue,{shouldDirty:!1})}},[E,D,ye]);const Q=we.reduce((w,A)=>{const I=w[w.length-1];return I&&I.section===A.section?I.fields.push(A):w.push({section:A.section,fields:[A]}),w},[]),Ce=w=>{const A={key:w.code,name:w.code,label:w.label,required:w.required,disabled:w.editable===!1};if(d&&w.code==="policy")return l.jsx("div",{className:jn.fullWidthField,children:l.jsx(Lj,{...A})},w.code);switch(w.inputType){case"textarea":return l.jsx(bd,{...A,multiline:!0,maxLength:w.maxLength});case"select":return l.jsx(TN,{...A,options:w.options??[]});case"multiselect":return l.jsx(EN,{...A,options:w.options??[]});case"chips":return l.jsx(AN,{...A});case"radio":return l.jsx(kN,{...A,options:w.options??[]});case"appIcon":return l.jsx(hj,{...A,nodeId:O??""});case"datepicker":case"datetime":return l.jsx(pj,{...A});case"keywords":case"tagsinput":return l.jsx(mj,{...A});case"nestedselect":return l.jsx(gj,{...A,levels:w.levels??[]});case"license":return l.jsx(vj,{...A});case"dialcode":return l.jsx(yj,{...A});default:return l.jsx(bd,{...A,maxLength:w.maxLength})}};return l.jsx(WL,{...ye,children:l.jsxs("div",{className:[jn.form,d?jn.formLp:""].filter(Boolean).join(" "),children:[Q.map((w,A)=>{const I=w.section?fO[w.section]:void 0;return I?l.jsx(HO,{title:I.title,description:I.description,children:w.fields.map(Ce)},w.section??A):l.jsx("div",{className:[jn.ungrouped,d?jn.ungroupedLp:""].filter(Boolean).join(" "),children:w.fields.map(Ce)},A)}),we.length===0&&!C&&l.jsx("p",{className:jn.noFields,children:a.sparkMetaForm.noFieldsMessage})]})})};function Gp(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function Bj(e,t){return e.reduce((r,n,s)=>{const i=t.get(n);return i&&(r[s]=i),r},Array(e.length))}function _i(e){return e!==null&&e>=0}function qj(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function $j(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Kp=e=>{let{rects:t,activeIndex:r,overIndex:n,index:s}=e;const i=Gp(t,n,r),o=t[s],a=i[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}},wi={scaleX:1,scaleY:1},Uj=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:s,rects:i,overIndex:o}=e;const a=(t=i[r])!=null?t:n;if(!a)return null;if(s===r){const u=i[o];return u?{x:0,y:r<o?u.top+u.height-(a.top+a.height):u.top-a.top,...wi}:null}const c=zj(i,s,r);return s>r&&s<=o?{x:0,y:-a.height-c,...wi}:s<r&&s>=o?{x:0,y:a.height+c,...wi}:{x:0,y:0,...wi}};function zj(e,t,r){const n=e[t],s=e[t-1],i=e[t+1];return n?r<t?s?n.top-(s.top+s.height):i?i.top-(n.top+n.height):0:i?i.top-(n.top+n.height):s?n.top-(s.top+s.height):0:0}const Yp="Sortable",Zp=g.createContext({activeIndex:-1,containerId:Yp,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Kp,disabled:{draggable:!1,droppable:!1}});function Vj(e){let{children:t,id:r,items:n,strategy:s=Kp,disabled:i=!1}=e;const{active:o,dragOverlay:a,droppableRects:c,over:u,measureDroppableContainers:d}=Nf(),f=Zs(Yp,r),m=a.rect!==null,p=g.useMemo(()=>n.map(T=>typeof T=="object"&&"id"in T?T.id:T),[n]),b=o!=null,h=o?p.indexOf(o.id):-1,v=u?p.indexOf(u.id):-1,y=g.useRef(p),C=!qj(p,y.current),S=v!==-1&&h===-1||C,_=$j(i);ir(()=>{C&&b&&d(p)},[C,p,b,d]),g.useEffect(()=>{y.current=p},[p]);const x=g.useMemo(()=>({activeIndex:h,containerId:f,disabled:_,disableTransforms:S,items:p,overIndex:v,useDragOverlay:m,sortedRects:Bj(p,c),strategy:s}),[h,f,_.draggable,_.droppable,S,p,v,c,m,s]);return g.createElement(Zp.Provider,{value:x},t)}const Hj=e=>{let{id:t,items:r,activeIndex:n,overIndex:s}=e;return Gp(r,n,s).indexOf(t)},Qj=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:s,items:i,newIndex:o,previousItems:a,previousContainerId:c,transition:u}=e;return!u||!n||a!==i&&s===o?!1:r?!0:o!==s&&t===c},Wj={duration:200,easing:"ease"},Xp="transform",Gj=Vr.Transition.toString({property:Xp,duration:0,easing:"linear"}),Kj={roleDescription:"sortable"};function Yj(e){let{disabled:t,index:r,node:n,rect:s}=e;const[i,o]=g.useState(null),a=g.useRef(r);return ir(()=>{if(!t&&r!==a.current&&n.current){const c=s.current;if(c){const u=os(n.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}r!==a.current&&(a.current=r)},[t,r,n,s]),g.useEffect(()=>{i&&o(null)},[i]),i}function Zj(e){let{animateLayoutChanges:t=Qj,attributes:r,disabled:n,data:s,getNewIndex:i=Hj,id:o,strategy:a,resizeObserverConfig:c,transition:u=Wj}=e;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:h,overIndex:v,useDragOverlay:y,strategy:C}=g.useContext(Zp),S=Xj(n,p),_=d.indexOf(o),x=g.useMemo(()=>({sortable:{containerId:f,index:_,items:d},...s}),[f,s,_,d]),T=g.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:D,node:E,isOver:j,setNodeRef:P}=ry({id:o,data:x,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:O,activatorEvent:N,activeNodeRect:R,attributes:M,setNodeRef:$,listeners:ee,isDragging:H,over:te,setActivatorNodeRef:de,transform:fe}=Of({id:o,data:x,attributes:{...Kj,...r},disabled:S.draggable}),pe=$g(P,$),ae=!!O,we=ae&&!b&&_i(m)&&_i(v),ye=!y&&H,F=ye&&we?fe:null,Z=we?F??(a??C)({rects:h,activeNodeRect:R,activeIndex:m,overIndex:v,index:_}):null,he=_i(m)&&_i(v)?i({id:o,items:d,activeIndex:m,overIndex:v}):_,be=O==null?void 0:O.id,me=g.useRef({activeId:be,items:d,newIndex:he,containerId:f}),le=d!==me.current.items,ve=t({active:O,containerId:f,isDragging:H,isSorting:ae,id:o,index:_,items:d,newIndex:me.current.newIndex,previousItems:me.current.items,previousContainerId:me.current.containerId,transition:u,wasDragging:me.current.activeId!=null}),Te=Yj({disabled:!ve,index:_,node:E,rect:D});return g.useEffect(()=>{ae&&me.current.newIndex!==he&&(me.current.newIndex=he),f!==me.current.containerId&&(me.current.containerId=f),d!==me.current.items&&(me.current.items=d)},[ae,he,f,d]),g.useEffect(()=>{if(be===me.current.activeId)return;if(be&&!me.current.activeId){me.current.activeId=be;return}const ce=setTimeout(()=>{me.current.activeId=be},50);return()=>clearTimeout(ce)},[be]),{active:O,activeIndex:m,attributes:M,data:x,rect:D,index:_,newIndex:he,items:d,isOver:j,isSorting:ae,isDragging:H,listeners:ee,node:E,overIndex:v,over:te,setNodeRef:pe,setActivatorNodeRef:de,setDroppableNodeRef:P,setDraggableNodeRef:$,transform:Te??Z,transition:Y()};function Y(){if(Te||le&&me.current.newIndex===_)return Gj;if(!(ye&&!fo(N)||!u)&&(ae||ve))return Vr.Transition.toString({...u,property:Xp})}}function Xj(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}function so(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Jj=[Oe.Down,Oe.Right,Oe.Up,Oe.Left],eP=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:i,over:o,scrollableAncestors:a}}=t;if(Jj.includes(e.code)){if(e.preventDefault(),!r||!n)return;const c=[];i.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=s.get(f.id);if(m)switch(e.code){case Oe.Down:n.top<m.top&&c.push(f);break;case Oe.Up:n.top>m.top&&c.push(f);break;case Oe.Left:n.left>m.left&&c.push(f);break;case Oe.Right:n.left<m.left&&c.push(f);break}});const u=sv({collisionRect:n,droppableRects:s,droppableContainers:c});let d=mf(u,"id");if(d===(o==null?void 0:o.id)&&u.length>1&&(d=u[1].id),d!=null){const f=i.get(r.id),m=i.get(d),p=m?s.get(m.id):null,b=m==null?void 0:m.node.current;if(b&&p&&f&&m){const v=ho(b).some((T,D)=>a[D]!==T),y=Jp(f,m),C=tP(f,m),S=v||!y?{x:0,y:0}:{x:C?n.width-p.width:0,y:C?n.height-p.height:0},_={x:p.left,y:p.top};return S.x&&S.y?_:Ps(_,S)}}}};function Jp(e,t){return!so(e)||!so(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function tP(e,t){return!so(e)||!so(t)||!Jp(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const rP="_row_1m6cn_1",nP="_removeBtn_1m6cn_14",sP="_grip_1m6cn_17",iP="_ctIcon_1m6cn_34",oP="_info_1m6cn_38",aP="_name_1m6cn_46",lP="_meta_1m6cn_55",Zr={row:rP,removeBtn:nP,grip:sP,ctIcon:iP,info:oP,name:aP,meta:lP},cP={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},uP=({item:e,onRemove:t,isEditable:r})=>{const n=oe(),s=oi(e),i=cP[s.key]??Wr,{attributes:o,listeners:a,setNodeRef:c,transform:u,transition:d,isDragging:f}=Zj({id:e.id,disabled:!r}),m={transform:Vr.Transform.toString(u),transition:d,opacity:f?.5:1};return l.jsxs("div",{ref:c,style:m,className:Zr.row,role:"listitem",children:[r&&l.jsx("span",{className:Zr.grip,...o,...a,"aria-label":n.contentRow.dragToReorderAriaLabel,children:l.jsx(Bf,{size:15})}),l.jsx("span",{className:[`sbx-ct-sq--${s.key}`,Zr.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(i,{size:14})}),l.jsxs("div",{className:Zr.info,children:[l.jsx("span",{className:Zr.name,title:e.name,children:e.name}),l.jsx("span",{className:Zr.meta,children:s.label})]}),l.jsx("span",{className:`sbx-ct-badge--${s.key}`,children:s.label}),r&&l.jsx("button",{type:"button",className:Zr.removeBtn,onClick:()=>t(e.id),"aria-label":n.contentRow.removeAriaLabel.replace("{name}",e.name),children:l.jsx(br,{size:14})})]})},dP="_container_pi4q5_1",fP="_header_pi4q5_7",hP="_heading_pi4q5_13",pP="_count_pi4q5_21",mP="_list_pi4q5_30",gP="_emptyState_pi4q5_36",vP="_skillPicker_pi4q5_52",yP="_skillsCovered_pi4q5_52",bP="_chips_pi4q5_64",CP="_chip_pi4q5_64",SP="_skillWarning_pi4q5_80",_P="_selectedSkills_pi4q5_85",wP="_skillPill_pi4q5_91",xP="_skillPillFlagged_pi4q5_103",TP="_skillPillUncovered_pi4q5_107",EP="_skillPillRemove_pi4q5_112",AP="_skillSearchBox_pi4q5_127",kP="_skillSearchWrap_pi4q5_132",IP="_searchIcon_pi4q5_147",DP="_skillSearchInput_pi4q5_152",LP="_skillDropdown_pi4q5_165",OP="_skillOption_pi4q5_179",NP="_skillCheckbox_pi4q5_201",jP="_skillCheckboxChecked_pi4q5_213",PP="_skillDropdownEmpty_pi4q5_218",RP="_skillPickerNote_pi4q5_224",FP="_emptyHint_pi4q5_229",MP="_assessmentsCard_pi4q5_242",BP="_assessmentSlots_pi4q5_254",qP="_assessmentItemRow_pi4q5_260",$P="_assessmentItemIcon_pi4q5_271",UP="_assessmentItemInfo_pi4q5_283",zP="_assessmentItemTitle_pi4q5_290",VP="_assessmentItemMeta_pi4q5_299",HP="_addRowIcon_pi4q5_304",QP="_assessmentItemBadge_pi4q5_316",WP="_menuWrap_pi4q5_327",GP="_menuBtn_pi4q5_332",KP="_dropmenu_pi4q5_345",YP="_dangerItem_pi4q5_375",ZP="_addRow_pi4q5_304",XP="_addRowAssessment_pi4q5_399",JP="_addRowText_pi4q5_406",eR="_requiredBadge_pi4q5_411",ue={container:dP,header:fP,heading:hP,count:pP,list:mP,emptyState:gP,skillPicker:vP,skillsCovered:yP,chips:bP,chip:CP,skillWarning:SP,selectedSkills:_P,skillPill:wP,skillPillFlagged:xP,skillPillUncovered:TP,skillPillRemove:EP,skillSearchBox:AP,skillSearchWrap:kP,searchIcon:IP,skillSearchInput:DP,skillDropdown:LP,skillOption:OP,skillCheckbox:NP,skillCheckboxChecked:jP,skillDropdownEmpty:PP,skillPickerNote:RP,emptyHint:FP,assessmentsCard:MP,assessmentSlots:BP,assessmentItemRow:qP,assessmentItemIcon:$P,assessmentItemInfo:UP,assessmentItemTitle:zP,assessmentItemMeta:VP,addRowIcon:HP,assessmentItemBadge:QP,menuWrap:WP,menuBtn:GP,dropmenu:KP,dangerItem:YP,addRow:ZP,addRowAssessment:XP,addRowText:JP,requiredBadge:eR},tR=({options:e,selected:t,outOfScope:r,uncovered:n,onChange:s,isEditable:i,description:o})=>{const a=oe(),[c,u]=g.useState(""),[d,f]=g.useState(!1),m=g.useRef(null);g.useEffect(()=>{if(!d)return;const v=y=>{var C;(C=m.current)!=null&&C.contains(y.target)||f(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]);const p=c?e.filter(v=>v.toLowerCase().includes(c.toLowerCase())):e,b=v=>{i&&s(t.includes(v)?t.filter(y=>y!==v):[...t,v])},h=v=>{i&&s(t.filter(y=>y!==v))};return l.jsxs("div",{className:ue.skillPicker,children:[l.jsxs("div",{className:ue.header,children:[l.jsx("span",{className:ue.heading,children:a.learningPath.skillsHeading}),l.jsx("span",{className:ue.count,children:t.length})]}),l.jsx("span",{className:ue.skillPickerNote,children:o}),r.length>0&&l.jsx("div",{className:ue.skillWarning,role:"alert",children:a.learningPath.skillsOutOfScopeWarning.replace("{skills}",r.join(", "))}),n.length>0&&l.jsx("div",{className:ue.skillWarning,role:"alert",children:a.learningPath.skillsUncoveredWarning.replace("{skills}",n.join(", "))}),t.length>0&&l.jsx("div",{className:ue.selectedSkills,children:t.map(v=>{const y=r.includes(v),C=n.includes(v);return l.jsxs("span",{className:[ue.skillPill,y?ue.skillPillFlagged:"",C?ue.skillPillUncovered:""].filter(Boolean).join(" "),title:C?a.learningPath.skillUncoveredPillTitle:void 0,children:[v,i&&l.jsx("button",{type:"button",className:ue.skillPillRemove,onClick:()=>h(v),"aria-label":a.learningPath.removeSkillAriaLabel.replace("{skill}",v),children:l.jsx(br,{size:11})})]},v)})}),i?l.jsxs("div",{className:ue.skillSearchBox,ref:m,children:[l.jsxs("div",{className:ue.skillSearchWrap,onClick:()=>f(!0),children:[l.jsx("input",{type:"search",className:ue.skillSearchInput,placeholder:a.learningPath.searchSkillsPlaceholder,value:c,onChange:v=>u(v.target.value),onFocus:()=>f(!0),"aria-label":a.learningPath.searchSkillsPlaceholder}),l.jsx(Yi,{size:14,className:ue.searchIcon})]}),d&&l.jsx("div",{className:ue.skillDropdown,role:"listbox",children:e.length===0?l.jsx("div",{className:ue.skillDropdownEmpty,children:a.learningPath.noSkillsAvailable}):p.length===0?l.jsx("div",{className:ue.skillDropdownEmpty,children:a.learningPath.noMatchingSkills}):p.map(v=>{const y=t.includes(v);return l.jsxs("button",{type:"button",role:"option","aria-selected":y,className:ue.skillOption,onClick:()=>b(v),children:[l.jsx("span",{className:[ue.skillCheckbox,y?ue.skillCheckboxChecked:""].join(" "),children:y&&l.jsx(bn,{size:12})}),v]},v)})})]}):t.length===0&&l.jsx("span",{className:ue.emptyHint,children:a.learningPath.noSkillsSelectedYet})]})},dl=({slot:e,isEditable:t})=>{const r=oe(),{pre:n,post:s,setActiveAssessmentSlot:i,deleteSlot:o}=Ql(),a=re(h=>h.selectNode),[c,u]=g.useState(!1),d=g.useRef(null),f=e==="pre"?n:s,m=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel;if(g.useEffect(()=>{if(!c)return;const h=v=>{var y;(y=d.current)!=null&&y.contains(v.target)||u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),!f.filled)return l.jsxs("button",{type:"button",className:[ue.addRow,ue.addRowAssessment].join(" "),disabled:!t,onClick:()=>i(e),children:[l.jsx("span",{className:ue.addRowIcon,children:l.jsx(Sn,{size:16})}),l.jsx("span",{className:ue.addRowText,children:r.learningPath.addAssessmentSlotButton.replace("{label}",m)}),f.required&&l.jsx("span",{className:ue.requiredBadge,children:r.learningPath.requiredSlotBadge})]});const p=e==="pre"?r.learningPath.skillCheckBadge:r.learningPath.outcomeCheckBadge,b=()=>f.level&&a(f.level.id);return l.jsxs("div",{className:ue.assessmentItemRow,role:"button",tabIndex:0,onClick:b,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),b())},children:[l.jsx("span",{className:ue.assessmentItemIcon,children:l.jsx(Qr,{size:16})}),l.jsxs("div",{className:ue.assessmentItemInfo,children:[l.jsx("span",{className:ue.assessmentItemTitle,children:f.courseName||r.learningPath.courseNameUnavailable}),l.jsxs("span",{className:ue.assessmentItemMeta,children:[m," · ",r.learningPath.assessmentCourseMeta]})]}),l.jsx("span",{className:ue.assessmentItemBadge,children:p}),t&&l.jsxs("div",{className:ue.menuWrap,ref:d,children:[l.jsx("button",{type:"button",className:ue.menuBtn,onClick:h=>{h.stopPropagation(),u(v=>!v)},"aria-label":r.treeNode.nodeOptionsAriaLabel,children:"⋮"}),c&&l.jsxs("div",{className:ue.dropmenu,onClick:h=>h.stopPropagation(),children:[l.jsxs("button",{type:"button",onClick:()=>{u(!1),f.level&&a(f.level.id)},children:[l.jsx(Ay,{size:12})," ",r.learningPath.viewCourseMenuItem]}),l.jsxs("button",{type:"button",className:ue.dangerItem,onClick:()=>{u(!1),o(e)},children:[l.jsx(So,{size:12})," ",r.treeNode.deleteMenuItem]})]})]})]})},rR=({editorMode:e,isRoot:t=!1})=>{const r=oe(),{selectedNodeId:n,getChildrenOf:s,getNodeById:i,reorderChildren:o,deleteNode:a,activeNodeMeta:c,updateNode:u,treeData:d}=re(),f=K(R=>R.editorProfile),m=n?s(n):[],p=e==="edit",b=n?i(n):void 0,h=f.competencyScoped,v=h&&!t&&!lt(b),y=h&&t,{scope:C,source:S}=ii(),_=lr(),x=_&&Array.isArray(c[_.code])?c[_.code]:[],T=S==="prior"?x.filter(R=>!C.includes(R)):[],D=y?Th(d[0],_==null?void 0:_.code):[],E=v?Eh(b,x,_==null?void 0:_.code):[],j=g.useCallback(R=>{!n||!(_!=null&&_.code)||u(n,{[_.code]:R},[_.code])},[n,_==null?void 0:_.code,u]),P=ff(ja(po,{activationConstraint:{distance:5}}),ja(Cl,{coordinateGetter:eP})),O=g.useCallback(R=>{const{active:M,over:$}=R;if(!$||M.id===$.id||!n)return;const ee=re.getState().getChildrenOf(n),H=ee.findIndex(de=>de.id===M.id),te=ee.findIndex(de=>de.id===$.id);H<0||te<0||o(n,H,te)},[n,o]),N=g.useCallback(R=>{window.confirm(r.unitContentList.removeConfirm)&&a(R)},[a,r.unitContentList.removeConfirm]);return n?l.jsxs("div",{className:ue.container,children:[y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ue.skillsCovered,children:[l.jsx("span",{className:ue.heading,children:r.learningPath.skillsCoveredHeading}),l.jsx("span",{className:ue.emptyHint,children:r.learningPath.skillsCoveredDescription}),D.length>0&&l.jsx("div",{className:ue.chips,children:D.map(R=>l.jsx("span",{className:ue.chip,children:R},R))}),D.length===0&&l.jsx("span",{className:ue.emptyHint,children:r.learningPath.noSkillsYet})]}),l.jsxs("div",{className:ue.assessmentsCard,children:[l.jsx("span",{className:ue.heading,children:r.learningPath.assessmentsCardHeading}),l.jsx("span",{className:ue.emptyHint,children:r.learningPath.assessmentsCardDescription}),l.jsxs("div",{className:ue.assessmentSlots,children:[l.jsx(dl,{slot:"pre",isEditable:p}),l.jsx(dl,{slot:"post",isEditable:p})]})]})]}),v&&l.jsx(tR,{options:C,selected:x,outOfScope:T,uncovered:E,onChange:j,isEditable:p,description:S==="prior"?r.learningPath.skillScopeFromPriorNote:r.learningPath.skillScopeManualNote}),!h&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ue.header,children:[l.jsx("span",{className:ue.heading,children:r.unitContentList.heading}),l.jsx("span",{className:ue.count,children:m.length})]}),m.length>0?l.jsx(Lf,{sensors:P,collisionDetection:nv,onDragEnd:O,children:l.jsx(Vj,{items:m.map(R=>R.id),strategy:Uj,children:l.jsx("div",{className:ue.list,role:"list",children:m.map(R=>l.jsx(uP,{item:R,onRemove:N,isEditable:p},R.id))})})}):l.jsxs("div",{className:ue.emptyState,children:[l.jsx("p",{children:r.unitContentList.emptyTitle}),l.jsx("span",{children:r.unitContentList.emptyHint})]}),p&&!lt(b)&&l.jsxs("button",{className:ue.addRow,type:"button","aria-label":r.unitContentList.addContentAriaLabel,children:[l.jsx(Sn,{size:14})," ",r.unitContentList.addContent]})]})]}):null},nR="_dropZone_ijo5w_1",sR="_active_ijo5w_14",_d={dropZone:nR,active:sR},iR=({isActive:e,label:t,nodeId:r,className:n})=>{const s=oe(),i=t??s.dropZone.dropHere;return l.jsx("div",{className:`${_d.dropZone} ${e?_d.active:""} ${n??""}`,"data-droppable":e?"true":void 0,"data-node-id":r,"aria-label":i,role:"region",children:l.jsx("span",{children:i})})},em=["identifier","name","mimeType","contentType","primaryCategory","appIcon","channel","organisation","pkgVersion"];async function oR(e){var o;const t={status:["Live"],...e.filters??{}};e.channel&&(t.channel=e.channel);const n=((o=(await Fe.post("/action/composite/v3/search",{request:{filters:t,query:e.query??"",limit:e.limit??20,offset:e.offset??0,sort_by:e.sortBy??{lastUpdatedOn:"desc"},fields:e.fields??em}},{headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:o.result)??{},s=new Set(["count","facets"]);return{content:Object.entries(n).filter(([a])=>!s.has(a)).flatMap(([,a])=>Array.isArray(a)?a:[]),count:n.count??0}}async function aR(e){var r,n;return(n=(r=(await Fe.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}const wd="application/vnd.sunbird.question";function xd(e){return{cardinality:"single",type:"integer",defaultValue:e.maxScore??1}}function tm(e,t,r){if(!e)return null;if(e.identifier===t)return{question:e,parent:r};for(const n of e.children??[]){const s=tm(n,t,e);if(s)return s}return null}function lR(e,t){const r=tm(e,t);if(!r)return null;const{question:n,parent:s}=r,i={...e,children:[n],childNodes:[t],shuffle:s==null?void 0:s.shuffle,showSolutions:(s==null?void 0:s.showSolutions)??"No",showFeedback:(s==null?void 0:s.showFeedback)??"No"};return(s==null?void 0:s.shuffle)===!0?i.maxScore=1:n.qType==="SA"?delete i.maxScore:n.maxScore!=null&&(i.maxScore=n.maxScore),i}function cR(e,t){const r=((t==null?void 0:t.enabled)??!0)&&!!e;return Jn({queryKey:["quml","questionset",e],enabled:r,queryFn:async()=>{const n=await vh(e),s=d=>{if(!d)return[];const f=d.mimeType===wd&&d.identifier?[d.identifier]:[],m=(d.children??[]).flatMap(s);return[...f,...m]},i=s(n),o=new Map;i.length&&(await e0(i)).forEach(f=>{const m=f.identifier;m&&o.set(m,f)});const a=d=>{if(!d)return d;if(d.mimeType===wd&&d.identifier){const f=o.get(d.identifier)??d,m=f.outcomeDeclaration;return m!=null&&m.maxScore||(f.outcomeDeclaration={...m??{},maxScore:xd(f)}),f}return Array.isArray(d.children)&&(d.children=d.children.map(f=>a(f))),d},c=a(n),u=c.outcomeDeclaration;return u!=null&&u.maxScore||(c.outcomeDeclaration={...u??{},maxScore:xd(c)}),c}})}const Td="/assets/quml-player/sunbird-quml-player.js",uR="/assets/quml-player/styles.css",Ed="sunbird-quml-player";function dR(e){const t=e.children??[];return t.length?t.every(n=>n.objectType==="Question")?[e]:t:[]}const ut=class ut{constructor(){ps(this,"eventHandlers",new WeakMap)}loadScript(){return ut.scriptLoaded||customElements.get(Ed)?(ut.scriptLoaded=!0,Promise.resolve()):(ut.scriptLoading||(ut.scriptLoading=new Promise((t,r)=>{const n=document.createElement("script");n.src=Td,n.setAttribute("data-quml-player-script","true"),n.onload=()=>{ut.scriptLoaded=!0,ut.scriptLoading=void 0,t()},n.onerror=()=>{ut.scriptLoading=void 0,r(new Error(`Failed to load QuML player script: ${Td}`))},document.body.appendChild(n)})),ut.scriptLoading)}loadStyles(){if(ut.stylesLoaded||document.querySelector('[data-quml-player-styles="true"]')){ut.stylesLoaded=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=uR,t.setAttribute("data-quml-player-styles","true"),document.head.appendChild(t),ut.stylesLoaded=!0}static unloadStyles(){var t;(t=document.querySelector('[data-quml-player-styles="true"]'))==null||t.remove(),ut.stylesLoaded=!1}async createConfig(t,r,n){var i,o,a;return await this.loadScript(),{context:{mode:(n==null?void 0:n.mode)??"play",host:"",pdata:{id:((i=r==null?void 0:r.pdata)==null?void 0:i.id)??"sunbird.portal",ver:((o=r==null?void 0:r.pdata)==null?void 0:o.ver)??"1.0",pid:((a=r==null?void 0:r.pdata)==null?void 0:a.pid)??"sunbird-portal"},contentId:t.identifier??"",sid:(r==null?void 0:r.sid)??"",uid:(r==null?void 0:r.uid)??(r==null?void 0:r.userId)??"",channel:(r==null?void 0:r.channel)??"",did:(r==null?void 0:r.did)??"",tags:(r==null?void 0:r.tags)??[],contextRollup:(n==null?void 0:n.contextRollup)??(r==null?void 0:r.rollup)??{},objectRollup:(n==null?void 0:n.objectRollup)??{},...n!=null&&n.cdata?{cdata:n.cdata}:{}},config:{language:"en"},data:{sections:dR(t),identifier:t.identifier??""},metadata:t}}createElement(t){this.loadStyles();const r=document.createElement(Ed);return r.setAttribute("player-config",JSON.stringify(t)),r.setAttribute("data-player-id",t.metadata.identifier??"quml"),r}attachEventListeners(t,r,n){this.removeEventListeners(t);const s=o=>r==null?void 0:r(o),i=o=>n==null?void 0:n(o.detail);t.addEventListener("playerEvent",s),t.addEventListener("telemetryEvent",i),this.eventHandlers.set(t,{player:s,telemetry:i})}removeEventListeners(t){const r=this.eventHandlers.get(t);r&&(t.removeEventListener("playerEvent",r.player),t.removeEventListener("telemetryEvent",r.telemetry),this.eventHandlers.delete(t))}};ps(ut,"scriptLoaded",!1),ps(ut,"scriptLoading"),ps(ut,"stylesLoaded",!1);let io=ut;const xi=new io,fR="_contentPlayerRoot_1rdfn_1",hR="_flowLayout_1rdfn_9",pR="_stage_1rdfn_13",mR="_aspectRatio_1rdfn_16",gR="_playerHeader_1rdfn_32",vR="_playerHeaderThumb_1rdfn_46",yR="_playerHeaderTitle_1rdfn_56",bR="_typeBadge_1rdfn_66",CR="_typeDot_1rdfn_105",SR="_playerFrame_1rdfn_125",_R="_coverOverlay_1rdfn_133",wR="_coverHidden_1rdfn_145",xR="_coverThumb_1rdfn_150",TR="_coverPlayRing_1rdfn_159",ER="_coverPlayIcon_1rdfn_172",AR="_coverLabel_1rdfn_181",kR="_coverSkeleton_1rdfn_187",IR="_playerWrapper_1rdfn_213",DR="_infoStrip_1rdfn_223",LR="_infoChip_1rdfn_239",OR="_infoChipLabel_1rdfn_258",NR="_infoChipIcon_1rdfn_267",jR="_playerError_1rdfn_273",PR="_playerErrorIcon_1rdfn_287",RR="_playerErrorMsg_1rdfn_292",FR="_qumlRoot_1rdfn_299",He={contentPlayerRoot:fR,flowLayout:hR,stage:pR,aspectRatio:mR,playerHeader:gR,playerHeaderThumb:vR,playerHeaderTitle:yR,typeBadge:bR,typeDot:CR,playerFrame:SR,coverOverlay:_R,coverHidden:wR,coverThumb:xR,coverPlayRing:TR,coverPlayIcon:ER,coverLabel:AR,coverSkeleton:kR,playerWrapper:IR,infoStrip:DR,infoChip:LR,infoChipLabel:OR,infoChipIcon:NR,playerError:jR,playerErrorIcon:PR,playerErrorMsg:RR,qumlRoot:FR},MR="application/vnd.sunbird.questionset";function BR(e,t){const r=new Map,n=i=>{for(const o of i)r.set(o.id,o),o.children&&n(o.children)};n(e);let s=r.get(t);for(;s;){if(s.mimeType===MR)return s.identifier;s=s.parent?r.get(s.parent):void 0}return null}const qR=[{key:"video",mimes:["video/mp4","video/webm","video/ogg"]},{key:"audio",mimes:["audio/mp3","audio/mpeg","audio/ogg","audio/wav"]},{key:"pdf",mimes:["application/pdf"]},{key:"epub",mimes:["application/epub"]},{key:"ecml",mimes:["application/vnd.ekstep.ecml-archive"]},{key:"h5p",mimes:["application/vnd.ekstep.h5p-archive"]},{key:"scorm",mimes:["application/vnd.ekstep.content-collection"]}];function $R(e){return qR.find(t=>t.mimes.includes(e))??{key:"other"}}function UR(e,t){switch(e){case"video":return t.contentPlayer.mimeLabelVideo;case"audio":return t.contentPlayer.mimeLabelAudio;case"pdf":return t.contentPlayer.mimeLabelPdf;case"epub":return t.contentPlayer.mimeLabelEpub;case"ecml":return t.contentPlayer.mimeLabelEcml;case"h5p":return t.contentPlayer.mimeLabelH5p;case"scorm":return t.contentPlayer.mimeLabelScorm;default:return t.contentPlayer.mimeLabelOther}}const zR={"pdf-player":["application/pdf"],"video-player":["video/mp4","video/webm"],"epub-player":["application/epub"]},VR={"pdf-player":"/assets/sunbird-pdf-player.js","video-player":"/assets/sunbird-video-player.js","epub-player":"/assets/sunbird-epub-player.js"},HR={"pdf-player":"sunbird-pdf-player","video-player":"sunbird-video-player","epub-player":"sunbird-epub-player"},QR="/content/preview/preview.html?webview=true&build_number=2.8.0.e552fcd";function ma(e){for(const[t,r]of Object.entries(zR))if(r.includes(e))return t;return"default-player"}function WR(e,t,r){var i;const n=r==null?void 0:r.context,s=t.mimeType??e.mimeType??"";return{context:{mode:"play",partner:[],pdata:{id:((i=n==null?void 0:n.pdata)==null?void 0:i.id)??"sunbird.portal",ver:1,pid:"sunbird-portal"},contentId:e.identifier,sid:(n==null?void 0:n.sid)??"",uid:(n==null?void 0:n.uid)??"",channel:(n==null?void 0:n.channel)??"",did:(n==null?void 0:n.did)??"",timeDiff:0,contextRollup:{},tags:[],app:[(n==null?void 0:n.channel)??""],dims:""},config:{showEndPage:!1,showStartPage:!0,host:"",overlay:{showUser:!1},splash:{text:"",icon:"",bgImage:"",webLink:""},sideMenu:{showDownload:!0,showExit:!1,showShare:!0},apislug:"/action",repos:["/sunbird-plugins/renderer"],plugins:[{id:"org.sunbird.iframeEvent",ver:1,type:"plugin"},{id:"org.sunbird.player.endpage",ver:1.1,type:"plugin"}],enableTelemetryValidation:!1},metadata:t,data:s==="application/vnd.ekstep.ecml-archive"?t.body??{}:{}}}function GR(e){return document.querySelector(`script[src="${e}"]`)?Promise.resolve():new Promise((t,r)=>{const n=document.createElement("script");n.src=e,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${e}`)),document.head.appendChild(n)})}async function KR(e,t,r=100){await GR(VR[t]??""),!customElements.get(e)&&await new Promise((n,s)=>{let i=0;const o=setInterval(()=>{i++,customElements.get(e)?(clearInterval(o),n()):i>=r&&(clearInterval(o),s(new Error(`Custom element <${e}> did not register`)))},100)})}const YR=[{key:"author",icon:Qy},{key:"license",icon:My},{key:"language",icon:Iy},{key:"gradeLevel",icon:By},{key:"subject",icon:Qr},{key:"contentType",icon:Vy}];function ZR(e,t){switch(e){case"author":return t.contentPlayer.infoFieldAuthor;case"license":return t.contentPlayer.infoFieldLicense;case"language":return t.contentPlayer.infoFieldLanguage;case"gradeLevel":return t.contentPlayer.infoFieldClass;case"subject":return t.contentPlayer.infoFieldSubject;case"contentType":return t.contentPlayer.infoFieldType;default:return e}}function XR({node:e}){const t=oe(),r=e.metadata??{},n=YR.flatMap(s=>{const i=r[s.key];if(!i)return[];const o=Array.isArray(i)?i.join(", "):String(i);return o?[{...s,label:ZR(s.key,t),val:o}]:[]});return n.length?l.jsx("div",{className:He.infoStrip,children:n.map(s=>l.jsxs("div",{className:He.infoChip,children:[s.icon&&l.jsx(s.icon,{size:13,className:He.infoChipIcon}),l.jsx("span",{className:He.infoChipLabel,children:s.label}),s.val]},s.key))}):null}function rm({node:e,hidden:t}){var s;const r=oe(),n=e.appIcon??((s=e.metadata)==null?void 0:s.appIcon);return l.jsx("div",{className:`${He.coverOverlay} ${t?He.coverHidden:""}`,children:n?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:n,alt:e.name,className:He.coverThumb}),l.jsx("div",{className:He.coverPlayRing,children:l.jsx("div",{className:He.coverPlayIcon})}),l.jsx("span",{className:He.coverLabel,children:r.contentPlayer.loadingPreview})]}):l.jsx("div",{className:He.coverSkeleton})})}function nm({message:e}){return l.jsxs("div",{className:He.playerError,children:[l.jsx(Hy,{size:28,className:He.playerErrorIcon}),l.jsx("span",{className:He.playerErrorMsg,children:e})]})}function JR({mimeType:e}){const t=oe(),r=$R(e);return l.jsxs("span",{className:He.typeBadge,"data-type":r.key,children:[l.jsx("span",{className:He.typeDot}),UR(r.key,t)]})}const fl=({node:e,editorMode:t,type:r,singleQuestion:n,layout:s="fill"})=>{var o;if(r==="quml")return l.jsx(tF,{node:e,editorMode:t,singleQuestion:!!n});const i=e.appIcon??((o=e.metadata)==null?void 0:o.appIcon);return l.jsxs("div",{className:`${He.contentPlayerRoot} ${s==="flow"?He.flowLayout:""}`,children:[l.jsxs("div",{className:He.stage,children:[l.jsxs("div",{className:He.playerHeader,children:[i&&l.jsx("img",{src:i,alt:"",className:He.playerHeaderThumb}),l.jsx("span",{className:He.playerHeaderTitle,children:e.name}),l.jsx(JR,{mimeType:e.mimeType??""})]}),l.jsx(eF,{node:e})]}),l.jsx(XR,{node:e})]})};function eF({node:e}){var y;const t=oe(),r=K(C=>C.editorConfig),[n,s]=g.useState(()=>ma(e.mimeType??"")),[i,o]=g.useState(!1),[a,c]=g.useState(null),[u,d]=g.useState(e.metadata??{}),[f,m]=g.useState(!1),p=g.useRef(null),b=g.useRef(null),h=((y=r==null?void 0:r.config)==null?void 0:y.previewCdnUrl)??QR;g.useEffect(()=>{let C=!1;return m(!1),o(!1),c(null),d(e.metadata??{}),s(ma(e.mimeType??"")),aR(e.identifier).then(S=>{if(C)return;const _={...e.metadata??{},...S};d(_);const x=S.mimeType??e.mimeType??"";s(ma(x)),m(!0)}).catch(()=>{C||m(!0)}),()=>{C=!0}},[e.identifier]);const v=WR(e,u,r);return g.useEffect(()=>{if(!f||n!=="default-player")return;const C=p.current;if(!C)return;C.src=h;const S=()=>{try{const x=C.contentWindow;if(typeof(x==null?void 0:x.initializePreview)!="function"){c(t.contentPlayer.previewPlayerUnavailable);return}x.initializePreview(v),setTimeout(()=>o(!0),300)}catch(x){console.error("[ContentPlayer] initializePreview failed",x),c(t.contentPlayer.failedToInitializePlayer)}},_=()=>c(t.contentPlayer.previewPlayerLoadFailed);return C.addEventListener("load",S),C.addEventListener("error",_),()=>{C.removeEventListener("load",S),C.removeEventListener("error",_),C.src=""}},[e.identifier,n,h,f,t]),g.useEffect(()=>{if(!f||n==="default-player")return;const C=b.current;if(!C)return;const S=HR[n];if(!S)return;const _=v;KR(S,n).then(()=>{if(!b.current)return;if(!customElements.get(S)){s("default-player");return}const x=document.createElement(S);x.setAttribute("player-config",JSON.stringify(_)),x.addEventListener("playerEvent",()=>{}),x.addEventListener("telemetryEvent",()=>{}),C.innerHTML="",C.appendChild(x),setTimeout(()=>{try{x.playerConfig=_}catch{}o(!0)},200)}).catch(()=>{console.warn(`[ContentPlayer] ${n} script unavailable, falling back to iframe`),s("default-player")})},[e.identifier,n,f]),l.jsxs("div",{className:He.aspectRatio,children:[a?l.jsx(nm,{message:a}):l.jsx(rm,{node:e,hidden:i}),n==="default-player"?l.jsx("iframe",{ref:p,id:"contentPlayer",title:e.name,className:He.playerFrame,name:"contentPlayer",allowFullScreen:!0}):l.jsx("div",{ref:b,className:He.playerFrame})]})}function tF({node:e,editorMode:t,singleQuestion:r}){const n=oe(),s=K(p=>p.editorConfig),i=re(p=>p.treeData),o=g.useRef(null),a=r?BR(i,e.id):e.identifier,{data:c,isLoading:u,error:d}=cR(a??"",{enabled:!!a}),f=g.useMemo(()=>c?r?lR(c,e.identifier):c:null,[c,r,e.identifier]);g.useEffect(()=>{const p=o.current;if(!p||!f)return;let b=null,h=!1;return(async()=>{try{const v=await xi.createConfig(f,s==null?void 0:s.context,{mode:t==="edit"?"edit":"play"});if(h||!o.current)return;const y=xi.createElement(v);b=y,xi.attachEventListeners(y,C=>console.debug("[QumlPlayer] playerEvent",C.detail),C=>console.debug("[QumlPlayer] telemetryEvent",C)),p.innerHTML="",p.appendChild(y)}catch(v){console.error("[QumlPlayer] failed to initialize",v)}})(),()=>{h=!0,b&&(xi.removeEventListeners(b),b.remove()),io.unloadStyles()}},[f,s,t,r]);const m=d?`${n.contentPlayer.unableToLoadQuestionset} ${d.message}`:r&&!a?n.contentPlayer.parentQuestionsetNotResolved:r&&c&&!f?n.contentPlayer.questionNotFoundInQuestionset:null;return l.jsxs("div",{className:He.qumlRoot,children:[m?l.jsx(nm,{message:m}):u||!f?l.jsx(rm,{node:e,hidden:!1}):null,l.jsx("div",{ref:o,className:He.playerWrapper})]})}const rF="_overlay_1b1xq_1",nF="_modal_1b1xq_11",sF="_header_1b1xq_21",iF="_body_1b1xq_37",oF="_hint_1b1xq_43",aF="_list_1b1xq_49",lF="_item_1b1xq_55",cF="_selected_1b1xq_68",uF="_empty_1b1xq_73",dF="_footer_1b1xq_79",fF="_cancelBtn_1b1xq_87",hF="_moveBtn_1b1xq_95",Gt={overlay:rF,modal:nF,header:sF,body:iF,hint:oF,list:aF,item:lF,selected:cF,empty:uF,footer:dF,cancelBtn:fF,moveBtn:hF};function pF(e,t,r){const n=[],s=i=>{var o;for(const a of i)a.isFolder&&a.id!==r&&a.id!==t&&n.push(a),(o=a.children)!=null&&o.length&&s(a.children)};return s(e),n}const mF=({resourceId:e,resourceName:t,currentUnitId:r,onClose:n})=>{var f;const s=oe(),{treeData:i,moveNode:o}=re(),a=pF(i,((f=i[0])==null?void 0:f.id)??"",r),[c,u]=g.useState(null),d=()=>{c&&(o(e,r,c),n())};return l.jsx("div",{className:Gt.overlay,role:"dialog","aria-label":s.resourceReorderDialog.dialogAriaLabel,children:l.jsxs("div",{className:Gt.modal,children:[l.jsxs("div",{className:Gt.header,children:[l.jsxs("span",{children:[s.resourceReorderDialog.moveHeaderPrefix,' "',t,'"']}),l.jsx("button",{onClick:n,"aria-label":s.resourceReorderDialog.closeAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsxs("div",{className:Gt.body,children:[l.jsx("p",{className:Gt.hint,children:s.resourceReorderDialog.selectUnitHint}),l.jsxs("ul",{className:Gt.list,children:[a.map(m=>l.jsxs("li",{className:`${Gt.item} ${c===m.id?Gt.selected:""}`,onClick:()=>u(m.id),children:[l.jsx(ky,{size:14}),l.jsx("span",{children:m.name})]},m.id)),a.length===0&&l.jsx("li",{className:Gt.empty,children:s.resourceReorderDialog.noUnitsAvailable})]})]}),l.jsxs("div",{className:Gt.footer,children:[l.jsx("button",{className:Gt.cancelBtn,onClick:n,children:s.resourceReorderDialog.cancelButton}),l.jsx("button",{className:Gt.moveBtn,onClick:d,disabled:!c,children:s.resourceReorderDialog.moveButton})]})]})})},gF="_overlay_1d56g_1",vF="_modal_1d56g_11",yF="_header_1d56g_21",bF="_body_1d56g_37",CF="_table_1d56g_43",SF="_pageInput_1d56g_61",_F="_empty_1d56g_68",wF="_footer_1d56g_74",xF="_cancelBtn_1d56g_82",TF="_saveBtn_1d56g_90",fr={overlay:gF,modal:vF,header:yF,body:bF,table:CF,pageInput:SF,empty:_F,footer:wF,cancelBtn:xF,saveBtn:TF};function EF(e){const t=[],r=n=>{var s;for(const i of n)!i.isFolder&&(!i.children||i.children.length===0)?t.push(i):(s=i.children)!=null&&s.length&&r(i.children)};return r(e),t}const AF=({onClose:e})=>{const t=oe(),{treeData:r,updateNode:n}=re(),s=EF(r),[i,o]=g.useState(()=>Object.fromEntries(s.map(c=>{var u;return[c.id,String(((u=c.metadata)==null?void 0:u.pageNumber)??"")]}))),a=g.useCallback(()=>{for(const[c,u]of Object.entries(i))u!==""&&n(c,{pageNumber:parseInt(u,10)||void 0});e()},[i,n,e]);return l.jsx("div",{className:fr.overlay,role:"dialog","aria-label":t.assignPageNumber.dialogAriaLabel,children:l.jsxs("div",{className:fr.modal,children:[l.jsxs("div",{className:fr.header,children:[l.jsx("span",{children:t.assignPageNumber.title}),l.jsx("button",{onClick:e,"aria-label":t.assignPageNumber.closeAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsx("div",{className:fr.body,children:s.length===0?l.jsx("p",{className:fr.empty,children:t.assignPageNumber.emptyState}):l.jsxs("table",{className:fr.table,children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:t.assignPageNumber.contentColumnHeader}),l.jsx("th",{children:t.assignPageNumber.pageNumberColumnHeader})]})}),l.jsx("tbody",{children:s.map(c=>l.jsxs("tr",{children:[l.jsx("td",{children:c.name}),l.jsx("td",{children:l.jsx("input",{type:"number",min:1,value:i[c.id]??"",onChange:u=>o(d=>({...d,[c.id]:u.target.value})),className:fr.pageInput})})]},c.id))})]})}),l.jsxs("div",{className:fr.footer,children:[l.jsx("button",{className:fr.cancelBtn,onClick:e,children:t.assignPageNumber.cancelButton}),l.jsxs("button",{className:fr.saveBtn,onClick:a,children:[l.jsx(Fy,{size:14})," ",t.assignPageNumber.saveButton]})]})]})})},kF="_container_p2feh_1",IF="_panelHeader_p2feh_10",DF="_panelHeaderLeft_p2feh_19",LF="_panelCollapseBtn_p2feh_27",OF="_titleRow_p2feh_46",NF="_field_p2feh_47",jF="_moveBtn_p2feh_64",PF="_icon_p2feh_84",RF="_nameInput_p2feh_93",FF="_fieldHeader_p2feh_118",MF="_label_p2feh_124",BF="_fieldCount_p2feh_133",qF="_chips_p2feh_170",$F="_chip_p2feh_170",UF="_chipRemove_p2feh_188",zF="_keywordInput_p2feh_202",VF="_input_p2feh_207",HF="_addBtn_p2feh_220",QF="_radioGroup_p2feh_234",WF="_radioLabel_p2feh_239",Ke={container:kF,panelHeader:IF,panelHeaderLeft:DF,panelCollapseBtn:LF,titleRow:OF,field:NF,moveBtn:jF,icon:PF,nameInput:RF,fieldHeader:FF,label:MF,fieldCount:BF,chips:qF,chip:$F,chipRemove:UF,keywordInput:zF,input:VF,addBtn:HF,radioGroup:QF,radioLabel:WF},GF=({node:e,editorMode:t,onMoveClick:r,reorderDialog:n})=>{var N,R;const{updateNode:s,markDirty:i}=re(),o=t==="edit",a=oi(e),c=oe(),u=K(M=>M.relationalFormConfig),d=M=>u==null?void 0:u.find($=>$.code===M),f=M=>!u||!!d(M),m=(M,$)=>{var ee;return((ee=d(M))==null?void 0:ee.label)||$},[p,b]=g.useState(!0),h=((N=e.metadata)==null?void 0:N.relationalMetadata)??{},[v,y]=g.useState(h.name??e.name??""),[C,S]=g.useState(""),[_,x]=g.useState(Array.isArray(h.keywords)?h.keywords:Array.isArray((R=e.metadata)==null?void 0:R.keywords)?e.metadata.keywords:[]),[T,D]=g.useState(!!h.optional);g.useEffect(()=>{var $,ee;const M=(($=e.metadata)==null?void 0:$.relationalMetadata)??{};y(M.name??e.name??""),x(Array.isArray(M.keywords)?M.keywords:Array.isArray((ee=e.metadata)==null?void 0:ee.keywords)?e.metadata.keywords:[]),D(!!M.optional)},[e.id]);const E=()=>{v.trim()&&v!==e.name&&(s(e.id,{name:v.trim()}),i())},j=()=>{const M=C.trim();if(M&&!_.includes(M)){const $=[..._,M];x($),s(e.id,{keywords:$}),i()}S("")},P=M=>{const $=_.filter(ee=>ee!==M);x($),s(e.id,{keywords:$}),i()},O=M=>{D(M),s(e.id,{optional:M}),i()};return l.jsxs("div",{className:Ke.container,children:[l.jsxs("div",{className:Ke.panelHeader,children:[l.jsxs("div",{className:Ke.panelHeaderLeft,children:[l.jsx("span",{className:`sbx-ct-badge--${a.key}`,children:a.label}),o&&l.jsx("button",{type:"button",className:Ke.moveBtn,onClick:r,children:c.contentEditForm.moveToAnotherUnitButton})]}),l.jsx("button",{type:"button",className:Ke.panelCollapseBtn,onClick:()=>b(M=>!M),"aria-expanded":p,"aria-label":p?c.contentEditForm.collapseMetadataPanelAriaLabel:c.contentEditForm.expandMetadataPanelAriaLabel,title:p?c.contentEditForm.collapseTitle:c.contentEditForm.expandTitle,children:p?l.jsx(Cn,{size:15}):l.jsx(wy,{size:15})})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ke.titleRow,children:[e.appIcon&&l.jsx("img",{src:e.appIcon,alt:c.contentEditForm.iconAlt,className:Ke.icon}),l.jsx("input",{type:"text",className:Ke.nameInput,value:v,disabled:!o,onChange:M=>y(M.target.value),onBlur:E,placeholder:c.contentEditForm.contentNamePlaceholder})]}),f("keywords")&&l.jsxs("div",{className:Ke.field,children:[l.jsx("div",{className:Ke.fieldHeader,children:l.jsxs("label",{className:Ke.label,children:[m("keywords",c.contentEditForm.keywordsLabel),_.length>0&&l.jsx("span",{className:Ke.fieldCount,children:_.length})]})}),_.length>0&&l.jsx("div",{className:Ke.chips,children:_.map(M=>l.jsxs("span",{className:Ke.chip,children:[M,o&&l.jsx("button",{type:"button",className:Ke.chipRemove,onClick:()=>P(M),children:"×"})]},M))}),o&&l.jsxs("div",{className:Ke.keywordInput,children:[l.jsx("input",{type:"text",className:Ke.input,value:C,placeholder:c.contentEditForm.addKeywordPlaceholder,onChange:M=>S(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),j())}}),l.jsx("button",{type:"button",className:Ke.addBtn,onClick:j,children:c.contentEditForm.addButton})]})]}),f("optional")&&l.jsxs("div",{className:Ke.field,children:[l.jsx("label",{className:Ke.label,children:m("optional",c.contentEditForm.optionalInCollectionLabel)}),l.jsxs("div",{className:Ke.radioGroup,children:[l.jsxs("label",{className:Ke.radioLabel,children:[l.jsx("input",{type:"radio",name:`optional-${e.id}`,checked:T===!0,onChange:()=>O(!0),disabled:!o}),c.contentEditForm.yesOption]}),l.jsxs("label",{className:Ke.radioLabel,children:[l.jsx("input",{type:"radio",name:`optional-${e.id}`,checked:T===!1,onChange:()=>O(!1),disabled:!o}),c.contentEditForm.noOption]})]})]})]}),n]})},KF="_iconBtn_gliz0_1",YF="_editable_gliz0_14",ZF="_iconImg_gliz0_26",XF="_placeholder_gliz0_34",JF="_removeBtn_gliz0_41",_s={iconBtn:KF,editable:YF,iconImg:ZF,placeholder:XF,removeBtn:JF},e2=({nodeId:e,value:t,editable:r})=>{const[n,s]=g.useState(!1),{updateNode:i,markDirty:o}=re(),a=oe(),c=d=>{i(e,{appIcon:d}),o(),s(!1)},u=d=>{d.stopPropagation(),i(e,{appIcon:""}),o()};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:[_s.iconBtn,r?_s.editable:""].filter(Boolean).join(" "),role:r?"button":void 0,tabIndex:r?0:-1,"aria-label":r?a.titleAppIcon.selectAppIconAriaLabel:a.titleAppIcon.appIconAriaLabel,onClick:()=>r&&s(!0),onKeyDown:d=>{r&&(d.key==="Enter"||d.key===" ")&&s(!0)},children:[t?l.jsx("img",{src:t,alt:a.titleAppIcon.appIconAlt,className:_s.iconImg}):l.jsx("div",{className:_s.placeholder,children:l.jsx(qf,{size:24})}),t&&r&&l.jsx("button",{type:"button",className:_s.removeBtn,onClick:u,"aria-label":a.titleAppIcon.removeIconAriaLabel,children:l.jsx(So,{size:11})})]}),n&&l.jsx(Wp,{nodeId:e,currentValue:t,onSelect:c,onClose:()=>s(!1)})]})},t2="_courseDetails_1eby7_1",r2="_courseDetailsLoading_1eby7_7",n2="_courseDetailsError_1eby7_7",s2="_detailsCard_1eby7_12",i2="_unitsCard_1eby7_12",o2="_cardTitle_1eby7_22",a2="_fieldGroup_1eby7_29",l2="_fieldGroupLast_1eby7_33",c2="_fieldLabel_1eby7_37",u2="_fieldValue_1eby7_47",d2="_fieldValueMultiline_1eby7_52",f2="_unitsLabel_1eby7_58",h2="_unitsDescription_1eby7_68",p2="_unitList_1eby7_74",m2="_unitCard_1eby7_80",g2="_unitHeader_1eby7_86",v2="_unitIcon_1eby7_99",y2="_unitTitle_1eby7_111",b2="_unitCount_1eby7_120",C2="_unitBody_1eby7_126",S2="_unitDescription_1eby7_131",_2="_unitKeywords_1eby7_138",w2="_keywordPill_1eby7_145",x2="_unitTopicsRow_1eby7_155",T2="_unitContents_1eby7_167",E2="_contentRow_1eby7_174",A2="_contentIcon_1eby7_180",k2="_contentTitle_1eby7_185",I2="_contentSkills_1eby7_193",D2="_skillPill_1eby7_200",Ne={courseDetails:t2,courseDetailsLoading:r2,courseDetailsError:n2,detailsCard:s2,unitsCard:i2,cardTitle:o2,fieldGroup:a2,fieldGroupLast:l2,fieldLabel:c2,fieldValue:u2,fieldValueMultiline:d2,unitsLabel:f2,unitsDescription:h2,unitList:p2,unitCard:m2,unitHeader:g2,unitIcon:v2,unitTitle:y2,unitCount:b2,unitBody:C2,unitDescription:S2,unitKeywords:_2,keywordPill:w2,unitTopicsRow:x2,unitContents:T2,contentRow:E2,contentIcon:A2,contentTitle:k2,contentSkills:I2,skillPill:D2},L2={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr};function ga(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}const sm=({courseId:e,variant:t="compact",title:r,onLoaded:n})=>{const s=oe(),i=lr(),[o,a]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(null),[m,p]=g.useState({}),b=t==="full";g.useEffect(()=>{let C=!1;return a(null),u(""),f(null),bh(e).then(S=>{if(C)return;const x=(S.children??[]).map(T=>Eo(T));a(x),u(S.description??""),p(Object.fromEntries(x.map(T=>[T.id,!0]))),n==null||n({totalContents:x.reduce((T,D)=>{var E;return T+(((E=D.children)==null?void 0:E.length)??0)},0)})}).catch(()=>{C||f(s.learningPath.courseDetailsError)}),()=>{C=!0}},[e,s.learningPath.courseDetailsError]);const h=C=>p(S=>({...S,[C]:!S[C]})),v=C=>{var S;return i?ga((S=C.metadata)==null?void 0:S[i.code]):[]},y=C=>(C===1?s.learningPath.contentCountLabel:s.learningPath.contentCountLabelPlural).replace("{count}",String(C));return l.jsx("div",{className:Ne.courseDetails,children:d?l.jsx("p",{className:Ne.courseDetailsError,children:d}):o===null?l.jsx("p",{className:Ne.courseDetailsLoading,children:s.learningPath.courseDetailsLoading}):l.jsxs(l.Fragment,{children:[b&&l.jsxs("div",{className:Ne.detailsCard,children:[l.jsx("h3",{className:Ne.cardTitle,children:s.learningPath.courseDetailsCardTitle}),l.jsxs("div",{className:Ne.fieldGroup,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.courseTitleFieldLabel}),l.jsx("div",{className:Ne.fieldValue,children:r})]}),l.jsxs("div",{className:Ne.fieldGroupLast,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.courseDescriptionFieldLabel}),l.jsx("div",{className:Ne.fieldValueMultiline,children:c||s.learningPath.noCourseDescriptionPlaceholder})]})]}),o.length===0?l.jsx("p",{className:Ne.courseDetailsLoading,children:s.learningPath.courseDetailsEmpty}):l.jsxs("div",{className:b?Ne.unitsCard:void 0,children:[l.jsx("span",{className:Ne.unitsLabel,children:s.learningPath.unitsSectionLabel}),b&&l.jsx("p",{className:Ne.unitsDescription,children:s.learningPath.unitsSectionDescription}),l.jsx("div",{className:Ne.unitList,children:o.map(C=>{var D,E;const S=!!m[C.id],_=(C.children??[]).length,x=ga((D=C.metadata)==null?void 0:D.keywords),T=ga((E=C.metadata)==null?void 0:E.topic);return l.jsxs("div",{className:Ne.unitCard,children:[l.jsxs("button",{type:"button",className:Ne.unitHeader,onClick:()=>h(C.id),"aria-expanded":S,children:[S?l.jsx(Cn,{size:17}):l.jsx(xl,{size:17}),l.jsx("span",{className:Ne.unitIcon,children:l.jsx(Mf,{size:16})}),l.jsx("span",{className:Ne.unitTitle,children:C.name}),b&&l.jsx("span",{className:Ne.unitCount,children:y(_)})]}),S&&l.jsxs("div",{className:Ne.unitBody,children:[b&&C.description&&l.jsx("p",{className:Ne.unitDescription,children:C.description}),b&&x.length>0&&l.jsx("div",{className:Ne.unitKeywords,children:x.map(j=>l.jsx("span",{className:Ne.keywordPill,children:j},j))}),b&&T.length>0&&l.jsxs("div",{className:Ne.unitTopicsRow,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.unitTopicsFieldLabel}),l.jsx("span",{children:T.join(", ")})]}),l.jsx("div",{className:Ne.unitContents,children:(C.children??[]).map(j=>{const P=oi(j),O=L2[P.key]??Wr,N=v(j);return l.jsxs("div",{className:Ne.contentRow,children:[l.jsx(O,{size:16,className:Ne.contentIcon}),l.jsx("span",{className:Ne.contentTitle,children:j.name}),N.length>0&&l.jsx("div",{className:Ne.contentSkills,children:N.map(R=>l.jsx("span",{className:Ne.skillPill,children:R},R))})]},j.id)})})]})]},C.id)})})]})]})})},O2="_backToPathButton_42cuj_1",N2="_assessmentTitle_42cuj_15",j2="_slotPills_42cuj_22",P2="_slotPill_42cuj_22",R2="_slotPillHint_42cuj_40",F2="_slotPillPurpose_42cuj_45",M2="_slotPillWarning_42cuj_51",B2="_slotPillPrimary_42cuj_56",q2="_courseCard_42cuj_62",$2="_courseCardHeading_42cuj_72",U2="_courseCardDescription_42cuj_79",z2="_courseNotAdded_42cuj_85",V2="_assessmentExplainer_42cuj_93",H2="_assessmentExplainerHeading_42cuj_107",Q2="_leafContentLayout_42cuj_117",W2="_container_42cuj_131",G2="_emptyState_42cuj_140",K2="_titleRow_42cuj_150",Y2="_titleRowLp_42cuj_157",Z2="_nodeTitle_42cuj_171",X2="_nodeTitleLpRoot_42cuj_193",J2="_nodeTitleSub_42cuj_198",eM="_courseDetailHeader_42cuj_203",tM="_courseDetailIcon_42cuj_210",rM="_courseDetailTitle_42cuj_222",nM="_courseDetailMeta_42cuj_229",sM="_formArea_42cuj_234",iM="_contentListArea_42cuj_238",oM="_contentListAreaLp_42cuj_242",aM="_dropZone_42cuj_246",lM="_reviewComment_42cuj_253",cM="_reviewCommentLabel_42cuj_266",uM="_reviewCommentText_42cuj_272",ke={backToPathButton:O2,assessmentTitle:N2,slotPills:j2,slotPill:P2,slotPillHint:R2,slotPillPurpose:F2,slotPillWarning:M2,slotPillPrimary:B2,courseCard:q2,courseCardHeading:$2,courseCardDescription:U2,courseNotAdded:z2,assessmentExplainer:V2,assessmentExplainerHeading:H2,leafContentLayout:Q2,container:W2,emptyState:G2,titleRow:K2,titleRowLp:Y2,nodeTitle:Z2,nodeTitleLpRoot:X2,nodeTitleSub:J2,courseDetailHeader:eM,courseDetailIcon:tM,courseDetailTitle:rM,courseDetailMeta:nM,formArea:sM,contentListArea:iM,contentListAreaLp:oM,dropZone:aM,reviewComment:lM,reviewCommentLabel:cM,reviewCommentText:uM},dM=({slot:e,isEditable:t})=>{var p;const r=oe(),n=re(b=>b.treeData),s=re(b=>b.selectNode),i=(p=n[0])==null?void 0:p.id,{pre:o,post:a}=Ql(),c=(e==="pre"?o:a).filled,u=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel,d=e==="pre"?Bn:Sy,f=e==="pre"?r.learningPath.priorAssessmentExplainerTitle:r.learningPath.outcomeAssessmentExplainerTitle,m=e==="pre"?r.learningPath.priorAssessmentExplainerBody:r.learningPath.outcomeAssessmentExplainerBody;return l.jsxs("div",{className:ke.container,children:[l.jsxs("button",{type:"button",className:ke.backToPathButton,onClick:()=>i&&s(i),children:[l.jsx(wl,{size:14})," ",r.learningPath.backToPathButton]}),l.jsx("div",{className:ke.assessmentTitle,children:u}),l.jsx("div",{className:ke.slotPills,children:e==="pre"?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillHint}`,children:[l.jsx(Ec,{size:12})," ",r.learningPath.priorAssessmentHint]}),l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillPurpose}`,children:[l.jsx(by,{size:12})," ",r.learningPath.priorAssessmentPurposeLabel]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillWarning}`,children:[l.jsx($f,{size:12})," ",r.learningPath.outcomeUnlocksHint]}),l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillPrimary}`,children:[l.jsx(Ec,{size:12})," ",r.learningPath.outcomeAssessmentHint]})]})}),l.jsxs("div",{className:ke.formArea,children:[l.jsxs("div",{className:ke.courseCard,children:[l.jsx("div",{className:ke.courseCardHeading,children:r.learningPath.assessmentCourseSectionTitle}),l.jsx("p",{className:ke.courseCardDescription,children:r.learningPath.assessmentCourseSectionDescription}),c?l.jsx(dl,{slot:e,isEditable:t}):l.jsx("div",{className:ke.courseNotAdded,children:r.learningPath.assessmentNotAddedYet})]}),l.jsxs("div",{className:ke.assessmentExplainer,children:[l.jsxs("div",{className:ke.assessmentExplainerHeading,children:[l.jsx(d,{size:16}),l.jsx("span",{children:f})]}),l.jsx("p",{children:m})]})]})]})},fM="application/vnd.sunbird.questionset",im="application/vnd.sunbird.question",hM=[fM,im];function Ad(e){var t,r;if(!(!e||e.status!=="Draft"||((t=e.metadata)==null?void 0:t.prevStatus)!=="Review"))return(r=e.metadata)==null?void 0:r.rejectComment}const pM=({editorMode:e,onToolbarEvent:t})=>{var fe,pe,ae,we,ye;const r=oe(),[n,s]=g.useState("details"),[i,o]=g.useState([]),[a,c]=g.useState(null),[u,d]=g.useState(!1),[f,m]=g.useState(null),p=g.useRef(null),b=g.useRef(),{selectedNodeId:h,breadcrumb:v,activeNodeMeta:y,updateNode:C,treeData:S,selectNode:_}=re(),x=yr(F=>F.activeAssessmentSlot),T=K(F=>{var B,Z,he,be;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.contentId)??((be=(he=F.editorConfig)==null?void 0:he.context)==null?void 0:be.identifier)??""}),D=K(F=>F.editorProfile.competencyScoped),E=h?om(S,h):null;g.useEffect(()=>{m(null)},[E==null?void 0:E.identifier]);const j=!!E&&!E.parent,P=!!(E!=null&&E.isFolder),O=E&&hM.includes(E.mimeType??""),N=(E==null?void 0:E.mimeType)===im,R=E&&!E.isFolder&&!O&&!j,$=D&&P&<(E??void 0)?((ae=(pe=(fe=S[0])==null?void 0:fe.children)==null?void 0:pe[0])==null?void 0:ae.id)===(E==null?void 0:E.id)?"pre":"post":D?x:null,ee=Ad(E)??(j?Ad(S[0]):void 0),H=g.useCallback(()=>{const F=p.current;if(!F||!h)return;const B=F.innerText.trim();clearTimeout(b.current),b.current=setTimeout(()=>{C(h,{name:B})},600)},[h,C]),te=g.useCallback(F=>{t({action:"onFormValueChange",data:F})},[t]),de=g.useCallback((F,B)=>{o(B),t({action:"onFormStatusChange",data:{isValid:F,nodeId:h}})},[t,h]);if(!E)return l.jsx("div",{className:ke.emptyState,children:l.jsx("p",{children:r.contextualEditor.emptyStateMessage})});if(O)return l.jsx(fl,{node:E,editorMode:e,type:"quml",singleQuestion:N});if(D&&R&&E.primaryCategory==="Course"){const F=E.parent?d0(((we=S[0])==null?void 0:we.children)??[],E.parent):null,B=(F==null?void 0:F.role)==="pre"?r.learningPath.priorAssessmentLabel:(F==null?void 0:F.role)==="post"?r.learningPath.outcomeAssessmentLabel:(F==null?void 0:F.role)==="level"?r.learningPath.levelNumberPrefix.replace("{n}",String(F.levelNumber)):null,Z=f===null?"":` · ${(f===1?r.learningPath.contentCountLabel:r.learningPath.contentCountLabelPlural).replace("{count}",String(f))}`;return l.jsxs("div",{className:ke.container,children:[l.jsxs("button",{type:"button",className:ke.backToPathButton,onClick:()=>E.parent&&_(E.parent),children:[l.jsx(wl,{size:14}),B?r.learningPath.backToLevelButton.replace("{label}",B):r.learningPath.backToPathButton]}),l.jsxs("div",{className:ke.courseDetailHeader,children:[l.jsx("span",{className:ke.courseDetailIcon,children:l.jsx(Qr,{size:26})}),l.jsxs("div",{children:[l.jsx("h2",{className:ke.courseDetailTitle,children:E.name}),l.jsxs("span",{className:ke.courseDetailMeta,children:[E.primaryCategory,Z]})]})]}),l.jsx(sm,{courseId:E.identifier,variant:"full",title:E.name,onLoaded:({totalContents:he})=>m(he)},E.identifier)]})}return $?l.jsx(dM,{slot:$,isEditable:e==="edit"}):R?l.jsxs("div",{className:ke.leafContentLayout,children:[l.jsx(fl,{node:E,editorMode:e,type:"content",layout:"flow"}),l.jsx(GF,{node:E,editorMode:e,onMoveClick:()=>c(E.identifier),reorderDialog:a?l.jsx(mF,{resourceId:a,resourceName:E.name,currentUnitId:E.parent??"",onClose:()=>c(null)}):null})]}):l.jsxs("div",{className:ke.container,children:[l.jsx(FL,{crumbs:v}),ee&&l.jsxs("div",{className:ke.reviewComment,role:"alert",children:[l.jsx("span",{className:ke.reviewCommentLabel,children:r.contextualEditor.reviewCommentLabel}),l.jsx("span",{className:ke.reviewCommentText,children:ee})]}),l.jsxs("div",{className:[ke.titleRow,D?ke.titleRowLp:""].filter(Boolean).join(" "),children:[j&&h&&l.jsx(e2,{nodeId:h,value:String(E.appIcon??((ye=E.metadata)==null?void 0:ye.appIcon)??""),editable:e==="edit"}),l.jsx("div",{ref:p,className:[ke.nodeTitle,D&&j?ke.nodeTitleLpRoot:"",D&&!j?ke.nodeTitleSub:""].filter(Boolean).join(" "),contentEditable:e==="edit",suppressContentEditableWarning:!0,onInput:H,onBlur:H,"data-placeholder":r.contextualEditor.untitledPlaceholder,"aria-label":r.contextualEditor.nodeTitleAriaLabel,children:E.name})]}),l.jsx(zL,{activeTab:n,onChange:F=>s(F),errorTabs:i,visibleTabs:j&&!D?void 0:["details"]}),l.jsx("div",{className:ke.formArea,children:l.jsx(Mj,{nodeMetadata:y,activeTab:n,isRoot:j,isFolder:P,editorMode:e,onFormValueChange:te,onFormStatusChange:de},`${h??"none"}:${j?"root":"node"}`)}),(P||j)&&n==="details"&&l.jsx("div",{className:[ke.contentListArea,D?ke.contentListAreaLp:""].filter(Boolean).join(" "),children:l.jsx(rR,{editorMode:e,isRoot:j})}),l.jsx(iR,{isActive:!1,label:r.contextualEditor.dropZoneLabel,nodeId:h??void 0,className:ke.dropZone}),u&&l.jsx(AF,{contentId:T,onClose:()=>d(!1)})]})};function om(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=om(r.children,t);if(n)return n}}}const am=ei((e,t)=>({allContent:[],filteredContent:[],searchQuery:"",activeFilter:"all",advancedFilters:{},isLoading:!1,totalCount:0,offset:0,sortAZ:!1,setContent:(r,n)=>{e({allContent:r,totalCount:n,offset:r.length}),t().applyFilter()},appendContent:(r,n)=>{const i=[...t().allContent,...r];e({allContent:i,totalCount:n,offset:i.length}),t().applyFilter()},setFilter:r=>{e({activeFilter:r}),t().applyFilter()},setSearch:r=>{e({searchQuery:r}),t().applyFilter()},setLoading:r=>e({isLoading:r}),setAdvancedFilters:r=>e({advancedFilters:r}),setOffset:r=>e({offset:r}),setSortAZ:r=>e({sortAZ:r}),applyFilter:()=>{const{allContent:r,activeFilter:n,searchQuery:s}=t();let i=r;if(n&&n!=="all"){const o=n.toLowerCase();i=i.filter(a=>[a.mimeType??"",a.primaryCategory??"",a.contentType??""].join(" ").toLowerCase().includes(o))}if(s&&s.trim()!==""){const o=s.toLowerCase().trim();i=i.filter(a=>(a.name??"").toLowerCase().includes(o))}e({filteredContent:i})}}));function mM(e,t,r,n){const s={primaryCategory:["Course"]};return n&&(s.framework=[n]),!e&&t.length&&r&&(s[r]=t),s}function gM(e,t){if(!(!e||!t))return[...em,t,"framework"]}function vM(e,t,r,n,s){return e?t?r&&!n&&s.length===0?"noSkills":null:"noCurriculum":null}const yM=20,bM=[];function lm(){var u;const e=K(d=>d.editorConfig),t=re(d=>d.selectedNodeId),r=re(d=>d.treeData),n=g.useCallback(()=>{if(!t||!r.length)return 0;function d(f,m,p=0){var b;for(const h of f){if(h.id===m)return p;if((b=h.children)!=null&&b.length){const v=d(h.children,m,p+1);if(v>=0)return v}}return-1}return Math.max(0,d(r,t))},[t,r])(),s=(u=e==null?void 0:e.config)==null?void 0:u.hierarchy;if(!s)return[...id];const i=`level${n}`,o=s[i],a=o==null?void 0:o.children,c=a==null?void 0:a.Content;return c!=null&&c.length?c:[...id]}function CM(){const e=am(),t=K(E=>{var j,P;return((P=(j=E.editorConfig)==null?void 0:j.context)==null?void 0:P.channel)??""}),r=lm(),n=K(E=>E.editorProfile),s=yr(E=>E.activeAssessmentSlot),i=re(E=>E.activeNodeMeta),o=re(E=>E.treeData),a=re(E=>E.treeCache),c=re(E=>E.selectedNodeId),u=re(E=>E.getNodeById),d=lr(),f=n.competencyScoped?wh(o[0],a):void 0,m=g.useRef(),p=d&&Array.isArray(i[d.code])?i[d.code]:bM,b=c?u(c):void 0,h=n.competencyScoped&&!!(b!=null&&b.isFolder)&&!!b.parent&&!lt(b),v=vM(n.competencyScoped,f,h,s,p),y=g.useCallback(async(E="",j="all",P={},O=!0,N=!1)=>{var R,M,$,ee,H;e.setLoading(!0);try{if(v){e.setContent([],0);return}let te;if(n.competencyScoped){const ae=mM(s,p,d==null?void 0:d.code,f);te={status:["Live"],...ae}}else te={status:["Live"],primaryCategory:j&&j!=="all"?[j]:r},(R=P==null?void 0:P.board)!=null&&R.length&&(te.board=P.board),(M=P==null?void 0:P.medium)!=null&&M.length&&(te.medium=P.medium),($=P==null?void 0:P.gradeLevel)!=null&&$.length&&(te.gradeLevel=P.gradeLevel),(ee=P==null?void 0:P.subject)!=null&&ee.length&&(te.subject=P.subject),(H=P==null?void 0:P.primaryCategory)!=null&&H.length&&(te.primaryCategory=P.primaryCategory);const de=O?0:e.offset,{content:fe,count:pe}=await oR({filters:te,query:E,limit:E?50:yM,offset:de,channel:t||void 0,sortBy:N?{name:"asc"}:{lastUpdatedOn:"desc"},fields:gM(n.competencyScoped,d==null?void 0:d.code)});O?e.setContent(fe,pe):e.appendContent(fe,pe)}catch(te){console.error("[useLibrary] load error:",te)}finally{e.setLoading(!1)}},[r,t,n,s,p,d,f,v]);g.useEffect(()=>{clearTimeout(m.current),e.setSearch("")},[f]),g.useEffect(()=>{y()},[t]),g.useEffect(()=>{n.competencyScoped&&y()},[n.competencyScoped,s,p.join("|"),f,c]);const C=g.useCallback(E=>{e.setSearch(E),clearTimeout(m.current),m.current=setTimeout(()=>y(E,e.activeFilter,e.advancedFilters,!0,e.sortAZ),300)},[e.activeFilter,e.advancedFilters,e.sortAZ,y]),S=g.useCallback(E=>{e.setFilter(E),y(e.searchQuery,E,e.advancedFilters,!0,e.sortAZ)},[e.searchQuery,e.advancedFilters,e.sortAZ,y]),_=g.useCallback(E=>{e.setAdvancedFilters(E),y(e.searchQuery,e.activeFilter,E,!0,e.sortAZ)},[e.searchQuery,e.activeFilter,e.sortAZ,y]),x=g.useCallback(()=>{const E=!e.sortAZ;e.setSortAZ(E),y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,E)},[e.sortAZ,e.searchQuery,e.activeFilter,e.advancedFilters,y]),T=g.useCallback(()=>{e.isLoading||y(e.searchQuery,e.activeFilter,e.advancedFilters,!1,e.sortAZ)},[e.isLoading,e.searchQuery,e.activeFilter,e.advancedFilters,e.sortAZ,y]),D=e.allContent.length<e.totalCount;return{content:e.filteredContent,isLoading:e.isLoading,totalCount:e.totalCount,activeFilter:e.activeFilter,advancedFilters:e.advancedFilters,searchQuery:e.searchQuery,sortAZ:e.sortAZ,hasMore:D,search:C,setFilter:S,applyAdvancedFilters:_,toggleSort:x,loadMore:T,refetch:()=>y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,e.sortAZ),activeAssessmentSlot:s,emptyReason:v}}function cm(){var a;const e=oe(),t=K(c=>c.editorProfile.competencyScoped),r=yr(c=>c.activeAssessmentSlot),n=re(c=>c.selectedNodeId),s=re(c=>c.treeData),i=re(c=>c.getNodeById),o=(a=s[0])==null?void 0:a.id;if(!t)return null;if(r==="pre")return e.learningPath.libraryAddPriorAssessmentCourse;if(r==="post")return e.learningPath.libraryAddOutcomeAssessmentCourse;if(n&&n!==o){const c=i(n);if(c!=null&&c.isFolder)return e.learningPath.libraryAddToLevel.replace("{level}",c.name??"")}return e.learningPath.libraryOpenLevelToAdd}const SM="_card_1cmpg_1",_M="_addBtn_1cmpg_17",wM="_dragging_1cmpg_24",xM="_ctIcon_1cmpg_29",TM="_info_1cmpg_33",EM="_name_1cmpg_41",AM="_meta_1cmpg_50",kM="_skillTags_1cmpg_58",IM="_skillTag_1cmpg_58",DM="_addBtnMuted_1cmpg_93",LM="_added_1cmpg_102",OM="_addedBadge_1cmpg_111",Kt={card:SM,addBtn:_M,dragging:wM,ctIcon:xM,info:TM,name:EM,meta:AM,skillTags:kM,skillTag:IM,addBtnMuted:DM,added:LM,addedBadge:OM},NM={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},jM=({item:e,onAdd:t,onPreview:r,isDraggable:n,isAdded:s})=>{var S,_;const i=oe(),o=oi(e),a=NM[o.key]??Wr,c=Hl(),u=hD(),d=c&&!s&&u,f=K(x=>x.editorProfile.competencyScoped),m=lr(),p=f&&m?(()=>{const x=e[m.code];return Array.isArray(x)?x:x?[String(x)]:[]})():[],{attributes:b,listeners:h,setNodeRef:v,isDragging:y}=Of({id:e.identifier,disabled:!n||!c||!u,data:{type:"library-item",item:e}}),C=()=>{r&&r(e)};return l.jsxs("div",{ref:v,className:[Kt.card,y?Kt.dragging:"",s?Kt.added:""].join(" "),"aria-label":e.name,...n?{...b,...h}:{},role:"listitem",onClick:C,children:[l.jsx("span",{className:[`sbx-ct-sq--${o.key}`,Kt.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(a,{size:14})}),l.jsxs("div",{className:Kt.info,children:[l.jsx("span",{className:Kt.name,title:e.name,children:e.name}),l.jsxs("span",{className:Kt.meta,children:[((S=e.organisation)==null?void 0:S[0])??e.channel??"",(_=e.organisation)!=null&&_[0]&&e.primaryCategory?" · ":"",e.primaryCategory??""]}),p.length>0&&l.jsx("span",{className:Kt.skillTags,children:p.slice(0,3).map(x=>l.jsx("span",{className:Kt.skillTag,children:x},x))})]}),s&&l.jsx("span",{className:Kt.addedBadge,"aria-label":i.libraryCard.alreadyAddedAriaLabel,title:i.libraryCard.alreadyAddedTitle,children:l.jsx(bn,{size:12})}),!s&&n&&l.jsx("button",{type:"button",className:[Kt.addBtn,!d&&c?Kt.addBtnMuted:""].join(" "),onClick:x=>{x.stopPropagation(),t(e)},disabled:!c,"aria-disabled":!d,"aria-label":i.libraryCard.addItemAriaLabel.replace("{name}",e.name),title:c?u?i.libraryCard.addToUnitTitle:i.libraryCard.selectUnitToAddTitle:i.libraryCard.draftOnlyTitle,children:l.jsx(Sn,{size:14})})]})},PM="_chips_xhhaq_1",RM="_chip_xhhaq_1",kd={chips:PM,chip:RM},FM=({filters:e,active:t,onChange:r})=>{const n=oe();return l.jsx("div",{className:kd.chips,role:"group","aria-label":n.filterChips.contentTypeFiltersAriaLabel,children:e.map(s=>l.jsx("button",{type:"button",role:"radio","aria-checked":t===s.value,className:["sbx-chip",t===s.value?"filled":"outline",kd.chip].join(" "),onClick:()=>r(s.value),children:s.label},s.value))})},MM="_panel_uame3_1",BM="_header_uame3_10",qM="_headerTitle_uame3_19",$M="_closeBtn_uame3_25",UM="_body_uame3_43",zM="_section_uame3_59",VM="_sectionLabel_uame3_65",HM="_chips_uame3_73",QM="_chip_uame3_73",WM="_active_uame3_96",GM="_footer_uame3_102",KM="_resetBtn_uame3_112",YM="_applyBtn_uame3_129",ht={panel:MM,header:BM,headerTitle:qM,closeBtn:$M,body:UM,section:zM,sectionLabel:VM,chips:HM,chip:QM,active:WM,footer:GM,resetBtn:KM,applyBtn:YM},ZM=e=>[{key:"board",label:e.libraryFilterPanel.boardLabel},{key:"medium",label:e.libraryFilterPanel.mediumLabel},{key:"gradeLevel",label:e.libraryFilterPanel.classLabel},{key:"subject",label:e.libraryFilterPanel.subjectLabel}],XM=new Set(["board","medium","gradeLevel","subject","topic"]),JM=({local:e,toggle:t})=>{const r=oe(),n=lm();return n.length?l.jsxs("div",{className:ht.section,children:[l.jsx("div",{className:ht.sectionLabel,children:r.libraryFilterPanel.primaryCategoryLabel}),l.jsx("div",{className:ht.chips,children:n.map(s=>l.jsx("button",{type:"button",className:[ht.chip,(e.primaryCategory??[]).includes(s)?ht.active:""].join(" "),onClick:()=>t("primaryCategory",s),children:s},s))})]}):null},eB=({isOpen:e,filters:t,onApply:r,onClose:n})=>{var v,y;const s=oe(),i=K(C=>C.editorConfig),o=K(C=>C.searchFormConfig),a=K(C=>C.contentFramework),c=K(C=>C.contentTargetFWIds),{organisationFramework:u}=Ao(a??((v=i==null?void 0:i.context)==null?void 0:v.framework),c??((y=i==null?void 0:i.context)==null?void 0:y.targetFWIds)),[d,f]=g.useState(t),m=o!=null&&o.length?o.filter(C=>XM.has(C.code)).map(C=>({key:C.code,label:C.label||C.code})):ZM(s);g.useEffect(()=>{f(t)},[t]);const p=(C,S)=>{f(_=>{const x=_[C]??[],T=x.includes(S)?x.filter(D=>D!==S):[...x,S];return{..._,[C]:T}})},b=(u==null?void 0:u.categories)??[],h=C=>{var S;return((S=b.find(_=>_.code===C))==null?void 0:S.terms)??[]};return e?l.jsxs("div",{className:ht.panel,role:"dialog","aria-label":s.libraryFilterPanel.filterLibraryAriaLabel,"aria-modal":"true",children:[l.jsxs("div",{className:ht.header,children:[l.jsx("span",{className:ht.headerTitle,children:s.libraryFilterPanel.filtersHeaderTitle}),l.jsx("button",{type:"button",className:ht.closeBtn,onClick:n,"aria-label":s.libraryFilterPanel.closeFiltersAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsxs("div",{className:ht.body,children:[m.map(({key:C,label:S})=>{const _=h(C);return _.length?l.jsxs("div",{className:ht.section,children:[l.jsx("div",{className:ht.sectionLabel,children:S}),l.jsx("div",{className:ht.chips,children:_.slice(0,20).map(x=>l.jsx("button",{type:"button",className:[ht.chip,(d[C]??[]).includes(x.name)?ht.active:""].join(" "),onClick:()=>p(C,x.name),children:x.name},x.identifier))})]},C):null}),l.jsx(JM,{local:d,toggle:p})]}),l.jsxs("div",{className:ht.footer,children:[l.jsx("button",{type:"button",className:ht.resetBtn,onClick:()=>f({}),children:s.libraryFilterPanel.resetButton}),l.jsx("button",{type:"button",className:ht.applyBtn,onClick:()=>{r(d),n()},children:s.libraryFilterPanel.applyButton})]})]}):null},tB="_header_1tvk1_10",rB="_headerCourse_1tvk1_20",nB="_courseIcon_1tvk1_25",sB="_titleGroup_1tvk1_37",iB="_courseMeta_1tvk1_45",oB="_title_1tvk1_37",aB="_headerActions_1tvk1_67",lB="_iconBtn_1tvk1_74",cB="_playerArea_1tvk1_92",uB="_footer_1tvk1_100",dB="_footerCourse_1tvk1_109",fB="_addBtn_1tvk1_115",hB="_addBtnCourse_1tvk1_134",pB="_modalOverlay_1tvk1_159",mB="_modalOverlayCourse_1tvk1_174",gB="_modalPanel_1tvk1_178",vB="_modalPanelCourse_1tvk1_190",gt={header:tB,headerCourse:rB,courseIcon:nB,titleGroup:sB,courseMeta:iB,title:oB,headerActions:aB,iconBtn:lB,playerArea:cB,footer:uB,footerCourse:dB,addBtn:fB,addBtnCourse:hB,modalOverlay:pB,modalOverlayCourse:mB,modalPanel:gB,modalPanelCourse:vB},yB="application/vnd.sunbird.questionset",bB=({content:e,editorMode:t,onAdd:r,onClose:n})=>{var f;const s=oe(),i=t==="edit",o=K(m=>m.editorProfile.competencyScoped),a=cm();if(!e)return null;const c=o&&e.primaryCategory==="Course",u=[((f=e.organisation)==null?void 0:f[0])??e.channel??"",e.primaryCategory??""].filter(Boolean).join(" • "),d={id:e.identifier,identifier:e.identifier,name:e.name??"",mimeType:e.mimeType,primaryCategory:e.primaryCategory,contentType:e.contentType,appIcon:e.appIcon,status:e.status,isFolder:!1,children:[],metadata:e};return xr.createPortal(l.jsx("div",{className:[gt.modalOverlay,c?gt.modalOverlayCourse:""].filter(Boolean).join(" "),role:"dialog","aria-modal":"true","aria-label":s.libraryPreviewPanel.contentPreviewAriaLabel,onClick:n,children:l.jsxs("div",{className:[gt.modalPanel,c?gt.modalPanelCourse:""].filter(Boolean).join(" "),onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:[gt.header,c?gt.headerCourse:""].filter(Boolean).join(" "),children:[c&&l.jsx("span",{className:gt.courseIcon,children:l.jsx(Qr,{size:20})}),l.jsxs("div",{className:gt.titleGroup,children:[l.jsx("span",{className:gt.title,title:e.name,children:e.name}),c&&u&&l.jsx("span",{className:gt.courseMeta,children:u})]}),l.jsx("div",{className:gt.headerActions,children:l.jsx("button",{type:"button",className:gt.iconBtn,onClick:n,"aria-label":s.libraryPreviewPanel.closePreviewAriaLabel,children:l.jsx(br,{size:16})})})]}),l.jsx("div",{className:gt.playerArea,children:c?l.jsx(sm,{courseId:e.identifier}):l.jsx(fl,{node:d,editorMode:"read",type:e.mimeType===yB?"quml":"content"})}),i&&l.jsx("div",{className:[gt.footer,c?gt.footerCourse:""].filter(Boolean).join(" "),children:c?l.jsxs("button",{type:"button",className:gt.addBtnCourse,onClick:()=>r(e),children:[l.jsx(Sn,{size:15})," ",a??s.libraryPreviewPanel.addToUnitButton]}):l.jsx("button",{type:"button",className:gt.addBtn,onClick:()=>r(e),children:s.libraryPreviewPanel.addToUnitButton})})]})}),document.body)},CB="_dock_2k0x7_1",SB="_header_2k0x7_8",_B="_libraryTargetLabel_2k0x7_18",wB="_headerLeft_2k0x7_28",xB="_headerTitle_2k0x7_36",TB="_count_2k0x7_42",EB="_searchRow_2k0x7_51",AB="_searchWrap_2k0x7_59",kB="_searchIcon_2k0x7_65",IB="_searchInput_2k0x7_74",DB="_filterToggleBtn_2k0x7_92",LB="_filterToggleBtnActive_2k0x7_111",OB="_filterBadge_2k0x7_117",NB="_filters_2k0x7_136",jB="_mainArea_2k0x7_146",PB="_sidePanelOverlay_2k0x7_155",RB="_cardList_2k0x7_164",FB="_skeleton_2k0x7_180",MB="_skeletonIcon_2k0x7_190",BB="_skeletonText_2k0x7_198",qB="_skeletonLine_2k0x7_205",$B="_skeletonLineSm_2k0x7_212",UB="_loadMoreBtn_2k0x7_227",zB="_emptyState_2k0x7_252",VB="_collapseBtn_2k0x7_272",ze={dock:CB,header:SB,libraryTargetLabel:_B,headerLeft:wB,headerTitle:xB,count:TB,searchRow:EB,searchWrap:AB,searchIcon:kB,searchInput:IB,filterToggleBtn:DB,filterToggleBtnActive:LB,filterBadge:OB,filters:NB,mainArea:jB,sidePanelOverlay:PB,cardList:RB,skeleton:FB,skeletonIcon:MB,skeletonText:BB,skeletonLine:qB,skeletonLineSm:$B,loadMoreBtn:UB,emptyState:zB,collapseBtn:VB},HB=[{label:"Courses",value:"all"}];function QB(e){const t=new Set,r=[...e];for(;r.length>0;){const n=r.shift();n.isFolder||t.add(n.identifier),n.children&&r.push(...n.children)}return t}const WB=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{const n=oe(),{content:s,isLoading:i,totalCount:o,activeFilter:a,searchQuery:c,sortAZ:u,hasMore:d,search:f,setFilter:m,applyAdvancedFilters:p,toggleSort:b,loadMore:h,activeAssessmentSlot:v,emptyReason:y}=CM(),{addResource:C,selectedNodeId:S,treeData:_,treeCache:x}=re(),T=yr(F=>F.setActiveAssessmentSlot),D=K(F=>F.editorProfile.competencyScoped),E=e==="edit",j=cm(),[P,O]=g.useState(!1),[N,R]=g.useState({}),[M,$]=g.useState(null),[ee,H]=g.useState(null),te=g.useMemo(()=>QB(_),[_]),de=g.useCallback(async(F,B)=>{var he,be;const Z=(he=_[0])==null?void 0:he.id;if(!(!Z||ee)){if(Ms(((be=_[0])==null?void 0:be.children)??[],B)){Se.error(B==="pre"?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}H(F.identifier);try{const{qualifies:me,meta:le}=await Sh(F.identifier);if(!me){Se.error(n.learningPath.notAssessmentCourseToast.replace("{name}",F.name));return}const ve={...F,...le};if(C(ve,Z,{isAssessmentCourse:!0,slot:B})===!1){Se.error(n.learningPath.bothSlotsFilledToast);return}Se.success(n.libraryDock.itemAddedToast.replace("{name}",F.name)),T(null)}catch(me){console.error("[LibraryDock] assessment-course check failed:",me),Se.error(n.learningPath.assessmentCheckFailedToast)}finally{H(null)}}},[_,C,T,ee,n]),fe=g.useCallback(F=>{var be,me,le;if(D&&!xh(_[0],x)){Se.error(n.learningPath.selectCurriculumFirstToast);return}if(v){de(F,v);return}if(!S){Se.error(D?n.learningPath.selectLevelFirstToast:n.libraryDock.selectUnitFirstToast);return}const B=(be=_[0])==null?void 0:be.id,Z=re.getState().getNodeById(S);if(D){const ve=((me=_[0])==null?void 0:me.children)??[],Te=Z!=null&&Z.isFolder?Z:Z!=null&&Z.parent?re.getState().getNodeById(Z.parent):void 0;if(Te&&Wa(ve,Te)){const Y=(le=ve[0])==null?void 0:le.id;Se.error(Te.id===Y?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}}if(S===B||!(Z!=null&&Z.isFolder)){Se(D?n.learningPath.selectLevelFromOutlineToast:n.libraryDock.selectUnitFromOutlineToast,{icon:l.jsx(Bn,{size:16}),duration:4e3});return}if(C(F,S)===!1){Se.error((D?n.learningPath.itemAlreadyInPathToast:n.libraryDock.itemAlreadyAddedToast).replace("{name}",F.name));return}Se.success(n.libraryDock.itemAddedToast.replace("{name}",F.name))},[v,de,S,C,_,x,n,D]),pe=g.useCallback(F=>{R(F),p(F)},[p]),ae=g.useCallback(F=>{$(F)},[]),we=g.useCallback(F=>{fe(F),$(null)},[fe]),ye=g.useMemo(()=>Object.values(N).reduce((F,B)=>F+((B==null?void 0:B.length)??0),0),[N]);return l.jsxs("div",{className:ze.dock,children:[l.jsxs("div",{className:ze.header,children:[l.jsxs("div",{className:ze.headerLeft,children:[l.jsx("button",{type:"button",className:ze.collapseBtn,onClick:r,"aria-label":n.libraryDock.collapseLibraryPanelAriaLabel,title:n.libraryDock.collapseLibraryTitle,children:l.jsx(Py,{size:15})}),l.jsx(Ly,{size:16}),l.jsx("span",{className:ze.headerTitle,children:n.libraryDock.headerTitle}),o>0&&l.jsx("span",{className:ze.count,children:o})]}),j&&l.jsx("span",{className:ze.libraryTargetLabel,children:j})]}),l.jsxs("div",{className:ze.searchRow,children:[l.jsxs("div",{className:ze.searchWrap,children:[l.jsx(Yi,{size:14,className:ze.searchIcon}),l.jsx("input",{type:"search",className:ze.searchInput,placeholder:n.libraryDock.searchPlaceholder,value:c,onChange:F=>f(F.target.value),"aria-label":n.libraryDock.searchAriaLabel})]}),l.jsx("button",{type:"button",className:[ze.filterToggleBtn,u?ze.filterToggleBtnActive:""].join(" "),onClick:b,"aria-label":u?n.libraryDock.sortAZAriaLabel:n.libraryDock.sortRecentAriaLabel,title:u?n.libraryDock.sortAZTitle:n.libraryDock.sortRecentTitle,children:u?l.jsx(Cy,{size:15}):l.jsx(Ty,{size:15})}),!D&&l.jsxs("button",{type:"button",className:[ze.filterToggleBtn,P?ze.filterToggleBtnActive:""].join(" "),onClick:()=>O(F=>!F),"aria-label":n.libraryDock.toggleAdvancedFiltersAriaLabel,"aria-pressed":P,title:n.libraryDock.advancedFiltersTitle,children:[l.jsx(zy,{size:15}),ye>0&&l.jsx("span",{className:ze.filterBadge,children:ye})]})]}),l.jsx("div",{className:ze.filters,children:l.jsx(FM,{filters:D?HB:pD,active:a,onChange:m})}),l.jsxs("div",{className:ze.mainArea,children:[l.jsx("div",{className:ze.cardList,role:"list","aria-label":n.libraryDock.libraryContentAriaLabel,children:i&&s.length===0?Array.from({length:4}).map((F,B)=>l.jsxs("div",{className:ze.skeleton,"aria-hidden":"true",children:[l.jsx("div",{className:ze.skeletonIcon}),l.jsxs("div",{className:ze.skeletonText,children:[l.jsx("div",{className:ze.skeletonLine}),l.jsx("div",{className:ze.skeletonLineSm})]})]},B)):s.length>0?l.jsxs(l.Fragment,{children:[s.map(F=>l.jsx(jM,{item:F,onAdd:fe,onPreview:ae,isDraggable:E,isAdded:te.has(F.identifier)},F.identifier)),d&&l.jsx("button",{type:"button",className:ze.loadMoreBtn,onClick:h,disabled:i,"aria-label":n.libraryDock.loadMoreAriaLabel,children:i?n.libraryDock.loadingText:n.libraryDock.loadMoreText})]}):l.jsxs("div",{className:ze.emptyState,children:[l.jsx(Yi,{size:24}),y==="noCurriculum"?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.learningPath.noCurriculumEmptyTitle}),l.jsx("span",{children:n.learningPath.noCurriculumEmptyHint})]}):y==="noSkills"?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.learningPath.noSkillsEmptyTitle}),l.jsx("span",{children:n.learningPath.noSkillsEmptyHint})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.libraryDock.noContentFound}),l.jsx("span",{children:n.libraryDock.tryDifferentSearch})]})]})}),P&&l.jsx("div",{className:ze.sidePanelOverlay,children:l.jsx(eB,{isOpen:P,filters:N,onApply:pe,onClose:()=>O(!1)})}),M&&l.jsx(bB,{content:M,editorMode:e,onAdd:we,onClose:()=>$(null)})]})]})};function GB(e,t,r,n=Al){const s={},i={},o=new Set(["id","isFolder","children","parent","isNew","breadcrumb","title","relationalMetadata","optional","metadata","isAssessmentCourse"]),a=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds","targetFWIds","targetTopicIds","topic","topicsIds"]),c=new Set(["audience","attributions","keywords","language","additionalCategories","medium","gradeLevel","subject","boardIds","mediumIds","gradeLevelIds","subjectIds","targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds","dialcodes"]),u=new Set(["copyrightYear","compatibilityLevel","version"]);function d(p,b=!1){const h={};for(const[v,y]of Object.entries(p))if(!o.has(v)&&!(b&&a.has(v)))if(c.has(v))Array.isArray(y)?h[v]=y:y!=null&&y!==""?h[v]=[y]:h[v]=[];else if(u.has(v)){const C=Number(y);isNaN(C)||(h[v]=C)}else h[v]=y;return h}function f(p){var h;const b={};for(const v of p.children??[]){if(v.isFolder)continue;const y=t[v.identifier];if(!y)continue;const{isNew:C,...S}=y;if(Object.keys(S).length===0)continue;const _=((h=v.metadata)==null?void 0:h.relationalMetadata)??{};b[v.identifier]={name:v.name,..._,...S}}return b}function m(p,b){var _,x;const h=p.identifier,v=t[h],y=h.startsWith("temp-")||!!(v!=null&&v.isNew),C=!p.isFolder&&!b;if(b||y||v&&!C){let T;if(y)T={mimeType:"application/vnd.ekstep.content-collection",code:h,contentType:((_=p.metadata)==null?void 0:_.contentType)??n.unitContentType,primaryCategory:((x=p.metadata)==null?void 0:x.primaryCategory)??n.unitPrimaryCategory,name:p.name,visibility:"Parent",channel:r,...d(p.metadata??{})};else if(b){const{isNew:D,...E}=v??{};T={...d(p.metadata??{},!0),...d(E,!1),name:p.name}}else{const{isNew:D,...E}=v??{};T={name:p.name,visibility:"Parent",...d(E,!0)}}s[h]={metadata:T,objectType:p.objectType||(p.isFolder?"Collection":"Content"),root:b,isNew:y}}const S=p.isFolder?f(p):{};i[h]={name:p.name,children:(p.children??[]).map(T=>T.identifier),...Object.keys(S).length>0?{relationalMetadata:S}:{},root:b},(p.children??[]).forEach(T=>m(T,!1))}return e.forEach((p,b)=>m(p,b===0)),{nodesModified:s,hierarchy:i}}function KB(){const[e,t]=g.useState(!1),r=re(d=>d.treeCache),n=re(d=>d.treeData),s=K(d=>d.isDirty),i=K(d=>d.lastSaved),{setIsDirty:o,setLastSaved:a}=K(),c=K(d=>d.editorConfig);return{save:g.useCallback(async()=>{if(!c||e)return;const d=c.context.contentId??c.context.identifier??"";if(!d)return;if(n.length===0){Se.error("Collection is empty. Please reload before saving.");return}const f=c.context.channel??"",m=c.context.userId??c.context.uid??"";t(!0);try{const p=K.getState().editorProfile,{nodesModified:b,hierarchy:h}=GB(n,r,f,p),{identifiers:v}=await r0(d,b,h,m);v&&Object.keys(v).length>0&&re.getState().replaceNodeIds(v);const y=new Date().toISOString();a(y),o(!1)}catch(p){console.error("[useSaveHierarchy] save failed:",p),Se.error("Failed to save. Please try again.")}finally{t(!1)}},[c,e,n,r,o,a]),isSaving:e,isDirty:s,lastSaved:i}}const YB={};function ZB(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function XB(e,t,r,n,s,i=YB){const o=[],a=(c,u)=>{var d;for(const f of c){const m=u&&!f.parent,p=m?r:f.isFolder?n:null;if(p&&p.length>0){const b={...f.metadata??{},...t[f.id]??{}},v=zp(p,b,i,m,s).filter(y=>y.required&&y.visible!==!1&&y.inputType!=="appIcon"&&ZB(y.currentValue)).map(y=>y.label);v.length>0&&o.push({nodeId:f.id,nodeName:f.name||"Untitled",missing:v})}(d=f.children)!=null&&d.length&&a(f.children,!1)}};return a(e,!0),o}function JB(e){var S,_;const t=K(x=>x.editorConfig),r=K(x=>x.editorProfile),n=K(x=>x.setButtonLoader),s=K(x=>x.validateAllForms),i=K(x=>x.rootFormConfig),o=K(x=>x.unitFormConfig),a=re(x=>x.treeData),c=re(x=>x.treeCache),u=re(x=>x.selectNode),d=lr(),{scope:f}=ii(),m=K(x=>x.contentFramework),p=K(x=>x.contentTargetFWIds),{organisationFramework:b,targetFrameworks:h}=Ao(m??((S=t==null?void 0:t.context)==null?void 0:S.framework),p??((_=t==null?void 0:t.context)==null?void 0:_.targetFWIds)),v=g.useCallback(()=>{var j,P,O;const x={editorMode:"edit",objectType:(j=t==null?void 0:t.config)==null?void 0:j.objectType,userFullName:(O=(P=t==null?void 0:t.context)==null?void 0:P.user)==null?void 0:O.fullName},T=XB(a,c,i,o,x,{organisationFramework:b,targetFrameworks:h});if(T.length===0)return!0;const D=T[0];Se.error(`"${D.nodeName}": please fill required field${D.missing.length>1?"s":""} — ${D.missing.join(", ")}`);const{setFormStatus:E}=K.getState();return T.forEach(N=>E(N.nodeId,!1)),u(D.nodeId),!1},[a,c,i,o,t,u,b,h]),y=g.useCallback(()=>{if(r.key!=="learningPath")return!0;const x=Rl(a[0],d==null?void 0:d.code,f,c);return x.length===0?!0:(Se.error(x[0].message),!1)},[r.key,a,c,d,f]);return{runAction:g.useCallback(async(x,T)=>{var j,P,O,N;const D=((j=t==null?void 0:t.context)==null?void 0:j.contentId)??((P=t==null?void 0:t.context)==null?void 0:P.identifier)??"";if(!D)return Se.error("No content identifier found."),!1;const E=((O=t==null?void 0:t.context)==null?void 0:O.userId)??((N=t==null?void 0:t.context)==null?void 0:N.uid)??"";try{switch(x){case"sendForReview":return v()?s(a)?y()?(n("saveCollection",!0),await e(),await i0(D),Se.success("Content sent for review"),!0):!1:(Se.error("Some units have missing required fields. Please fill them before sending for review."),!1):!1;case"reject":{n("rejectCollection",!0);const R=(T==null?void 0:T.comment)??"";return await o0(D,R),Se.success("Content rejected and sent back to the author"),!0}case"publish":return v()?s(a)?y()?(n("publishCollection",!0),await e(),await n0(D,E),Se.success("Content published successfully"),!0):!1:(Se.error("Some units have missing required fields. Please fill them before publishing."),!1):!1;default:return!1}}catch(R){console.error(`[useToolbarActions] ${x} failed`,R);const M=x==="sendForReview"?"send for review":x==="reject"?"reject":"publish";return Se.error(`Failed to ${M}. Please try again.`),!1}finally{n("saveCollection",!1),n("rejectCollection",!1),n("publishCollection",!1)}},[t,e,n,v,y,s,a]),checkRequiredFields:v}}function eq(){const e=oe(),t=K(c=>c.editorProfile.key==="learningPath"),r=re(c=>c.treeData),n=lr(),{scope:s,source:i}=ii(),o=g.useRef(!1),a=g.useRef("");g.useEffect(()=>{if(!t||i!=="prior"||!n)return;const c=m0(r[0],n.code,s),u=c.map(d=>d.id).sort().join(",");o.current?c.length>0&&u!==a.current&&Se.error(e.learningPath.priorAssessmentNarrowedScopeToast.replace("{count}",String(c.length))):o.current=!0,a.current=u},[t,i,s.join("|"),n==null?void 0:n.code,r])}function tq(){const e=K(o=>o.editorProfile.key==="learningPath"),t=re(o=>o.treeData),r=re(o=>o.treeCache),n=re(o=>o.updateNode),s=lr(),i=s==null?void 0:s.code;g.useEffect(()=>{if(!e||!i)return;const o=t[0],a=p0(o,i,r);a!==null&&n(o.id,{[i]:a},[i])},[e,t,r,i,n])}const rq="_shell_fu72l_1",nq="_workspace_fu72l_8",sq="_sidebarCollapsed_fu72l_16",iq="_dockCollapsed_fu72l_19",oq="_dock_fu72l_19",aq="_outline_fu72l_40",lq="_reopenTab_fu72l_45",cq="_outlineHidden_fu72l_79",uq="_editor_fu72l_86",dq="_editorLp_fu72l_92",fq="_dockHidden_fu72l_105",hq="_dockReopenTab_fu72l_112",pq="_dragChip_fu72l_137",mq="_dragChipLabel_fu72l_152",Ot={shell:rq,workspace:nq,sidebarCollapsed:sq,dockCollapsed:iq,dock:oq,outline:aq,reopenTab:lq,outlineHidden:cq,editor:uq,editorLp:dq,dockHidden:fq,dockReopenTab:hq,dragChip:pq,dragChipLabel:mq},gq=({editorMode:e,onToolbarEvent:t,onContentAdded:r,onHierarchySaved:n})=>{const s=oe(),[i,o]=g.useState(null),[a,c]=g.useState(!1),[u,d]=g.useState(!1),[f,m]=g.useState(!1);eq(),tq();const{addResource:p,treeData:b,treeCache:h}=re(),v=K(H=>H.setFormStatus),y=K(H=>H.editorProfile.key==="learningPath"),[C,S]=g.useState(!0),_=re(H=>H.selectedNodeId),{save:x,isSaving:T,isDirty:D,lastSaved:E}=KB(),{runAction:j,checkRequiredFields:P}=JB(x);g.useEffect(()=>{if(!D)return;const H=te=>{te.preventDefault(),te.returnValue=""};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[D]);const O=ff(ja(po,{activationConstraint:{distance:8}})),N=g.useCallback(H=>{var de;const te=(de=H.active.data.current)==null?void 0:de.item;te&&o(te)},[]),R=g.useCallback(H=>{var F,B,Z,he,be;o(null);const te=(F=H.active.data.current)==null?void 0:F.item;if(!te)return;if(y&&!xh(b[0],h)){Se.error(s.learningPath.selectCurriculumFirstToast);return}const de=H.over,fe=(de==null?void 0:de.id)??_??void 0,pe=y?s.learningPath.dropOntoLevelError:s.splitBuilderShell.dropOntoUnitError;if(!fe){Se.error(pe);return}const ae=(B=b[0])==null?void 0:B.id;if(fe===ae){Se.error(y?s.learningPath.dropOntoPathError:s.splitBuilderShell.dropOntoCourseError);return}const we=re.getState().getNodeById(fe);if(!(we!=null&&we.isFolder)){Se.error(pe);return}if(y&<(we)){const me=(be=(he=(Z=b[0])==null?void 0:Z.children)==null?void 0:he[0])==null?void 0:be.id;Se.error(we.id===me?s.learningPath.priorSlotFilledToast:s.learningPath.outcomeSlotFilledToast);return}if(!p(te,fe)){Se.error((y?s.learningPath.itemAlreadyInPathToast:s.splitBuilderShell.alreadyInCollectionError).replace("{name}",te.name));return}r==null||r(te,fe),Se.success((y?s.learningPath.addedToLevelSuccess:s.splitBuilderShell.addedToUnitSuccess).replace("{name}",te.name))},[_,p,b,h,r,s,y]),M=g.useCallback(async H=>{if(H.action==="onFormStatusChange"){const{isValid:te,nodeId:de}=H.data??{},fe=te!==!1;S(fe),de&&v(de,fe);return}if(H.action==="back"&&D&&e==="edit"){m(!0);return}if(H.action==="saveCollection"){if(!C){Se.error(s.splitBuilderShell.fillRequiredMetadataError);return}if(!P())return;await x(),n==null||n(b),t==null||t(H);return}if(H.action==="sendForReview"||H.action==="reject"||H.action==="publish"){await j(H.action,H.data)&&(t==null||t(H));return}t==null||t(H)},[x,j,P,t,n,b,D,C,e,s]),$=g.useCallback(async()=>{if(!P()){m(!1);return}await x(),m(!1),n==null||n(b),t==null||t({action:"back"})},[x,P,n,t,b]),ee=g.useCallback(()=>{m(!1),t==null||t({action:"back"})},[t]);return l.jsxs(Lf,{sensors:O,onDragStart:N,onDragEnd:R,children:[l.jsxs("div",{className:Ot.shell,children:[l.jsx(JT,{editorMode:e,isSaving:T,isDirty:D,lastSaved:E,isFormValid:C,onToolbarEvent:M}),l.jsxs("div",{className:[Ot.workspace,a?Ot.sidebarCollapsed:"",u?Ot.dockCollapsed:""].filter(Boolean).join(" "),children:[l.jsx("aside",{className:[Ot.outline,a?Ot.outlineHidden:""].join(" "),"aria-label":s.splitBuilderShell.outlineAriaLabel,"aria-hidden":a,children:l.jsx(OL,{editorMode:e,collapsed:a,onToggleCollapse:()=>c(H=>!H)})}),a&&l.jsx("button",{className:Ot.reopenTab,onClick:()=>c(!1),title:s.splitBuilderShell.showOutlineTitle,type:"button",children:"›"}),l.jsx("main",{className:[Ot.editor,y?Ot.editorLp:""].filter(Boolean).join(" "),role:"main","aria-label":s.splitBuilderShell.editorAriaLabel,children:l.jsx(pM,{editorMode:e,onToolbarEvent:M})}),l.jsx("aside",{className:[Ot.dock,u?Ot.dockHidden:""].filter(Boolean).join(" "),"aria-label":s.splitBuilderShell.libraryAriaLabel,"aria-hidden":u,children:l.jsx(WB,{editorMode:e,collapsed:u,onToggleCollapse:()=>d(H=>!H)})}),u&&l.jsx("button",{className:Ot.dockReopenTab,onClick:()=>d(!1),title:s.splitBuilderShell.showLibraryTitle,type:"button",children:"‹"})]})]}),l.jsx(my,{dropAnimation:null,children:i?l.jsx("div",{className:Ot.dragChip,children:l.jsx("span",{className:Ot.dragChipLabel,children:i.name})}):null}),f&&l.jsx(e1,{onSave:$,onDiscard:ee,onCancel:()=>m(!1),isSaving:T})]})},vq="v1";function yq(e){const t=e.validations,r=t==null?void 0:t.find(s=>s.type==="maxlength"||s.type==="maxLength");if(!r)return e.maxLength;const n=Number(r.value);return Number.isFinite(n)?n:void 0}function Id(e,t){var r;return{code:e.code??"",label:e.label??e.name??e.code??"",name:e.name,inputType:e.inputType,dataType:e.dataType,required:e.required===!0||Array.isArray(e.validations)&&e.validations.some(n=>n.type==="required")||String(((r=e.renderingHints)==null?void 0:r.class)??"").includes("required"),editable:e.editable!==!1,visible:e.visible!==!1,placeholder:e.placeholder,maxLength:yq(e),depends:e.depends,sourceCategory:e.sourceCategory,range:e.range,enum:e.enum,default:e.default,defaultValue:e.defaultValue,index:e.index,section:t,output:e.output}}function Dr(e){const t=e==null?void 0:e.properties;if(!Array.isArray(t))return[];const r=[];for(const n of t)if(Array.isArray(n.fields)){const s=n.name??void 0,i=n.fields.filter(o=>!!o.code).sort((o,a)=>(o.index??0)-(a.index??0));for(const o of i)r.push(Id(o,s))}else n.code&&r.push(Id(n));return r}function bq(e){const t=e==null?void 0:e.properties;if(!t)return{};const r={};for(const[n,s]of Object.entries(t))s&&"default"in s&&(r[n]=s.default);return r}async function Cq(e,t,r="Collection",n=vq){var u,d;const i=(d=(u=(await Fe.post(`/action/object/category/definition/${n}/read?fields=objectMetadata,forms,name,label`,{request:{objectCategoryDefinition:{objectType:r,name:e,...t?{channel:t}:{}}}})).data)==null?void 0:u.result)==null?void 0:d.objectCategoryDefinition,o=(i==null?void 0:i.forms)??{},a=(i==null?void 0:i.objectMetadata)??{},c=a.config??{};return{rootForm:Dr(o.create),unitForm:Dr(o.unitMetadata),childForm:Dr(o.childMetadata),searchForm:Dr(o.search??o.searchConfig),relationalForm:Dr(o.relationalMetadata),publishChecklist:Dr(o.publishchecklist),reviewChecklist:Dr(o.review),rfcChecklist:Dr(o.requestforchangeschecklist),schemaDefaults:bq(a.schema),frameworkMetadata:c.frameworkMetadata??{},sourcingSettings:c.sourcingSettings??{}}}function Dd(e,t,r){return{framework:e.framework??t??r.framework??null,targetFWIds:e.targetFWIds??r.targetFWIds??null}}function Sq({config:e,onError:t}){const[r,n]=g.useState(!0),[s,i]=g.useState(null),[o,a]=g.useState(!1),{setEditorConfig:c,setEditorMode:u,setCategoryDefinition:d,setContentFramework:f,setEditorProfile:m}=K(),{setTreeData:p,selectNode:b}=re();return g.useEffect(()=>{let h=!1;async function v(){var y,C,S;try{n(!0),i(null),e.apiBaseUrl&&mh(e.apiBaseUrl),c(e),u(e.config.mode),m(cb(e));const _=e.context.contentId??e.context.identifier??"",x=e.context.channel??"";let T;if(x)try{T=(y=await $p(x))==null?void 0:y.defaultFramework}catch{}let D=!1;if(_){const E=e.config.objectType==="QuestionSet";let{rootNode:j}=E?await t0(_):await yh(_);if(j&&e.config.primaryCategory==="Learning Path"&&(j=await c0(j)),!h&&(p(j?[j]:[]),j)){b(j.id);const{framework:M,targetFWIds:$}=Dd(j.metadata??{},T,e.context);f(M,$),D=!0}const P=e.config.primaryCategory??"Course",O=e.context.channel??"",N=e.config.categoryDefinitionApiVersion??"v1";try{const R=await Cq(P,O,e.config.objectType??"Collection",N);if(!h){d(R);const M=((C=R.sourcingSettings)==null?void 0:C.collection)??{},$={};M.maxDepth&&!e.config.maxDepth&&($.maxDepth=M.maxDepth),M.children&&!e.config.children&&($.children=M.children),M.hierarchy&&!((S=e.config.hierarchy)!=null&&S.level1)&&($.hierarchy={...e.config.hierarchy??{},...M.hierarchy}),Object.keys($).length>0&&c({...e,config:{...e.config,...$}})}}catch{}}if(!h&&!D){const{framework:E,targetFWIds:j}=Dd({},T,e.context);f(E,j)}h||a(!0)}catch(_){if(!h){const x=_ instanceof Error?_:new Error(String(_));i(x),t==null||t(x)}}finally{h||n(!1)}}return v(),()=>{h=!0}},[e.context.contentId,e.context.identifier]),{isLoading:r,error:s,isReady:o}}function _q(){const e=kl(t=>t.setLanguage);g.useEffect(()=>{e(localStorage.getItem(qa)||"en",{broadcast:!1});const t=n=>{n.key===qa&&n.newValue&&e(n.newValue,{broadcast:!1})},r=n=>{var i;const s=(i=n.detail)==null?void 0:i.lang;s&&e(s,{broadcast:!1})};return window.addEventListener("storage",t),window.addEventListener($a,r),()=>{window.removeEventListener("storage",t),window.removeEventListener($a,r)}},[e])}const wq="_root_1itrv_1",xq="_loadingState_1itrv_10",Tq="_loadingSpinner_1itrv_20",Eq="_errorState_1itrv_34",Ts={root:wq,loadingState:xq,loadingSpinner:Tq,errorState:Eq},Aq=new Bm({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function kq({error:e,onRetry:t}){const r=oe();return l.jsxs("div",{className:Ts.errorState,children:[l.jsx("h3",{children:r.collectionEditor.errorBoundaryTitle}),l.jsx("p",{children:e.message}),l.jsx("button",{onClick:t,children:r.collectionEditor.retryButton})]})}class Iq extends g.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){var r,n;(n=(r=this.props).onError)==null||n.call(r,t)}render(){return this.state.error?l.jsx(kq,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}}function Dq(e){_q();const t=oe(),{isLoading:r,error:n}=Sq({config:e,onError:e.onError}),s=K(o=>o.editorMode),i=K(o=>o.editorProfile);return r?l.jsxs("div",{className:Ts.loadingState,children:[l.jsx("div",{className:Ts.loadingSpinner}),l.jsx("p",{children:t.collectionEditor.loadingMessage})]}):n?l.jsxs("div",{className:Ts.errorState,children:[l.jsx("h3",{children:t.collectionEditor.loadErrorTitle}),l.jsx("p",{children:n.message})]}):l.jsx("div",{className:["sb-split-builder",Ts.root,i.key==="learningPath"?"sbx-lp-profile":""].filter(Boolean).join(" "),children:l.jsx(gq,{editorMode:s,onToolbarEvent:e.onToolbarEvent,onContentAdded:e.onContentAdded,onHierarchySaved:e.onHierarchySaved})})}const um=e=>l.jsx(Iq,{onError:e.onError,children:l.jsxs($m,{client:Aq,children:[l.jsx(Dq,{...e}),l.jsx(qg,{position:"top-right",toastOptions:{duration:3e3,style:{fontFamily:"var(--sbx-font)"}}})]})}),oo=Symbol.for("r2wc.reactRender"),Ld=Symbol.for("r2wc.shouldRender"),Ti=Symbol.for("r2wc.root");function Lq(e=""){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Oq(e=""){return e.replace(/-([a-z0-9])/g,function(t){return t[1].toUpperCase()})}var Od={expando:function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:function(){return r},set:function(n){r=n,this[oo]()}}),e[oo]()}};function Nq(e,t,r,n={}){var s={isConnected:"isConnected"in HTMLElement.prototype},i=!1,o=function(){var u=Reflect.construct(HTMLElement,arguments,this.constructor);return typeof n.shadow=="string"?u.attachShadow({mode:n.shadow}):n.shadow&&(console.warn('Specifying the "shadow" option as a boolean is deprecated and will be removed in a future version.'),u.attachShadow({mode:"open"})),u},a=Object.create(HTMLElement.prototype);a.constructor=o;var c=new Proxy(a,{has:function(u,d){return d in e.propTypes||d in a},set:function(u,d,f,m){return i&&(s[d]=!0),typeof d=="symbol"||s[d]||d in u?(e.propTypes&&d in e.propTypes&&Od.expando(m,d,f),Reflect.set(u,d,f,m)):(Od.expando(m,d,f),!0)},getOwnPropertyDescriptor:function(u,d){var f=Reflect.getOwnPropertyDescriptor(u,d);if(f)return f;if(d in e.propTypes)return{configurable:!0,enumerable:!0,writable:!0,value:void 0}}});return o.prototype=c,a.connectedCallback=function(){this[Ld]=!0,this[oo]()},a.disconnectedCallback=function(){typeof r.createRoot=="function"?this[Ti].unmount():r.unmountComponentAtNode(this)},a[oo]=function(){if(this[Ld]===!0){var u={};Object.keys(this).forEach(function(m){s[m]!==!1&&(u[m]=this[m])},this),i=!0;const d=n.shadow?this.shadowRoot:this,f=t.createElement(e,u);typeof r.createRoot=="function"?(this[Ti]||(this[Ti]=r.createRoot(d)),this[Ti].render(f)):r.render(f,d),i=!1}},e.propTypes&&(o.observedAttributes=n.dashStyleAttributes?Object.keys(e.propTypes).map(function(u){return Lq(u)}):Object.keys(e.propTypes),a.attributeChangedCallback=function(u,d,f){var m=n.dashStyleAttributes?Oq(u):u;this[m]=f}),o}var Pn={},Nd;function jq(){if(Nd)return Pn;Nd=1;var e=xr;if(process.env.NODE_ENV==="production")Pn.createRoot=e.createRoot,Pn.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Pn.createRoot=function(r,n){t.usingClientEntryPoint=!0;try{return e.createRoot(r,n)}finally{t.usingClientEntryPoint=!1}},Pn.hydrateRoot=function(r,n,s){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(r,n,s)}finally{t.usingClientEntryPoint=!1}}}return Pn}var Pq=jq();const Rq=Tl(Pq);function Fq(){if(document.getElementById("sb-ce-react-styles"))return;const e=document.createElement("style");e.id="sb-ce-react-styles",e.textContent="@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700&display=swap');",document.head.insertBefore(e,document.head.firstChild)}function Mq(e="sb-collection-editor"){if(Fq(),typeof customElements>"u"||customElements.get(e))return;const t=Nq(um,g,Rq,{});customElements.define(e,t)}exports.CollectionEditor=um;exports.registerCollectionEditor=Mq;exports.setApiBaseUrl=mh;exports.useEditorStore=K;exports.useLibraryStore=am;exports.useTreeStore=re;
|
|
546
|
+
Use the data prop if you want to provide your own handlers.`);if(e.initialData){const[t,r]=cD(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function dD(e,t){const r=uD(e);return l.jsxs(eD,{treeProps:r,imperativeHandle:t,children:[l.jsx(rD,{children:l.jsx(nD,{})}),l.jsx(sD,{})]})}const fD=g.forwardRef(dD);function Hl(){return re(e=>{var n;const t=e.treeData[0];return(((n=t==null?void 0:t.metadata)==null?void 0:n.status)??(t==null?void 0:t.status)??"Draft").toLowerCase()==="draft"})}function hD(){return re(e=>{var s;if(!e.selectedNodeId)return!1;const t=(s=e.treeData[0])==null?void 0:s.id,r=i=>{var o;for(const a of i){if(a.id===e.selectedNodeId)return a;if((o=a.children)!=null&&o.length){const c=r(a.children);if(c)return c}}},n=r(e.treeData);return!!(n!=null&&n.isFolder)&&n.id!==t})}const nd={video:"#EA580C",pdf:"#DC2626",h5p:"#0D9488",scorm:"#7C3AED",audio:"#DB2777",quiz:"#16A34A",course:"#A85236",default:"#6B7280"},sd={video:"Video",pdf:"FileText",h5p:"Layers",scorm:"Package",audio:"Music",quiz:"HelpCircle",course:"BookOpen",default:"File"},id=["Course Assessment","eTextbook","Exam Question","Explanation Content","Learning Resource","Practice Question Set","SCORM Content","Teacher Resource"],pD=[{label:"All",value:"all"},{label:"Course Assessment",value:"Course Assessment"},{label:"eTextbook",value:"eTextbook"},{label:"Exam Question",value:"Exam Question"},{label:"Explanation Content",value:"Explanation Content"},{label:"Learning Resource",value:"Learning Resource"},{label:"Practice Question Set",value:"Practice Question Set"},{label:"SCORM Content",value:"SCORM Content"},{label:"Teacher Resource",value:"Teacher Resource"}];function mD(e){var r;if((r=e.metadata)!=null&&r.isAssessmentCourse)return"quiz";const t=[e.mimeType??"",e.primaryCategory??"",e.contentType??""].join(" ").toLowerCase();return t.includes("video")?"video":t.includes("pdf")||t.includes("epub")?"pdf":t.includes("h5p")?"h5p":t.includes("scorm")?"scorm":t.includes("audio")||t.includes("mp3")?"audio":t.includes("quiz")||t.includes("question")||t.includes("ecml")?"quiz":e.primaryCategory==="Course"?"course":"default"}function oi(e){const t=mD(e);return{key:t,color:nd[t]??nd.default,bgClass:`sbx-ct-sq--${t}`,badgeClass:`sbx-ct-badge--${t}`,tintClass:`sbx-ct-tint--${t}`,iconName:sd[t]??sd.default,label:t.charAt(0).toUpperCase()+t.slice(1)}}const gD="_row_nm332_1",vD="_grip_nm332_16",yD="_menuBtn_nm332_19",bD="_rowLp_nm332_23",CD="_selected_nm332_27",SD="_title_nm332_32",_D="_dropTarget_nm332_41",wD="_toggle_nm332_58",xD="_ctIcon_nm332_73",TD="_ctIconLp_nm332_85",ED="_folderIcon_nm332_89",AD="_rootIcon_nm332_94",kD="_titleLp_nm332_110",ID="_levelTitle_nm332_114",DD="_renameInput_nm332_119",LD="_dropHere_nm332_128",OD="_menuWrap_nm332_138",ND="_menu_nm332_19",jD="_dangerItem_nm332_190",it={row:gD,grip:vD,menuBtn:yD,rowLp:bD,selected:CD,title:SD,dropTarget:_D,toggle:wD,ctIcon:xD,ctIconLp:TD,folderIcon:ED,rootIcon:AD,titleLp:kD,levelTitle:ID,renameInput:DD,dropHere:LD,menuWrap:OD,menu:ND,dangerItem:jD},PD={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},RD=({node:e,style:t,dragHandle:r,editorMode:n})=>{const[s,i]=g.useState(!1),[o,a]=g.useState(!1),[c,u]=g.useState(e.data.name),d=g.useRef(null),f=oe(),m=K(N=>N.editorProfile),p=n==="edit",b=Hl(),h=oi(e.data),v=PD[h.key]??Wr,y=e.isSelected,C=e.level===0,S=e.data.isFolder??(e.children&&e.children.length>0),_=m.key==="learningPath",x=C?_?Oh:_y:S?_?Oy:Mf:v,T=_&&S&&!C&&!lt(e.data),D=e.level+1<=m.maxDepth,E=_?f.learningPath.addLevelButton:f.treeNode.addSubunitMenuItem,j=_?f.learningPath.addLevelButton:f.treeNode.addSiblingMenuItem;g.useEffect(()=>{if(!s)return;const N=R=>{var M;(M=d.current)!=null&&M.contains(R.target)||i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const P=g.useCallback(()=>{c.trim()&&e.submit(c.trim()),a(!1)},[c,e]),O=g.useCallback(N=>{N.key==="Enter"&&P(),N.key==="Escape"&&(u(e.data.name),a(!1))},[P,e.data.name]);return l.jsxs("div",{className:[it.row,_?it.rowLp:"",y?it.selected:"",e.state.isOver&&S?it.dropTarget:""].filter(Boolean).join(" "),style:t,onClick:()=>e.select(),"data-node-id":e.data.id,"data-droppable":S?"true":void 0,role:"treeitem","aria-selected":y,"aria-expanded":S?!e.isClosed:void 0,children:[p&&l.jsx("span",{ref:r,className:it.grip,"aria-hidden":"true",children:l.jsx(Bf,{size:14})}),l.jsx("button",{className:it.toggle,onClick:N=>{N.stopPropagation(),e.toggle()},"aria-label":e.isClosed?f.treeNode.expandAriaLabel:f.treeNode.collapseAriaLabel,style:{visibility:S?"visible":"hidden"},children:e.isClosed?l.jsx(xl,{size:14}):l.jsx(Cn,{size:14})}),l.jsx("span",{className:[it.ctIcon,C||S?it.folderIcon:h.bgClass,_?it.ctIconLp:"",C&&_?it.rootIcon:""].filter(Boolean).join(" "),"aria-hidden":"true",children:l.jsx(x,{size:C&&_?15:12})}),o?l.jsx("input",{className:it.renameInput,value:c,autoFocus:!0,onChange:N=>u(N.target.value),onBlur:P,onKeyDown:O,onClick:N=>N.stopPropagation()}):l.jsx("span",{className:[it.title,_?it.titleLp:"",T?it.levelTitle:""].filter(Boolean).join(" "),title:e.data.name,onDoubleClick:()=>p&&a(!0),children:e.data.name.length>25?`${e.data.name.slice(0,25)}...`:e.data.name}),e.state.isOver&&S&&l.jsx("span",{className:it.dropHere,"aria-hidden":"true",children:f.treeNode.dropHereLabel}),p&&l.jsxs("div",{className:it.menuWrap,ref:d,children:[l.jsx("button",{className:it.menuBtn,onClick:N=>{N.stopPropagation(),i(R=>!R)},"aria-label":f.treeNode.nodeOptionsAriaLabel,children:l.jsx(Rf,{size:14})}),s&&l.jsxs("div",{className:it.menu,role:"menu",children:[l.jsxs("button",{role:"menuitem",onClick:()=>{a(!0),i(!1)},children:[l.jsx(Ry,{size:13})," ",f.treeNode.renameMenuItem]}),S&&b&&D&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.id}),i(!1)},children:[l.jsx(Ff,{size:13})," ",E]}),e.data.parent&&b&&!_&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.data.parent}),i(!1)},children:[l.jsx(Sn,{size:13})," ",j]}),!C&&l.jsxs("button",{role:"menuitem",className:it.dangerItem,onClick:()=>{e.tree.delete(e.id),i(!1)},children:[l.jsx(So,{size:13})," ",f.treeNode.deleteMenuItem]})]})]})]})};async function FD(e,t){var i,o;const n=((i=(await Fe.post(`/action/content/v3/upload/url/${e}?type=hierarchy`,{request:{content:{fileName:t}}})).data)==null?void 0:i.result)??{},s=((o=n.content)==null?void 0:o.preSignedURL)??n.pre_signed_url??n.preSignedUrl;if(!s)throw new Error("Could not obtain an upload URL");return s}async function MD(e,t){const r=await fetch(e,{method:"PUT",headers:{"x-ms-blob-type":"BlockBlob","Content-Type":"text/csv"},body:t});if(!r.ok)throw new Error(`Blob upload failed (${r.status})`);return e.split("?")[0]}async function BD(e,t){var a;const r=await FD(e,t.name),n=await MD(r,t),s=new FormData;return s.append("fileUrl",n),s.append("mimeType",t.type||"text/csv"),{processId:(((a=(await Fe.post(`/action/collection/v1/import/${e}`,s)).data)==null?void 0:a.result)??{}).processId??""}}async function qD(e){var r;return((r=(await Fe.get(`/action/collection/v1/import/status/${e}`)).data)==null?void 0:r.result)??{status:"PENDING"}}async function Ep(e){var n,s,i;const r=(i=(s=(n=(await Fe.get(`/action/collection/v1/export/${e}`)).data)==null?void 0:n.result)==null?void 0:s.collection)==null?void 0:i.tocUrl;if(!r)throw new Error("No export URL returned");return r}async function $D(e){return Ep(e)}const UD="_container_jw2be_1",zD="_header_jw2be_13",VD="_title_jw2be_22",HD="_closeBtn_jw2be_29",QD="_body_jw2be_45",WD="_dropZone_jw2be_54",GD="_dragOver_jw2be_67",KD="_hasFile_jw2be_72",YD="_hiddenInput_jw2be_78",ZD="_fileInfo_jw2be_82",XD="_fileIcon_jw2be_89",JD="_fileName_jw2be_93",eL="_fileSize_jw2be_100",tL="_dropHint_jw2be_105",rL="_dropIcon_jw2be_112",nL="_dropText_jw2be_117",sL="_dropSubtext_jw2be_124",iL="_sampleLink_jw2be_130",oL="_statusBar_jw2be_145",aL="_status_uploading_jw2be_154",lL="_status_processing_jw2be_154",cL="_status_done_jw2be_159",uL="_status_error_jw2be_164",dL="_successDetail_jw2be_170",fL="_spinner_jw2be_175",hL="_spin_jw2be_175",pL="_errorMsg_jw2be_191",mL="_failedSection_jw2be_197",gL="_failedTitle_jw2be_203",vL="_tableWrap_jw2be_213",yL="_failedTable_jw2be_219",bL="_reasonCell_jw2be_244",CL="_footer_jw2be_248",Ue={container:UD,header:zD,title:VD,closeBtn:HD,body:QD,dropZone:WD,dragOver:GD,hasFile:KD,hiddenInput:YD,fileInfo:ZD,fileIcon:XD,fileName:JD,fileSize:eL,dropHint:tL,dropIcon:rL,dropText:nL,dropSubtext:sL,sampleLink:iL,statusBar:oL,status_uploading:aL,status_processing:lL,status_done:cL,status_error:uL,successDetail:dL,spinner:fL,spin:hL,errorMsg:pL,failedSection:mL,failedTitle:gL,tableWrap:vL,failedTable:yL,reasonCell:bL,footer:CL},SL=({contentId:e,onComplete:t,onClose:r,mode:n="create"})=>{const s=oe(),[i,o]=g.useState(null),[a,c]=g.useState(!1),[u,d]=g.useState("idle"),[f,m]=g.useState(""),[p,b]=g.useState([]),[h,v]=g.useState(null),y=g.useRef(null),C=g.useRef(null),S=g.useCallback(()=>{C.current!==null&&(clearInterval(C.current),C.current=null)},[]);g.useEffect(()=>()=>S(),[S]);const _=O=>O.name.toLowerCase().endsWith(".csv")?O.size>50*1024*1024?(m(s.csvUpload.fileTooLarge),!1):!0:(m(s.csvUpload.invalidFileType),!1),x=g.useCallback(O=>{m(""),b([]),v(null),d("idle"),_(O)&&o(O)},[]),T=g.useCallback(O=>{O.preventDefault(),c(!1);const N=O.dataTransfer.files[0];N&&x(N)},[x]),D=g.useCallback(O=>{var R;const N=(R=O.target.files)==null?void 0:R[0];N&&x(N),O.target.value=""},[x]),E=g.useCallback(async()=>{try{const O=await $D(e),N=document.createElement("a");N.href=O,N.download="sample_hierarchy.csv",N.target="_blank",N.click()}catch{m(s.csvUpload.downloadSampleFailed)}},[e,s.csvUpload.downloadSampleFailed]),j=g.useCallback(async()=>{if(i){d("uploading"),m(""),b([]);try{const{processId:O}=await BD(e,i);if(!O){d("done"),v(null),setTimeout(t,1500);return}d("processing"),C.current=setInterval(async()=>{try{const N=await qD(O);N.status==="COMPLETED"?(S(),d("done"),v(N.successCount??null),N.failedRecords&&N.failedRecords.length>0?b(N.failedRecords):setTimeout(t,1500)):N.status==="FAILED"&&(S(),d("error"),m(s.csvUpload.processingFailed),N.failedRecords&&b(N.failedRecords))}catch{S(),d("error"),m(s.csvUpload.connectionLost)}},2e3)}catch{d("error"),m(s.csvUpload.uploadFailed)}}},[e,i,t,S,s.csvUpload.processingFailed,s.csvUpload.connectionLost,s.csvUpload.uploadFailed]),P={idle:"",uploading:s.csvUpload.statusUploading,processing:s.csvUpload.statusProcessing,done:s.csvUpload.statusDone,error:s.csvUpload.statusError};return l.jsxs("div",{className:Ue.container,children:[l.jsxs("div",{className:Ue.header,children:[l.jsx("h2",{className:Ue.title,children:n==="update"?s.csvUpload.titleUpdate:s.csvUpload.titleCreate}),l.jsx("button",{className:Ue.closeBtn,onClick:r,"aria-label":s.csvUpload.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Ue.body,children:[l.jsxs("div",{className:`${Ue.dropZone} ${a?Ue.dragOver:""} ${i?Ue.hasFile:""}`,onDragEnter:O=>{O.preventDefault(),c(!0)},onDragOver:O=>{O.preventDefault(),c(!0)},onDragLeave:O=>{O.preventDefault(),c(!1)},onDrop:T,onClick:()=>{var O;return(O=y.current)==null?void 0:O.click()},role:"button",tabIndex:0,"aria-label":s.csvUpload.dropZoneAriaLabel,onKeyDown:O=>{var N;return O.key==="Enter"&&((N=y.current)==null?void 0:N.click())},children:[l.jsx("input",{ref:y,type:"file",accept:".csv",className:Ue.hiddenInput,onChange:D,"aria-hidden":"true"}),i?l.jsxs("div",{className:Ue.fileInfo,children:[l.jsx(Js,{size:24,className:Ue.fileIcon}),l.jsx("span",{className:Ue.fileName,children:i.name}),l.jsxs("span",{className:Ue.fileSize,children:["(",(i.size/1024).toFixed(1)," KB)"]})]}):l.jsxs("div",{className:Ue.dropHint,children:[l.jsx(Ma,{size:32,className:Ue.dropIcon}),l.jsx("p",{className:Ue.dropText,children:s.csvUpload.dropText}),l.jsx("p",{className:Ue.dropSubtext,children:s.csvUpload.dropSubtext})]})]}),l.jsx("button",{className:Ue.sampleLink,onClick:E,type:"button",children:s.csvUpload.downloadSample}),u!=="idle"&&l.jsxs("div",{className:`${Ue.statusBar} ${Ue[`status_${u}`]}`,role:"status","aria-live":"polite",children:[u==="processing"&&l.jsx("span",{className:Ue.spinner,"aria-hidden":"true"}),P[u],u==="done"&&h!==null&&l.jsx("span",{className:Ue.successDetail,children:s.csvUpload.itemsImportedSuffix.replace("{count}",String(h))})]}),f&&l.jsx("p",{className:Ue.errorMsg,role:"alert",children:f}),p.length>0&&l.jsxs("div",{className:Ue.failedSection,children:[l.jsx("h4",{className:Ue.failedTitle,children:s.csvUpload.failedRowsTitle.replace("{count}",String(p.length))}),l.jsx("div",{className:Ue.tableWrap,children:l.jsxs("table",{className:Ue.failedTable,children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:s.csvUpload.rowHeader}),l.jsx("th",{children:s.csvUpload.nameHeader}),l.jsx("th",{children:s.csvUpload.reasonHeader})]})}),l.jsx("tbody",{children:p.map((O,N)=>l.jsxs("tr",{children:[l.jsx("td",{children:O.rowNumber??N+1}),l.jsx("td",{children:O.name??"—"}),l.jsx("td",{className:Ue.reasonCell,children:O.reason??s.csvUpload.unknownError})]},N))})]})})]})]}),l.jsxs("div",{className:Ue.footer,children:[l.jsx(Re,{variant:"ghost",onClick:r,disabled:u==="uploading"||u==="processing",children:s.csvUpload.cancel}),l.jsx(Re,{variant:"primary",isLoading:u==="uploading"||u==="processing",disabled:!i||u==="done",onClick:j,children:u==="done"?s.csvUpload.uploaded:s.csvUpload.upload})]})]})};function Ql(){var v,y,C,S,_,x,T;const e=oe(),t=re(D=>D.treeData),r=re(D=>D.treeCache),n=re(D=>D.deleteNode),s=yr(D=>D.activeAssessmentSlot),i=yr(D=>D.setActiveAssessmentSlot),o=yr(D=>D.openModal),a=((v=t[0])==null?void 0:v.children)??[],c=a[0],u=a.length>1?a[a.length-1]:void 0,d=lt(c),f=lt(u),m=t[0],p=m?((y=r[m.id])==null?void 0:y.policy)??((C=m.metadata)==null?void 0:C.policy):void 0,b=!!p&&Ah.has(p),h=D=>{const E=D==="pre"?c:u;if(!E)return;const j=D==="pre"&&b?e.learningPath.deletePriorAssessmentConfirm:e.learningPath.deleteAssessmentSlotConfirm;o("confirmDelete",{message:j,onConfirm:()=>n(E.id)})};return{pre:{level:c,filled:d,courseName:d?(_=(S=c==null?void 0:c.children)==null?void 0:S[0])==null?void 0:_.name:void 0,required:b},post:{level:u,filled:f,courseName:f?(T=(x=u==null?void 0:u.children)==null?void 0:x[0])==null?void 0:T.name:void 0,required:!1},activeAssessmentSlot:s,setActiveAssessmentSlot:i,deleteSlot:h}}const _L="_container_2qylm_1",wL="_header_2qylm_8",xL="_sectionLabel_2qylm_18",TL="_headerActions_2qylm_26",EL="_iconBtn_2qylm_33",AL="_menuWrap_2qylm_51",kL="_dropdownMenu_2qylm_55",IL="_treeWrapper_2qylm_87",DL="_csvModal_2qylm_103",LL="_footer_2qylm_113",tr={container:_L,header:wL,sectionLabel:xL,headerActions:TL,iconBtn:EL,menuWrap:AL,dropdownMenu:kL,treeWrapper:IL,csvModal:DL,footer:LL},OL=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{var Te;const n=oe(),s=g.useRef(null),i=g.useRef(null),o=g.useRef(null),[a,c]=g.useState(400),[u,d]=g.useState(!1),[f,m]=g.useState(!1),[p,b]=g.useState("create"),{treeData:h,selectedNodeId:v,selectNode:y,addNode:C,deleteNode:S,getNodeById:_,reorderChildren:x,moveNode:T,setTreeData:D}=re(),E=yr(Y=>Y.openModal),j=K(Y=>Y.editorProfile),P=j.key==="learningPath",O=e==="edit",N=Hl(),R=O&&N,M=P?n.learningPath.addLevelButton:n.outlineTree.addUnitButton,$=j.maxDepth>1,ee=(((Te=h[0])==null?void 0:Te.children)??[]).some(Y=>Y.isFolder),{pre:H,post:te,deleteSlot:de}=Ql(),{level:fe}=H,{level:pe}=te,ae=K(Y=>{var ce,Q,Ce,qe;return((Q=(ce=Y.editorConfig)==null?void 0:ce.context)==null?void 0:Q.contentId)??((qe=(Ce=Y.editorConfig)==null?void 0:Ce.context)==null?void 0:qe.identifier)??""}),we=K(Y=>{var Q,Ce;const ce=(Ce=(Q=Y.categoryMeta)==null?void 0:Q.sourcingSettings)==null?void 0:Ce.collection;return(ce==null?void 0:ce.enableBulkUpload)!==!1}),ye=j.features.csvUpload&&we;g.useEffect(()=>{const Y=i.current;if(!Y)return;const ce=new ResizeObserver(()=>{c(Y.clientHeight||400)});return ce.observe(Y),c(Y.clientHeight||400),()=>ce.disconnect()},[]),g.useEffect(()=>{if(!u)return;const Y=ce=>{var Q;(Q=o.current)!=null&&Q.contains(ce.target)||d(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[u]);const F=g.useCallback(Y=>{Y.length>0&&y(Y[0].data.id)},[y]),B=g.useCallback(({parentId:Y,index:ce,dragIds:Q})=>{if(!Y)return;const Ce=Q[0],qe=il(h,Ce);if(!qe)return;const et=qe.parent;if(et===Y){const $e=il(h,Y);if(!($e!=null&&$e.children))return;const We=$e.children.findIndex(tt=>tt.id===Ce);if(We<0)return;x(Y,We,ce>We?ce-1:ce)}else T(Ce,et??"",Y)},[h,x,T]),Z=g.useCallback(({ids:Y})=>{if(!P){for(const Q of Y)S(Q);return}if(Y.length===1){const Q=Y[0];if((fe==null?void 0:fe.id)===Q){de("pre");return}if((pe==null?void 0:pe.id)===Q){de("post");return}const Ce=_(Q),qe=Ce!=null&&Ce.isFolder?n.learningPath.deleteLevelConfirm.replace("{name}",Ce.name):n.learningPath.deleteCourseConfirm;E("confirmDelete",{message:qe,onConfirm:()=>S(Q)});return}const ce=n.learningPath.deleteMultipleConfirm.replace("{count}",String(Y.length));E("confirmDelete",{message:ce,onConfirm:()=>{for(const Q of Y)S(Q)}})},[S,de,P,fe,pe,_,E,n]),he=g.useCallback(({parentId:Y})=>{var Ce;const ce=Y??((Ce=h[0])==null?void 0:Ce.id)??"";if(!ce)return{id:crypto.randomUUID()};const Q=C(ce,"unit");return Q?{id:Q}:(Se.error(n.outlineTree.maxDepthReachedToast),{id:crypto.randomUUID()})},[C,h,n]),be=g.useCallback(()=>{var ce;const Y=(ce=h[0])==null?void 0:ce.id;Y&&(C(Y,"unit")||Se.error(n.outlineTree.maxDepthReachedToast))},[h,C,n]),me=g.useCallback(()=>{v&&(C(v,"subunit")||Se.error(n.outlineTree.maxDepthReachedToast))},[v,C,n]),le=g.useCallback(async()=>{if(d(!1),!!ae)try{const Y=await Ep(ae),ce=await fetch(Y).then(qe=>qe.blob()),Q=URL.createObjectURL(ce),Ce=document.createElement("a");Ce.href=Q,Ce.download=`${ae}-folders.csv`,Ce.style.display="none",document.body.appendChild(Ce),Ce.click(),document.body.removeChild(Ce),URL.revokeObjectURL(Q)}catch{Se.error(n.outlineTree.downloadCsvFailedToast)}},[ae,n]),ve=g.useCallback(async()=>{if(m(!1),!!ae)try{const{rootNode:Y}=await yh(ae);D([Y]),Se.success(n.outlineTree.outlineRefreshedToast)}catch{Se.error(n.outlineTree.outlineRefreshFailedToast)}},[ae,D,n]);return l.jsxs("div",{className:tr.container,children:[l.jsxs("div",{className:tr.header,children:[P&&l.jsx("span",{className:tr.sectionLabel,children:n.learningPath.pathStructureLabel}),l.jsxs("div",{className:tr.headerActions,children:[O&&ye&&l.jsxs("div",{className:tr.menuWrap,ref:o,children:[l.jsx("button",{type:"button",className:tr.iconBtn,onClick:()=>d(Y=>!Y),"aria-label":n.outlineTree.moreOptionsAriaLabel,title:n.outlineTree.moreOptionsTitle,"aria-haspopup":"true","aria-expanded":u,children:l.jsx(Rf,{size:15})}),u&&l.jsxs("div",{className:tr.dropdownMenu,role:"menu",children:[l.jsx("button",{role:"menuitem",type:"button",disabled:ee,title:ee?n.outlineTree.foldersExistTitle:void 0,onClick:()=>{d(!1),b("create"),m(!0)},children:n.outlineTree.createFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!ee,title:ee?void 0:n.outlineTree.noFoldersYetTitle,onClick:le,children:n.outlineTree.downloadFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!ee,title:ee?void 0:n.outlineTree.noFoldersYetTitle,onClick:()=>{d(!1),b("update"),m(!0)},children:n.outlineTree.updateFoldersCsvButton})]})]}),r&&l.jsx("button",{type:"button",className:tr.iconBtn,onClick:r,"aria-label":t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,title:t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,children:t?l.jsx(jy,{size:15}):l.jsx(Ny,{size:15})})]})]}),l.jsx("div",{className:tr.treeWrapper,ref:i,children:l.jsx(fD,{ref:s,data:h,idAccessor:"id",childrenAccessor:"children",onSelect:F,onMove:O?B:void 0,onDelete:O?Z:void 0,onCreate:O?he:void 0,disableEdit:!O,disableDrop:!O,selection:v??void 0,rowHeight:40,indent:20,paddingBottom:16,height:a,width:"100%",children:Y=>l.jsx(RD,{...Y,editorMode:e})})}),O&&l.jsxs("div",{className:tr.footer,children:[l.jsxs(Re,{variant:"ghost",size:"sm",onClick:be,disabled:!R,children:[l.jsx(Sn,{size:14})," ",M]}),$&&l.jsxs(Re,{variant:"ghost",size:"sm",onClick:me,disabled:!R||!v,children:[l.jsx(Ff,{size:14})," ",n.outlineTree.addSubunitButton]})]}),f&&l.jsx("div",{className:tr.csvModal,children:l.jsx(SL,{contentId:ae,mode:p,onComplete:ve,onClose:()=>m(!1)})})]})};function il(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=il(r.children,t);if(n)return n}}}const NL="_breadcrumb_zd1aj_1",jL="_crumb_zd1aj_10",PL="_sep_zd1aj_26",RL="_current_zd1aj_31",ys={breadcrumb:NL,crumb:jL,sep:PL,current:RL},FL=({crumbs:e})=>{const t=re(n=>n.selectNode),r=oe();return e.length?l.jsxs("nav",{className:ys.breadcrumb,"aria-label":r.breadcrumb.nodePathAriaLabel,children:[l.jsx("button",{className:ys.crumb,onClick:()=>t(e[0].id),"aria-label":r.breadcrumb.homeAriaLabel,children:l.jsx(Dy,{size:13})}),e.map((n,s)=>l.jsxs(g.Fragment,{children:[l.jsx(xl,{size:13,className:ys.sep}),s<e.length-1?l.jsx("button",{className:ys.crumb,onClick:()=>t(n.id),children:n.name}):l.jsx("span",{className:ys.current,children:n.name})]},n.id))]}):null},ML="_tabBar_qhks1_1",BL="_tab_qhks1_1",qL="_active_qhks1_29",$L="_error_qhks1_35",UL="_errorDot_qhks1_39",bs={tabBar:ML,tab:BL,active:qL,error:$L,errorDot:UL},zL=({activeTab:e,onChange:t,errorTabs:r=[],visibleTabs:n})=>{const s=oe(),i=[{id:"details",label:s.tabBar.detailsTab},{id:"audience",label:s.tabBar.audienceCurriculumTab},{id:"licensing",label:s.tabBar.licensingTab}],o=n?i.filter(a=>n.includes(a.id)):i;return l.jsx("div",{className:bs.tabBar,role:"tablist","aria-label":s.tabBar.metadataSectionsAriaLabel,children:o.map(a=>l.jsxs("button",{role:"tab","aria-selected":e===a.id,"aria-controls":`panel-${a.id}`,className:[bs.tab,e===a.id?bs.active:"",r.includes(a.id)?bs.error:""].join(" "),onClick:()=>t(a.id),children:[a.label,r.includes(a.id)&&l.jsx("span",{className:bs.errorDot,"aria-label":s.tabBar.hasErrorsAriaLabel})]},a.id))})};var ai=e=>e.type==="checkbox",tn=e=>e instanceof Date,vt=e=>e==null;const Ap=e=>typeof e=="object";var Ze=e=>!vt(e)&&!Array.isArray(e)&&Ap(e)&&!tn(e),ol=e=>Ze(e)&&e.target?ai(e.target)?e.target.checked:e.target.value:e,kp=(e,t)=>t.split(".").some((r,n,s)=>!isNaN(Number(r))&&e.has(s.slice(0,n).join("."))),Ip=e=>{const t=e.constructor&&e.constructor.prototype;return Ze(t)&&t.hasOwnProperty("isPrototypeOf")},No=typeof window<"u"&&typeof window.HTMLElement<"u"&&typeof document<"u";function Xe(e){if(e instanceof Date)return new Date(e);const t=typeof FileList<"u"&&e instanceof FileList;if(No&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ze(e)&&Ip(e)))return e;const n=r?[]:Object.create(Object.getPrototypeOf(e));for(const s in e)Object.prototype.hasOwnProperty.call(e,s)&&(n[s]=Xe(e[s]));return n}const jr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},sr={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},rr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ua="form",Dp="root",Lp=["__proto__","constructor","prototype"];var li=e=>/^\w*$/.test(e),Qe=e=>e===void 0,jo=e=>e.split(/[.[\]'"]/g).filter(Boolean),G=(e,t,r)=>{if(!t||!Ze(e))return r;const n=li(t)?[t]:jo(t);if(n.some(i=>Lp.includes(i)))return r;const s=n.reduce((i,o)=>vt(i)?void 0:i[o],e);return Qe(s)||s===e?Qe(e[t])?r:e[t]:s},Ut=e=>typeof e=="boolean",Et=e=>typeof e=="function",Ve=(e,t,r)=>{let n=-1;const s=li(t)?[t]:jo(t),i=s.length,o=i-1;for(;++n<i;){const a=s[n];let c=r;if(n!==o){const u=e[a];c=Ze(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(Lp.includes(a))return;e[a]=c,e=e[a]}};const Wl=g.createContext(null);Wl.displayName="HookFormControlContext";const Gl=()=>g.useContext(Wl);var Op=(e,t,r,n=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==sr.all&&(t._proxyFormState[o]=!n||sr.all),r&&(r[o]=!0),e[o]}});return s};const Kl=No?g.useLayoutEffect:g.useEffect;function VL(e){const t=Gl(),{control:r=t,disabled:n,name:s,exact:i}=e||{},[o,a]=g.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=g.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Kl(()=>r._subscribe({name:s,formState:c.current,exact:i,callback:u=>{!n&&a({...r._formState,...u,defaultValues:r._defaultValues})}}),[s,n,i]),g.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),g.useMemo(()=>Op(o,r,c.current,!1),[o,r])}var At=e=>typeof e=="string",al=(e,t,r,n,s)=>At(e)?(n&&t.watch.add(e),G(r,e,s)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),G(r,i))):(n&&(t.watchAll=!0),r),ll=e=>vt(e)||!Ap(e);const od=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ip(e);function zt(e,t,r=new WeakMap){if(e===t)return!0;if(ll(e)||ll(t))return Object.is(e,t);if(tn(e)&&tn(t))return Object.is(e.getTime(),t.getTime());const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;if(od(e,n)||od(t,s))return Object.is(e,t);const i=r.get(e);if(i&&i.has(t))return!0;i?i.add(t):r.set(e,new WeakSet([t]));for(const o of n){const a=e[o];if(!(o in t))return!1;if(o!=="ref"){const c=t[o];if(tn(a)&&tn(c)||(Ze(a)||Array.isArray(a))&&(Ze(c)||Array.isArray(c))?!zt(a,c,r):!Object.is(a,c))return!1}}return!0}function HL(e){const t=Gl(),{control:r=t,name:n,defaultValue:s,disabled:i,exact:o,compute:a}=e||{},c=g.useRef(s),u=g.useRef(a),d=g.useRef(void 0),f=g.useRef(r),m=g.useRef(n);u.current=a;const[p,b]=g.useState(()=>{const _=r._getWatch(n,c.current);return u.current?u.current(_):_}),h=g.useCallback(_=>{const x=al(n,r._names,_||r._formValues,!1,c.current);return u.current?u.current(x):x},[r._formValues,r._names,n]),v=g.useCallback(_=>{if(!i){const x=al(n,r._names,_||r._formValues,!1,c.current);if(u.current){const T=u.current(x);zt(T,d.current)||(b(T),d.current=T)}else b(x)}},[r._formValues,r._names,i,n]);Kl(()=>((f.current!==r||!zt(m.current,n))&&(f.current=r,m.current=n,v()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:_=>{v(_.values)}})),[r,o,n,v]),g.useEffect(()=>r._removeUnmounted());const y=f.current!==r,C=m.current,S=g.useMemo(()=>{if(i)return null;const _=!y&&!zt(C,n);return y||_?h():null},[i,y,n,C,h]);return S!==null?S:p}function ci(e){const t=Gl(),{name:r,disabled:n,control:s=t,shouldUnregister:i,defaultValue:o,exact:a=!0}=e,c=kp(s._names.array,r),u=g.useMemo(()=>G(s._formValues,r,G(s._defaultValues,r,o)),[s,r,o]),d=HL({control:s,name:r,defaultValue:u,exact:a}),f=VL({control:s,name:r,exact:a}),m=g.useRef(e),p=g.useRef(null),b=g.useRef(s.register(r,{...e.rules,value:d,...Ut(e.disabled)?{disabled:e.disabled}:{}}));m.current=e;const h=g.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!G(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!G(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!G(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!G(f.validatingFields,r)},error:{enumerable:!0,get:()=>G(f.errors,r)}}),[f,r]),v=g.useCallback(_=>{const x=ol(_);return G(s._fields,r)||(b.current=s.register(r,{...m.current.rules,value:x})),b.current.onChange({target:{value:ol(_),name:r},type:jr.CHANGE})},[r,s]),y=g.useCallback(()=>b.current.onBlur({target:{value:G(s._formValues,r),name:r},type:jr.BLUR}),[r,s._formValues]),C=g.useCallback(_=>{_&&(p.current={focus:()=>Et(_.focus)&&_.focus(),select:()=>Et(_.select)&&_.select(),setCustomValidity:T=>Et(_.setCustomValidity)&&_.setCustomValidity(T),reportValidity:()=>Et(_.reportValidity)&&_.reportValidity()});const x=G(s._fields,r);x&&x._f&&_&&(x._f.ref=p.current)},[s._fields,r]),S=g.useMemo(()=>({name:r,value:d,...Ut(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:v,onBlur:y,ref:C}),[r,n,f.disabled,v,y,C,d]);return g.useEffect(()=>{const _=s._options.shouldUnregister||i;s.register(r,{...m.current.rules,...Ut(m.current.disabled)?{disabled:m.current.disabled}:{}});const x=(T,D)=>{const E=G(s._fields,T);E&&E._f&&(E._f.mount=D)};if(x(r,!0),_){const T=Xe(G(i?s._defaultValues:s._options.values||s._defaultValues,r,G(s._options.defaultValues,r,m.current.defaultValue)));Ve(s._defaultValues,r,T),Qe(G(s._formValues,r))&&Ve(s._formValues,r,T)}if(!c&&s.register(r),p.current){const T=G(s._fields,r);T&&T._f&&(T._f.ref=p.current)}return()=>{(c?_&&!s._state.action:_)?s.unregister(r):x(r,!1)}},[r,s,c,i]),g.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),g.useMemo(()=>({field:S,formState:f,fieldState:h}),[S,f,h])}const QL=e=>e.render(ci(e)),Yl=g.createContext(null);Yl.displayName="HookFormContext";const Jt=()=>g.useContext(Yl),WL=({children:e,watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:m,unregister:p,control:b,register:h,setFocus:v,subscribe:y})=>{const C=g.useMemo(()=>({watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:m,unregister:p,control:b,register:h,setFocus:v,subscribe:y}),[i,b,u,n,r,m,h,f,d,s,v,o,a,y,c,p,t]);return g.createElement(Yl.Provider,{value:C},g.createElement(Wl.Provider,{value:C.control},e))};var GL=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},Np=e=>Array.isArray(e)?e.filter(Boolean):[],$i=e=>Array.isArray(e)?e:[e],ad=()=>{let e=[];return{get observers(){return e},next:s=>{for(const i of e)i.next&&i.next(s)},subscribe:s=>(e.push(s),{unsubscribe:()=>{e=e.filter(i=>i!==s)}}),unsubscribe:()=>{e=[]}}};function jp(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],i=t[n];if(s&&Ze(s)&&i){const o=jp(s,i);Ze(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var ft=e=>Ze(e)&&!Object.keys(e).length,Zl=e=>e.type==="file",ro=e=>{if(!No)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Pp=e=>e.type==="select-multiple",Xl=e=>e.type==="radio",KL=e=>Xl(e)||ai(e),da=e=>ro(e)&&e.isConnected;function YL(e,t){const r=t.slice(0,-1).length;let n=0;for(;n<r;){if(vt(e)){e=void 0;break}e=e[t[n]],n++}return e}function ZL(e){for(const t in e)if(e.hasOwnProperty(t)&&!Qe(e[t]))return!1;return!0}function nt(e,t){if(At(t)&&Object.prototype.hasOwnProperty.call(e,t))return delete e[t],e;const r=Array.isArray(t)?t:li(t)?[t]:jo(t),n=r.length===1?e:YL(e,r),s=r.length-1,i=r[s];return n&&delete n[i],s!==0&&(Ze(n)&&ft(n)||Array.isArray(n)&&ZL(n))&&nt(e,r.slice(0,-1)),e}var XL=e=>{for(const t in e)if(Et(e[t]))return!0;return!1};function Rp(e){return Array.isArray(e)||Ze(e)&&!XL(e)}function cl(e,t={}){for(const r in e){const n=e[r];Rp(n)?(t[r]=Array.isArray(n)?[]:{},cl(n,t[r])):Qe(n)||(t[r]=!0)}return t}function ul(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>ul(r));return t.some(r=>r!==void 0)?t:void 0}if(Ze(e)){const t={};for(const r in e){const n=ul(e[r]);Qe(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function Xr(e,t,r){r||(r=cl(t));for(const n in e){const s=e[n];if(Rp(s))Qe(t)||ll(r[n])?r[n]=cl(s,Array.isArray(s)?[]:{}):Xr(s,vt(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!zt(s,i)}}return ul(r)||{}}const ld={value:!1,isValid:!1},cd={value:!0,isValid:!0};var Fp=e=>{if(Array.isArray(e)){if(e.length>1){const t=e.filter(r=>r&&r.checked&&!r.disabled).map(r=>r.value);return{value:t,isValid:!!t.length}}return e[0].checked&&!e[0].disabled?e[0].attributes&&!Qe(e[0].attributes.value)?Qe(e[0].value)||e[0].value===""?cd:{value:e[0].value,isValid:!0}:cd:ld}return ld},Mp=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>Qe(e)?e:t?e===""?NaN:e&&+e:r&&At(e)?new Date(e):n?n(e):e;const ud={isValid:!1,value:null};var Bp=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,ud):ud;function dd(e){const t=e.ref;return Zl(t)?t.files:Xl(t)?Bp(e.refs).value:Pp(t)?[...t.selectedOptions].map(({value:r})=>r):ai(t)?Fp(e.refs).value:Mp(Qe(t.value)?e.ref.value:t.value,e)}var JL=(e,t,r,n)=>{const s={};for(const i of e){const o=G(t,i);o&&Ve(s,i,o._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},no=e=>e instanceof RegExp,Cs=e=>Qe(e)?e:no(e)?e.source:Ze(e)?no(e.value)?e.value.source:e.value:e,fd=e=>({isOnSubmit:!e||e===sr.onSubmit,isOnBlur:e===sr.onBlur,isOnChange:e===sr.onChange,isOnAll:e===sr.all,isOnTouch:e===sr.onTouched});const hd="AsyncFunction";var eO=e=>!!e&&!!e.validate&&!!(Et(e.validate)&&e.validate.constructor.name===hd||Ze(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===hd)),tO=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),fa=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(`${n}.`)));const Ds=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const i=G(e,s);if(i){const{_f:o,...a}=i;if(o){if(o.refs&&o.refs[0]&&t(o.refs[0],s)&&!n)return!0;if(o.ref&&t(o.ref,o.name)&&!n)return!0;if(Ds(a,t))break}else if(Ze(a)&&Ds(a,t))break}}};function pd(e,t,r){const n=G(e,r);if(n||li(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const i=s.join("."),o=G(t,i),a=G(e,i);if(o&&!Array.isArray(o)&&r!==i)return{name:r};if(a&&a.type)return{name:i,error:a};if(a&&a.root&&a.root.type)return{name:`${i}.root`,error:a.root};s.pop()}return{name:r}}var rO=(e,t,r,n)=>{r(e);const{name:s,...i}=e;return ft(i)||n&&Object.keys(i).length>=Object.keys(t).length||Object.keys(i).find(o=>t[o]===(!n||sr.all))},nO=(e,t,r)=>!e||!t||e===t||$i(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),sO=(e,t,r,n,s)=>s.isOnAll?!1:!r&&s.isOnTouch?!(t||e):(r?n.isOnBlur:s.isOnBlur)?!e:(r?n.isOnChange:s.isOnChange)?e:!0,iO=(e,t)=>!Np(G(e,t)).length&&nt(e,t),md=(e,t,r)=>{const n=G(e,r),s=Array.isArray(n)?n:[];return Ve(s,Dp,t[r]),Ve(e,r,s),e};function gd(e,t,r="validate"){if(At(e)||Array.isArray(e)&&e.every(At)||Ut(e)&&!e)return{type:r,message:At(e)?e:"",ref:t}}var On=e=>Ze(e)&&!no(e)?e:{value:e,message:""},vd=async(e,t,r,n,s,i)=>{const{ref:o,refs:a,required:c,maxLength:u,minLength:d,min:f,max:m,pattern:p,validate:b,name:h,valueAsNumber:v,mount:y}=e._f,C=G(r,h);if(!y||t.has(h))return{};const S=a?a[0]:o,_=N=>{if(s&&S.reportValidity){const R=Ut(N)?"":N||"";a?a.forEach(M=>M.setCustomValidity(R)):S.setCustomValidity(R),S.reportValidity()}},x={},T=Xl(o),D=ai(o),E=T||D,j=(v||Zl(o))&&Qe(o.value)&&Qe(C)||ro(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,P=GL.bind(null,h,n,x),O=(N,R,M,$=rr.maxLength,ee=rr.minLength)=>{const H=N?R:M;x[h]={type:N?$:ee,message:H,ref:o,...P(N?$:ee,H)}};if(i?!Array.isArray(C)||!C.length:c&&(!E&&(j||vt(C))||Ut(C)&&!C||D&&!Fp(a).isValid||T&&!Bp(a).isValid)){const{value:N,message:R}=At(c)?{value:!!c,message:c}:On(c);if(N&&(x[h]={type:rr.required,message:R,ref:S,...P(rr.required,R)},!n))return _(R),x}if(!j&&(!vt(f)||!vt(m))){let N,R;const M=On(m),$=On(f);if(!vt(C)&&!isNaN(C)){const ee=o.valueAsNumber||C&&+C;vt(M.value)||(N=ee>M.value),vt($.value)||(R=ee<$.value)}else{const ee=o.valueAsDate||new Date(C),H=fe=>new Date(new Date().toDateString()+" "+fe),te=o.type=="time",de=o.type=="week";At(M.value)&&C&&(N=te?H(C)>H(M.value):de?C>M.value:ee>new Date(M.value)),At($.value)&&C&&(R=te?H(C)<H($.value):de?C<$.value:ee<new Date($.value))}if((N||R)&&(O(!!N,M.message,$.message,rr.max,rr.min),!n))return _(x[h].message),x}if((u||d)&&!j&&(At(C)||i&&Array.isArray(C))){const N=On(u),R=On(d),M=!vt(N.value)&&C.length>+N.value,$=!vt(R.value)&&C.length<+R.value;if((M||$)&&(O(M,N.message,R.message),!n))return _(x[h].message),x}if(p&&!j&&At(C)){const{value:N,message:R}=On(p);if(no(N)&&!C.match(N)&&(x[h]={type:rr.pattern,message:R,ref:o,...P(rr.pattern,R)},!n))return _(R),x}if(b){if(Et(b)){const N=await b(C,r),R=gd(N,S);if(R&&(x[h]={...R,...P(rr.validate,R.message)},!n))return _(R.message),x}else if(Ze(b)){let N={};for(const R in b){if(!ft(N)&&!n)break;const M=gd(await b[R](C,r),S,R);M&&(N={...M,...P(R,M.message)},_(M.message),n&&(x[h]=N))}if(!ft(N)&&(x[h]={ref:S,...N},!n))return x}}return _(!0),x};const oO={mode:sr.onSubmit,reValidateMode:sr.onChange,shouldFocusError:!0},qp={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function aO(e={}){let t={...oO,...e},r={...Xe(qp),isLoading:Et(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ze(t.defaultValues)||Ze(t.values)?Xe(t.defaultValues||t.values)||{}:{},i=t.shouldUnregister?{}:Xe(s),o={action:!1,mount:!1,watch:!1,keepIsValid:!1},a={mount:new Set,disabled:new Set,unMount:new Set,array:new Set,watch:new Set,registerName:new Set},c,u=0;const d={isDirty:!1,dirtyFields:!1,validatingFields:!1,touchedFields:!1,isValidating:!1,isValid:!1,errors:!1},f={...d};let m={...f};const p={array:ad(),state:ad()},b=t.criteriaMode===sr.all,h=w=>A=>{clearTimeout(u),u=setTimeout(w,A)},v=async w=>{if(!o.keepIsValid&&!t.disabled&&(f.isValid||m.isValid||w)){let A;t.resolver?(A=ft((await P()).errors),y()):A=await R({fields:n,onlyCheckValid:!0,eventType:jr.VALID}),A!==r.isValid&&p.state.next({isValid:A})}},y=(w,A)=>{!t.disabled&&(f.isValidating||f.validatingFields||m.isValidating||m.validatingFields)&&((w||Array.from(a.mount)).forEach(I=>{I&&(A?Ve(r.validatingFields,I,A):nt(r.validatingFields,I))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ft(r.validatingFields)}))},C=()=>{r.dirtyFields=Xr(s,i)},S=(w,A=[],I,U,z=!0,W=!0)=>{if(U&&I&&!t.disabled){if(o.action=!0,W&&Array.isArray(G(n,w))){const V=I(G(n,w),U.argA,U.argB);z&&Ve(n,w,V)}if(W&&Array.isArray(G(r.errors,w))){const V=I(G(r.errors,w),U.argA,U.argB);z&&Ve(r.errors,w,V),iO(r.errors,w)}if((f.touchedFields||m.touchedFields)&&W&&Array.isArray(G(r.touchedFields,w))){const V=I(G(r.touchedFields,w),U.argA,U.argB);z&&Ve(r.touchedFields,w,V)}(f.dirtyFields||m.dirtyFields)&&C(),p.state.next({name:w,isDirty:$(w,A),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else Ve(i,w,A)},_=(w,A)=>{Ve(r.errors,w,A),r.errors={...r.errors},p.state.next({errors:r.errors})},x=w=>{r.errors=w,p.state.next({errors:r.errors,isValid:!1})},T=w=>{const A=li(w)?[w]:jo(w);let I=i,U=s;for(let z=0;z<A.length-1;z++){const W=A[z];if(I=vt(I)?I:I[W],U=vt(U)?U:U[W],I===null&&U!==null)return!0}return!1},D=(w,A,I,U)=>{const z=G(n,w);if(z){if(T(w))return;const W=Qe(G(i,w)),V=G(i,w,Qe(I)?G(s,w):I);Qe(V)||U&&U.defaultChecked||A?Ve(i,w,A?V:dd(z._f)):te(w,V),o.mount&&!o.action&&(v(),W&&r.isDirty&&(f.isDirty||m.isDirty)&&($()||(r.isDirty=!1,p.state.next({...r}))),e.shouldUnregister&&W&&!Qe(G(i,w))&&fa(w,a)&&(o.watch=!0))}},E=(w,A,I,U,z)=>{let W=!1,V=!1;const ne={name:w};if(!t.disabled){if(!I||U){(f.isDirty||m.isDirty)&&(V=r.isDirty,r.isDirty=ne.isDirty=$(),W=V!==ne.isDirty);const se=zt(G(s,w),A);V=!!G(r.dirtyFields,w),se!==r.isDirty?r.dirtyFields=Xr(s,i):se?nt(r.dirtyFields,w):Ve(r.dirtyFields,w,!0),ne.dirtyFields=r.dirtyFields,W=W||(f.dirtyFields||m.dirtyFields)&&V!==!se}if(I){const se=G(r.touchedFields,w);se||(Ve(r.touchedFields,w,I),ne.touchedFields=r.touchedFields,W=W||(f.touchedFields||m.touchedFields)&&se!==I)}W&&z&&p.state.next(ne)}return W?ne:{}},j=(w,A,I,U)=>{const z=G(r.errors,w),W=(f.isValid||m.isValid)&&Ut(A)&&r.isValid!==A;if(t.delayError&&I?(c=h(()=>_(w,I)),c(t.delayError)):(clearTimeout(u),c=null,I?Ve(r.errors,w,I):nt(r.errors,w),r.errors={...r.errors}),(I?!zt(z,I):z)||!ft(U)||W){const V={...U,...W&&Ut(A)?{isValid:A}:{},errors:r.errors,name:w};r={...r,...V},p.state.next(V)}},P=async w=>(y(w,!0),await t.resolver(i,t.context,JL(w||a.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),O=async w=>{const{errors:A}=await P(w);if(y(w),w){for(const I of w){const U=G(A,I);U?a.array.has(I)&&Ze(U)&&!Object.keys(U).some(z=>!Number.isNaN(Number(z)))?md(r.errors,{[I]:U},I):Ve(r.errors,I,U):nt(r.errors,I)}r.errors={...r.errors}}else r.errors=A;return A},N=async({name:w,eventType:A})=>{if(e.validate){const I=await e.validate({formValues:i,formState:r,name:w,eventType:A});if(Ze(I))for(const U in I){const z=I[U];z&&be(`${ua}.${U}`,{message:At(z.message)?z.message:"",type:z.type||rr.validate})}else At(I)||!I?be(ua,{message:I||"",type:rr.validate}):he(ua);return I}return!0},R=async({fields:w,onlyCheckValid:A,name:I,eventType:U,context:z={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(z.runRootValidation=!0,!await N({name:I,eventType:U})&&(z.valid=!1,A)))return z.valid;for(const W in w){const V=w[W];if(V){const{_f:ne,...se}=V;if(ne){const je=a.array.has(ne.name),Ge=V._f&&eO(V._f),st=f.validatingFields||f.isValidating||m.validatingFields||m.isValidating;Ge&&st&&y([ne.name],!0);const Vt=await vd(V,a.disabled,i,b,t.shouldUseNativeValidation&&!A,je);if(Ge&&st&&y([ne.name]),Vt[ne.name]&&(z.valid=!1,A)||(!A&&(G(Vt,ne.name)?je?md(r.errors,Vt,ne.name):Ve(r.errors,ne.name,Vt[ne.name]):nt(r.errors,ne.name)),e.shouldUseNativeValidation&&Vt[ne.name]))break}!ft(se)&&await R({context:z,onlyCheckValid:A,fields:se,name:W,eventType:U})}}return z.valid},M=()=>{for(const w of a.unMount){const A=G(n,w);A&&(A._f.refs?A._f.refs.every(I=>!da(I)):!da(A._f.ref))&&Te(w)}a.unMount=new Set},$=(w,A)=>!t.disabled&&(w&&A&&Ve(i,w,A),!zt(B(),s)),ee=(w,A,I)=>al(w,a,{...o.mount?i:Qe(A)?s:At(w)?{[w]:A}:A},I,A),H=w=>Np(G(o.mount?i:s,w,t.shouldUnregister?G(s,w,[]):[])),te=(w,A,I={},U=!1)=>{const z=G(n,w);let W=A;if(z){const V=z._f;V&&(!V.disabled&&Ve(i,w,Mp(A,V)),W=ro(V.ref)&&vt(A)?"":A,Pp(V.ref)?[...V.ref.options].forEach(ne=>ne.selected=W.includes(ne.value)):V.refs?ai(V.ref)?V.refs.forEach(ne=>{(!ne.defaultChecked||!ne.disabled)&&(Array.isArray(W)?ne.checked=!!W.find(se=>se===ne.value):ne.checked=W===ne.value||!!W)}):V.refs.forEach(ne=>ne.checked=ne.value===W):Zl(V.ref)?V.ref.value="":(V.ref.value=W,V.ref.type||p.state.next({name:w,values:U?i:Xe(i)})))}(I.shouldDirty||I.shouldTouch)&&E(w,W,I.shouldTouch,I.shouldDirty,!0),I.shouldValidate&&F(w)},de=(w,A,I,U=!1)=>{for(const z in A){if(!A.hasOwnProperty(z))return;const W=A[z],V=w+"."+z,ne=G(n,V);(a.array.has(w)||Ze(W)||ne&&!ne._f)&&!tn(W)?de(V,W,I,U):te(V,W,I,U)}},fe=(w,A,I,U)=>{const z=G(n,w),W=a.array.has(w),V=U?A:Xe(A),ne=G(i,w),se=zt(ne,V);if(se||Ve(i,w,V),W)p.array.next({name:w,values:U?i:Xe(i)}),(f.isDirty||f.dirtyFields||m.isDirty||m.dirtyFields)&&I.shouldDirty&&(C(),p.state.next({name:w,dirtyFields:r.dirtyFields,isDirty:$(w,V)}));else{const je=Array.isArray(V)&&!V.length||ft(V);!z||z._f||vt(V)||je?te(w,V,I,U):de(w,V,I,U)}if(!se){const je=fa(w,a),Ge=U?i:Xe(i);p.state.next({...je&&r,name:o.mount||je?w:void 0,values:Ge})}},pe=(w,A,I={})=>fe(w,A,I,!1),ae=(w,A={})=>{const I=Et(w)?w(i):w;if(!zt(i,I)){i={...i,...I};for(const U of a.mount)fe(U,G(I,U),A,!0);p.state.next({...r,name:void 0,type:void 0,values:i}),A.shouldValidate&&v()}},we=async w=>{o.mount=!0;const A=w.target;let I=A.name,U=!0;const z=G(n,I),W=se=>{U=Number.isNaN(se)||tn(se)&&isNaN(se.getTime())||zt(se,G(i,I,se))},V=fd(t.mode),ne=fd(t.reValidateMode);if(z){let se,je;const Ge=A.type?dd(z._f):ol(w),st=w.type===jr.BLUR||w.type===jr.FOCUS_OUT,Vt=!tO(z._f)&&!e.validate&&!t.resolver&&!G(r.errors,I)&&!z._f.deps||sO(st,G(r.touchedFields,I),r.isSubmitted,ne,V),us=fa(I,a,st);Ve(i,I,Ge),st?(!A||!A.readOnly)&&(z._f.onBlur&&z._f.onBlur(w),c&&c(0)):z._f.onChange&&z._f.onChange(w);const Yr=E(I,Ge,st),ct=!ft(Yr)||us;if(!st&&p.state.next({name:I,type:w.type,values:Xe(i)}),Vt)return(f.isValid||m.isValid)&&(t.mode==="onBlur"?st&&v():st||v()),ct&&p.state.next({name:I,...us?{}:Yr});if(!t.resolver&&e.validate&&await N({name:I,eventType:w.type}),!st&&us&&p.state.next({...r}),t.resolver){const{errors:Ct}=await P([I]);if(y([I]),W(Ge),!U){!ft(Yr)&&p.state.next(Yr);return}const It=pd(r.errors,n,I),er=pd(Ct,n,It.name||I);se=er.error,I=er.name,je=ft(Ct)}else y([I],!0),se=(await vd(z,a.disabled,i,b,t.shouldUseNativeValidation))[I],y([I]),W(Ge),U&&(se?je=!1:(f.isValid||m.isValid)&&(je=await R({fields:n,onlyCheckValid:!0,name:I,eventType:w.type})));U&&(z._f.deps&&(!Array.isArray(z._f.deps)||z._f.deps.length>0)&&F(z._f.deps),j(I,je,se,Yr))}},ye=(w,A)=>{if(G(r.errors,A)&&w.focus)return w.focus(),1},F=async(w,A={})=>{let I,U;const z=$i(w);if(t.resolver){const W=await O(Qe(w)?w:z);I=ft(W),U=w?!z.some(V=>G(W,V)):I}else w?(U=(await Promise.all(z.map(async W=>{const V=G(n,W);return await R({fields:V&&V._f?{[W]:V}:V,eventType:jr.TRIGGER})}))).every(Boolean),!(!U&&!r.isValid)&&v()):U=I=await R({fields:n,name:w,eventType:jr.TRIGGER});return p.state.next({...!At(w)||(f.isValid||m.isValid)&&I!==r.isValid?{}:{name:w},...t.resolver||!w?{isValid:I}:{},errors:r.errors}),A.shouldFocus&&!U&&Ds(n,ye,w?z:a.mount),U},B=(w,A)=>{let I={...o.mount?i:s};return A&&(I=jp(A.dirtyFields?r.dirtyFields:r.touchedFields,I)),Qe(w)?I:At(w)?G(I,w):w.map(U=>G(I,U))},Z=(w,A)=>({invalid:!!G((A||r).errors,w),isDirty:!!G((A||r).dirtyFields,w),error:G((A||r).errors,w),isValidating:!!G(r.validatingFields,w),isTouched:!!G((A||r).touchedFields,w)}),he=w=>{const A=w?$i(w):void 0;A==null||A.forEach(I=>nt(r.errors,I)),A?A.forEach(I=>{p.state.next({name:I,errors:r.errors})}):p.state.next({errors:{}})},be=(w,A,I)=>{const U=(G(n,w,{_f:{}})._f||{}).ref,z=G(r.errors,w)||{},{ref:W,message:V,type:ne,...se}=z;Ve(r.errors,w,{...se,...A,ref:U}),p.state.next({name:w,errors:r.errors,isValid:!1}),I&&I.shouldFocus&&U&&U.focus&&U.focus()},me=(w,A)=>Et(w)?p.state.subscribe({next:I=>"values"in I&&w(I.values||ee(void 0,A),I)}):ee(w,A,!0),le=w=>p.state.subscribe({next:A=>{if(nO(w.name,A.name,w.exact)&&rO(A,w.formState||f,Gr,w.reRenderRoot)){const I={...i};w.callback({values:I,...r,...A,defaultValues:s})}}}).unsubscribe,ve=w=>(o.mount=!0,m={...m,...w.formState},le({...w,formState:{...d,...w.formState}})),Te=(w,A={})=>{for(const I of w?$i(w):a.mount)a.mount.delete(I),a.array.delete(I),A.keepValue||(nt(n,I),nt(i,I)),!A.keepError&&nt(r.errors,I),!A.keepDirty&&nt(r.dirtyFields,I),!A.keepTouched&&nt(r.touchedFields,I),!A.keepIsValidating&&nt(r.validatingFields,I),!t.shouldUnregister&&!A.keepDefaultValue&&nt(s,I);p.state.next({values:Xe(i)}),p.state.next({...r,...A.keepDirty?{isDirty:$()}:{}}),!A.keepIsValid&&v()},Y=({disabled:w,name:A})=>{if(Ut(w)&&o.mount||w||a.disabled.has(A)){const z=a.disabled.has(A)!==!!w;w?a.disabled.add(A):a.disabled.delete(A),z&&o.mount&&!o.action&&v()}},ce=(w,A={})=>{let I=G(n,w);const U=Ut(A.disabled)||Ut(t.disabled),z=!a.registerName.has(w)&&I&&I._f&&!I._f.mount;return Ve(n,w,{...I||{},_f:{...I&&I._f?I._f:{ref:{name:w}},name:w,mount:!0,...A}}),a.mount.add(w),I&&!z?Y({disabled:Ut(A.disabled)?A.disabled:t.disabled,name:w}):D(w,!0,A.value),{...U?{disabled:A.disabled||t.disabled}:{},...t.progressive?{required:!!A.required,min:Cs(A.min),max:Cs(A.max),minLength:Cs(A.minLength),maxLength:Cs(A.maxLength),pattern:Cs(A.pattern)}:{},name:w,onChange:we,onBlur:we,ref:W=>{if(W){a.registerName.add(w),ce(w,A),a.registerName.delete(w),I=G(n,w);const V=Qe(W.value)&&W.querySelectorAll&&W.querySelectorAll("input,select,textarea")[0]||W,ne=KL(V),se=I._f.refs||[];if(ne?se.find(je=>je===V):V===I._f.ref)return;Ve(n,w,{_f:{...I._f,...ne?{refs:[...se.filter(da),V,...Array.isArray(G(s,w))?[{}]:[]],ref:{type:V.type,name:w}}:{ref:V}}}),D(w,!1,void 0,V)}else I=G(n,w,{}),I._f&&(I._f.mount=!1),(t.shouldUnregister||A.shouldUnregister)&&!(kp(a.array,w)&&o.action)&&a.unMount.add(w)}}},Q=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Ds(n,ye,a.mount),Ce=w=>{Ut(w)&&(p.state.next({disabled:w}),Ds(n,(A,I)=>{const U=G(n,I);U&&(A.disabled=U._f.disabled||w,Array.isArray(U._f.refs)&&U._f.refs.forEach(z=>{z.disabled=U._f.disabled||w}))},0,!1))},qe=(w,A)=>async I=>{let U;I&&(I.preventDefault&&I.preventDefault(),I.persist&&I.persist());let z=Xe(i);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:W,values:V}=await P();y(),r.errors=W,z=Xe(V)}else await R({fields:n,eventType:jr.SUBMIT});if(a.disabled.size)for(const W of a.disabled)nt(z,W);if(nt(r.errors,Dp),ft(r.errors)){p.state.next({errors:{}});try{await w(z,I)}catch(W){U=W}}else A&&await A({...r.errors},I),Q(),setTimeout(Q);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ft(r.errors)&&!U,submitCount:r.submitCount+1,errors:r.errors}),U)throw U},et=(w,A={})=>{G(n,w)&&(Qe(A.defaultValue)?pe(w,Xe(G(s,w))):(pe(w,A.defaultValue),Ve(s,w,Xe(A.defaultValue))),A.keepTouched||nt(r.touchedFields,w),A.keepDirty||(nt(r.dirtyFields,w),r.isDirty=A.defaultValue?$(w,Xe(G(s,w))):$()),A.keepError||(nt(r.errors,w),f.isValid&&v()),p.state.next({...r}))},$e=(w,A={})=>{const I=w?Xe(w):s,U=Xe(I),z=ft(w),W=U;if(A.keepDefaultValues||(s=I),!A.keepValues){if(A.keepDirtyValues){const V=new Set([...a.mount,...Object.keys(Xr(s,i))]);for(const ne of Array.from(V)){const se=G(r.dirtyFields,ne),je=G(i,ne),Ge=G(W,ne);se&&!Qe(je)?Ve(W,ne,je):!se&&!Qe(Ge)&&pe(ne,Ge)}}else{if(No&&Qe(w))for(const V of a.mount){const ne=G(n,V);if(ne&&ne._f){const se=Array.isArray(ne._f.refs)?ne._f.refs[0]:ne._f.ref;if(ro(se)){const je=se.closest("form");if(je){je.reset();break}}}}if(A.keepFieldsRef)for(const V of a.mount)pe(V,G(W,V));else n={}}if(t.shouldUnregister){if(i=A.keepDefaultValues?Xe(s):{},A.keepFieldsRef)for(const V of a.mount)Ve(i,V,G(W,V))}else i=Xe(W);p.array.next({values:{...W}}),p.state.next({values:{...W}})}a={mount:A.keepDirtyValues?a.mount:new Set,unMount:new Set,array:new Set,registerName:new Set,disabled:new Set,watch:new Set,watchAll:!1,focus:""},o.mount=!f.isValid||!!A.keepIsValid||!!A.keepDirtyValues||!t.shouldUnregister&&!ft(W),o.watch=!!t.shouldUnregister,o.keepIsValid=!!A.keepIsValid,o.action=!1,A.keepErrors||(r.errors={}),p.state.next({submitCount:A.keepSubmitCount?r.submitCount:0,isDirty:z?!1:A.keepDirty?r.isDirty:A.keepValues?$():!!(A.keepDefaultValues&&!zt(w,s)),isSubmitted:A.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:z?{}:A.keepDirtyValues?A.keepDefaultValues&&i?Xr(s,i):r.dirtyFields:A.keepDefaultValues&&w?Xr(s,w):A.keepDirty?r.dirtyFields:{},touchedFields:A.keepTouched?r.touchedFields:{},errors:A.keepErrors?r.errors:{},isSubmitSuccessful:A.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},We=(w,A)=>$e(Et(w)?w(i):w,{...t.resetOptions,...A}),tt=(w,A={})=>{const I=G(n,w),U=I&&I._f;if(U){const z=U.refs?U.refs[0]:U.ref;z.focus&&setTimeout(()=>{z.focus(),A.shouldSelect&&Et(z.select)&&z.select()})}},Gr=w=>{r={...r,...w}},Kr={control:{register:ce,unregister:Te,getFieldState:Z,handleSubmit:qe,setError:be,_subscribe:le,_runSchema:P,_updateIsValidating:y,_focusError:Q,_getWatch:ee,_getDirty:$,_setValid:v,_setFieldArray:S,_setDisabledField:Y,_setErrors:x,_getFieldArray:H,_reset:$e,_resetDefaultValues:()=>Et(t.defaultValues)&&t.defaultValues().then(w=>{We(w,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:M,_disableForm:Ce,_subjects:p,_proxyFormState:f,get _fields(){return n},get _formValues(){return i},get _state(){return o},set _state(w){o=w},get _defaultValues(){return s},get _names(){return a},set _names(w){a=w},get _formState(){return r},get _options(){return t},set _options(w){t={...t,...w}}},subscribe:ve,trigger:F,register:ce,handleSubmit:qe,watch:me,setValue:pe,setValues:ae,getValues:B,reset:We,resetField:et,resetDefaultValues:(w,A={})=>{if(s=Xe(w),!A.keepDirty){const I=Xr(s,i);r.dirtyFields=I,r.isDirty=!ft(I)}A.keepIsValid||v(),p.state.next({...r,defaultValues:s})},clearErrors:he,unregister:Te,setError:be,setFocus:tt,getFieldState:Z};return{...Kr,formControl:Kr}}function lO(e={}){const t=g.useRef(void 0),r=g.useRef(void 0),n=g.useRef(e.formControl),[s,i]=g.useState(()=>({...Xe(qp),isLoading:Et(e.defaultValues),errors:e.errors||{},disabled:e.disabled||!1,defaultValues:Et(e.defaultValues)?void 0:e.defaultValues}));if(!t.current||e.formControl&&n.current!==e.formControl)if(n.current=e.formControl,e.formControl)t.current={...e.formControl,formState:s},e.defaultValues&&!Et(e.defaultValues)&&e.formControl.reset(e.defaultValues,e.resetOptions);else{const{formControl:a,...c}=aO(e);t.current={...c,formState:s}}const o=t.current.control;return o._options=e,Kl(()=>{const a=o._subscribe({formState:o._proxyFormState,callback:()=>i({...o._formState,defaultValues:o._defaultValues}),reRenderRoot:!0});return i(c=>({...c,isReady:!0})),o._formState.isReady=!0,a},[o]),g.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),g.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),g.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),g.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),g.useEffect(()=>{if(o._proxyFormState.isDirty){const a=o._getDirty();a!==s.isDirty&&o._subjects.state.next({isDirty:a})}},[o,s.isDirty]),g.useEffect(()=>{var a;e.values&&!zt(e.values,r.current)?(o._reset(e.values,{keepFieldsRef:!0,...o._options.resetOptions}),!((a=o._options.resetOptions)===null||a===void 0)&&a.keepIsValid||o._setValid(),r.current=e.values,i(c=>({...c}))):o._resetDefaultValues()},[o,e.values]),g.useEffect(()=>{o._state.mount||(o._setValid(),o._state.mount=!0),o._state.watch&&(o._state.watch=!1,o._subjects.state.next({...o._formState})),o._removeUnmounted()}),t.current.formState=g.useMemo(()=>Op(s,o),[o,s]),t.current}function cO(e,t,r){const n=e??[],s=new Set(n.map(d=>d.type).filter(Boolean)),i=(t??[]).filter(d=>!s.has(d)),{data:o}=Jn({queryKey:["framework-search",i.sort().join(","),r],queryFn:()=>_0({type:i,systemDefault:"Yes"}),enabled:i.length>0,staleTime:600*1e3}),a=t&&t.length?n.filter(d=>d.type&&t.includes(d.type)):n,c=[...(o??[]).map(d=>({label:d.name,value:d.identifier})),...a.map(d=>({label:d.name,value:d.identifier}))],u=new Set;return c.filter(d=>u.has(d.value)?!1:(u.add(d.value),!0))}async function $p(e){var r,n;return(n=(r=(await Fe.get(`/action/channel/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.channel}function uO(e){var r,n,s,i,o,a,c;const t=Jn({queryKey:["channel",e],queryFn:()=>$p(e),enabled:!!e,staleTime:6e5});return{identifier:((r=t.data)==null?void 0:r.identifier)??e??"",name:(n=t.data)==null?void 0:n.name,frameworks:(s=t.data)==null?void 0:s.frameworks,collectionAdditionalCategories:(i=t.data)==null?void 0:i.collectionAdditionalCategories,contentAdditionalCategories:(o=t.data)==null?void 0:o.contentAdditionalCategories,defaultLicense:(a=t.data)==null?void 0:a.defaultLicense,defaultFramework:(c=t.data)==null?void 0:c.defaultFramework,isLoading:t.isLoading}}function dO(e){const{data:t}=Jn({queryKey:["user","read",e],enabled:!!e,staleTime:1/0,queryFn:()=>V0(e)});return t&&([t.firstName,t.lastName].filter(Boolean).join(" ").trim()||t.userName)||void 0}const Up=[{label:"Strict",value:"strict"},{label:"Adaptive",value:"adaptive"},{label:"Prior learning",value:"priorLearning"}],fO={"First Section":{title:"Basic Information",description:"Core details that define the content identity."},"Second Section":{title:"Categorisation",description:"Category and type classification for the content."},"Third Section":{title:"Categorisation",description:"Category and type classification for the content."},"Organisation Framework Terms":{title:"Curriculum",description:"Framework-aligned categorisation."},"Target Framework Terms":{title:"Target Audience",description:"Curriculum alignment for the intended learners."},"Fourth Section":{title:"Licensing & Attribution",description:"Copyright and usage rights information."},"Sixth Section":{title:"Licensing & Attribution",description:"Copyright and usage rights information."},"Consumption policy":{title:"Consumption policy",description:"How learners move through this path."}},hO=new Set(["review","read","sourcingreview","orgreview"]),Si={"First Section":"details","Second Section":"details","Third Section":"details","Organisation Framework Terms":"details","Target Framework Terms":"audience","Fourth Section":"licensing","Sixth Section":"licensing"},pO={Categorisation:"Second Section","Basic Information":"First Section","Licensing & Attribution":"Fourth Section",Curriculum:"Organisation Framework Terms","Target Audience":"Target Framework Terms"},mO={name:"details",description:"details",keywords:"details",appIcon:"details",primaryCategory:"details",additionalCategories:"details",board:"details",boardIds:"details",subject:"details",subjectIds:"details",medium:"details",framework:"details",topicsIds:"details",topic:"details",dialcodeRequired:"details",dialcodes:"details",audience:"audience",targetBoardIds:"audience",targetMediumIds:"audience",targetGradeLevelIds:"audience",targetSubjectIds:"audience",gradeLevel:"audience",creator:"licensing",author:"licensing",attributions:"licensing",license:"licensing",copyright:"licensing",copyrightYear:"licensing"},ui={board:"board",boardIds:"board",medium:"medium",gradeLevel:"gradeLevel",subject:"subject",subjectIds:"subject",topicsIds:"topic",topic:"topic",targetBoardIds:"board",targetMediumIds:"medium",targetGradeLevelIds:"gradeLevel",targetSubjectIds:"subject"},Jl=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds"]);function zp(e,t,r,n,s={}){if(!(e!=null&&e.length))return yd(jO(t,n,r,s),r,t,n,s);const i=new Map;for(const c of e){const u=c.code;u&&!i.has(u)&&i.set(u,c)}const o=new Set,a=e.filter(c=>{var d;if(n&&(c.code==="dialCode"||c.code==="dialcode")||((d=s.profile)==null?void 0:d.key)==="learningPath"&&Jl.has(c.code)||c.visible===!1)return!1;const u=c.code;return o.has(u)?!1:(o.add(u),!0)}).map(c=>{const u=c.code??"",d=_O(c),f=wO(c,r,t,i,s),m=t[u],p=vO(u,Vp(m,d),d,t,s),b={code:u,label:c.label??u,inputType:d,required:!!(c.required===!0||Array.isArray(c.validations)&&c.validations.some(h=>h.type==="required")),editable:gO(u,c.editable!==!1,s),placeholder:c.placeholder,maxLength:c.maxLength,options:CO(f,p,d,r),depends:c.depends,tab:SO(c),section:c.section,sourceCategory:c.sourceCategory,defaultValue:c.defaultValue??c.default,currentValue:p};if(u==="dialcodes"){const h=t.dialcodeRequired==="Yes";return{...b,required:h,visible:h}}return b});return yd(a,r,t,n,s)}function yd(e,t,r,n,s){var i;return((i=s.profile)==null?void 0:i.key)==="learningPath"?NO(e,t,r,n):OO(e,t,r,n)}function gO(e,t,r){var i;const n=r.editorMode??"edit";if(!hO.has(n))return t!==!1;const s=(i=r.editableFields)==null?void 0:i[n];return!!(s&&s.includes(e))}function vO(e,t,r,n,s){const i=t==null||t===""||Array.isArray(t)&&t.length===0;switch(e){case"license":return i?s.defaultLicense??"":t;case"copyright":return i&&s.channelName?s.channelName:t;case"copyrightYear":return i?String(new Date().getFullYear()):t;case"author":case"creator":return i&&s.userFullName?s.userFullName:t;case"instructions":{const o=n.instructions;return o&&typeof o=="object"&&!Array.isArray(o)?o.default??"":typeof t=="object"&&t!==null?"":t}case"maxTime":case"warningTime":{if(!i)return t;const o=n.timeLimits,a=o==null?void 0:o[e];return a!=null&&a!==""?yO(Number(a)):t}default:return t}}function yO(e){if(!Number.isFinite(e)||e<0)return"";const t=Math.floor(e%60),r=Math.floor(e/60%60),n=Math.floor(e/3600),s=i=>String(i).padStart(2,"0");return n>0?`${s(n)}:${s(r)}:${s(t)}`:`${s(r)}:${s(t)}`}function bO(e){var n,s,i;const t=new Map,r=o=>o==null?void 0:o.forEach(a=>{a.identifier&&t.set(a.identifier,a.name),a.name&&t.set(a.name,a.name)});return(s=(n=e.organisationFramework)==null?void 0:n.categories)==null||s.forEach(o=>r(o.terms)),(i=e.targetFrameworks)==null||i.forEach(o=>{var a;return(a=o.categories)==null?void 0:a.forEach(c=>r(c.terms))}),t}function CO(e,t,r,n){if(r!=="select"&&r!=="multiselect"&&r!=="radio")return e;const s=Array.isArray(t)?t:t!=null&&t!==""?[t]:[];if(!s.length)return e;const i=e?[...e]:[],o=new Set(i.map(c=>c.value)),a=bO(n);for(const c of s){const u=String(c);o.has(u)||(i.push({label:a.get(u)??u,value:u}),o.add(u))}return i}function SO(e){const t=e.section;if(t){if(Si[t])return Si[t];const n=pO[t];if(n&&Si[n])return Si[n]}const r=e.code??"";return mO[r]??"details"}function Vp(e,t){const r=new Set(["multiselect","chips","keywords","tagsinput"]),n=new Set(["select","text","textarea","radio","datepicker","datetime","license"]);return r.has(t)?Array.isArray(e)?e:e!=null&&e!==""?[e]:[]:n.has(t)?Array.isArray(e)?e[0]??"":e??"":e}function _O(e){const t=(e.inputType??e.dataType??"").toLowerCase(),n=(e.dataType??"").toLowerCase()==="list";return t==="select"?"select":t==="framework"||t==="frameworkcategoryselect"?n?"multiselect":"select":t==="topicselector"?"chips":t==="multiselect"||t==="multi-select"?"multiselect":t==="keywords"||e.code==="keywords"||e.code==="topic"||e.code==="topicsIds"?"chips":t==="radio"?"radio":e.code==="appIcon"||t==="appicon"?"appIcon":t==="textarea"||e.code==="description"?"textarea":t==="datepicker"||t==="date"?"datepicker":t==="datetime"||t==="datetime-local"?"datetime":t==="tagsinput"?"tagsinput":t==="nestedselect"||t==="nested-select"?n?"multiselect":"select":t==="license"?"license":t==="dialcode"||t==="dial-code"?"dialcode":"text"}function wO(e,t,r,n,s){var u;const i=e.code??"";if(((u=s.profile)==null?void 0:u.key)==="learningPath"&&i==="policy")return Up;if(i==="maxQuestions"){const d=s.childCount??0;if(d>0)return Array.from({length:d},(f,m)=>({label:String(m+1),value:String(m+1)}))}const o=e.range;if(Array.isArray(o)&&o.length)return typeof o[0]=="string"?o.map(d=>({label:d,value:d})):o.map(d=>({label:d.name,value:d.identifier}));const a=e.enum;if(a!=null&&a.length)return a.map(d=>({label:d,value:d}));if(i==="framework")return t.orgFrameworks;if(i==="additionalCategories"){const f=(s.objectType??"")==="QuestionSet"?s.contentAdditionalCategories??s.collectionAdditionalCategories:s.collectionAdditionalCategories??s.contentAdditionalCategories,m=(f&&f.length?f:s.contextAdditionalCategories)??t.channelAdditionalCategories;return m!=null&&m.length?AO(m).map(p=>({label:p,value:p})):void 0}const c=e.sourceCategory??ui[i];if(c)return Hp(i,c,e,t,r,n)}function xO(e,t){return Jl.has(e)||t.output==="identifier"||typeof t.section=="string"&&t.section.includes("Target")}function TO(e,t){return Jl.has(e)||typeof t.section=="string"&&t.section.includes("Target")}function ha(e,t,r){var i,o,a,c,u;const n=(o=(i=e.organisationFramework)==null?void 0:i.categories)==null?void 0:o.find(d=>d.code===t),s=(u=(c=(a=e.targetFrameworks)==null?void 0:a[0])==null?void 0:c.categories)==null?void 0:u.find(d=>d.code===t);return r?(s==null?void 0:s.terms)??(n==null?void 0:n.terms)??[]:(n==null?void 0:n.terms)??(s==null?void 0:s.terms)??[]}function EO(e){const t=new Set,r=[];for(const n of e){const s=n.identifier??n.name;s&&!t.has(s)&&(t.add(s),r.push(n))}return r}function AO(e){return Array.from(new Set(e))}function kO(e){return Array.isArray(e)?e:e!=null&&e!==""?[e]:[]}function Hp(e,t,r,n,s,i){const o=xO(e,r),a=TO(e,r),c=h=>({label:h.name,value:o?h.identifier:h.name}),u=r.depends;if(!(u!=null&&u.length))return ha(n,t,a).map(c);const d=u.flatMap(h=>kO(s[h])).map(String);if(!d.length)return[];const f=[];for(const h of u){const v=i.get(h),y=(v==null?void 0:v.sourceCategory)??ui[h]??h;f.push(...ha(n,y,a))}const p=f.filter(h=>d.includes(String(h.name))||d.includes(String(h.identifier))||d.includes(String(h.code))).flatMap(h=>h.associations??[]).filter(h=>String(h.category??"").toLowerCase()===t.toLowerCase()),b=EO(p);return b.length?b.map(c):ha(n,t,a).map(c)}function Ss(e,t){const r=ui[e];if(r)return Hp(e,r,{},t,{},new Map)}function Ye(e,t,r){return Vp(e[t],r)}const IO=["board","medium","gradeLevel","subject"];function DO(e){var r;const t=((r=e.organisationFramework)==null?void 0:r.categories)??[];return t.length?t.some(n=>IO.includes(n.code)):!0}function LO(e,t){var r,n,s;return!!((n=(r=e.organisationFramework)==null?void 0:r.categories)!=null&&n.some(i=>i.code===t)||(s=e.targetFrameworks)!=null&&s.some(i=>{var o;return(o=i.categories)==null?void 0:o.some(a=>a.code===t)}))}function OO(e,t,r,n){var c;if(!n||DO(t))return e;const s=e.filter(u=>{const d=u.sourceCategory??ui[u.code];return!d||LO(t,d)}),i=new Set(s.map(u=>u.code)),o=[];for(const u of((c=t.organisationFramework)==null?void 0:c.categories)??[])i.has(u.code)||o.push({code:u.code,label:u.name,inputType:"multiselect",editable:!0,tab:"details",section:"Organisation Framework Terms",options:(u.terms??[]).map(d=>({label:d.name,value:d.name})),currentValue:Ye(r,u.code,"multiselect")});if(!o.length)return s;const a=s.findIndex(u=>u.code==="framework");return a>=0?[...s.slice(0,a+1),...o,...s.slice(a+1)]:[...s,...o]}const pa="Organisation Framework Terms";function NO(e,t,r,n){var m,p;if(!n)return e;const s=[...((m=t.organisationFramework)==null?void 0:m.categories)??[]].sort((b,h)=>(b.index??1/0)-(h.index??1/0));if(!s.length)return e;const i=(p=Nh(s))==null?void 0:p.code,o=b=>b.sourceCategory??ui[b.code];let c=e.filter(b=>{const h=o(b);return h?h!==i&&s.some(v=>v.code===h):!0}).map(b=>o(b)?{...b,section:pa,required:!0,inputType:"select",currentValue:Ye(r,b.code,"select")}:b),u=c.findIndex(b=>b.code==="framework");if(u===-1){const b={code:"framework",label:"Curriculum",inputType:"select",required:!0,editable:!0,tab:"details",section:pa,options:t.orgFrameworks,currentValue:Ye(r,"framework","select")},h=c.findIndex(v=>!!o(v));u=h>=0?h:c.length,c=[...c.slice(0,u),b,...c.slice(u)]}const d=new Set(c.map(b=>b.code)),f=s.filter(b=>b.code!==i&&!d.has(b.code)).map(b=>({code:b.code,label:b.name,inputType:"select",required:!0,editable:!0,tab:"details",section:pa,options:(b.terms??[]).map(h=>({label:h.name,value:h.name})),currentValue:Ye(r,b.code,"select")}));return f.length?[...c.slice(0,u+1),...f,...c.slice(u+1)]:c}function jO(e,t,r,n={}){var i,o;const s=[{code:"name",label:"Title",inputType:"text",required:!0,editable:!0,tab:"details",section:"First Section",maxLength:200,currentValue:Ye(e,"name","text")},{code:"description",label:"Description",inputType:"textarea",editable:!0,tab:"details",section:"First Section",maxLength:2e3,currentValue:Ye(e,"description","textarea")},{code:"keywords",label:"Keywords",inputType:"chips",editable:!0,tab:"details",section:"First Section",currentValue:Ye(e,"keywords","chips")}];return t?((i=n.profile)==null?void 0:i.key)==="learningPath"?(s.push({code:"framework",label:"Curriculum",inputType:"select",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:r.orgFrameworks,currentValue:Ye(e,"framework","select")},{code:"policy",label:"Consumption policy",inputType:"select",required:!0,editable:!0,tab:"details",section:"Consumption policy",options:Up,currentValue:Ye(e,"policy","select")||"strict"}),s):(s.push({code:"primaryCategory",label:"Category",inputType:"select",editable:!1,tab:"details",section:"Second Section",currentValue:Ye(e,"primaryCategory","select")},{code:"additionalCategories",label:"Additional Category",inputType:"multiselect",editable:!0,tab:"details",section:"Second Section",currentValue:Ye(e,"additionalCategories","multiselect"),options:(o=r.channelAdditionalCategories)==null?void 0:o.map(a=>({label:a,value:a}))},{code:"framework",label:"Course Type",inputType:"select",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:r.orgFrameworks,currentValue:Ye(e,"framework","select")},{code:"subjectIds",label:"Subjects covered",inputType:"multiselect",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:Ss("subjectIds",r),currentValue:Ye(e,"subjectIds","multiselect")}),s.push({code:"audience",label:"Audience Type",inputType:"multiselect",editable:!0,tab:"audience",section:"Target Framework Terms",currentValue:Ye(e,"audience","multiselect")},{code:"targetBoardIds",label:"Board/Syllabus of the audience",inputType:"select",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",options:Ss("targetBoardIds",r),currentValue:Ye(e,"targetBoardIds","select")},{code:"targetMediumIds",label:"Medium(s) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetBoardIds"],options:Ss("targetMediumIds",r),currentValue:Ye(e,"targetMediumIds","multiselect")},{code:"targetGradeLevelIds",label:"Class(es) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetMediumIds"],options:Ss("targetGradeLevelIds",r),currentValue:Ye(e,"targetGradeLevelIds","multiselect")},{code:"targetSubjectIds",label:"Subject(s) of the audience",inputType:"multiselect",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",depends:["targetGradeLevelIds"],options:Ss("targetSubjectIds",r),currentValue:Ye(e,"targetSubjectIds","multiselect")}),s.push({code:"creator",label:"Author",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"creator","text")},{code:"attributions",label:"Attributions",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"attributions","text")},{code:"copyright",label:"Copyright",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"copyright","text")},{code:"copyrightYear",label:"Copyright Year",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"copyrightYear","text")},{code:"license",label:"License",inputType:"select",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Ye(e,"license","select")}),s):s}const PO=["allowECM","levels","setPeriod","instances"];function Qp(e){const t={};return e.forEach((r,n)=>{t[`L${n+1}`]={label:r}}),t}function RO(e,t={}){const r={...e};for(const i of PO)delete r[i];const n=e.levels;Array.isArray(n)&&n.length&&(r.outcomeDeclaration={levels:Qp(n)});const s=e.instances;return s!=null&&s!==""&&(r.instances={label:s}),t.isReview&&(r.name===void 0||r.name===null||r.name==="")&&t.nodeTitle&&(r.name=t.nodeTitle),r}function FO(e,t){return e==="allowECM"||e==="setPeriod"?null:e==="levels"?{outcomeDeclaration:{levels:Array.isArray(t)?Qp(t):{}}}:e==="instances"?{instances:t!=null&&t!==""?{label:t}:""}:{[e]:t}}function MO(e,t){const{watch:r,setValue:n}=e,s=g.useRef(!1);g.useEffect(()=>{const i=r((o,{name:a})=>{var c;if(!(!a||s.current)){s.current=!0;try{const u=new Set([a]);let d=!0;for(;d;){d=!1;for(const f of t)u.has(f.code)||(c=f.depends)!=null&&c.some(m=>u.has(m))&&(n(f.code,f.inputType==="multiselect"||f.inputType==="chips"?[]:"",{shouldDirty:!0}),u.add(f.code),d=!0)}}finally{s.current=!1}}});return()=>i.unsubscribe()},[r,n,t])}const BO="_section_qa0tm_1",qO="_header_qa0tm_11",$O="_title_qa0tm_17",UO="_description_qa0tm_24",zO="_divider_qa0tm_30",VO="_fields_qa0tm_36",Nn={section:BO,header:qO,title:$O,description:UO,divider:zO,fields:VO},HO=({title:e,description:t,children:r})=>l.jsxs("div",{className:Nn.section,children:[l.jsxs("div",{className:Nn.header,children:[l.jsx("h3",{className:Nn.title,children:e}),t&&l.jsx("p",{className:Nn.description,children:t})]}),l.jsx("hr",{className:Nn.divider}),l.jsx("div",{className:Nn.fields,children:r})]}),QO="_field_93co8_1",WO="_fullWidth_93co8_7",GO="_label_93co8_11",KO="_required_93co8_19",YO="_input_93co8_24",ZO="_textarea_93co8_45",XO="_inputError_93co8_50",JO="_error_93co8_54",eN="_selectBtn_93co8_59",tN="_selectOpen_93co8_83",rN="_placeholder_93co8_87",nN="_selectedVal_93co8_91",sN="_chevronUp_93co8_95",iN="_dropdown_93co8_100",oN="_option_93co8_116",aN="_optionSelected_93co8_134",lN="_noOpts_93co8_139",cN="_chipGroup_93co8_146",uN="_chipInput_93co8_158",dN="_addChipBtn_93co8_167",fN="_radioGroup_93co8_184",hN="_radioLabel_93co8_191",pN="_iconWrap_93co8_199",mN="_iconPreview_93co8_214",gN="_iconPlaceholder_93co8_220",vN="_removeIconBtn_93co8_233",yN="_tagChip_93co8_252",bN="_tagChipRemove_93co8_264",CN="_nestedSelectRow_93co8_278",SN="_dialcodeRow_93co8_287",_N="_validateBtn_93co8_293",wN="_dialcodeValid_93co8_315",xN="_dialcodeSpinner_93co8_325",q={field:QO,fullWidth:WO,label:GO,required:KO,input:YO,textarea:ZO,inputError:XO,error:JO,selectBtn:eN,selectOpen:tN,placeholder:rN,selectedVal:nN,chevronUp:sN,dropdown:iN,option:oN,optionSelected:aN,noOpts:lN,chipGroup:cN,chipInput:uN,addChipBtn:dN,radioGroup:fN,radioLabel:hN,iconWrap:pN,iconPreview:mN,iconPlaceholder:gN,removeIconBtn:vN,tagChip:yN,tagChipRemove:bN,nestedSelectRow:CN,dialcodeRow:SN,validateBtn:_N,dialcodeValid:wN,dialcodeSpinner:xN},bd=({name:e,label:t,required:r,disabled:n,multiline:s,maxLength:i,placeholder:o})=>{const a=oe(),{register:c,formState:{errors:u}}=Jt(),d=u[e],f={required:r?a.textField.requiredError.replace("{field}",t):!1,maxLength:i?{value:i,message:a.textField.maxLengthError.replace("{max}",String(i))}:void 0};return l.jsxs("div",{className:[q.field,s?q.fullWidth:""].join(" "),children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),s?l.jsx("textarea",{id:e,className:[q.input,q.textarea,d?q.inputError:""].join(" "),disabled:n,placeholder:o,rows:3,...c(e,f)}):l.jsx("input",{id:e,type:"text",className:[q.input,d?q.inputError:""].join(" "),disabled:n,placeholder:o,...c(e,f)}),d&&l.jsx("span",{className:q.error,children:String(d.message)})]})},TN=({name:e,label:t,options:r,required:n,disabled:s})=>{var v;const i=oe(),[o,a]=g.useState(!1),c=g.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:m}}=Jt(),p=d(e),b=((v=r.find(y=>y.value===p))==null?void 0:v.label)??i.selectField.selectPlaceholder,h=m[e];return g.useEffect(()=>{if(!o)return;const y=C=>{var S;(S=c.current)!=null&&S.contains(C.target)||a(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]),l.jsxs("div",{className:q.field,ref:c,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...u(e,{required:n?i.selectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:s,className:[q.selectBtn,h?q.inputError:"",o?q.selectOpen:""].join(" "),onClick:()=>a(y=>!y),children:[l.jsx("span",{className:p?q.selectedVal:q.placeholder,children:b}),l.jsx(Cn,{size:14,className:o?q.chevronUp:""})]}),o&&l.jsxs("div",{className:q.dropdown,children:[r.map(y=>l.jsxs("button",{type:"button",className:[q.option,p===y.value?q.optionSelected:""].join(" "),onClick:()=>{f(e,y.value,{shouldDirty:!0,shouldValidate:!0}),a(!1)},children:[l.jsx("span",{children:y.label}),p===y.value&&l.jsx(bn,{size:13})]},y.value)),!r.length&&l.jsx("span",{className:q.noOpts,children:i.selectField.noOptionsMessage})]}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},EN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=oe(),[o,a]=g.useState(!1),c=g.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:m}}=Jt(),p=d(e)??[],b=m[e],h=p.length?`${p.length} ${i.multiSelectField.selectedCountSuffix}`:i.multiSelectField.selectPlaceholder;g.useEffect(()=>{if(!o)return;const y=C=>{var S;(S=c.current)!=null&&S.contains(C.target)||a(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[o]);const v=y=>{const C=p.includes(y)?p.filter(S=>S!==y):[...p,y];f(e,C,{shouldDirty:!0,shouldValidate:!0})};return l.jsxs("div",{className:q.field,ref:c,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...u(e,{required:n?i.multiSelectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:s,className:[q.selectBtn,b?q.inputError:"",o?q.selectOpen:""].join(" "),onClick:()=>a(y=>!y),children:[l.jsx("span",{className:p.length?q.selectedVal:q.placeholder,children:h}),l.jsx(Cn,{size:14,className:o?q.chevronUp:""})]}),o&&l.jsxs("div",{className:q.dropdown,children:[r.map(y=>l.jsxs("button",{type:"button",className:[q.option,p.includes(y.value)?q.optionSelected:""].join(" "),onClick:()=>v(y.value),children:[l.jsx(bn,{size:13,style:{opacity:p.includes(y.value)?1:0}}),l.jsx("span",{children:y.label})]},y.value)),!r.length&&l.jsx("span",{className:q.noOpts,children:i.multiSelectField.noOptionsMessage})]}),b&&l.jsx("span",{className:q.error,children:String(b.message)})]})},AN=({name:e,label:t,required:r,disabled:n,placeholder:s})=>{const i=oe(),o=s??i.chipGroupField.addPlaceholder,[a,c]=g.useState(""),[u,d]=g.useState(!1),f=g.useRef(null),{watch:m,setValue:p,formState:{errors:b}}=Jt(),h=m(e)??[],v=b[e],y=()=>{const S=a.trim();S&&!h.includes(S)&&p(e,[...h,S],{shouldDirty:!0}),c(""),d(!1)},C=S=>p(e,h.filter(_=>_!==S),{shouldDirty:!0});return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:q.chipGroup,children:[h.map(S=>l.jsxs("span",{className:"sbx-chip filled",children:[S,!n&&l.jsx("button",{type:"button",className:"sbx-chip-remove",onClick:()=>C(S),"aria-label":`Remove ${S}`,children:"×"})]},S)),!n&&(u?l.jsx("input",{ref:f,autoFocus:!0,className:q.chipInput,value:a,onChange:S=>c(S.target.value),onKeyDown:S=>{S.key==="Enter"&&(S.preventDefault(),y()),S.key==="Escape"&&(c(""),d(!1))},onBlur:y,placeholder:o}):l.jsxs("button",{type:"button",className:q.addChipBtn,onClick:()=>{d(!0),setTimeout(()=>{var S;return(S=f.current)==null?void 0:S.focus()},50)},children:[l.jsx(Sn,{size:12})," ",i.chipGroupField.addButtonLabel]}))]}),v&&l.jsx("span",{className:q.error,children:String(v.message)})]})},kN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=oe(),{register:o,formState:{errors:a}}=Jt(),c=a[e];return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("div",{className:q.radioGroup,children:r.map(u=>l.jsxs("label",{className:q.radioLabel,children:[l.jsx("input",{type:"radio",value:u.value,disabled:s,...o(e,{required:n?i.radioField.requiredError.replace("{field}",t):!1})}),u.label]},u.value))}),c&&l.jsx("span",{className:q.error,children:String(c.message)})]})};async function IN(e,t,r,n){var o,a;const i=(a=(o=(await Fe.post("/action/asset/v1/create",{request:{asset:{primaryCategory:"asset",language:["English"],code:crypto.randomUUID(),name:e,mediaType:"image",mimeType:t,createdBy:r,creator:null,channel:n,keywords:""}}})).data)==null?void 0:o.result)==null?void 0:a.node_id;if(!i)throw new Error("Asset creation failed: no node_id returned");return i}async function DN(e,t){var s,i;const n=(i=(s=(await Fe.post(`/action/content/v3/upload/url/${e}`,{request:{content:{fileName:t}}})).data)==null?void 0:s.result)==null?void 0:i.pre_signed_url;if(!n)throw new Error("Pre-signed URL fetch failed");return n}async function LN(e,t,r={}){const n=await fetch(e,{method:"PUT",body:t,headers:{"x-ms-blob-type":"BlockBlob","Content-Type":"application/octet-stream",...r}});if(!n.ok)throw new Error(`Blob upload failed: ${n.status} ${n.statusText}`)}async function ON(e,t,r){var o,a;const n=new FormData;n.append("fileUrl",t),n.append("mimeType",r);const i=(a=(o=(await Fe.post(`/action/asset/v1/upload/${e}`,n,{params:{enctype:"multipart/form-data",processData:!1,contentType:!1,cache:!1}})).data)==null?void 0:o.result)==null?void 0:a.content_url;if(!i)throw new Error("Asset finalize failed: no content_url returned");return i}const NN="_overlay_1bq5u_1",jN="_modal_1bq5u_12",PN="_header_1bq5u_24",RN="_title_1bq5u_33",FN="_closeBtn_1bq5u_39",MN="_tabs_1bq5u_57",BN="_tab_1bq5u_57",qN="_activeTab_1bq5u_83",$N="_body_1bq5u_88",UN="_searchWrap_1bq5u_99",zN="_searchIcon_1bq5u_104",VN="_searchInput_1bq5u_113",HN="_grid_1bq5u_132",QN="_imgCell_1bq5u_148",WN="_imgCellSelected_1bq5u_166",GN="_thumb_1bq5u_171",KN="_noThumb_1bq5u_177",YN="_checkBadge_1bq5u_183",ZN="_loadMoreBtn_1bq5u_198",XN="_loadingRow_1bq5u_220",JN="_empty_1bq5u_230",ej="_spinner_1bq5u_237",tj="_uploadArea_1bq5u_247",rj="_dropZone_1bq5u_256",nj="_uploadIcon_1bq5u_277",sj="_dropText_1bq5u_281",ij="_dropSubtext_1bq5u_288",oj="_uploadPreview_1bq5u_294",aj="_hiddenInput_1bq5u_301",lj="_fileName_1bq5u_305",cj="_errorText_1bq5u_311",uj="_footer_1bq5u_318",dj="_cancelBtn_1bq5u_328",fj="_confirmBtn_1bq5u_345",Ee={overlay:NN,modal:jN,header:PN,title:RN,closeBtn:FN,tabs:MN,tab:BN,activeTab:qN,body:$N,searchWrap:UN,searchIcon:zN,searchInput:VN,grid:HN,imgCell:QN,imgCellSelected:WN,thumb:GN,noThumb:KN,checkBadge:YN,loadMoreBtn:ZN,loadingRow:XN,empty:JN,spinner:ej,uploadArea:tj,dropZone:rj,uploadIcon:nj,dropText:sj,dropSubtext:ij,uploadPreview:oj,hiddenInput:aj,fileName:lj,errorText:cj,footer:uj,cancelBtn:dj,confirmBtn:fj},Cd=18,Wp=({nodeId:e,currentValue:t,onSelect:r,onClose:n})=>{const s=oe(),[i,o]=g.useState("my"),[a,c]=g.useState(""),[u,d]=g.useState([]),[f,m]=g.useState(0),[p,b]=g.useState(!1),[h,v]=g.useState(null),[y,C]=g.useState(0),[S,_]=g.useState(null),[x,T]=g.useState(""),[D,E]=g.useState(!1),[j,P]=g.useState(""),O=g.useRef(null),N=K(F=>{var B,Z;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.channel)??""}),R=K(F=>{var B,Z;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.uid)??""}),M=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.cloudStorage)==null?void 0:he.presigned_headers)??{}}),$=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.config)==null?void 0:Z.assetConfig)==null?void 0:he.size)??1*1024*1024}),ee=K(F=>{var B,Z,he;return((he=(Z=(B=F.editorConfig)==null?void 0:B.config)==null?void 0:Z.assetConfig)==null?void 0:he.accepted)??"image/png,image/jpeg"}),H=g.useCallback(async(F,B,Z=!1)=>{var he;b(!0);try{const be={status:["Live"],mediaType:["image"],mimeType:["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml"]};i==="my"&&R&&(be.createdBy=R),N&&(be.channel=N);const le=((he=(await Fe.post("/action/composite/v3/search",{request:{filters:be,query:F,limit:Cd,offset:B,sort_by:{createdOn:"desc"},fields:["identifier","name","appIcon","artifactUrl","downloadUrl"]}},{headers:{"X-Source":"web"}})).data)==null?void 0:he.result)??{},ve=le.content??[];m(le.count??0),d(Te=>Z?[...Te,...ve]:ve)}catch{}finally{b(!1)}},[i,R,N]);g.useEffect(()=>{i!=="upload"&&(d([]),C(0),H(a,0))},[i]);const te=g.useRef(),de=F=>{c(F),clearTimeout(te.current),te.current=setTimeout(()=>{d([]),C(0),H(F,0)},400)},fe=()=>{const F=y+Cd;C(F),H(a,F,!0)},pe=()=>{const F=(h==null?void 0:h.artifactUrl)??(h==null?void 0:h.appIcon)??(h==null?void 0:h.downloadUrl)??"";F&&r(F)};g.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]);const ae=F=>{var he;const B=(he=F.target.files)==null?void 0:he[0];if(F.target.value="",!B)return;const Z=ee.split(",").map(be=>be.trim());if(!Z.includes(B.type)){const be=Z.map(me=>me.replace("image/","").toUpperCase()).join(", ");P(s.appIconPickerModal.invalidFileTypeError.replace("{types}",be));return}if(B.size>$){const be=($/1048576).toFixed(0);P(s.appIconPickerModal.fileTooLargeError.replace("{size}",be));return}x&&URL.revokeObjectURL(x),_(B),T(URL.createObjectURL(B)),P("")},we=async()=>{if(S){E(!0),P("");try{const F=await IN(S.name.split(".").slice(0,-1).join(".")||S.name,S.type,R,N),B=await DN(F,S.name);await LN(B,S,M);const Z=B.split("?")[0],he=await ON(F,Z,S.type);r(he)}catch(F){P(F instanceof Error?F.message:s.appIconPickerModal.uploadFailedError)}finally{E(!1)}}},ye=u.length<f;return l.jsx("div",{className:Ee.overlay,role:"dialog","aria-modal":"true","aria-label":s.appIconPickerModal.dialogAriaLabel,children:l.jsxs("div",{className:Ee.modal,children:[l.jsxs("div",{className:Ee.header,children:[l.jsx("span",{className:Ee.title,children:s.appIconPickerModal.title}),l.jsx("button",{className:Ee.closeBtn,onClick:n,"aria-label":s.appIconPickerModal.closeAriaLabel,children:l.jsx(br,{size:18})})]}),l.jsxs("div",{className:Ee.tabs,role:"tablist",children:[l.jsx("button",{role:"tab","aria-selected":i==="my",className:`${Ee.tab} ${i==="my"?Ee.activeTab:""}`,onClick:()=>o("my"),children:s.appIconPickerModal.myImagesTab}),l.jsx("button",{role:"tab","aria-selected":i==="all",className:`${Ee.tab} ${i==="all"?Ee.activeTab:""}`,onClick:()=>o("all"),children:s.appIconPickerModal.allImagesTab}),l.jsxs("button",{role:"tab","aria-selected":i==="upload",className:`${Ee.tab} ${i==="upload"?Ee.activeTab:""}`,onClick:()=>o("upload"),children:[l.jsx(Ma,{size:13,style:{marginRight:4}}),s.appIconPickerModal.uploadTab]})]}),l.jsx("div",{className:Ee.body,children:i!=="upload"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ee.searchWrap,children:[l.jsx(Yi,{size:14,className:Ee.searchIcon}),l.jsx("input",{type:"search",className:Ee.searchInput,placeholder:s.appIconPickerModal.searchPlaceholder,value:a,onChange:F=>de(F.target.value)})]}),p&&u.length===0?l.jsxs("div",{className:Ee.loadingRow,children:[l.jsx(ki,{size:20,className:Ee.spinner}),l.jsx("span",{children:s.appIconPickerModal.loadingText})]}):u.length===0?l.jsx("div",{className:Ee.empty,children:s.appIconPickerModal.noImagesFound}):l.jsx("div",{className:Ee.grid,children:u.map(F=>{const B=F.appIcon??F.artifactUrl??F.downloadUrl??"",Z=(h==null?void 0:h.identifier)===F.identifier;return l.jsxs("button",{type:"button",className:`${Ee.imgCell} ${Z?Ee.imgCellSelected:""}`,onClick:()=>v(F),title:F.name,children:[B?l.jsx("img",{src:B,alt:F.name,className:Ee.thumb}):l.jsx("div",{className:Ee.noThumb,children:s.appIconPickerModal.noThumbnailText}),Z&&l.jsx("div",{className:Ee.checkBadge,children:l.jsx(bn,{size:12})})]},F.identifier)})}),ye&&!p&&l.jsx("button",{className:Ee.loadMoreBtn,onClick:fe,children:s.appIconPickerModal.loadMoreButton}),p&&u.length>0&&l.jsx("div",{className:Ee.loadingRow,children:l.jsx(ki,{size:16,className:Ee.spinner})})]}):l.jsxs("div",{className:Ee.uploadArea,children:[l.jsx("div",{className:Ee.dropZone,onClick:()=>{var F;return(F=O.current)==null?void 0:F.click()},onDragOver:F=>F.preventDefault(),onDrop:F=>{F.preventDefault();const B=F.dataTransfer.files[0];B&&ae({target:{files:[B],value:""}})},children:x?l.jsx("img",{src:x,alt:s.appIconPickerModal.previewAlt,className:Ee.uploadPreview}):l.jsxs(l.Fragment,{children:[l.jsx(Ma,{size:32,className:Ee.uploadIcon}),l.jsx("p",{className:Ee.dropText,children:s.appIconPickerModal.dropZoneText}),l.jsx("p",{className:Ee.dropSubtext,children:s.appIconPickerModal.acceptedTypesInfo.replace("{types}",ee.split(",").map(F=>F.replace("image/","").toUpperCase()).join(", ")).replace("{size}",($/(1024*1024)).toFixed(0))})]})}),l.jsx("input",{ref:O,type:"file",accept:ee,className:Ee.hiddenInput,onChange:ae}),S&&l.jsx("p",{className:Ee.fileName,children:S.name}),j&&l.jsx("p",{className:Ee.errorText,children:j})]})}),l.jsxs("div",{className:Ee.footer,children:[l.jsx("button",{className:Ee.cancelBtn,onClick:n,children:s.appIconPickerModal.cancelButton}),i==="upload"?l.jsx("button",{className:Ee.confirmBtn,disabled:!S||D,onClick:we,children:D?l.jsxs(l.Fragment,{children:[l.jsx(ki,{size:14,className:Ee.spinner})," ",s.appIconPickerModal.uploadingText]}):s.appIconPickerModal.uploadAndUseButton}):l.jsx("button",{className:Ee.confirmBtn,disabled:!h,onClick:pe,children:s.appIconPickerModal.useSelectedButton})]})]})})},hj=({name:e,label:t,nodeId:r,required:n,disabled:s})=>{const i=oe(),[o,a]=g.useState(!1),{watch:c,setValue:u,register:d,formState:{errors:f}}=Jt(),m=c(e),p=f[e],b=v=>{u(e,v,{shouldDirty:!0,shouldValidate:!0}),a(!1)},h=()=>{u(e,"",{shouldDirty:!0,shouldValidate:!0})};return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...d(e,{required:n?i.appIconField.requiredError.replace("{field}",t):!1})}),l.jsx("div",{className:q.iconWrap,role:"button",tabIndex:s?-1:0,"aria-label":i.appIconField.selectIconAriaLabel,onClick:()=>!s&&a(!0),onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&!s&&a(!0)},children:m?l.jsx("img",{src:m,alt:i.appIconField.iconAlt,className:q.iconPreview}):l.jsxs("div",{className:q.iconPlaceholder,children:[l.jsx(qf,{size:20}),l.jsx("span",{children:i.appIconField.selectIconLabel})]})}),m&&!s&&l.jsxs("button",{type:"button",className:q.removeIconBtn,onClick:h,"aria-label":i.appIconField.removeIconAriaLabel,children:[l.jsx(So,{size:13}),l.jsx("span",{children:i.appIconField.removeLabel})]}),p&&l.jsx("span",{className:q.error,children:String(p.message)}),o&&l.jsx(Wp,{nodeId:r,currentValue:m,onSelect:b,onClose:()=>a(!1)})]})},pj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.dateTimeField.requiredError.replace("{field}",t):!1}});return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{id:e,type:"datetime-local",className:[q.input,a?q.inputError:""].join(" "),disabled:n,value:o.value??"",onChange:o.onChange,onBlur:o.onBlur,ref:o.ref}),a&&l.jsx("span",{className:q.error,children:String(a.message)})]})},mj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.keywordSuggestField.requiredError.replace("{field}",t):!1},defaultValue:[]}),[c,u]=g.useState(""),d=g.useRef(null),f=o.value??[],m=v=>{const y=v.trim();!y||f.includes(y)||o.onChange([...f,y])},p=v=>{o.onChange(f.filter(y=>y!==v))},b=v=>{v.key==="Enter"||v.key===","?(v.preventDefault(),m(c),u("")):v.key==="Backspace"&&c===""&&f.length>0&&p(f[f.length-1])},h=()=>{c.trim()&&(m(c),u("")),o.onBlur()};return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:[q.chipGroup,a?q.inputError:""].join(" "),onClick:()=>{var v;return!n&&((v=d.current)==null?void 0:v.focus())},style:{cursor:n?"not-allowed":"text"},children:[f.map(v=>l.jsxs("span",{className:q.tagChip,children:[v,!n&&l.jsx("button",{type:"button",className:q.tagChipRemove,onClick:y=>{y.stopPropagation(),p(v)},"aria-label":`Remove ${v}`,children:l.jsx(br,{size:11})})]},v)),!n&&l.jsx("input",{ref:d,className:q.chipInput,value:c,onChange:v=>u(v.target.value),onKeyDown:b,onBlur:h,placeholder:f.length===0?s.keywordSuggestField.inputPlaceholder:"",style:{flexGrow:1,minWidth:120}})]}),a&&l.jsx("span",{className:q.error,children:String(a.message)})]})},gj=({name:e,label:t,levels:r,required:n,disabled:s})=>{const i=oe(),{control:o}=Jt(),{field:a,fieldState:{error:c}}=ci({name:e,control:o,rules:{required:n?i.nestedSelectField.requiredError.replace("{field}",t):!1},defaultValue:{}}),u=a.value??{},d=(f,m,p)=>{const b={};for(let h=0;h<m;h++)b[r[h].code]=u[r[h].code]??"";b[f]=p;for(let h=m+1;h<r.length;h++)b[r[h].code]="";a.onChange(b)};return l.jsxs("div",{className:[q.field,q.fullWidth].join(" "),children:[l.jsxs("label",{className:q.label,children:[t,n&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("div",{className:q.nestedSelectRow,children:r.map((f,m)=>{const p=m>0&&!u[r[m-1].code];return l.jsxs("div",{className:q.field,style:{flex:1},children:[l.jsx("label",{className:q.label,htmlFor:`${e}_${f.code}`,children:f.label}),l.jsxs("select",{id:`${e}_${f.code}`,className:[q.input,c?q.inputError:""].join(" "),disabled:s||p,value:u[f.code]??"",onChange:b=>d(f.code,m,b.target.value),onBlur:a.onBlur,children:[l.jsx("option",{value:"",children:i.nestedSelectField.selectPlaceholder}),f.options.map(b=>l.jsx("option",{value:b.value,children:b.label},b.value))]})]},f.code)})}),c&&l.jsx("span",{className:q.error,children:String(c.message)})]})},Sd=[{label:"CC BY 4.0",value:"CC BY 4.0"},{label:"CC BY-SA 4.0",value:"CC BY-SA 4.0"},{label:"CC BY-NC 4.0",value:"CC BY-NC 4.0"},{label:"CC BY-NC-SA 4.0",value:"CC BY-NC-SA 4.0"},{label:"CC BY-ND 4.0",value:"CC BY-ND 4.0"},{label:"CC0 1.0 (Public Domain)",value:"CC0 1.0"}],vj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),[i,o]=g.useState(!1),a=g.useRef(null),{register:c,watch:u,setValue:d,formState:{errors:f}}=Jt(),m=u(e),p=Sd.find(v=>v.value===m),b=(p==null?void 0:p.label)??s.licenseSelectField.selectPlaceholder,h=f[e];return g.useEffect(()=>{if(!i)return;const v=y=>{var C;(C=a.current)!=null&&C.contains(y.target)||o(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[i]),l.jsxs("div",{className:q.field,ref:a,style:{position:"relative"},children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx("input",{type:"hidden",...c(e,{required:r?s.licenseSelectField.requiredError.replace("{field}",t):!1})}),l.jsxs("button",{type:"button",disabled:n,className:[q.selectBtn,h?q.inputError:"",i?q.selectOpen:""].join(" "),onClick:()=>o(v=>!v),"aria-haspopup":"listbox","aria-expanded":i,children:[l.jsx("span",{className:m?q.selectedVal:q.placeholder,children:b}),l.jsx(Cn,{size:14,className:i?q.chevronUp:""})]}),i&&l.jsx("div",{className:q.dropdown,role:"listbox",children:Sd.map(v=>l.jsxs("button",{type:"button",role:"option","aria-selected":m===v.value,className:[q.option,m===v.value?q.optionSelected:""].join(" "),onClick:()=>{d(e,v.value,{shouldDirty:!0,shouldValidate:!0}),o(!1)},children:[l.jsx("span",{children:v.label}),m===v.value&&l.jsx(bn,{size:13})]},v.value))}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},yj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),{field:o,fieldState:{error:a}}=ci({name:e,control:i,rules:{required:r?s.dialcodeInputField.requiredError.replace("{field}",t):!1},defaultValue:""}),[c,u]=g.useState("idle"),[d,f]=g.useState(""),m=async()=>{const b=(o.value??"").trim();if(!b){u("invalid"),f(s.dialcodeInputField.enterCodeMessage);return}u("loading"),f("");try{const h=await bT(b),v=h==null?void 0:h.result,y=v==null?void 0:v.dialcodes;Array.isArray(y)&&y.length>0?(u("valid"),f(s.dialcodeInputField.validMessage)):(u("invalid"),f(s.dialcodeInputField.notFoundMessage))}catch{u("invalid"),f(s.dialcodeInputField.validationFailedMessage)}},p=()=>c==="loading"?l.jsx(ki,{size:16,className:q.dialcodeSpinner}):c==="valid"?l.jsx(Pf,{size:16,color:"var(--sbx-success, #2e7d32)"}):c==="invalid"?l.jsx(xy,{size:16,color:"var(--sbx-error)"}):null;return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,htmlFor:e,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsxs("div",{className:q.dialcodeRow,children:[l.jsx("input",{id:e,type:"text",className:[q.input,a?q.inputError:""].join(" "),disabled:n,value:o.value??"",onChange:b=>{o.onChange(b),u("idle"),f("")},onBlur:o.onBlur,ref:o.ref,placeholder:s.dialcodeInputField.placeholderExample,style:{flex:1}}),l.jsx("button",{type:"button",className:q.validateBtn,onClick:m,disabled:n||c==="loading","aria-label":s.dialcodeInputField.validateAriaLabel,children:c==="loading"?s.dialcodeInputField.validatingLabel:s.dialcodeInputField.validateButtonLabel}),p()]}),a&&l.jsx("span",{className:q.error,children:String(a.message)}),!a&&d&&l.jsx("span",{className:c==="valid"?q.dialcodeValid:q.error,children:d})]})},bj="_cards_1oc2m_1",Cj="_card_1oc2m_1",Sj="_cardActive_1oc2m_30",_j="_cardIcon_1oc2m_35",wj="_cardIconPrimary_1oc2m_46",xj="_cardIconHover_1oc2m_50",Tj="_radioDot_1oc2m_54",Ej="_radioDotActive_1oc2m_65",Aj="_cardTitle_1oc2m_70",kj="_cardTitleInk_1oc2m_76",Ij="_cardDescription_1oc2m_80",Dj="_cardDescriptionCharcoal_1oc2m_86",Bt={cards:bj,card:Cj,cardActive:Sj,cardIcon:_j,cardIconPrimary:wj,cardIconHover:xj,radioDot:Tj,radioDotActive:Ej,cardTitle:Aj,cardTitleInk:kj,cardDescription:Ij,cardDescriptionCharcoal:Dj},Lj=({name:e,label:t,required:r,disabled:n})=>{const s=oe(),{control:i}=Jt(),o=[{value:"strict",Icon:$f,iconVariant:Bt.cardIconPrimary,title:s.learningPath.policyStrictLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyStrictDescription}),descriptionVariant:""},{value:"adaptive",Icon:Gy,iconVariant:Bt.cardIconPrimary,title:s.learningPath.policyAdaptiveLabel,titleVariant:Bt.cardTitleInk,description:l.jsxs(l.Fragment,{children:[s.learningPath.policyAdaptiveDescriptionPre,l.jsx("span",{className:q.required,children:"*"}),s.learningPath.policyAdaptiveDescriptionPost]}),descriptionVariant:Bt.cardDescriptionCharcoal},{value:"priorLearning",Icon:$y,iconVariant:Bt.cardIconHover,title:s.learningPath.policyPriorLearningLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyPriorLearningDescription}),descriptionVariant:""}];return l.jsxs("div",{className:q.field,children:[l.jsxs("label",{className:q.label,children:[t,r&&l.jsx("span",{className:q.required,children:"*"})]}),l.jsx(QL,{name:e,control:i,rules:{required:r?s.selectField.requiredError.replace("{field}",t):!1},render:({field:a})=>l.jsx("div",{className:Bt.cards,children:o.map(({value:c,Icon:u,iconVariant:d,title:f,titleVariant:m,description:p,descriptionVariant:b})=>{const h=a.value===c;return l.jsxs("button",{type:"button",disabled:n,className:[Bt.card,h?Bt.cardActive:""].join(" "),onClick:()=>a.onChange(c),children:[l.jsx("span",{className:[Bt.cardIcon,d].join(" "),children:l.jsx(u,{size:16})}),l.jsx("span",{className:[Bt.radioDot,h?Bt.radioDotActive:""].join(" ")}),l.jsx("span",{className:[Bt.cardTitle,m].join(" "),children:f}),l.jsx("span",{className:[Bt.cardDescription,b].join(" "),children:p})]},c)})})})]})},Oj="_form_lktqh_1",Nj="_formLp_lktqh_7",jj="_ungrouped_lktqh_12",Pj="_ungroupedLp_lktqh_23",Rj="_fullWidthField_lktqh_27",Fj="_noFields_lktqh_31",jn={form:Oj,formLp:Nj,ungrouped:jj,ungroupedLp:Pj,fullWidthField:Rj,noFields:Fj},Mj=({nodeMetadata:e,activeTab:t,isRoot:r,isFolder:n,editorMode:s,onFormValueChange:i,onFormStatusChange:o})=>{var qe,et,$e,We,tt,Gr,wn,cs,Kr;const a=oe(),c=K(w=>w.editorConfig),u=K(w=>w.editorProfile),d=u.key==="learningPath",f=K(w=>w.rootFormConfig),m=K(w=>w.unitFormConfig),p=K(w=>w.categoryMeta),b=K(w=>w.contentFramework),h=K(w=>w.contentTargetFWIds),{organisationFramework:v,targetFrameworks:y,isLoading:C}=Ao(b??((qe=c==null?void 0:c.context)==null?void 0:qe.framework),h??((et=c==null?void 0:c.context)==null?void 0:et.targetFWIds)),{frameworks:S,collectionAdditionalCategories:_,contentAdditionalCategories:x,defaultLicense:T,name:D}=uO(($e=c==null?void 0:c.context)==null?void 0:$e.channel),E=dO(((We=c==null?void 0:c.context)==null?void 0:We.userId)??((tt=c==null?void 0:c.context)==null?void 0:tt.uid)),j=cO(S,(Gr=p==null?void 0:p.frameworkMetadata)==null?void 0:Gr.orgFWType,(wn=c==null?void 0:c.context)==null?void 0:wn.channel),P={organisationFramework:v,targetFrameworks:y,orgFrameworks:j,channelAdditionalCategories:_},O=re(w=>w.selectedNodeId),N=re(w=>w.treeData),R=re(w=>w.treeCache),M=O?R[O]??{}:{},$={...e,...M},ee=g.useMemo(()=>{var A;if(!O)return 0;const w=[...N];for(;w.length;){const I=w.shift();if(I.id===O)return((A=I.children)==null?void 0:A.length)??0;I.children&&w.push(...I.children)}return 0},[N,O]),H=(c==null?void 0:c.config)??{},te=(c==null?void 0:c.context)??{},de={editorMode:s,editableFields:H.editableFields,objectType:H.objectType,setDefaultCopyRight:H.setDefaultCopyRight===!0,defaultLicense:te.defaultLicense??T,contextAdditionalCategories:te.additionalCategories,userFullName:((cs=te.user)==null?void 0:cs.fullName)??E,channelName:D,collectionAdditionalCategories:_,contentAdditionalCategories:x,childCount:ee,profile:u},fe=r?f:m,pe=fe||(((Kr=c==null?void 0:c.config.hierarchy)==null?void 0:Kr.formConfig)??[]),ae=zp(pe,$,P,r,de),we=ae.filter(w=>w.tab===t&&w.inputType!=="appIcon"&&w.visible!==!1),ye=lO({mode:"onChange",defaultValues:Object.fromEntries(ae.map(w=>{const A=["multiselect","chips","keywords","tagsinput"],I=["nestedselect"];return A.includes(w.inputType)?[w.code,w.currentValue??w.defaultValue??[]]:I.includes(w.inputType)?[w.code,w.currentValue??w.defaultValue??{}]:[w.code,w.currentValue??w.defaultValue??""]}))});MO(ye,ae);const{updateNode:F}=re(),B=g.useRef(ae);B.current=ae;const Z=g.useRef(O);Z.current=O;const he=g.useRef(i);he.current=i;const be=g.useRef(o);be.current=o;const me=g.useRef(typeof $.shuffle=="boolean"?$.shuffle:void 0),le=g.useRef($.name??"");le.current=$.name??"";const ve=g.useRef(s);ve.current=s;const Te=lr(),Y=g.useRef(Te==null?void 0:Te.code);Y.current=Te==null?void 0:Te.code;const ce=["review","read","sourcingreview","orgreview"];g.useEffect(()=>{const w=Z.current;if(w){const A=Object.fromEntries(B.current.filter(I=>I.currentValue!==void 0&&I.currentValue!==null).map(I=>[I.code,I.currentValue]));Object.keys(A).length>0&&F(w,A)}ye.trigger().then(()=>{const A=ye.formState.errors,I=B.current,U=Array.from(new Set(Object.keys(A).map(z=>{var W;return(W=I.find(V=>V.code===z))==null?void 0:W.tab}).filter(Boolean)));be.current(Object.keys(A).length===0,U)})},[]),g.useEffect(()=>{const w=ye.watch((A,{name:I})=>{const U=Z.current;if(!U)return;const z=B.current,W=new Set(z.map(se=>se.code));if(I&&W.has(I)){let se=ye.getValues(I);if(I==="dialcodes"&&(se=Array.isArray(se)?se:se?[se]:[]),I==="shuffle"&&(se===!0&&me.current===!1&&Se(a.sparkMetaForm.shuffleEnabledMessage,{icon:l.jsx(Bn,{size:16})}),me.current=se),I==="framework"&&r&&typeof se=="string"&&se){const Ge=K.getState();if(Ge.setContentFramework(se,Ge.contentTargetFWIds),d){const st=re.getState().pruneCoursesByFramework(se);st>0&&Se(a.learningPath.coursesRemovedFrameworkChangeToast.replace("{count}",String(st)),{icon:l.jsx(Bn,{size:16}),duration:5e3});const Vt=re.getState().clearLevelSkills(Y.current);Vt>0&&Se(a.learningPath.levelSkillsResetFrameworkChangeToast.replace("{count}",String(Vt)),{icon:l.jsx(Bn,{size:16}),duration:5e3})}}const je=FO(I,se);je&&(F(U,je),he.current(je))}else if(!I){const se=ye.getValues(),je=Object.fromEntries(Object.entries(se).filter(([st])=>W.has(st))),Ge=RO(je,{isReview:ce.includes(ve.current),nodeTitle:le.current});Object.keys(Ge).length>0&&(F(U,Ge),he.current(Ge))}const V=ye.formState.errors,ne=Array.from(new Set(Object.keys(V).map(se=>{var je;return(je=z.find(Ge=>Ge.code===se))==null?void 0:je.tab}).filter(Boolean)));be.current(Object.keys(V).length===0,ne)});return()=>w.unsubscribe()},[ye]),g.useEffect(()=>{for(const w of["author","creator","copyright","copyrightYear","license"]){const A=B.current.find(U=>U.code===w);if(!A||A.currentValue===void 0||A.currentValue===null||A.currentValue==="")continue;const I=ye.getValues(w);(I==null||I==="")&&ye.setValue(w,A.currentValue,{shouldDirty:!1})}},[E,D,ye]);const Q=we.reduce((w,A)=>{const I=w[w.length-1];return I&&I.section===A.section?I.fields.push(A):w.push({section:A.section,fields:[A]}),w},[]),Ce=w=>{const A={key:w.code,name:w.code,label:w.label,required:w.required,disabled:w.editable===!1};if(d&&w.code==="policy")return l.jsx("div",{className:jn.fullWidthField,children:l.jsx(Lj,{...A})},w.code);switch(w.inputType){case"textarea":return l.jsx(bd,{...A,multiline:!0,maxLength:w.maxLength});case"select":return l.jsx(TN,{...A,options:w.options??[]});case"multiselect":return l.jsx(EN,{...A,options:w.options??[]});case"chips":return l.jsx(AN,{...A});case"radio":return l.jsx(kN,{...A,options:w.options??[]});case"appIcon":return l.jsx(hj,{...A,nodeId:O??""});case"datepicker":case"datetime":return l.jsx(pj,{...A});case"keywords":case"tagsinput":return l.jsx(mj,{...A});case"nestedselect":return l.jsx(gj,{...A,levels:w.levels??[]});case"license":return l.jsx(vj,{...A});case"dialcode":return l.jsx(yj,{...A});default:return l.jsx(bd,{...A,maxLength:w.maxLength})}};return l.jsx(WL,{...ye,children:l.jsxs("div",{className:[jn.form,d?jn.formLp:""].filter(Boolean).join(" "),children:[Q.map((w,A)=>{const I=w.section?fO[w.section]:void 0;return I?l.jsx(HO,{title:I.title,description:I.description,children:w.fields.map(Ce)},w.section??A):l.jsx("div",{className:[jn.ungrouped,d?jn.ungroupedLp:""].filter(Boolean).join(" "),children:w.fields.map(Ce)},A)}),we.length===0&&!C&&l.jsx("p",{className:jn.noFields,children:a.sparkMetaForm.noFieldsMessage})]})})};function Gp(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function Bj(e,t){return e.reduce((r,n,s)=>{const i=t.get(n);return i&&(r[s]=i),r},Array(e.length))}function _i(e){return e!==null&&e>=0}function qj(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function $j(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Kp=e=>{let{rects:t,activeIndex:r,overIndex:n,index:s}=e;const i=Gp(t,n,r),o=t[s],a=i[s];return!a||!o?null:{x:a.left-o.left,y:a.top-o.top,scaleX:a.width/o.width,scaleY:a.height/o.height}},wi={scaleX:1,scaleY:1},Uj=e=>{var t;let{activeIndex:r,activeNodeRect:n,index:s,rects:i,overIndex:o}=e;const a=(t=i[r])!=null?t:n;if(!a)return null;if(s===r){const u=i[o];return u?{x:0,y:r<o?u.top+u.height-(a.top+a.height):u.top-a.top,...wi}:null}const c=zj(i,s,r);return s>r&&s<=o?{x:0,y:-a.height-c,...wi}:s<r&&s>=o?{x:0,y:a.height+c,...wi}:{x:0,y:0,...wi}};function zj(e,t,r){const n=e[t],s=e[t-1],i=e[t+1];return n?r<t?s?n.top-(s.top+s.height):i?i.top-(n.top+n.height):0:i?i.top-(n.top+n.height):s?n.top-(s.top+s.height):0:0}const Yp="Sortable",Zp=g.createContext({activeIndex:-1,containerId:Yp,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Kp,disabled:{draggable:!1,droppable:!1}});function Vj(e){let{children:t,id:r,items:n,strategy:s=Kp,disabled:i=!1}=e;const{active:o,dragOverlay:a,droppableRects:c,over:u,measureDroppableContainers:d}=Nf(),f=Zs(Yp,r),m=a.rect!==null,p=g.useMemo(()=>n.map(T=>typeof T=="object"&&"id"in T?T.id:T),[n]),b=o!=null,h=o?p.indexOf(o.id):-1,v=u?p.indexOf(u.id):-1,y=g.useRef(p),C=!qj(p,y.current),S=v!==-1&&h===-1||C,_=$j(i);ir(()=>{C&&b&&d(p)},[C,p,b,d]),g.useEffect(()=>{y.current=p},[p]);const x=g.useMemo(()=>({activeIndex:h,containerId:f,disabled:_,disableTransforms:S,items:p,overIndex:v,useDragOverlay:m,sortedRects:Bj(p,c),strategy:s}),[h,f,_.draggable,_.droppable,S,p,v,c,m,s]);return g.createElement(Zp.Provider,{value:x},t)}const Hj=e=>{let{id:t,items:r,activeIndex:n,overIndex:s}=e;return Gp(r,n,s).indexOf(t)},Qj=e=>{let{containerId:t,isSorting:r,wasDragging:n,index:s,items:i,newIndex:o,previousItems:a,previousContainerId:c,transition:u}=e;return!u||!n||a!==i&&s===o?!1:r?!0:o!==s&&t===c},Wj={duration:200,easing:"ease"},Xp="transform",Gj=Vr.Transition.toString({property:Xp,duration:0,easing:"linear"}),Kj={roleDescription:"sortable"};function Yj(e){let{disabled:t,index:r,node:n,rect:s}=e;const[i,o]=g.useState(null),a=g.useRef(r);return ir(()=>{if(!t&&r!==a.current&&n.current){const c=s.current;if(c){const u=os(n.current,{ignoreTransform:!0}),d={x:c.left-u.left,y:c.top-u.top,scaleX:c.width/u.width,scaleY:c.height/u.height};(d.x||d.y)&&o(d)}}r!==a.current&&(a.current=r)},[t,r,n,s]),g.useEffect(()=>{i&&o(null)},[i]),i}function Zj(e){let{animateLayoutChanges:t=Qj,attributes:r,disabled:n,data:s,getNewIndex:i=Hj,id:o,strategy:a,resizeObserverConfig:c,transition:u=Wj}=e;const{items:d,containerId:f,activeIndex:m,disabled:p,disableTransforms:b,sortedRects:h,overIndex:v,useDragOverlay:y,strategy:C}=g.useContext(Zp),S=Xj(n,p),_=d.indexOf(o),x=g.useMemo(()=>({sortable:{containerId:f,index:_,items:d},...s}),[f,s,_,d]),T=g.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:D,node:E,isOver:j,setNodeRef:P}=ry({id:o,data:x,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:T,...c}}),{active:O,activatorEvent:N,activeNodeRect:R,attributes:M,setNodeRef:$,listeners:ee,isDragging:H,over:te,setActivatorNodeRef:de,transform:fe}=Of({id:o,data:x,attributes:{...Kj,...r},disabled:S.draggable}),pe=$g(P,$),ae=!!O,we=ae&&!b&&_i(m)&&_i(v),ye=!y&&H,F=ye&&we?fe:null,Z=we?F??(a??C)({rects:h,activeNodeRect:R,activeIndex:m,overIndex:v,index:_}):null,he=_i(m)&&_i(v)?i({id:o,items:d,activeIndex:m,overIndex:v}):_,be=O==null?void 0:O.id,me=g.useRef({activeId:be,items:d,newIndex:he,containerId:f}),le=d!==me.current.items,ve=t({active:O,containerId:f,isDragging:H,isSorting:ae,id:o,index:_,items:d,newIndex:me.current.newIndex,previousItems:me.current.items,previousContainerId:me.current.containerId,transition:u,wasDragging:me.current.activeId!=null}),Te=Yj({disabled:!ve,index:_,node:E,rect:D});return g.useEffect(()=>{ae&&me.current.newIndex!==he&&(me.current.newIndex=he),f!==me.current.containerId&&(me.current.containerId=f),d!==me.current.items&&(me.current.items=d)},[ae,he,f,d]),g.useEffect(()=>{if(be===me.current.activeId)return;if(be&&!me.current.activeId){me.current.activeId=be;return}const ce=setTimeout(()=>{me.current.activeId=be},50);return()=>clearTimeout(ce)},[be]),{active:O,activeIndex:m,attributes:M,data:x,rect:D,index:_,newIndex:he,items:d,isOver:j,isSorting:ae,isDragging:H,listeners:ee,node:E,overIndex:v,over:te,setNodeRef:pe,setActivatorNodeRef:de,setDroppableNodeRef:P,setDraggableNodeRef:$,transform:Te??Z,transition:Y()};function Y(){if(Te||le&&me.current.newIndex===_)return Gj;if(!(ye&&!fo(N)||!u)&&(ae||ve))return Vr.Transition.toString({...u,property:Xp})}}function Xj(e,t){var r,n;return typeof e=="boolean"?{draggable:e,droppable:!1}:{draggable:(r=e==null?void 0:e.draggable)!=null?r:t.draggable,droppable:(n=e==null?void 0:e.droppable)!=null?n:t.droppable}}function so(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&typeof t.sortable=="object"&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const Jj=[Oe.Down,Oe.Right,Oe.Up,Oe.Left],eP=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:i,over:o,scrollableAncestors:a}}=t;if(Jj.includes(e.code)){if(e.preventDefault(),!r||!n)return;const c=[];i.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const m=s.get(f.id);if(m)switch(e.code){case Oe.Down:n.top<m.top&&c.push(f);break;case Oe.Up:n.top>m.top&&c.push(f);break;case Oe.Left:n.left>m.left&&c.push(f);break;case Oe.Right:n.left<m.left&&c.push(f);break}});const u=sv({collisionRect:n,droppableRects:s,droppableContainers:c});let d=mf(u,"id");if(d===(o==null?void 0:o.id)&&u.length>1&&(d=u[1].id),d!=null){const f=i.get(r.id),m=i.get(d),p=m?s.get(m.id):null,b=m==null?void 0:m.node.current;if(b&&p&&f&&m){const v=ho(b).some((T,D)=>a[D]!==T),y=Jp(f,m),C=tP(f,m),S=v||!y?{x:0,y:0}:{x:C?n.width-p.width:0,y:C?n.height-p.height:0},_={x:p.left,y:p.top};return S.x&&S.y?_:Ps(_,S)}}}};function Jp(e,t){return!so(e)||!so(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function tP(e,t){return!so(e)||!so(t)||!Jp(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const rP="_row_1m6cn_1",nP="_removeBtn_1m6cn_14",sP="_grip_1m6cn_17",iP="_ctIcon_1m6cn_34",oP="_info_1m6cn_38",aP="_name_1m6cn_46",lP="_meta_1m6cn_55",Zr={row:rP,removeBtn:nP,grip:sP,ctIcon:iP,info:oP,name:aP,meta:lP},cP={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},uP=({item:e,onRemove:t,isEditable:r})=>{const n=oe(),s=oi(e),i=cP[s.key]??Wr,{attributes:o,listeners:a,setNodeRef:c,transform:u,transition:d,isDragging:f}=Zj({id:e.id,disabled:!r}),m={transform:Vr.Transform.toString(u),transition:d,opacity:f?.5:1};return l.jsxs("div",{ref:c,style:m,className:Zr.row,role:"listitem",children:[r&&l.jsx("span",{className:Zr.grip,...o,...a,"aria-label":n.contentRow.dragToReorderAriaLabel,children:l.jsx(Bf,{size:15})}),l.jsx("span",{className:[`sbx-ct-sq--${s.key}`,Zr.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(i,{size:14})}),l.jsxs("div",{className:Zr.info,children:[l.jsx("span",{className:Zr.name,title:e.name,children:e.name}),l.jsx("span",{className:Zr.meta,children:s.label})]}),l.jsx("span",{className:`sbx-ct-badge--${s.key}`,children:s.label}),r&&l.jsx("button",{type:"button",className:Zr.removeBtn,onClick:()=>t(e.id),"aria-label":n.contentRow.removeAriaLabel.replace("{name}",e.name),children:l.jsx(br,{size:14})})]})},dP="_container_pi4q5_1",fP="_header_pi4q5_7",hP="_heading_pi4q5_13",pP="_count_pi4q5_21",mP="_list_pi4q5_30",gP="_emptyState_pi4q5_36",vP="_skillPicker_pi4q5_52",yP="_skillsCovered_pi4q5_52",bP="_chips_pi4q5_64",CP="_chip_pi4q5_64",SP="_skillWarning_pi4q5_80",_P="_selectedSkills_pi4q5_85",wP="_skillPill_pi4q5_91",xP="_skillPillFlagged_pi4q5_103",TP="_skillPillUncovered_pi4q5_107",EP="_skillPillRemove_pi4q5_112",AP="_skillSearchBox_pi4q5_127",kP="_skillSearchWrap_pi4q5_132",IP="_searchIcon_pi4q5_147",DP="_skillSearchInput_pi4q5_152",LP="_skillDropdown_pi4q5_165",OP="_skillOption_pi4q5_179",NP="_skillCheckbox_pi4q5_201",jP="_skillCheckboxChecked_pi4q5_213",PP="_skillDropdownEmpty_pi4q5_218",RP="_skillPickerNote_pi4q5_224",FP="_emptyHint_pi4q5_229",MP="_assessmentsCard_pi4q5_242",BP="_assessmentSlots_pi4q5_254",qP="_assessmentItemRow_pi4q5_260",$P="_assessmentItemIcon_pi4q5_271",UP="_assessmentItemInfo_pi4q5_283",zP="_assessmentItemTitle_pi4q5_290",VP="_assessmentItemMeta_pi4q5_299",HP="_addRowIcon_pi4q5_304",QP="_assessmentItemBadge_pi4q5_316",WP="_menuWrap_pi4q5_327",GP="_menuBtn_pi4q5_332",KP="_dropmenu_pi4q5_345",YP="_dangerItem_pi4q5_375",ZP="_addRow_pi4q5_304",XP="_addRowAssessment_pi4q5_399",JP="_addRowText_pi4q5_406",eR="_requiredBadge_pi4q5_411",ue={container:dP,header:fP,heading:hP,count:pP,list:mP,emptyState:gP,skillPicker:vP,skillsCovered:yP,chips:bP,chip:CP,skillWarning:SP,selectedSkills:_P,skillPill:wP,skillPillFlagged:xP,skillPillUncovered:TP,skillPillRemove:EP,skillSearchBox:AP,skillSearchWrap:kP,searchIcon:IP,skillSearchInput:DP,skillDropdown:LP,skillOption:OP,skillCheckbox:NP,skillCheckboxChecked:jP,skillDropdownEmpty:PP,skillPickerNote:RP,emptyHint:FP,assessmentsCard:MP,assessmentSlots:BP,assessmentItemRow:qP,assessmentItemIcon:$P,assessmentItemInfo:UP,assessmentItemTitle:zP,assessmentItemMeta:VP,addRowIcon:HP,assessmentItemBadge:QP,menuWrap:WP,menuBtn:GP,dropmenu:KP,dangerItem:YP,addRow:ZP,addRowAssessment:XP,addRowText:JP,requiredBadge:eR},tR=({options:e,selected:t,outOfScope:r,uncovered:n,onChange:s,isEditable:i,description:o})=>{const a=oe(),[c,u]=g.useState(""),[d,f]=g.useState(!1),m=g.useRef(null);g.useEffect(()=>{if(!d)return;const v=y=>{var C;(C=m.current)!=null&&C.contains(y.target)||f(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[d]);const p=c?e.filter(v=>v.toLowerCase().includes(c.toLowerCase())):e,b=v=>{i&&s(t.includes(v)?t.filter(y=>y!==v):[...t,v])},h=v=>{i&&s(t.filter(y=>y!==v))};return l.jsxs("div",{className:ue.skillPicker,children:[l.jsxs("div",{className:ue.header,children:[l.jsx("span",{className:ue.heading,children:a.learningPath.skillsHeading}),l.jsx("span",{className:ue.count,children:t.length})]}),l.jsx("span",{className:ue.skillPickerNote,children:o}),r.length>0&&l.jsx("div",{className:ue.skillWarning,role:"alert",children:a.learningPath.skillsOutOfScopeWarning.replace("{skills}",r.join(", "))}),n.length>0&&l.jsx("div",{className:ue.skillWarning,role:"alert",children:a.learningPath.skillsUncoveredWarning.replace("{skills}",n.join(", "))}),t.length>0&&l.jsx("div",{className:ue.selectedSkills,children:t.map(v=>{const y=r.includes(v),C=n.includes(v);return l.jsxs("span",{className:[ue.skillPill,y?ue.skillPillFlagged:"",C?ue.skillPillUncovered:""].filter(Boolean).join(" "),title:C?a.learningPath.skillUncoveredPillTitle:void 0,children:[v,i&&l.jsx("button",{type:"button",className:ue.skillPillRemove,onClick:()=>h(v),"aria-label":a.learningPath.removeSkillAriaLabel.replace("{skill}",v),children:l.jsx(br,{size:11})})]},v)})}),i?l.jsxs("div",{className:ue.skillSearchBox,ref:m,children:[l.jsxs("div",{className:ue.skillSearchWrap,onClick:()=>f(!0),children:[l.jsx("input",{type:"search",className:ue.skillSearchInput,placeholder:a.learningPath.searchSkillsPlaceholder,value:c,onChange:v=>u(v.target.value),onFocus:()=>f(!0),"aria-label":a.learningPath.searchSkillsPlaceholder}),l.jsx(Yi,{size:14,className:ue.searchIcon})]}),d&&l.jsx("div",{className:ue.skillDropdown,role:"listbox",children:e.length===0?l.jsx("div",{className:ue.skillDropdownEmpty,children:a.learningPath.noSkillsAvailable}):p.length===0?l.jsx("div",{className:ue.skillDropdownEmpty,children:a.learningPath.noMatchingSkills}):p.map(v=>{const y=t.includes(v);return l.jsxs("button",{type:"button",role:"option","aria-selected":y,className:ue.skillOption,onClick:()=>b(v),children:[l.jsx("span",{className:[ue.skillCheckbox,y?ue.skillCheckboxChecked:""].join(" "),children:y&&l.jsx(bn,{size:12})}),v]},v)})})]}):t.length===0&&l.jsx("span",{className:ue.emptyHint,children:a.learningPath.noSkillsSelectedYet})]})},dl=({slot:e,isEditable:t})=>{const r=oe(),{pre:n,post:s,setActiveAssessmentSlot:i,deleteSlot:o}=Ql(),a=re(h=>h.selectNode),[c,u]=g.useState(!1),d=g.useRef(null),f=e==="pre"?n:s,m=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel;if(g.useEffect(()=>{if(!c)return;const h=v=>{var y;(y=d.current)!=null&&y.contains(v.target)||u(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[c]),!f.filled)return l.jsxs("button",{type:"button",className:[ue.addRow,ue.addRowAssessment].join(" "),disabled:!t,onClick:()=>i(e),children:[l.jsx("span",{className:ue.addRowIcon,children:l.jsx(Sn,{size:16})}),l.jsx("span",{className:ue.addRowText,children:r.learningPath.addAssessmentSlotButton.replace("{label}",m)}),f.required&&l.jsx("span",{className:ue.requiredBadge,children:r.learningPath.requiredSlotBadge})]});const p=e==="pre"?r.learningPath.skillCheckBadge:r.learningPath.outcomeCheckBadge,b=()=>f.level&&a(f.level.id);return l.jsxs("div",{className:ue.assessmentItemRow,role:"button",tabIndex:0,onClick:b,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),b())},children:[l.jsx("span",{className:ue.assessmentItemIcon,children:l.jsx(Qr,{size:16})}),l.jsxs("div",{className:ue.assessmentItemInfo,children:[l.jsx("span",{className:ue.assessmentItemTitle,children:f.courseName||r.learningPath.courseNameUnavailable}),l.jsxs("span",{className:ue.assessmentItemMeta,children:[m," · ",r.learningPath.assessmentCourseMeta]})]}),l.jsx("span",{className:ue.assessmentItemBadge,children:p}),t&&l.jsxs("div",{className:ue.menuWrap,ref:d,children:[l.jsx("button",{type:"button",className:ue.menuBtn,onClick:h=>{h.stopPropagation(),u(v=>!v)},"aria-label":r.treeNode.nodeOptionsAriaLabel,children:"⋮"}),c&&l.jsxs("div",{className:ue.dropmenu,onClick:h=>h.stopPropagation(),children:[l.jsxs("button",{type:"button",onClick:()=>{u(!1),f.level&&a(f.level.id)},children:[l.jsx(Ay,{size:12})," ",r.learningPath.viewCourseMenuItem]}),l.jsxs("button",{type:"button",className:ue.dangerItem,onClick:()=>{u(!1),o(e)},children:[l.jsx(So,{size:12})," ",r.treeNode.deleteMenuItem]})]})]})]})},rR=({editorMode:e,isRoot:t=!1})=>{const r=oe(),{selectedNodeId:n,getChildrenOf:s,getNodeById:i,reorderChildren:o,deleteNode:a,activeNodeMeta:c,updateNode:u,treeData:d}=re(),f=K(R=>R.editorProfile),m=n?s(n):[],p=e==="edit",b=n?i(n):void 0,h=f.competencyScoped,v=h&&!t&&!lt(b),y=h&&t,{scope:C,source:S}=ii(),_=lr(),x=_&&Array.isArray(c[_.code])?c[_.code]:[],T=S==="prior"?x.filter(R=>!C.includes(R)):[],D=y?Th(d[0],_==null?void 0:_.code):[],E=v?Eh(b,x,_==null?void 0:_.code):[],j=g.useCallback(R=>{!n||!(_!=null&&_.code)||u(n,{[_.code]:R},[_.code])},[n,_==null?void 0:_.code,u]),P=ff(ja(po,{activationConstraint:{distance:5}}),ja(Cl,{coordinateGetter:eP})),O=g.useCallback(R=>{const{active:M,over:$}=R;if(!$||M.id===$.id||!n)return;const ee=re.getState().getChildrenOf(n),H=ee.findIndex(de=>de.id===M.id),te=ee.findIndex(de=>de.id===$.id);H<0||te<0||o(n,H,te)},[n,o]),N=g.useCallback(R=>{window.confirm(r.unitContentList.removeConfirm)&&a(R)},[a,r.unitContentList.removeConfirm]);return n?l.jsxs("div",{className:ue.container,children:[y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ue.skillsCovered,children:[l.jsx("span",{className:ue.heading,children:r.learningPath.skillsCoveredHeading}),l.jsx("span",{className:ue.emptyHint,children:r.learningPath.skillsCoveredDescription}),D.length>0&&l.jsx("div",{className:ue.chips,children:D.map(R=>l.jsx("span",{className:ue.chip,children:R},R))}),D.length===0&&l.jsx("span",{className:ue.emptyHint,children:r.learningPath.noSkillsYet})]}),l.jsxs("div",{className:ue.assessmentsCard,children:[l.jsx("span",{className:ue.heading,children:r.learningPath.assessmentsCardHeading}),l.jsx("span",{className:ue.emptyHint,children:r.learningPath.assessmentsCardDescription}),l.jsxs("div",{className:ue.assessmentSlots,children:[l.jsx(dl,{slot:"pre",isEditable:p}),l.jsx(dl,{slot:"post",isEditable:p})]})]})]}),v&&l.jsx(tR,{options:C,selected:x,outOfScope:T,uncovered:E,onChange:j,isEditable:p,description:S==="prior"?r.learningPath.skillScopeFromPriorNote:r.learningPath.skillScopeManualNote}),!h&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:ue.header,children:[l.jsx("span",{className:ue.heading,children:r.unitContentList.heading}),l.jsx("span",{className:ue.count,children:m.length})]}),m.length>0?l.jsx(Lf,{sensors:P,collisionDetection:nv,onDragEnd:O,children:l.jsx(Vj,{items:m.map(R=>R.id),strategy:Uj,children:l.jsx("div",{className:ue.list,role:"list",children:m.map(R=>l.jsx(uP,{item:R,onRemove:N,isEditable:p},R.id))})})}):l.jsxs("div",{className:ue.emptyState,children:[l.jsx("p",{children:r.unitContentList.emptyTitle}),l.jsx("span",{children:r.unitContentList.emptyHint})]}),p&&!lt(b)&&l.jsxs("button",{className:ue.addRow,type:"button","aria-label":r.unitContentList.addContentAriaLabel,children:[l.jsx(Sn,{size:14})," ",r.unitContentList.addContent]})]})]}):null},nR="_dropZone_ijo5w_1",sR="_active_ijo5w_14",_d={dropZone:nR,active:sR},iR=({isActive:e,label:t,nodeId:r,className:n})=>{const s=oe(),i=t??s.dropZone.dropHere;return l.jsx("div",{className:`${_d.dropZone} ${e?_d.active:""} ${n??""}`,"data-droppable":e?"true":void 0,"data-node-id":r,"aria-label":i,role:"region",children:l.jsx("span",{children:i})})},em=["identifier","name","mimeType","contentType","primaryCategory","appIcon","channel","organisation","pkgVersion"];async function oR(e){var o;const t={status:["Live"],...e.filters??{}};e.channel&&(t.channel=e.channel);const n=((o=(await Fe.post("/action/composite/v3/search",{request:{filters:t,query:e.query??"",limit:e.limit??20,offset:e.offset??0,sort_by:e.sortBy??{lastUpdatedOn:"desc"},fields:e.fields??em}},{headers:{"X-Source":"web","X-msgid":Math.random().toString(36).slice(2)}})).data)==null?void 0:o.result)??{},s=new Set(["count","facets"]);return{content:Object.entries(n).filter(([a])=>!s.has(a)).flatMap(([,a])=>Array.isArray(a)?a:[]),count:n.count??0}}async function aR(e){var r,n;return(n=(r=(await Fe.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}const wd="application/vnd.sunbird.question";function xd(e){return{cardinality:"single",type:"integer",defaultValue:e.maxScore??1}}function tm(e,t,r){if(!e)return null;if(e.identifier===t)return{question:e,parent:r};for(const n of e.children??[]){const s=tm(n,t,e);if(s)return s}return null}function lR(e,t){const r=tm(e,t);if(!r)return null;const{question:n,parent:s}=r,i={...e,children:[n],childNodes:[t],shuffle:s==null?void 0:s.shuffle,showSolutions:(s==null?void 0:s.showSolutions)??"No",showFeedback:(s==null?void 0:s.showFeedback)??"No"};return(s==null?void 0:s.shuffle)===!0?i.maxScore=1:n.qType==="SA"?delete i.maxScore:n.maxScore!=null&&(i.maxScore=n.maxScore),i}function cR(e,t){const r=((t==null?void 0:t.enabled)??!0)&&!!e;return Jn({queryKey:["quml","questionset",e],enabled:r,queryFn:async()=>{const n=await vh(e),s=d=>{if(!d)return[];const f=d.mimeType===wd&&d.identifier?[d.identifier]:[],m=(d.children??[]).flatMap(s);return[...f,...m]},i=s(n),o=new Map;i.length&&(await e0(i)).forEach(f=>{const m=f.identifier;m&&o.set(m,f)});const a=d=>{if(!d)return d;if(d.mimeType===wd&&d.identifier){const f=o.get(d.identifier)??d,m=f.outcomeDeclaration;return m!=null&&m.maxScore||(f.outcomeDeclaration={...m??{},maxScore:xd(f)}),f}return Array.isArray(d.children)&&(d.children=d.children.map(f=>a(f))),d},c=a(n),u=c.outcomeDeclaration;return u!=null&&u.maxScore||(c.outcomeDeclaration={...u??{},maxScore:xd(c)}),c}})}const Td="/assets/quml-player/sunbird-quml-player.js",uR="/assets/quml-player/styles.css",Ed="sunbird-quml-player";function dR(e){const t=e.children??[];return t.length?t.every(n=>n.objectType==="Question")?[e]:t:[]}const ut=class ut{constructor(){ps(this,"eventHandlers",new WeakMap)}loadScript(){return ut.scriptLoaded||customElements.get(Ed)?(ut.scriptLoaded=!0,Promise.resolve()):(ut.scriptLoading||(ut.scriptLoading=new Promise((t,r)=>{const n=document.createElement("script");n.src=Td,n.setAttribute("data-quml-player-script","true"),n.onload=()=>{ut.scriptLoaded=!0,ut.scriptLoading=void 0,t()},n.onerror=()=>{ut.scriptLoading=void 0,r(new Error(`Failed to load QuML player script: ${Td}`))},document.body.appendChild(n)})),ut.scriptLoading)}loadStyles(){if(ut.stylesLoaded||document.querySelector('[data-quml-player-styles="true"]')){ut.stylesLoaded=!0;return}const t=document.createElement("link");t.rel="stylesheet",t.href=uR,t.setAttribute("data-quml-player-styles","true"),document.head.appendChild(t),ut.stylesLoaded=!0}static unloadStyles(){var t;(t=document.querySelector('[data-quml-player-styles="true"]'))==null||t.remove(),ut.stylesLoaded=!1}async createConfig(t,r,n){var i,o,a;return await this.loadScript(),{context:{mode:(n==null?void 0:n.mode)??"play",host:"",pdata:{id:((i=r==null?void 0:r.pdata)==null?void 0:i.id)??"sunbird.portal",ver:((o=r==null?void 0:r.pdata)==null?void 0:o.ver)??"1.0",pid:((a=r==null?void 0:r.pdata)==null?void 0:a.pid)??"sunbird-portal"},contentId:t.identifier??"",sid:(r==null?void 0:r.sid)??"",uid:(r==null?void 0:r.uid)??(r==null?void 0:r.userId)??"",channel:(r==null?void 0:r.channel)??"",did:(r==null?void 0:r.did)??"",tags:(r==null?void 0:r.tags)??[],contextRollup:(n==null?void 0:n.contextRollup)??(r==null?void 0:r.rollup)??{},objectRollup:(n==null?void 0:n.objectRollup)??{},...n!=null&&n.cdata?{cdata:n.cdata}:{}},config:{language:"en"},data:{sections:dR(t),identifier:t.identifier??""},metadata:t}}createElement(t){this.loadStyles();const r=document.createElement(Ed);return r.setAttribute("player-config",JSON.stringify(t)),r.setAttribute("data-player-id",t.metadata.identifier??"quml"),r}attachEventListeners(t,r,n){this.removeEventListeners(t);const s=o=>r==null?void 0:r(o),i=o=>n==null?void 0:n(o.detail);t.addEventListener("playerEvent",s),t.addEventListener("telemetryEvent",i),this.eventHandlers.set(t,{player:s,telemetry:i})}removeEventListeners(t){const r=this.eventHandlers.get(t);r&&(t.removeEventListener("playerEvent",r.player),t.removeEventListener("telemetryEvent",r.telemetry),this.eventHandlers.delete(t))}};ps(ut,"scriptLoaded",!1),ps(ut,"scriptLoading"),ps(ut,"stylesLoaded",!1);let io=ut;const xi=new io,fR="_contentPlayerRoot_1rdfn_1",hR="_flowLayout_1rdfn_9",pR="_stage_1rdfn_13",mR="_aspectRatio_1rdfn_16",gR="_playerHeader_1rdfn_32",vR="_playerHeaderThumb_1rdfn_46",yR="_playerHeaderTitle_1rdfn_56",bR="_typeBadge_1rdfn_66",CR="_typeDot_1rdfn_105",SR="_playerFrame_1rdfn_125",_R="_coverOverlay_1rdfn_133",wR="_coverHidden_1rdfn_145",xR="_coverThumb_1rdfn_150",TR="_coverPlayRing_1rdfn_159",ER="_coverPlayIcon_1rdfn_172",AR="_coverLabel_1rdfn_181",kR="_coverSkeleton_1rdfn_187",IR="_playerWrapper_1rdfn_213",DR="_infoStrip_1rdfn_223",LR="_infoChip_1rdfn_239",OR="_infoChipLabel_1rdfn_258",NR="_infoChipIcon_1rdfn_267",jR="_playerError_1rdfn_273",PR="_playerErrorIcon_1rdfn_287",RR="_playerErrorMsg_1rdfn_292",FR="_qumlRoot_1rdfn_299",He={contentPlayerRoot:fR,flowLayout:hR,stage:pR,aspectRatio:mR,playerHeader:gR,playerHeaderThumb:vR,playerHeaderTitle:yR,typeBadge:bR,typeDot:CR,playerFrame:SR,coverOverlay:_R,coverHidden:wR,coverThumb:xR,coverPlayRing:TR,coverPlayIcon:ER,coverLabel:AR,coverSkeleton:kR,playerWrapper:IR,infoStrip:DR,infoChip:LR,infoChipLabel:OR,infoChipIcon:NR,playerError:jR,playerErrorIcon:PR,playerErrorMsg:RR,qumlRoot:FR},MR="application/vnd.sunbird.questionset";function BR(e,t){const r=new Map,n=i=>{for(const o of i)r.set(o.id,o),o.children&&n(o.children)};n(e);let s=r.get(t);for(;s;){if(s.mimeType===MR)return s.identifier;s=s.parent?r.get(s.parent):void 0}return null}const qR=[{key:"video",mimes:["video/mp4","video/webm","video/ogg"]},{key:"audio",mimes:["audio/mp3","audio/mpeg","audio/ogg","audio/wav"]},{key:"pdf",mimes:["application/pdf"]},{key:"epub",mimes:["application/epub"]},{key:"ecml",mimes:["application/vnd.ekstep.ecml-archive"]},{key:"h5p",mimes:["application/vnd.ekstep.h5p-archive"]},{key:"scorm",mimes:["application/vnd.ekstep.content-collection"]}];function $R(e){return qR.find(t=>t.mimes.includes(e))??{key:"other"}}function UR(e,t){switch(e){case"video":return t.contentPlayer.mimeLabelVideo;case"audio":return t.contentPlayer.mimeLabelAudio;case"pdf":return t.contentPlayer.mimeLabelPdf;case"epub":return t.contentPlayer.mimeLabelEpub;case"ecml":return t.contentPlayer.mimeLabelEcml;case"h5p":return t.contentPlayer.mimeLabelH5p;case"scorm":return t.contentPlayer.mimeLabelScorm;default:return t.contentPlayer.mimeLabelOther}}const zR={"pdf-player":["application/pdf"],"video-player":["video/mp4","video/webm"],"epub-player":["application/epub"]},VR={"pdf-player":"/assets/sunbird-pdf-player.js","video-player":"/assets/sunbird-video-player.js","epub-player":"/assets/sunbird-epub-player.js"},HR={"pdf-player":"sunbird-pdf-player","video-player":"sunbird-video-player","epub-player":"sunbird-epub-player"},QR="/content/preview/preview.html?webview=true&build_number=2.8.0.e552fcd";function ma(e){for(const[t,r]of Object.entries(zR))if(r.includes(e))return t;return"default-player"}function WR(e,t,r){var i;const n=r==null?void 0:r.context,s=t.mimeType??e.mimeType??"";return{context:{mode:"play",partner:[],pdata:{id:((i=n==null?void 0:n.pdata)==null?void 0:i.id)??"sunbird.portal",ver:1,pid:"sunbird-portal"},contentId:e.identifier,sid:(n==null?void 0:n.sid)??"",uid:(n==null?void 0:n.uid)??"",channel:(n==null?void 0:n.channel)??"",did:(n==null?void 0:n.did)??"",timeDiff:0,contextRollup:{},tags:[],app:[(n==null?void 0:n.channel)??""],dims:""},config:{showEndPage:!1,showStartPage:!0,host:"",overlay:{showUser:!1},splash:{text:"",icon:"",bgImage:"",webLink:""},sideMenu:{showDownload:!0,showExit:!1,showShare:!0},apislug:"/action",repos:["/sunbird-plugins/renderer"],plugins:[{id:"org.sunbird.iframeEvent",ver:1,type:"plugin"},{id:"org.sunbird.player.endpage",ver:1.1,type:"plugin"}],enableTelemetryValidation:!1},metadata:t,data:s==="application/vnd.ekstep.ecml-archive"?t.body??{}:{}}}function GR(e){return document.querySelector(`script[src="${e}"]`)?Promise.resolve():new Promise((t,r)=>{const n=document.createElement("script");n.src=e,n.onload=()=>t(),n.onerror=()=>r(new Error(`Failed to load ${e}`)),document.head.appendChild(n)})}async function KR(e,t,r=100){await GR(VR[t]??""),!customElements.get(e)&&await new Promise((n,s)=>{let i=0;const o=setInterval(()=>{i++,customElements.get(e)?(clearInterval(o),n()):i>=r&&(clearInterval(o),s(new Error(`Custom element <${e}> did not register`)))},100)})}const YR=[{key:"author",icon:Qy},{key:"license",icon:My},{key:"language",icon:Iy},{key:"gradeLevel",icon:By},{key:"subject",icon:Qr},{key:"contentType",icon:Vy}];function ZR(e,t){switch(e){case"author":return t.contentPlayer.infoFieldAuthor;case"license":return t.contentPlayer.infoFieldLicense;case"language":return t.contentPlayer.infoFieldLanguage;case"gradeLevel":return t.contentPlayer.infoFieldClass;case"subject":return t.contentPlayer.infoFieldSubject;case"contentType":return t.contentPlayer.infoFieldType;default:return e}}function XR({node:e}){const t=oe(),r=e.metadata??{},n=YR.flatMap(s=>{const i=r[s.key];if(!i)return[];const o=Array.isArray(i)?i.join(", "):String(i);return o?[{...s,label:ZR(s.key,t),val:o}]:[]});return n.length?l.jsx("div",{className:He.infoStrip,children:n.map(s=>l.jsxs("div",{className:He.infoChip,children:[s.icon&&l.jsx(s.icon,{size:13,className:He.infoChipIcon}),l.jsx("span",{className:He.infoChipLabel,children:s.label}),s.val]},s.key))}):null}function rm({node:e,hidden:t}){var s;const r=oe(),n=e.appIcon??((s=e.metadata)==null?void 0:s.appIcon);return l.jsx("div",{className:`${He.coverOverlay} ${t?He.coverHidden:""}`,children:n?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:n,alt:e.name,className:He.coverThumb}),l.jsx("div",{className:He.coverPlayRing,children:l.jsx("div",{className:He.coverPlayIcon})}),l.jsx("span",{className:He.coverLabel,children:r.contentPlayer.loadingPreview})]}):l.jsx("div",{className:He.coverSkeleton})})}function nm({message:e}){return l.jsxs("div",{className:He.playerError,children:[l.jsx(Hy,{size:28,className:He.playerErrorIcon}),l.jsx("span",{className:He.playerErrorMsg,children:e})]})}function JR({mimeType:e}){const t=oe(),r=$R(e);return l.jsxs("span",{className:He.typeBadge,"data-type":r.key,children:[l.jsx("span",{className:He.typeDot}),UR(r.key,t)]})}const fl=({node:e,editorMode:t,type:r,singleQuestion:n,layout:s="fill"})=>{var o;if(r==="quml")return l.jsx(tF,{node:e,editorMode:t,singleQuestion:!!n});const i=e.appIcon??((o=e.metadata)==null?void 0:o.appIcon);return l.jsxs("div",{className:`${He.contentPlayerRoot} ${s==="flow"?He.flowLayout:""}`,children:[l.jsxs("div",{className:He.stage,children:[l.jsxs("div",{className:He.playerHeader,children:[i&&l.jsx("img",{src:i,alt:"",className:He.playerHeaderThumb}),l.jsx("span",{className:He.playerHeaderTitle,children:e.name}),l.jsx(JR,{mimeType:e.mimeType??""})]}),l.jsx(eF,{node:e})]}),l.jsx(XR,{node:e})]})};function eF({node:e}){var y;const t=oe(),r=K(C=>C.editorConfig),[n,s]=g.useState(()=>ma(e.mimeType??"")),[i,o]=g.useState(!1),[a,c]=g.useState(null),[u,d]=g.useState(e.metadata??{}),[f,m]=g.useState(!1),p=g.useRef(null),b=g.useRef(null),h=((y=r==null?void 0:r.config)==null?void 0:y.previewCdnUrl)??QR;g.useEffect(()=>{let C=!1;return m(!1),o(!1),c(null),d(e.metadata??{}),s(ma(e.mimeType??"")),aR(e.identifier).then(S=>{if(C)return;const _={...e.metadata??{},...S};d(_);const x=S.mimeType??e.mimeType??"";s(ma(x)),m(!0)}).catch(()=>{C||m(!0)}),()=>{C=!0}},[e.identifier]);const v=WR(e,u,r);return g.useEffect(()=>{if(!f||n!=="default-player")return;const C=p.current;if(!C)return;C.src=h;const S=()=>{try{const x=C.contentWindow;if(typeof(x==null?void 0:x.initializePreview)!="function"){c(t.contentPlayer.previewPlayerUnavailable);return}x.initializePreview(v),setTimeout(()=>o(!0),300)}catch(x){console.error("[ContentPlayer] initializePreview failed",x),c(t.contentPlayer.failedToInitializePlayer)}},_=()=>c(t.contentPlayer.previewPlayerLoadFailed);return C.addEventListener("load",S),C.addEventListener("error",_),()=>{C.removeEventListener("load",S),C.removeEventListener("error",_),C.src=""}},[e.identifier,n,h,f,t]),g.useEffect(()=>{if(!f||n==="default-player")return;const C=b.current;if(!C)return;const S=HR[n];if(!S)return;const _=v;KR(S,n).then(()=>{if(!b.current)return;if(!customElements.get(S)){s("default-player");return}const x=document.createElement(S);x.setAttribute("player-config",JSON.stringify(_)),x.addEventListener("playerEvent",()=>{}),x.addEventListener("telemetryEvent",()=>{}),C.innerHTML="",C.appendChild(x),setTimeout(()=>{try{x.playerConfig=_}catch{}o(!0)},200)}).catch(()=>{console.warn(`[ContentPlayer] ${n} script unavailable, falling back to iframe`),s("default-player")})},[e.identifier,n,f]),l.jsxs("div",{className:He.aspectRatio,children:[a?l.jsx(nm,{message:a}):l.jsx(rm,{node:e,hidden:i}),n==="default-player"?l.jsx("iframe",{ref:p,id:"contentPlayer",title:e.name,className:He.playerFrame,name:"contentPlayer",allowFullScreen:!0}):l.jsx("div",{ref:b,className:He.playerFrame})]})}function tF({node:e,editorMode:t,singleQuestion:r}){const n=oe(),s=K(p=>p.editorConfig),i=re(p=>p.treeData),o=g.useRef(null),a=r?BR(i,e.id):e.identifier,{data:c,isLoading:u,error:d}=cR(a??"",{enabled:!!a}),f=g.useMemo(()=>c?r?lR(c,e.identifier):c:null,[c,r,e.identifier]);g.useEffect(()=>{const p=o.current;if(!p||!f)return;let b=null,h=!1;return(async()=>{try{const v=await xi.createConfig(f,s==null?void 0:s.context,{mode:t==="edit"?"edit":"play"});if(h||!o.current)return;const y=xi.createElement(v);b=y,xi.attachEventListeners(y,C=>console.debug("[QumlPlayer] playerEvent",C.detail),C=>console.debug("[QumlPlayer] telemetryEvent",C)),p.innerHTML="",p.appendChild(y)}catch(v){console.error("[QumlPlayer] failed to initialize",v)}})(),()=>{h=!0,b&&(xi.removeEventListeners(b),b.remove()),io.unloadStyles()}},[f,s,t,r]);const m=d?`${n.contentPlayer.unableToLoadQuestionset} ${d.message}`:r&&!a?n.contentPlayer.parentQuestionsetNotResolved:r&&c&&!f?n.contentPlayer.questionNotFoundInQuestionset:null;return l.jsxs("div",{className:He.qumlRoot,children:[m?l.jsx(nm,{message:m}):u||!f?l.jsx(rm,{node:e,hidden:!1}):null,l.jsx("div",{ref:o,className:He.playerWrapper})]})}const rF="_overlay_1b1xq_1",nF="_modal_1b1xq_11",sF="_header_1b1xq_21",iF="_body_1b1xq_37",oF="_hint_1b1xq_43",aF="_list_1b1xq_49",lF="_item_1b1xq_55",cF="_selected_1b1xq_68",uF="_empty_1b1xq_73",dF="_footer_1b1xq_79",fF="_cancelBtn_1b1xq_87",hF="_moveBtn_1b1xq_95",Gt={overlay:rF,modal:nF,header:sF,body:iF,hint:oF,list:aF,item:lF,selected:cF,empty:uF,footer:dF,cancelBtn:fF,moveBtn:hF};function pF(e,t,r){const n=[],s=i=>{var o;for(const a of i)a.isFolder&&a.id!==r&&a.id!==t&&n.push(a),(o=a.children)!=null&&o.length&&s(a.children)};return s(e),n}const mF=({resourceId:e,resourceName:t,currentUnitId:r,onClose:n})=>{var f;const s=oe(),{treeData:i,moveNode:o}=re(),a=pF(i,((f=i[0])==null?void 0:f.id)??"",r),[c,u]=g.useState(null),d=()=>{c&&(o(e,r,c),n())};return l.jsx("div",{className:Gt.overlay,role:"dialog","aria-label":s.resourceReorderDialog.dialogAriaLabel,children:l.jsxs("div",{className:Gt.modal,children:[l.jsxs("div",{className:Gt.header,children:[l.jsxs("span",{children:[s.resourceReorderDialog.moveHeaderPrefix,' "',t,'"']}),l.jsx("button",{onClick:n,"aria-label":s.resourceReorderDialog.closeAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsxs("div",{className:Gt.body,children:[l.jsx("p",{className:Gt.hint,children:s.resourceReorderDialog.selectUnitHint}),l.jsxs("ul",{className:Gt.list,children:[a.map(m=>l.jsxs("li",{className:`${Gt.item} ${c===m.id?Gt.selected:""}`,onClick:()=>u(m.id),children:[l.jsx(ky,{size:14}),l.jsx("span",{children:m.name})]},m.id)),a.length===0&&l.jsx("li",{className:Gt.empty,children:s.resourceReorderDialog.noUnitsAvailable})]})]}),l.jsxs("div",{className:Gt.footer,children:[l.jsx("button",{className:Gt.cancelBtn,onClick:n,children:s.resourceReorderDialog.cancelButton}),l.jsx("button",{className:Gt.moveBtn,onClick:d,disabled:!c,children:s.resourceReorderDialog.moveButton})]})]})})},gF="_overlay_1d56g_1",vF="_modal_1d56g_11",yF="_header_1d56g_21",bF="_body_1d56g_37",CF="_table_1d56g_43",SF="_pageInput_1d56g_61",_F="_empty_1d56g_68",wF="_footer_1d56g_74",xF="_cancelBtn_1d56g_82",TF="_saveBtn_1d56g_90",fr={overlay:gF,modal:vF,header:yF,body:bF,table:CF,pageInput:SF,empty:_F,footer:wF,cancelBtn:xF,saveBtn:TF};function EF(e){const t=[],r=n=>{var s;for(const i of n)!i.isFolder&&(!i.children||i.children.length===0)?t.push(i):(s=i.children)!=null&&s.length&&r(i.children)};return r(e),t}const AF=({onClose:e})=>{const t=oe(),{treeData:r,updateNode:n}=re(),s=EF(r),[i,o]=g.useState(()=>Object.fromEntries(s.map(c=>{var u;return[c.id,String(((u=c.metadata)==null?void 0:u.pageNumber)??"")]}))),a=g.useCallback(()=>{for(const[c,u]of Object.entries(i))u!==""&&n(c,{pageNumber:parseInt(u,10)||void 0});e()},[i,n,e]);return l.jsx("div",{className:fr.overlay,role:"dialog","aria-label":t.assignPageNumber.dialogAriaLabel,children:l.jsxs("div",{className:fr.modal,children:[l.jsxs("div",{className:fr.header,children:[l.jsx("span",{children:t.assignPageNumber.title}),l.jsx("button",{onClick:e,"aria-label":t.assignPageNumber.closeAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsx("div",{className:fr.body,children:s.length===0?l.jsx("p",{className:fr.empty,children:t.assignPageNumber.emptyState}):l.jsxs("table",{className:fr.table,children:[l.jsx("thead",{children:l.jsxs("tr",{children:[l.jsx("th",{children:t.assignPageNumber.contentColumnHeader}),l.jsx("th",{children:t.assignPageNumber.pageNumberColumnHeader})]})}),l.jsx("tbody",{children:s.map(c=>l.jsxs("tr",{children:[l.jsx("td",{children:c.name}),l.jsx("td",{children:l.jsx("input",{type:"number",min:1,value:i[c.id]??"",onChange:u=>o(d=>({...d,[c.id]:u.target.value})),className:fr.pageInput})})]},c.id))})]})}),l.jsxs("div",{className:fr.footer,children:[l.jsx("button",{className:fr.cancelBtn,onClick:e,children:t.assignPageNumber.cancelButton}),l.jsxs("button",{className:fr.saveBtn,onClick:a,children:[l.jsx(Fy,{size:14})," ",t.assignPageNumber.saveButton]})]})]})})},kF="_container_p2feh_1",IF="_panelHeader_p2feh_10",DF="_panelHeaderLeft_p2feh_19",LF="_panelCollapseBtn_p2feh_27",OF="_titleRow_p2feh_46",NF="_field_p2feh_47",jF="_moveBtn_p2feh_64",PF="_icon_p2feh_84",RF="_nameInput_p2feh_93",FF="_fieldHeader_p2feh_118",MF="_label_p2feh_124",BF="_fieldCount_p2feh_133",qF="_chips_p2feh_170",$F="_chip_p2feh_170",UF="_chipRemove_p2feh_188",zF="_keywordInput_p2feh_202",VF="_input_p2feh_207",HF="_addBtn_p2feh_220",QF="_radioGroup_p2feh_234",WF="_radioLabel_p2feh_239",Ke={container:kF,panelHeader:IF,panelHeaderLeft:DF,panelCollapseBtn:LF,titleRow:OF,field:NF,moveBtn:jF,icon:PF,nameInput:RF,fieldHeader:FF,label:MF,fieldCount:BF,chips:qF,chip:$F,chipRemove:UF,keywordInput:zF,input:VF,addBtn:HF,radioGroup:QF,radioLabel:WF},GF=({node:e,editorMode:t,onMoveClick:r,reorderDialog:n})=>{var N,R;const{updateNode:s,markDirty:i}=re(),o=t==="edit",a=oi(e),c=oe(),u=K(M=>M.relationalFormConfig),d=M=>u==null?void 0:u.find($=>$.code===M),f=M=>!u||!!d(M),m=(M,$)=>{var ee;return((ee=d(M))==null?void 0:ee.label)||$},[p,b]=g.useState(!0),h=((N=e.metadata)==null?void 0:N.relationalMetadata)??{},[v,y]=g.useState(h.name??e.name??""),[C,S]=g.useState(""),[_,x]=g.useState(Array.isArray(h.keywords)?h.keywords:Array.isArray((R=e.metadata)==null?void 0:R.keywords)?e.metadata.keywords:[]),[T,D]=g.useState(!!h.optional);g.useEffect(()=>{var $,ee;const M=(($=e.metadata)==null?void 0:$.relationalMetadata)??{};y(M.name??e.name??""),x(Array.isArray(M.keywords)?M.keywords:Array.isArray((ee=e.metadata)==null?void 0:ee.keywords)?e.metadata.keywords:[]),D(!!M.optional)},[e.id]);const E=()=>{v.trim()&&v!==e.name&&(s(e.id,{name:v.trim()}),i())},j=()=>{const M=C.trim();if(M&&!_.includes(M)){const $=[..._,M];x($),s(e.id,{keywords:$}),i()}S("")},P=M=>{const $=_.filter(ee=>ee!==M);x($),s(e.id,{keywords:$}),i()},O=M=>{D(M),s(e.id,{optional:M}),i()};return l.jsxs("div",{className:Ke.container,children:[l.jsxs("div",{className:Ke.panelHeader,children:[l.jsxs("div",{className:Ke.panelHeaderLeft,children:[l.jsx("span",{className:`sbx-ct-badge--${a.key}`,children:a.label}),o&&l.jsx("button",{type:"button",className:Ke.moveBtn,onClick:r,children:c.contentEditForm.moveToAnotherUnitButton})]}),l.jsx("button",{type:"button",className:Ke.panelCollapseBtn,onClick:()=>b(M=>!M),"aria-expanded":p,"aria-label":p?c.contentEditForm.collapseMetadataPanelAriaLabel:c.contentEditForm.expandMetadataPanelAriaLabel,title:p?c.contentEditForm.collapseTitle:c.contentEditForm.expandTitle,children:p?l.jsx(Cn,{size:15}):l.jsx(wy,{size:15})})]}),p&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ke.titleRow,children:[e.appIcon&&l.jsx("img",{src:e.appIcon,alt:c.contentEditForm.iconAlt,className:Ke.icon}),l.jsx("input",{type:"text",className:Ke.nameInput,value:v,disabled:!o,onChange:M=>y(M.target.value),onBlur:E,placeholder:c.contentEditForm.contentNamePlaceholder})]}),f("keywords")&&l.jsxs("div",{className:Ke.field,children:[l.jsx("div",{className:Ke.fieldHeader,children:l.jsxs("label",{className:Ke.label,children:[m("keywords",c.contentEditForm.keywordsLabel),_.length>0&&l.jsx("span",{className:Ke.fieldCount,children:_.length})]})}),_.length>0&&l.jsx("div",{className:Ke.chips,children:_.map(M=>l.jsxs("span",{className:Ke.chip,children:[M,o&&l.jsx("button",{type:"button",className:Ke.chipRemove,onClick:()=>P(M),children:"×"})]},M))}),o&&l.jsxs("div",{className:Ke.keywordInput,children:[l.jsx("input",{type:"text",className:Ke.input,value:C,placeholder:c.contentEditForm.addKeywordPlaceholder,onChange:M=>S(M.target.value),onKeyDown:M=>{M.key==="Enter"&&(M.preventDefault(),j())}}),l.jsx("button",{type:"button",className:Ke.addBtn,onClick:j,children:c.contentEditForm.addButton})]})]}),f("optional")&&l.jsxs("div",{className:Ke.field,children:[l.jsx("label",{className:Ke.label,children:m("optional",c.contentEditForm.optionalInCollectionLabel)}),l.jsxs("div",{className:Ke.radioGroup,children:[l.jsxs("label",{className:Ke.radioLabel,children:[l.jsx("input",{type:"radio",name:`optional-${e.id}`,checked:T===!0,onChange:()=>O(!0),disabled:!o}),c.contentEditForm.yesOption]}),l.jsxs("label",{className:Ke.radioLabel,children:[l.jsx("input",{type:"radio",name:`optional-${e.id}`,checked:T===!1,onChange:()=>O(!1),disabled:!o}),c.contentEditForm.noOption]})]})]})]}),n]})},KF="_iconBtn_gliz0_1",YF="_editable_gliz0_14",ZF="_iconImg_gliz0_26",XF="_placeholder_gliz0_34",JF="_removeBtn_gliz0_41",_s={iconBtn:KF,editable:YF,iconImg:ZF,placeholder:XF,removeBtn:JF},e2=({nodeId:e,value:t,editable:r})=>{const[n,s]=g.useState(!1),{updateNode:i,markDirty:o}=re(),a=oe(),c=d=>{i(e,{appIcon:d}),o(),s(!1)},u=d=>{d.stopPropagation(),i(e,{appIcon:""}),o()};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:[_s.iconBtn,r?_s.editable:""].filter(Boolean).join(" "),role:r?"button":void 0,tabIndex:r?0:-1,"aria-label":r?a.titleAppIcon.selectAppIconAriaLabel:a.titleAppIcon.appIconAriaLabel,onClick:()=>r&&s(!0),onKeyDown:d=>{r&&(d.key==="Enter"||d.key===" ")&&s(!0)},children:[t?l.jsx("img",{src:t,alt:a.titleAppIcon.appIconAlt,className:_s.iconImg}):l.jsx("div",{className:_s.placeholder,children:l.jsx(qf,{size:24})}),t&&r&&l.jsx("button",{type:"button",className:_s.removeBtn,onClick:u,"aria-label":a.titleAppIcon.removeIconAriaLabel,children:l.jsx(So,{size:11})})]}),n&&l.jsx(Wp,{nodeId:e,currentValue:t,onSelect:c,onClose:()=>s(!1)})]})},t2="_courseDetails_1eby7_1",r2="_courseDetailsLoading_1eby7_7",n2="_courseDetailsError_1eby7_7",s2="_detailsCard_1eby7_12",i2="_unitsCard_1eby7_12",o2="_cardTitle_1eby7_22",a2="_fieldGroup_1eby7_29",l2="_fieldGroupLast_1eby7_33",c2="_fieldLabel_1eby7_37",u2="_fieldValue_1eby7_47",d2="_fieldValueMultiline_1eby7_52",f2="_unitsLabel_1eby7_58",h2="_unitsDescription_1eby7_68",p2="_unitList_1eby7_74",m2="_unitCard_1eby7_80",g2="_unitHeader_1eby7_86",v2="_unitIcon_1eby7_99",y2="_unitTitle_1eby7_111",b2="_unitCount_1eby7_120",C2="_unitBody_1eby7_126",S2="_unitDescription_1eby7_131",_2="_unitKeywords_1eby7_138",w2="_keywordPill_1eby7_145",x2="_unitTopicsRow_1eby7_155",T2="_unitContents_1eby7_167",E2="_contentRow_1eby7_174",A2="_contentIcon_1eby7_180",k2="_contentTitle_1eby7_185",I2="_contentSkills_1eby7_193",D2="_skillPill_1eby7_200",Ne={courseDetails:t2,courseDetailsLoading:r2,courseDetailsError:n2,detailsCard:s2,unitsCard:i2,cardTitle:o2,fieldGroup:a2,fieldGroupLast:l2,fieldLabel:c2,fieldValue:u2,fieldValueMultiline:d2,unitsLabel:f2,unitsDescription:h2,unitList:p2,unitCard:m2,unitHeader:g2,unitIcon:v2,unitTitle:y2,unitCount:b2,unitBody:C2,unitDescription:S2,unitKeywords:_2,keywordPill:w2,unitTopicsRow:x2,unitContents:T2,contentRow:E2,contentIcon:A2,contentTitle:k2,contentSkills:I2,skillPill:D2},L2={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr};function ga(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}const sm=({courseId:e,variant:t="compact",title:r,onLoaded:n})=>{const s=oe(),i=lr(),[o,a]=g.useState(null),[c,u]=g.useState(""),[d,f]=g.useState(null),[m,p]=g.useState({}),b=t==="full";g.useEffect(()=>{let C=!1;return a(null),u(""),f(null),bh(e).then(S=>{if(C)return;const x=(S.children??[]).map(T=>Eo(T));a(x),u(S.description??""),p(Object.fromEntries(x.map(T=>[T.id,!0]))),n==null||n({totalContents:x.reduce((T,D)=>{var E;return T+(((E=D.children)==null?void 0:E.length)??0)},0)})}).catch(()=>{C||f(s.learningPath.courseDetailsError)}),()=>{C=!0}},[e,s.learningPath.courseDetailsError]);const h=C=>p(S=>({...S,[C]:!S[C]})),v=C=>{var S;return i?ga((S=C.metadata)==null?void 0:S[i.code]):[]},y=C=>(C===1?s.learningPath.contentCountLabel:s.learningPath.contentCountLabelPlural).replace("{count}",String(C));return l.jsx("div",{className:Ne.courseDetails,children:d?l.jsx("p",{className:Ne.courseDetailsError,children:d}):o===null?l.jsx("p",{className:Ne.courseDetailsLoading,children:s.learningPath.courseDetailsLoading}):l.jsxs(l.Fragment,{children:[b&&l.jsxs("div",{className:Ne.detailsCard,children:[l.jsx("h3",{className:Ne.cardTitle,children:s.learningPath.courseDetailsCardTitle}),l.jsxs("div",{className:Ne.fieldGroup,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.courseTitleFieldLabel}),l.jsx("div",{className:Ne.fieldValue,children:r})]}),l.jsxs("div",{className:Ne.fieldGroupLast,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.courseDescriptionFieldLabel}),l.jsx("div",{className:Ne.fieldValueMultiline,children:c||s.learningPath.noCourseDescriptionPlaceholder})]})]}),o.length===0?l.jsx("p",{className:Ne.courseDetailsLoading,children:s.learningPath.courseDetailsEmpty}):l.jsxs("div",{className:b?Ne.unitsCard:void 0,children:[l.jsx("span",{className:Ne.unitsLabel,children:s.learningPath.unitsSectionLabel}),b&&l.jsx("p",{className:Ne.unitsDescription,children:s.learningPath.unitsSectionDescription}),l.jsx("div",{className:Ne.unitList,children:o.map(C=>{var D,E;const S=!!m[C.id],_=(C.children??[]).length,x=ga((D=C.metadata)==null?void 0:D.keywords),T=ga((E=C.metadata)==null?void 0:E.topic);return l.jsxs("div",{className:Ne.unitCard,children:[l.jsxs("button",{type:"button",className:Ne.unitHeader,onClick:()=>h(C.id),"aria-expanded":S,children:[S?l.jsx(Cn,{size:17}):l.jsx(xl,{size:17}),l.jsx("span",{className:Ne.unitIcon,children:l.jsx(Mf,{size:16})}),l.jsx("span",{className:Ne.unitTitle,children:C.name}),b&&l.jsx("span",{className:Ne.unitCount,children:y(_)})]}),S&&l.jsxs("div",{className:Ne.unitBody,children:[b&&C.description&&l.jsx("p",{className:Ne.unitDescription,children:C.description}),b&&x.length>0&&l.jsx("div",{className:Ne.unitKeywords,children:x.map(j=>l.jsx("span",{className:Ne.keywordPill,children:j},j))}),b&&T.length>0&&l.jsxs("div",{className:Ne.unitTopicsRow,children:[l.jsx("span",{className:Ne.fieldLabel,children:s.learningPath.unitTopicsFieldLabel}),l.jsx("span",{children:T.join(", ")})]}),l.jsx("div",{className:Ne.unitContents,children:(C.children??[]).map(j=>{const P=oi(j),O=L2[P.key]??Wr,N=v(j);return l.jsxs("div",{className:Ne.contentRow,children:[l.jsx(O,{size:16,className:Ne.contentIcon}),l.jsx("span",{className:Ne.contentTitle,children:j.name}),N.length>0&&l.jsx("div",{className:Ne.contentSkills,children:N.map(R=>l.jsx("span",{className:Ne.skillPill,children:R},R))})]},j.id)})})]})]},C.id)})})]})]})})},O2="_backToPathButton_42cuj_1",N2="_assessmentTitle_42cuj_15",j2="_slotPills_42cuj_22",P2="_slotPill_42cuj_22",R2="_slotPillHint_42cuj_40",F2="_slotPillPurpose_42cuj_45",M2="_slotPillWarning_42cuj_51",B2="_slotPillPrimary_42cuj_56",q2="_courseCard_42cuj_62",$2="_courseCardHeading_42cuj_72",U2="_courseCardDescription_42cuj_79",z2="_courseNotAdded_42cuj_85",V2="_assessmentExplainer_42cuj_93",H2="_assessmentExplainerHeading_42cuj_107",Q2="_leafContentLayout_42cuj_117",W2="_container_42cuj_131",G2="_emptyState_42cuj_140",K2="_titleRow_42cuj_150",Y2="_titleRowLp_42cuj_157",Z2="_nodeTitle_42cuj_171",X2="_nodeTitleLpRoot_42cuj_193",J2="_nodeTitleSub_42cuj_198",eM="_courseDetailHeader_42cuj_203",tM="_courseDetailIcon_42cuj_210",rM="_courseDetailTitle_42cuj_222",nM="_courseDetailMeta_42cuj_229",sM="_formArea_42cuj_234",iM="_contentListArea_42cuj_238",oM="_contentListAreaLp_42cuj_242",aM="_dropZone_42cuj_246",lM="_reviewComment_42cuj_253",cM="_reviewCommentLabel_42cuj_266",uM="_reviewCommentText_42cuj_272",ke={backToPathButton:O2,assessmentTitle:N2,slotPills:j2,slotPill:P2,slotPillHint:R2,slotPillPurpose:F2,slotPillWarning:M2,slotPillPrimary:B2,courseCard:q2,courseCardHeading:$2,courseCardDescription:U2,courseNotAdded:z2,assessmentExplainer:V2,assessmentExplainerHeading:H2,leafContentLayout:Q2,container:W2,emptyState:G2,titleRow:K2,titleRowLp:Y2,nodeTitle:Z2,nodeTitleLpRoot:X2,nodeTitleSub:J2,courseDetailHeader:eM,courseDetailIcon:tM,courseDetailTitle:rM,courseDetailMeta:nM,formArea:sM,contentListArea:iM,contentListAreaLp:oM,dropZone:aM,reviewComment:lM,reviewCommentLabel:cM,reviewCommentText:uM},dM=({slot:e,isEditable:t})=>{var p;const r=oe(),n=re(b=>b.treeData),s=re(b=>b.selectNode),i=(p=n[0])==null?void 0:p.id,{pre:o,post:a}=Ql(),c=(e==="pre"?o:a).filled,u=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel,d=e==="pre"?Bn:Sy,f=e==="pre"?r.learningPath.priorAssessmentExplainerTitle:r.learningPath.outcomeAssessmentExplainerTitle,m=e==="pre"?r.learningPath.priorAssessmentExplainerBody:r.learningPath.outcomeAssessmentExplainerBody;return l.jsxs("div",{className:ke.container,children:[l.jsxs("button",{type:"button",className:ke.backToPathButton,onClick:()=>i&&s(i),children:[l.jsx(wl,{size:14})," ",r.learningPath.backToPathButton]}),l.jsx("div",{className:ke.assessmentTitle,children:u}),l.jsx("div",{className:ke.slotPills,children:e==="pre"?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillHint}`,children:[l.jsx(Ec,{size:12})," ",r.learningPath.priorAssessmentHint]}),l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillPurpose}`,children:[l.jsx(by,{size:12})," ",r.learningPath.priorAssessmentPurposeLabel]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillWarning}`,children:[l.jsx($f,{size:12})," ",r.learningPath.outcomeUnlocksHint]}),l.jsxs("span",{className:`${ke.slotPill} ${ke.slotPillPrimary}`,children:[l.jsx(Ec,{size:12})," ",r.learningPath.outcomeAssessmentHint]})]})}),l.jsxs("div",{className:ke.formArea,children:[l.jsxs("div",{className:ke.courseCard,children:[l.jsx("div",{className:ke.courseCardHeading,children:r.learningPath.assessmentCourseSectionTitle}),l.jsx("p",{className:ke.courseCardDescription,children:r.learningPath.assessmentCourseSectionDescription}),c?l.jsx(dl,{slot:e,isEditable:t}):l.jsx("div",{className:ke.courseNotAdded,children:r.learningPath.assessmentNotAddedYet})]}),l.jsxs("div",{className:ke.assessmentExplainer,children:[l.jsxs("div",{className:ke.assessmentExplainerHeading,children:[l.jsx(d,{size:16}),l.jsx("span",{children:f})]}),l.jsx("p",{children:m})]})]})]})},fM="application/vnd.sunbird.questionset",im="application/vnd.sunbird.question",hM=[fM,im];function Ad(e){var t,r;if(!(!e||e.status!=="Draft"||((t=e.metadata)==null?void 0:t.prevStatus)!=="Review"))return(r=e.metadata)==null?void 0:r.rejectComment}const pM=({editorMode:e,onToolbarEvent:t})=>{var fe,pe,ae,we,ye;const r=oe(),[n,s]=g.useState("details"),[i,o]=g.useState([]),[a,c]=g.useState(null),[u,d]=g.useState(!1),[f,m]=g.useState(null),p=g.useRef(null),b=g.useRef(),{selectedNodeId:h,breadcrumb:v,activeNodeMeta:y,updateNode:C,treeData:S,selectNode:_}=re(),x=yr(F=>F.activeAssessmentSlot),T=K(F=>{var B,Z,he,be;return((Z=(B=F.editorConfig)==null?void 0:B.context)==null?void 0:Z.contentId)??((be=(he=F.editorConfig)==null?void 0:he.context)==null?void 0:be.identifier)??""}),D=K(F=>F.editorProfile.competencyScoped),E=h?om(S,h):null;g.useEffect(()=>{m(null)},[E==null?void 0:E.identifier]);const j=!!E&&!E.parent,P=!!(E!=null&&E.isFolder),O=E&&hM.includes(E.mimeType??""),N=(E==null?void 0:E.mimeType)===im,R=E&&!E.isFolder&&!O&&!j,$=D&&P&<(E??void 0)?((ae=(pe=(fe=S[0])==null?void 0:fe.children)==null?void 0:pe[0])==null?void 0:ae.id)===(E==null?void 0:E.id)?"pre":"post":D?x:null,ee=Ad(E)??(j?Ad(S[0]):void 0),H=g.useCallback(()=>{const F=p.current;if(!F||!h)return;const B=F.innerText.trim();clearTimeout(b.current),b.current=setTimeout(()=>{C(h,{name:B})},600)},[h,C]),te=g.useCallback(F=>{t({action:"onFormValueChange",data:F})},[t]),de=g.useCallback((F,B)=>{o(B),t({action:"onFormStatusChange",data:{isValid:F,nodeId:h}})},[t,h]);if(!E)return l.jsx("div",{className:ke.emptyState,children:l.jsx("p",{children:r.contextualEditor.emptyStateMessage})});if(O)return l.jsx(fl,{node:E,editorMode:e,type:"quml",singleQuestion:N});if(D&&R&&E.primaryCategory==="Course"){const F=E.parent?d0(((we=S[0])==null?void 0:we.children)??[],E.parent):null,B=(F==null?void 0:F.role)==="pre"?r.learningPath.priorAssessmentLabel:(F==null?void 0:F.role)==="post"?r.learningPath.outcomeAssessmentLabel:(F==null?void 0:F.role)==="level"?r.learningPath.levelNumberPrefix.replace("{n}",String(F.levelNumber)):null,Z=f===null?"":` · ${(f===1?r.learningPath.contentCountLabel:r.learningPath.contentCountLabelPlural).replace("{count}",String(f))}`;return l.jsxs("div",{className:ke.container,children:[l.jsxs("button",{type:"button",className:ke.backToPathButton,onClick:()=>E.parent&&_(E.parent),children:[l.jsx(wl,{size:14}),B?r.learningPath.backToLevelButton.replace("{label}",B):r.learningPath.backToPathButton]}),l.jsxs("div",{className:ke.courseDetailHeader,children:[l.jsx("span",{className:ke.courseDetailIcon,children:l.jsx(Qr,{size:26})}),l.jsxs("div",{children:[l.jsx("h2",{className:ke.courseDetailTitle,children:E.name}),l.jsxs("span",{className:ke.courseDetailMeta,children:[E.primaryCategory,Z]})]})]}),l.jsx(sm,{courseId:E.identifier,variant:"full",title:E.name,onLoaded:({totalContents:he})=>m(he)},E.identifier)]})}return $?l.jsx(dM,{slot:$,isEditable:e==="edit"}):R?l.jsxs("div",{className:ke.leafContentLayout,children:[l.jsx(fl,{node:E,editorMode:e,type:"content",layout:"flow"}),l.jsx(GF,{node:E,editorMode:e,onMoveClick:()=>c(E.identifier),reorderDialog:a?l.jsx(mF,{resourceId:a,resourceName:E.name,currentUnitId:E.parent??"",onClose:()=>c(null)}):null})]}):l.jsxs("div",{className:ke.container,children:[l.jsx(FL,{crumbs:v}),ee&&l.jsxs("div",{className:ke.reviewComment,role:"alert",children:[l.jsx("span",{className:ke.reviewCommentLabel,children:r.contextualEditor.reviewCommentLabel}),l.jsx("span",{className:ke.reviewCommentText,children:ee})]}),l.jsxs("div",{className:[ke.titleRow,D?ke.titleRowLp:""].filter(Boolean).join(" "),children:[j&&h&&l.jsx(e2,{nodeId:h,value:String(E.appIcon??((ye=E.metadata)==null?void 0:ye.appIcon)??""),editable:e==="edit"}),l.jsx("div",{ref:p,className:[ke.nodeTitle,D&&j?ke.nodeTitleLpRoot:"",D&&!j?ke.nodeTitleSub:""].filter(Boolean).join(" "),contentEditable:e==="edit",suppressContentEditableWarning:!0,onInput:H,onBlur:H,"data-placeholder":r.contextualEditor.untitledPlaceholder,"aria-label":r.contextualEditor.nodeTitleAriaLabel,children:E.name})]}),l.jsx(zL,{activeTab:n,onChange:F=>s(F),errorTabs:i,visibleTabs:j&&!D?void 0:["details"]}),l.jsx("div",{className:ke.formArea,children:l.jsx(Mj,{nodeMetadata:y,activeTab:n,isRoot:j,isFolder:P,editorMode:e,onFormValueChange:te,onFormStatusChange:de},`${h??"none"}:${j?"root":"node"}`)}),(P||j)&&n==="details"&&l.jsx("div",{className:[ke.contentListArea,D?ke.contentListAreaLp:""].filter(Boolean).join(" "),children:l.jsx(rR,{editorMode:e,isRoot:j})}),l.jsx(iR,{isActive:!1,label:r.contextualEditor.dropZoneLabel,nodeId:h??void 0,className:ke.dropZone}),u&&l.jsx(AF,{contentId:T,onClose:()=>d(!1)})]})};function om(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=om(r.children,t);if(n)return n}}}const am=ei((e,t)=>({allContent:[],filteredContent:[],searchQuery:"",activeFilter:"all",advancedFilters:{},isLoading:!1,totalCount:0,offset:0,sortAZ:!1,setContent:(r,n)=>{e({allContent:r,totalCount:n,offset:r.length}),t().applyFilter()},appendContent:(r,n)=>{const i=[...t().allContent,...r];e({allContent:i,totalCount:n,offset:i.length}),t().applyFilter()},setFilter:r=>{e({activeFilter:r}),t().applyFilter()},setSearch:r=>{e({searchQuery:r}),t().applyFilter()},setLoading:r=>e({isLoading:r}),setAdvancedFilters:r=>e({advancedFilters:r}),setOffset:r=>e({offset:r}),setSortAZ:r=>e({sortAZ:r}),applyFilter:()=>{const{allContent:r,activeFilter:n,searchQuery:s}=t();let i=r;if(n&&n!=="all"){const o=n.toLowerCase();i=i.filter(a=>[a.mimeType??"",a.primaryCategory??"",a.contentType??""].join(" ").toLowerCase().includes(o))}if(s&&s.trim()!==""){const o=s.toLowerCase().trim();i=i.filter(a=>(a.name??"").toLowerCase().includes(o))}e({filteredContent:i})}}));function mM(e,t,r,n){const s={primaryCategory:["Course"]};return n&&(s.framework=[n]),!e&&t.length&&r&&(s[r]=t),s}function gM(e,t){if(!(!e||!t))return[...em,t,"framework"]}function vM(e,t,r,n,s){return e?t?r&&!n&&s.length===0?"noSkills":null:"noCurriculum":null}const yM=20,bM=[];function lm(){var u;const e=K(d=>d.editorConfig),t=re(d=>d.selectedNodeId),r=re(d=>d.treeData),n=g.useCallback(()=>{if(!t||!r.length)return 0;function d(f,m,p=0){var b;for(const h of f){if(h.id===m)return p;if((b=h.children)!=null&&b.length){const v=d(h.children,m,p+1);if(v>=0)return v}}return-1}return Math.max(0,d(r,t))},[t,r])(),s=(u=e==null?void 0:e.config)==null?void 0:u.hierarchy;if(!s)return[...id];const i=`level${n}`,o=s[i],a=o==null?void 0:o.children,c=a==null?void 0:a.Content;return c!=null&&c.length?c:[...id]}function CM(){const e=am(),t=K(E=>{var j,P;return((P=(j=E.editorConfig)==null?void 0:j.context)==null?void 0:P.channel)??""}),r=lm(),n=K(E=>E.editorProfile),s=yr(E=>E.activeAssessmentSlot),i=re(E=>E.activeNodeMeta),o=re(E=>E.treeData),a=re(E=>E.treeCache),c=re(E=>E.selectedNodeId),u=re(E=>E.getNodeById),d=lr(),f=n.competencyScoped?wh(o[0],a):void 0,m=g.useRef(),p=d&&Array.isArray(i[d.code])?i[d.code]:bM,b=c?u(c):void 0,h=n.competencyScoped&&!!(b!=null&&b.isFolder)&&!!b.parent&&!lt(b),v=vM(n.competencyScoped,f,h,s,p),y=g.useCallback(async(E="",j="all",P={},O=!0,N=!1)=>{var R,M,$,ee,H;e.setLoading(!0);try{if(v){e.setContent([],0);return}let te;if(n.competencyScoped){const ae=mM(s,p,d==null?void 0:d.code,f);te={status:["Live"],...ae}}else te={status:["Live"],primaryCategory:j&&j!=="all"?[j]:r},(R=P==null?void 0:P.board)!=null&&R.length&&(te.board=P.board),(M=P==null?void 0:P.medium)!=null&&M.length&&(te.medium=P.medium),($=P==null?void 0:P.gradeLevel)!=null&&$.length&&(te.gradeLevel=P.gradeLevel),(ee=P==null?void 0:P.subject)!=null&&ee.length&&(te.subject=P.subject),(H=P==null?void 0:P.primaryCategory)!=null&&H.length&&(te.primaryCategory=P.primaryCategory);const de=O?0:e.offset,{content:fe,count:pe}=await oR({filters:te,query:E,limit:E?50:yM,offset:de,channel:t||void 0,sortBy:N?{name:"asc"}:{lastUpdatedOn:"desc"},fields:gM(n.competencyScoped,d==null?void 0:d.code)});O?e.setContent(fe,pe):e.appendContent(fe,pe)}catch(te){console.error("[useLibrary] load error:",te)}finally{e.setLoading(!1)}},[r,t,n,s,p,d,f,v]);g.useEffect(()=>{clearTimeout(m.current),e.setSearch("")},[f]),g.useEffect(()=>{y()},[t]),g.useEffect(()=>{n.competencyScoped&&y()},[n.competencyScoped,s,p.join("|"),f,c]);const C=g.useCallback(E=>{e.setSearch(E),clearTimeout(m.current),m.current=setTimeout(()=>y(E,e.activeFilter,e.advancedFilters,!0,e.sortAZ),300)},[e.activeFilter,e.advancedFilters,e.sortAZ,y]),S=g.useCallback(E=>{e.setFilter(E),y(e.searchQuery,E,e.advancedFilters,!0,e.sortAZ)},[e.searchQuery,e.advancedFilters,e.sortAZ,y]),_=g.useCallback(E=>{e.setAdvancedFilters(E),y(e.searchQuery,e.activeFilter,E,!0,e.sortAZ)},[e.searchQuery,e.activeFilter,e.sortAZ,y]),x=g.useCallback(()=>{const E=!e.sortAZ;e.setSortAZ(E),y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,E)},[e.sortAZ,e.searchQuery,e.activeFilter,e.advancedFilters,y]),T=g.useCallback(()=>{e.isLoading||y(e.searchQuery,e.activeFilter,e.advancedFilters,!1,e.sortAZ)},[e.isLoading,e.searchQuery,e.activeFilter,e.advancedFilters,e.sortAZ,y]),D=e.allContent.length<e.totalCount;return{content:e.filteredContent,isLoading:e.isLoading,totalCount:e.totalCount,activeFilter:e.activeFilter,advancedFilters:e.advancedFilters,searchQuery:e.searchQuery,sortAZ:e.sortAZ,hasMore:D,search:C,setFilter:S,applyAdvancedFilters:_,toggleSort:x,loadMore:T,refetch:()=>y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,e.sortAZ),activeAssessmentSlot:s,emptyReason:v}}function cm(){var a;const e=oe(),t=K(c=>c.editorProfile.competencyScoped),r=yr(c=>c.activeAssessmentSlot),n=re(c=>c.selectedNodeId),s=re(c=>c.treeData),i=re(c=>c.getNodeById),o=(a=s[0])==null?void 0:a.id;if(!t)return null;if(r==="pre")return e.learningPath.libraryAddPriorAssessmentCourse;if(r==="post")return e.learningPath.libraryAddOutcomeAssessmentCourse;if(n&&n!==o){const c=i(n);if(c!=null&&c.isFolder)return e.learningPath.libraryAddToLevel.replace("{level}",c.name??"")}return e.learningPath.libraryOpenLevelToAdd}const SM="_card_1cmpg_1",_M="_addBtn_1cmpg_17",wM="_dragging_1cmpg_24",xM="_ctIcon_1cmpg_29",TM="_info_1cmpg_33",EM="_name_1cmpg_41",AM="_meta_1cmpg_50",kM="_skillTags_1cmpg_58",IM="_skillTag_1cmpg_58",DM="_addBtnMuted_1cmpg_93",LM="_added_1cmpg_102",OM="_addedBadge_1cmpg_111",Kt={card:SM,addBtn:_M,dragging:wM,ctIcon:xM,info:TM,name:EM,meta:AM,skillTags:kM,skillTag:IM,addBtnMuted:DM,added:LM,addedBadge:OM},NM={video:_o,pdf:Js,h5p:yo,scorm:Co,audio:bo,quiz:vo,course:Qr,default:Wr},jM=({item:e,onAdd:t,onPreview:r,isDraggable:n,isAdded:s})=>{var S,_;const i=oe(),o=oi(e),a=NM[o.key]??Wr,c=Hl(),u=hD(),d=c&&!s&&u,f=K(x=>x.editorProfile.competencyScoped),m=lr(),p=f&&m?(()=>{const x=e[m.code];return Array.isArray(x)?x:x?[String(x)]:[]})():[],{attributes:b,listeners:h,setNodeRef:v,isDragging:y}=Of({id:e.identifier,disabled:!n||!c||!u,data:{type:"library-item",item:e}}),C=()=>{r&&r(e)};return l.jsxs("div",{ref:v,className:[Kt.card,y?Kt.dragging:"",s?Kt.added:""].join(" "),"aria-label":e.name,...n?{...b,...h}:{},role:"listitem",onClick:C,children:[l.jsx("span",{className:[`sbx-ct-sq--${o.key}`,Kt.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(a,{size:14})}),l.jsxs("div",{className:Kt.info,children:[l.jsx("span",{className:Kt.name,title:e.name,children:e.name}),l.jsxs("span",{className:Kt.meta,children:[((S=e.organisation)==null?void 0:S[0])??e.channel??"",(_=e.organisation)!=null&&_[0]&&e.primaryCategory?" · ":"",e.primaryCategory??""]}),p.length>0&&l.jsx("span",{className:Kt.skillTags,children:p.slice(0,3).map(x=>l.jsx("span",{className:Kt.skillTag,children:x},x))})]}),s&&l.jsx("span",{className:Kt.addedBadge,"aria-label":i.libraryCard.alreadyAddedAriaLabel,title:i.libraryCard.alreadyAddedTitle,children:l.jsx(bn,{size:12})}),!s&&n&&l.jsx("button",{type:"button",className:[Kt.addBtn,!d&&c?Kt.addBtnMuted:""].join(" "),onClick:x=>{x.stopPropagation(),t(e)},disabled:!c,"aria-disabled":!d,"aria-label":i.libraryCard.addItemAriaLabel.replace("{name}",e.name),title:c?u?i.libraryCard.addToUnitTitle:i.libraryCard.selectUnitToAddTitle:i.libraryCard.draftOnlyTitle,children:l.jsx(Sn,{size:14})})]})},PM="_chips_xhhaq_1",RM="_chip_xhhaq_1",kd={chips:PM,chip:RM},FM=({filters:e,active:t,onChange:r})=>{const n=oe();return l.jsx("div",{className:kd.chips,role:"group","aria-label":n.filterChips.contentTypeFiltersAriaLabel,children:e.map(s=>l.jsx("button",{type:"button",role:"radio","aria-checked":t===s.value,className:["sbx-chip",t===s.value?"filled":"outline",kd.chip].join(" "),onClick:()=>r(s.value),children:s.label},s.value))})},MM="_panel_uame3_1",BM="_header_uame3_10",qM="_headerTitle_uame3_19",$M="_closeBtn_uame3_25",UM="_body_uame3_43",zM="_section_uame3_59",VM="_sectionLabel_uame3_65",HM="_chips_uame3_73",QM="_chip_uame3_73",WM="_active_uame3_96",GM="_footer_uame3_102",KM="_resetBtn_uame3_112",YM="_applyBtn_uame3_129",ht={panel:MM,header:BM,headerTitle:qM,closeBtn:$M,body:UM,section:zM,sectionLabel:VM,chips:HM,chip:QM,active:WM,footer:GM,resetBtn:KM,applyBtn:YM},ZM=e=>[{key:"board",label:e.libraryFilterPanel.boardLabel},{key:"medium",label:e.libraryFilterPanel.mediumLabel},{key:"gradeLevel",label:e.libraryFilterPanel.classLabel},{key:"subject",label:e.libraryFilterPanel.subjectLabel}],XM=new Set(["board","medium","gradeLevel","subject","topic"]),JM=({local:e,toggle:t})=>{const r=oe(),n=lm();return n.length?l.jsxs("div",{className:ht.section,children:[l.jsx("div",{className:ht.sectionLabel,children:r.libraryFilterPanel.primaryCategoryLabel}),l.jsx("div",{className:ht.chips,children:n.map(s=>l.jsx("button",{type:"button",className:[ht.chip,(e.primaryCategory??[]).includes(s)?ht.active:""].join(" "),onClick:()=>t("primaryCategory",s),children:s},s))})]}):null},eB=({isOpen:e,filters:t,onApply:r,onClose:n})=>{var v,y;const s=oe(),i=K(C=>C.editorConfig),o=K(C=>C.searchFormConfig),a=K(C=>C.contentFramework),c=K(C=>C.contentTargetFWIds),{organisationFramework:u}=Ao(a??((v=i==null?void 0:i.context)==null?void 0:v.framework),c??((y=i==null?void 0:i.context)==null?void 0:y.targetFWIds)),[d,f]=g.useState(t),m=o!=null&&o.length?o.filter(C=>XM.has(C.code)).map(C=>({key:C.code,label:C.label||C.code})):ZM(s);g.useEffect(()=>{f(t)},[t]);const p=(C,S)=>{f(_=>{const x=_[C]??[],T=x.includes(S)?x.filter(D=>D!==S):[...x,S];return{..._,[C]:T}})},b=(u==null?void 0:u.categories)??[],h=C=>{var S;return((S=b.find(_=>_.code===C))==null?void 0:S.terms)??[]};return e?l.jsxs("div",{className:ht.panel,role:"dialog","aria-label":s.libraryFilterPanel.filterLibraryAriaLabel,"aria-modal":"true",children:[l.jsxs("div",{className:ht.header,children:[l.jsx("span",{className:ht.headerTitle,children:s.libraryFilterPanel.filtersHeaderTitle}),l.jsx("button",{type:"button",className:ht.closeBtn,onClick:n,"aria-label":s.libraryFilterPanel.closeFiltersAriaLabel,children:l.jsx(br,{size:16})})]}),l.jsxs("div",{className:ht.body,children:[m.map(({key:C,label:S})=>{const _=h(C);return _.length?l.jsxs("div",{className:ht.section,children:[l.jsx("div",{className:ht.sectionLabel,children:S}),l.jsx("div",{className:ht.chips,children:_.slice(0,20).map(x=>l.jsx("button",{type:"button",className:[ht.chip,(d[C]??[]).includes(x.name)?ht.active:""].join(" "),onClick:()=>p(C,x.name),children:x.name},x.identifier))})]},C):null}),l.jsx(JM,{local:d,toggle:p})]}),l.jsxs("div",{className:ht.footer,children:[l.jsx("button",{type:"button",className:ht.resetBtn,onClick:()=>f({}),children:s.libraryFilterPanel.resetButton}),l.jsx("button",{type:"button",className:ht.applyBtn,onClick:()=>{r(d),n()},children:s.libraryFilterPanel.applyButton})]})]}):null},tB="_header_1tvk1_10",rB="_headerCourse_1tvk1_20",nB="_courseIcon_1tvk1_25",sB="_titleGroup_1tvk1_37",iB="_courseMeta_1tvk1_45",oB="_title_1tvk1_37",aB="_headerActions_1tvk1_67",lB="_iconBtn_1tvk1_74",cB="_playerArea_1tvk1_92",uB="_footer_1tvk1_100",dB="_footerCourse_1tvk1_109",fB="_addBtn_1tvk1_115",hB="_addBtnCourse_1tvk1_134",pB="_modalOverlay_1tvk1_159",mB="_modalOverlayCourse_1tvk1_174",gB="_modalPanel_1tvk1_178",vB="_modalPanelCourse_1tvk1_190",gt={header:tB,headerCourse:rB,courseIcon:nB,titleGroup:sB,courseMeta:iB,title:oB,headerActions:aB,iconBtn:lB,playerArea:cB,footer:uB,footerCourse:dB,addBtn:fB,addBtnCourse:hB,modalOverlay:pB,modalOverlayCourse:mB,modalPanel:gB,modalPanelCourse:vB},yB="application/vnd.sunbird.questionset",bB=({content:e,editorMode:t,onAdd:r,onClose:n})=>{var f;const s=oe(),i=t==="edit",o=K(m=>m.editorProfile.competencyScoped),a=cm();if(!e)return null;const c=o&&e.primaryCategory==="Course",u=[((f=e.organisation)==null?void 0:f[0])??e.channel??"",e.primaryCategory??""].filter(Boolean).join(" • "),d={id:e.identifier,identifier:e.identifier,name:e.name??"",mimeType:e.mimeType,primaryCategory:e.primaryCategory,contentType:e.contentType,appIcon:e.appIcon,status:e.status,isFolder:!1,children:[],metadata:e};return xr.createPortal(l.jsx("div",{className:[gt.modalOverlay,c?gt.modalOverlayCourse:""].filter(Boolean).join(" "),role:"dialog","aria-modal":"true","aria-label":s.libraryPreviewPanel.contentPreviewAriaLabel,onClick:n,children:l.jsxs("div",{className:[gt.modalPanel,c?gt.modalPanelCourse:""].filter(Boolean).join(" "),onClick:m=>m.stopPropagation(),children:[l.jsxs("div",{className:[gt.header,c?gt.headerCourse:""].filter(Boolean).join(" "),children:[c&&l.jsx("span",{className:gt.courseIcon,children:l.jsx(Qr,{size:20})}),l.jsxs("div",{className:gt.titleGroup,children:[l.jsx("span",{className:gt.title,title:e.name,children:e.name}),c&&u&&l.jsx("span",{className:gt.courseMeta,children:u})]}),l.jsx("div",{className:gt.headerActions,children:l.jsx("button",{type:"button",className:gt.iconBtn,onClick:n,"aria-label":s.libraryPreviewPanel.closePreviewAriaLabel,children:l.jsx(br,{size:16})})})]}),l.jsx("div",{className:gt.playerArea,children:c?l.jsx(sm,{courseId:e.identifier}):l.jsx(fl,{node:d,editorMode:"read",type:e.mimeType===yB?"quml":"content"})}),i&&l.jsx("div",{className:[gt.footer,c?gt.footerCourse:""].filter(Boolean).join(" "),children:c?l.jsxs("button",{type:"button",className:gt.addBtnCourse,onClick:()=>r(e),children:[l.jsx(Sn,{size:15})," ",a??s.libraryPreviewPanel.addToUnitButton]}):l.jsx("button",{type:"button",className:gt.addBtn,onClick:()=>r(e),children:s.libraryPreviewPanel.addToUnitButton})})]})}),document.body)},CB="_dock_2k0x7_1",SB="_header_2k0x7_8",_B="_libraryTargetLabel_2k0x7_18",wB="_headerLeft_2k0x7_28",xB="_headerTitle_2k0x7_36",TB="_count_2k0x7_42",EB="_searchRow_2k0x7_51",AB="_searchWrap_2k0x7_59",kB="_searchIcon_2k0x7_65",IB="_searchInput_2k0x7_74",DB="_filterToggleBtn_2k0x7_92",LB="_filterToggleBtnActive_2k0x7_111",OB="_filterBadge_2k0x7_117",NB="_filters_2k0x7_136",jB="_mainArea_2k0x7_146",PB="_sidePanelOverlay_2k0x7_155",RB="_cardList_2k0x7_164",FB="_skeleton_2k0x7_180",MB="_skeletonIcon_2k0x7_190",BB="_skeletonText_2k0x7_198",qB="_skeletonLine_2k0x7_205",$B="_skeletonLineSm_2k0x7_212",UB="_loadMoreBtn_2k0x7_227",zB="_emptyState_2k0x7_252",VB="_collapseBtn_2k0x7_272",ze={dock:CB,header:SB,libraryTargetLabel:_B,headerLeft:wB,headerTitle:xB,count:TB,searchRow:EB,searchWrap:AB,searchIcon:kB,searchInput:IB,filterToggleBtn:DB,filterToggleBtnActive:LB,filterBadge:OB,filters:NB,mainArea:jB,sidePanelOverlay:PB,cardList:RB,skeleton:FB,skeletonIcon:MB,skeletonText:BB,skeletonLine:qB,skeletonLineSm:$B,loadMoreBtn:UB,emptyState:zB,collapseBtn:VB},HB=[{label:"Courses",value:"all"}];function QB(e){const t=new Set,r=[...e];for(;r.length>0;){const n=r.shift();n.isFolder||t.add(n.identifier),n.children&&r.push(...n.children)}return t}const WB=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{const n=oe(),{content:s,isLoading:i,totalCount:o,activeFilter:a,searchQuery:c,sortAZ:u,hasMore:d,search:f,setFilter:m,applyAdvancedFilters:p,toggleSort:b,loadMore:h,activeAssessmentSlot:v,emptyReason:y}=CM(),{addResource:C,selectedNodeId:S,treeData:_,treeCache:x}=re(),T=yr(F=>F.setActiveAssessmentSlot),D=K(F=>F.editorProfile.competencyScoped),E=e==="edit",j=cm(),[P,O]=g.useState(!1),[N,R]=g.useState({}),[M,$]=g.useState(null),[ee,H]=g.useState(null),te=g.useMemo(()=>QB(_),[_]),de=g.useCallback(async(F,B)=>{var he,be;const Z=(he=_[0])==null?void 0:he.id;if(!(!Z||ee)){if(Ms(((be=_[0])==null?void 0:be.children)??[],B)){Se.error(B==="pre"?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}H(F.identifier);try{const{qualifies:me,meta:le}=await Sh(F.identifier);if(!me){Se.error(n.learningPath.notAssessmentCourseToast.replace("{name}",F.name));return}const ve={...F,...le};if(C(ve,Z,{isAssessmentCourse:!0,slot:B})===!1){Se.error(n.learningPath.bothSlotsFilledToast);return}Se.success(n.libraryDock.itemAddedToast.replace("{name}",F.name)),T(null)}catch(me){console.error("[LibraryDock] assessment-course check failed:",me),Se.error(n.learningPath.assessmentCheckFailedToast)}finally{H(null)}}},[_,C,T,ee,n]),fe=g.useCallback(F=>{var be,me,le;if(D&&!xh(_[0],x)){Se.error(n.learningPath.selectCurriculumFirstToast);return}if(v){de(F,v);return}if(!S){Se.error(D?n.learningPath.selectLevelFirstToast:n.libraryDock.selectUnitFirstToast);return}const B=(be=_[0])==null?void 0:be.id,Z=re.getState().getNodeById(S);if(D){const ve=((me=_[0])==null?void 0:me.children)??[],Te=Z!=null&&Z.isFolder?Z:Z!=null&&Z.parent?re.getState().getNodeById(Z.parent):void 0;if(Te&&Wa(ve,Te)){const Y=(le=ve[0])==null?void 0:le.id;Se.error(Te.id===Y?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}}if(S===B||!(Z!=null&&Z.isFolder)){Se(D?n.learningPath.selectLevelFromOutlineToast:n.libraryDock.selectUnitFromOutlineToast,{icon:l.jsx(Bn,{size:16}),duration:4e3});return}if(C(F,S)===!1){Se.error((D?n.learningPath.itemAlreadyInPathToast:n.libraryDock.itemAlreadyAddedToast).replace("{name}",F.name));return}Se.success(n.libraryDock.itemAddedToast.replace("{name}",F.name))},[v,de,S,C,_,x,n,D]),pe=g.useCallback(F=>{R(F),p(F)},[p]),ae=g.useCallback(F=>{$(F)},[]),we=g.useCallback(F=>{fe(F),$(null)},[fe]),ye=g.useMemo(()=>Object.values(N).reduce((F,B)=>F+((B==null?void 0:B.length)??0),0),[N]);return l.jsxs("div",{className:ze.dock,children:[l.jsxs("div",{className:ze.header,children:[l.jsxs("div",{className:ze.headerLeft,children:[l.jsx("button",{type:"button",className:ze.collapseBtn,onClick:r,"aria-label":n.libraryDock.collapseLibraryPanelAriaLabel,title:n.libraryDock.collapseLibraryTitle,children:l.jsx(Py,{size:15})}),l.jsx(Ly,{size:16}),l.jsx("span",{className:ze.headerTitle,children:n.libraryDock.headerTitle}),o>0&&l.jsx("span",{className:ze.count,children:o})]}),j&&l.jsx("span",{className:ze.libraryTargetLabel,children:j})]}),l.jsxs("div",{className:ze.searchRow,children:[l.jsxs("div",{className:ze.searchWrap,children:[l.jsx(Yi,{size:14,className:ze.searchIcon}),l.jsx("input",{type:"search",className:ze.searchInput,placeholder:n.libraryDock.searchPlaceholder,value:c,onChange:F=>f(F.target.value),"aria-label":n.libraryDock.searchAriaLabel})]}),l.jsx("button",{type:"button",className:[ze.filterToggleBtn,u?ze.filterToggleBtnActive:""].join(" "),onClick:b,"aria-label":u?n.libraryDock.sortAZAriaLabel:n.libraryDock.sortRecentAriaLabel,title:u?n.libraryDock.sortAZTitle:n.libraryDock.sortRecentTitle,children:u?l.jsx(Cy,{size:15}):l.jsx(Ty,{size:15})}),!D&&l.jsxs("button",{type:"button",className:[ze.filterToggleBtn,P?ze.filterToggleBtnActive:""].join(" "),onClick:()=>O(F=>!F),"aria-label":n.libraryDock.toggleAdvancedFiltersAriaLabel,"aria-pressed":P,title:n.libraryDock.advancedFiltersTitle,children:[l.jsx(zy,{size:15}),ye>0&&l.jsx("span",{className:ze.filterBadge,children:ye})]})]}),l.jsx("div",{className:ze.filters,children:l.jsx(FM,{filters:D?HB:pD,active:a,onChange:m})}),l.jsxs("div",{className:ze.mainArea,children:[l.jsx("div",{className:ze.cardList,role:"list","aria-label":n.libraryDock.libraryContentAriaLabel,children:i&&s.length===0?Array.from({length:4}).map((F,B)=>l.jsxs("div",{className:ze.skeleton,"aria-hidden":"true",children:[l.jsx("div",{className:ze.skeletonIcon}),l.jsxs("div",{className:ze.skeletonText,children:[l.jsx("div",{className:ze.skeletonLine}),l.jsx("div",{className:ze.skeletonLineSm})]})]},B)):s.length>0?l.jsxs(l.Fragment,{children:[s.map(F=>l.jsx(jM,{item:F,onAdd:fe,onPreview:ae,isDraggable:E,isAdded:te.has(F.identifier)},F.identifier)),d&&l.jsx("button",{type:"button",className:ze.loadMoreBtn,onClick:h,disabled:i,"aria-label":n.libraryDock.loadMoreAriaLabel,children:i?n.libraryDock.loadingText:n.libraryDock.loadMoreText})]}):l.jsxs("div",{className:ze.emptyState,children:[l.jsx(Yi,{size:24}),y==="noCurriculum"?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.learningPath.noCurriculumEmptyTitle}),l.jsx("span",{children:n.learningPath.noCurriculumEmptyHint})]}):y==="noSkills"?l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.learningPath.noSkillsEmptyTitle}),l.jsx("span",{children:n.learningPath.noSkillsEmptyHint})]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{children:n.libraryDock.noContentFound}),l.jsx("span",{children:n.libraryDock.tryDifferentSearch})]})]})}),P&&l.jsx("div",{className:ze.sidePanelOverlay,children:l.jsx(eB,{isOpen:P,filters:N,onApply:pe,onClose:()=>O(!1)})}),M&&l.jsx(bB,{content:M,editorMode:e,onAdd:we,onClose:()=>$(null)})]})]})};function GB(e,t,r,n=Al){const s={},i={},o=new Set(["id","isFolder","children","parent","isNew","breadcrumb","title","relationalMetadata","optional","metadata","isAssessmentCourse"]),a=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds","targetFWIds","targetTopicIds","topic","topicsIds"]),c=new Set(["audience","attributions","keywords","language","additionalCategories","medium","gradeLevel","subject","boardIds","mediumIds","gradeLevelIds","subjectIds","targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds","industry","domain","dialcodes"]),u=new Set(["copyrightYear","compatibilityLevel","version"]);function d(p,b=!1){const h={};for(const[v,y]of Object.entries(p))if(!o.has(v)&&!(b&&a.has(v)))if(c.has(v))Array.isArray(y)?h[v]=y:y!=null&&y!==""?h[v]=[y]:h[v]=[];else if(u.has(v)){const C=Number(y);isNaN(C)||(h[v]=C)}else h[v]=y;return h}function f(p){var h;const b={};for(const v of p.children??[]){if(v.isFolder)continue;const y=t[v.identifier];if(!y)continue;const{isNew:C,...S}=y;if(Object.keys(S).length===0)continue;const _=((h=v.metadata)==null?void 0:h.relationalMetadata)??{};b[v.identifier]={name:v.name,..._,...S}}return b}function m(p,b){var _,x;const h=p.identifier,v=t[h],y=h.startsWith("temp-")||!!(v!=null&&v.isNew),C=!p.isFolder&&!b;if(b||y||v&&!C){let T;if(y)T={mimeType:"application/vnd.ekstep.content-collection",code:h,contentType:((_=p.metadata)==null?void 0:_.contentType)??n.unitContentType,primaryCategory:((x=p.metadata)==null?void 0:x.primaryCategory)??n.unitPrimaryCategory,name:p.name,visibility:"Parent",channel:r,...d(p.metadata??{})};else if(b){const{isNew:D,...E}=v??{};T={...d(p.metadata??{},!0),...d(E,!1),name:p.name}}else{const{isNew:D,...E}=v??{};T={name:p.name,visibility:"Parent",...d(E,!0)}}s[h]={metadata:T,objectType:p.objectType||(p.isFolder?"Collection":"Content"),root:b,isNew:y}}const S=p.isFolder?f(p):{};i[h]={name:p.name,children:(p.children??[]).map(T=>T.identifier),...Object.keys(S).length>0?{relationalMetadata:S}:{},root:b},(p.children??[]).forEach(T=>m(T,!1))}return e.forEach((p,b)=>m(p,b===0)),{nodesModified:s,hierarchy:i}}function KB(){const[e,t]=g.useState(!1),r=re(d=>d.treeCache),n=re(d=>d.treeData),s=K(d=>d.isDirty),i=K(d=>d.lastSaved),{setIsDirty:o,setLastSaved:a}=K(),c=K(d=>d.editorConfig);return{save:g.useCallback(async()=>{if(!c||e)return;const d=c.context.contentId??c.context.identifier??"";if(!d)return;if(n.length===0){Se.error("Collection is empty. Please reload before saving.");return}const f=c.context.channel??"",m=c.context.userId??c.context.uid??"";t(!0);try{const p=K.getState().editorProfile,{nodesModified:b,hierarchy:h}=GB(n,r,f,p),{identifiers:v}=await r0(d,b,h,m);v&&Object.keys(v).length>0&&re.getState().replaceNodeIds(v);const y=new Date().toISOString();a(y),o(!1)}catch(p){console.error("[useSaveHierarchy] save failed:",p),Se.error("Failed to save. Please try again.")}finally{t(!1)}},[c,e,n,r,o,a]),isSaving:e,isDirty:s,lastSaved:i}}const YB={};function ZB(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function XB(e,t,r,n,s,i=YB){const o=[],a=(c,u)=>{var d;for(const f of c){const m=u&&!f.parent,p=m?r:f.isFolder?n:null;if(p&&p.length>0){const b={...f.metadata??{},...t[f.id]??{}},v=zp(p,b,i,m,s).filter(y=>y.required&&y.visible!==!1&&y.inputType!=="appIcon"&&ZB(y.currentValue)).map(y=>y.label);v.length>0&&o.push({nodeId:f.id,nodeName:f.name||"Untitled",missing:v})}(d=f.children)!=null&&d.length&&a(f.children,!1)}};return a(e,!0),o}function JB(e){var S,_;const t=K(x=>x.editorConfig),r=K(x=>x.editorProfile),n=K(x=>x.setButtonLoader),s=K(x=>x.validateAllForms),i=K(x=>x.rootFormConfig),o=K(x=>x.unitFormConfig),a=re(x=>x.treeData),c=re(x=>x.treeCache),u=re(x=>x.selectNode),d=lr(),{scope:f}=ii(),m=K(x=>x.contentFramework),p=K(x=>x.contentTargetFWIds),{organisationFramework:b,targetFrameworks:h}=Ao(m??((S=t==null?void 0:t.context)==null?void 0:S.framework),p??((_=t==null?void 0:t.context)==null?void 0:_.targetFWIds)),v=g.useCallback(()=>{var j,P,O;const x={editorMode:"edit",objectType:(j=t==null?void 0:t.config)==null?void 0:j.objectType,userFullName:(O=(P=t==null?void 0:t.context)==null?void 0:P.user)==null?void 0:O.fullName},T=XB(a,c,i,o,x,{organisationFramework:b,targetFrameworks:h});if(T.length===0)return!0;const D=T[0];Se.error(`"${D.nodeName}": please fill required field${D.missing.length>1?"s":""} — ${D.missing.join(", ")}`);const{setFormStatus:E}=K.getState();return T.forEach(N=>E(N.nodeId,!1)),u(D.nodeId),!1},[a,c,i,o,t,u,b,h]),y=g.useCallback(()=>{if(r.key!=="learningPath")return!0;const x=Rl(a[0],d==null?void 0:d.code,f,c);return x.length===0?!0:(Se.error(x[0].message),!1)},[r.key,a,c,d,f]);return{runAction:g.useCallback(async(x,T)=>{var j,P,O,N;const D=((j=t==null?void 0:t.context)==null?void 0:j.contentId)??((P=t==null?void 0:t.context)==null?void 0:P.identifier)??"";if(!D)return Se.error("No content identifier found."),!1;const E=((O=t==null?void 0:t.context)==null?void 0:O.userId)??((N=t==null?void 0:t.context)==null?void 0:N.uid)??"";try{switch(x){case"sendForReview":return v()?s(a)?y()?(n("saveCollection",!0),await e(),await i0(D),Se.success("Content sent for review"),!0):!1:(Se.error("Some units have missing required fields. Please fill them before sending for review."),!1):!1;case"reject":{n("rejectCollection",!0);const R=(T==null?void 0:T.comment)??"";return await o0(D,R),Se.success("Content rejected and sent back to the author"),!0}case"publish":return v()?s(a)?y()?(n("publishCollection",!0),await e(),await n0(D,E),Se.success("Content published successfully"),!0):!1:(Se.error("Some units have missing required fields. Please fill them before publishing."),!1):!1;default:return!1}}catch(R){console.error(`[useToolbarActions] ${x} failed`,R);const M=x==="sendForReview"?"send for review":x==="reject"?"reject":"publish";return Se.error(`Failed to ${M}. Please try again.`),!1}finally{n("saveCollection",!1),n("rejectCollection",!1),n("publishCollection",!1)}},[t,e,n,v,y,s,a]),checkRequiredFields:v}}function eq(){const e=oe(),t=K(c=>c.editorProfile.key==="learningPath"),r=re(c=>c.treeData),n=lr(),{scope:s,source:i}=ii(),o=g.useRef(!1),a=g.useRef("");g.useEffect(()=>{if(!t||i!=="prior"||!n)return;const c=m0(r[0],n.code,s),u=c.map(d=>d.id).sort().join(",");o.current?c.length>0&&u!==a.current&&Se.error(e.learningPath.priorAssessmentNarrowedScopeToast.replace("{count}",String(c.length))):o.current=!0,a.current=u},[t,i,s.join("|"),n==null?void 0:n.code,r])}function tq(){const e=K(o=>o.editorProfile.key==="learningPath"),t=re(o=>o.treeData),r=re(o=>o.treeCache),n=re(o=>o.updateNode),s=lr(),i=s==null?void 0:s.code;g.useEffect(()=>{if(!e||!i)return;const o=t[0],a=p0(o,i,r);a!==null&&n(o.id,{[i]:a},[i])},[e,t,r,i,n])}const rq="_shell_fu72l_1",nq="_workspace_fu72l_8",sq="_sidebarCollapsed_fu72l_16",iq="_dockCollapsed_fu72l_19",oq="_dock_fu72l_19",aq="_outline_fu72l_40",lq="_reopenTab_fu72l_45",cq="_outlineHidden_fu72l_79",uq="_editor_fu72l_86",dq="_editorLp_fu72l_92",fq="_dockHidden_fu72l_105",hq="_dockReopenTab_fu72l_112",pq="_dragChip_fu72l_137",mq="_dragChipLabel_fu72l_152",Ot={shell:rq,workspace:nq,sidebarCollapsed:sq,dockCollapsed:iq,dock:oq,outline:aq,reopenTab:lq,outlineHidden:cq,editor:uq,editorLp:dq,dockHidden:fq,dockReopenTab:hq,dragChip:pq,dragChipLabel:mq},gq=({editorMode:e,onToolbarEvent:t,onContentAdded:r,onHierarchySaved:n})=>{const s=oe(),[i,o]=g.useState(null),[a,c]=g.useState(!1),[u,d]=g.useState(!1),[f,m]=g.useState(!1);eq(),tq();const{addResource:p,treeData:b,treeCache:h}=re(),v=K(H=>H.setFormStatus),y=K(H=>H.editorProfile.key==="learningPath"),[C,S]=g.useState(!0),_=re(H=>H.selectedNodeId),{save:x,isSaving:T,isDirty:D,lastSaved:E}=KB(),{runAction:j,checkRequiredFields:P}=JB(x);g.useEffect(()=>{if(!D)return;const H=te=>{te.preventDefault(),te.returnValue=""};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[D]);const O=ff(ja(po,{activationConstraint:{distance:8}})),N=g.useCallback(H=>{var de;const te=(de=H.active.data.current)==null?void 0:de.item;te&&o(te)},[]),R=g.useCallback(H=>{var F,B,Z,he,be;o(null);const te=(F=H.active.data.current)==null?void 0:F.item;if(!te)return;if(y&&!xh(b[0],h)){Se.error(s.learningPath.selectCurriculumFirstToast);return}const de=H.over,fe=(de==null?void 0:de.id)??_??void 0,pe=y?s.learningPath.dropOntoLevelError:s.splitBuilderShell.dropOntoUnitError;if(!fe){Se.error(pe);return}const ae=(B=b[0])==null?void 0:B.id;if(fe===ae){Se.error(y?s.learningPath.dropOntoPathError:s.splitBuilderShell.dropOntoCourseError);return}const we=re.getState().getNodeById(fe);if(!(we!=null&&we.isFolder)){Se.error(pe);return}if(y&<(we)){const me=(be=(he=(Z=b[0])==null?void 0:Z.children)==null?void 0:he[0])==null?void 0:be.id;Se.error(we.id===me?s.learningPath.priorSlotFilledToast:s.learningPath.outcomeSlotFilledToast);return}if(!p(te,fe)){Se.error((y?s.learningPath.itemAlreadyInPathToast:s.splitBuilderShell.alreadyInCollectionError).replace("{name}",te.name));return}r==null||r(te,fe),Se.success((y?s.learningPath.addedToLevelSuccess:s.splitBuilderShell.addedToUnitSuccess).replace("{name}",te.name))},[_,p,b,h,r,s,y]),M=g.useCallback(async H=>{if(H.action==="onFormStatusChange"){const{isValid:te,nodeId:de}=H.data??{},fe=te!==!1;S(fe),de&&v(de,fe);return}if(H.action==="back"&&D&&e==="edit"){m(!0);return}if(H.action==="saveCollection"){if(!C){Se.error(s.splitBuilderShell.fillRequiredMetadataError);return}if(!P())return;await x(),n==null||n(b),t==null||t(H);return}if(H.action==="sendForReview"||H.action==="reject"||H.action==="publish"){await j(H.action,H.data)&&(t==null||t(H));return}t==null||t(H)},[x,j,P,t,n,b,D,C,e,s]),$=g.useCallback(async()=>{if(!P()){m(!1);return}await x(),m(!1),n==null||n(b),t==null||t({action:"back"})},[x,P,n,t,b]),ee=g.useCallback(()=>{m(!1),t==null||t({action:"back"})},[t]);return l.jsxs(Lf,{sensors:O,onDragStart:N,onDragEnd:R,children:[l.jsxs("div",{className:Ot.shell,children:[l.jsx(JT,{editorMode:e,isSaving:T,isDirty:D,lastSaved:E,isFormValid:C,onToolbarEvent:M}),l.jsxs("div",{className:[Ot.workspace,a?Ot.sidebarCollapsed:"",u?Ot.dockCollapsed:""].filter(Boolean).join(" "),children:[l.jsx("aside",{className:[Ot.outline,a?Ot.outlineHidden:""].join(" "),"aria-label":s.splitBuilderShell.outlineAriaLabel,"aria-hidden":a,children:l.jsx(OL,{editorMode:e,collapsed:a,onToggleCollapse:()=>c(H=>!H)})}),a&&l.jsx("button",{className:Ot.reopenTab,onClick:()=>c(!1),title:s.splitBuilderShell.showOutlineTitle,type:"button",children:"›"}),l.jsx("main",{className:[Ot.editor,y?Ot.editorLp:""].filter(Boolean).join(" "),role:"main","aria-label":s.splitBuilderShell.editorAriaLabel,children:l.jsx(pM,{editorMode:e,onToolbarEvent:M})}),l.jsx("aside",{className:[Ot.dock,u?Ot.dockHidden:""].filter(Boolean).join(" "),"aria-label":s.splitBuilderShell.libraryAriaLabel,"aria-hidden":u,children:l.jsx(WB,{editorMode:e,collapsed:u,onToggleCollapse:()=>d(H=>!H)})}),u&&l.jsx("button",{className:Ot.dockReopenTab,onClick:()=>d(!1),title:s.splitBuilderShell.showLibraryTitle,type:"button",children:"‹"})]})]}),l.jsx(my,{dropAnimation:null,children:i?l.jsx("div",{className:Ot.dragChip,children:l.jsx("span",{className:Ot.dragChipLabel,children:i.name})}):null}),f&&l.jsx(e1,{onSave:$,onDiscard:ee,onCancel:()=>m(!1),isSaving:T})]})},vq="v1";function yq(e){const t=e.validations,r=t==null?void 0:t.find(s=>s.type==="maxlength"||s.type==="maxLength");if(!r)return e.maxLength;const n=Number(r.value);return Number.isFinite(n)?n:void 0}function Id(e,t){var r;return{code:e.code??"",label:e.label??e.name??e.code??"",name:e.name,inputType:e.inputType,dataType:e.dataType,required:e.required===!0||Array.isArray(e.validations)&&e.validations.some(n=>n.type==="required")||String(((r=e.renderingHints)==null?void 0:r.class)??"").includes("required"),editable:e.editable!==!1,visible:e.visible!==!1,placeholder:e.placeholder,maxLength:yq(e),depends:e.depends,sourceCategory:e.sourceCategory,range:e.range,enum:e.enum,default:e.default,defaultValue:e.defaultValue,index:e.index,section:t,output:e.output}}function Dr(e){const t=e==null?void 0:e.properties;if(!Array.isArray(t))return[];const r=[];for(const n of t)if(Array.isArray(n.fields)){const s=n.name??void 0,i=n.fields.filter(o=>!!o.code).sort((o,a)=>(o.index??0)-(a.index??0));for(const o of i)r.push(Id(o,s))}else n.code&&r.push(Id(n));return r}function bq(e){const t=e==null?void 0:e.properties;if(!t)return{};const r={};for(const[n,s]of Object.entries(t))s&&"default"in s&&(r[n]=s.default);return r}async function Cq(e,t,r="Collection",n=vq){var u,d;const i=(d=(u=(await Fe.post(`/action/object/category/definition/${n}/read?fields=objectMetadata,forms,name,label`,{request:{objectCategoryDefinition:{objectType:r,name:e,...t?{channel:t}:{}}}})).data)==null?void 0:u.result)==null?void 0:d.objectCategoryDefinition,o=(i==null?void 0:i.forms)??{},a=(i==null?void 0:i.objectMetadata)??{},c=a.config??{};return{rootForm:Dr(o.create),unitForm:Dr(o.unitMetadata),childForm:Dr(o.childMetadata),searchForm:Dr(o.search??o.searchConfig),relationalForm:Dr(o.relationalMetadata),publishChecklist:Dr(o.publishchecklist),reviewChecklist:Dr(o.review),rfcChecklist:Dr(o.requestforchangeschecklist),schemaDefaults:bq(a.schema),frameworkMetadata:c.frameworkMetadata??{},sourcingSettings:c.sourcingSettings??{}}}function Dd(e,t,r){return{framework:e.framework??t??r.framework??null,targetFWIds:e.targetFWIds??r.targetFWIds??null}}function Sq({config:e,onError:t}){const[r,n]=g.useState(!0),[s,i]=g.useState(null),[o,a]=g.useState(!1),{setEditorConfig:c,setEditorMode:u,setCategoryDefinition:d,setContentFramework:f,setEditorProfile:m}=K(),{setTreeData:p,selectNode:b}=re();return g.useEffect(()=>{let h=!1;async function v(){var y,C,S;try{n(!0),i(null),e.apiBaseUrl&&mh(e.apiBaseUrl),c(e),u(e.config.mode),m(cb(e));const _=e.context.contentId??e.context.identifier??"",x=e.context.channel??"";let T;if(x)try{T=(y=await $p(x))==null?void 0:y.defaultFramework}catch{}let D=!1;if(_){const E=e.config.objectType==="QuestionSet";let{rootNode:j}=E?await t0(_):await yh(_);if(j&&e.config.primaryCategory==="Learning Path"&&(j=await c0(j)),!h&&(p(j?[j]:[]),j)){b(j.id);const{framework:M,targetFWIds:$}=Dd(j.metadata??{},T,e.context);f(M,$),D=!0}const P=e.config.primaryCategory??"Course",O=e.context.channel??"",N=e.config.categoryDefinitionApiVersion??"v1";try{const R=await Cq(P,O,e.config.objectType??"Collection",N);if(!h){d(R);const M=((C=R.sourcingSettings)==null?void 0:C.collection)??{},$={};M.maxDepth&&!e.config.maxDepth&&($.maxDepth=M.maxDepth),M.children&&!e.config.children&&($.children=M.children),M.hierarchy&&!((S=e.config.hierarchy)!=null&&S.level1)&&($.hierarchy={...e.config.hierarchy??{},...M.hierarchy}),Object.keys($).length>0&&c({...e,config:{...e.config,...$}})}}catch{}}if(!h&&!D){const{framework:E,targetFWIds:j}=Dd({},T,e.context);f(E,j)}h||a(!0)}catch(_){if(!h){const x=_ instanceof Error?_:new Error(String(_));i(x),t==null||t(x)}}finally{h||n(!1)}}return v(),()=>{h=!0}},[e.context.contentId,e.context.identifier]),{isLoading:r,error:s,isReady:o}}function _q(){const e=kl(t=>t.setLanguage);g.useEffect(()=>{e(localStorage.getItem(qa)||"en",{broadcast:!1});const t=n=>{n.key===qa&&n.newValue&&e(n.newValue,{broadcast:!1})},r=n=>{var i;const s=(i=n.detail)==null?void 0:i.lang;s&&e(s,{broadcast:!1})};return window.addEventListener("storage",t),window.addEventListener($a,r),()=>{window.removeEventListener("storage",t),window.removeEventListener($a,r)}},[e])}const wq="_root_1itrv_1",xq="_loadingState_1itrv_10",Tq="_loadingSpinner_1itrv_20",Eq="_errorState_1itrv_34",Ts={root:wq,loadingState:xq,loadingSpinner:Tq,errorState:Eq},Aq=new Bm({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function kq({error:e,onRetry:t}){const r=oe();return l.jsxs("div",{className:Ts.errorState,children:[l.jsx("h3",{children:r.collectionEditor.errorBoundaryTitle}),l.jsx("p",{children:e.message}),l.jsx("button",{onClick:t,children:r.collectionEditor.retryButton})]})}class Iq extends g.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t){var r,n;(n=(r=this.props).onError)==null||n.call(r,t)}render(){return this.state.error?l.jsx(kq,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}}function Dq(e){_q();const t=oe(),{isLoading:r,error:n}=Sq({config:e,onError:e.onError}),s=K(o=>o.editorMode),i=K(o=>o.editorProfile);return r?l.jsxs("div",{className:Ts.loadingState,children:[l.jsx("div",{className:Ts.loadingSpinner}),l.jsx("p",{children:t.collectionEditor.loadingMessage})]}):n?l.jsxs("div",{className:Ts.errorState,children:[l.jsx("h3",{children:t.collectionEditor.loadErrorTitle}),l.jsx("p",{children:n.message})]}):l.jsx("div",{className:["sb-split-builder",Ts.root,i.key==="learningPath"?"sbx-lp-profile":""].filter(Boolean).join(" "),children:l.jsx(gq,{editorMode:s,onToolbarEvent:e.onToolbarEvent,onContentAdded:e.onContentAdded,onHierarchySaved:e.onHierarchySaved})})}const um=e=>l.jsx(Iq,{onError:e.onError,children:l.jsxs($m,{client:Aq,children:[l.jsx(Dq,{...e}),l.jsx(qg,{position:"top-right",toastOptions:{duration:3e3,style:{fontFamily:"var(--sbx-font)"}}})]})}),oo=Symbol.for("r2wc.reactRender"),Ld=Symbol.for("r2wc.shouldRender"),Ti=Symbol.for("r2wc.root");function Lq(e=""){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function Oq(e=""){return e.replace(/-([a-z0-9])/g,function(t){return t[1].toUpperCase()})}var Od={expando:function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:function(){return r},set:function(n){r=n,this[oo]()}}),e[oo]()}};function Nq(e,t,r,n={}){var s={isConnected:"isConnected"in HTMLElement.prototype},i=!1,o=function(){var u=Reflect.construct(HTMLElement,arguments,this.constructor);return typeof n.shadow=="string"?u.attachShadow({mode:n.shadow}):n.shadow&&(console.warn('Specifying the "shadow" option as a boolean is deprecated and will be removed in a future version.'),u.attachShadow({mode:"open"})),u},a=Object.create(HTMLElement.prototype);a.constructor=o;var c=new Proxy(a,{has:function(u,d){return d in e.propTypes||d in a},set:function(u,d,f,m){return i&&(s[d]=!0),typeof d=="symbol"||s[d]||d in u?(e.propTypes&&d in e.propTypes&&Od.expando(m,d,f),Reflect.set(u,d,f,m)):(Od.expando(m,d,f),!0)},getOwnPropertyDescriptor:function(u,d){var f=Reflect.getOwnPropertyDescriptor(u,d);if(f)return f;if(d in e.propTypes)return{configurable:!0,enumerable:!0,writable:!0,value:void 0}}});return o.prototype=c,a.connectedCallback=function(){this[Ld]=!0,this[oo]()},a.disconnectedCallback=function(){typeof r.createRoot=="function"?this[Ti].unmount():r.unmountComponentAtNode(this)},a[oo]=function(){if(this[Ld]===!0){var u={};Object.keys(this).forEach(function(m){s[m]!==!1&&(u[m]=this[m])},this),i=!0;const d=n.shadow?this.shadowRoot:this,f=t.createElement(e,u);typeof r.createRoot=="function"?(this[Ti]||(this[Ti]=r.createRoot(d)),this[Ti].render(f)):r.render(f,d),i=!1}},e.propTypes&&(o.observedAttributes=n.dashStyleAttributes?Object.keys(e.propTypes).map(function(u){return Lq(u)}):Object.keys(e.propTypes),a.attributeChangedCallback=function(u,d,f){var m=n.dashStyleAttributes?Oq(u):u;this[m]=f}),o}var Pn={},Nd;function jq(){if(Nd)return Pn;Nd=1;var e=xr;if(process.env.NODE_ENV==="production")Pn.createRoot=e.createRoot,Pn.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;Pn.createRoot=function(r,n){t.usingClientEntryPoint=!0;try{return e.createRoot(r,n)}finally{t.usingClientEntryPoint=!1}},Pn.hydrateRoot=function(r,n,s){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(r,n,s)}finally{t.usingClientEntryPoint=!1}}}return Pn}var Pq=jq();const Rq=Tl(Pq);function Fq(){if(document.getElementById("sb-ce-react-styles"))return;const e=document.createElement("style");e.id="sb-ce-react-styles",e.textContent="@import url('https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700&display=swap');",document.head.insertBefore(e,document.head.firstChild)}function Mq(e="sb-collection-editor"){if(Fq(),typeof customElements>"u"||customElements.get(e))return;const t=Nq(um,g,Rq,{});customElements.define(e,t)}exports.CollectionEditor=um;exports.registerCollectionEditor=Mq;exports.setApiBaseUrl=mh;exports.useEditorStore=K;exports.useLibraryStore=am;exports.useTreeStore=re;
|