@project-sunbird/collection-editor-react 1.0.3 → 1.0.4
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 +2 -2
- 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&&Ii.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&&(I.isFunction(s)?r.paramsSerializer={serialize:s}:Ii.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),Ii.assertOptions(r,{baseUrl:St.spelling("baseURL"),withXsrfToken:St.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&I.merge(i.common,i[r.method]);i&&I.forEach(["delete","get","head","post","put","patch","query","common"],b=>{delete i[b]}),r.headers=It.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||Ll;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,g;if(!c){const b=[Xc.bind(this),void 0];for(b.unshift(...a),b.push(...u),g=b.length,d=Promise.resolve(r);f<g;)d=d.then(b[f++],b[f++]);return d}g=a.length;let p=r;for(;f<g;){const b=a[f++],h=a[f++];try{p=b(p)}catch(v){h.call(this,v);break}}try{d=Xc.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,g=u.length;f<g;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=gn(this.defaults,t);const r=ah(t.baseURL,t.url,t.allowAbsoluteUrls,t);return rh(r,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){hn.prototype[t]=function(r,n){return this.request(gn(n||{},{method:t,url:r,data:n&&I.hasOwnProp(n,"data")?n.data:void 0}))}});I.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 Wx=class dh{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 ri(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 dh(function(s){t=s}),cancel:t}}};function Gx(e){return function(r){return e.apply(null,r)}}function Kx(e){return I.isObject(e)&&e.isAxiosError===!0}const Va={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(Va).forEach(([e,t])=>{Va[t]=e});function fh(e){const t=new hn(e),r=Uf(hn.prototype.request,t);return I.extend(r,hn.prototype,t,{allOwnKeys:!0}),I.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return fh(gn(e,s))},r}const rt=fh(ti);rt.Axios=hn;rt.CanceledError=ri;rt.CancelToken=Wx;rt.isCancel=ih;rt.VERSION=Nl;rt.toFormData=wo;rt.AxiosError=J;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=Gx;rt.isAxiosError=Kx;rt.mergeConfig=gn;rt.AxiosHeaders=It;rt.formToJSON=e=>sh(I.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=uh.getAdapter;rt.HttpStatusCode=Va;rt.default=rt;const{Axios:Nq,AxiosError:jq,CanceledError:Pq,isCancel:Rq,CancelToken:Fq,VERSION:Mq,all:Bq,Cancel:qq,isAxiosError:$q,spread:Uq,toFormData:zq,AxiosHeaders:Vq,HttpStatusCode:Hq,formToJSON:Qq,getAdapter:Wq,mergeConfig:Gq,create:Kq}=rt;let Ha="";function hh(e){Ha=e}const Re=rt.create({timeout:3e4});Re.interceptors.request.use(async e=>{var s;const{useEditorStore:t}=await Promise.resolve().then(()=>ab),n=(s=t.getState().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),Ha&&(e.baseURL=Ha),e});const ph="/portal";async function mh(e){var n,s,i,o,a,c,u;const t=await Re.get(`${ph}/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 Yx(e){var r,n;return e.length?((n=(r=(await Re.post(`${ph}/question/v2/list`,{request:{search:{identifier:e}}})).data)==null?void 0:r.result)==null?void 0:n.questions)??[]:[]}function To(e,t){const r=e??{},n=r.identifier??"",s=r.objectType??"",i=r.mimeType??"",o=r.children,a=Array.isArray(o)?o.map(u=>To(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 gh(e){var s,i,o,a,c,u,d;const t=await Re.get(`/action/content/v3/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=To(r);return{content:r,rootNode:n}}async function Zx(e){const t=await mh(e),r=To(t);return{content:t,rootNode:r}}async function Xx(e,t,r,n){var i;return((i=(await Re.patch("/action/content/v3/hierarchy/update",{request:{data:{nodesModified:t,hierarchy:r,...n?{lastUpdatedBy:n}:{}}}})).data)==null?void 0:i.result)??{}}async function Jx(e,t=""){await Re.post(`/action/content/v3/publish/${e}`,{request:{content:{lastPublishedBy:t}}})}async function vh(e){var n,s,i,o,a,c,u;const t=await Re.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 e1(e){var r,n;return(n=(r=(await Re.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}async function t1(e){await Re.post(`/action/content/v3/review/${e}`,{request:{content:{}}})}async function r1(e,t){await Re.post(`/action/content/v3/reject/${e}`,{request:{content:{rejectComment:t}}})}async function n1(e,t){await Re.patch(`/action/content/v1/collaborator/update/${e}`,{request:{content:{collaborators:t}}})}const s1="application/vnd.sunbird.questionset";function yh(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===s1||(r=!1)}}return n(e.children??[]),t&&r}const eu=new Map;async function bh(e){const t=eu.get(e);if(t)return t;const r=await vh(e),{children:n,...s}=r??{},i={qualifies:yh(r),meta:s};return eu.set(e,i),i}async function Ch(e){return(await bh(e)).qualifies}async function i1(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=yh(c);else if(o.length===1&&(s===0||s===t.length-1))try{u=await Ch(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 o1(e,t,r){return r?e===0?"pre":e===t-1?"post":"levelAssessment":"content"}function a1(e,t){const r=e.findIndex(s=>s.id===t);return r===-1?null:Zi(e,r)?{role:r===0?"pre":"post",levelNumber:null}:{role:"level",levelNumber:e.slice(0,r+1).filter((s,i)=>!Zi(e,i)).length}}function Fs(e,t){return t==="pre"?e.length>0&<(e[0]):e.length>1&<(e[e.length-1])}function Zi(e,t){const r=o1(t,e.length,lt(e[t]));return r==="pre"||r==="post"}function Qa(e,t){const r=t?e.findIndex(n=>n.id===t.id):-1;return r!==-1&&Zi(e,r)}function l1(e){return Fs(e,"pre")?Fs(e,"post")?null:"post":"pre"}function c1(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 tu(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 Xi(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function Sh(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 _h(e,t){return!!Sh(e,t)}function u1(e,t){if(!e||!t)return[];const r=new Set,n=e.children??[];return n.forEach((s,i)=>{var o,a;Zi(n,i)?Xi((o=s.children[0].metadata)==null?void 0:o[t]).forEach(c=>r.add(c)):Xi((a=s.metadata)==null?void 0:a[t]).forEach(c=>r.add(c))}),Array.from(r)}const wh=new Set(["Diagnostic","PriorLearning"]);function d1(e,t,r){var p,b,h;const n=[];if(!e)return n;const s=(p=e.metadata)==null?void 0:p.policy;s||n.push({code:"policyMissing",message:"Set a consumption policy for this path."});const i=e.children??[],o=i[0],a=i.length>1?i[i.length-1]:void 0,c=lt(o),u=lt(a);!c&&s&&wh.has(s)&&n.push({code:"priorAssessmentRequired",message:"A Prior Assessment is required for the Adaptive/Prior learning policy."}),u||n.push({code:"outcomeAssessmentMissing",message:"Add an Outcome Assessment to close the path."}),[[o,"Prior Assessment"],[a,"Outcome Assessment"]].forEach(([v,y])=>{var S,_;if(!v)return;const C=v.children??[];(C.length!==1||!((_=(S=C[0])==null?void 0:S.metadata)!=null&&_.isAssessmentCourse))&&n.push({code:"slotNotPure",nodeId:v.id,message:`${y} must contain exactly one question-set-only course.`})});const d=new Set,f=(v,y)=>{d.has(v)&&n.push({code:"duplicateCourse",nodeId:y,message:"A course appears more than once in this path."}),d.add(v)},g=i.slice(c?1:0,i.length-(u?1:0));c&&f(o.children[0].id,o.id),u&&f(a.children[0].id,a.id);for(const v of g){const y=v.children??[];if(y.length===0){n.push({code:"emptyLevel",nodeId:v.id,message:`"${v.name}" has no courses yet.`});continue}const C=t?Xi((b=v.metadata)==null?void 0:b[t]):[];if(C.length===0)n.push({code:"levelMissingSkills",nodeId:v.id,message:`"${v.name}" needs at least one skill selected.`});else if(r.length>0){const S=C.filter(_=>!r.includes(_));S.length>0&&n.push({code:"levelSkillsOutOfScope",nodeId:v.id,message:`"${v.name}" has skills outside the current scope: ${S.join(", ")}.`})}for(const S of y)f(S.id,v.id),(t?Xi((h=S.metadata)==null?void 0:h[t]):[]).length===0&&n.push({code:"courseMissingSkillTag",nodeId:S.id,message:`"${S.name}" has no skill tag.`})}return n}async function f1(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 Ch(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 Pt(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 xh(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=xh(s.children,t,r+1);if(i>=0)return i}}return-1}const ru=new Set(["name","appIcon","description","keywords","trackable","qrCodeProcessId","reservedDialcodes"]);function Th(e,t,r,n){return e.map(s=>{if(s.id===t){const i=r.metadata??{},o=n!=null&&n.length?new Set([...ru,...n]):ru,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:Th(s.children,t,r,n)}:s})}function ki(e,t,r){return e.map(n=>n.id===t?{...n,children:[...n.children??[],r]}:n.children&&n.children.length>0?{...n,children:ki(n.children,t,r)}:n)}function Eh(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:Eh(s.children,t,r,n)}:s})}function Wa(e,t){return e.filter(r=>r.id!==t).map(r=>({...r,children:r.children?Wa(r.children,t):[]}))}function Ga(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:Ga(s.children,t,r,n)}:s})}function Ah(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?Ah(r.children,t):[]}})}function h1(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 p1(e,t){const r=Pt(e,t);if(!r)return[];const n=[];let s=r;for(;s;)n.unshift({id:s.id,name:s.name}),s=s.parent?Pt(e,s.parent):void 0;return n}const ue=Xs((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=Pt(n,r),a=i(r),c={...(o==null?void 0:o.metadata)??{},...s[r]??{}};Z.getState().setNodeFlags({isFolder:(o==null?void 0:o.isFolder)??!1,isRoot:!(o!=null&&o.parent),isQuml:!1}),Hr.getState().setActiveAssessmentSlot(null),e({selectedNodeId:r,breadcrumb:a,activeNodeMeta:c})},updateNode:(r,n,s)=>{if(e(i=>({treeData:Th(i.treeData,r,n,s),treeCache:{...i.treeCache,[r]:{...i.treeCache[r]??{},...n}}})),t().selectedNodeId===r){const i=Pt(t().treeData,r);e(o=>({activeNodeMeta:{...(i==null?void 0:i.metadata)??{},...o.treeCache[r]??{}}}))}t().markDirty()},addNode:(r,n)=>{var g,p,b;const s=t(),i=Z.getState().editorProfile,o=((p=(g=Z.getState().editorConfig)==null?void 0:g.config)==null?void 0:p.maxDepth)??i.maxDepth,a=xh(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=Pt(s.treeData,r))==null?void 0:b.children)??[],f=i.derivedRoles&&Fs(d,"post");return e(h=>({treeData:f?Eh(h.treeData,r,u,d.length-1):ki(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:Wa(i.treeData,r),selectedNodeId:i.selectedNodeId===r?null:i.selectedNodeId}))},reorderChildren:(r,n,s)=>{var a;const i=Z.getState().editorProfile,o=(a=t().treeData[0])==null?void 0:a.id;if(i.derivedRoles&&r===o){const c=Pt(t().treeData,r);if(c!=null&&c.children&&!c1(c.children,n,s))return}e(c=>({treeData:Ga(c.treeData,r,n,s)}))},moveNode:(r,n,s)=>{var u,d,f;const i=Z.getState().editorProfile,o=Pt(t().treeData,r),a=Pt(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 g=!!((d=o.metadata)!=null&&d.isAssessmentCourse),p=((f=t().treeData[0])==null?void 0:f.children)??[];if(!tu(a,g,Qa(p,a)))return}e(g=>{const p=Pt(g.treeData,r);if(!p)return g;let b=Wa(g.treeData,r);return b=ki(b,s,{...p,parent:s}),{treeData:b}}),t().markDirty()}},addResource:(r,n,s)=>{var b,h,v,y,C,S;const i=Z.getState().editorConfig,o=Z.getState().editorProfile,a=(b=t().treeData[0])==null?void 0:b.id,c=!!(s!=null&&s.isAssessmentCourse);if(o.derivedRoles&&n===a){if(!c||Pt(t().treeData,r.identifier))return!1;const _=t().treeData[0],x=(_==null?void 0:_.children)??[],E=(s==null?void 0:s.slot)??l1(x);if(!E||Fs(x,E))return!1;const D=t().addNode(a,"unit");if(!D)return!1;const{learningPath:T}=Al.getState().labelConfig;if(t().updateNode(D,{name:E==="pre"?T.priorAssessmentLabel:T.outcomeAssessmentLabel}),E==="pre"){const j=(((v=(h=t().treeData[0])==null?void 0:h.children)==null?void 0:v.length)??1)-1;e(F=>({treeData:Ga(F.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||Pt(t().treeData,r.identifier))return!1;const d=Pt(t().treeData,n);if(!(d!=null&&d.isFolder))return!1;if(o.derivedRoles){const _=((C=t().treeData[0])==null?void 0:C.children)??[];if(!tu(d,c,Qa(_,d)))return!1}const f=((S=i==null?void 0:i.config)==null?void 0:S.maxContentsLimit)??1200;if(h1(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:ki(_.treeData,n,p)})),t().markDirty(),!0},markDirty:()=>{const{editorMode:r,setIsDirty:n}=Z.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,g=!f||(Array.isArray(f)?f.includes(r):f===r);return g||n++,g});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},replaceNodeIds:r=>{!r||Object.keys(r).length===0||e(n=>{const s=Ah(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=>Pt(t().treeData,r),getChildrenOf:r=>{const n=Pt(t().treeData,r);return(n==null?void 0:n.children)??[]},getBreadcrumb:r=>p1(t().treeData,r)})),m1="_spin_1ah4d_9",g1={spin:m1};function ae(){return Al(e=>e.labelConfig)}const v1=({size:e=16,color:t="currentColor"})=>{const r=ae();return l.jsx("svg",{className:g1.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"})})},qe=({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(v1,{size:14}):null,i]}),Ih=({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 nu(e){var r,n;return(n=(r=(await Re.get(`/api/framework/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.framework}async function y1(e){var r,n;return((n=(r=(await Re.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 Eo(e,t){const r=Zn({queryKey:["framework",e],queryFn:()=>nu(e),enabled:!!e,staleTime:3e5}),n=t==null?void 0:t[0],s=Zn({queryKey:["framework",n],queryFn:()=>nu(n),enabled:!!n,staleTime:300*1e3}),i=s.data?[s.data]:[];return{organisationFramework:r.data,targetFrameworks:i,isLoading:r.isLoading||s.isLoading}}function kh(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 b1(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 as(){var i;const e=Z(o=>o.editorConfig),t=Z(o=>o.contentFramework),r=ue(o=>o.treeData),n=b1(r[0])??t??((i=e==null?void 0:e.context)==null?void 0:i.framework),{organisationFramework:s}=Eo(n);return kh(s==null?void 0:s.categories)}function C1(e,t,r){var u,d,f,g;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])??((g=i.metadata)==null?void 0:g[t.code]);return{scope:Array.isArray(a)?a:a?[a]:[],source:"prior"}}function Dh(){const e=as(),t=ue(n=>n.treeData),r=ue(n=>n.treeCache);return m.useMemo(()=>C1(t[0],e,r),[t,e,r])}const S1="_overlay_kdzmi_1",_1="_modal_kdzmi_15",w1="_modalHeader_kdzmi_27",x1="_modalHeaderClose_kdzmi_37",T1="_modalBody_kdzmi_55",E1="_modalFooter_kdzmi_62",A1="_checkRow_kdzmi_69",I1="_formGroup_kdzmi_112",k1="_textarea_kdzmi_123",D1="_sliderGroup_kdzmi_144",L1="_sliderValue_kdzmi_156",O1="_sliderLabels_kdzmi_164",N1="_sectionTitle_kdzmi_172",Ne={overlay:S1,modal:_1,modalHeader:w1,modalHeaderClose:x1,modalBody:T1,modalFooter:E1,checkRow:A1,formGroup:I1,textarea:k1,sliderGroup:D1,sliderValue:L1,sliderLabels:O1,sectionTitle:N1},j1=({objectType:e,onConfirm:t,onCancel:r})=>{const n=ae(),s=ue(p=>p.treeData[0]),i=as(),{scope:o}=Dh(),[a,c]=m.useState(null),u=d1(s,i==null?void 0:i.code,o);m.useEffect(()=>{let p=!1;return c(null),f1(s).then(b=>{p||c(b)}),()=>{p=!0}},[s]);const d=a===null,f=[...u,...a??[]],g=!d&&f.length===0;return l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",e]}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:f.length===0?l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:d?n.learningPath.verifyingAssessmentCourses:`${n.publishChecklist.confirmPublishPrefix} ${e}?`}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ne.sectionTitle,children:n.learningPath.resolveBeforePublishing}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:f.map((p,b)=>l.jsx("li",{children:p.message},`${p.code}-${p.nodeId??b}`))})]})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(qe,{variant:"primary",onClick:t,disabled:!g,children:n.publishChecklist.yesButton})]})]})})},P1=({contentId:e,onConfirm:t,onCancel:r})=>{const n=ae(),s=Z(g=>{var p,b;return(b=(p=g.editorConfig)==null?void 0:p.config)==null?void 0:b.objectType})||"Content",i=Z(g=>g.editorProfile.key==="learningPath"),o=Z(g=>g.publishChecklist)??[],[a,c]=m.useState({}),u=o.every(g=>a[g.code]),d=o.length===0||u,f=()=>{t()};return i?l.jsx(j1,{objectType:s,onConfirm:t,onCancel:r}):l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",s]}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.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:Ne.sectionTitle,children:n.publishChecklist.checklistInstructions}),o.map(g=>l.jsxs("label",{className:Ne.checkRow,children:[l.jsx("input",{type:"checkbox",checked:!!a[g.code],onChange:p=>c(b=>({...b,[g.code]:p.target.checked}))}),l.jsx("span",{children:g.label})]},g.code))]})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(qe,{variant:"primary",onClick:f,disabled:!d,children:n.publishChecklist.yesButton})]})]})})},R1=({contentId:e,action:t,onConfirm:r,onCancel:n})=>{const s=ae(),[i,o]=m.useState(""),[a,c]=m.useState(7),u=t==="approve",d=u?s.qualityParamsModal.reviewQualityTitle:s.qualityParamsModal.rejectContentTitle,f=!u&&i.trim().length===0,g=()=>{u?r(i.trim(),a):r(i.trim())};return l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"quality-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsx("span",{id:"quality-modal-title",children:d}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:n,"aria-label":s.qualityParamsModal.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:u?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ne.formGroup,children:[l.jsx("label",{htmlFor:"quality-score",children:s.qualityParamsModal.qualityScoreLabel}),l.jsxs("div",{className:Ne.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:Ne.sliderValue,children:a})]}),l.jsxs("div",{className:Ne.sliderLabels,children:[l.jsx("span",{children:s.qualityParamsModal.scorePoorLabel}),l.jsx("span",{children:s.qualityParamsModal.scoreExcellentLabel})]})]}),l.jsxs("div",{className:Ne.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:Ne.textarea,placeholder:s.qualityParamsModal.commentPlaceholder,value:i,onChange:p=>o(p.target.value),rows:4})]})]}):l.jsxs("div",{className:Ne.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:Ne.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:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:n,children:s.qualityParamsModal.cancelButton}),l.jsx(qe,{variant:u?"primary":"danger",onClick:g,disabled:f,children:u?s.qualityParamsModal.approveButton:s.qualityParamsModal.rejectButton})]})]})})},Lh=["email","firstName","lastName","identifier","organisations","rootOrgName","phone"];async function F1(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:Lh,offset:0,limit:t.limit??200};return s?n.email=e.trim():i?n.phone=e.trim():o.query=e,((f=(d=(u=(await Re.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 M1(e){var r,n,s;return e.length?((s=(n=(r=(await Re.post("/action/user/v1/search",{request:{filters:{userId:e},fields:Lh,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 B1(e){var r,n;return((n=(r=(await Re.get(`/portal/user/v5/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.response)??{}}const q1="_container_1hnn8_1",$1="_header_1hnn8_13",U1="_title_1hnn8_22",z1="_closeBtn_1hnn8_29",V1="_body_1hnn8_45",H1="_label_1hnn8_54",Q1="_searchSection_1hnn8_62",W1="_searchRow_1hnn8_68",G1="_searchInput_1hnn8_74",K1="_searchSpinner_1hnn8_89",Y1="_resultsList_1hnn8_105",Z1="_resultItem_1hnn8_118",X1="_userInfo_1hnn8_133",J1="_userName_1hnn8_141",e0="_userEmail_1hnn8_150",t0="_userOrg_1hnn8_158",r0="_noResults_1hnn8_167",n0="_collabSection_1hnn8_174",s0="_sectionTitle_1hnn8_179",i0="_badge_1hnn8_189",o0="_emptyCollab_1hnn8_203",a0="_collabList_1hnn8_214",l0="_collabItem_1hnn8_223",c0="_userAvatar_1hnn8_237",u0="_error_1hnn8_251",d0="_success_1hnn8_257",f0="_footer_1hnn8_263",Pe={container:q1,header:$1,title:U1,closeBtn:z1,body:V1,label:H1,searchSection:Q1,searchRow:W1,searchInput:G1,searchSpinner:K1,resultsList:Y1,resultItem:Z1,userInfo:X1,userName:J1,userEmail:e0,userOrg:t0,noResults:r0,collabSection:n0,sectionTitle:s0,badge:i0,emptyCollab:o0,collabList:a0,collabItem:l0,userAvatar:c0,error:u0,success:d0,footer:f0},h0=({contentId:e,onClose:t})=>{var j,F;const r=ae(),n=Z(O=>O.editorConfig),s=(j=n==null?void 0:n.context)==null?void 0:j.channel,i=(F=n==null?void 0:n.config)==null?void 0:F.objectType,[o,a]=m.useState(""),[c,u]=m.useState([]),[d,f]=m.useState(!1),[g,p]=m.useState([]),[b,h]=m.useState(!1),[v,y]=m.useState(""),[C,S]=m.useState(!1),_=m.useRef(null);m.useEffect(()=>{let O=!1;return(async()=>{try{const N=await e1(e),B=(N==null?void 0:N.collaborators)??[];if(!B.length)return;const P=await M1(B);if(O)return;const U=B.map(ne=>P.find(H=>H.identifier===ne)??{identifier:ne,firstName:ne});p(U)}catch{}})(),()=>{O=!0}},[e]),m.useEffect(()=>{_.current&&clearTimeout(_.current);const O=o.trim();if(O.length<2){u([]);return}return _.current=setTimeout(async()=>{f(!0);try{const N=await F1(O,{rootOrgId:s,objectType:i}),B=new Set(g.map(P=>P.identifier));u(N.filter(P=>!B.has(P.identifier)))}catch{u([])}finally{f(!1)}},300),()=>{_.current&&clearTimeout(_.current)}},[o,g,s,i]);const x=m.useCallback(O=>{p(N=>N.find(B=>B.identifier===O.identifier)?N:[...N,O]),u(N=>N.filter(B=>B.identifier!==O.identifier)),S(!1)},[]),E=m.useCallback(O=>{p(N=>N.filter(B=>B.identifier!==O)),S(!1)},[]),D=m.useCallback(async()=>{h(!0),y(""),S(!1);try{await n1(e,g.map(O=>O.identifier)),S(!0)}catch{y(r.manageCollaborators.saveFailed)}finally{h(!1)}},[e,g,r.manageCollaborators.saveFailed]),T=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(yr,{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,B,P,U;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:T(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((B=(N=O.organisations)==null?void 0:N[0])==null?void 0:B.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:((U=(P=O.organisations)==null?void 0:P[0])==null?void 0:U.orgName)??O.rootOrgName})]}),l.jsx(qe,{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,g.length>0&&l.jsx("span",{className:Pe.badge,children:g.length})]}),g.length===0?l.jsx("p",{className:Pe.emptyCollab,children:r.manageCollaborators.noCollaboratorsYet}):l.jsx("ul",{className:Pe.collabList,children:g.map(O=>{var N,B,P,U;return l.jsxs("li",{className:Pe.collabItem,children:[l.jsx("div",{className:Pe.userAvatar,"aria-hidden":"true",children:T(O).charAt(0).toUpperCase()}),l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:T(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((B=(N=O.organisations)==null?void 0:N[0])==null?void 0:B.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:((U=(P=O.organisations)==null?void 0:P[0])==null?void 0:U.orgName)??O.rootOrgName})]}),l.jsx(qe,{variant:"danger",size:"sm",onClick:()=>E(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(qe,{variant:"ghost",onClick:t,disabled:b,children:r.manageCollaborators.cancel}),l.jsx(qe,{variant:"primary",isLoading:b,onClick:D,children:r.manageCollaborators.save})]})]})};async function p0(e){return(await Re.post("/api/dialcode/v1/read",{request:{dialcodes:[e]}})).data}async function m0(e,t){var s;const n=((s=(await Re.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 g0(e){var n;const r=((n=(await Re.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 v0="_topbar_c3y0z_1",y0="_left_c3y0z_15",b0="_right_c3y0z_23",C0="_backBtn_c3y0z_30",S0="_title_c3y0z_49",_0="_profileBadge_c3y0z_61",w0="_statusChip_c3y0z_76",x0="_savedIndicator_c3y0z_88",T0="_unsaved_c3y0z_98",E0="_iconBtn_c3y0z_103",A0="_iconBtnLabel_c3y0z_130",I0="_qrDropdown_c3y0z_134",k0="_qrMenu_c3y0z_138",D0="_reviewBtns_c3y0z_173",L0="_sourcingBtns_c3y0z_182",O0="_modalOverlay_c3y0z_191",N0="_sbOverlay_c3y0z_201",j0="_sbModal_c3y0z_211",P0="_sbModalHeader_c3y0z_222",R0="_sbModalTitle_c3y0z_230",F0="_sbModalClose_c3y0z_237",M0="_sbModalBody_c3y0z_250",B0="_sbLabel_c3y0z_257",q0="_sbTextarea_c3y0z_264",$0="_sbError_c3y0z_281",U0="_sbModalFooter_c3y0z_288",Se={topbar:v0,left:y0,right:b0,backBtn:C0,title:S0,profileBadge:_0,statusChip:w0,savedIndicator:x0,unsaved:T0,iconBtn:E0,iconBtnLabel:A0,qrDropdown:I0,qrMenu:k0,reviewBtns:D0,sourcingBtns:L0,modalOverlay:O0,sbOverlay:N0,sbModal:j0,sbModalHeader:P0,sbModalTitle:R0,sbModalClose:F0,sbModalBody:M0,sbLabel:B0,sbTextarea:q0,sbError:$0,sbModalFooter:U0};function z0(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function V0(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}const H0=({titleText:e,labelText:t,placeholderText:r,submitLabel:n,submitVariant:s="primary",onConfirm:i,onCancel:o})=>{const a=ae(),[c,u]=m.useState(""),d=e.toLowerCase().replace(/\s+/g,"-");return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":`${d}-title`,children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:`${d}-title`,className:Se.sbModalTitle,children:e}),l.jsx("button",{className:Se.sbModalClose,onClick:o,"aria-label":a.reviewCommentModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:Se.sbModalBody,children:[l.jsxs("label",{className:Se.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:Se.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:Se.sbError,children:a.reviewCommentModal.fillCommentsError})]}),l.jsxs("div",{className:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:o,children:a.reviewCommentModal.cancelButton}),l.jsx(qe,{variant:s,onClick:()=>i(c.trim()),disabled:c.trim().length===0,children:n})]})]})})},Q0=({onConfirm:e,onCancel:t})=>{const r=ae(),[n,s]=m.useState(!1);return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"review-confirm-title",children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:"review-confirm-title",className:Se.sbModalTitle,children:r.confirmReviewModal.title}),l.jsx("button",{className:Se.sbModalClose,onClick:t,"aria-label":r.confirmReviewModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsx("div",{className:Se.sbModalBody,children: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:i=>s(i.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:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:t,children:r.confirmReviewModal.cancelButton}),l.jsx(qe,{variant:"primary",onClick:e,disabled:!n,children:r.confirmReviewModal.submitButton})]})]})})},W0=({onConfirm:e,onCancel:t})=>{const r=ae(),[n,s]=m.useState(""),i=parseInt(n,10),o=!isNaN(i)&&i>=2&&i<=250;return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"genqr-title",children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:"genqr-title",className:Se.sbModalTitle,children:r.generateQRModal.title}),l.jsx("button",{className:Se.sbModalClose,onClick:t,"aria-label":r.generateQRModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:Se.sbModalBody,children:[l.jsxs("label",{className:Se.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:Se.sbTextarea,style:{resize:"none",height:"40px"},placeholder:r.generateQRModal.countPlaceholder,value:n,onChange:a=>s(a.target.value)}),n&&!o&&l.jsx("p",{className:Se.sbError,children:r.generateQRModal.countRangeError})]}),l.jsxs("div",{className:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:t,children:r.generateQRModal.cancelButton}),l.jsx(qe,{variant:"primary",onClick:()=>e(i),disabled:!o,children:r.generateQRModal.generateButton})]})]})})},G0=({editorMode:e,isSaving:t,isDirty:r,lastSaved:n,isFormValid:s=!0,onToolbarEvent:i})=>{var Ce,de;const o=ae(),c=ue(ce=>ce.treeData)[0],u=(c==null?void 0:c.name)??o.contextualEditor.untitledPlaceholder,d=V0(((Ce=c==null?void 0:c.metadata)==null?void 0:Ce.status)??(c==null?void 0:c.status),o.topbar.draftStatusFallback),f=Z(ce=>{var Q,se,Te,me;return((se=(Q=ce.editorConfig)==null?void 0:Q.context)==null?void 0:se.contentId)??((me=(Te=ce.editorConfig)==null?void 0:Te.context)==null?void 0:me.identifier)??""}),{activeModal:g,modalData:p,closeModal:b,openModal:h}=Hr(),v=Z(ce=>ce.buttonLoaders),y=Z(ce=>ce.categoryMeta),C=Z(ce=>ce.editorProfile),S=C.key==="learningPath",_=C.features.dialcodes&&(!y||y.schemaDefaults.generateDIALCodes!=="No"),[x,E]=m.useState(!1),[D,T]=m.useState(!1),[j,F]=m.useState(!1),O=m.useRef(null),[N,B]=m.useState(!1);m.useEffect(()=>{if(!j)return;const ce=Q=>{var se;(se=O.current)!=null&&se.contains(Q.target)||F(!1)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[j]);const[P,U]=m.useState(!1),[ne,H]=m.useState(!1),{updateNode:te}=ue(),he=(de=c==null?void 0:c.metadata)==null?void 0:de.qrCodeProcessId,oe=m.useCallback(async ce=>{if(f){B(!1),U(!0);try{const{processId:Q,reservedDialcodes:se}=await m0(f,ce);Q&&c&&te(c.id,{qrCodeProcessId:Q,reservedDialcodes:se}),we.success(o.topbar.qrGenerationStartedToast)}catch{we.error(o.topbar.qrGenerationFailedToast)}finally{U(!1)}}},[f,c,te,o]),ge=m.useCallback(async()=>{if(!he){we.error(o.topbar.qrCodesNotGeneratedToast);return}H(!0);try{const ce=await g0(he);if(ce.status==="in-process"){we(o.topbar.qrGenerationInProgressToast,{icon:l.jsx(Ps,{size:16})});return}const Q=ce.url;if(!Q){we.error(o.topbar.qrCodesNotReadyToast);return}const se=await fetch(Q).then(tt=>tt.blob()),Te=await new Promise(tt=>{const st=new FileReader;st.onloadend=()=>tt(st.result),st.readAsDataURL(se)}),me=(c==null?void 0:c.metadata)??{},ee=tt=>Array.isArray(tt)?tt.join("_"):typeof tt=="string"?tt:"",He=[f,ee(me.medium),ee(me.gradeLevel),ee(me.subject)].filter(Boolean),Ge=new Date().toISOString().replace(/[:.]/g,"-"),Ze=`${He.join("_")}_${Ge}.zip`,Qe=document.createElement("a");Qe.href=Te,Qe.download=Ze,Qe.style.display="none",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),we.success(o.topbar.qrCodesDownloadedToast)}catch{we.error(o.topbar.qrCodesDownloadFailedToast)}finally{H(!1)}},[he,c,f,o]),ve=e==="edit",xe=e==="review",ye=e==="sourcingreview",R=e==="read",M=m.useCallback((ce,Q)=>{i({action:ce,data:Q})},[i]),Y=m.useCallback(()=>{b(),M("publish")},[b,M]),le=m.useCallback((ce,Q)=>{const se=p==null?void 0:p.action;b(),se==="approve"?M("sourcingApprove",{comment:ce,score:Q}):M("reject",{comment:ce})},[b,M,p]);return l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:Se.topbar,role:"banner",children:[l.jsxs("div",{className:Se.left,children:[l.jsx("button",{className:Se.backBtn,onClick:()=>M("back"),"aria-label":o.topbar.backAriaLabel,type:"button",children:l.jsx(_l,{size:18})}),l.jsx("h1",{className:Se.title,title:u,children:u}),S&&l.jsxs("span",{className:Se.profileBadge,children:[l.jsx(Ih,{size:13,"aria-hidden":"true"}),o.learningPath.profileBadgeLabel]}),l.jsx("span",{className:`sbx-chip ${Se.statusChip}`,"aria-label":`${o.topbar.statusAriaLabelPrefix} ${d}`,children:d})]}),l.jsxs("div",{className:Se.right,children:[t?l.jsx("span",{className:Se.savedIndicator,"aria-live":"polite",children:o.topbar.savingIndicator}):r&&ve?l.jsx("span",{className:`${Se.savedIndicator} ${Se.unsaved}`,"aria-live":"polite",children:o.topbar.unsavedIndicator}):n?l.jsxs("span",{className:Se.savedIndicator,"aria-live":"polite",children:[l.jsx(yn,{size:14,"aria-hidden":"true"}),o.topbar.savedIndicatorPrefix," ",z0(n)]}):null,!R&&!xe&&!ye&&d!=="Review"&&l.jsx("span",{title:s?void 0:o.topbar.fillRequiredFieldsTooltip,children:l.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>M("saveCollection"),disabled:!s,children:o.topbar.saveAsDraftButton})}),ve&&l.jsxs(l.Fragment,{children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>T(!0),disabled:v.saveCollection,isLoading:v.saveCollection,children:[l.jsx(Fy,{size:14,"aria-hidden":"true"})," ",o.topbar.sendForReviewButton]}),C.features.collaborators&&l.jsx("button",{className:Se.iconBtn,onClick:()=>h("manageCollaborators"),"aria-label":o.topbar.collaboratorsLabel,title:o.topbar.collaboratorsLabel,type:"button",children:l.jsx(Vy,{size:16,"aria-hidden":"true"})}),_&&l.jsxs("div",{className:Se.qrDropdown,ref:O,children:[l.jsxs("button",{className:Se.iconBtn,onClick:()=>F(ce=>!ce),"aria-label":o.topbar.qrCodesLabel,title:o.topbar.qrCodesLabel,type:"button","aria-haspopup":"true","aria-expanded":j,children:[l.jsx(Tc,{size:16,"aria-hidden":"true"}),l.jsx("span",{className:Se.iconBtnLabel,children:o.topbar.qrCodesLabel}),l.jsx(bn,{size:14,style:{marginLeft:2},"aria-hidden":"true"})]}),j&&l.jsxs("div",{className:Se.qrMenu,role:"menu",children:[l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{F(!1),B(!0)},disabled:P,children:[l.jsx(Tc,{size:14}),P?o.topbar.generatingEllipsis:o.topbar.generateQrCodesMenuItem]}),l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{F(!1),ge()},disabled:ne||!he,children:[l.jsx(wy,{size:14}),ne?o.topbar.downloadingEllipsis:o.topbar.downloadQrCodesMenuItem]})]})]})]}),xe&&l.jsxs("div",{className:Se.reviewBtns,children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("publishChecklist"),disabled:v.publishCollection,isLoading:v.publishCollection,children:[l.jsx(Nf,{size:14,"aria-hidden":"true"})," ",o.topbar.publishButton]}),l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>E(!0),disabled:v.rejectCollection,isLoading:v.rejectCollection,children:[l.jsx(Ec,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]}),ye&&l.jsxs("div",{className:Se.sourcingBtns,children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"approve"}),children:[l.jsx(By,{size:14,"aria-hidden":"true"})," ",o.topbar.approveButton]}),l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"reject"}),children:[l.jsx(Ec,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]})]})]}),g==="publishChecklist"&&l.jsx(P1,{contentId:f,onConfirm:Y,onCancel:b}),g==="qualityParams"&&l.jsx(R1,{contentId:f,action:(p==null?void 0:p.action)??"reject",onConfirm:le,onCancel:b}),g==="manageCollaborators"&&l.jsx("div",{className:Se.modalOverlay,role:"dialog","aria-modal":"true",children:l.jsx(h0,{contentId:f,onClose:b})}),D&&l.jsx(Q0,{onConfirm:()=>{T(!1),M("sendForReview")},onCancel:()=>T(!1)}),x&&l.jsx(H0,{titleText:o.topbar.requestChangesTitle,labelText:o.topbar.changesRequestedLabel,placeholderText:o.topbar.describeChangesPlaceholder,submitLabel:o.topbar.requestForChangesButton,submitVariant:"primary",onConfirm:ce=>{E(!1),M("reject",{comment:ce})},onCancel:()=>E(!1)}),N&&l.jsx(W0,{onConfirm:oe,onCancel:()=>B(!1)})]})},K0=({onSave:e,onDiscard:t,onCancel:r,isSaving:n})=>{const s=ae();return Ur.createPortal(l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"unsaved-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsx("span",{id:"unsaved-title",children:s.unsavedChangesModal.title}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":s.unsavedChangesModal.closeAriaLabel,disabled:n,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:s.unsavedChangesModal.bodyMessage})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,disabled:n,children:s.unsavedChangesModal.cancelButton}),l.jsx(qe,{variant:"danger",onClick:t,disabled:n,children:s.unsavedChangesModal.discardButton}),l.jsx(qe,{variant:"primary",onClick:e,isLoading:n,disabled:n,children:s.unsavedChangesModal.saveButton})]})]})}),document.body)};var Y0=Tl();const Oh=m.createContext(null);function Bt(){const e=m.useContext(Oh);if(e===null)throw new Error("No Tree Api Provided");return e}const Nh=m.createContext(null);function Z0(){const e=m.useContext(Nh);if(e===null)throw new Error("Provide a NodesContext");return e}const jh=m.createContext(null);function X0(){const e=m.useContext(jh);if(e===null)throw new Error("Provide a DnDContext");return e}const Ph=m.createContext(0);function Rh(){m.useContext(Ph)}function Di(e,t,r){return Math.max(Math.min(e,r),t)}function Fh(e){return e&&e.isLeaf}function Mh(e){return e&&e.isInternal&&!e.isOpen}function Bh(e){var t;return e&&e.isOpen&&!(!((t=e.children)===null||t===void 0)&&t.length)}const qh=(e,t)=>{let r=e;for(;r;){if(r.id===t.id)return!0;r=r.parent}return!1},$h=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function Pl(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let r of e.children){const n=Pl(r,t);if(n)return n}return null}function Ji(e,t){if(t(e),e.children)for(let r of e.children)Ji(r,t)}function Uh(e){const t=Vh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=J0(t,n);break}r==null||r.focus()}function zh(e){const t=Vh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=eT(t,n);break}r==null||r.focus()}function J0(e,t){return t+1<e.length?e[t+1]:e[0]}function eT(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function Vh(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 _s(e,t){return typeof t=="boolean"?t:typeof t=="string"?e[t]:t(e)}function Pn(e){return typeof e=="string"?e:e.id}function tT(e,...t){if(e)return e(...t)}function Hh(e){return new Promise((t,r)=>{let n=0;function s(){n+=1,n===100&&r(),e()?t():setTimeout(s,10)}s()})}function Qh(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 Wh(e){const t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}const rT=Object.freeze(Object.defineProperty({__proto__:null,access:_s,bound:Di,dfs:Pl,focusNextElement:Uh,focusPrevElement:zh,getInsertIndex:Qh,getInsertParentId:Wh,identify:Pn,indexOf:$h,isClosed:Mh,isDescendant:qh,isItem:Fh,isOpenWithEmptyChildren:Bh,safeRun:tT,waitFor:Hh,walk:Ji},Symbol.toStringTag,{value:"Module"})),nT={display:"flex",alignItems:"center",zIndex:1},sT={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},iT={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},oT=m.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({},nT),s),children:[l.jsx("div",{style:Object.assign({},iT)}),l.jsx("div",{style:Object.assign({},sT)})]})});function aT({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 lT(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(uT,Object.assign({},e)):l.jsx(cT,Object.assign({},e))]})}function cT(e){return l.jsx(l.Fragment,{children:l.jsx("span",{children:e.node.data.name})})}function uT({node:e}){const t=m.useRef();return m.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 Ms="__REACT_ARBORIST_INTERNAL_ROOT__";function su(e){var t;function r(i,o,a){const c=e.accessId(i),u=new Bs({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 Bs({tree:e,id:Ms,data:{id:Ms},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 Bs{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===Ms}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 Bs(Object.assign({},this))}edit(){return this.tree.edit(this)}}function Go(e){return{type:"EDIT",id:e}}function dT(e={id:null},t){return t.type==="EDIT"?Object.assign(Object.assign({},e),{id:t.id}):e}function Tn(e){return{type:"FOCUS",id:e}}function fT(){return{type:"TREE_BLUR"}}function hT(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 Ka={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 iu(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 pT(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:iu(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:iu(e.unfiltered,t)}):e}const es=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:Pn(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(Pn)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(Pn)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:e===null?null:Pn(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:e===null?null:Pn(e)})};function mT(e=es().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 ts={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 gT(e=es().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 es().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}const vT={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},yT=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t}px, ${r}px)`}},bT=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t+10}px, ${r+10}px)`}};function Gh({offset:e,mouse:t,id:r,dragIds:n,isDragging:s}){return l.jsxs(CT,{isDragging:s,children:[l.jsx(ST,{offset:e,children:l.jsx(wT,{id:r,dragIds:n})}),l.jsx(_T,{mouse:t,count:n.length})]})}const CT=m.memo(function(t){return t.isDragging?l.jsx("div",{style:vT,children:t.children}):null});function ST(e){return l.jsx("div",{className:"row preview",style:yT(e.offset),children:e.children})}function _T(e){const{count:t,mouse:r}=e;return t>1?l.jsx("div",{className:"selected-count",style:bT(r),children:t}):null}const wT=m.memo(function(t){const r=Bt(),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 Ya(){return Ya=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},Ya.apply(null,arguments)}function ou(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Za(e,t){return Za=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Za(e,t)}function xT(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Za(e,t)}var au=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function TT(e,t){return!!(e===t||au(e)&&au(t))}function ET(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!TT(e[r],t[r]))return!1;return!0}function Ko(e,t){t===void 0&&(t=ET);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 AT=typeof performance=="object"&&typeof performance.now=="function",lu=AT?function(){return performance.now()}:function(){return Date.now()};function cu(e){cancelAnimationFrame(e.id)}function IT(e,t){var r=lu();function n(){lu()-r>=t?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var Yo=-1;function uu(e){if(e===void 0&&(e=!1),Yo===-1||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(t),Yo=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Yo}var En=null;function du(e){if(e===void 0&&(e=!1),En===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?En="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?En="negative":En="positive-ascending"),document.body.removeChild(t),En}return En}process.env.NODE_ENV;var kT=150,DT=function(t,r){return t},Li=null,Oi=null;process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof window.WeakSet<"u"&&(Li=new WeakSet,Oi=new WeakSet);function Kh(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){xT(g,f);function g(b){var h;return h=f.call(this,b)||this,h._instanceProps=c(h.props,ou(h)),h._outerRef=void 0,h._resetIsScrollingTimeoutId=null,h.state={instance:ou(h),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof h.props.initialScrollOffset=="number"?h.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},h._callOnItemsRendered=void 0,h._callOnItemsRendered=Ko(function(v,y,C,S){return h.props.onItemsRendered({overscanStartIndex:v,overscanStopIndex:y,visibleStartIndex:C,visibleStopIndex:S})}),h._callOnScroll=void 0,h._callOnScroll=Ko(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),E;if(x.hasOwnProperty(v))E=x[v];else{var D=r(h.props,v,h._instanceProps),T=s(h.props,v,h._instanceProps),j=C==="horizontal"||_==="horizontal",F=C==="rtl",O=j?D:0;x[v]=E={position:"absolute",left:F?void 0:O,right:F?O:void 0,top:j?0:D,height:j?"100%":T,width:j?T:"100%"}}return E},h._getItemStyleCache=void 0,h._getItemStyleCache=Ko(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 E=h.props.direction,D=S;if(E==="rtl")switch(du()){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 E=Math.max(0,Math.min(_,S-C));return{isScrolling:!0,scrollDirection:x.scrollOffset<E?"forward":"backward",scrollOffset:E,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&&cu(h._resetIsScrollingTimeoutId),h._resetIsScrollingTimeoutId=IT(h._resetIsScrolling,kT)},h._resetIsScrolling=function(){h._resetIsScrollingTimeoutId=null,h.setState({isScrolling:!1},function(){h._getItemStyleCache(-1,null)})},h}g.getDerivedStateFromProps=function(h,v){return LT(h,v),d(h),null};var p=g.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 E=this._outerRef;S==="vertical"?x=E.scrollWidth>E.clientWidth?uu():0:x=E.scrollHeight>E.clientHeight?uu():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(du()){case"negative":x.scrollLeft=-S;break;case"positive-ascending":x.scrollLeft=S;break;default:var E=x.clientWidth,D=x.scrollWidth;x.scrollLeft=D-E-S;break}else x.scrollLeft=S;else x.scrollTop=S}this._callPropsCallbacks()},p.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&cu(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,E=h.innerTagName,D=h.itemCount,T=h.itemData,j=h.itemKey,F=j===void 0?DT:j,O=h.layout,N=h.outerElementType,B=h.outerTagName,P=h.style,U=h.useIsScrolling,ne=h.width,H=this.state.isScrolling,te=C==="horizontal"||O==="horizontal",he=te?this._onScrollHorizontal:this._onScrollVertical,oe=this._getRangeToRender(),ge=oe[0],ve=oe[1],xe=[];if(D>0)for(var ye=ge;ye<=ve;ye++)xe.push(m.createElement(v,{data:T,key:F(ye,T),index:ye,isScrolling:U?H:void 0,style:this._getItemStyle(ye)}));var R=n(this.props,this._instanceProps);return m.createElement(N||B||"div",{className:y,onScroll:he,ref:this._outerRefSetter,style:Ya({position:"relative",height:S,width:ne,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:C},P)},m.createElement(x||E||"div",{children:xe,ref:_,style:{height:te?"100%":R,pointerEvents:H?"none":void 0,width:te?R:"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,E=x.scrollDirection,D=x.scrollOffset,T=x.scrollUpdateWasRequested;this._callOnScroll(E,D,T)}},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 E=o(this.props,x,this._instanceProps),D=a(this.props,E,x,this._instanceProps),T=!S||_==="backward"?Math.max(1,y):1,j=!S||_==="forward"?Math.max(1,y):1;return[Math.max(0,E-T),Math.max(0,Math.min(v-1,D+j)),E,D]},g})(m.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var LT=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)&&Oi&&!Oi.has(d)&&(Oi.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":Li&&!Li.has(d)&&(Li.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.'))}},OT=50,Rn=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]},NT=function(t,r,n){var s=r.itemMetadataMap,i=r.lastMeasuredIndex,o=i>0?s[i].offset:0;return o>=n?Yh(t,r,i,0,n):jT(t,r,Math.max(0,i),n)},Yh=function(t,r,n,s,i){for(;s<=n;){var o=s+Math.floor((n-s)/2),a=Rn(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},jT=function(t,r,n,s){for(var i=t.itemCount,o=1;n<i&&Rn(t,n,r).offset<s;)n+=o,o*=2;return Yh(t,r,Math.min(n,i-1),Math.floor(n/2),s)},fu=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},PT=Kh({getItemOffset:function(t,r,n){return Rn(t,r,n).offset},getItemSize:function(t,r,n){return n.itemMetadataMap[r].size},getEstimatedTotalSize:fu,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",g=f?d:c,p=Rn(t,r,i),b=fu(t,i),h=Math.max(0,Math.min(b-g,p.offset)),v=Math.max(0,p.offset-g+p.size+o);switch(n==="smart"&&(s>=v-g&&s<=h+g?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 NT(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,g=Rn(t,r,s),p=n+f,b=g.offset+g.size,h=r;h<a-1&&b<p;)h++,b+=Rn(t,h,s).size;return h},initInstanceProps:function(t,r){var n=t,s=n.estimatedItemSize,i={itemMetadataMap:{},estimatedItemSize:s||OT,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.'))}}),RT=Kh({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,g=t.width,p=a==="horizontal"||f==="horizontal",b=p?g: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,g=d?u:i,p=Math.ceil((g+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 FT(){var e,t;const r=Bt(),s=X0().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 MT=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 BT=m.forwardRef(function(t,r){const{children:n}=t,s=MT(t,["children"]),i=Bt();return l.jsxs("div",Object.assign({ref:r},s,{onClick:o=>{o.currentTarget===o.target&&i.deselectAll()},children:[l.jsx(qT,{}),n]}))}),qT=()=>{const e=Bt();return l.jsx("div",{style:{height:e.rowTopPosition(e.visibleNodes.length),width:"100%",position:"absolute",left:"0",right:"0"},children:l.jsx(FT,{})})};var $T=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 UT=m.forwardRef(function(t,r){var n,s,i,o,{style:a}=t,c=$T(t,["style"]);const u=Bt(),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 Zh=m.createContext({dragDropManager:void 0}),Jt;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(Jt||(Jt={}));function Ee(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 Rl="dnd-core/INIT_COORDS",Ao="dnd-core/BEGIN_DRAG",Fl="dnd-core/PUBLISH_DRAG_SOURCE",Io="dnd-core/HOVER",ko="dnd-core/DROP",Do="dnd-core/END_DRAG";function hu(e,t){return{type:Rl,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function Ni(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ni=function(r){return typeof r}:Ni=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ni(e)}function zT(e,t,r){return t.split(".").reduce(function(n,s){return n&&n[s]?n[s]:r||null},e)}function VT(e,t){return e.filter(function(r){return r!==t})}function Xh(e){return Ni(e)==="object"}function HT(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 QT(e,t){return e.filter(function(r){return t.indexOf(r)>-1})}var WT={type:Rl,payload:{clientOffset:null,sourceClientOffset:null}};function GT(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(hu(o)),KT(r,c,u);var d=XT(r,c);if(d===null){e.dispatch(WT);return}var f=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");YT(a),f=a(d)}e.dispatch(hu(o,f));var g=u.getSource(d),p=g.beginDrag(c,d);if(p!=null){ZT(p),u.pinSource(d);var b=u.getSourceType(d);return{type:Ao,payload:{itemType:b,item:p,sourceId:d,clientOffset:o||null,sourceClientOffset:f||null,isSourcePublic:!!i}}}}}function KT(e,t,r){Ee(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(n){Ee(r.getSource(n),"Expected sourceIds to be registered.")})}function YT(e){Ee(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function ZT(e){Ee(Xh(e),"Item must be an object.")}function XT(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 JT(e){return function(){var r=e.getMonitor();if(r.isDragging())return{type:Fl}}}function Xa(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(r){return r===t}):e===t}function eE(e){return function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=n.clientOffset;tE(r);var i=r.slice(0),o=e.getMonitor(),a=e.getRegistry();rE(i,o,a);var c=o.getItemType();return nE(i,a,c),sE(i,o,a),{type:Io,payload:{targetIds:i,clientOffset:s||null}}}}function tE(e){Ee(Array.isArray(e),"Expected targetIds to be an array.")}function rE(e,t,r){Ee(t.isDragging(),"Cannot call hover while not dragging."),Ee(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n<e.length;n++){var s=e[n];Ee(e.lastIndexOf(s)===n,"Expected targetIds to be unique in the passed array.");var i=r.getTarget(s);Ee(i,"Expected targetIds to be registered.")}}function nE(e,t,r){for(var n=e.length-1;n>=0;n--){var s=e[n],i=t.getTargetType(s);Xa(i,r)||e.splice(n,1)}}function sE(e,t,r){e.forEach(function(n){var s=r.getTarget(n);s.hover(t,n)})}function pu(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 mu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pu(Object(r),!0).forEach(function(n){iE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return 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}function oE(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),s=e.getRegistry();aE(n);var i=uE(n);i.forEach(function(o,a){var c=lE(o,a,s,n),u={type:ko,payload:{dropResult:mu(mu({},r),c)}};e.dispatch(u)})}}function aE(e){Ee(e.isDragging(),"Cannot call drop while not dragging."),Ee(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function lE(e,t,r,n){var s=r.getTarget(e),i=s?s.drop(n,e):void 0;return cE(i),typeof i>"u"&&(i=t===0?{}:n.getDropResult()),i}function cE(e){Ee(typeof e>"u"||Xh(e),"Drop result must either be an object or undefined.")}function uE(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function dE(e){return function(){var r=e.getMonitor(),n=e.getRegistry();fE(r);var s=r.getSourceId();if(s!=null){var i=n.getSource(s,!0);i.endDrag(r,s),n.unpinSource()}return{type:Do}}}function fE(e){Ee(e.isDragging(),"Cannot call endDrag while not dragging.")}function hE(e){return{beginDrag:GT(e),publishDragSource:JT(e),hover:eE(e),drop:oE(e),endDrag:dE(e)}}function pE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mE(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 gE(e,t,r){return t&&mE(e.prototype,t),e}function ps(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var vE=(function(){function e(t,r){var n=this;pE(this,e),ps(this,"store",void 0),ps(this,"monitor",void 0),ps(this,"backend",void 0),ps(this,"isSetUp",!1),ps(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 gE(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=hE(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 Wt(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 gu=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),vu=function(){return Math.random().toString(36).substring(7).split("").join(".")},yu={INIT:"@@redux/INIT"+vu(),REPLACE:"@@redux/REPLACE"+vu()};function yE(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 bE(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(_E(e))return"date";if(SE(e))return"error";var r=CE(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 CE(e){return typeof e.constructor=="function"?e.constructor.name:null}function SE(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function _E(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function An(e){var t=typeof e;return process.env.NODE_ENV!=="production"&&(t=bE(e)),t}function Jh(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"?Wt(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"?Wt(1):"Expected the enhancer to be a function. Instead, received: '"+An(r)+"'");return r(Jh)(e,t)}if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?Wt(2):"Expected the root reducer to be a function. Instead, received: '"+An(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"?Wt(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"?Wt(4):"Expected the listener to be a function. Instead, received: '"+An(h)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?Wt(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"?Wt(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 g(h){if(!yE(h))throw new Error(process.env.NODE_ENV==="production"?Wt(7):"Actions must be plain objects. Instead, the actual type was: '"+An(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"?Wt(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"?Wt(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"?Wt(10):"Expected the nextReducer to be a function. Instead, received: '"+An(h));s=h,g({type:yu.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"?Wt(11):"Expected the observer to be an object. Instead, received: '"+An(C)+"'");function S(){C.next&&C.next(d())}S();var _=v(S);return{unsubscribe:_}}},h[gu]=function(){return this},h}return g({type:yu.INIT}),n={dispatch:g,subscribe:f,getState:d,replaceReducer:p},n[gu]=b,n}var wE=function(t,r){return t===r};function xE(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function TE(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wE;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 bu(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 Cu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bu(Object(r),!0).forEach(function(n){EE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function EE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Su={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function AE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Su,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Rl:case Ao:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case Io:return xE(e.clientOffset,r.clientOffset)?e:Cu(Cu({},e),{},{clientOffset:r.clientOffset});case Do:case ko:return Su;default:return e}}var Ml="dnd-core/ADD_SOURCE",Bl="dnd-core/ADD_TARGET",ql="dnd-core/REMOVE_SOURCE",Lo="dnd-core/REMOVE_TARGET";function IE(e){return{type:Ml,payload:{sourceId:e}}}function kE(e){return{type:Bl,payload:{targetId:e}}}function DE(e){return{type:ql,payload:{sourceId:e}}}function LE(e){return{type:Lo,payload:{targetId:e}}}function _u(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 Gt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_u(Object(r),!0).forEach(function(n){OE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_u(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function OE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var NE={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function jE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:NE,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Ao:return Gt(Gt({},e),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case Fl:return Gt(Gt({},e),{},{isSourcePublic:!0});case Io:return Gt(Gt({},e),{},{targetIds:r.targetIds});case Lo:return e.targetIds.indexOf(r.targetId)===-1?e:Gt(Gt({},e),{},{targetIds:VT(e.targetIds,r.targetId)});case ko:return Gt(Gt({},e),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case Do:return Gt(Gt({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function PE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case Ml:case Bl:return e+1;case ql:case Lo:return e-1;default:return e}}var eo=[],$l=[];eo.__IS_NONE__=!0;$l.__IS_ALL__=!0;function RE(e,t){if(e===eo)return!1;if(e===$l||typeof t>"u")return!0;var r=QT(t,e);return r.length>0}function FE(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case Io:break;case Ml:case Bl:case Lo:case ql:return eo;case Ao:case Fl:case Do:case ko:default:return $l}var t=e.payload,r=t.targetIds,n=r===void 0?[]:r,s=t.prevTargetIds,i=s===void 0?[]:s,o=HT(n,i),a=o.length>0||!TE(n,i);if(!a)return eo;var c=i[i.length-1],u=n[n.length-1];return c!==u&&(c&&o.push(c),u&&o.push(u)),o}function ME(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e+1}function wu(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 xu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wu(Object(r),!0).forEach(function(n){BE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function BE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:FE(e.dirtyHandlerIds,{type:t.type,payload:xu(xu({},t.payload),{},{prevTargetIds:zT(e,"dragOperation.targetIds",[])})}),dragOffset:AE(e.dragOffset,t),refCount:PE(e.refCount,t),dragOperation:jE(e.dragOperation,t),stateId:ME(e.stateId)}}function $E(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ep(e,t){return{x:e.x-t.x,y:e.y-t.y}}function UE(e){var t=e.clientOffset,r=e.initialClientOffset,n=e.initialSourceClientOffset;return!t||!r||!n?null:ep($E(t,n),r)}function zE(e){var t=e.clientOffset,r=e.initialClientOffset;return!t||!r?null:ep(t,r)}function VE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HE(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 QE(e,t,r){return t&&HE(e.prototype,t),e}function Tu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var WE=(function(){function e(t,r){VE(this,e),Tu(this,"store",void 0),Tu(this,"registry",void 0),this.store=t,this.registry=r}return QE(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;Ee(typeof r=="function","listener must be a function."),Ee(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&&!RE(u.dirtyHandlerIds,i);f||r()}finally{o=d}};return this.store.subscribe(a)}},{key:"subscribeToOffsetChange",value:function(r){var n=this;Ee(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 Ee(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(Ee(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 Xa(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(Ee(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&&!Xa(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 UE(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){return zE(this.store.getState().dragOffset)}}]),e})(),GE=0;function KE(){return GE++}function ji(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ji=function(r){return typeof r}:ji=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ji(e)}function YE(e){Ee(typeof e.canDrag=="function","Expected canDrag to be a function."),Ee(typeof e.beginDrag=="function","Expected beginDrag to be a function."),Ee(typeof e.endDrag=="function","Expected endDrag to be a function.")}function ZE(e){Ee(typeof e.canDrop=="function","Expected canDrop to be a function."),Ee(typeof e.hover=="function","Expected hover to be a function."),Ee(typeof e.drop=="function","Expected beginDrag to be a function.")}function Ja(e,t){if(t&&Array.isArray(e)){e.forEach(function(r){return Ja(r,!1)});return}Ee(typeof e=="string"||ji(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 Eu=typeof global<"u"?global:self,tp=Eu.MutationObserver||Eu.WebKitMutationObserver;function rp(e){return function(){const r=setTimeout(s,0),n=setInterval(s,50);function s(){clearTimeout(r),clearInterval(n),e()}}}function XE(e){let t=1;const r=new tp(e),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){t=-t,n.data=t}}const JE=typeof tp=="function"?XE:rp;class eA{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=JE(this.flush),this.requestErrorThrow=rp(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}}class tA{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 rA{create(t){const r=this.freeTasks,n=r.length?r.pop():new tA(this.onError,s=>r[r.length]=s);return n.task=t,n}constructor(t){this.onError=t,this.freeTasks=[]}}const np=new eA,nA=new rA(np.registerPendingError);function sA(e){np.enqueueTask(nA.create(e))}function iA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oA(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 aA(e,t,r){return t&&oA(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 lA(e,t){return fA(e)||dA(e,t)||uA(e,t)||cA()}function cA(){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&&Ii.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&&(I.isFunction(s)?r.paramsSerializer={serialize:s}:Ii.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),Ii.assertOptions(r,{baseUrl:St.spelling("baseURL"),withXsrfToken:St.spelling("withXSRFToken")},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o=i&&I.merge(i.common,i[r.method]);i&&I.forEach(["delete","get","head","post","put","patch","query","common"],b=>{delete i[b]}),r.headers=It.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||Ll;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,g;if(!c){const b=[Xc.bind(this),void 0];for(b.unshift(...a),b.push(...u),g=b.length,d=Promise.resolve(r);f<g;)d=d.then(b[f++],b[f++]);return d}g=a.length;let p=r;for(;f<g;){const b=a[f++],h=a[f++];try{p=b(p)}catch(v){h.call(this,v);break}}try{d=Xc.call(this,p)}catch(b){return Promise.reject(b)}for(f=0,g=u.length;f<g;)d=d.then(u[f++],u[f++]);return d}getUri(t){t=gn(this.defaults,t);const r=ah(t.baseURL,t.url,t.allowAbsoluteUrls,t);return rh(r,t.params,t.paramsSerializer)}};I.forEach(["delete","get","head","options"],function(t){hn.prototype[t]=function(r,n){return this.request(gn(n||{},{method:t,url:r,data:n&&I.hasOwnProp(n,"data")?n.data:void 0}))}});I.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 Wx=class dh{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 ri(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 dh(function(s){t=s}),cancel:t}}};function Gx(e){return function(r){return e.apply(null,r)}}function Kx(e){return I.isObject(e)&&e.isAxiosError===!0}const Va={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(Va).forEach(([e,t])=>{Va[t]=e});function fh(e){const t=new hn(e),r=Uf(hn.prototype.request,t);return I.extend(r,hn.prototype,t,{allOwnKeys:!0}),I.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return fh(gn(e,s))},r}const rt=fh(ti);rt.Axios=hn;rt.CanceledError=ri;rt.CancelToken=Wx;rt.isCancel=ih;rt.VERSION=Nl;rt.toFormData=wo;rt.AxiosError=J;rt.Cancel=rt.CanceledError;rt.all=function(t){return Promise.all(t)};rt.spread=Gx;rt.isAxiosError=Kx;rt.mergeConfig=gn;rt.AxiosHeaders=It;rt.formToJSON=e=>sh(I.isHTMLForm(e)?new FormData(e):e);rt.getAdapter=uh.getAdapter;rt.HttpStatusCode=Va;rt.default=rt;const{Axios:Nq,AxiosError:jq,CanceledError:Pq,isCancel:Rq,CancelToken:Fq,VERSION:Mq,all:Bq,Cancel:qq,isAxiosError:$q,spread:Uq,toFormData:zq,AxiosHeaders:Vq,HttpStatusCode:Hq,formToJSON:Qq,getAdapter:Wq,mergeConfig:Gq,create:Kq}=rt;let Ha="";function hh(e){Ha=e}const Re=rt.create({timeout:3e4});Re.interceptors.request.use(async e=>{var s;const{useEditorStore:t}=await Promise.resolve().then(()=>ab),n=(s=t.getState().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),Ha&&(e.baseURL=Ha),e});const ph="/portal";async function mh(e){var n,s,i,o,a,c,u;const t=await Re.get(`${ph}/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 Yx(e){var r,n;return e.length?((n=(r=(await Re.post(`${ph}/question/v2/list`,{request:{search:{identifier:e}}})).data)==null?void 0:r.result)==null?void 0:n.questions)??[]:[]}function To(e,t){const r=e??{},n=r.identifier??"",s=r.objectType??"",i=r.mimeType??"",o=r.children,a=Array.isArray(o)?o.map(u=>To(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 gh(e){var s,i,o,a,c,u,d;const t=await Re.get(`/action/content/v3/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=To(r);return{content:r,rootNode:n}}async function Zx(e){const t=await mh(e),r=To(t);return{content:t,rootNode:r}}async function Xx(e,t,r,n){var i;return((i=(await Re.patch("/action/content/v3/hierarchy/update",{request:{data:{nodesModified:t,hierarchy:r,...n?{lastUpdatedBy:n}:{}}}})).data)==null?void 0:i.result)??{}}async function Jx(e,t=""){await Re.post(`/action/content/v3/publish/${e}`,{request:{content:{lastPublishedBy:t}}})}async function vh(e){var n,s,i,o,a,c,u;const t=await Re.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 e1(e){var r,n;return(n=(r=(await Re.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}async function t1(e){await Re.post(`/action/content/v3/review/${e}`,{request:{content:{}}})}async function r1(e,t){await Re.post(`/action/content/v3/reject/${e}`,{request:{content:{rejectComment:t}}})}async function n1(e,t){await Re.patch(`/action/content/v1/collaborator/update/${e}`,{request:{content:{collaborators:t}}})}const s1="application/vnd.sunbird.questionset";function yh(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===s1||(r=!1)}}return n(e.children??[]),t&&r}const eu=new Map;async function bh(e){const t=eu.get(e);if(t)return t;const r=await vh(e),{children:n,...s}=r??{},i={qualifies:yh(r),meta:s};return eu.set(e,i),i}async function Ch(e){return(await bh(e)).qualifies}async function i1(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=yh(c);else if(o.length===1&&(s===0||s===t.length-1))try{u=await Ch(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 o1(e,t,r){return r?e===0?"pre":e===t-1?"post":"levelAssessment":"content"}function a1(e,t){const r=e.findIndex(s=>s.id===t);return r===-1?null:Zi(e,r)?{role:r===0?"pre":"post",levelNumber:null}:{role:"level",levelNumber:e.slice(0,r+1).filter((s,i)=>!Zi(e,i)).length}}function Fs(e,t){return t==="pre"?e.length>0&<(e[0]):e.length>1&<(e[e.length-1])}function Zi(e,t){const r=o1(t,e.length,lt(e[t]));return r==="pre"||r==="post"}function Qa(e,t){const r=t?e.findIndex(n=>n.id===t.id):-1;return r!==-1&&Zi(e,r)}function l1(e){return Fs(e,"pre")?Fs(e,"post")?null:"post":"pre"}function c1(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 tu(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 Xi(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}function Sh(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 _h(e,t){return!!Sh(e,t)}function u1(e,t){if(!e||!t)return[];const r=new Set,n=e.children??[];return n.forEach((s,i)=>{var o,a;Zi(n,i)?Xi((o=s.children[0].metadata)==null?void 0:o[t]).forEach(c=>r.add(c)):Xi((a=s.metadata)==null?void 0:a[t]).forEach(c=>r.add(c))}),Array.from(r)}const wh=new Set(["Diagnostic","PriorLearning"]);function d1(e,t,r){var p,b,h;const n=[];if(!e)return n;const s=(p=e.metadata)==null?void 0:p.policy;s||n.push({code:"policyMissing",message:"Set a consumption policy for this path."});const i=e.children??[],o=i[0],a=i.length>1?i[i.length-1]:void 0,c=lt(o),u=lt(a);!c&&s&&wh.has(s)&&n.push({code:"priorAssessmentRequired",message:"A Prior Assessment is required for the Adaptive/Prior learning policy."}),u||n.push({code:"outcomeAssessmentMissing",message:"Add an Outcome Assessment to close the path."}),[[o,"Prior Assessment"],[a,"Outcome Assessment"]].forEach(([v,y])=>{var S,_;if(!v)return;const C=v.children??[];(C.length!==1||!((_=(S=C[0])==null?void 0:S.metadata)!=null&&_.isAssessmentCourse))&&n.push({code:"slotNotPure",nodeId:v.id,message:`${y} must contain exactly one question-set-only course.`})});const d=new Set,f=(v,y)=>{d.has(v)&&n.push({code:"duplicateCourse",nodeId:y,message:"A course appears more than once in this path."}),d.add(v)},g=i.slice(c?1:0,i.length-(u?1:0));c&&f(o.children[0].id,o.id),u&&f(a.children[0].id,a.id);for(const v of g){const y=v.children??[];if(y.length===0){n.push({code:"emptyLevel",nodeId:v.id,message:`"${v.name}" has no courses yet.`});continue}const C=t?Xi((b=v.metadata)==null?void 0:b[t]):[];if(C.length===0)n.push({code:"levelMissingSkills",nodeId:v.id,message:`"${v.name}" needs at least one skill selected.`});else if(r.length>0){const S=C.filter(_=>!r.includes(_));S.length>0&&n.push({code:"levelSkillsOutOfScope",nodeId:v.id,message:`"${v.name}" has skills outside the current scope: ${S.join(", ")}.`})}for(const S of y)f(S.id,v.id),(t?Xi((h=S.metadata)==null?void 0:h[t]):[]).length===0&&n.push({code:"courseMissingSkillTag",nodeId:S.id,message:`"${S.name}" has no skill tag.`})}return n}async function f1(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 Ch(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 Pt(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 xh(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=xh(s.children,t,r+1);if(i>=0)return i}}return-1}const ru=new Set(["name","appIcon","description","keywords","trackable","qrCodeProcessId","reservedDialcodes"]);function Th(e,t,r,n){return e.map(s=>{if(s.id===t){const i=r.metadata??{},o=n!=null&&n.length?new Set([...ru,...n]):ru,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:Th(s.children,t,r,n)}:s})}function ki(e,t,r){return e.map(n=>n.id===t?{...n,children:[...n.children??[],r]}:n.children&&n.children.length>0?{...n,children:ki(n.children,t,r)}:n)}function Eh(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:Eh(s.children,t,r,n)}:s})}function Wa(e,t){return e.filter(r=>r.id!==t).map(r=>({...r,children:r.children?Wa(r.children,t):[]}))}function Ga(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:Ga(s.children,t,r,n)}:s})}function Ah(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?Ah(r.children,t):[]}})}function h1(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 p1(e,t){const r=Pt(e,t);if(!r)return[];const n=[];let s=r;for(;s;)n.unshift({id:s.id,name:s.name}),s=s.parent?Pt(e,s.parent):void 0;return n}const ue=Xs((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=Pt(n,r),a=i(r),c={...(o==null?void 0:o.metadata)??{},...s[r]??{}};Z.getState().setNodeFlags({isFolder:(o==null?void 0:o.isFolder)??!1,isRoot:!(o!=null&&o.parent),isQuml:!1}),Hr.getState().setActiveAssessmentSlot(null),e({selectedNodeId:r,breadcrumb:a,activeNodeMeta:c})},updateNode:(r,n,s)=>{if(e(i=>({treeData:Th(i.treeData,r,n,s),treeCache:{...i.treeCache,[r]:{...i.treeCache[r]??{},...n}}})),t().selectedNodeId===r){const i=Pt(t().treeData,r);e(o=>({activeNodeMeta:{...(i==null?void 0:i.metadata)??{},...o.treeCache[r]??{}}}))}t().markDirty()},addNode:(r,n)=>{var g,p,b;const s=t(),i=Z.getState().editorProfile,o=((p=(g=Z.getState().editorConfig)==null?void 0:g.config)==null?void 0:p.maxDepth)??i.maxDepth,a=xh(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=Pt(s.treeData,r))==null?void 0:b.children)??[],f=i.derivedRoles&&Fs(d,"post");return e(h=>({treeData:f?Eh(h.treeData,r,u,d.length-1):ki(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:Wa(i.treeData,r),selectedNodeId:i.selectedNodeId===r?null:i.selectedNodeId}))},reorderChildren:(r,n,s)=>{var a;const i=Z.getState().editorProfile,o=(a=t().treeData[0])==null?void 0:a.id;if(i.derivedRoles&&r===o){const c=Pt(t().treeData,r);if(c!=null&&c.children&&!c1(c.children,n,s))return}e(c=>({treeData:Ga(c.treeData,r,n,s)}))},moveNode:(r,n,s)=>{var u,d,f;const i=Z.getState().editorProfile,o=Pt(t().treeData,r),a=Pt(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 g=!!((d=o.metadata)!=null&&d.isAssessmentCourse),p=((f=t().treeData[0])==null?void 0:f.children)??[];if(!tu(a,g,Qa(p,a)))return}e(g=>{const p=Pt(g.treeData,r);if(!p)return g;let b=Wa(g.treeData,r);return b=ki(b,s,{...p,parent:s}),{treeData:b}}),t().markDirty()}},addResource:(r,n,s)=>{var b,h,v,y,C,S;const i=Z.getState().editorConfig,o=Z.getState().editorProfile,a=(b=t().treeData[0])==null?void 0:b.id,c=!!(s!=null&&s.isAssessmentCourse);if(o.derivedRoles&&n===a){if(!c||Pt(t().treeData,r.identifier))return!1;const _=t().treeData[0],x=(_==null?void 0:_.children)??[],E=(s==null?void 0:s.slot)??l1(x);if(!E||Fs(x,E))return!1;const D=t().addNode(a,"unit");if(!D)return!1;const{learningPath:T}=Al.getState().labelConfig;if(t().updateNode(D,{name:E==="pre"?T.priorAssessmentLabel:T.outcomeAssessmentLabel}),E==="pre"){const j=(((v=(h=t().treeData[0])==null?void 0:h.children)==null?void 0:v.length)??1)-1;e(F=>({treeData:Ga(F.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||Pt(t().treeData,r.identifier))return!1;const d=Pt(t().treeData,n);if(!(d!=null&&d.isFolder))return!1;if(o.derivedRoles){const _=((C=t().treeData[0])==null?void 0:C.children)??[];if(!tu(d,c,Qa(_,d)))return!1}const f=((S=i==null?void 0:i.config)==null?void 0:S.maxContentsLimit)??1200;if(h1(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:ki(_.treeData,n,p)})),t().markDirty(),!0},markDirty:()=>{const{editorMode:r,setIsDirty:n}=Z.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,g=!f||(Array.isArray(f)?f.includes(r):f===r);return g||n++,g});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},replaceNodeIds:r=>{!r||Object.keys(r).length===0||e(n=>{const s=Ah(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=>Pt(t().treeData,r),getChildrenOf:r=>{const n=Pt(t().treeData,r);return(n==null?void 0:n.children)??[]},getBreadcrumb:r=>p1(t().treeData,r)})),m1="_spin_1ah4d_9",g1={spin:m1};function ae(){return Al(e=>e.labelConfig)}const v1=({size:e=16,color:t="currentColor"})=>{const r=ae();return l.jsx("svg",{className:g1.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"})})},qe=({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(v1,{size:14}):null,i]}),Ih=({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 nu(e){var r,n;return(n=(r=(await Re.get(`/action/framework/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.framework}async function y1(e){var r,n;return((n=(r=(await Re.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 Eo(e,t){const r=Zn({queryKey:["framework",e],queryFn:()=>nu(e),enabled:!!e,staleTime:3e5}),n=t==null?void 0:t[0],s=Zn({queryKey:["framework",n],queryFn:()=>nu(n),enabled:!!n,staleTime:300*1e3}),i=s.data?[s.data]:[];return{organisationFramework:r.data,targetFrameworks:i,isLoading:r.isLoading||s.isLoading}}function kh(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 b1(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 as(){var i;const e=Z(o=>o.editorConfig),t=Z(o=>o.contentFramework),r=ue(o=>o.treeData),n=b1(r[0])??t??((i=e==null?void 0:e.context)==null?void 0:i.framework),{organisationFramework:s}=Eo(n);return kh(s==null?void 0:s.categories)}function C1(e,t,r){var u,d,f,g;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])??((g=i.metadata)==null?void 0:g[t.code]);return{scope:Array.isArray(a)?a:a?[a]:[],source:"prior"}}function Dh(){const e=as(),t=ue(n=>n.treeData),r=ue(n=>n.treeCache);return m.useMemo(()=>C1(t[0],e,r),[t,e,r])}const S1="_overlay_kdzmi_1",_1="_modal_kdzmi_15",w1="_modalHeader_kdzmi_27",x1="_modalHeaderClose_kdzmi_37",T1="_modalBody_kdzmi_55",E1="_modalFooter_kdzmi_62",A1="_checkRow_kdzmi_69",I1="_formGroup_kdzmi_112",k1="_textarea_kdzmi_123",D1="_sliderGroup_kdzmi_144",L1="_sliderValue_kdzmi_156",O1="_sliderLabels_kdzmi_164",N1="_sectionTitle_kdzmi_172",Ne={overlay:S1,modal:_1,modalHeader:w1,modalHeaderClose:x1,modalBody:T1,modalFooter:E1,checkRow:A1,formGroup:I1,textarea:k1,sliderGroup:D1,sliderValue:L1,sliderLabels:O1,sectionTitle:N1},j1=({objectType:e,onConfirm:t,onCancel:r})=>{const n=ae(),s=ue(p=>p.treeData[0]),i=as(),{scope:o}=Dh(),[a,c]=m.useState(null),u=d1(s,i==null?void 0:i.code,o);m.useEffect(()=>{let p=!1;return c(null),f1(s).then(b=>{p||c(b)}),()=>{p=!0}},[s]);const d=a===null,f=[...u,...a??[]],g=!d&&f.length===0;return l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",e]}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:f.length===0?l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:d?n.learningPath.verifyingAssessmentCourses:`${n.publishChecklist.confirmPublishPrefix} ${e}?`}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:Ne.sectionTitle,children:n.learningPath.resolveBeforePublishing}),l.jsx("ul",{style:{margin:0,paddingLeft:18,fontSize:13,lineHeight:1.6},children:f.map((p,b)=>l.jsx("li",{children:p.message},`${p.code}-${p.nodeId??b}`))})]})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(qe,{variant:"primary",onClick:t,disabled:!g,children:n.publishChecklist.yesButton})]})]})})},P1=({contentId:e,onConfirm:t,onCancel:r})=>{const n=ae(),s=Z(g=>{var p,b;return(b=(p=g.editorConfig)==null?void 0:p.config)==null?void 0:b.objectType})||"Content",i=Z(g=>g.editorProfile.key==="learningPath"),o=Z(g=>g.publishChecklist)??[],[a,c]=m.useState({}),u=o.every(g=>a[g.code]),d=o.length===0||u,f=()=>{t()};return i?l.jsx(j1,{objectType:s,onConfirm:t,onCancel:r}):l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"publish-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsxs("span",{id:"publish-modal-title",children:[n.publishChecklist.publishTitlePrefix," ",s]}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":n.publishChecklist.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.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:Ne.sectionTitle,children:n.publishChecklist.checklistInstructions}),o.map(g=>l.jsxs("label",{className:Ne.checkRow,children:[l.jsx("input",{type:"checkbox",checked:!!a[g.code],onChange:p=>c(b=>({...b,[g.code]:p.target.checked}))}),l.jsx("span",{children:g.label})]},g.code))]})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,children:n.publishChecklist.noButton}),l.jsx(qe,{variant:"primary",onClick:f,disabled:!d,children:n.publishChecklist.yesButton})]})]})})},R1=({contentId:e,action:t,onConfirm:r,onCancel:n})=>{const s=ae(),[i,o]=m.useState(""),[a,c]=m.useState(7),u=t==="approve",d=u?s.qualityParamsModal.reviewQualityTitle:s.qualityParamsModal.rejectContentTitle,f=!u&&i.trim().length===0,g=()=>{u?r(i.trim(),a):r(i.trim())};return l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"quality-modal-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsx("span",{id:"quality-modal-title",children:d}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:n,"aria-label":s.qualityParamsModal.closeAriaLabel,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:u?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ne.formGroup,children:[l.jsx("label",{htmlFor:"quality-score",children:s.qualityParamsModal.qualityScoreLabel}),l.jsxs("div",{className:Ne.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:Ne.sliderValue,children:a})]}),l.jsxs("div",{className:Ne.sliderLabels,children:[l.jsx("span",{children:s.qualityParamsModal.scorePoorLabel}),l.jsx("span",{children:s.qualityParamsModal.scoreExcellentLabel})]})]}),l.jsxs("div",{className:Ne.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:Ne.textarea,placeholder:s.qualityParamsModal.commentPlaceholder,value:i,onChange:p=>o(p.target.value),rows:4})]})]}):l.jsxs("div",{className:Ne.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:Ne.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:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:n,children:s.qualityParamsModal.cancelButton}),l.jsx(qe,{variant:u?"primary":"danger",onClick:g,disabled:f,children:u?s.qualityParamsModal.approveButton:s.qualityParamsModal.rejectButton})]})]})})},Lh=["email","firstName","lastName","identifier","organisations","rootOrgName","phone"];async function F1(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:Lh,offset:0,limit:t.limit??200};return s?n.email=e.trim():i?n.phone=e.trim():o.query=e,((f=(d=(u=(await Re.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 M1(e){var r,n,s;return e.length?((s=(n=(r=(await Re.post("/action/user/v1/search",{request:{filters:{userId:e},fields:Lh,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 B1(e){var r,n;return((n=(r=(await Re.get(`/portal/user/v5/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.response)??{}}const q1="_container_1hnn8_1",$1="_header_1hnn8_13",U1="_title_1hnn8_22",z1="_closeBtn_1hnn8_29",V1="_body_1hnn8_45",H1="_label_1hnn8_54",Q1="_searchSection_1hnn8_62",W1="_searchRow_1hnn8_68",G1="_searchInput_1hnn8_74",K1="_searchSpinner_1hnn8_89",Y1="_resultsList_1hnn8_105",Z1="_resultItem_1hnn8_118",X1="_userInfo_1hnn8_133",J1="_userName_1hnn8_141",e0="_userEmail_1hnn8_150",t0="_userOrg_1hnn8_158",r0="_noResults_1hnn8_167",n0="_collabSection_1hnn8_174",s0="_sectionTitle_1hnn8_179",i0="_badge_1hnn8_189",o0="_emptyCollab_1hnn8_203",a0="_collabList_1hnn8_214",l0="_collabItem_1hnn8_223",c0="_userAvatar_1hnn8_237",u0="_error_1hnn8_251",d0="_success_1hnn8_257",f0="_footer_1hnn8_263",Pe={container:q1,header:$1,title:U1,closeBtn:z1,body:V1,label:H1,searchSection:Q1,searchRow:W1,searchInput:G1,searchSpinner:K1,resultsList:Y1,resultItem:Z1,userInfo:X1,userName:J1,userEmail:e0,userOrg:t0,noResults:r0,collabSection:n0,sectionTitle:s0,badge:i0,emptyCollab:o0,collabList:a0,collabItem:l0,userAvatar:c0,error:u0,success:d0,footer:f0},h0=({contentId:e,onClose:t})=>{var j,F;const r=ae(),n=Z(O=>O.editorConfig),s=(j=n==null?void 0:n.context)==null?void 0:j.channel,i=(F=n==null?void 0:n.config)==null?void 0:F.objectType,[o,a]=m.useState(""),[c,u]=m.useState([]),[d,f]=m.useState(!1),[g,p]=m.useState([]),[b,h]=m.useState(!1),[v,y]=m.useState(""),[C,S]=m.useState(!1),_=m.useRef(null);m.useEffect(()=>{let O=!1;return(async()=>{try{const N=await e1(e),B=(N==null?void 0:N.collaborators)??[];if(!B.length)return;const P=await M1(B);if(O)return;const U=B.map(ne=>P.find(H=>H.identifier===ne)??{identifier:ne,firstName:ne});p(U)}catch{}})(),()=>{O=!0}},[e]),m.useEffect(()=>{_.current&&clearTimeout(_.current);const O=o.trim();if(O.length<2){u([]);return}return _.current=setTimeout(async()=>{f(!0);try{const N=await F1(O,{rootOrgId:s,objectType:i}),B=new Set(g.map(P=>P.identifier));u(N.filter(P=>!B.has(P.identifier)))}catch{u([])}finally{f(!1)}},300),()=>{_.current&&clearTimeout(_.current)}},[o,g,s,i]);const x=m.useCallback(O=>{p(N=>N.find(B=>B.identifier===O.identifier)?N:[...N,O]),u(N=>N.filter(B=>B.identifier!==O.identifier)),S(!1)},[]),E=m.useCallback(O=>{p(N=>N.filter(B=>B.identifier!==O)),S(!1)},[]),D=m.useCallback(async()=>{h(!0),y(""),S(!1);try{await n1(e,g.map(O=>O.identifier)),S(!0)}catch{y(r.manageCollaborators.saveFailed)}finally{h(!1)}},[e,g,r.manageCollaborators.saveFailed]),T=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(yr,{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,B,P,U;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:T(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((B=(N=O.organisations)==null?void 0:N[0])==null?void 0:B.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:((U=(P=O.organisations)==null?void 0:P[0])==null?void 0:U.orgName)??O.rootOrgName})]}),l.jsx(qe,{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,g.length>0&&l.jsx("span",{className:Pe.badge,children:g.length})]}),g.length===0?l.jsx("p",{className:Pe.emptyCollab,children:r.manageCollaborators.noCollaboratorsYet}):l.jsx("ul",{className:Pe.collabList,children:g.map(O=>{var N,B,P,U;return l.jsxs("li",{className:Pe.collabItem,children:[l.jsx("div",{className:Pe.userAvatar,"aria-hidden":"true",children:T(O).charAt(0).toUpperCase()}),l.jsxs("div",{className:Pe.userInfo,children:[l.jsx("span",{className:Pe.userName,children:T(O)}),O.email&&l.jsx("span",{className:Pe.userEmail,children:O.email}),(((B=(N=O.organisations)==null?void 0:N[0])==null?void 0:B.orgName)??O.rootOrgName)&&l.jsx("span",{className:Pe.userOrg,children:((U=(P=O.organisations)==null?void 0:P[0])==null?void 0:U.orgName)??O.rootOrgName})]}),l.jsx(qe,{variant:"danger",size:"sm",onClick:()=>E(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(qe,{variant:"ghost",onClick:t,disabled:b,children:r.manageCollaborators.cancel}),l.jsx(qe,{variant:"primary",isLoading:b,onClick:D,children:r.manageCollaborators.save})]})]})};async function p0(e){return(await Re.post("/api/dialcode/v1/read",{request:{dialcodes:[e]}})).data}async function m0(e,t){var s;const n=((s=(await Re.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 g0(e){var n;const r=((n=(await Re.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 v0="_topbar_c3y0z_1",y0="_left_c3y0z_15",b0="_right_c3y0z_23",C0="_backBtn_c3y0z_30",S0="_title_c3y0z_49",_0="_profileBadge_c3y0z_61",w0="_statusChip_c3y0z_76",x0="_savedIndicator_c3y0z_88",T0="_unsaved_c3y0z_98",E0="_iconBtn_c3y0z_103",A0="_iconBtnLabel_c3y0z_130",I0="_qrDropdown_c3y0z_134",k0="_qrMenu_c3y0z_138",D0="_reviewBtns_c3y0z_173",L0="_sourcingBtns_c3y0z_182",O0="_modalOverlay_c3y0z_191",N0="_sbOverlay_c3y0z_201",j0="_sbModal_c3y0z_211",P0="_sbModalHeader_c3y0z_222",R0="_sbModalTitle_c3y0z_230",F0="_sbModalClose_c3y0z_237",M0="_sbModalBody_c3y0z_250",B0="_sbLabel_c3y0z_257",q0="_sbTextarea_c3y0z_264",$0="_sbError_c3y0z_281",U0="_sbModalFooter_c3y0z_288",Se={topbar:v0,left:y0,right:b0,backBtn:C0,title:S0,profileBadge:_0,statusChip:w0,savedIndicator:x0,unsaved:T0,iconBtn:E0,iconBtnLabel:A0,qrDropdown:I0,qrMenu:k0,reviewBtns:D0,sourcingBtns:L0,modalOverlay:O0,sbOverlay:N0,sbModal:j0,sbModalHeader:P0,sbModalTitle:R0,sbModalClose:F0,sbModalBody:M0,sbLabel:B0,sbTextarea:q0,sbError:$0,sbModalFooter:U0};function z0(e){return e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):""}function V0(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}const H0=({titleText:e,labelText:t,placeholderText:r,submitLabel:n,submitVariant:s="primary",onConfirm:i,onCancel:o})=>{const a=ae(),[c,u]=m.useState(""),d=e.toLowerCase().replace(/\s+/g,"-");return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":`${d}-title`,children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:`${d}-title`,className:Se.sbModalTitle,children:e}),l.jsx("button",{className:Se.sbModalClose,onClick:o,"aria-label":a.reviewCommentModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:Se.sbModalBody,children:[l.jsxs("label",{className:Se.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:Se.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:Se.sbError,children:a.reviewCommentModal.fillCommentsError})]}),l.jsxs("div",{className:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:o,children:a.reviewCommentModal.cancelButton}),l.jsx(qe,{variant:s,onClick:()=>i(c.trim()),disabled:c.trim().length===0,children:n})]})]})})},Q0=({onConfirm:e,onCancel:t})=>{const r=ae(),[n,s]=m.useState(!1);return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"review-confirm-title",children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:"review-confirm-title",className:Se.sbModalTitle,children:r.confirmReviewModal.title}),l.jsx("button",{className:Se.sbModalClose,onClick:t,"aria-label":r.confirmReviewModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsx("div",{className:Se.sbModalBody,children: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:i=>s(i.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:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:t,children:r.confirmReviewModal.cancelButton}),l.jsx(qe,{variant:"primary",onClick:e,disabled:!n,children:r.confirmReviewModal.submitButton})]})]})})},W0=({onConfirm:e,onCancel:t})=>{const r=ae(),[n,s]=m.useState(""),i=parseInt(n,10),o=!isNaN(i)&&i>=2&&i<=250;return l.jsx("div",{className:Se.sbOverlay,role:"dialog","aria-modal":"true","aria-labelledby":"genqr-title",children:l.jsxs("div",{className:Se.sbModal,children:[l.jsxs("div",{className:Se.sbModalHeader,children:[l.jsx("span",{id:"genqr-title",className:Se.sbModalTitle,children:r.generateQRModal.title}),l.jsx("button",{className:Se.sbModalClose,onClick:t,"aria-label":r.generateQRModal.closeAriaLabel,type:"button",children:"×"})]}),l.jsxs("div",{className:Se.sbModalBody,children:[l.jsxs("label",{className:Se.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:Se.sbTextarea,style:{resize:"none",height:"40px"},placeholder:r.generateQRModal.countPlaceholder,value:n,onChange:a=>s(a.target.value)}),n&&!o&&l.jsx("p",{className:Se.sbError,children:r.generateQRModal.countRangeError})]}),l.jsxs("div",{className:Se.sbModalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:t,children:r.generateQRModal.cancelButton}),l.jsx(qe,{variant:"primary",onClick:()=>e(i),disabled:!o,children:r.generateQRModal.generateButton})]})]})})},G0=({editorMode:e,isSaving:t,isDirty:r,lastSaved:n,isFormValid:s=!0,onToolbarEvent:i})=>{var Ce,de;const o=ae(),c=ue(ce=>ce.treeData)[0],u=(c==null?void 0:c.name)??o.contextualEditor.untitledPlaceholder,d=V0(((Ce=c==null?void 0:c.metadata)==null?void 0:Ce.status)??(c==null?void 0:c.status),o.topbar.draftStatusFallback),f=Z(ce=>{var Q,se,Te,me;return((se=(Q=ce.editorConfig)==null?void 0:Q.context)==null?void 0:se.contentId)??((me=(Te=ce.editorConfig)==null?void 0:Te.context)==null?void 0:me.identifier)??""}),{activeModal:g,modalData:p,closeModal:b,openModal:h}=Hr(),v=Z(ce=>ce.buttonLoaders),y=Z(ce=>ce.categoryMeta),C=Z(ce=>ce.editorProfile),S=C.key==="learningPath",_=C.features.dialcodes&&(!y||y.schemaDefaults.generateDIALCodes!=="No"),[x,E]=m.useState(!1),[D,T]=m.useState(!1),[j,F]=m.useState(!1),O=m.useRef(null),[N,B]=m.useState(!1);m.useEffect(()=>{if(!j)return;const ce=Q=>{var se;(se=O.current)!=null&&se.contains(Q.target)||F(!1)};return document.addEventListener("mousedown",ce),()=>document.removeEventListener("mousedown",ce)},[j]);const[P,U]=m.useState(!1),[ne,H]=m.useState(!1),{updateNode:te}=ue(),he=(de=c==null?void 0:c.metadata)==null?void 0:de.qrCodeProcessId,oe=m.useCallback(async ce=>{if(f){B(!1),U(!0);try{const{processId:Q,reservedDialcodes:se}=await m0(f,ce);Q&&c&&te(c.id,{qrCodeProcessId:Q,reservedDialcodes:se}),we.success(o.topbar.qrGenerationStartedToast)}catch{we.error(o.topbar.qrGenerationFailedToast)}finally{U(!1)}}},[f,c,te,o]),ge=m.useCallback(async()=>{if(!he){we.error(o.topbar.qrCodesNotGeneratedToast);return}H(!0);try{const ce=await g0(he);if(ce.status==="in-process"){we(o.topbar.qrGenerationInProgressToast,{icon:l.jsx(Ps,{size:16})});return}const Q=ce.url;if(!Q){we.error(o.topbar.qrCodesNotReadyToast);return}const se=await fetch(Q).then(tt=>tt.blob()),Te=await new Promise(tt=>{const st=new FileReader;st.onloadend=()=>tt(st.result),st.readAsDataURL(se)}),me=(c==null?void 0:c.metadata)??{},ee=tt=>Array.isArray(tt)?tt.join("_"):typeof tt=="string"?tt:"",He=[f,ee(me.medium),ee(me.gradeLevel),ee(me.subject)].filter(Boolean),Ge=new Date().toISOString().replace(/[:.]/g,"-"),Ze=`${He.join("_")}_${Ge}.zip`,Qe=document.createElement("a");Qe.href=Te,Qe.download=Ze,Qe.style.display="none",document.body.appendChild(Qe),Qe.click(),document.body.removeChild(Qe),we.success(o.topbar.qrCodesDownloadedToast)}catch{we.error(o.topbar.qrCodesDownloadFailedToast)}finally{H(!1)}},[he,c,f,o]),ve=e==="edit",xe=e==="review",ye=e==="sourcingreview",R=e==="read",M=m.useCallback((ce,Q)=>{i({action:ce,data:Q})},[i]),Y=m.useCallback(()=>{b(),M("publish")},[b,M]),le=m.useCallback((ce,Q)=>{const se=p==null?void 0:p.action;b(),se==="approve"?M("sourcingApprove",{comment:ce,score:Q}):M("reject",{comment:ce})},[b,M,p]);return l.jsxs(l.Fragment,{children:[l.jsxs("header",{className:Se.topbar,role:"banner",children:[l.jsxs("div",{className:Se.left,children:[l.jsx("button",{className:Se.backBtn,onClick:()=>M("back"),"aria-label":o.topbar.backAriaLabel,type:"button",children:l.jsx(_l,{size:18})}),l.jsx("h1",{className:Se.title,title:u,children:u}),S&&l.jsxs("span",{className:Se.profileBadge,children:[l.jsx(Ih,{size:13,"aria-hidden":"true"}),o.learningPath.profileBadgeLabel]}),l.jsx("span",{className:`sbx-chip ${Se.statusChip}`,"aria-label":`${o.topbar.statusAriaLabelPrefix} ${d}`,children:d})]}),l.jsxs("div",{className:Se.right,children:[t?l.jsx("span",{className:Se.savedIndicator,"aria-live":"polite",children:o.topbar.savingIndicator}):r&&ve?l.jsx("span",{className:`${Se.savedIndicator} ${Se.unsaved}`,"aria-live":"polite",children:o.topbar.unsavedIndicator}):n?l.jsxs("span",{className:Se.savedIndicator,"aria-live":"polite",children:[l.jsx(yn,{size:14,"aria-hidden":"true"}),o.topbar.savedIndicatorPrefix," ",z0(n)]}):null,!R&&!xe&&!ye&&d!=="Review"&&l.jsx("span",{title:s?void 0:o.topbar.fillRequiredFieldsTooltip,children:l.jsx(qe,{variant:"ghost",size:"sm",onClick:()=>M("saveCollection"),disabled:!s,children:o.topbar.saveAsDraftButton})}),ve&&l.jsxs(l.Fragment,{children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>T(!0),disabled:v.saveCollection,isLoading:v.saveCollection,children:[l.jsx(Fy,{size:14,"aria-hidden":"true"})," ",o.topbar.sendForReviewButton]}),C.features.collaborators&&l.jsx("button",{className:Se.iconBtn,onClick:()=>h("manageCollaborators"),"aria-label":o.topbar.collaboratorsLabel,title:o.topbar.collaboratorsLabel,type:"button",children:l.jsx(Vy,{size:16,"aria-hidden":"true"})}),_&&l.jsxs("div",{className:Se.qrDropdown,ref:O,children:[l.jsxs("button",{className:Se.iconBtn,onClick:()=>F(ce=>!ce),"aria-label":o.topbar.qrCodesLabel,title:o.topbar.qrCodesLabel,type:"button","aria-haspopup":"true","aria-expanded":j,children:[l.jsx(Tc,{size:16,"aria-hidden":"true"}),l.jsx("span",{className:Se.iconBtnLabel,children:o.topbar.qrCodesLabel}),l.jsx(bn,{size:14,style:{marginLeft:2},"aria-hidden":"true"})]}),j&&l.jsxs("div",{className:Se.qrMenu,role:"menu",children:[l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{F(!1),B(!0)},disabled:P,children:[l.jsx(Tc,{size:14}),P?o.topbar.generatingEllipsis:o.topbar.generateQrCodesMenuItem]}),l.jsxs("button",{role:"menuitem",type:"button",onClick:()=>{F(!1),ge()},disabled:ne||!he,children:[l.jsx(wy,{size:14}),ne?o.topbar.downloadingEllipsis:o.topbar.downloadQrCodesMenuItem]})]})]})]}),xe&&l.jsxs("div",{className:Se.reviewBtns,children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("publishChecklist"),disabled:v.publishCollection,isLoading:v.publishCollection,children:[l.jsx(Nf,{size:14,"aria-hidden":"true"})," ",o.topbar.publishButton]}),l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>E(!0),disabled:v.rejectCollection,isLoading:v.rejectCollection,children:[l.jsx(Ec,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]}),ye&&l.jsxs("div",{className:Se.sourcingBtns,children:[l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"approve"}),children:[l.jsx(By,{size:14,"aria-hidden":"true"})," ",o.topbar.approveButton]}),l.jsxs(qe,{variant:"primary",size:"sm",onClick:()=>h("qualityParams",{action:"reject"}),children:[l.jsx(Ec,{size:14,"aria-hidden":"true"})," ",o.topbar.requestForChangesButton]})]})]})]}),g==="publishChecklist"&&l.jsx(P1,{contentId:f,onConfirm:Y,onCancel:b}),g==="qualityParams"&&l.jsx(R1,{contentId:f,action:(p==null?void 0:p.action)??"reject",onConfirm:le,onCancel:b}),g==="manageCollaborators"&&l.jsx("div",{className:Se.modalOverlay,role:"dialog","aria-modal":"true",children:l.jsx(h0,{contentId:f,onClose:b})}),D&&l.jsx(Q0,{onConfirm:()=>{T(!1),M("sendForReview")},onCancel:()=>T(!1)}),x&&l.jsx(H0,{titleText:o.topbar.requestChangesTitle,labelText:o.topbar.changesRequestedLabel,placeholderText:o.topbar.describeChangesPlaceholder,submitLabel:o.topbar.requestForChangesButton,submitVariant:"primary",onConfirm:ce=>{E(!1),M("reject",{comment:ce})},onCancel:()=>E(!1)}),N&&l.jsx(W0,{onConfirm:oe,onCancel:()=>B(!1)})]})},K0=({onSave:e,onDiscard:t,onCancel:r,isSaving:n})=>{const s=ae();return Ur.createPortal(l.jsx("div",{className:Ne.overlay,role:"dialog","aria-modal":"true","aria-labelledby":"unsaved-title",children:l.jsxs("div",{className:Ne.modal,children:[l.jsxs("div",{className:Ne.modalHeader,children:[l.jsx("span",{id:"unsaved-title",children:s.unsavedChangesModal.title}),l.jsx("button",{className:Ne.modalHeaderClose,onClick:r,"aria-label":s.unsavedChangesModal.closeAriaLabel,disabled:n,children:"×"})]}),l.jsx("div",{className:Ne.modalBody,children:l.jsx("p",{style:{margin:0,fontSize:14,lineHeight:1.5},children:s.unsavedChangesModal.bodyMessage})}),l.jsxs("div",{className:Ne.modalFooter,children:[l.jsx(qe,{variant:"ghost",onClick:r,disabled:n,children:s.unsavedChangesModal.cancelButton}),l.jsx(qe,{variant:"danger",onClick:t,disabled:n,children:s.unsavedChangesModal.discardButton}),l.jsx(qe,{variant:"primary",onClick:e,isLoading:n,disabled:n,children:s.unsavedChangesModal.saveButton})]})]})}),document.body)};var Y0=Tl();const Oh=m.createContext(null);function Bt(){const e=m.useContext(Oh);if(e===null)throw new Error("No Tree Api Provided");return e}const Nh=m.createContext(null);function Z0(){const e=m.useContext(Nh);if(e===null)throw new Error("Provide a NodesContext");return e}const jh=m.createContext(null);function X0(){const e=m.useContext(jh);if(e===null)throw new Error("Provide a DnDContext");return e}const Ph=m.createContext(0);function Rh(){m.useContext(Ph)}function Di(e,t,r){return Math.max(Math.min(e,r),t)}function Fh(e){return e&&e.isLeaf}function Mh(e){return e&&e.isInternal&&!e.isOpen}function Bh(e){var t;return e&&e.isOpen&&!(!((t=e.children)===null||t===void 0)&&t.length)}const qh=(e,t)=>{let r=e;for(;r;){if(r.id===t.id)return!0;r=r.parent}return!1},$h=e=>{if(!e.parent)throw Error("Node does not have a parent");return e.parent.children.findIndex(t=>t.id===e.id)};function Pl(e,t){if(!e)return null;if(e.id===t)return e;if(e.children)for(let r of e.children){const n=Pl(r,t);if(n)return n}return null}function Ji(e,t){if(t(e),e.children)for(let r of e.children)Ji(r,t)}function Uh(e){const t=Vh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=J0(t,n);break}r==null||r.focus()}function zh(e){const t=Vh(e);let r;for(let n=0;n<t.length;++n)if(t[n]===e){r=eT(t,n);break}r==null||r.focus()}function J0(e,t){return t+1<e.length?e[t+1]:e[0]}function eT(e,t){return t-1>=0?e[t-1]:e[e.length-1]}function Vh(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 _s(e,t){return typeof t=="boolean"?t:typeof t=="string"?e[t]:t(e)}function Pn(e){return typeof e=="string"?e:e.id}function tT(e,...t){if(e)return e(...t)}function Hh(e){return new Promise((t,r)=>{let n=0;function s(){n+=1,n===100&&r(),e()?t():setTimeout(s,10)}s()})}function Qh(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 Wh(e){const t=e.focusedNode;return t?t.isOpen?t.id:t.parent&&!t.parent.isRoot?t.parent.id:null:null}const rT=Object.freeze(Object.defineProperty({__proto__:null,access:_s,bound:Di,dfs:Pl,focusNextElement:Uh,focusPrevElement:zh,getInsertIndex:Qh,getInsertParentId:Wh,identify:Pn,indexOf:$h,isClosed:Mh,isDescendant:qh,isItem:Fh,isOpenWithEmptyChildren:Bh,safeRun:tT,waitFor:Hh,walk:Ji},Symbol.toStringTag,{value:"Module"})),nT={display:"flex",alignItems:"center",zIndex:1},sT={flex:1,height:"2px",background:"#4B91E2",borderRadius:"1px"},iT={width:"4px",height:"4px",boxShadow:"0 0 0 3px #4B91E2",borderRadius:"50%"},oT=m.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({},nT),s),children:[l.jsx("div",{style:Object.assign({},iT)}),l.jsx("div",{style:Object.assign({},sT)})]})});function aT({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 lT(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(uT,Object.assign({},e)):l.jsx(cT,Object.assign({},e))]})}function cT(e){return l.jsx(l.Fragment,{children:l.jsx("span",{children:e.node.data.name})})}function uT({node:e}){const t=m.useRef();return m.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 Ms="__REACT_ARBORIST_INTERNAL_ROOT__";function su(e){var t;function r(i,o,a){const c=e.accessId(i),u=new Bs({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 Bs({tree:e,id:Ms,data:{id:Ms},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 Bs{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===Ms}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 Bs(Object.assign({},this))}edit(){return this.tree.edit(this)}}function Go(e){return{type:"EDIT",id:e}}function dT(e={id:null},t){return t.type==="EDIT"?Object.assign(Object.assign({},e),{id:t.id}):e}function Tn(e){return{type:"FOCUS",id:e}}function fT(){return{type:"TREE_BLUR"}}function hT(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 Ka={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 iu(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 pT(e={filtered:{},unfiltered:{}},t){return t.type.startsWith("VISIBILITY")?t.filtered?Object.assign(Object.assign({},e),{filtered:iu(e.filtered,t)}):Object.assign(Object.assign({},e),{unfiltered:iu(e.unfiltered,t)}):e}const es=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:Pn(e)}),add:e=>({type:"SELECTION_ADD",ids:(Array.isArray(e)?e:[e]).map(Pn)}),remove:e=>({type:"SELECTION_REMOVE",ids:(Array.isArray(e)?e:[e]).map(Pn)}),set:e=>Object.assign({type:"SELECTION_SET"},e),mostRecent:e=>({type:"SELECTION_MOST_RECENT",id:e===null?null:Pn(e)}),anchor:e=>({type:"SELECTION_ANCHOR",id:e===null?null:Pn(e)})};function mT(e=es().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 ts={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 gT(e=es().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 es().dnd;case"DND_HOVERING":return Object.assign(Object.assign({},e),{parentId:t.parentId,index:t.index});default:return e}}const vT={position:"fixed",pointerEvents:"none",zIndex:100,left:0,top:0,width:"100%",height:"100%"},yT=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t}px, ${r}px)`}},bT=e=>{if(!e)return{display:"none"};const{x:t,y:r}=e;return{transform:`translate(${t+10}px, ${r+10}px)`}};function Gh({offset:e,mouse:t,id:r,dragIds:n,isDragging:s}){return l.jsxs(CT,{isDragging:s,children:[l.jsx(ST,{offset:e,children:l.jsx(wT,{id:r,dragIds:n})}),l.jsx(_T,{mouse:t,count:n.length})]})}const CT=m.memo(function(t){return t.isDragging?l.jsx("div",{style:vT,children:t.children}):null});function ST(e){return l.jsx("div",{className:"row preview",style:yT(e.offset),children:e.children})}function _T(e){const{count:t,mouse:r}=e;return t>1?l.jsx("div",{className:"selected-count",style:bT(r),children:t}):null}const wT=m.memo(function(t){const r=Bt(),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 Ya(){return Ya=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},Ya.apply(null,arguments)}function ou(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Za(e,t){return Za=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,n){return r.__proto__=n,r},Za(e,t)}function xT(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,Za(e,t)}var au=Number.isNaN||function(t){return typeof t=="number"&&t!==t};function TT(e,t){return!!(e===t||au(e)&&au(t))}function ET(e,t){if(e.length!==t.length)return!1;for(var r=0;r<e.length;r++)if(!TT(e[r],t[r]))return!1;return!0}function Ko(e,t){t===void 0&&(t=ET);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 AT=typeof performance=="object"&&typeof performance.now=="function",lu=AT?function(){return performance.now()}:function(){return Date.now()};function cu(e){cancelAnimationFrame(e.id)}function IT(e,t){var r=lu();function n(){lu()-r>=t?e.call(null):s.id=requestAnimationFrame(n)}var s={id:requestAnimationFrame(n)};return s}var Yo=-1;function uu(e){if(e===void 0&&(e=!1),Yo===-1||e){var t=document.createElement("div"),r=t.style;r.width="50px",r.height="50px",r.overflow="scroll",document.body.appendChild(t),Yo=t.offsetWidth-t.clientWidth,document.body.removeChild(t)}return Yo}var En=null;function du(e){if(e===void 0&&(e=!1),En===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?En="positive-descending":(t.scrollLeft=1,t.scrollLeft===0?En="negative":En="positive-ascending"),document.body.removeChild(t),En}return En}process.env.NODE_ENV;var kT=150,DT=function(t,r){return t},Li=null,Oi=null;process.env.NODE_ENV!=="production"&&typeof window<"u"&&typeof window.WeakSet<"u"&&(Li=new WeakSet,Oi=new WeakSet);function Kh(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){xT(g,f);function g(b){var h;return h=f.call(this,b)||this,h._instanceProps=c(h.props,ou(h)),h._outerRef=void 0,h._resetIsScrollingTimeoutId=null,h.state={instance:ou(h),isScrolling:!1,scrollDirection:"forward",scrollOffset:typeof h.props.initialScrollOffset=="number"?h.props.initialScrollOffset:0,scrollUpdateWasRequested:!1},h._callOnItemsRendered=void 0,h._callOnItemsRendered=Ko(function(v,y,C,S){return h.props.onItemsRendered({overscanStartIndex:v,overscanStopIndex:y,visibleStartIndex:C,visibleStopIndex:S})}),h._callOnScroll=void 0,h._callOnScroll=Ko(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),E;if(x.hasOwnProperty(v))E=x[v];else{var D=r(h.props,v,h._instanceProps),T=s(h.props,v,h._instanceProps),j=C==="horizontal"||_==="horizontal",F=C==="rtl",O=j?D:0;x[v]=E={position:"absolute",left:F?void 0:O,right:F?O:void 0,top:j?0:D,height:j?"100%":T,width:j?T:"100%"}}return E},h._getItemStyleCache=void 0,h._getItemStyleCache=Ko(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 E=h.props.direction,D=S;if(E==="rtl")switch(du()){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 E=Math.max(0,Math.min(_,S-C));return{isScrolling:!0,scrollDirection:x.scrollOffset<E?"forward":"backward",scrollOffset:E,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&&cu(h._resetIsScrollingTimeoutId),h._resetIsScrollingTimeoutId=IT(h._resetIsScrolling,kT)},h._resetIsScrolling=function(){h._resetIsScrollingTimeoutId=null,h.setState({isScrolling:!1},function(){h._getItemStyleCache(-1,null)})},h}g.getDerivedStateFromProps=function(h,v){return LT(h,v),d(h),null};var p=g.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 E=this._outerRef;S==="vertical"?x=E.scrollWidth>E.clientWidth?uu():0:x=E.scrollHeight>E.clientHeight?uu():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(du()){case"negative":x.scrollLeft=-S;break;case"positive-ascending":x.scrollLeft=S;break;default:var E=x.clientWidth,D=x.scrollWidth;x.scrollLeft=D-E-S;break}else x.scrollLeft=S;else x.scrollTop=S}this._callPropsCallbacks()},p.componentWillUnmount=function(){this._resetIsScrollingTimeoutId!==null&&cu(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,E=h.innerTagName,D=h.itemCount,T=h.itemData,j=h.itemKey,F=j===void 0?DT:j,O=h.layout,N=h.outerElementType,B=h.outerTagName,P=h.style,U=h.useIsScrolling,ne=h.width,H=this.state.isScrolling,te=C==="horizontal"||O==="horizontal",he=te?this._onScrollHorizontal:this._onScrollVertical,oe=this._getRangeToRender(),ge=oe[0],ve=oe[1],xe=[];if(D>0)for(var ye=ge;ye<=ve;ye++)xe.push(m.createElement(v,{data:T,key:F(ye,T),index:ye,isScrolling:U?H:void 0,style:this._getItemStyle(ye)}));var R=n(this.props,this._instanceProps);return m.createElement(N||B||"div",{className:y,onScroll:he,ref:this._outerRefSetter,style:Ya({position:"relative",height:S,width:ne,overflow:"auto",WebkitOverflowScrolling:"touch",willChange:"transform",direction:C},P)},m.createElement(x||E||"div",{children:xe,ref:_,style:{height:te?"100%":R,pointerEvents:H?"none":void 0,width:te?R:"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,E=x.scrollDirection,D=x.scrollOffset,T=x.scrollUpdateWasRequested;this._callOnScroll(E,D,T)}},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 E=o(this.props,x,this._instanceProps),D=a(this.props,E,x,this._instanceProps),T=!S||_==="backward"?Math.max(1,y):1,j=!S||_==="forward"?Math.max(1,y):1;return[Math.max(0,E-T),Math.max(0,Math.min(v-1,D+j)),E,D]},g})(m.PureComponent),t.defaultProps={direction:"ltr",itemData:void 0,layout:"vertical",overscanCount:2,useIsScrolling:!1},t}var LT=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)&&Oi&&!Oi.has(d)&&(Oi.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":Li&&!Li.has(d)&&(Li.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.'))}},OT=50,Rn=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]},NT=function(t,r,n){var s=r.itemMetadataMap,i=r.lastMeasuredIndex,o=i>0?s[i].offset:0;return o>=n?Yh(t,r,i,0,n):jT(t,r,Math.max(0,i),n)},Yh=function(t,r,n,s,i){for(;s<=n;){var o=s+Math.floor((n-s)/2),a=Rn(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},jT=function(t,r,n,s){for(var i=t.itemCount,o=1;n<i&&Rn(t,n,r).offset<s;)n+=o,o*=2;return Yh(t,r,Math.min(n,i-1),Math.floor(n/2),s)},fu=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},PT=Kh({getItemOffset:function(t,r,n){return Rn(t,r,n).offset},getItemSize:function(t,r,n){return n.itemMetadataMap[r].size},getEstimatedTotalSize:fu,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",g=f?d:c,p=Rn(t,r,i),b=fu(t,i),h=Math.max(0,Math.min(b-g,p.offset)),v=Math.max(0,p.offset-g+p.size+o);switch(n==="smart"&&(s>=v-g&&s<=h+g?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 NT(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,g=Rn(t,r,s),p=n+f,b=g.offset+g.size,h=r;h<a-1&&b<p;)h++,b+=Rn(t,h,s).size;return h},initInstanceProps:function(t,r){var n=t,s=n.estimatedItemSize,i={itemMetadataMap:{},estimatedItemSize:s||OT,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.'))}}),RT=Kh({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,g=t.width,p=a==="horizontal"||f==="horizontal",b=p?g: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,g=d?u:i,p=Math.ceil((g+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 FT(){var e,t;const r=Bt(),s=X0().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 MT=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 BT=m.forwardRef(function(t,r){const{children:n}=t,s=MT(t,["children"]),i=Bt();return l.jsxs("div",Object.assign({ref:r},s,{onClick:o=>{o.currentTarget===o.target&&i.deselectAll()},children:[l.jsx(qT,{}),n]}))}),qT=()=>{const e=Bt();return l.jsx("div",{style:{height:e.rowTopPosition(e.visibleNodes.length),width:"100%",position:"absolute",left:"0",right:"0"},children:l.jsx(FT,{})})};var $T=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 UT=m.forwardRef(function(t,r){var n,s,i,o,{style:a}=t,c=$T(t,["style"]);const u=Bt(),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 Zh=m.createContext({dragDropManager:void 0}),Jt;(function(e){e.SOURCE="SOURCE",e.TARGET="TARGET"})(Jt||(Jt={}));function Ee(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 Rl="dnd-core/INIT_COORDS",Ao="dnd-core/BEGIN_DRAG",Fl="dnd-core/PUBLISH_DRAG_SOURCE",Io="dnd-core/HOVER",ko="dnd-core/DROP",Do="dnd-core/END_DRAG";function hu(e,t){return{type:Rl,payload:{sourceClientOffset:t||null,clientOffset:e||null}}}function Ni(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?Ni=function(r){return typeof r}:Ni=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},Ni(e)}function zT(e,t,r){return t.split(".").reduce(function(n,s){return n&&n[s]?n[s]:r||null},e)}function VT(e,t){return e.filter(function(r){return r!==t})}function Xh(e){return Ni(e)==="object"}function HT(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 QT(e,t){return e.filter(function(r){return t.indexOf(r)>-1})}var WT={type:Rl,payload:{clientOffset:null,sourceClientOffset:null}};function GT(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(hu(o)),KT(r,c,u);var d=XT(r,c);if(d===null){e.dispatch(WT);return}var f=null;if(o){if(!a)throw new Error("getSourceClientOffset must be defined");YT(a),f=a(d)}e.dispatch(hu(o,f));var g=u.getSource(d),p=g.beginDrag(c,d);if(p!=null){ZT(p),u.pinSource(d);var b=u.getSourceType(d);return{type:Ao,payload:{itemType:b,item:p,sourceId:d,clientOffset:o||null,sourceClientOffset:f||null,isSourcePublic:!!i}}}}}function KT(e,t,r){Ee(!t.isDragging(),"Cannot call beginDrag while dragging."),e.forEach(function(n){Ee(r.getSource(n),"Expected sourceIds to be registered.")})}function YT(e){Ee(typeof e=="function","When clientOffset is provided, getSourceClientOffset must be a function.")}function ZT(e){Ee(Xh(e),"Item must be an object.")}function XT(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 JT(e){return function(){var r=e.getMonitor();if(r.isDragging())return{type:Fl}}}function Xa(e,t){return t===null?e===null:Array.isArray(e)?e.some(function(r){return r===t}):e===t}function eE(e){return function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=n.clientOffset;tE(r);var i=r.slice(0),o=e.getMonitor(),a=e.getRegistry();rE(i,o,a);var c=o.getItemType();return nE(i,a,c),sE(i,o,a),{type:Io,payload:{targetIds:i,clientOffset:s||null}}}}function tE(e){Ee(Array.isArray(e),"Expected targetIds to be an array.")}function rE(e,t,r){Ee(t.isDragging(),"Cannot call hover while not dragging."),Ee(!t.didDrop(),"Cannot call hover after drop.");for(var n=0;n<e.length;n++){var s=e[n];Ee(e.lastIndexOf(s)===n,"Expected targetIds to be unique in the passed array.");var i=r.getTarget(s);Ee(i,"Expected targetIds to be registered.")}}function nE(e,t,r){for(var n=e.length-1;n>=0;n--){var s=e[n],i=t.getTargetType(s);Xa(i,r)||e.splice(n,1)}}function sE(e,t,r){e.forEach(function(n){var s=r.getTarget(n);s.hover(t,n)})}function pu(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 mu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?pu(Object(r),!0).forEach(function(n){iE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):pu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return 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}function oE(e){return function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=e.getMonitor(),s=e.getRegistry();aE(n);var i=uE(n);i.forEach(function(o,a){var c=lE(o,a,s,n),u={type:ko,payload:{dropResult:mu(mu({},r),c)}};e.dispatch(u)})}}function aE(e){Ee(e.isDragging(),"Cannot call drop while not dragging."),Ee(!e.didDrop(),"Cannot call drop twice during one drag operation.")}function lE(e,t,r,n){var s=r.getTarget(e),i=s?s.drop(n,e):void 0;return cE(i),typeof i>"u"&&(i=t===0?{}:n.getDropResult()),i}function cE(e){Ee(typeof e>"u"||Xh(e),"Drop result must either be an object or undefined.")}function uE(e){var t=e.getTargetIds().filter(e.canDropOnTarget,e);return t.reverse(),t}function dE(e){return function(){var r=e.getMonitor(),n=e.getRegistry();fE(r);var s=r.getSourceId();if(s!=null){var i=n.getSource(s,!0);i.endDrag(r,s),n.unpinSource()}return{type:Do}}}function fE(e){Ee(e.isDragging(),"Cannot call endDrag while not dragging.")}function hE(e){return{beginDrag:GT(e),publishDragSource:JT(e),hover:eE(e),drop:oE(e),endDrag:dE(e)}}function pE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function mE(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 gE(e,t,r){return t&&mE(e.prototype,t),e}function ps(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var vE=(function(){function e(t,r){var n=this;pE(this,e),ps(this,"store",void 0),ps(this,"monitor",void 0),ps(this,"backend",void 0),ps(this,"isSetUp",!1),ps(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 gE(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=hE(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 Wt(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 gu=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})(),vu=function(){return Math.random().toString(36).substring(7).split("").join(".")},yu={INIT:"@@redux/INIT"+vu(),REPLACE:"@@redux/REPLACE"+vu()};function yE(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 bE(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(_E(e))return"date";if(SE(e))return"error";var r=CE(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 CE(e){return typeof e.constructor=="function"?e.constructor.name:null}function SE(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function _E(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function An(e){var t=typeof e;return process.env.NODE_ENV!=="production"&&(t=bE(e)),t}function Jh(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"?Wt(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"?Wt(1):"Expected the enhancer to be a function. Instead, received: '"+An(r)+"'");return r(Jh)(e,t)}if(typeof e!="function")throw new Error(process.env.NODE_ENV==="production"?Wt(2):"Expected the root reducer to be a function. Instead, received: '"+An(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"?Wt(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"?Wt(4):"Expected the listener to be a function. Instead, received: '"+An(h)+"'");if(c)throw new Error(process.env.NODE_ENV==="production"?Wt(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"?Wt(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 g(h){if(!yE(h))throw new Error(process.env.NODE_ENV==="production"?Wt(7):"Actions must be plain objects. Instead, the actual type was: '"+An(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"?Wt(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"?Wt(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"?Wt(10):"Expected the nextReducer to be a function. Instead, received: '"+An(h));s=h,g({type:yu.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"?Wt(11):"Expected the observer to be an object. Instead, received: '"+An(C)+"'");function S(){C.next&&C.next(d())}S();var _=v(S);return{unsubscribe:_}}},h[gu]=function(){return this},h}return g({type:yu.INIT}),n={dispatch:g,subscribe:f,getState:d,replaceReducer:p},n[gu]=b,n}var wE=function(t,r){return t===r};function xE(e,t){return!e&&!t?!0:!e||!t?!1:e.x===t.x&&e.y===t.y}function TE(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:wE;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 bu(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 Cu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bu(Object(r),!0).forEach(function(n){EE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function EE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Su={initialSourceClientOffset:null,initialClientOffset:null,clientOffset:null};function AE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Su,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Rl:case Ao:return{initialSourceClientOffset:r.sourceClientOffset,initialClientOffset:r.clientOffset,clientOffset:r.clientOffset};case Io:return xE(e.clientOffset,r.clientOffset)?e:Cu(Cu({},e),{},{clientOffset:r.clientOffset});case Do:case ko:return Su;default:return e}}var Ml="dnd-core/ADD_SOURCE",Bl="dnd-core/ADD_TARGET",ql="dnd-core/REMOVE_SOURCE",Lo="dnd-core/REMOVE_TARGET";function IE(e){return{type:Ml,payload:{sourceId:e}}}function kE(e){return{type:Bl,payload:{targetId:e}}}function DE(e){return{type:ql,payload:{sourceId:e}}}function LE(e){return{type:Lo,payload:{targetId:e}}}function _u(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 Gt(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_u(Object(r),!0).forEach(function(n){OE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_u(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function OE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var NE={itemType:null,item:null,sourceId:null,targetIds:[],dropResult:null,didDrop:!1,isSourcePublic:null};function jE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:NE,t=arguments.length>1?arguments[1]:void 0,r=t.payload;switch(t.type){case Ao:return Gt(Gt({},e),{},{itemType:r.itemType,item:r.item,sourceId:r.sourceId,isSourcePublic:r.isSourcePublic,dropResult:null,didDrop:!1});case Fl:return Gt(Gt({},e),{},{isSourcePublic:!0});case Io:return Gt(Gt({},e),{},{targetIds:r.targetIds});case Lo:return e.targetIds.indexOf(r.targetId)===-1?e:Gt(Gt({},e),{},{targetIds:VT(e.targetIds,r.targetId)});case ko:return Gt(Gt({},e),{},{dropResult:r.dropResult,didDrop:!0,targetIds:[]});case Do:return Gt(Gt({},e),{},{itemType:null,item:null,sourceId:null,dropResult:null,didDrop:!1,isSourcePublic:null,targetIds:[]});default:return e}}function PE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case Ml:case Bl:return e+1;case ql:case Lo:return e-1;default:return e}}var eo=[],$l=[];eo.__IS_NONE__=!0;$l.__IS_ALL__=!0;function RE(e,t){if(e===eo)return!1;if(e===$l||typeof t>"u")return!0;var r=QT(t,e);return r.length>0}function FE(){var e=arguments.length>1?arguments[1]:void 0;switch(e.type){case Io:break;case Ml:case Bl:case Lo:case ql:return eo;case Ao:case Fl:case Do:case ko:default:return $l}var t=e.payload,r=t.targetIds,n=r===void 0?[]:r,s=t.prevTargetIds,i=s===void 0?[]:s,o=HT(n,i),a=o.length>0||!TE(n,i);if(!a)return eo;var c=i[i.length-1],u=n[n.length-1];return c!==u&&(c&&o.push(c),u&&o.push(u)),o}function ME(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return e+1}function wu(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 xu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?wu(Object(r),!0).forEach(function(n){BE(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):wu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function BE(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qE(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;return{dirtyHandlerIds:FE(e.dirtyHandlerIds,{type:t.type,payload:xu(xu({},t.payload),{},{prevTargetIds:zT(e,"dragOperation.targetIds",[])})}),dragOffset:AE(e.dragOffset,t),refCount:PE(e.refCount,t),dragOperation:jE(e.dragOperation,t),stateId:ME(e.stateId)}}function $E(e,t){return{x:e.x+t.x,y:e.y+t.y}}function ep(e,t){return{x:e.x-t.x,y:e.y-t.y}}function UE(e){var t=e.clientOffset,r=e.initialClientOffset,n=e.initialSourceClientOffset;return!t||!r||!n?null:ep($E(t,n),r)}function zE(e){var t=e.clientOffset,r=e.initialClientOffset;return!t||!r?null:ep(t,r)}function VE(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HE(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 QE(e,t,r){return t&&HE(e.prototype,t),e}function Tu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var WE=(function(){function e(t,r){VE(this,e),Tu(this,"store",void 0),Tu(this,"registry",void 0),this.store=t,this.registry=r}return QE(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;Ee(typeof r=="function","listener must be a function."),Ee(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&&!RE(u.dirtyHandlerIds,i);f||r()}finally{o=d}};return this.store.subscribe(a)}},{key:"subscribeToOffsetChange",value:function(r){var n=this;Ee(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 Ee(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(Ee(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 Xa(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(Ee(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&&!Xa(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 UE(this.store.getState().dragOffset)}},{key:"getDifferenceFromInitialOffset",value:function(){return zE(this.store.getState().dragOffset)}}]),e})(),GE=0;function KE(){return GE++}function ji(e){"@babel/helpers - typeof";return typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?ji=function(r){return typeof r}:ji=function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ji(e)}function YE(e){Ee(typeof e.canDrag=="function","Expected canDrag to be a function."),Ee(typeof e.beginDrag=="function","Expected beginDrag to be a function."),Ee(typeof e.endDrag=="function","Expected endDrag to be a function.")}function ZE(e){Ee(typeof e.canDrop=="function","Expected canDrop to be a function."),Ee(typeof e.hover=="function","Expected hover to be a function."),Ee(typeof e.drop=="function","Expected beginDrag to be a function.")}function Ja(e,t){if(t&&Array.isArray(e)){e.forEach(function(r){return Ja(r,!1)});return}Ee(typeof e=="string"||ji(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 Eu=typeof global<"u"?global:self,tp=Eu.MutationObserver||Eu.WebKitMutationObserver;function rp(e){return function(){const r=setTimeout(s,0),n=setInterval(s,50);function s(){clearTimeout(r),clearInterval(n),e()}}}function XE(e){let t=1;const r=new tp(e),n=document.createTextNode("");return r.observe(n,{characterData:!0}),function(){t=-t,n.data=t}}const JE=typeof tp=="function"?XE:rp;class eA{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=JE(this.flush),this.requestErrorThrow=rp(()=>{if(this.pendingErrors.length)throw this.pendingErrors.shift()})}}class tA{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 rA{create(t){const r=this.freeTasks,n=r.length?r.pop():new tA(this.onError,s=>r[r.length]=s);return n.task=t,n}constructor(t){this.onError=t,this.freeTasks=[]}}const np=new eA,nA=new rA(np.registerPendingError);function sA(e){np.enqueueTask(nA.create(e))}function iA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function oA(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 aA(e,t,r){return t&&oA(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 lA(e,t){return fA(e)||dA(e,t)||uA(e,t)||cA()}function cA(){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 uA(e,t){if(e){if(typeof e=="string")return Au(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 Au(e,t)}}function Au(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 dA(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 fA(e){if(Array.isArray(e))return e}function hA(e){var t=KE().toString();switch(e){case Jt.SOURCE:return"S".concat(t);case Jt.TARGET:return"T".concat(t);default:throw new Error("Unknown Handler Role: ".concat(e))}}function Iu(e){switch(e[0]){case"S":return Jt.SOURCE;case"T":return Jt.TARGET;default:Ee(!1,"Cannot parse handler ID: ".concat(e))}}function ku(e,t){var r=e.entries(),n=!1;do{var s=r.next(),i=s.done,o=lA(s.value,2),a=o[1];if(a===t)return!0;n=!!i}while(!n);return!1}var pA=(function(){function e(t){iA(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 aA(e,[{key:"addSource",value:function(r,n){Ja(r),YE(n);var s=this.addHandler(Jt.SOURCE,r,n);return this.store.dispatch(IE(s)),s}},{key:"addTarget",value:function(r,n){Ja(r,!0),ZE(n);var s=this.addHandler(Jt.TARGET,r,n);return this.store.dispatch(kE(s)),s}},{key:"containsHandler",value:function(r){return ku(this.dragSources,r)||ku(this.dropTargets,r)}},{key:"getSource",value:function(r){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;Ee(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 Ee(this.isTargetId(r),"Expected a valid target ID."),this.dropTargets.get(r)}},{key:"getSourceType",value:function(r){return Ee(this.isSourceId(r),"Expected a valid source ID."),this.types.get(r)}},{key:"getTargetType",value:function(r){return Ee(this.isTargetId(r),"Expected a valid target ID."),this.types.get(r)}},{key:"isSourceId",value:function(r){var n=Iu(r);return n===Jt.SOURCE}},{key:"isTargetId",value:function(r){var n=Iu(r);return n===Jt.TARGET}},{key:"removeSource",value:function(r){var n=this;Ee(this.getSource(r),"Expected an existing source."),this.store.dispatch(DE(r)),sA(function(){n.dragSources.delete(r),n.types.delete(r)})}},{key:"removeTarget",value:function(r){Ee(this.getTarget(r),"Expected an existing target."),this.store.dispatch(LE(r)),this.dropTargets.delete(r),this.types.delete(r)}},{key:"pinSource",value:function(r){var n=this.getSource(r);Ee(n,"Expected an existing source."),this.pinnedSourceId=r,this.pinnedSource=n}},{key:"unpinSource",value:function(){Ee(this.pinnedSource,"No source is pinned at the time."),this.pinnedSourceId=null,this.pinnedSource=null}},{key:"addHandler",value:function(r,n,s){var i=hA(r);return this.types.set(i,n),r===Jt.SOURCE?this.dragSources.set(i,s):r===Jt.TARGET&&this.dropTargets.set(i,s),i}}]),e})();function mA(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=gA(n),i=new WE(s,new pA(s)),o=new vE(s,i),a=e(o,t,r);return o.receiveBackend(a),o}function gA(e){var t=typeof window<"u"&&window.__REDUX_DEVTOOLS_EXTENSION__;return Jh(qE,e&&t&&t({name:"dnd-core",instanceId:"dnd-core"}))}var vA=["children"];function yA(e,t){return _A(e)||SA(e,t)||CA(e,t)||bA()}function bA(){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 CA(e,t){if(e){if(typeof e=="string")return Du(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 Du(e,t)}}function Du(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 SA(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 _A(e){if(Array.isArray(e))return e}function wA(e,t){if(e==null)return{};var r=xA(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 xA(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 Lu=0,Pi=Symbol.for("__REACT_DND_CONTEXT_INSTANCE__"),TA=m.memo(function(t){var r=t.children,n=wA(t,vA),s=EA(n),i=yA(s,2),o=i[0],a=i[1];return m.useEffect(function(){if(a){var c=sp();return++Lu,function(){--Lu===0&&(c[Pi]=null)}}},[]),l.jsx(Zh.Provider,Object.assign({value:o},{children:r}),void 0)});function EA(e){if("manager"in e){var t={dragDropManager:e.manager};return[t,!1]}var r=AA(e.backend,e.context,e.options,e.debugMode),n=!e.context;return[r,n]}function AA(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:sp(),r=arguments.length>2?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,s=t;return s[Pi]||(s[Pi]={dragDropManager:mA(e,t,r,n)}),s[Pi]}function sp(){return typeof global<"u"?global:window}function IA(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 DA(e,t,r){return t&&kA(e.prototype,t),e}function Ou(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Zo=!1,Xo=!1,LA=(function(){function e(t){IA(this,e),Ou(this,"internalMonitor",void 0),Ou(this,"sourceId",null),this.internalMonitor=t.getMonitor()}return DA(e,[{key:"receiveHandlerId",value:function(r){this.sourceId=r}},{key:"getHandlerId",value:function(){return this.sourceId}},{key:"canDrag",value:function(){Ee(!Zo,"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 Zo=!0,this.internalMonitor.canDragSource(this.sourceId)}finally{Zo=!1}}},{key:"isDragging",value:function(){if(!this.sourceId)return!1;Ee(!Xo,"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 Xo=!0,this.internalMonitor.isDraggingSource(this.sourceId)}finally{Xo=!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 OA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function NA(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 jA(e,t,r){return t&&NA(e.prototype,t),e}function Nu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Jo=!1,PA=(function(){function e(t){OA(this,e),Nu(this,"internalMonitor",void 0),Nu(this,"targetId",null),this.internalMonitor=t.getMonitor()}return jA(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;Ee(!Jo,"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 Jo=!0,this.internalMonitor.canDropOnTarget(this.targetId)}finally{Jo=!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 RA(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 FA(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(!m.isValidElement(t)){var n=t;return e(n,r),n}var s=t;RA(s);var i=r?function(o){return e(o,r)}:e;return MA(s,i)}}function ip(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=FA(n);t[r]=function(){return s}}}),t}function ju(e,t){typeof e=="function"?e(t):e.current=t}function MA(e,t){var r=e.ref;return Ee(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?m.cloneElement(e,{ref:function(s){ju(r,s),ju(t,s)}}):m.cloneElement(e,{ref:t})}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 el(e){return e!==null&&Ri(e)==="object"&&Object.prototype.hasOwnProperty.call(e,"current")}function tl(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 BA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function qA(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 $A(e,t,r){return t&&qA(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 UA=(function(){function e(t){var r=this;BA(this,e),_t(this,"hooks",ip({dragSource:function(s,i){r.clearDragSource(),r.dragSourceOptions=i||null,el(s)?r.dragSourceRef=s:r.dragSourceNode=s,r.reconnectDragSource()},dragPreview:function(s,i){r.clearDragPreview(),r.dragPreviewOptions=i||null,el(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 $A(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!tl(this.lastConnectedDragSourceOptions,this.dragSourceOptions)}},{key:"didDragPreviewOptionsChange",value:function(){return!tl(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 zA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function VA(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 HA(e,t,r){return t&&VA(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 QA=(function(){function e(t){var r=this;zA(this,e),dr(this,"hooks",ip({dropTarget:function(s,i){r.clearDropTarget(),r.dropTargetOptions=i,el(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 HA(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!tl(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 WA(e,t,r){var n=r.getRegistry(),s=n.addTarget(e,t);return[s,function(){return n.removeTarget(s)}]}function GA(e,t,r){var n=r.getRegistry(),s=n.addSource(e,t);return[s,function(){return n.removeSource(s)}]}var vn=typeof window<"u"?m.useLayoutEffect:m.useEffect;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 KA(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function YA(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 ZA(e,t,r){return t&&YA(e.prototype,t),e}function ea(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var XA=(function(){function e(t,r,n){KA(this,e),ea(this,"spec",void 0),ea(this,"monitor",void 0),ea(this,"connector",void 0),this.spec=t,this.monitor=r,this.connector=n}return ZA(e,[{key:"beginDrag",value:function(){var r,n=this.spec,s=this.monitor,i=null;return Fi(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 JA(e,t,r){var n=m.useMemo(function(){return new XA(e,t,r)},[t,r]);return m.useEffect(function(){n.spec=e},[e]),n}function Sn(){var e=m.useContext(Zh),t=e.dragDropManager;return Ee(t!=null,"Expected drag drop context"),t}function eI(e){return m.useMemo(function(){var t=e.type;return Ee(t!=null,"spec.type must be defined"),t},[e])}function tI(e,t){return iI(e)||sI(e,t)||nI(e,t)||rI()}function rI(){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 nI(e,t){if(e){if(typeof e=="string")return Pu(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 Pu(e,t)}}function Pu(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 sI(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 iI(e){if(Array.isArray(e))return e}function oI(e,t,r){var n=Sn(),s=JA(e,t,r),i=eI(e);vn(function(){if(i!=null){var a=GA(i,s,n),c=tI(a,2),u=c[0],d=c[1];return t.receiveHandlerId(u),r.receiveHandlerId(u),d}},[n,t,r,s,i])}function aI(e){return dI(e)||uI(e)||cI(e)||lI()}function lI(){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 BI(e,t){if(e){if(typeof e=="string")return qu(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 qu(e,t)}}function qu(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 qI(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 $I(e){if(Array.isArray(e))return e}function UI(e,t,r){var n=Sn(),s=RI(e,t),i=LI(e);vn(function(){var a=WA(i,s,n),c=FI(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 zI(){var e=Sn();return m.useMemo(function(){return new PA(e)},[e])}function VI(e){var t=Sn(),r=m.useMemo(function(){return new QA(t.getBackend())},[t]);return vn(function(){return r.dropTargetOptions=e||null,r.reconnect(),function(){return r.disconnectDropTarget()}},[e]),r}function HI(e){return m.useMemo(function(){return e.hooks.dropTarget()},[e])}function cp(e,t){var r=op(e,t),n=zI(),s=VI(r.options);return UI(r,n,s),[lp(r.collect,n,s),HI(s)]}function QI(e,t){return YI(e)||KI(e,t)||GI(e,t)||WI()}function WI(){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 GI(e,t){if(e){if(typeof e=="string")return $u(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 $u(e,t)}}function $u(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 KI(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 YI(e){if(Array.isArray(e))return e}function ZI(e){var t=Sn(),r=t.getMonitor(),n=ap(r,e),s=QI(n,2),i=s[0],o=s[1];return m.useEffect(function(){return r.subscribeToOffsetChange(o)}),m.useEffect(function(){return r.subscribeToStateChange(o)}),i}function up(e){var t=null,r=function(){return t==null&&(t=e()),t};return r}function XI(e,t){return e.filter(function(r){return r!==t})}function JI(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 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 Uu(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){ek(this,e),Uu(this,"entered",[]),Uu(this,"isNodeInDocument",void 0),this.isNodeInDocument=t}return rk(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=JI(this.entered.filter(i),[r]),s===0&&this.entered.length>0}},{key:"leave",value:function(r){var n=this.entered.length;return this.entered=XI(this.entered.filter(this.isNodeInDocument),r),n>0&&this.entered.length===0}},{key:"reset",value:function(){this.entered=[]}}]),e})(),sk=up(function(){return/firefox/i.test(navigator.userAgent)}),dp=up(function(){return!!window.safari});function ik(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function ok(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 ak(e,t,r){return t&&ok(e.prototype,t),e}function ms(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var zu=(function(){function e(t,r){ik(this,e),ms(this,"xs",void 0),ms(this,"ys",void 0),ms(this,"c1s",void 0),ms(this,"c2s",void 0),ms(this,"c3s",void 0);for(var n=t.length,s=[],i=0;i<n;i++)s.push(i);s.sort(function(T,j){return t[T]<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]],g=0;g<o.length-1;g++){var p=a[g],b=a[g+1];if(p*b<=0)f.push(0);else{c=o[g];var h=o[g+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[_],E=1/o[_],D=x+f[_+1]-S-S;y.push((S-x-D)*E),C.push(D*E*E)}this.xs=t,this.ys=r,this.c1s=f,this.c2s=y,this.c3s=C}return ak(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 g=n[f];if(g<r)u=f+1;else if(g>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})(),lk=1;function fp(e){var t=e.nodeType===lk?e:e.parentElement;if(!t)return null;var r=t.getBoundingClientRect(),n=r.top,s=r.left;return{x:s,y:n}}function pi(e){return{x:e.clientX,y:e.clientY}}function ck(e){var t;return e.nodeName==="IMG"&&(sk()||!((t=document.documentElement)!==null&&t!==void 0&&t.contains(e)))}function uk(e,t,r,n){var s=e?t.width:r,i=e?t.height:n;return dp()&&e&&(i/=window.devicePixelRatio,s/=window.devicePixelRatio),{dragPreviewWidth:s,dragPreviewHeight:i}}function dk(e,t,r,n,s){var i=ck(t),o=i?e:t,a=fp(o),c={x:r.x-a.x,y:r.y-a.y},u=e.offsetWidth,d=e.offsetHeight,f=n.anchorX,g=n.anchorY,p=uk(i,t,u,d),b=p.dragPreviewWidth,h=p.dragPreviewHeight,v=function(){var D=new zu([0,.5,1],[c.y,c.y/d*h,c.y+h-d]),T=D.interpolate(g);return dp()&&i&&(T+=(window.devicePixelRatio-1)*h),T},y=function(){var D=new zu([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 hp="__NATIVE_FILE__",pp="__NATIVE_URL__",mp="__NATIVE_TEXT__",gp="__NATIVE_HTML__";const Vu=Object.freeze(Object.defineProperty({__proto__:null,FILE:hp,HTML:gp,TEXT:mp,URL:pp},Symbol.toStringTag,{value:"Module"}));function ra(e,t,r){var n=t.reduce(function(s,i){return s||e.getData(i)},"");return n??r}var kn;function mi(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var nl=(kn={},mi(kn,hp,{exposeProperties:{files:function(t){return Array.prototype.slice.call(t.files)},items:function(t){return t.items},dataTransfer:function(t){return t}},matchesTypes:["Files"]}),mi(kn,gp,{exposeProperties:{html:function(t,r){return ra(t,r,"")},dataTransfer:function(t){return t}},matchesTypes:["Html","text/html"]}),mi(kn,pp,{exposeProperties:{urls:function(t,r){return ra(t,r,"").split(`
|
|
545
545
|
`)},dataTransfer:function(t){return t}},matchesTypes:["Url","text/uri-list"]}),mi(kn,mp,{exposeProperties:{text:function(t,r){return ra(t,r,"")},dataTransfer:function(t){return t}},matchesTypes:["Text","text/plain"]}),kn);function fk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hk(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 pk(e,t,r){return t&&hk(e.prototype,t),e}function Hu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var mk=(function(){function e(t){fk(this,e),Hu(this,"item",void 0),Hu(this,"config",void 0),this.config=t,this.item={},this.initializeExposedProperties()}return pk(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 gk(e,t){var r=new mk(nl[e]);return r.loadDataTransfer(t),r}function na(e){if(!e)return null;var t=Array.prototype.slice.call(e.types||[]);return Object.keys(nl).filter(function(r){var n=nl[r].matchesTypes;return n.some(function(s){return t.indexOf(s)>-1})})[0]||null}function vk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yk(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 bk(e,t,r){return t&&yk(e.prototype,t),e}function sa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Ck=(function(){function e(t,r){vk(this,e),sa(this,"ownerDocument",null),sa(this,"globalContext",void 0),sa(this,"optionsArgs",void 0),this.globalContext=t,this.optionsArgs=r}return bk(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 Qu(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 Wu(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Qu(Object(r),!0).forEach(function(n){ke(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Qu(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function Sk(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function _k(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 wk(e,t,r){return t&&_k(e.prototype,t),e}function ke(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var xk=(function(){function e(t,r,n){var s=this;Sk(this,e),ke(this,"options",void 0),ke(this,"actions",void 0),ke(this,"monitor",void 0),ke(this,"registry",void 0),ke(this,"enterLeaveCounter",void 0),ke(this,"sourcePreviewNodes",new Map),ke(this,"sourcePreviewNodeOptions",new Map),ke(this,"sourceNodes",new Map),ke(this,"sourceNodeOptions",new Map),ke(this,"dragStartSourceIds",null),ke(this,"dropTargetIds",[]),ke(this,"dragEnterTargetIds",[]),ke(this,"currentNativeSource",null),ke(this,"currentNativeHandle",null),ke(this,"currentDragSourceNode",null),ke(this,"altKeyPressed",!1),ke(this,"mouseMoveTimeoutTimer",null),ke(this,"asyncEndDragFrameId",null),ke(this,"dragOverTargetIds",null),ke(this,"lastClientOffset",null),ke(this,"hoverRafId",null),ke(this,"getSourceClientOffset",function(i){var o=s.sourceNodes.get(i);return o&&fp(o)||null}),ke(this,"endDragNativeItem",function(){s.isDraggingNativeItem()&&(s.actions.endDrag(),s.currentNativeHandle&&s.registry.removeSource(s.currentNativeHandle),s.currentNativeHandle=null,s.currentNativeSource=null)}),ke(this,"isNodeInDocument",function(i){return!!(i&&s.document&&s.document.body&&s.document.body.contains(i))}),ke(this,"endDragIfSourceWasRemovedFromDOM",function(){var i=s.currentDragSourceNode;i==null||s.isNodeInDocument(i)||s.clearCurrentDragSourceNode()&&s.monitor.isDragging()&&s.actions.endDrag()}),ke(this,"handleTopDragStartCapture",function(){s.clearCurrentDragSourceNode(),s.dragStartSourceIds=[]}),ke(this,"handleTopDragStart",function(i){if(!i.defaultPrevented){var o=s.dragStartSourceIds;s.dragStartSourceIds=null;var a=pi(i);s.monitor.isDragging()&&s.actions.endDrag(),s.actions.beginDrag(o||[],{publishSource:!1,getSourceClientOffset:s.getSourceClientOffset,clientOffset:a});var c=i.dataTransfer,u=na(c);if(s.monitor.isDragging()){if(c&&typeof c.setDragImage=="function"){var d=s.monitor.getSourceId(),f=s.sourceNodes.get(d),g=s.sourcePreviewNodes.get(d)||f;if(g){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},_=dk(f,g,a,C,S);c.setDragImage(g,_.x,_.y)}}try{c==null||c.setData("application/json",{})}catch{}s.setCurrentDragSourceNode(i.target);var x=s.getCurrentSourcePreviewNodeOptions(),E=x.captureDraggingState;E?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()}}}),ke(this,"handleTopDragEndCapture",function(){s.clearCurrentDragSourceNode()&&s.monitor.isDragging()&&s.actions.endDrag()}),ke(this,"handleTopDragEnterCapture",function(i){s.dragEnterTargetIds=[];var o=s.enterLeaveCounter.enter(i.target);if(!(!o||s.monitor.isDragging())){var a=i.dataTransfer,c=na(a);c&&s.beginDragNativeItem(c,a)}}),ke(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:pi(i)});var a=o.some(function(c){return s.monitor.canDropOnTarget(c)});a&&(i.preventDefault(),i.dataTransfer&&(i.dataTransfer.dropEffect=s.getCurrentDropEffect()))}}),ke(this,"handleTopDragOverCapture",function(){s.dragOverTargetIds=[]}),ke(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=pi(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"))}),ke(this,"handleTopDragLeaveCapture",function(i){s.isDraggingNativeItem()&&i.preventDefault();var o=s.enterLeaveCounter.leave(i.target);o&&s.isDraggingNativeItem()&&setTimeout(function(){return s.endDragNativeItem()},0)}),ke(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 na(i.dataTransfer)&&i.preventDefault();s.enterLeaveCounter.reset()}),ke(this,"handleTopDrop",function(i){var o=s.dropTargetIds;s.dropTargetIds=[],s.actions.hover(o,{clientOffset:pi(i)}),s.actions.drop({dropEffect:s.getCurrentDropEffect()}),s.isDraggingNativeItem()?s.endDragNativeItem():s.monitor.isDragging()&&s.actions.endDrag()}),ke(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 Ck(r,n),this.actions=t.getActions(),this.monitor=t.getMonitor(),this.registry=t.getRegistry(),this.enterLeaveCounter=new nk(this.isNodeInDocument)}return wk(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 Wu({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 Wu({anchorX:.5,anchorY:.5,captureDraggingState:!1},n||{})}},{key:"isDraggingNativeItem",value:function(){var r=this.monitor.getItemType();return Object.keys(Vu).some(function(n){return Vu[n]===r})}},{key:"beginDragNativeItem",value:function(r,n){this.clearCurrentDragSourceNode(),this.currentNativeSource=gk(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})(),gi;function Tk(){return gi||(gi=new Image,gi.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),gi}var Ek=function(t,r,n){return new xk(t,r,n)};function Ak(e,t){return typeof e=="function"?e(t):e??"NODE"}function Ik(e){return e.isDraggable&&!e.isEditing}function kk(e){const t=Bt(),r=t.selectedIds,[n,s,i]=DI(()=>({canDrag:()=>Ik(e),type:Ak(t.props.dragType,e),item:()=>{const o=t.isSelected(e.id)?Array.from(r):[e.id];return t.dispatch(ts.dragStart(e.id,o)),{id:e.id,dragIds:o,data:e.data}},end:()=>{t.hideCursor(),t.redrawList(),t.dispatch(ts.dragEnd())}}),[r,e,t.props.dragType]);return m.useEffect(()=>{i(Tk())},[i]),s}function Dk(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 Lk(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 vi(e,t){return{parentId:e||null,index:t}}function Dn(e,t){return{type:"line",index:e,level:t}}function Ok(e){return{type:"highlight",id:e}}function ia(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=$h(n)+1;return{parentId:s,index:i}}function vp(e){var t;const r=Dk(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]=Lk(i,a,o,r);if(i&&i.isInternal&&r.inMiddle)return{drop:vi(i.id,null),cursor:Ok(i.id)};if(!c)return{drop:vi((t=u==null?void 0:u.parent)===null||t===void 0?void 0:t.id,0),cursor:Dn(0,0)};if(Fh(c)){const d=Di(s,(u==null?void 0:u.level)||0,c.level);return{drop:ia(c,d),cursor:Dn(c.rowIndex+1,d)}}if(Mh(c)){const d=Di(s,(u==null?void 0:u.level)||0,c.level);return{drop:ia(c,d),cursor:Dn(c.rowIndex+1,d)}}if(Bh(c)){const d=Di(s,0,c.level+1);return d>c.level?{drop:vi(c.id,0),cursor:Dn(c.rowIndex+1,d)}:{drop:ia(c,d),cursor:Dn(c.rowIndex+1,d)}}return{drop:vi(c==null?void 0:c.id,0),cursor:Dn(c.rowIndex+1,c.level+1)}}function Nk(e,t){const r=Bt(),[n,s]=cp(()=>({accept:"NODE",canDrop:()=>r.canDrop(),hover:(i,o)=>{const a=o.getClientOffset();if(!e.current||!a)return;const{cursor:c,drop:u}=vp({element:e.current,offset:a,indent:r.indent,node:t,prevNode:t.prev,nextNode:t.next});u&&r.dispatch(ts.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 jk(e){const t=Bt(),r=t.at(e);if(!r)throw new Error(`Could not find node for index: ${e}`);return m.useMemo(()=>{const n=r.clone();return t.visibleNodes[e]=n,n},[...Object.values(r.state),r])}const Gu=m.memo(function({index:t,style:r}){Rh(),Z0();const n=Bt(),s=jk(t),i=m.useRef(null),o=kk(s),a=Nk(i,s),c=m.useCallback(h=>{i.current=h,a(h)},[a]),u=n.indent*s.level,d=m.useMemo(()=>({paddingLeft:u}),[u]),f=m.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]),g={role:"treeitem","aria-level":s.level+1,"aria-selected":s.isSelected,"aria-expanded":s.isOpen,style:f,tabIndex:-1,className:n.props.rowClassName};m.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:g,children:l.jsx(p,{node:s,tree:n,style:d,dragHandle:o})})});let oa="",Ku=null;function yp(){Rh();const e=Bt();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(),Uh(t.currentTarget);return}if(t.key==="Tab"&&t.shiftKey){t.preventDefault(),zh(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(Ku),oa+=t.key,Ku=setTimeout(()=>{oa=""},600);const n=e.visibleNodes.find(s=>{const i=s.data.name;return typeof i=="string"?i.toLowerCase().startsWith(oa):!1});n&&e.focus(n.id)},children:l.jsx(Pk,{})})}function Pk(){var e,t;const r=Bt(),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:BT,innerElementType:(t=r.props.innerElementType)!==null&&t!==void 0?t:UT,onScroll:r.props.onScroll,onItemsRendered:r.onItemsRendered.bind(r)};return typeof r.props.rowHeight=="function"?l.jsx(PT,Object.assign({},n,{itemSize:r.rowHeightAt,ref:r.list,children:Gu})):l.jsx(RT,Object.assign({},n,{itemSize:r.rowHeight,ref:r.list,children:Gu}))}function Yu(e){return e.isFiltered?Fk(e.root,e.isMatch.bind(e)):Rk(e.root)}function Rk(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(bp),t}function Fk(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(bp),n}function bp(e,t){e.rowIndex=t}const Zu=e=>e.reduce((t,r,n)=>(t[r.id]=n,t),{});var aa=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}=rT;class As{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=su(this),this.visibleNodes=Yu(this),this.idToIndex=Zu(this.visibleNodes)}update(t){this.props=t,this.root=su(this),this.visibleNodes=Yu(this),this.idToIndex=Zu(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=_s(t,n))!==null&&r!==void 0?r:null}accessId(t){const r=this.props.idAccessor||"id",n=_s(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 Bs)return t.id;const r=this.props.idAccessor||"id";return _s(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 aa(this,arguments,void 0,function*(t={}){var r,n;const s=t.parentId===void 0?Wh(this):t.parentId,i=(r=t.index)!==null&&r!==void 0?r:Qh(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 aa(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(Go(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=>{As.editPromise=i})}submit(t,r){return aa(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(Go(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(Go(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=As.editPromise;r&&r(t),As.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(Tn(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(Tn(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(Tn(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(Tn(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(Tn((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&&qh(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===Ms?null:t,index:r===null?0:r,dragNodes:this.dragNodes,parentNode:this.get(t)}),this.open(t)}hideCursor(){this.dispatch(ts.cursor({type:"none"}))}showCursor(t){this.dispatch(ts.cursor(t))}open(t,r=!0){var n,s;const i=this.identifyNull(t);i&&(this.isOpen(i)||(this.dispatch(Ka.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(Ka.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=Pl(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(){Ji(this.root,t=>{t.isInternal&&this.open(t.id,!1)}),this.redrawList()}closeAll(){Ji(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),Hh(()=>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===Ms)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!_s(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(Tn(t.id))}onBlur(){this.dispatch(fT())}onItemsRendered(t){this.visibleStartIndex=t.visibleStartIndex,this.visibleStopIndex=t.visibleStopIndex}get renderContainer(){return this.props.renderContainer||yp}get renderRow(){return this.props.renderRow||aT}get renderNode(){return this.props.children||lT}get renderDragPreview(){return this.props.renderDragPreview||Gh}get renderCursor(){return this.props.renderCursor||oT}}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 Mk=typeof Symbol=="function"&&Symbol.observable||"@@observable",Xu=Mk,la=()=>Math.random().toString(36).substring(7).split("").join("."),Bk={INIT:`@@redux/INIT${la()}`,REPLACE:`@@redux/REPLACE${la()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${la()}`},pn=Bk;function Cp(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 qk(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(zk(e))return"date";if(Uk(e))return"error";const r=$k(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 $k(e){return typeof e.constructor=="function"?e.constructor.name:null}function Uk(e){return e instanceof Error||typeof e.message=="string"&&e.constructor&&typeof e.constructor.stackTraceLimit=="number"}function zk(e){return e instanceof Date?!0:typeof e.toDateString=="function"&&typeof e.getDate=="function"&&typeof e.setDate=="function"}function Lr(e){let t=typeof e;return process.env.NODE_ENV!=="production"&&(t=qk(e)),t}function Sp(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: '${Lr(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: '${Lr(r)}'`);return r(Sp)(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: '${Lr(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 g(v){if(!Cp(v))throw new Error(process.env.NODE_ENV==="production"?xt(7):`Actions must be plain objects. Instead, the actual type was: '${Lr(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: '${Lr(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: '${Lr(v)}`);n=v,g({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: '${Lr(y)}'`);function C(){const _=y;_.next&&_.next(d())}return C(),{unsubscribe:v(C)}},[Xu](){return this}}}return g({type:pn.INIT}),{dispatch:g,subscribe:f,getState:d,replaceReducer:p,[Xu]:b}}function Ju(e){typeof console<"u"&&typeof console.error=="function"&&console.error(e);try{throw new Error(e)}catch{}}function Vk(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(!Cp(e))return`The ${i} has unexpected type of "${Lr(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 Hk(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 ed(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"&&Ju(`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{Hk(r)}catch(o){i=o}return function(a={},c){if(i)throw i;if(process.env.NODE_ENV!=="production"){const f=Vk(a,r,c,s);f&&Ju(f)}let u=!1;const d={};for(let f=0;f<n.length;f++){const g=n[f],p=r[g],b=a[g],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 "${g}" 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[g]=h,u=u||h!==b}return u=u||n.length!==Object.keys(a).length,u?d:a}}function Qk(e=es().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 Wk=ed({nodes:ed({focus:hT,edit:dT,open:pT,selection:mT,drag:Qk}),dnd:gT}),Gk=es();function Kk({treeProps:e,imperativeHandle:t,children:r}){const n=m.useRef(null),s=m.useRef(null),i=m.useRef(Sp(Wk,es(e))),o=Y0.useSyncExternalStore(i.current.subscribe,i.current.getState,()=>Gk),a=m.useMemo(()=>new As(i.current,e,n,s),[]),c=m.useRef(0);return m.useMemo(()=>{c.current+=1,a.update(e)},Object.values(e)),m.useMemo(()=>{c.current+=1,a.update(a.props)},[o.nodes.open]),m.useImperativeHandle(t,()=>a),m.useEffect(()=>{a.props.selection?a.select(a.props.selection,{focus:!1}):a.deselectAll()},[a.props.selection]),m.useEffect(()=>{a.props.searchTerm||i.current.dispatch(Ka.clear(!0))},[a.props.searchTerm]),l.jsx(Oh.Provider,{value:a,children:l.jsx(Ph.Provider,{value:c.current,children:l.jsx(Nh.Provider,{value:o.nodes,children:l.jsx(jh.Provider,{value:o.dnd,children:l.jsx(TA,Object.assign({},e.dndManager?{manager:e.dndManager}:{backend:e.dndBackend||Ek,options:{rootElement:a.props.dndRootElement||void 0}},{children:r}))})})})})}function Yk(){const e=Bt(),[,t]=cp(()=>({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}=vp({element:e.listEl.current,offset:s,indent:e.indent,node:null,prevNode:e.visibleNodes[e.visibleNodes.length-1],nextNode:null});o&&e.dispatch(ts.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 Zk(e){return Yk(),e.children}function Xk(){const t=Bt().props.renderContainer||yp;return l.jsx(l.Fragment,{children:l.jsx(t,{})})}function Jk(){const e=Bt(),{offset:t,mouse:r,item:n,isDragging:s}=ZI(o=>({offset:o.getSourceClientOffset(),mouse:o.getClientOffset(),item:o.getItem(),isDragging:o.isDragging()})),i=e.props.renderDragPreview||Gh;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 eD(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 tD{constructor(t,r={}){this.accessors=eD(r),this.root=rD(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 rD(e,t){const r=new _p({},null,t,"ROOT");return r.children=e.map(n=>Ul(n,r,t)),r}function Ul(e,t,r){const n=new _p(e,t,r),s=r.getChildren(e);return s&&(n.children=s.map(i=>Ul(i,n,r))),n}class _p{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=Ul(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 nD=0;function sD(e,t={}){const[r,n]=m.useState(e),s=t.idAccessor,i=t.childrenAccessor,o=m.useMemo(()=>new tD(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-${nD++}`,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 iD(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]=sD(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function oD(e,t){const r=iD(e);return l.jsxs(Kk,{treeProps:r,imperativeHandle:t,children:[l.jsx(Zk,{children:l.jsx(Xk,{})}),l.jsx(Jk,{})]})}const aD=m.forwardRef(oD);function zl(){return ue(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 lD(){return ue(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 td={video:"#EA580C",pdf:"#DC2626",h5p:"#0D9488",scorm:"#7C3AED",audio:"#DB2777",quiz:"#16A34A",course:"#A85236",default:"#6B7280"},rd={video:"Video",pdf:"FileText",h5p:"Layers",scorm:"Package",audio:"Music",quiz:"HelpCircle",course:"BookOpen",default:"File"},nd=["Course Assessment","eTextbook","Exam Question","Explanation Content","Learning Resource","Practice Question Set","SCORM Content","Teacher Resource"],cD=[{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 uD(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 ni(e){const t=uD(e);return{key:t,color:td[t]??td.default,bgClass:`sbx-ct-sq--${t}`,badgeClass:`sbx-ct-badge--${t}`,tintClass:`sbx-ct-tint--${t}`,iconName:rd[t]??rd.default,label:t.charAt(0).toUpperCase()+t.slice(1)}}const dD="_row_nm332_1",fD="_grip_nm332_16",hD="_menuBtn_nm332_19",pD="_rowLp_nm332_23",mD="_selected_nm332_27",gD="_title_nm332_32",vD="_dropTarget_nm332_41",yD="_toggle_nm332_58",bD="_ctIcon_nm332_73",CD="_ctIconLp_nm332_85",SD="_folderIcon_nm332_89",_D="_rootIcon_nm332_94",wD="_titleLp_nm332_110",xD="_levelTitle_nm332_114",TD="_renameInput_nm332_119",ED="_dropHere_nm332_128",AD="_menuWrap_nm332_138",ID="_menu_nm332_19",kD="_dangerItem_nm332_190",it={row:dD,grip:fD,menuBtn:hD,rowLp:pD,selected:mD,title:gD,dropTarget:vD,toggle:yD,ctIcon:bD,ctIconLp:CD,folderIcon:SD,rootIcon:_D,titleLp:wD,levelTitle:xD,renameInput:TD,dropHere:ED,menuWrap:AD,menu:ID,dangerItem:kD},DD={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},LD=({node:e,style:t,dragHandle:r,editorMode:n})=>{const[s,i]=m.useState(!1),[o,a]=m.useState(!1),[c,u]=m.useState(e.data.name),d=m.useRef(null),f=ae(),g=Z(N=>N.editorProfile),p=n==="edit",b=zl(),h=ni(e.data),v=DD[h.key]??Gr,y=e.isSelected,C=e.level===0,S=e.data.isFolder??(e.children&&e.children.length>0),_=g.key==="learningPath",x=C?_?Ih:by:S?_?ky:Rf:v,E=_&&S&&!C&&!lt(e.data),D=e.level+1<=g.maxDepth,T=_?f.learningPath.addLevelButton:f.treeNode.addSubunitMenuItem,j=_?f.learningPath.addLevelButton:f.treeNode.addSiblingMenuItem;m.useEffect(()=>{if(!s)return;const N=B=>{var P;(P=d.current)!=null&&P.contains(B.target)||i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const F=m.useCallback(()=>{c.trim()&&e.submit(c.trim()),a(!1)},[c,e]),O=m.useCallback(N=>{N.key==="Enter"&&F(),N.key==="Escape"&&(u(e.data.name),a(!1))},[F,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(Ff,{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(wl,{size:14}):l.jsx(bn,{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:F,onKeyDown:O,onClick:N=>N.stopPropagation()}):l.jsx("span",{className:[it.title,_?it.titleLp:"",E?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(B=>!B)},"aria-label":f.treeNode.nodeOptionsAriaLabel,children:l.jsx(jf,{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(Ny,{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(Pf,{size:13})," ",T]}),e.data.parent&&b&&!_&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.data.parent}),i(!1)},children:[l.jsx(Cn,{size:13})," ",j]}),!C&&l.jsxs("button",{role:"menuitem",className:it.dangerItem,onClick:()=>{e.tree.delete(e.id),i(!1)},children:[l.jsx(Co,{size:13})," ",f.treeNode.deleteMenuItem]})]})]})]})};async function OD(e,t){var i,o;const n=((i=(await Re.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 ND(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 jD(e,t){var a;const r=await OD(e,t.name),n=await ND(r,t),s=new FormData;return s.append("fileUrl",n),s.append("mimeType",t.type||"text/csv"),{processId:(((a=(await Re.post(`/action/collection/v1/import/${e}`,s)).data)==null?void 0:a.result)??{}).processId??""}}async function PD(e){var r;return((r=(await Re.get(`/action/collection/v1/import/status/${e}`)).data)==null?void 0:r.result)??{status:"PENDING"}}async function wp(e){var n,s,i;const r=(i=(s=(n=(await Re.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 RD(e){return wp(e)}const FD="_container_jw2be_1",MD="_header_jw2be_13",BD="_title_jw2be_22",qD="_closeBtn_jw2be_29",$D="_body_jw2be_45",UD="_dropZone_jw2be_54",zD="_dragOver_jw2be_67",VD="_hasFile_jw2be_72",HD="_hiddenInput_jw2be_78",QD="_fileInfo_jw2be_82",WD="_fileIcon_jw2be_89",GD="_fileName_jw2be_93",KD="_fileSize_jw2be_100",YD="_dropHint_jw2be_105",ZD="_dropIcon_jw2be_112",XD="_dropText_jw2be_117",JD="_dropSubtext_jw2be_124",eL="_sampleLink_jw2be_130",tL="_statusBar_jw2be_145",rL="_status_uploading_jw2be_154",nL="_status_processing_jw2be_154",sL="_status_done_jw2be_159",iL="_status_error_jw2be_164",oL="_successDetail_jw2be_170",aL="_spinner_jw2be_175",lL="_spin_jw2be_175",cL="_errorMsg_jw2be_191",uL="_failedSection_jw2be_197",dL="_failedTitle_jw2be_203",fL="_tableWrap_jw2be_213",hL="_failedTable_jw2be_219",pL="_reasonCell_jw2be_244",mL="_footer_jw2be_248",Be={container:FD,header:MD,title:BD,closeBtn:qD,body:$D,dropZone:UD,dragOver:zD,hasFile:VD,hiddenInput:HD,fileInfo:QD,fileIcon:WD,fileName:GD,fileSize:KD,dropHint:YD,dropIcon:ZD,dropText:XD,dropSubtext:JD,sampleLink:eL,statusBar:tL,status_uploading:rL,status_processing:nL,status_done:sL,status_error:iL,successDetail:oL,spinner:aL,spin:lL,errorMsg:cL,failedSection:uL,failedTitle:dL,tableWrap:fL,failedTable:hL,reasonCell:pL,footer:mL},gL=({contentId:e,onComplete:t,onClose:r,mode:n="create"})=>{const s=ae(),[i,o]=m.useState(null),[a,c]=m.useState(!1),[u,d]=m.useState("idle"),[f,g]=m.useState(""),[p,b]=m.useState([]),[h,v]=m.useState(null),y=m.useRef(null),C=m.useRef(null),S=m.useCallback(()=>{C.current!==null&&(clearInterval(C.current),C.current=null)},[]);m.useEffect(()=>()=>S(),[S]);const _=O=>O.name.toLowerCase().endsWith(".csv")?O.size>50*1024*1024?(g(s.csvUpload.fileTooLarge),!1):!0:(g(s.csvUpload.invalidFileType),!1),x=m.useCallback(O=>{g(""),b([]),v(null),d("idle"),_(O)&&o(O)},[]),E=m.useCallback(O=>{O.preventDefault(),c(!1);const N=O.dataTransfer.files[0];N&&x(N)},[x]),D=m.useCallback(O=>{var B;const N=(B=O.target.files)==null?void 0:B[0];N&&x(N),O.target.value=""},[x]),T=m.useCallback(async()=>{try{const O=await RD(e),N=document.createElement("a");N.href=O,N.download="sample_hierarchy.csv",N.target="_blank",N.click()}catch{g(s.csvUpload.downloadSampleFailed)}},[e,s.csvUpload.downloadSampleFailed]),j=m.useCallback(async()=>{if(i){d("uploading"),g(""),b([]);try{const{processId:O}=await jD(e,i);if(!O){d("done"),v(null),setTimeout(t,1500);return}d("processing"),C.current=setInterval(async()=>{try{const N=await PD(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"),g(s.csvUpload.processingFailed),N.failedRecords&&b(N.failedRecords))}catch{S(),d("error"),g(s.csvUpload.connectionLost)}},2e3)}catch{d("error"),g(s.csvUpload.uploadFailed)}}},[e,i,t,S,s.csvUpload.processingFailed,s.csvUpload.connectionLost,s.csvUpload.uploadFailed]),F={idle:"",uploading:s.csvUpload.statusUploading,processing:s.csvUpload.statusProcessing,done:s.csvUpload.statusDone,error:s.csvUpload.statusError};return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsx("h2",{className:Be.title,children:n==="update"?s.csvUpload.titleUpdate:s.csvUpload.titleCreate}),l.jsx("button",{className:Be.closeBtn,onClick:r,"aria-label":s.csvUpload.closeAriaLabel,children:l.jsx(yr,{size:18})})]}),l.jsxs("div",{className:Be.body,children:[l.jsxs("div",{className:`${Be.dropZone} ${a?Be.dragOver:""} ${i?Be.hasFile:""}`,onDragEnter:O=>{O.preventDefault(),c(!0)},onDragOver:O=>{O.preventDefault(),c(!0)},onDragLeave:O=>{O.preventDefault(),c(!1)},onDrop:E,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:Be.hiddenInput,onChange:D,"aria-hidden":"true"}),i?l.jsxs("div",{className:Be.fileInfo,children:[l.jsx(Zs,{size:24,className:Be.fileIcon}),l.jsx("span",{className:Be.fileName,children:i.name}),l.jsxs("span",{className:Be.fileSize,children:["(",(i.size/1024).toFixed(1)," KB)"]})]}):l.jsxs("div",{className:Be.dropHint,children:[l.jsx(Fa,{size:32,className:Be.dropIcon}),l.jsx("p",{className:Be.dropText,children:s.csvUpload.dropText}),l.jsx("p",{className:Be.dropSubtext,children:s.csvUpload.dropSubtext})]})]}),l.jsx("button",{className:Be.sampleLink,onClick:T,type:"button",children:s.csvUpload.downloadSample}),u!=="idle"&&l.jsxs("div",{className:`${Be.statusBar} ${Be[`status_${u}`]}`,role:"status","aria-live":"polite",children:[u==="processing"&&l.jsx("span",{className:Be.spinner,"aria-hidden":"true"}),F[u],u==="done"&&h!==null&&l.jsx("span",{className:Be.successDetail,children:s.csvUpload.itemsImportedSuffix.replace("{count}",String(h))})]}),f&&l.jsx("p",{className:Be.errorMsg,role:"alert",children:f}),p.length>0&&l.jsxs("div",{className:Be.failedSection,children:[l.jsx("h4",{className:Be.failedTitle,children:s.csvUpload.failedRowsTitle.replace("{count}",String(p.length))}),l.jsx("div",{className:Be.tableWrap,children:l.jsxs("table",{className:Be.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:Be.reasonCell,children:O.reason??s.csvUpload.unknownError})]},N))})]})})]})]}),l.jsxs("div",{className:Be.footer,children:[l.jsx(qe,{variant:"ghost",onClick:r,disabled:u==="uploading"||u==="processing",children:s.csvUpload.cancel}),l.jsx(qe,{variant:"primary",isLoading:u==="uploading"||u==="processing",disabled:!i||u==="done",onClick:j,children:u==="done"?s.csvUpload.uploaded:s.csvUpload.upload})]})]})};function Vl(){var g,p,b,h,v;const e=ae(),t=ue(y=>y.treeData),r=ue(y=>y.treeCache),n=ue(y=>y.deleteNode),s=Hr(y=>y.activeAssessmentSlot),i=Hr(y=>y.setActiveAssessmentSlot),o=((g=t[0])==null?void 0:g.children)??[],a=o[0],c=o.length>1?o[o.length-1]:void 0,u=lt(a),d=lt(c),f=y=>{var D,T;const C=y==="pre"?a:c;if(!C)return;const S=t[0],_=S?((D=r[S.id])==null?void 0:D.policy)??((T=S.metadata)==null?void 0:T.policy):void 0,E=y==="pre"&&!!_&&wh.has(_)?e.learningPath.deletePriorAssessmentConfirm:e.learningPath.deleteAssessmentSlotConfirm;window.confirm(E)&&n(C.id)};return{pre:{level:a,filled:u,courseName:u?(b=(p=a==null?void 0:a.children)==null?void 0:p[0])==null?void 0:b.name:void 0},post:{level:c,filled:d,courseName:d?(v=(h=c==null?void 0:c.children)==null?void 0:h[0])==null?void 0:v.name:void 0},activeAssessmentSlot:s,setActiveAssessmentSlot:i,deleteSlot:f}}const vL="_container_2qylm_1",yL="_header_2qylm_8",bL="_sectionLabel_2qylm_18",CL="_headerActions_2qylm_26",SL="_iconBtn_2qylm_33",_L="_menuWrap_2qylm_51",wL="_dropdownMenu_2qylm_55",xL="_treeWrapper_2qylm_87",TL="_csvModal_2qylm_103",EL="_footer_2qylm_113",rr={container:vL,header:yL,sectionLabel:bL,headerActions:CL,iconBtn:SL,menuWrap:_L,dropdownMenu:wL,treeWrapper:xL,csvModal:TL,footer:EL},AL=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{var ce;const n=ae(),s=m.useRef(null),i=m.useRef(null),o=m.useRef(null),[a,c]=m.useState(400),[u,d]=m.useState(!1),[f,g]=m.useState(!1),[p,b]=m.useState("create"),{treeData:h,selectedNodeId:v,selectNode:y,addNode:C,deleteNode:S,reorderChildren:_,moveNode:x,setTreeData:E}=ue(),D=Z(Q=>Q.editorProfile),T=D.key==="learningPath",j=e==="edit",F=zl(),O=j&&F,N=T?n.learningPath.addLevelButton:n.outlineTree.addUnitButton,B=D.maxDepth>1,P=(((ce=h[0])==null?void 0:ce.children)??[]).some(Q=>Q.isFolder),{pre:U,post:ne,deleteSlot:H}=Vl(),{level:te}=U,{level:he}=ne,oe=Z(Q=>{var se,Te,me,ee;return((Te=(se=Q.editorConfig)==null?void 0:se.context)==null?void 0:Te.contentId)??((ee=(me=Q.editorConfig)==null?void 0:me.context)==null?void 0:ee.identifier)??""}),ge=Z(Q=>{var Te,me;const se=(me=(Te=Q.categoryMeta)==null?void 0:Te.sourcingSettings)==null?void 0:me.collection;return(se==null?void 0:se.enableBulkUpload)!==!1}),ve=D.features.csvUpload&≥m.useEffect(()=>{const Q=i.current;if(!Q)return;const se=new ResizeObserver(()=>{c(Q.clientHeight||400)});return se.observe(Q),c(Q.clientHeight||400),()=>se.disconnect()},[]),m.useEffect(()=>{if(!u)return;const Q=se=>{var Te;(Te=o.current)!=null&&Te.contains(se.target)||d(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[u]);const xe=m.useCallback(Q=>{Q.length>0&&y(Q[0].data.id)},[y]),ye=m.useCallback(({parentId:Q,index:se,dragIds:Te})=>{if(!Q)return;const me=Te[0],ee=sl(h,me);if(!ee)return;const He=ee.parent;if(He===Q){const Ge=sl(h,Q);if(!(Ge!=null&&Ge.children))return;const Ze=Ge.children.findIndex(Qe=>Qe.id===me);if(Ze<0)return;_(Q,Ze,se>Ze?se-1:se)}else x(me,He??"",Q)},[h,_,x]),R=m.useCallback(({ids:Q})=>{for(const se of Q){if(T&&(te==null?void 0:te.id)===se){H("pre");continue}if(T&&(he==null?void 0:he.id)===se){H("post");continue}S(se)}},[S,H,T,te,he]),M=m.useCallback(({parentId:Q})=>{var me;const se=Q??((me=h[0])==null?void 0:me.id)??"";if(!se)return{id:crypto.randomUUID()};const Te=C(se,"unit");return Te?{id:Te}:(we.error(n.outlineTree.maxDepthReachedToast),{id:crypto.randomUUID()})},[C,h,n]),Y=m.useCallback(()=>{var se;const Q=(se=h[0])==null?void 0:se.id;Q&&(C(Q,"unit")||we.error(n.outlineTree.maxDepthReachedToast))},[h,C,n]),le=m.useCallback(()=>{v&&(C(v,"subunit")||we.error(n.outlineTree.maxDepthReachedToast))},[v,C,n]),Ce=m.useCallback(async()=>{if(d(!1),!!oe)try{const Q=await wp(oe),se=await fetch(Q).then(ee=>ee.blob()),Te=URL.createObjectURL(se),me=document.createElement("a");me.href=Te,me.download=`${oe}-folders.csv`,me.style.display="none",document.body.appendChild(me),me.click(),document.body.removeChild(me),URL.revokeObjectURL(Te)}catch{we.error(n.outlineTree.downloadCsvFailedToast)}},[oe,n]),de=m.useCallback(async()=>{if(g(!1),!!oe)try{const{rootNode:Q}=await gh(oe);E([Q]),we.success(n.outlineTree.outlineRefreshedToast)}catch{we.error(n.outlineTree.outlineRefreshFailedToast)}},[oe,E,n]);return l.jsxs("div",{className:rr.container,children:[l.jsxs("div",{className:rr.header,children:[T&&l.jsx("span",{className:rr.sectionLabel,children:n.learningPath.pathStructureLabel}),l.jsxs("div",{className:rr.headerActions,children:[j&&ve&&l.jsxs("div",{className:rr.menuWrap,ref:o,children:[l.jsx("button",{type:"button",className:rr.iconBtn,onClick:()=>d(Q=>!Q),"aria-label":n.outlineTree.moreOptionsAriaLabel,title:n.outlineTree.moreOptionsTitle,"aria-haspopup":"true","aria-expanded":u,children:l.jsx(jf,{size:15})}),u&&l.jsxs("div",{className:rr.dropdownMenu,role:"menu",children:[l.jsx("button",{role:"menuitem",type:"button",disabled:P,title:P?n.outlineTree.foldersExistTitle:void 0,onClick:()=>{d(!1),b("create"),g(!0)},children:n.outlineTree.createFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!P,title:P?void 0:n.outlineTree.noFoldersYetTitle,onClick:Ce,children:n.outlineTree.downloadFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!P,title:P?void 0:n.outlineTree.noFoldersYetTitle,onClick:()=>{d(!1),b("update"),g(!0)},children:n.outlineTree.updateFoldersCsvButton})]})]}),r&&l.jsx("button",{type:"button",className:rr.iconBtn,onClick:r,"aria-label":t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,title:t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,children:t?l.jsx(Ly,{size:15}):l.jsx(Dy,{size:15})})]})]}),l.jsx("div",{className:rr.treeWrapper,ref:i,children:l.jsx(aD,{ref:s,data:h,idAccessor:"id",childrenAccessor:"children",onSelect:xe,onMove:j?ye:void 0,onDelete:j?R:void 0,onCreate:j?M:void 0,disableEdit:!j,disableDrop:!j,selection:v??void 0,rowHeight:40,indent:20,paddingBottom:16,height:a,width:"100%",children:Q=>l.jsx(LD,{...Q,editorMode:e})})}),j&&l.jsxs("div",{className:rr.footer,children:[l.jsxs(qe,{variant:"ghost",size:"sm",onClick:Y,disabled:!O,children:[l.jsx(Cn,{size:14})," ",N]}),B&&l.jsxs(qe,{variant:"ghost",size:"sm",onClick:le,disabled:!O||!v,children:[l.jsx(Pf,{size:14})," ",n.outlineTree.addSubunitButton]})]}),f&&l.jsx("div",{className:rr.csvModal,children:l.jsx(gL,{contentId:oe,mode:p,onComplete:de,onClose:()=>g(!1)})})]})};function sl(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=sl(r.children,t);if(n)return n}}}const IL="_breadcrumb_zd1aj_1",kL="_crumb_zd1aj_10",DL="_sep_zd1aj_26",LL="_current_zd1aj_31",gs={breadcrumb:IL,crumb:kL,sep:DL,current:LL},OL=({crumbs:e})=>{const t=ue(n=>n.selectNode),r=ae();return e.length?l.jsxs("nav",{className:gs.breadcrumb,"aria-label":r.breadcrumb.nodePathAriaLabel,children:[l.jsx("button",{className:gs.crumb,onClick:()=>t(e[0].id),"aria-label":r.breadcrumb.homeAriaLabel,children:l.jsx(Ay,{size:13})}),e.map((n,s)=>l.jsxs(m.Fragment,{children:[l.jsx(wl,{size:13,className:gs.sep}),s<e.length-1?l.jsx("button",{className:gs.crumb,onClick:()=>t(n.id),children:n.name}):l.jsx("span",{className:gs.current,children:n.name})]},n.id))]}):null},NL="_tabBar_qhks1_1",jL="_tab_qhks1_1",PL="_active_qhks1_29",RL="_error_qhks1_35",FL="_errorDot_qhks1_39",vs={tabBar:NL,tab:jL,active:PL,error:RL,errorDot:FL},ML=({activeTab:e,onChange:t,errorTabs:r=[],visibleTabs:n})=>{const s=ae(),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:vs.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:[vs.tab,e===a.id?vs.active:"",r.includes(a.id)?vs.error:""].join(" "),onClick:()=>t(a.id),children:[a.label,r.includes(a.id)&&l.jsx("span",{className:vs.errorDot,"aria-label":s.tabBar.hasErrorsAriaLabel})]},a.id))})};var si=e=>e.type==="checkbox",tn=e=>e instanceof Date,vt=e=>e==null;const xp=e=>typeof e=="object";var Ye=e=>!vt(e)&&!Array.isArray(e)&&xp(e)&&!tn(e),il=e=>Ye(e)&&e.target?si(e.target)?e.target.checked:e.target.value:e,Tp=(e,t)=>t.split(".").some((r,n,s)=>!isNaN(Number(r))&&e.has(s.slice(0,n).join("."))),Ep=e=>{const t=e.constructor&&e.constructor.prototype;return Ye(t)&&t.hasOwnProperty("isPrototypeOf")},Oo=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(Oo&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ye(e)&&Ep(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 Nr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ir={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},nr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ca="form",Ap="root",Ip=["__proto__","constructor","prototype"];var ii=e=>/^\w*$/.test(e),We=e=>e===void 0,No=e=>e.split(/[.[\]'"]/g).filter(Boolean),W=(e,t,r)=>{if(!t||!Ye(e))return r;const n=ii(t)?[t]:No(t);if(n.some(i=>Ip.includes(i)))return r;const s=n.reduce((i,o)=>vt(i)?void 0:i[o],e);return We(s)||s===e?We(e[t])?r:e[t]:s},Vt=e=>typeof e=="boolean",Et=e=>typeof e=="function",ze=(e,t,r)=>{let n=-1;const s=ii(t)?[t]:No(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=Ye(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(Ip.includes(a))return;e[a]=c,e=e[a]}};const Hl=m.createContext(null);Hl.displayName="HookFormControlContext";const Ql=()=>m.useContext(Hl);var kp=(e,t,r,n=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ir.all&&(t._proxyFormState[o]=!n||ir.all),r&&(r[o]=!0),e[o]}});return s};const Wl=Oo?m.useLayoutEffect:m.useEffect;function BL(e){const t=Ql(),{control:r=t,disabled:n,name:s,exact:i}=e||{},[o,a]=m.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=m.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Wl(()=>r._subscribe({name:s,formState:c.current,exact:i,callback:u=>{!n&&a({...r._formState,...u,defaultValues:r._defaultValues})}}),[s,n,i]),m.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),m.useMemo(()=>kp(o,r,c.current,!1),[o,r])}var At=e=>typeof e=="string",ol=(e,t,r,n,s)=>At(e)?(n&&t.watch.add(e),W(r,e,s)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),W(r,i))):(n&&(t.watchAll=!0),r),al=e=>vt(e)||!xp(e);const sd=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ep(e);function Ht(e,t,r=new WeakMap){if(e===t)return!0;if(al(e)||al(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(sd(e,n)||sd(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)||(Ye(a)||Array.isArray(a))&&(Ye(c)||Array.isArray(c))?!Ht(a,c,r):!Object.is(a,c))return!1}}return!0}function qL(e){const t=Ql(),{control:r=t,name:n,defaultValue:s,disabled:i,exact:o,compute:a}=e||{},c=m.useRef(s),u=m.useRef(a),d=m.useRef(void 0),f=m.useRef(r),g=m.useRef(n);u.current=a;const[p,b]=m.useState(()=>{const _=r._getWatch(n,c.current);return u.current?u.current(_):_}),h=m.useCallback(_=>{const x=ol(n,r._names,_||r._formValues,!1,c.current);return u.current?u.current(x):x},[r._formValues,r._names,n]),v=m.useCallback(_=>{if(!i){const x=ol(n,r._names,_||r._formValues,!1,c.current);if(u.current){const E=u.current(x);Ht(E,d.current)||(b(E),d.current=E)}else b(x)}},[r._formValues,r._names,i,n]);Wl(()=>((f.current!==r||!Ht(g.current,n))&&(f.current=r,g.current=n,v()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:_=>{v(_.values)}})),[r,o,n,v]),m.useEffect(()=>r._removeUnmounted());const y=f.current!==r,C=g.current,S=m.useMemo(()=>{if(i)return null;const _=!y&&!Ht(C,n);return y||_?h():null},[i,y,n,C,h]);return S!==null?S:p}function oi(e){const t=Ql(),{name:r,disabled:n,control:s=t,shouldUnregister:i,defaultValue:o,exact:a=!0}=e,c=Tp(s._names.array,r),u=m.useMemo(()=>W(s._formValues,r,W(s._defaultValues,r,o)),[s,r,o]),d=qL({control:s,name:r,defaultValue:u,exact:a}),f=BL({control:s,name:r,exact:a}),g=m.useRef(e),p=m.useRef(null),b=m.useRef(s.register(r,{...e.rules,value:d,...Vt(e.disabled)?{disabled:e.disabled}:{}}));g.current=e;const h=m.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!W(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!W(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!W(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!W(f.validatingFields,r)},error:{enumerable:!0,get:()=>W(f.errors,r)}}),[f,r]),v=m.useCallback(_=>{const x=il(_);return W(s._fields,r)||(b.current=s.register(r,{...g.current.rules,value:x})),b.current.onChange({target:{value:il(_),name:r},type:Nr.CHANGE})},[r,s]),y=m.useCallback(()=>b.current.onBlur({target:{value:W(s._formValues,r),name:r},type:Nr.BLUR}),[r,s._formValues]),C=m.useCallback(_=>{_&&(p.current={focus:()=>Et(_.focus)&&_.focus(),select:()=>Et(_.select)&&_.select(),setCustomValidity:E=>Et(_.setCustomValidity)&&_.setCustomValidity(E),reportValidity:()=>Et(_.reportValidity)&&_.reportValidity()});const x=W(s._fields,r);x&&x._f&&_&&(x._f.ref=p.current)},[s._fields,r]),S=m.useMemo(()=>({name:r,value:d,...Vt(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:v,onBlur:y,ref:C}),[r,n,f.disabled,v,y,C,d]);return m.useEffect(()=>{const _=s._options.shouldUnregister||i;s.register(r,{...g.current.rules,...Vt(g.current.disabled)?{disabled:g.current.disabled}:{}});const x=(E,D)=>{const T=W(s._fields,E);T&&T._f&&(T._f.mount=D)};if(x(r,!0),_){const E=Xe(W(i?s._defaultValues:s._options.values||s._defaultValues,r,W(s._options.defaultValues,r,g.current.defaultValue)));ze(s._defaultValues,r,E),We(W(s._formValues,r))&&ze(s._formValues,r,E)}if(!c&&s.register(r),p.current){const E=W(s._fields,r);E&&E._f&&(E._f.ref=p.current)}return()=>{(c?_&&!s._state.action:_)?s.unregister(r):x(r,!1)}},[r,s,c,i]),m.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),m.useMemo(()=>({field:S,formState:f,fieldState:h}),[S,f,h])}const $L=e=>e.render(oi(e)),Gl=m.createContext(null);Gl.displayName="HookFormContext";const er=()=>m.useContext(Gl),UL=({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:g,unregister:p,control:b,register:h,setFocus:v,subscribe:y})=>{const C=m.useMemo(()=>({watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:g,unregister:p,control:b,register:h,setFocus:v,subscribe:y}),[i,b,u,n,r,g,h,f,d,s,v,o,a,y,c,p,t]);return m.createElement(Gl.Provider,{value:C},m.createElement(Hl.Provider,{value:C.control},e))};var zL=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},Dp=e=>Array.isArray(e)?e.filter(Boolean):[],Mi=e=>Array.isArray(e)?e:[e],id=()=>{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 Lp(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],i=t[n];if(s&&Ye(s)&&i){const o=Lp(s,i);Ye(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var ft=e=>Ye(e)&&!Object.keys(e).length,Kl=e=>e.type==="file",to=e=>{if(!Oo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Op=e=>e.type==="select-multiple",Yl=e=>e.type==="radio",VL=e=>Yl(e)||si(e),ua=e=>to(e)&&e.isConnected;function HL(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 QL(e){for(const t in e)if(e.hasOwnProperty(t)&&!We(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:ii(t)?[t]:No(t),n=r.length===1?e:HL(e,r),s=r.length-1,i=r[s];return n&&delete n[i],s!==0&&(Ye(n)&&ft(n)||Array.isArray(n)&&QL(n))&&nt(e,r.slice(0,-1)),e}var WL=e=>{for(const t in e)if(Et(e[t]))return!0;return!1};function Np(e){return Array.isArray(e)||Ye(e)&&!WL(e)}function ll(e,t={}){for(const r in e){const n=e[r];Np(n)?(t[r]=Array.isArray(n)?[]:{},ll(n,t[r])):We(n)||(t[r]=!0)}return t}function cl(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>cl(r));return t.some(r=>r!==void 0)?t:void 0}if(Ye(e)){const t={};for(const r in e){const n=cl(e[r]);We(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function Xr(e,t,r){r||(r=ll(t));for(const n in e){const s=e[n];if(Np(s))We(t)||al(r[n])?r[n]=ll(s,Array.isArray(s)?[]:{}):Xr(s,vt(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!Ht(s,i)}}return cl(r)||{}}const od={value:!1,isValid:!1},ad={value:!0,isValid:!0};var jp=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&&!We(e[0].attributes.value)?We(e[0].value)||e[0].value===""?ad:{value:e[0].value,isValid:!0}:ad:od}return od},Pp=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>We(e)?e:t?e===""?NaN:e&&+e:r&&At(e)?new Date(e):n?n(e):e;const ld={isValid:!1,value:null};var Rp=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,ld):ld;function cd(e){const t=e.ref;return Kl(t)?t.files:Yl(t)?Rp(e.refs).value:Op(t)?[...t.selectedOptions].map(({value:r})=>r):si(t)?jp(e.refs).value:Pp(We(t.value)?e.ref.value:t.value,e)}var GL=(e,t,r,n)=>{const s={};for(const i of e){const o=W(t,i);o&&ze(s,i,o._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},ro=e=>e instanceof RegExp,ys=e=>We(e)?e:ro(e)?e.source:Ye(e)?ro(e.value)?e.value.source:e.value:e,ud=e=>({isOnSubmit:!e||e===ir.onSubmit,isOnBlur:e===ir.onBlur,isOnChange:e===ir.onChange,isOnAll:e===ir.all,isOnTouch:e===ir.onTouched});const dd="AsyncFunction";var KL=e=>!!e&&!!e.validate&&!!(Et(e.validate)&&e.validate.constructor.name===dd||Ye(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===dd)),YL=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),da=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(`${n}.`)));const Is=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const i=W(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(Is(a,t))break}else if(Ye(a)&&Is(a,t))break}}};function fd(e,t,r){const n=W(e,r);if(n||ii(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const i=s.join("."),o=W(t,i),a=W(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 ZL=(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||ir.all))},XL=(e,t,r)=>!e||!t||e===t||Mi(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),JL=(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,eO=(e,t)=>!Dp(W(e,t)).length&&nt(e,t),hd=(e,t,r)=>{const n=W(e,r),s=Array.isArray(n)?n:[];return ze(s,Ap,t[r]),ze(e,r,s),e};function pd(e,t,r="validate"){if(At(e)||Array.isArray(e)&&e.every(At)||Vt(e)&&!e)return{type:r,message:At(e)?e:"",ref:t}}var Ln=e=>Ye(e)&&!ro(e)?e:{value:e,message:""},md=async(e,t,r,n,s,i)=>{const{ref:o,refs:a,required:c,maxLength:u,minLength:d,min:f,max:g,pattern:p,validate:b,name:h,valueAsNumber:v,mount:y}=e._f,C=W(r,h);if(!y||t.has(h))return{};const S=a?a[0]:o,_=N=>{if(s&&S.reportValidity){const B=Vt(N)?"":N||"";a?a.forEach(P=>P.setCustomValidity(B)):S.setCustomValidity(B),S.reportValidity()}},x={},E=Yl(o),D=si(o),T=E||D,j=(v||Kl(o))&&We(o.value)&&We(C)||to(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,F=zL.bind(null,h,n,x),O=(N,B,P,U=nr.maxLength,ne=nr.minLength)=>{const H=N?B:P;x[h]={type:N?U:ne,message:H,ref:o,...F(N?U:ne,H)}};if(i?!Array.isArray(C)||!C.length:c&&(!T&&(j||vt(C))||Vt(C)&&!C||D&&!jp(a).isValid||E&&!Rp(a).isValid)){const{value:N,message:B}=At(c)?{value:!!c,message:c}:Ln(c);if(N&&(x[h]={type:nr.required,message:B,ref:S,...F(nr.required,B)},!n))return _(B),x}if(!j&&(!vt(f)||!vt(g))){let N,B;const P=Ln(g),U=Ln(f);if(!vt(C)&&!isNaN(C)){const ne=o.valueAsNumber||C&&+C;vt(P.value)||(N=ne>P.value),vt(U.value)||(B=ne<U.value)}else{const ne=o.valueAsDate||new Date(C),H=oe=>new Date(new Date().toDateString()+" "+oe),te=o.type=="time",he=o.type=="week";At(P.value)&&C&&(N=te?H(C)>H(P.value):he?C>P.value:ne>new Date(P.value)),At(U.value)&&C&&(B=te?H(C)<H(U.value):he?C<U.value:ne<new Date(U.value))}if((N||B)&&(O(!!N,P.message,U.message,nr.max,nr.min),!n))return _(x[h].message),x}if((u||d)&&!j&&(At(C)||i&&Array.isArray(C))){const N=Ln(u),B=Ln(d),P=!vt(N.value)&&C.length>+N.value,U=!vt(B.value)&&C.length<+B.value;if((P||U)&&(O(P,N.message,B.message),!n))return _(x[h].message),x}if(p&&!j&&At(C)){const{value:N,message:B}=Ln(p);if(ro(N)&&!C.match(N)&&(x[h]={type:nr.pattern,message:B,ref:o,...F(nr.pattern,B)},!n))return _(B),x}if(b){if(Et(b)){const N=await b(C,r),B=pd(N,S);if(B&&(x[h]={...B,...F(nr.validate,B.message)},!n))return _(B.message),x}else if(Ye(b)){let N={};for(const B in b){if(!ft(N)&&!n)break;const P=pd(await b[B](C,r),S,B);P&&(N={...P,...F(B,P.message)},_(P.message),n&&(x[h]=N))}if(!ft(N)&&(x[h]={ref:S,...N},!n))return x}}return _(!0),x};const tO={mode:ir.onSubmit,reValidateMode:ir.onChange,shouldFocusError:!0},Fp={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function rO(e={}){let t={...tO,...e},r={...Xe(Fp),isLoading:Et(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ye(t.defaultValues)||Ye(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 g={...f};const p={array:id(),state:id()},b=t.criteriaMode===ir.all,h=w=>k=>{clearTimeout(u),u=setTimeout(w,k)},v=async w=>{if(!o.keepIsValid&&!t.disabled&&(f.isValid||g.isValid||w)){let k;t.resolver?(k=ft((await F()).errors),y()):k=await B({fields:n,onlyCheckValid:!0,eventType:Nr.VALID}),k!==r.isValid&&p.state.next({isValid:k})}},y=(w,k)=>{!t.disabled&&(f.isValidating||f.validatingFields||g.isValidating||g.validatingFields)&&((w||Array.from(a.mount)).forEach(L=>{L&&(k?ze(r.validatingFields,L,k):nt(r.validatingFields,L))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ft(r.validatingFields)}))},C=()=>{r.dirtyFields=Xr(s,i)},S=(w,k=[],L,z,V=!0,G=!0)=>{if(z&&L&&!t.disabled){if(o.action=!0,G&&Array.isArray(W(n,w))){const $=L(W(n,w),z.argA,z.argB);V&&ze(n,w,$)}if(G&&Array.isArray(W(r.errors,w))){const $=L(W(r.errors,w),z.argA,z.argB);V&&ze(r.errors,w,$),eO(r.errors,w)}if((f.touchedFields||g.touchedFields)&&G&&Array.isArray(W(r.touchedFields,w))){const $=L(W(r.touchedFields,w),z.argA,z.argB);V&&ze(r.touchedFields,w,$)}(f.dirtyFields||g.dirtyFields)&&C(),p.state.next({name:w,isDirty:U(w,k),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ze(i,w,k)},_=(w,k)=>{ze(r.errors,w,k),r.errors={...r.errors},p.state.next({errors:r.errors})},x=w=>{r.errors=w,p.state.next({errors:r.errors,isValid:!1})},E=w=>{const k=ii(w)?[w]:No(w);let L=i,z=s;for(let V=0;V<k.length-1;V++){const G=k[V];if(L=vt(L)?L:L[G],z=vt(z)?z:z[G],L===null&&z!==null)return!0}return!1},D=(w,k,L,z)=>{const V=W(n,w);if(V){if(E(w))return;const G=We(W(i,w)),$=W(i,w,We(L)?W(s,w):L);We($)||z&&z.defaultChecked||k?ze(i,w,k?$:cd(V._f)):te(w,$),o.mount&&!o.action&&(v(),G&&r.isDirty&&(f.isDirty||g.isDirty)&&(U()||(r.isDirty=!1,p.state.next({...r}))),e.shouldUnregister&&G&&!We(W(i,w))&&da(w,a)&&(o.watch=!0))}},T=(w,k,L,z,V)=>{let G=!1,$=!1;const re={name:w};if(!t.disabled){if(!L||z){(f.isDirty||g.isDirty)&&($=r.isDirty,r.isDirty=re.isDirty=U(),G=$!==re.isDirty);const be=Ht(W(s,w),k);$=!!W(r.dirtyFields,w),be!==r.isDirty?r.dirtyFields=Xr(s,i):be?nt(r.dirtyFields,w):ze(r.dirtyFields,w,!0),re.dirtyFields=r.dirtyFields,G=G||(f.dirtyFields||g.dirtyFields)&&$!==!be}if(L){const be=W(r.touchedFields,w);be||(ze(r.touchedFields,w,L),re.touchedFields=r.touchedFields,G=G||(f.touchedFields||g.touchedFields)&&be!==L)}G&&V&&p.state.next(re)}return G?re:{}},j=(w,k,L,z)=>{const V=W(r.errors,w),G=(f.isValid||g.isValid)&&Vt(k)&&r.isValid!==k;if(t.delayError&&L?(c=h(()=>_(w,L)),c(t.delayError)):(clearTimeout(u),c=null,L?ze(r.errors,w,L):nt(r.errors,w),r.errors={...r.errors}),(L?!Ht(V,L):V)||!ft(z)||G){const $={...z,...G&&Vt(k)?{isValid:k}:{},errors:r.errors,name:w};r={...r,...$},p.state.next($)}},F=async w=>(y(w,!0),await t.resolver(i,t.context,GL(w||a.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),O=async w=>{const{errors:k}=await F(w);if(y(w),w){for(const L of w){const z=W(k,L);z?a.array.has(L)&&Ye(z)&&!Object.keys(z).some(V=>!Number.isNaN(Number(V)))?hd(r.errors,{[L]:z},L):ze(r.errors,L,z):nt(r.errors,L)}r.errors={...r.errors}}else r.errors=k;return k},N=async({name:w,eventType:k})=>{if(e.validate){const L=await e.validate({formValues:i,formState:r,name:w,eventType:k});if(Ye(L))for(const z in L){const V=L[z];V&&Ce(`${ca}.${z}`,{message:At(V.message)?V.message:"",type:V.type||nr.validate})}else At(L)||!L?Ce(ca,{message:L||"",type:nr.validate}):le(ca);return L}return!0},B=async({fields:w,onlyCheckValid:k,name:L,eventType:z,context:V={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(V.runRootValidation=!0,!await N({name:L,eventType:z})&&(V.valid=!1,k)))return V.valid;for(const G in w){const $=w[G];if($){const{_f:re,...be}=$;if(re){const $e=a.array.has(re.name),Ot=$._f&&KL($._f),Nt=f.validatingFields||f.isValidating||g.validatingFields||g.isValidating;Ot&&Nt&&y([re.name],!0);const br=await md($,a.disabled,i,b,t.shouldUseNativeValidation&&!k,$e);if(Ot&&Nt&&y([re.name]),br[re.name]&&(V.valid=!1,k)||(!k&&(W(br,re.name)?$e?hd(r.errors,br,re.name):ze(r.errors,re.name,br[re.name]):nt(r.errors,re.name)),e.shouldUseNativeValidation&&br[re.name]))break}!ft(be)&&await B({context:V,onlyCheckValid:k,fields:be,name:G,eventType:z})}}return V.valid},P=()=>{for(const w of a.unMount){const k=W(n,w);k&&(k._f.refs?k._f.refs.every(L=>!ua(L)):!ua(k._f.ref))&&se(w)}a.unMount=new Set},U=(w,k)=>!t.disabled&&(w&&k&&ze(i,w,k),!Ht(M(),s)),ne=(w,k,L)=>ol(w,a,{...o.mount?i:We(k)?s:At(w)?{[w]:k}:k},L,k),H=w=>Dp(W(o.mount?i:s,w,t.shouldUnregister?W(s,w,[]):[])),te=(w,k,L={},z=!1)=>{const V=W(n,w);let G=k;if(V){const $=V._f;$&&(!$.disabled&&ze(i,w,Pp(k,$)),G=to($.ref)&&vt(k)?"":k,Op($.ref)?[...$.ref.options].forEach(re=>re.selected=G.includes(re.value)):$.refs?si($.ref)?$.refs.forEach(re=>{(!re.defaultChecked||!re.disabled)&&(Array.isArray(G)?re.checked=!!G.find(be=>be===re.value):re.checked=G===re.value||!!G)}):$.refs.forEach(re=>re.checked=re.value===G):Kl($.ref)?$.ref.value="":($.ref.value=G,$.ref.type||p.state.next({name:w,values:z?i:Xe(i)})))}(L.shouldDirty||L.shouldTouch)&&T(w,G,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&R(w)},he=(w,k,L,z=!1)=>{for(const V in k){if(!k.hasOwnProperty(V))return;const G=k[V],$=w+"."+V,re=W(n,$);(a.array.has(w)||Ye(G)||re&&!re._f)&&!tn(G)?he($,G,L,z):te($,G,L,z)}},oe=(w,k,L,z)=>{const V=W(n,w),G=a.array.has(w),$=z?k:Xe(k),re=W(i,w),be=Ht(re,$);if(be||ze(i,w,$),G)p.array.next({name:w,values:z?i:Xe(i)}),(f.isDirty||f.dirtyFields||g.isDirty||g.dirtyFields)&&L.shouldDirty&&(C(),p.state.next({name:w,dirtyFields:r.dirtyFields,isDirty:U(w,$)}));else{const $e=Array.isArray($)&&!$.length||ft($);!V||V._f||vt($)||$e?te(w,$,L,z):he(w,$,L,z)}if(!be){const $e=da(w,a),Ot=z?i:Xe(i);p.state.next({...$e&&r,name:o.mount||$e?w:void 0,values:Ot})}},ge=(w,k,L={})=>oe(w,k,L,!1),ve=(w,k={})=>{const L=Et(w)?w(i):w;if(!Ht(i,L)){i={...i,...L};for(const z of a.mount)oe(z,W(L,z),k,!0);p.state.next({...r,name:void 0,type:void 0,values:i}),k.shouldValidate&&v()}},xe=async w=>{o.mount=!0;const k=w.target;let L=k.name,z=!0;const V=W(n,L),G=be=>{z=Number.isNaN(be)||tn(be)&&isNaN(be.getTime())||Ht(be,W(i,L,be))},$=ud(t.mode),re=ud(t.reValidateMode);if(V){let be,$e;const Ot=k.type?cd(V._f):il(w),Nt=w.type===Nr.BLUR||w.type===Nr.FOCUS_OUT,br=!YL(V._f)&&!e.validate&&!t.resolver&&!W(r.errors,L)&&!V._f.deps||JL(Nt,W(r.touchedFields,L),r.isSubmitted,re,$),ls=da(L,a,Nt);ze(i,L,Ot),Nt?(!k||!k.readOnly)&&(V._f.onBlur&&V._f.onBlur(w),c&&c(0)):V._f.onChange&&V._f.onChange(w);const Yr=T(L,Ot,Nt),ct=!ft(Yr)||ls;if(!Nt&&p.state.next({name:L,type:w.type,values:Xe(i)}),br)return(f.isValid||g.isValid)&&(t.mode==="onBlur"?Nt&&v():Nt||v()),ct&&p.state.next({name:L,...ls?{}:Yr});if(!t.resolver&&e.validate&&await N({name:L,eventType:w.type}),!Nt&&ls&&p.state.next({...r}),t.resolver){const{errors:Ct}=await F([L]);if(y([L]),G(Ot),!z){!ft(Yr)&&p.state.next(Yr);return}const kt=fd(r.errors,n,L),tr=fd(Ct,n,kt.name||L);be=tr.error,L=tr.name,$e=ft(Ct)}else y([L],!0),be=(await md(V,a.disabled,i,b,t.shouldUseNativeValidation))[L],y([L]),G(Ot),z&&(be?$e=!1:(f.isValid||g.isValid)&&($e=await B({fields:n,onlyCheckValid:!0,name:L,eventType:w.type})));z&&(V._f.deps&&(!Array.isArray(V._f.deps)||V._f.deps.length>0)&&R(V._f.deps),j(L,$e,be,Yr))}},ye=(w,k)=>{if(W(r.errors,k)&&w.focus)return w.focus(),1},R=async(w,k={})=>{let L,z;const V=Mi(w);if(t.resolver){const G=await O(We(w)?w:V);L=ft(G),z=w?!V.some($=>W(G,$)):L}else w?(z=(await Promise.all(V.map(async G=>{const $=W(n,G);return await B({fields:$&&$._f?{[G]:$}:$,eventType:Nr.TRIGGER})}))).every(Boolean),!(!z&&!r.isValid)&&v()):z=L=await B({fields:n,name:w,eventType:Nr.TRIGGER});return p.state.next({...!At(w)||(f.isValid||g.isValid)&&L!==r.isValid?{}:{name:w},...t.resolver||!w?{isValid:L}:{},errors:r.errors}),k.shouldFocus&&!z&&Is(n,ye,w?V:a.mount),z},M=(w,k)=>{let L={...o.mount?i:s};return k&&(L=Lp(k.dirtyFields?r.dirtyFields:r.touchedFields,L)),We(w)?L:At(w)?W(L,w):w.map(z=>W(L,z))},Y=(w,k)=>({invalid:!!W((k||r).errors,w),isDirty:!!W((k||r).dirtyFields,w),error:W((k||r).errors,w),isValidating:!!W(r.validatingFields,w),isTouched:!!W((k||r).touchedFields,w)}),le=w=>{const k=w?Mi(w):void 0;k==null||k.forEach(L=>nt(r.errors,L)),k?k.forEach(L=>{p.state.next({name:L,errors:r.errors})}):p.state.next({errors:{}})},Ce=(w,k,L)=>{const z=(W(n,w,{_f:{}})._f||{}).ref,V=W(r.errors,w)||{},{ref:G,message:$,type:re,...be}=V;ze(r.errors,w,{...be,...k,ref:z}),p.state.next({name:w,errors:r.errors,isValid:!1}),L&&L.shouldFocus&&z&&z.focus&&z.focus()},de=(w,k)=>Et(w)?p.state.subscribe({next:L=>"values"in L&&w(L.values||ne(void 0,k),L)}):ne(w,k,!0),ce=w=>p.state.subscribe({next:k=>{if(XL(w.name,k.name,w.exact)&&ZL(k,w.formState||f,Kr,w.reRenderRoot)){const L={...i};w.callback({values:L,...r,...k,defaultValues:s})}}}).unsubscribe,Q=w=>(o.mount=!0,g={...g,...w.formState},ce({...w,formState:{...d,...w.formState}})),se=(w,k={})=>{for(const L of w?Mi(w):a.mount)a.mount.delete(L),a.array.delete(L),k.keepValue||(nt(n,L),nt(i,L)),!k.keepError&&nt(r.errors,L),!k.keepDirty&&nt(r.dirtyFields,L),!k.keepTouched&&nt(r.touchedFields,L),!k.keepIsValidating&&nt(r.validatingFields,L),!t.shouldUnregister&&!k.keepDefaultValue&&nt(s,L);p.state.next({values:Xe(i)}),p.state.next({...r,...k.keepDirty?{isDirty:U()}:{}}),!k.keepIsValid&&v()},Te=({disabled:w,name:k})=>{if(Vt(w)&&o.mount||w||a.disabled.has(k)){const V=a.disabled.has(k)!==!!w;w?a.disabled.add(k):a.disabled.delete(k),V&&o.mount&&!o.action&&v()}},me=(w,k={})=>{let L=W(n,w);const z=Vt(k.disabled)||Vt(t.disabled),V=!a.registerName.has(w)&&L&&L._f&&!L._f.mount;return ze(n,w,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:w}},name:w,mount:!0,...k}}),a.mount.add(w),L&&!V?Te({disabled:Vt(k.disabled)?k.disabled:t.disabled,name:w}):D(w,!0,k.value),{...z?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:ys(k.min),max:ys(k.max),minLength:ys(k.minLength),maxLength:ys(k.maxLength),pattern:ys(k.pattern)}:{},name:w,onChange:xe,onBlur:xe,ref:G=>{if(G){a.registerName.add(w),me(w,k),a.registerName.delete(w),L=W(n,w);const $=We(G.value)&&G.querySelectorAll&&G.querySelectorAll("input,select,textarea")[0]||G,re=VL($),be=L._f.refs||[];if(re?be.find($e=>$e===$):$===L._f.ref)return;ze(n,w,{_f:{...L._f,...re?{refs:[...be.filter(ua),$,...Array.isArray(W(s,w))?[{}]:[]],ref:{type:$.type,name:w}}:{ref:$}}}),D(w,!1,void 0,$)}else L=W(n,w,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(Tp(a.array,w)&&o.action)&&a.unMount.add(w)}}},ee=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Is(n,ye,a.mount),He=w=>{Vt(w)&&(p.state.next({disabled:w}),Is(n,(k,L)=>{const z=W(n,L);z&&(k.disabled=z._f.disabled||w,Array.isArray(z._f.refs)&&z._f.refs.forEach(V=>{V.disabled=z._f.disabled||w}))},0,!1))},Ge=(w,k)=>async L=>{let z;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let V=Xe(i);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:G,values:$}=await F();y(),r.errors=G,V=Xe($)}else await B({fields:n,eventType:Nr.SUBMIT});if(a.disabled.size)for(const G of a.disabled)nt(V,G);if(nt(r.errors,Ap),ft(r.errors)){p.state.next({errors:{}});try{await w(V,L)}catch(G){z=G}}else k&&await k({...r.errors},L),ee(),setTimeout(ee);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ft(r.errors)&&!z,submitCount:r.submitCount+1,errors:r.errors}),z)throw z},Ze=(w,k={})=>{W(n,w)&&(We(k.defaultValue)?ge(w,Xe(W(s,w))):(ge(w,k.defaultValue),ze(s,w,Xe(k.defaultValue))),k.keepTouched||nt(r.touchedFields,w),k.keepDirty||(nt(r.dirtyFields,w),r.isDirty=k.defaultValue?U(w,Xe(W(s,w))):U()),k.keepError||(nt(r.errors,w),f.isValid&&v()),p.state.next({...r}))},Qe=(w,k={})=>{const L=w?Xe(w):s,z=Xe(L),V=ft(w),G=z;if(k.keepDefaultValues||(s=L),!k.keepValues){if(k.keepDirtyValues){const $=new Set([...a.mount,...Object.keys(Xr(s,i))]);for(const re of Array.from($)){const be=W(r.dirtyFields,re),$e=W(i,re),Ot=W(G,re);be&&!We($e)?ze(G,re,$e):!be&&!We(Ot)&&ge(re,Ot)}}else{if(Oo&&We(w))for(const $ of a.mount){const re=W(n,$);if(re&&re._f){const be=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(to(be)){const $e=be.closest("form");if($e){$e.reset();break}}}}if(k.keepFieldsRef)for(const $ of a.mount)ge($,W(G,$));else n={}}if(t.shouldUnregister){if(i=k.keepDefaultValues?Xe(s):{},k.keepFieldsRef)for(const $ of a.mount)ze(i,$,W(G,$))}else i=Xe(G);p.array.next({values:{...G}}),p.state.next({values:{...G}})}a={mount:k.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||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!ft(G),o.watch=!!t.shouldUnregister,o.keepIsValid=!!k.keepIsValid,o.action=!1,k.keepErrors||(r.errors={}),p.state.next({submitCount:k.keepSubmitCount?r.submitCount:0,isDirty:V?!1:k.keepDirty?r.isDirty:k.keepValues?U():!!(k.keepDefaultValues&&!Ht(w,s)),isSubmitted:k.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:V?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Xr(s,i):r.dirtyFields:k.keepDefaultValues&&w?Xr(s,w):k.keepDirty?r.dirtyFields:{},touchedFields:k.keepTouched?r.touchedFields:{},errors:k.keepErrors?r.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},tt=(w,k)=>Qe(Et(w)?w(i):w,{...t.resetOptions,...k}),st=(w,k={})=>{const L=W(n,w),z=L&&L._f;if(z){const V=z.refs?z.refs[0]:z.ref;V.focus&&setTimeout(()=>{V.focus(),k.shouldSelect&&Et(V.select)&&V.select()})}},Kr=w=>{r={...r,...w}},_e={control:{register:me,unregister:se,getFieldState:Y,handleSubmit:Ge,setError:Ce,_subscribe:ce,_runSchema:F,_updateIsValidating:y,_focusError:ee,_getWatch:ne,_getDirty:U,_setValid:v,_setFieldArray:S,_setDisabledField:Te,_setErrors:x,_getFieldArray:H,_reset:Qe,_resetDefaultValues:()=>Et(t.defaultValues)&&t.defaultValues().then(w=>{tt(w,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:He,_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:Q,trigger:R,register:me,handleSubmit:Ge,watch:de,setValue:ge,setValues:ve,getValues:M,reset:tt,resetField:Ze,resetDefaultValues:(w,k={})=>{if(s=Xe(w),!k.keepDirty){const L=Xr(s,i);r.dirtyFields=L,r.isDirty=!ft(L)}k.keepIsValid||v(),p.state.next({...r,defaultValues:s})},clearErrors:le,unregister:se,setError:Ce,setFocus:st,getFieldState:Y};return{..._e,formControl:_e}}function nO(e={}){const t=m.useRef(void 0),r=m.useRef(void 0),n=m.useRef(e.formControl),[s,i]=m.useState(()=>({...Xe(Fp),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}=rO(e);t.current={...c,formState:s}}const o=t.current.control;return o._options=e,Wl(()=>{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]),m.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),m.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),m.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),m.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),m.useEffect(()=>{if(o._proxyFormState.isDirty){const a=o._getDirty();a!==s.isDirty&&o._subjects.state.next({isDirty:a})}},[o,s.isDirty]),m.useEffect(()=>{var a;e.values&&!Ht(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]),m.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=m.useMemo(()=>kp(s,o),[o,s]),t.current}function sO(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}=Zn({queryKey:["framework-search",i.sort().join(","),r],queryFn:()=>y1({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 Mp(e){var r,n;return(n=(r=(await Re.get(`/api/channel/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.channel}function iO(e){var r,n,s,i,o,a,c;const t=Zn({queryKey:["channel",e],queryFn:()=>Mp(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 oO(e){const{data:t}=Zn({queryKey:["user","read",e],enabled:!!e,staleTime:1/0,queryFn:()=>B1(e)});return t&&([t.firstName,t.lastName].filter(Boolean).join(" ").trim()||t.userName)||void 0}const Bp=[{label:"Strict",value:"Fixed"},{label:"Adaptive",value:"Diagnostic"},{label:"Prior learning",value:"PriorLearning"}],aO={"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."}},lO=new Set(["review","read","sourcingreview","orgreview"]),yi={"First Section":"details","Second Section":"details","Third Section":"details","Organisation Framework Terms":"details","Target Framework Terms":"audience","Fourth Section":"licensing","Sixth Section":"licensing"},cO={Categorisation:"Second Section","Basic Information":"First Section","Licensing & Attribution":"Fourth Section",Curriculum:"Organisation Framework Terms","Target Audience":"Target Framework Terms"},uO={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"},ai={board:"board",boardIds:"board",medium:"medium",gradeLevel:"gradeLevel",subject:"subject",subjectIds:"subject",topicsIds:"topic",topic:"topic",targetBoardIds:"board",targetMediumIds:"medium",targetGradeLevelIds:"gradeLevel",targetSubjectIds:"subject"},Zl=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds"]);function qp(e,t,r,n,s={}){if(!(e!=null&&e.length))return gd(kO(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"&&Zl.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=vO(c),f=yO(c,r,t,i,s),g=t[u],p=fO(u,$p(g,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:dO(u,c.editable!==!1,s),placeholder:c.placeholder,maxLength:c.maxLength,options:mO(f,p,d,r),depends:c.depends,tab:gO(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 gd(a,r,t,n,s)}function gd(e,t,r,n,s){var i;return((i=s.profile)==null?void 0:i.key)==="learningPath"?IO(e,t,r,n):AO(e,t,r,n)}function dO(e,t,r){var i;const n=r.editorMode??"edit";if(!lO.has(n))return t!==!1;const s=(i=r.editableFields)==null?void 0:i[n];return!!(s&&s.includes(e))}function fO(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!==""?hO(Number(a)):t}default:return t}}function hO(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 pO(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 mO(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=pO(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 gO(e){const t=e.section;if(t){if(yi[t])return yi[t];const n=cO[t];if(n&&yi[n])return yi[n]}const r=e.code??"";return uO[r]??"details"}function $p(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 vO(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 yO(e,t,r,n,s){var u;const i=e.code??"";if(((u=s.profile)==null?void 0:u.key)==="learningPath"&&i==="policy")return Bp;if(i==="maxQuestions"){const d=s.childCount??0;if(d>0)return Array.from({length:d},(f,g)=>({label:String(g+1),value:String(g+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,g=(f&&f.length?f:s.contextAdditionalCategories)??t.channelAdditionalCategories;return g!=null&&g.length?_O(g).map(p=>({label:p,value:p})):void 0}const c=e.sourceCategory??ai[i];if(c)return Up(i,c,e,t,r,n)}function bO(e,t){return Zl.has(e)||t.output==="identifier"||typeof t.section=="string"&&t.section.includes("Target")}function CO(e,t){return Zl.has(e)||typeof t.section=="string"&&t.section.includes("Target")}function fa(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 SO(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 _O(e){return Array.from(new Set(e))}function wO(e){return Array.isArray(e)?e:e!=null&&e!==""?[e]:[]}function Up(e,t,r,n,s,i){const o=bO(e,r),a=CO(e,r),c=h=>({label:h.name,value:o?h.identifier:h.name}),u=r.depends;if(!(u!=null&&u.length))return fa(n,t,a).map(c);const d=u.flatMap(h=>wO(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)??ai[h]??h;f.push(...fa(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=SO(p);return b.length?b.map(c):fa(n,t,a).map(c)}function bs(e,t){const r=ai[e];if(r)return Up(e,r,{},t,{},new Map)}function Je(e,t,r){return $p(e[t],r)}const xO=["board","medium","gradeLevel","subject"];function TO(e){var r;const t=((r=e.organisationFramework)==null?void 0:r.categories)??[];return t.length?t.some(n=>xO.includes(n.code)):!0}function EO(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 AO(e,t,r,n){var c;if(!n||TO(t))return e;const s=e.filter(u=>{const d=u.sourceCategory??ai[u.code];return!d||EO(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:Je(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 ha="Organisation Framework Terms";function IO(e,t,r,n){var g,p;if(!n)return e;const s=[...((g=t.organisationFramework)==null?void 0:g.categories)??[]].sort((b,h)=>(b.index??1/0)-(h.index??1/0));if(!s.length)return e;const i=(p=kh(s))==null?void 0:p.code,o=b=>b.sourceCategory??ai[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:ha}: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:ha,options:t.orgFrameworks,currentValue:Je(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:"multiselect",editable:!0,tab:"details",section:ha,options:(b.terms??[]).map(h=>({label:h.name,value:h.name})),currentValue:Je(r,b.code,"multiselect")}));return f.length?[...c.slice(0,u+1),...f,...c.slice(u+1)]:c}function kO(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:Je(e,"name","text")},{code:"description",label:"Description",inputType:"textarea",editable:!0,tab:"details",section:"First Section",maxLength:2e3,currentValue:Je(e,"description","textarea")},{code:"keywords",label:"Keywords",inputType:"chips",editable:!0,tab:"details",section:"First Section",currentValue:Je(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:Je(e,"framework","select")},{code:"policy",label:"Consumption policy",inputType:"select",required:!0,editable:!0,tab:"details",section:"Consumption policy",options:Bp,currentValue:Je(e,"policy","select")||"Fixed"}),s):(s.push({code:"primaryCategory",label:"Category",inputType:"select",editable:!1,tab:"details",section:"Second Section",currentValue:Je(e,"primaryCategory","select")},{code:"additionalCategories",label:"Additional Category",inputType:"multiselect",editable:!0,tab:"details",section:"Second Section",currentValue:Je(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:Je(e,"framework","select")},{code:"subjectIds",label:"Subjects covered",inputType:"multiselect",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:bs("subjectIds",r),currentValue:Je(e,"subjectIds","multiselect")}),s.push({code:"audience",label:"Audience Type",inputType:"multiselect",editable:!0,tab:"audience",section:"Target Framework Terms",currentValue:Je(e,"audience","multiselect")},{code:"targetBoardIds",label:"Board/Syllabus of the audience",inputType:"select",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",options:bs("targetBoardIds",r),currentValue:Je(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:bs("targetMediumIds",r),currentValue:Je(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:bs("targetGradeLevelIds",r),currentValue:Je(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:bs("targetSubjectIds",r),currentValue:Je(e,"targetSubjectIds","multiselect")}),s.push({code:"creator",label:"Author",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"creator","text")},{code:"attributions",label:"Attributions",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"attributions","text")},{code:"copyright",label:"Copyright",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"copyright","text")},{code:"copyrightYear",label:"Copyright Year",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"copyrightYear","text")},{code:"license",label:"License",inputType:"select",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"license","select")}),s):s}const DO=["allowECM","levels","setPeriod","instances"];function zp(e){const t={};return e.forEach((r,n)=>{t[`L${n+1}`]={label:r}}),t}function LO(e,t={}){const r={...e};for(const i of DO)delete r[i];const n=e.levels;Array.isArray(n)&&n.length&&(r.outcomeDeclaration={levels:zp(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 OO(e,t){return e==="allowECM"||e==="setPeriod"?null:e==="levels"?{outcomeDeclaration:{levels:Array.isArray(t)?zp(t):{}}}:e==="instances"?{instances:t!=null&&t!==""?{label:t}:""}:{[e]:t}}function NO(e,t){const{watch:r,setValue:n}=e,s=m.useRef(!1);m.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(g=>u.has(g))&&(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 jO="_section_qa0tm_1",PO="_header_qa0tm_11",RO="_title_qa0tm_17",FO="_description_qa0tm_24",MO="_divider_qa0tm_30",BO="_fields_qa0tm_36",On={section:jO,header:PO,title:RO,description:FO,divider:MO,fields:BO},qO=({title:e,description:t,children:r})=>l.jsxs("div",{className:On.section,children:[l.jsxs("div",{className:On.header,children:[l.jsx("h3",{className:On.title,children:e}),t&&l.jsx("p",{className:On.description,children:t})]}),l.jsx("hr",{className:On.divider}),l.jsx("div",{className:On.fields,children:r})]}),$O="_field_93co8_1",UO="_fullWidth_93co8_7",zO="_label_93co8_11",VO="_required_93co8_19",HO="_input_93co8_24",QO="_textarea_93co8_45",WO="_inputError_93co8_50",GO="_error_93co8_54",KO="_selectBtn_93co8_59",YO="_selectOpen_93co8_83",ZO="_placeholder_93co8_87",XO="_selectedVal_93co8_91",JO="_chevronUp_93co8_95",eN="_dropdown_93co8_100",tN="_option_93co8_116",rN="_optionSelected_93co8_134",nN="_noOpts_93co8_139",sN="_chipGroup_93co8_146",iN="_chipInput_93co8_158",oN="_addChipBtn_93co8_167",aN="_radioGroup_93co8_184",lN="_radioLabel_93co8_191",cN="_iconWrap_93co8_199",uN="_iconPreview_93co8_214",dN="_iconPlaceholder_93co8_220",fN="_removeIconBtn_93co8_233",hN="_tagChip_93co8_252",pN="_tagChipRemove_93co8_264",mN="_nestedSelectRow_93co8_278",gN="_dialcodeRow_93co8_287",vN="_validateBtn_93co8_293",yN="_dialcodeValid_93co8_315",bN="_dialcodeSpinner_93co8_325",q={field:$O,fullWidth:UO,label:zO,required:VO,input:HO,textarea:QO,inputError:WO,error:GO,selectBtn:KO,selectOpen:YO,placeholder:ZO,selectedVal:XO,chevronUp:JO,dropdown:eN,option:tN,optionSelected:rN,noOpts:nN,chipGroup:sN,chipInput:iN,addChipBtn:oN,radioGroup:aN,radioLabel:lN,iconWrap:cN,iconPreview:uN,iconPlaceholder:dN,removeIconBtn:fN,tagChip:hN,tagChipRemove:pN,nestedSelectRow:mN,dialcodeRow:gN,validateBtn:vN,dialcodeValid:yN,dialcodeSpinner:bN},vd=({name:e,label:t,required:r,disabled:n,multiline:s,maxLength:i,placeholder:o})=>{const a=ae(),{register:c,formState:{errors:u}}=er(),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)})]})},CN=({name:e,label:t,options:r,required:n,disabled:s})=>{var v;const i=ae(),[o,a]=m.useState(!1),c=m.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:g}}=er(),p=d(e),b=((v=r.find(y=>y.value===p))==null?void 0:v.label)??i.selectField.selectPlaceholder,h=g[e];return m.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(bn,{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(yn,{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)})]})},SN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=ae(),[o,a]=m.useState(!1),c=m.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:g}}=er(),p=d(e)??[],b=g[e],h=p.length?`${p.length} ${i.multiSelectField.selectedCountSuffix}`:i.multiSelectField.selectPlaceholder;m.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(bn,{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(yn,{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)})]})},_N=({name:e,label:t,required:r,disabled:n,placeholder:s})=>{const i=ae(),o=s??i.chipGroupField.addPlaceholder,[a,c]=m.useState(""),[u,d]=m.useState(!1),f=m.useRef(null),{watch:g,setValue:p,formState:{errors:b}}=er(),h=g(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(Cn,{size:12})," ",i.chipGroupField.addButtonLabel]}))]}),v&&l.jsx("span",{className:q.error,children:String(v.message)})]})},wN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=ae(),{register:o,formState:{errors:a}}=er(),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 xN(e,t,r,n){var o,a;const i=(a=(o=(await Re.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 TN(e,t){var s,i;const n=(i=(s=(await Re.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 EN(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 AN(e,t,r){var o,a;const n=new FormData;n.append("fileUrl",t),n.append("mimeType",r);const i=(a=(o=(await Re.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 IN="_overlay_1bq5u_1",kN="_modal_1bq5u_12",DN="_header_1bq5u_24",LN="_title_1bq5u_33",ON="_closeBtn_1bq5u_39",NN="_tabs_1bq5u_57",jN="_tab_1bq5u_57",PN="_activeTab_1bq5u_83",RN="_body_1bq5u_88",FN="_searchWrap_1bq5u_99",MN="_searchIcon_1bq5u_104",BN="_searchInput_1bq5u_113",qN="_grid_1bq5u_132",$N="_imgCell_1bq5u_148",UN="_imgCellSelected_1bq5u_166",zN="_thumb_1bq5u_171",VN="_noThumb_1bq5u_177",HN="_checkBadge_1bq5u_183",QN="_loadMoreBtn_1bq5u_198",WN="_loadingRow_1bq5u_220",GN="_empty_1bq5u_230",KN="_spinner_1bq5u_237",YN="_uploadArea_1bq5u_247",ZN="_dropZone_1bq5u_256",XN="_uploadIcon_1bq5u_277",JN="_dropText_1bq5u_281",ej="_dropSubtext_1bq5u_288",tj="_uploadPreview_1bq5u_294",rj="_hiddenInput_1bq5u_301",nj="_fileName_1bq5u_305",sj="_errorText_1bq5u_311",ij="_footer_1bq5u_318",oj="_cancelBtn_1bq5u_328",aj="_confirmBtn_1bq5u_345",Ae={overlay:IN,modal:kN,header:DN,title:LN,closeBtn:ON,tabs:NN,tab:jN,activeTab:PN,body:RN,searchWrap:FN,searchIcon:MN,searchInput:BN,grid:qN,imgCell:$N,imgCellSelected:UN,thumb:zN,noThumb:VN,checkBadge:HN,loadMoreBtn:QN,loadingRow:WN,empty:GN,spinner:KN,uploadArea:YN,dropZone:ZN,uploadIcon:XN,dropText:JN,dropSubtext:ej,uploadPreview:tj,hiddenInput:rj,fileName:nj,errorText:sj,footer:ij,cancelBtn:oj,confirmBtn:aj},yd=18,Vp=({nodeId:e,currentValue:t,onSelect:r,onClose:n})=>{const s=ae(),[i,o]=m.useState("my"),[a,c]=m.useState(""),[u,d]=m.useState([]),[f,g]=m.useState(0),[p,b]=m.useState(!1),[h,v]=m.useState(null),[y,C]=m.useState(0),[S,_]=m.useState(null),[x,E]=m.useState(""),[D,T]=m.useState(!1),[j,F]=m.useState(""),O=m.useRef(null),N=Z(R=>{var M,Y;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.channel)??""}),B=Z(R=>{var M,Y;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.uid)??""}),P=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.cloudStorage)==null?void 0:le.presigned_headers)??{}}),U=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.config)==null?void 0:Y.assetConfig)==null?void 0:le.size)??1*1024*1024}),ne=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.config)==null?void 0:Y.assetConfig)==null?void 0:le.accepted)??"image/png,image/jpeg"}),H=m.useCallback(async(R,M,Y=!1)=>{var le;b(!0);try{const Ce={status:["Live"],mediaType:["image"],mimeType:["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml"]};i==="my"&&B&&(Ce.createdBy=B),N&&(Ce.channel=N);const ce=((le=(await Re.post("/action/composite/v3/search",{request:{filters:Ce,query:R,limit:yd,offset:M,sort_by:{createdOn:"desc"},fields:["identifier","name","appIcon","artifactUrl","downloadUrl"]}},{headers:{"X-Source":"web"}})).data)==null?void 0:le.result)??{},Q=ce.content??[];g(ce.count??0),d(se=>Y?[...se,...Q]:Q)}catch{}finally{b(!1)}},[i,B,N]);m.useEffect(()=>{i!=="upload"&&(d([]),C(0),H(a,0))},[i]);const te=m.useRef(),he=R=>{c(R),clearTimeout(te.current),te.current=setTimeout(()=>{d([]),C(0),H(R,0)},400)},oe=()=>{const R=y+yd;C(R),H(a,R,!0)},ge=()=>{const R=(h==null?void 0:h.artifactUrl)??(h==null?void 0:h.appIcon)??(h==null?void 0:h.downloadUrl)??"";R&&r(R)};m.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]);const ve=R=>{var le;const M=(le=R.target.files)==null?void 0:le[0];if(R.target.value="",!M)return;const Y=ne.split(",").map(Ce=>Ce.trim());if(!Y.includes(M.type)){const Ce=Y.map(de=>de.replace("image/","").toUpperCase()).join(", ");F(s.appIconPickerModal.invalidFileTypeError.replace("{types}",Ce));return}if(M.size>U){const Ce=(U/1048576).toFixed(0);F(s.appIconPickerModal.fileTooLargeError.replace("{size}",Ce));return}x&&URL.revokeObjectURL(x),_(M),E(URL.createObjectURL(M)),F("")},xe=async()=>{if(S){T(!0),F("");try{const R=await xN(S.name.split(".").slice(0,-1).join(".")||S.name,S.type,B,N),M=await TN(R,S.name);await EN(M,S,P);const Y=M.split("?")[0],le=await AN(R,Y,S.type);r(le)}catch(R){F(R instanceof Error?R.message:s.appIconPickerModal.uploadFailedError)}finally{T(!1)}}},ye=u.length<f;return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-label":s.appIconPickerModal.dialogAriaLabel,children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.header,children:[l.jsx("span",{className:Ae.title,children:s.appIconPickerModal.title}),l.jsx("button",{className:Ae.closeBtn,onClick:n,"aria-label":s.appIconPickerModal.closeAriaLabel,children:l.jsx(yr,{size:18})})]}),l.jsxs("div",{className:Ae.tabs,role:"tablist",children:[l.jsx("button",{role:"tab","aria-selected":i==="my",className:`${Ae.tab} ${i==="my"?Ae.activeTab:""}`,onClick:()=>o("my"),children:s.appIconPickerModal.myImagesTab}),l.jsx("button",{role:"tab","aria-selected":i==="all",className:`${Ae.tab} ${i==="all"?Ae.activeTab:""}`,onClick:()=>o("all"),children:s.appIconPickerModal.allImagesTab}),l.jsxs("button",{role:"tab","aria-selected":i==="upload",className:`${Ae.tab} ${i==="upload"?Ae.activeTab:""}`,onClick:()=>o("upload"),children:[l.jsx(Fa,{size:13,style:{marginRight:4}}),s.appIconPickerModal.uploadTab]})]}),l.jsx("div",{className:Ae.body,children:i!=="upload"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ae.searchWrap,children:[l.jsx(Wi,{size:14,className:Ae.searchIcon}),l.jsx("input",{type:"search",className:Ae.searchInput,placeholder:s.appIconPickerModal.searchPlaceholder,value:a,onChange:R=>he(R.target.value)})]}),p&&u.length===0?l.jsxs("div",{className:Ae.loadingRow,children:[l.jsx(Ti,{size:20,className:Ae.spinner}),l.jsx("span",{children:s.appIconPickerModal.loadingText})]}):u.length===0?l.jsx("div",{className:Ae.empty,children:s.appIconPickerModal.noImagesFound}):l.jsx("div",{className:Ae.grid,children:u.map(R=>{const M=R.appIcon??R.artifactUrl??R.downloadUrl??"",Y=(h==null?void 0:h.identifier)===R.identifier;return l.jsxs("button",{type:"button",className:`${Ae.imgCell} ${Y?Ae.imgCellSelected:""}`,onClick:()=>v(R),title:R.name,children:[M?l.jsx("img",{src:M,alt:R.name,className:Ae.thumb}):l.jsx("div",{className:Ae.noThumb,children:s.appIconPickerModal.noThumbnailText}),Y&&l.jsx("div",{className:Ae.checkBadge,children:l.jsx(yn,{size:12})})]},R.identifier)})}),ye&&!p&&l.jsx("button",{className:Ae.loadMoreBtn,onClick:oe,children:s.appIconPickerModal.loadMoreButton}),p&&u.length>0&&l.jsx("div",{className:Ae.loadingRow,children:l.jsx(Ti,{size:16,className:Ae.spinner})})]}):l.jsxs("div",{className:Ae.uploadArea,children:[l.jsx("div",{className:Ae.dropZone,onClick:()=>{var R;return(R=O.current)==null?void 0:R.click()},onDragOver:R=>R.preventDefault(),onDrop:R=>{R.preventDefault();const M=R.dataTransfer.files[0];M&&ve({target:{files:[M],value:""}})},children:x?l.jsx("img",{src:x,alt:s.appIconPickerModal.previewAlt,className:Ae.uploadPreview}):l.jsxs(l.Fragment,{children:[l.jsx(Fa,{size:32,className:Ae.uploadIcon}),l.jsx("p",{className:Ae.dropText,children:s.appIconPickerModal.dropZoneText}),l.jsx("p",{className:Ae.dropSubtext,children:s.appIconPickerModal.acceptedTypesInfo.replace("{types}",ne.split(",").map(R=>R.replace("image/","").toUpperCase()).join(", ")).replace("{size}",(U/(1024*1024)).toFixed(0))})]})}),l.jsx("input",{ref:O,type:"file",accept:ne,className:Ae.hiddenInput,onChange:ve}),S&&l.jsx("p",{className:Ae.fileName,children:S.name}),j&&l.jsx("p",{className:Ae.errorText,children:j})]})}),l.jsxs("div",{className:Ae.footer,children:[l.jsx("button",{className:Ae.cancelBtn,onClick:n,children:s.appIconPickerModal.cancelButton}),i==="upload"?l.jsx("button",{className:Ae.confirmBtn,disabled:!S||D,onClick:xe,children:D?l.jsxs(l.Fragment,{children:[l.jsx(Ti,{size:14,className:Ae.spinner})," ",s.appIconPickerModal.uploadingText]}):s.appIconPickerModal.uploadAndUseButton}):l.jsx("button",{className:Ae.confirmBtn,disabled:!h,onClick:ge,children:s.appIconPickerModal.useSelectedButton})]})]})})},lj=({name:e,label:t,nodeId:r,required:n,disabled:s})=>{const i=ae(),[o,a]=m.useState(!1),{watch:c,setValue:u,register:d,formState:{errors:f}}=er(),g=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:g?l.jsx("img",{src:g,alt:i.appIconField.iconAlt,className:q.iconPreview}):l.jsxs("div",{className:q.iconPlaceholder,children:[l.jsx(Mf,{size:20}),l.jsx("span",{children:i.appIconField.selectIconLabel})]})}),g&&!s&&l.jsxs("button",{type:"button",className:q.removeIconBtn,onClick:h,"aria-label":i.appIconField.removeIconAriaLabel,children:[l.jsx(Co,{size:13}),l.jsx("span",{children:i.appIconField.removeLabel})]}),p&&l.jsx("span",{className:q.error,children:String(p.message)}),o&&l.jsx(Vp,{nodeId:r,currentValue:g,onSelect:b,onClose:()=>a(!1)})]})},cj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({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)})]})},uj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({name:e,control:i,rules:{required:r?s.keywordSuggestField.requiredError.replace("{field}",t):!1},defaultValue:[]}),[c,u]=m.useState(""),d=m.useRef(null),f=o.value??[],g=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(),g(c),u("")):v.key==="Backspace"&&c===""&&f.length>0&&p(f[f.length-1])},h=()=>{c.trim()&&(g(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(yr,{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)})]})},dj=({name:e,label:t,levels:r,required:n,disabled:s})=>{const i=ae(),{control:o}=er(),{field:a,fieldState:{error:c}}=oi({name:e,control:o,rules:{required:n?i.nestedSelectField.requiredError.replace("{field}",t):!1},defaultValue:{}}),u=a.value??{},d=(f,g,p)=>{const b={};for(let h=0;h<g;h++)b[r[h].code]=u[r[h].code]??"";b[f]=p;for(let h=g+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,g)=>{const p=g>0&&!u[r[g-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,g,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)})]})},bd=[{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"}],fj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),[i,o]=m.useState(!1),a=m.useRef(null),{register:c,watch:u,setValue:d,formState:{errors:f}}=er(),g=u(e),p=bd.find(v=>v.value===g),b=(p==null?void 0:p.label)??s.licenseSelectField.selectPlaceholder,h=f[e];return m.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:g?q.selectedVal:q.placeholder,children:b}),l.jsx(bn,{size:14,className:i?q.chevronUp:""})]}),i&&l.jsx("div",{className:q.dropdown,role:"listbox",children:bd.map(v=>l.jsxs("button",{type:"button",role:"option","aria-selected":g===v.value,className:[q.option,g===v.value?q.optionSelected:""].join(" "),onClick:()=>{d(e,v.value,{shouldDirty:!0,shouldValidate:!0}),o(!1)},children:[l.jsx("span",{children:v.label}),g===v.value&&l.jsx(yn,{size:13})]},v.value))}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},hj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({name:e,control:i,rules:{required:r?s.dialcodeInputField.requiredError.replace("{field}",t):!1},defaultValue:""}),[c,u]=m.useState("idle"),[d,f]=m.useState(""),g=async()=>{const b=(o.value??"").trim();if(!b){u("invalid"),f(s.dialcodeInputField.enterCodeMessage);return}u("loading"),f("");try{const h=await p0(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(Ti,{size:16,className:q.dialcodeSpinner}):c==="valid"?l.jsx(Nf,{size:16,color:"var(--sbx-success, #2e7d32)"}):c==="invalid"?l.jsx(Sy,{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:g,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})]})},pj="_cards_1oc2m_1",mj="_card_1oc2m_1",gj="_cardActive_1oc2m_30",vj="_cardIcon_1oc2m_35",yj="_cardIconPrimary_1oc2m_46",bj="_cardIconHover_1oc2m_50",Cj="_radioDot_1oc2m_54",Sj="_radioDotActive_1oc2m_65",_j="_cardTitle_1oc2m_70",wj="_cardTitleInk_1oc2m_76",xj="_cardDescription_1oc2m_80",Tj="_cardDescriptionCharcoal_1oc2m_86",$t={cards:pj,card:mj,cardActive:gj,cardIcon:vj,cardIconPrimary:yj,cardIconHover:bj,radioDot:Cj,radioDotActive:Sj,cardTitle:_j,cardTitleInk:wj,cardDescription:xj,cardDescriptionCharcoal:Tj},Ej=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),o=[{value:"Fixed",Icon:Bf,iconVariant:$t.cardIconPrimary,title:s.learningPath.policyStrictLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyStrictDescription}),descriptionVariant:""},{value:"Diagnostic",Icon:Hy,iconVariant:$t.cardIconPrimary,title:s.learningPath.policyAdaptiveLabel,titleVariant:$t.cardTitleInk,description:l.jsxs(l.Fragment,{children:[s.learningPath.policyAdaptiveDescriptionPre,l.jsx("span",{className:q.required,children:"*"}),s.learningPath.policyAdaptiveDescriptionPost]}),descriptionVariant:$t.cardDescriptionCharcoal},{value:"PriorLearning",Icon:My,iconVariant:$t.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($L,{name:e,control:i,rules:{required:r?s.selectField.requiredError.replace("{field}",t):!1},render:({field:a})=>l.jsx("div",{className:$t.cards,children:o.map(({value:c,Icon:u,iconVariant:d,title:f,titleVariant:g,description:p,descriptionVariant:b})=>{const h=a.value===c;return l.jsxs("button",{type:"button",disabled:n,className:[$t.card,h?$t.cardActive:""].join(" "),onClick:()=>a.onChange(c),children:[l.jsx("span",{className:[$t.cardIcon,d].join(" "),children:l.jsx(u,{size:16})}),l.jsx("span",{className:[$t.radioDot,h?$t.radioDotActive:""].join(" ")}),l.jsx("span",{className:[$t.cardTitle,g].join(" "),children:f}),l.jsx("span",{className:[$t.cardDescription,b].join(" "),children:p})]},c)})})})]})},Aj="_form_lktqh_1",Ij="_formLp_lktqh_7",kj="_ungrouped_lktqh_12",Dj="_ungroupedLp_lktqh_23",Lj="_fullWidthField_lktqh_27",Oj="_noFields_lktqh_31",Nn={form:Aj,formLp:Ij,ungrouped:kj,ungroupedLp:Dj,fullWidthField:Lj,noFields:Oj},Nj=({nodeMetadata:e,activeTab:t,isRoot:r,isFolder:n,editorMode:s,onFormValueChange:i,onFormStatusChange:o})=>{var ee,He,Ge,Ze,Qe,tt,st,Kr,_n;const a=ae(),c=Z(K=>K.editorConfig),u=Z(K=>K.editorProfile),d=u.key==="learningPath",f=Z(K=>K.rootFormConfig),g=Z(K=>K.unitFormConfig),p=Z(K=>K.categoryMeta),b=Z(K=>K.contentFramework),h=Z(K=>K.contentTargetFWIds),{organisationFramework:v,targetFrameworks:y,isLoading:C}=Eo(b??((ee=c==null?void 0:c.context)==null?void 0:ee.framework),h??((He=c==null?void 0:c.context)==null?void 0:He.targetFWIds)),{frameworks:S,collectionAdditionalCategories:_,contentAdditionalCategories:x,defaultLicense:E,name:D}=iO((Ge=c==null?void 0:c.context)==null?void 0:Ge.channel),T=oO(((Ze=c==null?void 0:c.context)==null?void 0:Ze.userId)??((Qe=c==null?void 0:c.context)==null?void 0:Qe.uid)),j=sO(S,(tt=p==null?void 0:p.frameworkMetadata)==null?void 0:tt.orgFWType,(st=c==null?void 0:c.context)==null?void 0:st.channel),F={organisationFramework:v,targetFrameworks:y,orgFrameworks:j,channelAdditionalCategories:_},O=ue(K=>K.selectedNodeId),N=ue(K=>K.treeData),B=ue(K=>K.treeCache),P=O?B[O]??{}:{},U={...e,...P},ne=m.useMemo(()=>{var _e;if(!O)return 0;const K=[...N];for(;K.length;){const w=K.shift();if(w.id===O)return((_e=w.children)==null?void 0:_e.length)??0;w.children&&K.push(...w.children)}return 0},[N,O]),H=(c==null?void 0:c.config)??{},te=(c==null?void 0:c.context)??{},he={editorMode:s,editableFields:H.editableFields,objectType:H.objectType,setDefaultCopyRight:H.setDefaultCopyRight===!0,defaultLicense:te.defaultLicense??E,contextAdditionalCategories:te.additionalCategories,userFullName:((Kr=te.user)==null?void 0:Kr.fullName)??T,channelName:D,collectionAdditionalCategories:_,contentAdditionalCategories:x,childCount:ne,profile:u},oe=r?f:g,ge=oe||(((_n=c==null?void 0:c.config.hierarchy)==null?void 0:_n.formConfig)??[]),ve=qp(ge,U,F,r,he),xe=ve.filter(K=>K.tab===t&&K.inputType!=="appIcon"&&K.visible!==!1),ye=nO({mode:"onChange",defaultValues:Object.fromEntries(ve.map(K=>{const _e=["multiselect","chips","keywords","tagsinput"],w=["nestedselect"];return _e.includes(K.inputType)?[K.code,K.currentValue??K.defaultValue??[]]:w.includes(K.inputType)?[K.code,K.currentValue??K.defaultValue??{}]:[K.code,K.currentValue??K.defaultValue??""]}))});NO(ye,ve);const{updateNode:R}=ue(),M=m.useRef(ve);M.current=ve;const Y=m.useRef(O);Y.current=O;const le=m.useRef(i);le.current=i;const Ce=m.useRef(o);Ce.current=o;const de=m.useRef(typeof U.shuffle=="boolean"?U.shuffle:void 0),ce=m.useRef(U.name??"");ce.current=U.name??"";const Q=m.useRef(s);Q.current=s;const se=["review","read","sourcingreview","orgreview"];m.useEffect(()=>{const K=Y.current;if(K){const _e=Object.fromEntries(M.current.filter(w=>w.currentValue!==void 0&&w.currentValue!==null).map(w=>[w.code,w.currentValue]));Object.keys(_e).length>0&&R(K,_e)}ye.trigger().then(()=>{const _e=ye.formState.errors,w=M.current,k=Array.from(new Set(Object.keys(_e).map(L=>{var z;return(z=w.find(V=>V.code===L))==null?void 0:z.tab}).filter(Boolean)));Ce.current(Object.keys(_e).length===0,k)})},[]),m.useEffect(()=>{const K=ye.watch((_e,{name:w})=>{const k=Y.current;if(!k)return;const L=M.current,z=new Set(L.map($=>$.code));if(w&&z.has(w)){let $=ye.getValues(w);if(w==="dialcodes"&&($=Array.isArray($)?$:$?[$]:[]),w==="shuffle"&&($===!0&&de.current===!1&&we(a.sparkMetaForm.shuffleEnabledMessage,{icon:l.jsx(Ps,{size:16})}),de.current=$),w==="framework"&&r&&typeof $=="string"&&$){const be=Z.getState();if(be.setContentFramework($,be.contentTargetFWIds),d){const $e=ue.getState().pruneCoursesByFramework($);$e>0&&we(a.learningPath.coursesRemovedFrameworkChangeToast.replace("{count}",String($e)),{icon:l.jsx(Ps,{size:16}),duration:5e3})}}const re=OO(w,$);re&&(R(k,re),le.current(re))}else if(!w){const $=ye.getValues(),re=Object.fromEntries(Object.entries($).filter(([$e])=>z.has($e))),be=LO(re,{isReview:se.includes(Q.current),nodeTitle:ce.current});Object.keys(be).length>0&&(R(k,be),le.current(be))}const V=ye.formState.errors,G=Array.from(new Set(Object.keys(V).map($=>{var re;return(re=L.find(be=>be.code===$))==null?void 0:re.tab}).filter(Boolean)));Ce.current(Object.keys(V).length===0,G)});return()=>K.unsubscribe()},[ye]),m.useEffect(()=>{for(const K of["author","creator","copyright","copyrightYear","license"]){const _e=M.current.find(k=>k.code===K);if(!_e||_e.currentValue===void 0||_e.currentValue===null||_e.currentValue==="")continue;const w=ye.getValues(K);(w==null||w==="")&&ye.setValue(K,_e.currentValue,{shouldDirty:!1})}},[T,D,ye]);const Te=xe.reduce((K,_e)=>{const w=K[K.length-1];return w&&w.section===_e.section?w.fields.push(_e):K.push({section:_e.section,fields:[_e]}),K},[]),me=K=>{const _e={key:K.code,name:K.code,label:K.label,required:K.required,disabled:K.editable===!1};if(d&&K.code==="policy")return l.jsx("div",{className:Nn.fullWidthField,children:l.jsx(Ej,{..._e})},K.code);switch(K.inputType){case"textarea":return l.jsx(vd,{..._e,multiline:!0,maxLength:K.maxLength});case"select":return l.jsx(CN,{..._e,options:K.options??[]});case"multiselect":return l.jsx(SN,{..._e,options:K.options??[]});case"chips":return l.jsx(_N,{..._e});case"radio":return l.jsx(wN,{..._e,options:K.options??[]});case"appIcon":return l.jsx(lj,{..._e,nodeId:O??""});case"datepicker":case"datetime":return l.jsx(cj,{..._e});case"keywords":case"tagsinput":return l.jsx(uj,{..._e});case"nestedselect":return l.jsx(dj,{..._e,levels:K.levels??[]});case"license":return l.jsx(fj,{..._e});case"dialcode":return l.jsx(hj,{..._e});default:return l.jsx(vd,{..._e,maxLength:K.maxLength})}};return l.jsx(UL,{...ye,children:l.jsxs("div",{className:[Nn.form,d?Nn.formLp:""].filter(Boolean).join(" "),children:[Te.map((K,_e)=>{const w=K.section?aO[K.section]:void 0;return w?l.jsx(qO,{title:w.title,description:w.description,children:K.fields.map(me)},K.section??_e):l.jsx("div",{className:[Nn.ungrouped,d?Nn.ungroupedLp:""].filter(Boolean).join(" "),children:K.fields.map(me)},_e)}),xe.length===0&&!C&&l.jsx("p",{className:Nn.noFields,children:a.sparkMetaForm.noFieldsMessage})]})})};function Hp(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function jj(e,t){return e.reduce((r,n,s)=>{const i=t.get(n);return i&&(r[s]=i),r},Array(e.length))}function bi(e){return e!==null&&e>=0}function Pj(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 Rj(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Qp=e=>{let{rects:t,activeIndex:r,overIndex:n,index:s}=e;const i=Hp(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}},Ci={scaleX:1,scaleY:1},Fj=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,...Ci}:null}const c=Mj(i,s,r);return s>r&&s<=o?{x:0,y:-a.height-c,...Ci}:s<r&&s>=o?{x:0,y:a.height+c,...Ci}:{x:0,y:0,...Ci}};function Mj(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 Wp="Sortable",Gp=m.createContext({activeIndex:-1,containerId:Wp,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Qp,disabled:{draggable:!1,droppable:!1}});function Bj(e){let{children:t,id:r,items:n,strategy:s=Qp,disabled:i=!1}=e;const{active:o,dragOverlay:a,droppableRects:c,over:u,measureDroppableContainers:d}=Lf(),f=Ks(Wp,r),g=a.rect!==null,p=m.useMemo(()=>n.map(E=>typeof E=="object"&&"id"in E?E.id:E),[n]),b=o!=null,h=o?p.indexOf(o.id):-1,v=u?p.indexOf(u.id):-1,y=m.useRef(p),C=!Pj(p,y.current),S=v!==-1&&h===-1||C,_=Rj(i);or(()=>{C&&b&&d(p)},[C,p,b,d]),m.useEffect(()=>{y.current=p},[p]);const x=m.useMemo(()=>({activeIndex:h,containerId:f,disabled:_,disableTransforms:S,items:p,overIndex:v,useDragOverlay:g,sortedRects:jj(p,c),strategy:s}),[h,f,_.draggable,_.droppable,S,p,v,c,g,s]);return m.createElement(Gp.Provider,{value:x},t)}const qj=e=>{let{id:t,items:r,activeIndex:n,overIndex:s}=e;return Hp(r,n,s).indexOf(t)},$j=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},Uj={duration:200,easing:"ease"},Kp="transform",zj=Vr.Transition.toString({property:Kp,duration:0,easing:"linear"}),Vj={roleDescription:"sortable"};function Hj(e){let{disabled:t,index:r,node:n,rect:s}=e;const[i,o]=m.useState(null),a=m.useRef(r);return or(()=>{if(!t&&r!==a.current&&n.current){const c=s.current;if(c){const u=ss(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]),m.useEffect(()=>{i&&o(null)},[i]),i}function Qj(e){let{animateLayoutChanges:t=$j,attributes:r,disabled:n,data:s,getNewIndex:i=qj,id:o,strategy:a,resizeObserverConfig:c,transition:u=Uj}=e;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:b,sortedRects:h,overIndex:v,useDragOverlay:y,strategy:C}=m.useContext(Gp),S=Wj(n,p),_=d.indexOf(o),x=m.useMemo(()=>({sortable:{containerId:f,index:_,items:d},...s}),[f,s,_,d]),E=m.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:D,node:T,isOver:j,setNodeRef:F}=Jv({id:o,data:x,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...c}}),{active:O,activatorEvent:N,activeNodeRect:B,attributes:P,setNodeRef:U,listeners:ne,isDragging:H,over:te,setActivatorNodeRef:he,transform:oe}=Df({id:o,data:x,attributes:{...Vj,...r},disabled:S.draggable}),ge=Mg(F,U),ve=!!O,xe=ve&&!b&&bi(g)&&bi(v),ye=!y&&H,R=ye&&xe?oe:null,Y=xe?R??(a??C)({rects:h,activeNodeRect:B,activeIndex:g,overIndex:v,index:_}):null,le=bi(g)&&bi(v)?i({id:o,items:d,activeIndex:g,overIndex:v}):_,Ce=O==null?void 0:O.id,de=m.useRef({activeId:Ce,items:d,newIndex:le,containerId:f}),ce=d!==de.current.items,Q=t({active:O,containerId:f,isDragging:H,isSorting:ve,id:o,index:_,items:d,newIndex:de.current.newIndex,previousItems:de.current.items,previousContainerId:de.current.containerId,transition:u,wasDragging:de.current.activeId!=null}),se=Hj({disabled:!Q,index:_,node:T,rect:D});return m.useEffect(()=>{ve&&de.current.newIndex!==le&&(de.current.newIndex=le),f!==de.current.containerId&&(de.current.containerId=f),d!==de.current.items&&(de.current.items=d)},[ve,le,f,d]),m.useEffect(()=>{if(Ce===de.current.activeId)return;if(Ce&&!de.current.activeId){de.current.activeId=Ce;return}const me=setTimeout(()=>{de.current.activeId=Ce},50);return()=>clearTimeout(me)},[Ce]),{active:O,activeIndex:g,attributes:P,data:x,rect:D,index:_,newIndex:le,items:d,isOver:j,isSorting:ve,isDragging:H,listeners:ne,node:T,overIndex:v,over:te,setNodeRef:ge,setActivatorNodeRef:he,setDroppableNodeRef:F,setDraggableNodeRef:U,transform:se??Y,transition:Te()};function Te(){if(se||ce&&de.current.newIndex===_)return zj;if(!(ye&&!uo(N)||!u)&&(ve||Q))return Vr.Transition.toString({...u,property:Kp})}}function Wj(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 no(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 Gj=[Oe.Down,Oe.Right,Oe.Up,Oe.Left],Kj=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:i,over:o,scrollableAncestors:a}}=t;if(Gj.includes(e.code)){if(e.preventDefault(),!r||!n)return;const c=[];i.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=s.get(f.id);if(g)switch(e.code){case Oe.Down:n.top<g.top&&c.push(f);break;case Oe.Up:n.top>g.top&&c.push(f);break;case Oe.Left:n.left>g.left&&c.push(f);break;case Oe.Right:n.left<g.left&&c.push(f);break}});const u=tv({collisionRect:n,droppableRects:s,droppableContainers:c});let d=hf(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),g=i.get(d),p=g?s.get(g.id):null,b=g==null?void 0:g.node.current;if(b&&p&&f&&g){const v=fo(b).some((E,D)=>a[D]!==E),y=Yp(f,g),C=Yj(f,g),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?_:Ns(_,S)}}}};function Yp(e,t){return!no(e)||!no(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Yj(e,t){return!no(e)||!no(t)||!Yp(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const Zj="_row_1m6cn_1",Xj="_removeBtn_1m6cn_14",Jj="_grip_1m6cn_17",eP="_ctIcon_1m6cn_34",tP="_info_1m6cn_38",rP="_name_1m6cn_46",nP="_meta_1m6cn_55",Zr={row:Zj,removeBtn:Xj,grip:Jj,ctIcon:eP,info:tP,name:rP,meta:nP},sP={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},iP=({item:e,onRemove:t,isEditable:r})=>{const n=ae(),s=ni(e),i=sP[s.key]??Gr,{attributes:o,listeners:a,setNodeRef:c,transform:u,transition:d,isDragging:f}=Qj({id:e.id,disabled:!r}),g={transform:Vr.Transform.toString(u),transition:d,opacity:f?.5:1};return l.jsxs("div",{ref:c,style:g,className:Zr.row,role:"listitem",children:[r&&l.jsx("span",{className:Zr.grip,...o,...a,"aria-label":n.contentRow.dragToReorderAriaLabel,children:l.jsx(Ff,{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(yr,{size:14})})]})},oP="_container_1ls1w_1",aP="_header_1ls1w_7",lP="_heading_1ls1w_13",cP="_count_1ls1w_21",uP="_list_1ls1w_30",dP="_emptyState_1ls1w_36",fP="_skillPicker_1ls1w_52",hP="_skillsCovered_1ls1w_52",pP="_chips_1ls1w_64",mP="_chip_1ls1w_64",gP="_skillWarning_1ls1w_80",vP="_selectedSkills_1ls1w_85",yP="_skillPill_1ls1w_91",bP="_skillPillFlagged_1ls1w_103",CP="_skillPillRemove_1ls1w_107",SP="_skillSearchBox_1ls1w_122",_P="_skillSearchWrap_1ls1w_127",wP="_searchIcon_1ls1w_142",xP="_skillSearchInput_1ls1w_147",TP="_skillDropdown_1ls1w_160",EP="_skillOption_1ls1w_174",AP="_skillCheckbox_1ls1w_196",IP="_skillCheckboxChecked_1ls1w_208",kP="_skillDropdownEmpty_1ls1w_213",DP="_skillPickerNote_1ls1w_219",LP="_emptyHint_1ls1w_224",OP="_assessmentsCard_1ls1w_237",NP="_assessmentSlots_1ls1w_249",jP="_assessmentItemRow_1ls1w_255",PP="_assessmentItemIcon_1ls1w_266",RP="_assessmentItemInfo_1ls1w_278",FP="_assessmentItemTitle_1ls1w_285",MP="_assessmentItemMeta_1ls1w_294",BP="_addRowIcon_1ls1w_299",qP="_assessmentItemBadge_1ls1w_311",$P="_menuWrap_1ls1w_322",UP="_menuBtn_1ls1w_327",zP="_dropmenu_1ls1w_340",VP="_dangerItem_1ls1w_370",HP="_addRow_1ls1w_299",QP="_addRowAssessment_1ls1w_394",pe={container:oP,header:aP,heading:lP,count:cP,list:uP,emptyState:dP,skillPicker:fP,skillsCovered:hP,chips:pP,chip:mP,skillWarning:gP,selectedSkills:vP,skillPill:yP,skillPillFlagged:bP,skillPillRemove:CP,skillSearchBox:SP,skillSearchWrap:_P,searchIcon:wP,skillSearchInput:xP,skillDropdown:TP,skillOption:EP,skillCheckbox:AP,skillCheckboxChecked:IP,skillDropdownEmpty:kP,skillPickerNote:DP,emptyHint:LP,assessmentsCard:OP,assessmentSlots:NP,assessmentItemRow:jP,assessmentItemIcon:PP,assessmentItemInfo:RP,assessmentItemTitle:FP,assessmentItemMeta:MP,addRowIcon:BP,assessmentItemBadge:qP,menuWrap:$P,menuBtn:UP,dropmenu:zP,dangerItem:VP,addRow:HP,addRowAssessment:QP},WP=({options:e,selected:t,outOfScope:r,onChange:n,isEditable:s,description:i})=>{const o=ae(),[a,c]=m.useState(""),[u,d]=m.useState(!1),f=m.useRef(null);m.useEffect(()=>{if(!u)return;const h=v=>{var y;(y=f.current)!=null&&y.contains(v.target)||d(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[u]);const g=a?e.filter(h=>h.toLowerCase().includes(a.toLowerCase())):e,p=h=>{s&&n(t.includes(h)?t.filter(v=>v!==h):[...t,h])},b=h=>{s&&n(t.filter(v=>v!==h))};return l.jsxs("div",{className:pe.skillPicker,children:[l.jsxs("div",{className:pe.header,children:[l.jsx("span",{className:pe.heading,children:o.learningPath.skillsHeading}),l.jsx("span",{className:pe.count,children:t.length})]}),l.jsx("span",{className:pe.skillPickerNote,children:i}),r.length>0&&l.jsx("div",{className:pe.skillWarning,role:"alert",children:o.learningPath.skillsOutOfScopeWarning.replace("{skills}",r.join(", "))}),t.length>0&&l.jsx("div",{className:pe.selectedSkills,children:t.map(h=>{const v=r.includes(h);return l.jsxs("span",{className:[pe.skillPill,v?pe.skillPillFlagged:""].join(" "),children:[h,s&&l.jsx("button",{type:"button",className:pe.skillPillRemove,onClick:()=>b(h),"aria-label":o.learningPath.removeSkillAriaLabel.replace("{skill}",h),children:l.jsx(yr,{size:11})})]},h)})}),s?l.jsxs("div",{className:pe.skillSearchBox,ref:f,children:[l.jsxs("div",{className:pe.skillSearchWrap,onClick:()=>d(!0),children:[l.jsx("input",{type:"search",className:pe.skillSearchInput,placeholder:o.learningPath.searchSkillsPlaceholder,value:a,onChange:h=>c(h.target.value),onFocus:()=>d(!0),"aria-label":o.learningPath.searchSkillsPlaceholder}),l.jsx(Wi,{size:14,className:pe.searchIcon})]}),u&&l.jsx("div",{className:pe.skillDropdown,role:"listbox",children:e.length===0?l.jsx("div",{className:pe.skillDropdownEmpty,children:o.learningPath.noSkillsAvailable}):g.length===0?l.jsx("div",{className:pe.skillDropdownEmpty,children:o.learningPath.noMatchingSkills}):g.map(h=>{const v=t.includes(h);return l.jsxs("button",{type:"button",role:"option","aria-selected":v,className:pe.skillOption,onClick:()=>p(h),children:[l.jsx("span",{className:[pe.skillCheckbox,v?pe.skillCheckboxChecked:""].join(" "),children:v&&l.jsx(yn,{size:12})}),h]},h)})})]}):t.length===0&&l.jsx("span",{className:pe.emptyHint,children:o.learningPath.noSkillsSelectedYet})]})},ul=({slot:e,isEditable:t})=>{const r=ae(),{pre:n,post:s,setActiveAssessmentSlot:i,deleteSlot:o}=Vl(),a=ue(h=>h.selectNode),[c,u]=m.useState(!1),d=m.useRef(null),f=e==="pre"?n:s,g=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel;if(m.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:[pe.addRow,pe.addRowAssessment].join(" "),disabled:!t,onClick:()=>i(e),children:[l.jsx("span",{className:pe.addRowIcon,children:l.jsx(Cn,{size:16})}),r.learningPath.addAssessmentSlotButton.replace("{label}",g)]});const p=e==="pre"?r.learningPath.skillCheckBadge:r.learningPath.outcomeCheckBadge,b=()=>f.level&&a(f.level.id);return l.jsxs("div",{className:pe.assessmentItemRow,role:"button",tabIndex:0,onClick:b,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),b())},children:[l.jsx("span",{className:pe.assessmentItemIcon,children:l.jsx(Wr,{size:16})}),l.jsxs("div",{className:pe.assessmentItemInfo,children:[l.jsx("span",{className:pe.assessmentItemTitle,children:f.courseName||r.learningPath.courseNameUnavailable}),l.jsxs("span",{className:pe.assessmentItemMeta,children:[g," · ",r.learningPath.assessmentCourseMeta]})]}),l.jsx("span",{className:pe.assessmentItemBadge,children:p}),t&&l.jsxs("div",{className:pe.menuWrap,ref:d,children:[l.jsx("button",{type:"button",className:pe.menuBtn,onClick:h=>{h.stopPropagation(),u(v=>!v)},"aria-label":r.treeNode.nodeOptionsAriaLabel,children:"⋮"}),c&&l.jsxs("div",{className:pe.dropmenu,onClick:h=>h.stopPropagation(),children:[l.jsxs("button",{type:"button",onClick:()=>{u(!1),f.level&&a(f.level.id)},children:[l.jsx(xy,{size:12})," ",r.learningPath.viewCourseMenuItem]}),l.jsxs("button",{type:"button",className:pe.dangerItem,onClick:()=>{u(!1),o(e)},children:[l.jsx(Co,{size:12})," ",r.treeNode.deleteMenuItem]})]})]})]})},GP=({editorMode:e,isRoot:t=!1})=>{const r=ae(),{selectedNodeId:n,getChildrenOf:s,getNodeById:i,reorderChildren:o,deleteNode:a,activeNodeMeta:c,updateNode:u,treeData:d}=ue(),f=Z(N=>N.editorProfile),g=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}=Dh(),_=as(),x=_&&Array.isArray(c[_.code])?c[_.code]:[],E=S==="prior"?x.filter(N=>!C.includes(N)):[],D=y?u1(d[0],_==null?void 0:_.code):[],T=m.useCallback(N=>{!n||!(_!=null&&_.code)||u(n,{[_.code]:N},[_.code])},[n,_==null?void 0:_.code,u]),j=uf(Na(ho,{activationConstraint:{distance:5}}),Na(bl,{coordinateGetter:Kj})),F=m.useCallback(N=>{const{active:B,over:P}=N;if(!P||B.id===P.id||!n)return;const U=ue.getState().getChildrenOf(n),ne=U.findIndex(te=>te.id===B.id),H=U.findIndex(te=>te.id===P.id);ne<0||H<0||o(n,ne,H)},[n,o]),O=m.useCallback(N=>{window.confirm(r.unitContentList.removeConfirm)&&a(N)},[a,r.unitContentList.removeConfirm]);return n?l.jsxs("div",{className:pe.container,children:[y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:pe.skillsCovered,children:[l.jsx("span",{className:pe.heading,children:r.learningPath.skillsCoveredHeading}),l.jsx("span",{className:pe.emptyHint,children:r.learningPath.skillsCoveredDescription}),D.length>0&&l.jsx("div",{className:pe.chips,children:D.map(N=>l.jsx("span",{className:pe.chip,children:N},N))}),D.length===0&&l.jsx("span",{className:pe.emptyHint,children:r.learningPath.noSkillsYet})]}),l.jsxs("div",{className:pe.assessmentsCard,children:[l.jsx("span",{className:pe.heading,children:r.learningPath.assessmentsCardHeading}),l.jsx("span",{className:pe.emptyHint,children:r.learningPath.assessmentsCardDescription}),l.jsxs("div",{className:pe.assessmentSlots,children:[l.jsx(ul,{slot:"pre",isEditable:p}),l.jsx(ul,{slot:"post",isEditable:p})]})]})]}),v&&l.jsx(WP,{options:C,selected:x,outOfScope:E,onChange:T,isEditable:p,description:S==="prior"?r.learningPath.skillScopeFromPriorNote:r.learningPath.skillScopeManualNote}),!h&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:pe.header,children:[l.jsx("span",{className:pe.heading,children:r.unitContentList.heading}),l.jsx("span",{className:pe.count,children:g.length})]}),g.length>0?l.jsx(kf,{sensors:j,collisionDetection:ev,onDragEnd:F,children:l.jsx(Bj,{items:g.map(N=>N.id),strategy:Fj,children:l.jsx("div",{className:pe.list,role:"list",children:g.map(N=>l.jsx(iP,{item:N,onRemove:O,isEditable:p},N.id))})})}):l.jsxs("div",{className:pe.emptyState,children:[l.jsx("p",{children:r.unitContentList.emptyTitle}),l.jsx("span",{children:r.unitContentList.emptyHint})]}),p&&!lt(b)&&l.jsxs("button",{className:pe.addRow,type:"button","aria-label":r.unitContentList.addContentAriaLabel,children:[l.jsx(Cn,{size:14})," ",r.unitContentList.addContent]})]})]}):null},KP="_dropZone_ijo5w_1",YP="_active_ijo5w_14",Cd={dropZone:KP,active:YP},ZP=({isActive:e,label:t,nodeId:r,className:n})=>{const s=ae(),i=t??s.dropZone.dropHere;return l.jsx("div",{className:`${Cd.dropZone} ${e?Cd.active:""} ${n??""}`,"data-droppable":e?"true":void 0,"data-node-id":r,"aria-label":i,role:"region",children:l.jsx("span",{children:i})})},Zp=["identifier","name","mimeType","contentType","primaryCategory","appIcon","channel","organisation","pkgVersion"];async function XP(e){var o;const t={status:["Live"],...e.filters??{}};e.channel&&(t.channel=e.channel);const n=((o=(await Re.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??Zp}},{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 JP(e){var r,n;return(n=(r=(await Re.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}const Sd="application/vnd.sunbird.question";function _d(e){return{cardinality:"single",type:"integer",defaultValue:e.maxScore??1}}function Xp(e,t,r){if(!e)return null;if(e.identifier===t)return{question:e,parent:r};for(const n of e.children??[]){const s=Xp(n,t,e);if(s)return s}return null}function eR(e,t){const r=Xp(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 tR(e,t){const r=((t==null?void 0:t.enabled)??!0)&&!!e;return Zn({queryKey:["quml","questionset",e],enabled:r,queryFn:async()=>{const n=await mh(e),s=d=>{if(!d)return[];const f=d.mimeType===Sd&&d.identifier?[d.identifier]:[],g=(d.children??[]).flatMap(s);return[...f,...g]},i=s(n),o=new Map;i.length&&(await Yx(i)).forEach(f=>{const g=f.identifier;g&&o.set(g,f)});const a=d=>{if(!d)return d;if(d.mimeType===Sd&&d.identifier){const f=o.get(d.identifier)??d,g=f.outcomeDeclaration;return g!=null&&g.maxScore||(f.outcomeDeclaration={...g??{},maxScore:_d(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:_d(c)}),c}})}const wd="/assets/quml-player/sunbird-quml-player.js",rR="/assets/quml-player/styles.css",xd="sunbird-quml-player";function nR(e){const t=e.children??[];return t.length?t.every(n=>n.objectType==="Question")?[e]:t:[]}const ut=class ut{constructor(){fs(this,"eventHandlers",new WeakMap)}loadScript(){return ut.scriptLoaded||customElements.get(xd)?(ut.scriptLoaded=!0,Promise.resolve()):(ut.scriptLoading||(ut.scriptLoading=new Promise((t,r)=>{const n=document.createElement("script");n.src=wd,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: ${wd}`))},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=rR,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:nR(t),identifier:t.identifier??""},metadata:t}}createElement(t){this.loadStyles();const r=document.createElement(xd);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))}};fs(ut,"scriptLoaded",!1),fs(ut,"scriptLoading"),fs(ut,"stylesLoaded",!1);let so=ut;const Si=new so,sR="_contentPlayerRoot_1rdfn_1",iR="_flowLayout_1rdfn_9",oR="_stage_1rdfn_13",aR="_aspectRatio_1rdfn_16",lR="_playerHeader_1rdfn_32",cR="_playerHeaderThumb_1rdfn_46",uR="_playerHeaderTitle_1rdfn_56",dR="_typeBadge_1rdfn_66",fR="_typeDot_1rdfn_105",hR="_playerFrame_1rdfn_125",pR="_coverOverlay_1rdfn_133",mR="_coverHidden_1rdfn_145",gR="_coverThumb_1rdfn_150",vR="_coverPlayRing_1rdfn_159",yR="_coverPlayIcon_1rdfn_172",bR="_coverLabel_1rdfn_181",CR="_coverSkeleton_1rdfn_187",SR="_playerWrapper_1rdfn_213",_R="_infoStrip_1rdfn_223",wR="_infoChip_1rdfn_239",xR="_infoChipLabel_1rdfn_258",TR="_infoChipIcon_1rdfn_267",ER="_playerError_1rdfn_273",AR="_playerErrorIcon_1rdfn_287",IR="_playerErrorMsg_1rdfn_292",kR="_qumlRoot_1rdfn_299",Ve={contentPlayerRoot:sR,flowLayout:iR,stage:oR,aspectRatio:aR,playerHeader:lR,playerHeaderThumb:cR,playerHeaderTitle:uR,typeBadge:dR,typeDot:fR,playerFrame:hR,coverOverlay:pR,coverHidden:mR,coverThumb:gR,coverPlayRing:vR,coverPlayIcon:yR,coverLabel:bR,coverSkeleton:CR,playerWrapper:SR,infoStrip:_R,infoChip:wR,infoChipLabel:xR,infoChipIcon:TR,playerError:ER,playerErrorIcon:AR,playerErrorMsg:IR,qumlRoot:kR},DR="application/vnd.sunbird.questionset";function LR(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===DR)return s.identifier;s=s.parent?r.get(s.parent):void 0}return null}const OR=[{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 NR(e){return OR.find(t=>t.mimes.includes(e))??{key:"other"}}function jR(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 PR={"pdf-player":["application/pdf"],"video-player":["video/mp4","video/webm"],"epub-player":["application/epub"]},RR={"pdf-player":"/assets/sunbird-pdf-player.js","video-player":"/assets/sunbird-video-player.js","epub-player":"/assets/sunbird-epub-player.js"},FR={"pdf-player":"sunbird-pdf-player","video-player":"sunbird-video-player","epub-player":"sunbird-epub-player"},MR="/content/preview/preview.html?webview=true&build_number=2.8.0.e552fcd";function pa(e){for(const[t,r]of Object.entries(PR))if(r.includes(e))return t;return"default-player"}function BR(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 qR(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 $R(e,t,r=100){await qR(RR[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 UR=[{key:"author",icon:zy},{key:"license",icon:Py},{key:"language",icon:Ey},{key:"gradeLevel",icon:Ry},{key:"subject",icon:Wr},{key:"contentType",icon:$y}];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 VR({node:e}){const t=ae(),r=e.metadata??{},n=UR.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:Ve.infoStrip,children:n.map(s=>l.jsxs("div",{className:Ve.infoChip,children:[s.icon&&l.jsx(s.icon,{size:13,className:Ve.infoChipIcon}),l.jsx("span",{className:Ve.infoChipLabel,children:s.label}),s.val]},s.key))}):null}function Jp({node:e,hidden:t}){var s;const r=ae(),n=e.appIcon??((s=e.metadata)==null?void 0:s.appIcon);return l.jsx("div",{className:`${Ve.coverOverlay} ${t?Ve.coverHidden:""}`,children:n?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:n,alt:e.name,className:Ve.coverThumb}),l.jsx("div",{className:Ve.coverPlayRing,children:l.jsx("div",{className:Ve.coverPlayIcon})}),l.jsx("span",{className:Ve.coverLabel,children:r.contentPlayer.loadingPreview})]}):l.jsx("div",{className:Ve.coverSkeleton})})}function em({message:e}){return l.jsxs("div",{className:Ve.playerError,children:[l.jsx(Uy,{size:28,className:Ve.playerErrorIcon}),l.jsx("span",{className:Ve.playerErrorMsg,children:e})]})}function HR({mimeType:e}){const t=ae(),r=NR(e);return l.jsxs("span",{className:Ve.typeBadge,"data-type":r.key,children:[l.jsx("span",{className:Ve.typeDot}),jR(r.key,t)]})}const dl=({node:e,editorMode:t,type:r,singleQuestion:n,layout:s="fill"})=>{var o;if(r==="quml")return l.jsx(WR,{node:e,editorMode:t,singleQuestion:!!n});const i=e.appIcon??((o=e.metadata)==null?void 0:o.appIcon);return l.jsxs("div",{className:`${Ve.contentPlayerRoot} ${s==="flow"?Ve.flowLayout:""}`,children:[l.jsxs("div",{className:Ve.stage,children:[l.jsxs("div",{className:Ve.playerHeader,children:[i&&l.jsx("img",{src:i,alt:"",className:Ve.playerHeaderThumb}),l.jsx("span",{className:Ve.playerHeaderTitle,children:e.name}),l.jsx(HR,{mimeType:e.mimeType??""})]}),l.jsx(QR,{node:e})]}),l.jsx(VR,{node:e})]})};function QR({node:e}){var y;const t=ae(),r=Z(C=>C.editorConfig),[n,s]=m.useState(()=>pa(e.mimeType??"")),[i,o]=m.useState(!1),[a,c]=m.useState(null),[u,d]=m.useState(e.metadata??{}),[f,g]=m.useState(!1),p=m.useRef(null),b=m.useRef(null),h=((y=r==null?void 0:r.config)==null?void 0:y.previewCdnUrl)??MR;m.useEffect(()=>{let C=!1;return g(!1),o(!1),c(null),d(e.metadata??{}),s(pa(e.mimeType??"")),JP(e.identifier).then(S=>{if(C)return;const _={...e.metadata??{},...S};d(_);const x=S.mimeType??e.mimeType??"";s(pa(x)),g(!0)}).catch(()=>{C||g(!0)}),()=>{C=!0}},[e.identifier]);const v=BR(e,u,r);return m.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]),m.useEffect(()=>{if(!f||n==="default-player")return;const C=b.current;if(!C)return;const S=FR[n];if(!S)return;const _=v;$R(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:Ve.aspectRatio,children:[a?l.jsx(em,{message:a}):l.jsx(Jp,{node:e,hidden:i}),n==="default-player"?l.jsx("iframe",{ref:p,id:"contentPlayer",title:e.name,className:Ve.playerFrame,name:"contentPlayer",allowFullScreen:!0}):l.jsx("div",{ref:b,className:Ve.playerFrame})]})}function WR({node:e,editorMode:t,singleQuestion:r}){const n=ae(),s=Z(p=>p.editorConfig),i=ue(p=>p.treeData),o=m.useRef(null),a=r?LR(i,e.id):e.identifier,{data:c,isLoading:u,error:d}=tR(a??"",{enabled:!!a}),f=m.useMemo(()=>c?r?eR(c,e.identifier):c:null,[c,r,e.identifier]);m.useEffect(()=>{const p=o.current;if(!p||!f)return;let b=null,h=!1;return(async()=>{try{const v=await Si.createConfig(f,s==null?void 0:s.context,{mode:t==="edit"?"edit":"play"});if(h||!o.current)return;const y=Si.createElement(v);b=y,Si.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&&(Si.removeEventListeners(b),b.remove()),so.unloadStyles()}},[f,s,t,r]);const g=d?`${n.contentPlayer.unableToLoadQuestionset} ${d.message}`:r&&!a?n.contentPlayer.parentQuestionsetNotResolved:r&&c&&!f?n.contentPlayer.questionNotFoundInQuestionset:null;return l.jsxs("div",{className:Ve.qumlRoot,children:[g?l.jsx(em,{message:g}):u||!f?l.jsx(Jp,{node:e,hidden:!1}):null,l.jsx("div",{ref:o,className:Ve.playerWrapper})]})}const GR="_overlay_1b1xq_1",KR="_modal_1b1xq_11",YR="_header_1b1xq_21",ZR="_body_1b1xq_37",XR="_hint_1b1xq_43",JR="_list_1b1xq_49",eF="_item_1b1xq_55",tF="_selected_1b1xq_68",rF="_empty_1b1xq_73",nF="_footer_1b1xq_79",sF="_cancelBtn_1b1xq_87",iF="_moveBtn_1b1xq_95",Kt={overlay:GR,modal:KR,header:YR,body:ZR,hint:XR,list:JR,item:eF,selected:tF,empty:rF,footer:nF,cancelBtn:sF,moveBtn:iF};function oF(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 aF=({resourceId:e,resourceName:t,currentUnitId:r,onClose:n})=>{var f;const s=ae(),{treeData:i,moveNode:o}=ue(),a=oF(i,((f=i[0])==null?void 0:f.id)??"",r),[c,u]=m.useState(null),d=()=>{c&&(o(e,r,c),n())};return l.jsx("div",{className:Kt.overlay,role:"dialog","aria-label":s.resourceReorderDialog.dialogAriaLabel,children:l.jsxs("div",{className:Kt.modal,children:[l.jsxs("div",{className:Kt.header,children:[l.jsxs("span",{children:[s.resourceReorderDialog.moveHeaderPrefix,' "',t,'"']}),l.jsx("button",{onClick:n,"aria-label":s.resourceReorderDialog.closeAriaLabel,children:l.jsx(yr,{size:16})})]}),l.jsxs("div",{className:Kt.body,children:[l.jsx("p",{className:Kt.hint,children:s.resourceReorderDialog.selectUnitHint}),l.jsxs("ul",{className:Kt.list,children:[a.map(g=>l.jsxs("li",{className:`${Kt.item} ${c===g.id?Kt.selected:""}`,onClick:()=>u(g.id),children:[l.jsx(Ty,{size:14}),l.jsx("span",{children:g.name})]},g.id)),a.length===0&&l.jsx("li",{className:Kt.empty,children:s.resourceReorderDialog.noUnitsAvailable})]})]}),l.jsxs("div",{className:Kt.footer,children:[l.jsx("button",{className:Kt.cancelBtn,onClick:n,children:s.resourceReorderDialog.cancelButton}),l.jsx("button",{className:Kt.moveBtn,onClick:d,disabled:!c,children:s.resourceReorderDialog.moveButton})]})]})})},lF="_overlay_1d56g_1",cF="_modal_1d56g_11",uF="_header_1d56g_21",dF="_body_1d56g_37",fF="_table_1d56g_43",hF="_pageInput_1d56g_61",pF="_empty_1d56g_68",mF="_footer_1d56g_74",gF="_cancelBtn_1d56g_82",vF="_saveBtn_1d56g_90",fr={overlay:lF,modal:cF,header:uF,body:dF,table:fF,pageInput:hF,empty:pF,footer:mF,cancelBtn:gF,saveBtn:vF};function yF(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 bF=({onClose:e})=>{const t=ae(),{treeData:r,updateNode:n}=ue(),s=yF(r),[i,o]=m.useState(()=>Object.fromEntries(s.map(c=>{var u;return[c.id,String(((u=c.metadata)==null?void 0:u.pageNumber)??"")]}))),a=m.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(yr,{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(jy,{size:14})," ",t.assignPageNumber.saveButton]})]})]})})},CF="_container_p2feh_1",SF="_panelHeader_p2feh_10",_F="_panelHeaderLeft_p2feh_19",wF="_panelCollapseBtn_p2feh_27",xF="_titleRow_p2feh_46",TF="_field_p2feh_47",EF="_moveBtn_p2feh_64",AF="_icon_p2feh_84",IF="_nameInput_p2feh_93",kF="_fieldHeader_p2feh_118",DF="_label_p2feh_124",LF="_fieldCount_p2feh_133",OF="_chips_p2feh_170",NF="_chip_p2feh_170",jF="_chipRemove_p2feh_188",PF="_keywordInput_p2feh_202",RF="_input_p2feh_207",FF="_addBtn_p2feh_220",MF="_radioGroup_p2feh_234",BF="_radioLabel_p2feh_239",Ke={container:CF,panelHeader:SF,panelHeaderLeft:_F,panelCollapseBtn:wF,titleRow:xF,field:TF,moveBtn:EF,icon:AF,nameInput:IF,fieldHeader:kF,label:DF,fieldCount:LF,chips:OF,chip:NF,chipRemove:jF,keywordInput:PF,input:RF,addBtn:FF,radioGroup:MF,radioLabel:BF},qF=({node:e,editorMode:t,onMoveClick:r,reorderDialog:n})=>{var N,B;const{updateNode:s,markDirty:i}=ue(),o=t==="edit",a=ni(e),c=ae(),u=Z(P=>P.relationalFormConfig),d=P=>u==null?void 0:u.find(U=>U.code===P),f=P=>!u||!!d(P),g=(P,U)=>{var ne;return((ne=d(P))==null?void 0:ne.label)||U},[p,b]=m.useState(!0),h=((N=e.metadata)==null?void 0:N.relationalMetadata)??{},[v,y]=m.useState(h.name??e.name??""),[C,S]=m.useState(""),[_,x]=m.useState(Array.isArray(h.keywords)?h.keywords:Array.isArray((B=e.metadata)==null?void 0:B.keywords)?e.metadata.keywords:[]),[E,D]=m.useState(!!h.optional);m.useEffect(()=>{var U,ne;const P=((U=e.metadata)==null?void 0:U.relationalMetadata)??{};y(P.name??e.name??""),x(Array.isArray(P.keywords)?P.keywords:Array.isArray((ne=e.metadata)==null?void 0:ne.keywords)?e.metadata.keywords:[]),D(!!P.optional)},[e.id]);const T=()=>{v.trim()&&v!==e.name&&(s(e.id,{name:v.trim()}),i())},j=()=>{const P=C.trim();if(P&&!_.includes(P)){const U=[..._,P];x(U),s(e.id,{keywords:U}),i()}S("")},F=P=>{const U=_.filter(ne=>ne!==P);x(U),s(e.id,{keywords:U}),i()},O=P=>{D(P),s(e.id,{optional:P}),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(P=>!P),"aria-expanded":p,"aria-label":p?c.contentEditForm.collapseMetadataPanelAriaLabel:c.contentEditForm.expandMetadataPanelAriaLabel,title:p?c.contentEditForm.collapseTitle:c.contentEditForm.expandTitle,children:p?l.jsx(bn,{size:15}):l.jsx(Cy,{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:P=>y(P.target.value),onBlur:T,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:[g("keywords",c.contentEditForm.keywordsLabel),_.length>0&&l.jsx("span",{className:Ke.fieldCount,children:_.length})]})}),_.length>0&&l.jsx("div",{className:Ke.chips,children:_.map(P=>l.jsxs("span",{className:Ke.chip,children:[P,o&&l.jsx("button",{type:"button",className:Ke.chipRemove,onClick:()=>F(P),children:"×"})]},P))}),o&&l.jsxs("div",{className:Ke.keywordInput,children:[l.jsx("input",{type:"text",className:Ke.input,value:C,placeholder:c.contentEditForm.addKeywordPlaceholder,onChange:P=>S(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.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:g("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:E===!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:E===!1,onChange:()=>O(!1),disabled:!o}),c.contentEditForm.noOption]})]})]})]}),n]})},$F="_iconBtn_gliz0_1",UF="_editable_gliz0_14",zF="_iconImg_gliz0_26",VF="_placeholder_gliz0_34",HF="_removeBtn_gliz0_41",Cs={iconBtn:$F,editable:UF,iconImg:zF,placeholder:VF,removeBtn:HF},QF=({nodeId:e,value:t,editable:r})=>{const[n,s]=m.useState(!1),{updateNode:i,markDirty:o}=ue(),a=ae(),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:[Cs.iconBtn,r?Cs.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:Cs.iconImg}):l.jsx("div",{className:Cs.placeholder,children:l.jsx(Mf,{size:24})}),t&&r&&l.jsx("button",{type:"button",className:Cs.removeBtn,onClick:u,"aria-label":a.titleAppIcon.removeIconAriaLabel,children:l.jsx(Co,{size:11})})]}),n&&l.jsx(Vp,{nodeId:e,currentValue:t,onSelect:c,onClose:()=>s(!1)})]})},WF="_courseDetails_1eby7_1",GF="_courseDetailsLoading_1eby7_7",KF="_courseDetailsError_1eby7_7",YF="_detailsCard_1eby7_12",ZF="_unitsCard_1eby7_12",XF="_cardTitle_1eby7_22",JF="_fieldGroup_1eby7_29",e2="_fieldGroupLast_1eby7_33",t2="_fieldLabel_1eby7_37",r2="_fieldValue_1eby7_47",n2="_fieldValueMultiline_1eby7_52",s2="_unitsLabel_1eby7_58",i2="_unitsDescription_1eby7_68",o2="_unitList_1eby7_74",a2="_unitCard_1eby7_80",l2="_unitHeader_1eby7_86",c2="_unitIcon_1eby7_99",u2="_unitTitle_1eby7_111",d2="_unitCount_1eby7_120",f2="_unitBody_1eby7_126",h2="_unitDescription_1eby7_131",p2="_unitKeywords_1eby7_138",m2="_keywordPill_1eby7_145",g2="_unitTopicsRow_1eby7_155",v2="_unitContents_1eby7_167",y2="_contentRow_1eby7_174",b2="_contentIcon_1eby7_180",C2="_contentTitle_1eby7_185",S2="_contentSkills_1eby7_193",_2="_skillPill_1eby7_200",je={courseDetails:WF,courseDetailsLoading:GF,courseDetailsError:KF,detailsCard:YF,unitsCard:ZF,cardTitle:XF,fieldGroup:JF,fieldGroupLast:e2,fieldLabel:t2,fieldValue:r2,fieldValueMultiline:n2,unitsLabel:s2,unitsDescription:i2,unitList:o2,unitCard:a2,unitHeader:l2,unitIcon:c2,unitTitle:u2,unitCount:d2,unitBody:f2,unitDescription:h2,unitKeywords:p2,keywordPill:m2,unitTopicsRow:g2,unitContents:v2,contentRow:y2,contentIcon:b2,contentTitle:C2,contentSkills:S2,skillPill:_2},w2={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr};function ma(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}const tm=({courseId:e,variant:t="compact",title:r,onLoaded:n})=>{const s=ae(),i=as(),[o,a]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(null),[g,p]=m.useState({}),b=t==="full";m.useEffect(()=>{let C=!1;return a(null),u(""),f(null),vh(e).then(S=>{if(C)return;const x=(S.children??[]).map(E=>To(E));a(x),u(S.description??""),p(Object.fromEntries(x.map(E=>[E.id,!0]))),n==null||n({totalContents:x.reduce((E,D)=>{var T;return E+(((T=D.children)==null?void 0:T.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?ma((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:je.courseDetails,children:d?l.jsx("p",{className:je.courseDetailsError,children:d}):o===null?l.jsx("p",{className:je.courseDetailsLoading,children:s.learningPath.courseDetailsLoading}):l.jsxs(l.Fragment,{children:[b&&l.jsxs("div",{className:je.detailsCard,children:[l.jsx("h3",{className:je.cardTitle,children:s.learningPath.courseDetailsCardTitle}),l.jsxs("div",{className:je.fieldGroup,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.courseTitleFieldLabel}),l.jsx("div",{className:je.fieldValue,children:r})]}),l.jsxs("div",{className:je.fieldGroupLast,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.courseDescriptionFieldLabel}),l.jsx("div",{className:je.fieldValueMultiline,children:c||s.learningPath.noCourseDescriptionPlaceholder})]})]}),o.length===0?l.jsx("p",{className:je.courseDetailsLoading,children:s.learningPath.courseDetailsEmpty}):l.jsxs("div",{className:b?je.unitsCard:void 0,children:[l.jsx("span",{className:je.unitsLabel,children:s.learningPath.unitsSectionLabel}),b&&l.jsx("p",{className:je.unitsDescription,children:s.learningPath.unitsSectionDescription}),l.jsx("div",{className:je.unitList,children:o.map(C=>{var D,T;const S=!!g[C.id],_=(C.children??[]).length,x=ma((D=C.metadata)==null?void 0:D.keywords),E=ma((T=C.metadata)==null?void 0:T.topic);return l.jsxs("div",{className:je.unitCard,children:[l.jsxs("button",{type:"button",className:je.unitHeader,onClick:()=>h(C.id),"aria-expanded":S,children:[S?l.jsx(bn,{size:17}):l.jsx(wl,{size:17}),l.jsx("span",{className:je.unitIcon,children:l.jsx(Rf,{size:16})}),l.jsx("span",{className:je.unitTitle,children:C.name}),b&&l.jsx("span",{className:je.unitCount,children:y(_)})]}),S&&l.jsxs("div",{className:je.unitBody,children:[b&&C.description&&l.jsx("p",{className:je.unitDescription,children:C.description}),b&&x.length>0&&l.jsx("div",{className:je.unitKeywords,children:x.map(j=>l.jsx("span",{className:je.keywordPill,children:j},j))}),b&&E.length>0&&l.jsxs("div",{className:je.unitTopicsRow,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.unitTopicsFieldLabel}),l.jsx("span",{children:E.join(", ")})]}),l.jsx("div",{className:je.unitContents,children:(C.children??[]).map(j=>{const F=ni(j),O=w2[F.key]??Gr,N=v(j);return l.jsxs("div",{className:je.contentRow,children:[l.jsx(O,{size:16,className:je.contentIcon}),l.jsx("span",{className:je.contentTitle,children:j.name}),N.length>0&&l.jsx("div",{className:je.contentSkills,children:N.map(B=>l.jsx("span",{className:je.skillPill,children:B},B))})]},j.id)})})]})]},C.id)})})]})]})})},x2="_backToPathButton_42cuj_1",T2="_assessmentTitle_42cuj_15",E2="_slotPills_42cuj_22",A2="_slotPill_42cuj_22",I2="_slotPillHint_42cuj_40",k2="_slotPillPurpose_42cuj_45",D2="_slotPillWarning_42cuj_51",L2="_slotPillPrimary_42cuj_56",O2="_courseCard_42cuj_62",N2="_courseCardHeading_42cuj_72",j2="_courseCardDescription_42cuj_79",P2="_courseNotAdded_42cuj_85",R2="_assessmentExplainer_42cuj_93",F2="_assessmentExplainerHeading_42cuj_107",M2="_leafContentLayout_42cuj_117",B2="_container_42cuj_131",q2="_emptyState_42cuj_140",$2="_titleRow_42cuj_150",U2="_titleRowLp_42cuj_157",z2="_nodeTitle_42cuj_171",V2="_nodeTitleLpRoot_42cuj_193",H2="_nodeTitleSub_42cuj_198",Q2="_courseDetailHeader_42cuj_203",W2="_courseDetailIcon_42cuj_210",G2="_courseDetailTitle_42cuj_222",K2="_courseDetailMeta_42cuj_229",Y2="_formArea_42cuj_234",Z2="_contentListArea_42cuj_238",X2="_contentListAreaLp_42cuj_242",J2="_dropZone_42cuj_246",eM="_reviewComment_42cuj_253",tM="_reviewCommentLabel_42cuj_266",rM="_reviewCommentText_42cuj_272",Ie={backToPathButton:x2,assessmentTitle:T2,slotPills:E2,slotPill:A2,slotPillHint:I2,slotPillPurpose:k2,slotPillWarning:D2,slotPillPrimary:L2,courseCard:O2,courseCardHeading:N2,courseCardDescription:j2,courseNotAdded:P2,assessmentExplainer:R2,assessmentExplainerHeading:F2,leafContentLayout:M2,container:B2,emptyState:q2,titleRow:$2,titleRowLp:U2,nodeTitle:z2,nodeTitleLpRoot:V2,nodeTitleSub:H2,courseDetailHeader:Q2,courseDetailIcon:W2,courseDetailTitle:G2,courseDetailMeta:K2,formArea:Y2,contentListArea:Z2,contentListAreaLp:X2,dropZone:J2,reviewComment:eM,reviewCommentLabel:tM,reviewCommentText:rM},nM=({slot:e,isEditable:t})=>{var p;const r=ae(),n=ue(b=>b.treeData),s=ue(b=>b.selectNode),i=(p=n[0])==null?void 0:p.id,{pre:o,post:a}=Vl(),c=(e==="pre"?o:a).filled,u=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel,d=e==="pre"?Ps:yy,f=e==="pre"?r.learningPath.priorAssessmentExplainerTitle:r.learningPath.outcomeAssessmentExplainerTitle,g=e==="pre"?r.learningPath.priorAssessmentExplainerBody:r.learningPath.outcomeAssessmentExplainerBody;return l.jsxs("div",{className:Ie.container,children:[l.jsxs("button",{type:"button",className:Ie.backToPathButton,onClick:()=>i&&s(i),children:[l.jsx(_l,{size:14})," ",r.learningPath.backToPathButton]}),l.jsx("div",{className:Ie.assessmentTitle,children:u}),l.jsx("div",{className:Ie.slotPills,children:e==="pre"?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillHint}`,children:[l.jsx(xc,{size:12})," ",r.learningPath.priorAssessmentHint]}),l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillPurpose}`,children:[l.jsx(gy,{size:12})," ",r.learningPath.priorAssessmentPurposeLabel]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillWarning}`,children:[l.jsx(Bf,{size:12})," ",r.learningPath.outcomeUnlocksHint]}),l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillPrimary}`,children:[l.jsx(xc,{size:12})," ",r.learningPath.outcomeAssessmentHint]})]})}),l.jsxs("div",{className:Ie.formArea,children:[l.jsxs("div",{className:Ie.courseCard,children:[l.jsx("div",{className:Ie.courseCardHeading,children:r.learningPath.assessmentCourseSectionTitle}),l.jsx("p",{className:Ie.courseCardDescription,children:r.learningPath.assessmentCourseSectionDescription}),c?l.jsx(ul,{slot:e,isEditable:t}):l.jsx("div",{className:Ie.courseNotAdded,children:r.learningPath.assessmentNotAddedYet})]}),l.jsxs("div",{className:Ie.assessmentExplainer,children:[l.jsxs("div",{className:Ie.assessmentExplainerHeading,children:[l.jsx(d,{size:16}),l.jsx("span",{children:f})]}),l.jsx("p",{children:g})]})]})]})},sM="application/vnd.sunbird.questionset",rm="application/vnd.sunbird.question",iM=[sM,rm];function Td(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 oM=({editorMode:e,onToolbarEvent:t})=>{var oe,ge,ve,xe,ye;const r=ae(),[n,s]=m.useState("details"),[i,o]=m.useState([]),[a,c]=m.useState(null),[u,d]=m.useState(!1),[f,g]=m.useState(null),p=m.useRef(null),b=m.useRef(),{selectedNodeId:h,breadcrumb:v,activeNodeMeta:y,updateNode:C,treeData:S,selectNode:_}=ue(),x=Hr(R=>R.activeAssessmentSlot),E=Z(R=>{var M,Y,le,Ce;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.contentId)??((Ce=(le=R.editorConfig)==null?void 0:le.context)==null?void 0:Ce.identifier)??""}),D=Z(R=>R.editorProfile.competencyScoped),T=h?nm(S,h):null;m.useEffect(()=>{g(null)},[T==null?void 0:T.identifier]);const j=!!T&&!T.parent,F=!!(T!=null&&T.isFolder),O=T&&iM.includes(T.mimeType??""),N=(T==null?void 0:T.mimeType)===rm,B=T&&!T.isFolder&&!O&&!j,U=D&&F&<(T??void 0)?((ve=(ge=(oe=S[0])==null?void 0:oe.children)==null?void 0:ge[0])==null?void 0:ve.id)===(T==null?void 0:T.id)?"pre":"post":D?x:null,ne=Td(T)??(j?Td(S[0]):void 0),H=m.useCallback(()=>{const R=p.current;if(!R||!h)return;const M=R.innerText.trim();clearTimeout(b.current),b.current=setTimeout(()=>{C(h,{name:M})},600)},[h,C]),te=m.useCallback(R=>{t({action:"onFormValueChange",data:R})},[t]),he=m.useCallback((R,M)=>{o(M),t({action:"onFormStatusChange",data:{isValid:R,nodeId:h}})},[t,h]);if(!T)return l.jsx("div",{className:Ie.emptyState,children:l.jsx("p",{children:r.contextualEditor.emptyStateMessage})});if(O)return l.jsx(dl,{node:T,editorMode:e,type:"quml",singleQuestion:N});if(D&&B&&T.primaryCategory==="Course"){const R=T.parent?a1(((xe=S[0])==null?void 0:xe.children)??[],T.parent):null,M=(R==null?void 0:R.role)==="pre"?r.learningPath.priorAssessmentLabel:(R==null?void 0:R.role)==="post"?r.learningPath.outcomeAssessmentLabel:(R==null?void 0:R.role)==="level"?r.learningPath.levelNumberPrefix.replace("{n}",String(R.levelNumber)):null,Y=f===null?"":` · ${(f===1?r.learningPath.contentCountLabel:r.learningPath.contentCountLabelPlural).replace("{count}",String(f))}`;return l.jsxs("div",{className:Ie.container,children:[l.jsxs("button",{type:"button",className:Ie.backToPathButton,onClick:()=>T.parent&&_(T.parent),children:[l.jsx(_l,{size:14}),M?r.learningPath.backToLevelButton.replace("{label}",M):r.learningPath.backToPathButton]}),l.jsxs("div",{className:Ie.courseDetailHeader,children:[l.jsx("span",{className:Ie.courseDetailIcon,children:l.jsx(Wr,{size:26})}),l.jsxs("div",{children:[l.jsx("h2",{className:Ie.courseDetailTitle,children:T.name}),l.jsxs("span",{className:Ie.courseDetailMeta,children:[T.primaryCategory,Y]})]})]}),l.jsx(tm,{courseId:T.identifier,variant:"full",title:T.name,onLoaded:({totalContents:le})=>g(le)},T.identifier)]})}return U?l.jsx(nM,{slot:U,isEditable:e==="edit"}):B?l.jsxs("div",{className:Ie.leafContentLayout,children:[l.jsx(dl,{node:T,editorMode:e,type:"content",layout:"flow"}),l.jsx(qF,{node:T,editorMode:e,onMoveClick:()=>c(T.identifier),reorderDialog:a?l.jsx(aF,{resourceId:a,resourceName:T.name,currentUnitId:T.parent??"",onClose:()=>c(null)}):null})]}):l.jsxs("div",{className:Ie.container,children:[l.jsx(OL,{crumbs:v}),ne&&l.jsxs("div",{className:Ie.reviewComment,role:"alert",children:[l.jsx("span",{className:Ie.reviewCommentLabel,children:r.contextualEditor.reviewCommentLabel}),l.jsx("span",{className:Ie.reviewCommentText,children:ne})]}),l.jsxs("div",{className:[Ie.titleRow,D?Ie.titleRowLp:""].filter(Boolean).join(" "),children:[j&&h&&l.jsx(QF,{nodeId:h,value:String(T.appIcon??((ye=T.metadata)==null?void 0:ye.appIcon)??""),editable:e==="edit"}),l.jsx("div",{ref:p,className:[Ie.nodeTitle,D&&j?Ie.nodeTitleLpRoot:"",D&&!j?Ie.nodeTitleSub:""].filter(Boolean).join(" "),contentEditable:e==="edit",suppressContentEditableWarning:!0,onInput:H,onBlur:H,"data-placeholder":r.contextualEditor.untitledPlaceholder,"aria-label":r.contextualEditor.nodeTitleAriaLabel,children:T.name})]}),l.jsx(ML,{activeTab:n,onChange:R=>s(R),errorTabs:i,visibleTabs:j&&!D?void 0:["details"]}),l.jsx("div",{className:Ie.formArea,children:l.jsx(Nj,{nodeMetadata:y,activeTab:n,isRoot:j,isFolder:F,editorMode:e,onFormValueChange:te,onFormStatusChange:he},`${h??"none"}:${j?"root":"node"}`)}),(F||j)&&n==="details"&&l.jsx("div",{className:[Ie.contentListArea,D?Ie.contentListAreaLp:""].filter(Boolean).join(" "),children:l.jsx(GP,{editorMode:e,isRoot:j})}),l.jsx(ZP,{isActive:!1,label:r.contextualEditor.dropZoneLabel,nodeId:h??void 0,className:Ie.dropZone}),u&&l.jsx(bF,{contentId:E,onClose:()=>d(!1)})]})};function nm(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=nm(r.children,t);if(n)return n}}}const sm=Xs((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 aM(e,t,r,n){const s={primaryCategory:["Course"]};return n&&(s.framework=[n]),!e&&t.length&&r&&(s[r]=t),s}function lM(e,t){if(!(!e||!t))return[...Zp,t,"framework"]}function cM(e,t,r,n,s){return e?t?r&&!n&&s.length===0?"noSkills":null:"noCurriculum":null}const uM=20,dM=[];function im(){var u;const e=Z(d=>d.editorConfig),t=ue(d=>d.selectedNodeId),r=ue(d=>d.treeData),n=m.useCallback(()=>{if(!t||!r.length)return 0;function d(f,g,p=0){var b;for(const h of f){if(h.id===g)return p;if((b=h.children)!=null&&b.length){const v=d(h.children,g,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[...nd];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:[...nd]}function fM(){const e=sm(),t=Z(T=>{var j,F;return((F=(j=T.editorConfig)==null?void 0:j.context)==null?void 0:F.channel)??""}),r=im(),n=Z(T=>T.editorProfile),s=Hr(T=>T.activeAssessmentSlot),i=ue(T=>T.activeNodeMeta),o=ue(T=>T.treeData),a=ue(T=>T.treeCache),c=ue(T=>T.selectedNodeId),u=ue(T=>T.getNodeById),d=as(),f=n.competencyScoped?Sh(o[0],a):void 0,g=m.useRef(),p=d&&Array.isArray(i[d.code])?i[d.code]:dM,b=c?u(c):void 0,h=n.competencyScoped&&!!(b!=null&&b.isFolder)&&!!b.parent&&!lt(b),v=cM(n.competencyScoped,f,h,s,p),y=m.useCallback(async(T="",j="all",F={},O=!0,N=!1)=>{var B,P,U,ne,H;e.setLoading(!0);try{if(v){e.setContent([],0);return}let te;if(n.competencyScoped){const ve=aM(s,p,d==null?void 0:d.code,f);te={status:["Live"],...ve}}else te={status:["Live"],primaryCategory:j&&j!=="all"?[j]:r},(B=F==null?void 0:F.board)!=null&&B.length&&(te.board=F.board),(P=F==null?void 0:F.medium)!=null&&P.length&&(te.medium=F.medium),(U=F==null?void 0:F.gradeLevel)!=null&&U.length&&(te.gradeLevel=F.gradeLevel),(ne=F==null?void 0:F.subject)!=null&&ne.length&&(te.subject=F.subject),(H=F==null?void 0:F.primaryCategory)!=null&&H.length&&(te.primaryCategory=F.primaryCategory);const he=O?0:e.offset,{content:oe,count:ge}=await XP({filters:te,query:T,limit:T?50:uM,offset:he,channel:t||void 0,sortBy:N?{name:"asc"}:{lastUpdatedOn:"desc"},fields:lM(n.competencyScoped,d==null?void 0:d.code)});O?e.setContent(oe,ge):e.appendContent(oe,ge)}catch(te){console.error("[useLibrary] load error:",te)}finally{e.setLoading(!1)}},[r,t,n,s,p,d,f,v]);m.useEffect(()=>{clearTimeout(g.current),e.setSearch("")},[f]),m.useEffect(()=>{y()},[t]),m.useEffect(()=>{n.competencyScoped&&y()},[n.competencyScoped,s,p.join("|"),f,c]);const C=m.useCallback(T=>{e.setSearch(T),clearTimeout(g.current),g.current=setTimeout(()=>y(T,e.activeFilter,e.advancedFilters,!0,e.sortAZ),300)},[e.activeFilter,e.advancedFilters,e.sortAZ,y]),S=m.useCallback(T=>{e.setFilter(T),y(e.searchQuery,T,e.advancedFilters,!0,e.sortAZ)},[e.searchQuery,e.advancedFilters,e.sortAZ,y]),_=m.useCallback(T=>{e.setAdvancedFilters(T),y(e.searchQuery,e.activeFilter,T,!0,e.sortAZ)},[e.searchQuery,e.activeFilter,e.sortAZ,y]),x=m.useCallback(()=>{const T=!e.sortAZ;e.setSortAZ(T),y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,T)},[e.sortAZ,e.searchQuery,e.activeFilter,e.advancedFilters,y]),E=m.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:E,refetch:()=>y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,e.sortAZ),activeAssessmentSlot:s,emptyReason:v}}function om(){var a;const e=ae(),t=Z(c=>c.editorProfile.competencyScoped),r=Hr(c=>c.activeAssessmentSlot),n=ue(c=>c.selectedNodeId),s=ue(c=>c.treeData),i=ue(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 hM="_card_1cmpg_1",pM="_addBtn_1cmpg_17",mM="_dragging_1cmpg_24",gM="_ctIcon_1cmpg_29",vM="_info_1cmpg_33",yM="_name_1cmpg_41",bM="_meta_1cmpg_50",CM="_skillTags_1cmpg_58",SM="_skillTag_1cmpg_58",_M="_addBtnMuted_1cmpg_93",wM="_added_1cmpg_102",xM="_addedBadge_1cmpg_111",Yt={card:hM,addBtn:pM,dragging:mM,ctIcon:gM,info:vM,name:yM,meta:bM,skillTags:CM,skillTag:SM,addBtnMuted:_M,added:wM,addedBadge:xM},TM={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},EM=({item:e,onAdd:t,onPreview:r,isDraggable:n,isAdded:s})=>{var S,_;const i=ae(),o=ni(e),a=TM[o.key]??Gr,c=zl(),u=lD(),d=c&&!s&&u,f=Z(x=>x.editorProfile.competencyScoped),g=as(),p=f&&g?(()=>{const x=e[g.code];return Array.isArray(x)?x:x?[String(x)]:[]})():[],{attributes:b,listeners:h,setNodeRef:v,isDragging:y}=Df({id:e.identifier,disabled:!n||!c||!u,data:{type:"library-item",item:e}}),C=()=>{r&&r(e)};return l.jsxs("div",{ref:v,className:[Yt.card,y?Yt.dragging:"",s?Yt.added:""].join(" "),"aria-label":e.name,...n?{...b,...h}:{},role:"listitem",onClick:C,children:[l.jsx("span",{className:[`sbx-ct-sq--${o.key}`,Yt.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(a,{size:14})}),l.jsxs("div",{className:Yt.info,children:[l.jsx("span",{className:Yt.name,title:e.name,children:e.name}),l.jsxs("span",{className:Yt.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:Yt.skillTags,children:p.slice(0,3).map(x=>l.jsx("span",{className:Yt.skillTag,children:x},x))})]}),s&&l.jsx("span",{className:Yt.addedBadge,"aria-label":i.libraryCard.alreadyAddedAriaLabel,title:i.libraryCard.alreadyAddedTitle,children:l.jsx(yn,{size:12})}),!s&&n&&l.jsx("button",{type:"button",className:[Yt.addBtn,!d&&c?Yt.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(Cn,{size:14})})]})},AM="_chips_xhhaq_1",IM="_chip_xhhaq_1",Ed={chips:AM,chip:IM},kM=({filters:e,active:t,onChange:r})=>{const n=ae();return l.jsx("div",{className:Ed.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",Ed.chip].join(" "),onClick:()=>r(s.value),children:s.label},s.value))})},DM="_panel_uame3_1",LM="_header_uame3_10",OM="_headerTitle_uame3_19",NM="_closeBtn_uame3_25",jM="_body_uame3_43",PM="_section_uame3_59",RM="_sectionLabel_uame3_65",FM="_chips_uame3_73",MM="_chip_uame3_73",BM="_active_uame3_96",qM="_footer_uame3_102",$M="_resetBtn_uame3_112",UM="_applyBtn_uame3_129",ht={panel:DM,header:LM,headerTitle:OM,closeBtn:NM,body:jM,section:PM,sectionLabel:RM,chips:FM,chip:MM,active:BM,footer:qM,resetBtn:$M,applyBtn:UM},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}],VM=new Set(["board","medium","gradeLevel","subject","topic"]),HM=({local:e,toggle:t})=>{const r=ae(),n=im();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},QM=({isOpen:e,filters:t,onApply:r,onClose:n})=>{var v,y;const s=ae(),i=Z(C=>C.editorConfig),o=Z(C=>C.searchFormConfig),a=Z(C=>C.contentFramework),c=Z(C=>C.contentTargetFWIds),{organisationFramework:u}=Eo(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]=m.useState(t),g=o!=null&&o.length?o.filter(C=>VM.has(C.code)).map(C=>({key:C.code,label:C.label||C.code})):zM(s);m.useEffect(()=>{f(t)},[t]);const p=(C,S)=>{f(_=>{const x=_[C]??[],E=x.includes(S)?x.filter(D=>D!==S):[...x,S];return{..._,[C]:E}})},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(yr,{size:16})})]}),l.jsxs("div",{className:ht.body,children:[g.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(HM,{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},WM="_header_1tvk1_10",GM="_headerCourse_1tvk1_20",KM="_courseIcon_1tvk1_25",YM="_titleGroup_1tvk1_37",ZM="_courseMeta_1tvk1_45",XM="_title_1tvk1_37",JM="_headerActions_1tvk1_67",eB="_iconBtn_1tvk1_74",tB="_playerArea_1tvk1_92",rB="_footer_1tvk1_100",nB="_footerCourse_1tvk1_109",sB="_addBtn_1tvk1_115",iB="_addBtnCourse_1tvk1_134",oB="_modalOverlay_1tvk1_159",aB="_modalOverlayCourse_1tvk1_174",lB="_modalPanel_1tvk1_178",cB="_modalPanelCourse_1tvk1_190",gt={header:WM,headerCourse:GM,courseIcon:KM,titleGroup:YM,courseMeta:ZM,title:XM,headerActions:JM,iconBtn:eB,playerArea:tB,footer:rB,footerCourse:nB,addBtn:sB,addBtnCourse:iB,modalOverlay:oB,modalOverlayCourse:aB,modalPanel:lB,modalPanelCourse:cB},uB="application/vnd.sunbird.questionset",dB=({content:e,editorMode:t,onAdd:r,onClose:n})=>{var f;const s=ae(),i=t==="edit",o=Z(g=>g.editorProfile.competencyScoped),a=om();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 Ur.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:g=>g.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(Wr,{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(yr,{size:16})})})]}),l.jsx("div",{className:gt.playerArea,children:c?l.jsx(tm,{courseId:e.identifier}):l.jsx(dl,{node:d,editorMode:"read",type:e.mimeType===uB?"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(Cn,{size:15})," ",a??s.libraryPreviewPanel.addToUnitButton]}):l.jsx("button",{type:"button",className:gt.addBtn,onClick:()=>r(e),children:s.libraryPreviewPanel.addToUnitButton})})]})}),document.body)},fB="_dock_2k0x7_1",hB="_header_2k0x7_8",pB="_libraryTargetLabel_2k0x7_18",mB="_headerLeft_2k0x7_28",gB="_headerTitle_2k0x7_36",vB="_count_2k0x7_42",yB="_searchRow_2k0x7_51",bB="_searchWrap_2k0x7_59",CB="_searchIcon_2k0x7_65",SB="_searchInput_2k0x7_74",_B="_filterToggleBtn_2k0x7_92",wB="_filterToggleBtnActive_2k0x7_111",xB="_filterBadge_2k0x7_117",TB="_filters_2k0x7_136",EB="_mainArea_2k0x7_146",AB="_sidePanelOverlay_2k0x7_155",IB="_cardList_2k0x7_164",kB="_skeleton_2k0x7_180",DB="_skeletonIcon_2k0x7_190",LB="_skeletonText_2k0x7_198",OB="_skeletonLine_2k0x7_205",NB="_skeletonLineSm_2k0x7_212",jB="_loadMoreBtn_2k0x7_227",PB="_emptyState_2k0x7_252",RB="_collapseBtn_2k0x7_272",Ue={dock:fB,header:hB,libraryTargetLabel:pB,headerLeft:mB,headerTitle:gB,count:vB,searchRow:yB,searchWrap:bB,searchIcon:CB,searchInput:SB,filterToggleBtn:_B,filterToggleBtnActive:wB,filterBadge:xB,filters:TB,mainArea:EB,sidePanelOverlay:AB,cardList:IB,skeleton:kB,skeletonIcon:DB,skeletonText:LB,skeletonLine:OB,skeletonLineSm:NB,loadMoreBtn:jB,emptyState:PB,collapseBtn:RB},FB=[{label:"Courses",value:"all"}];function MB(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 BB=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{const n=ae(),{content:s,isLoading:i,totalCount:o,activeFilter:a,searchQuery:c,sortAZ:u,hasMore:d,search:f,setFilter:g,applyAdvancedFilters:p,toggleSort:b,loadMore:h,activeAssessmentSlot:v,emptyReason:y}=fM(),{addResource:C,selectedNodeId:S,treeData:_,treeCache:x}=ue(),E=Hr(R=>R.setActiveAssessmentSlot),D=Z(R=>R.editorProfile.competencyScoped),T=e==="edit",j=om(),[F,O]=m.useState(!1),[N,B]=m.useState({}),[P,U]=m.useState(null),[ne,H]=m.useState(null),te=m.useMemo(()=>MB(_),[_]),he=m.useCallback(async(R,M)=>{var le,Ce;const Y=(le=_[0])==null?void 0:le.id;if(!(!Y||ne)){if(Fs(((Ce=_[0])==null?void 0:Ce.children)??[],M)){we.error(M==="pre"?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}H(R.identifier);try{const{qualifies:de,meta:ce}=await bh(R.identifier);if(!de){we.error(n.learningPath.notAssessmentCourseToast.replace("{name}",R.name));return}const Q={...R,...ce};if(C(Q,Y,{isAssessmentCourse:!0,slot:M})===!1){we.error(n.learningPath.bothSlotsFilledToast);return}we.success(n.libraryDock.itemAddedToast.replace("{name}",R.name)),E(null)}catch(de){console.error("[LibraryDock] assessment-course check failed:",de),we.error(n.learningPath.assessmentCheckFailedToast)}finally{H(null)}}},[_,C,E,ne,n]),oe=m.useCallback(R=>{var Ce,de,ce;if(D&&!_h(_[0],x)){we.error(n.learningPath.selectCurriculumFirstToast);return}if(v){he(R,v);return}if(!S){we.error(D?n.learningPath.selectLevelFirstToast:n.libraryDock.selectUnitFirstToast);return}const M=(Ce=_[0])==null?void 0:Ce.id,Y=ue.getState().getNodeById(S);if(D){const Q=((de=_[0])==null?void 0:de.children)??[],se=Y!=null&&Y.isFolder?Y:Y!=null&&Y.parent?ue.getState().getNodeById(Y.parent):void 0;if(se&&Qa(Q,se)){const Te=(ce=Q[0])==null?void 0:ce.id;we.error(se.id===Te?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}}if(S===M||!(Y!=null&&Y.isFolder)){we(D?n.learningPath.selectLevelFromOutlineToast:n.libraryDock.selectUnitFromOutlineToast,{icon:l.jsx(Ps,{size:16}),duration:4e3});return}if(C(R,S)===!1){we.error((D?n.learningPath.itemAlreadyInPathToast:n.libraryDock.itemAlreadyAddedToast).replace("{name}",R.name));return}we.success(n.libraryDock.itemAddedToast.replace("{name}",R.name))},[v,he,S,C,_,x,n,D]),ge=m.useCallback(R=>{B(R),p(R)},[p]),ve=m.useCallback(R=>{U(R)},[]),xe=m.useCallback(R=>{oe(R),U(null)},[oe]),ye=m.useMemo(()=>Object.values(N).reduce((R,M)=>R+((M==null?void 0:M.length)??0),0),[N]);return l.jsxs("div",{className:Ue.dock,children:[l.jsxs("div",{className:Ue.header,children:[l.jsxs("div",{className:Ue.headerLeft,children:[l.jsx("button",{type:"button",className:Ue.collapseBtn,onClick:r,"aria-label":n.libraryDock.collapseLibraryPanelAriaLabel,title:n.libraryDock.collapseLibraryTitle,children:l.jsx(Oy,{size:15})}),l.jsx(Iy,{size:16}),l.jsx("span",{className:Ue.headerTitle,children:n.libraryDock.headerTitle}),o>0&&l.jsx("span",{className:Ue.count,children:o})]}),j&&l.jsx("span",{className:Ue.libraryTargetLabel,children:j})]}),l.jsxs("div",{className:Ue.searchRow,children:[l.jsxs("div",{className:Ue.searchWrap,children:[l.jsx(Wi,{size:14,className:Ue.searchIcon}),l.jsx("input",{type:"search",className:Ue.searchInput,placeholder:n.libraryDock.searchPlaceholder,value:c,onChange:R=>f(R.target.value),"aria-label":n.libraryDock.searchAriaLabel})]}),l.jsx("button",{type:"button",className:[Ue.filterToggleBtn,u?Ue.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(vy,{size:15}):l.jsx(_y,{size:15})}),l.jsxs("button",{type:"button",className:[Ue.filterToggleBtn,F?Ue.filterToggleBtnActive:""].join(" "),onClick:()=>O(R=>!R),"aria-label":n.libraryDock.toggleAdvancedFiltersAriaLabel,"aria-pressed":F,title:n.libraryDock.advancedFiltersTitle,children:[l.jsx(qy,{size:15}),ye>0&&l.jsx("span",{className:Ue.filterBadge,children:ye})]})]}),l.jsx("div",{className:Ue.filters,children:l.jsx(kM,{filters:D?FB:cD,active:a,onChange:g})}),l.jsxs("div",{className:Ue.mainArea,children:[l.jsx("div",{className:Ue.cardList,role:"list","aria-label":n.libraryDock.libraryContentAriaLabel,children:i&&s.length===0?Array.from({length:4}).map((R,M)=>l.jsxs("div",{className:Ue.skeleton,"aria-hidden":"true",children:[l.jsx("div",{className:Ue.skeletonIcon}),l.jsxs("div",{className:Ue.skeletonText,children:[l.jsx("div",{className:Ue.skeletonLine}),l.jsx("div",{className:Ue.skeletonLineSm})]})]},M)):s.length>0?l.jsxs(l.Fragment,{children:[s.map(R=>l.jsx(EM,{item:R,onAdd:oe,onPreview:ve,isDraggable:T,isAdded:te.has(R.identifier)},R.identifier)),d&&l.jsx("button",{type:"button",className:Ue.loadMoreBtn,onClick:h,disabled:i,"aria-label":n.libraryDock.loadMoreAriaLabel,children:i?n.libraryDock.loadingText:n.libraryDock.loadMoreText})]}):l.jsxs("div",{className:Ue.emptyState,children:[l.jsx(Wi,{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})]})]})}),F&&l.jsx("div",{className:Ue.sidePanelOverlay,children:l.jsx(QM,{isOpen:F,filters:N,onApply:ge,onClose:()=>O(!1)})}),P&&l.jsx(dB,{content:P,editorMode:e,onAdd:xe,onClose:()=>U(null)})]})]})};function qB(e,t,r,n=El){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 g(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 E;if(y)E={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,...T}=v??{};E={...d(p.metadata??{},!0),...d(T,!1),name:p.name}}else{const{isNew:D,...T}=v??{};E={name:p.name,visibility:"Parent",...d(T,!0)}}s[h]={metadata:E,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(E=>E.identifier),...Object.keys(S).length>0?{relationalMetadata:S}:{},root:b},(p.children??[]).forEach(E=>g(E,!1))}return e.forEach((p,b)=>g(p,b===0)),{nodesModified:s,hierarchy:i}}function $B(){const[e,t]=m.useState(!1),r=ue(d=>d.treeCache),n=ue(d=>d.treeData),s=Z(d=>d.isDirty),i=Z(d=>d.lastSaved),{setIsDirty:o,setLastSaved:a}=Z(),c=Z(d=>d.editorConfig);return{save:m.useCallback(async()=>{if(!c||e)return;const d=c.context.contentId??c.context.identifier??"";if(!d)return;if(n.length===0){we.error("Collection is empty. Please reload before saving.");return}const f=c.context.channel??"",g=c.context.userId??c.context.uid??"";t(!0);try{const p=Z.getState().editorProfile,{nodesModified:b,hierarchy:h}=qB(n,r,f,p),{identifiers:v}=await Xx(d,b,h,g);v&&Object.keys(v).length>0&&ue.getState().replaceNodeIds(v);const y=new Date().toISOString();a(y),o(!1)}catch(p){console.error("[useSaveHierarchy] save failed:",p),we.error("Failed to save. Please try again.")}finally{t(!1)}},[c,e,n,r,o,a]),isSaving:e,isDirty:s,lastSaved:i}}const UB={};function zB(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function VB(e,t,r,n,s,i=UB){const o=[],a=(c,u)=>{var d;for(const f of c){const g=u&&!f.parent,p=g?r:f.isFolder?n:null;if(p&&p.length>0){const b={...f.metadata??{},...t[f.id]??{}},v=qp(p,b,i,g,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 HB(e){var h,v;const t=Z(y=>y.editorConfig),r=Z(y=>y.setButtonLoader),n=Z(y=>y.validateAllForms),s=Z(y=>y.rootFormConfig),i=Z(y=>y.unitFormConfig),o=ue(y=>y.treeData),a=ue(y=>y.treeCache),c=ue(y=>y.selectNode),u=Z(y=>y.contentFramework),d=Z(y=>y.contentTargetFWIds),{organisationFramework:f,targetFrameworks:g}=Eo(u??((h=t==null?void 0:t.context)==null?void 0:h.framework),d??((v=t==null?void 0:t.context)==null?void 0:v.targetFWIds)),p=m.useCallback(()=>{var x,E,D;const y={editorMode:"edit",objectType:(x=t==null?void 0:t.config)==null?void 0:x.objectType,userFullName:(D=(E=t==null?void 0:t.context)==null?void 0:E.user)==null?void 0:D.fullName},C=VB(o,a,s,i,y,{organisationFramework:f,targetFrameworks:g});if(C.length===0)return!0;const S=C[0];we.error(`"${S.nodeName}": please fill required field${S.missing.length>1?"s":""} — ${S.missing.join(", ")}`);const{setFormStatus:_}=Z.getState();return C.forEach(T=>_(T.nodeId,!1)),c(S.nodeId),!1},[o,a,s,i,t,c,f,g]);return{runAction:m.useCallback(async(y,C)=>{var x,E,D,T;const S=((x=t==null?void 0:t.context)==null?void 0:x.contentId)??((E=t==null?void 0:t.context)==null?void 0:E.identifier)??"";if(!S)return we.error("No content identifier found."),!1;const _=((D=t==null?void 0:t.context)==null?void 0:D.userId)??((T=t==null?void 0:t.context)==null?void 0:T.uid)??"";try{switch(y){case"sendForReview":return p()?n(o)?(r("saveCollection",!0),await e(),await t1(S),we.success("Content sent for review"),!0):(we.error("Some units have missing required fields. Please fill them before sending for review."),!1):!1;case"reject":{r("rejectCollection",!0);const j=(C==null?void 0:C.comment)??"";return await r1(S,j),we.success("Content rejected and sent back to the author"),!0}case"publish":return p()?n(o)?(r("publishCollection",!0),await e(),await Jx(S,_),we.success("Content published successfully"),!0):(we.error("Some units have missing required fields. Please fill them before publishing."),!1):!1;default:return!1}}catch(j){console.error(`[useToolbarActions] ${y} failed`,j);const F=y==="sendForReview"?"send for review":y==="reject"?"reject":"publish";return we.error(`Failed to ${F}. Please try again.`),!1}finally{r("saveCollection",!1),r("rejectCollection",!1),r("publishCollection",!1)}},[t,e,r,p,n,o]),checkRequiredFields:p}}const QB="_shell_fu72l_1",WB="_workspace_fu72l_8",GB="_sidebarCollapsed_fu72l_16",KB="_dockCollapsed_fu72l_19",YB="_dock_fu72l_19",ZB="_outline_fu72l_40",XB="_reopenTab_fu72l_45",JB="_outlineHidden_fu72l_79",eq="_editor_fu72l_86",tq="_editorLp_fu72l_92",rq="_dockHidden_fu72l_105",nq="_dockReopenTab_fu72l_112",sq="_dragChip_fu72l_137",iq="_dragChipLabel_fu72l_152",jt={shell:QB,workspace:WB,sidebarCollapsed:GB,dockCollapsed:KB,dock:YB,outline:ZB,reopenTab:XB,outlineHidden:JB,editor:eq,editorLp:tq,dockHidden:rq,dockReopenTab:nq,dragChip:sq,dragChipLabel:iq},oq=({editorMode:e,onToolbarEvent:t,onContentAdded:r,onHierarchySaved:n})=>{const s=ae(),[i,o]=m.useState(null),[a,c]=m.useState(!1),[u,d]=m.useState(!1),[f,g]=m.useState(!1),{addResource:p,treeData:b,treeCache:h}=ue(),v=Z(H=>H.setFormStatus),y=Z(H=>H.editorProfile.key==="learningPath"),[C,S]=m.useState(!0),_=ue(H=>H.selectedNodeId),{save:x,isSaving:E,isDirty:D,lastSaved:T}=$B(),{runAction:j,checkRequiredFields:F}=HB(x);m.useEffect(()=>{if(!D)return;const H=te=>{te.preventDefault(),te.returnValue=""};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[D]);const O=uf(Na(ho,{activationConstraint:{distance:8}})),N=m.useCallback(H=>{var he;const te=(he=H.active.data.current)==null?void 0:he.item;te&&o(te)},[]),B=m.useCallback(H=>{var R,M,Y,le,Ce;o(null);const te=(R=H.active.data.current)==null?void 0:R.item;if(!te)return;if(y&&!_h(b[0],h)){we.error(s.learningPath.selectCurriculumFirstToast);return}const he=H.over,oe=(he==null?void 0:he.id)??_??void 0,ge=y?s.learningPath.dropOntoLevelError:s.splitBuilderShell.dropOntoUnitError;if(!oe){we.error(ge);return}const ve=(M=b[0])==null?void 0:M.id;if(oe===ve){we.error(y?s.learningPath.dropOntoPathError:s.splitBuilderShell.dropOntoCourseError);return}const xe=ue.getState().getNodeById(oe);if(!(xe!=null&&xe.isFolder)){we.error(ge);return}if(y&<(xe)){const de=(Ce=(le=(Y=b[0])==null?void 0:Y.children)==null?void 0:le[0])==null?void 0:Ce.id;we.error(xe.id===de?s.learningPath.priorSlotFilledToast:s.learningPath.outcomeSlotFilledToast);return}if(!p(te,oe)){we.error((y?s.learningPath.itemAlreadyInPathToast:s.splitBuilderShell.alreadyInCollectionError).replace("{name}",te.name));return}r==null||r(te,oe),we.success((y?s.learningPath.addedToLevelSuccess:s.splitBuilderShell.addedToUnitSuccess).replace("{name}",te.name))},[_,p,b,h,r,s,y]),P=m.useCallback(async H=>{if(H.action==="onFormStatusChange"){const{isValid:te,nodeId:he}=H.data??{},oe=te!==!1;S(oe),he&&v(he,oe);return}if(H.action==="back"&&D&&e==="edit"){g(!0);return}if(H.action==="saveCollection"){if(!C){we.error(s.splitBuilderShell.fillRequiredMetadataError);return}if(!F())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,F,t,n,b,D,C,e,s]),U=m.useCallback(async()=>{if(!F()){g(!1);return}await x(),g(!1),n==null||n(b),t==null||t({action:"back"})},[x,F,n,t,b]),ne=m.useCallback(()=>{g(!1),t==null||t({action:"back"})},[t]);return l.jsxs(kf,{sensors:O,onDragStart:N,onDragEnd:B,children:[l.jsxs("div",{className:jt.shell,children:[l.jsx(G0,{editorMode:e,isSaving:E,isDirty:D,lastSaved:T,isFormValid:C,onToolbarEvent:P}),l.jsxs("div",{className:[jt.workspace,a?jt.sidebarCollapsed:"",u?jt.dockCollapsed:""].filter(Boolean).join(" "),children:[l.jsx("aside",{className:[jt.outline,a?jt.outlineHidden:""].join(" "),"aria-label":s.splitBuilderShell.outlineAriaLabel,"aria-hidden":a,children:l.jsx(AL,{editorMode:e,collapsed:a,onToggleCollapse:()=>c(H=>!H)})}),a&&l.jsx("button",{className:jt.reopenTab,onClick:()=>c(!1),title:s.splitBuilderShell.showOutlineTitle,type:"button",children:"›"}),l.jsx("main",{className:[jt.editor,y?jt.editorLp:""].filter(Boolean).join(" "),role:"main","aria-label":s.splitBuilderShell.editorAriaLabel,children:l.jsx(oM,{editorMode:e,onToolbarEvent:P})}),l.jsx("aside",{className:[jt.dock,u?jt.dockHidden:""].filter(Boolean).join(" "),"aria-label":s.splitBuilderShell.libraryAriaLabel,"aria-hidden":u,children:l.jsx(BB,{editorMode:e,collapsed:u,onToggleCollapse:()=>d(H=>!H)})}),u&&l.jsx("button",{className:jt.dockReopenTab,onClick:()=>d(!1),title:s.splitBuilderShell.showLibraryTitle,type:"button",children:"‹"})]})]}),l.jsx(fy,{dropAnimation:null,children:i?l.jsx("div",{className:jt.dragChip,children:l.jsx("span",{className:jt.dragChipLabel,children:i.name})}):null}),f&&l.jsx(K0,{onSave:U,onDiscard:ne,onCancel:()=>g(!1),isSaving:E})]})},aq="v1";function lq(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 Ad(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:lq(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 kr(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(Ad(o,s))}else n.code&&r.push(Ad(n));return r}function cq(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 uq(e,t,r="Collection",n=aq){var u,d;const i=(d=(u=(await Re.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:kr(o.create),unitForm:kr(o.unitMetadata),childForm:kr(o.childMetadata),searchForm:kr(o.search??o.searchConfig),relationalForm:kr(o.relationalMetadata),publishChecklist:kr(o.publishchecklist),reviewChecklist:kr(o.review),rfcChecklist:kr(o.requestforchangeschecklist),schemaDefaults:cq(a.schema),frameworkMetadata:c.frameworkMetadata??{},sourcingSettings:c.sourcingSettings??{}}}function Id(e,t,r){return{framework:e.framework??t??r.framework??null,targetFWIds:e.targetFWIds??r.targetFWIds??null}}function dq({config:e,onError:t}){const[r,n]=m.useState(!0),[s,i]=m.useState(null),[o,a]=m.useState(!1),{setEditorConfig:c,setEditorMode:u,setCategoryDefinition:d,setContentFramework:f,setEditorProfile:g}=Z(),{setTreeData:p,selectNode:b}=ue();return m.useEffect(()=>{let h=!1;async function v(){var y,C,S;try{n(!0),i(null),e.apiBaseUrl&&hh(e.apiBaseUrl),c(e),u(e.config.mode),g(ob(e));const _=e.context.contentId??e.context.identifier??"",x=e.context.channel??"";let E;if(x)try{E=(y=await Mp(x))==null?void 0:y.defaultFramework}catch{}let D=!1;if(_){const T=e.config.objectType==="QuestionSet";let{rootNode:j}=T?await Zx(_):await gh(_);if(j&&e.config.primaryCategory==="Learning Path"&&(j=await i1(j)),!h&&(p(j?[j]:[]),j)){b(j.id);const{framework:P,targetFWIds:U}=Id(j.metadata??{},E,e.context);f(P,U),D=!0}const F=e.config.primaryCategory??"Course",O=e.context.channel??"",N=e.config.categoryDefinitionApiVersion??"v1";try{const B=await uq(F,O,e.config.objectType??"Collection",N);if(!h){d(B);const P=((C=B.sourcingSettings)==null?void 0:C.collection)??{},U={};P.maxDepth&&!e.config.maxDepth&&(U.maxDepth=P.maxDepth),P.children&&!e.config.children&&(U.children=P.children),P.hierarchy&&!((S=e.config.hierarchy)!=null&&S.level1)&&(U.hierarchy={...e.config.hierarchy??{},...P.hierarchy}),Object.keys(U).length>0&&c({...e,config:{...e.config,...U}})}}catch{}}if(!h&&!D){const{framework:T,targetFWIds:j}=Id({},E,e.context);f(T,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 fq(){const e=Al(t=>t.setLanguage);m.useEffect(()=>{e(localStorage.getItem(Ba)||"en",{broadcast:!1});const t=n=>{n.key===Ba&&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(qa,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(qa,r)}},[e])}const hq="_root_1itrv_1",pq="_loadingState_1itrv_10",mq="_loadingSpinner_1itrv_20",gq="_errorState_1itrv_34",ws={root:hq,loadingState:pq,loadingSpinner:mq,errorState:gq},vq=new Rm({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function yq({error:e,onRetry:t}){const r=ae();return l.jsxs("div",{className:ws.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 bq extends m.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(yq,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}}function Cq(e){fq();const t=ae(),{isLoading:r,error:n}=dq({config:e,onError:e.onError}),s=Z(o=>o.editorMode),i=Z(o=>o.editorProfile);return r?l.jsxs("div",{className:ws.loadingState,children:[l.jsx("div",{className:ws.loadingSpinner}),l.jsx("p",{children:t.collectionEditor.loadingMessage})]}):n?l.jsxs("div",{className:ws.errorState,children:[l.jsx("h3",{children:t.collectionEditor.loadErrorTitle}),l.jsx("p",{children:n.message})]}):l.jsx("div",{className:["sb-split-builder",ws.root,i.key==="learningPath"?"sbx-lp-profile":""].filter(Boolean).join(" "),children:l.jsx(oq,{editorMode:s,onToolbarEvent:e.onToolbarEvent,onContentAdded:e.onContentAdded,onHierarchySaved:e.onHierarchySaved})})}const am=e=>l.jsx(bq,{onError:e.onError,children:l.jsxs(Mm,{client:vq,children:[l.jsx(Cq,{...e}),l.jsx(Fg,{position:"top-right",toastOptions:{duration:3e3,style:{fontFamily:"var(--sbx-font)"}}})]})}),io=Symbol.for("r2wc.reactRender"),kd=Symbol.for("r2wc.shouldRender"),_i=Symbol.for("r2wc.root");function Sq(e=""){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function _q(e=""){return e.replace(/-([a-z0-9])/g,function(t){return t[1].toUpperCase()})}var Dd={expando:function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:function(){return r},set:function(n){r=n,this[io]()}}),e[io]()}};function wq(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,g){return i&&(s[d]=!0),typeof d=="symbol"||s[d]||d in u?(e.propTypes&&d in e.propTypes&&Dd.expando(g,d,f),Reflect.set(u,d,f,g)):(Dd.expando(g,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[kd]=!0,this[io]()},a.disconnectedCallback=function(){typeof r.createRoot=="function"?this[_i].unmount():r.unmountComponentAtNode(this)},a[io]=function(){if(this[kd]===!0){var u={};Object.keys(this).forEach(function(g){s[g]!==!1&&(u[g]=this[g])},this),i=!0;const d=n.shadow?this.shadowRoot:this,f=t.createElement(e,u);typeof r.createRoot=="function"?(this[_i]||(this[_i]=r.createRoot(d)),this[_i].render(f)):r.render(f,d),i=!1}},e.propTypes&&(o.observedAttributes=n.dashStyleAttributes?Object.keys(e.propTypes).map(function(u){return Sq(u)}):Object.keys(e.propTypes),a.attributeChangedCallback=function(u,d,f){var g=n.dashStyleAttributes?_q(u):u;this[g]=f}),o}var jn={},Ld;function xq(){if(Ld)return jn;Ld=1;var e=Ur;if(process.env.NODE_ENV==="production")jn.createRoot=e.createRoot,jn.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;jn.createRoot=function(r,n){t.usingClientEntryPoint=!0;try{return e.createRoot(r,n)}finally{t.usingClientEntryPoint=!1}},jn.hydrateRoot=function(r,n,s){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(r,n,s)}finally{t.usingClientEntryPoint=!1}}}return jn}var Tq=xq();const Eq=xl(Tq);function Aq(){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 Iq(e="sb-collection-editor"){if(Aq(),typeof customElements>"u"||customElements.get(e))return;const t=wq(am,m,Eq,{});customElements.define(e,t)}exports.CollectionEditor=am;exports.registerCollectionEditor=Iq;exports.setApiBaseUrl=hh;exports.useEditorStore=Z;exports.useLibraryStore=sm;exports.useTreeStore=ue;
|
|
546
|
+
Use the data prop if you want to provide your own handlers.`);if(e.initialData){const[t,r]=sD(e.initialData,{idAccessor:e.idAccessor,childrenAccessor:e.childrenAccessor});return Object.assign(Object.assign(Object.assign({},e),r),{data:t})}else return e}function oD(e,t){const r=iD(e);return l.jsxs(Kk,{treeProps:r,imperativeHandle:t,children:[l.jsx(Zk,{children:l.jsx(Xk,{})}),l.jsx(Jk,{})]})}const aD=m.forwardRef(oD);function zl(){return ue(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 lD(){return ue(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 td={video:"#EA580C",pdf:"#DC2626",h5p:"#0D9488",scorm:"#7C3AED",audio:"#DB2777",quiz:"#16A34A",course:"#A85236",default:"#6B7280"},rd={video:"Video",pdf:"FileText",h5p:"Layers",scorm:"Package",audio:"Music",quiz:"HelpCircle",course:"BookOpen",default:"File"},nd=["Course Assessment","eTextbook","Exam Question","Explanation Content","Learning Resource","Practice Question Set","SCORM Content","Teacher Resource"],cD=[{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 uD(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 ni(e){const t=uD(e);return{key:t,color:td[t]??td.default,bgClass:`sbx-ct-sq--${t}`,badgeClass:`sbx-ct-badge--${t}`,tintClass:`sbx-ct-tint--${t}`,iconName:rd[t]??rd.default,label:t.charAt(0).toUpperCase()+t.slice(1)}}const dD="_row_nm332_1",fD="_grip_nm332_16",hD="_menuBtn_nm332_19",pD="_rowLp_nm332_23",mD="_selected_nm332_27",gD="_title_nm332_32",vD="_dropTarget_nm332_41",yD="_toggle_nm332_58",bD="_ctIcon_nm332_73",CD="_ctIconLp_nm332_85",SD="_folderIcon_nm332_89",_D="_rootIcon_nm332_94",wD="_titleLp_nm332_110",xD="_levelTitle_nm332_114",TD="_renameInput_nm332_119",ED="_dropHere_nm332_128",AD="_menuWrap_nm332_138",ID="_menu_nm332_19",kD="_dangerItem_nm332_190",it={row:dD,grip:fD,menuBtn:hD,rowLp:pD,selected:mD,title:gD,dropTarget:vD,toggle:yD,ctIcon:bD,ctIconLp:CD,folderIcon:SD,rootIcon:_D,titleLp:wD,levelTitle:xD,renameInput:TD,dropHere:ED,menuWrap:AD,menu:ID,dangerItem:kD},DD={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},LD=({node:e,style:t,dragHandle:r,editorMode:n})=>{const[s,i]=m.useState(!1),[o,a]=m.useState(!1),[c,u]=m.useState(e.data.name),d=m.useRef(null),f=ae(),g=Z(N=>N.editorProfile),p=n==="edit",b=zl(),h=ni(e.data),v=DD[h.key]??Gr,y=e.isSelected,C=e.level===0,S=e.data.isFolder??(e.children&&e.children.length>0),_=g.key==="learningPath",x=C?_?Ih:by:S?_?ky:Rf:v,E=_&&S&&!C&&!lt(e.data),D=e.level+1<=g.maxDepth,T=_?f.learningPath.addLevelButton:f.treeNode.addSubunitMenuItem,j=_?f.learningPath.addLevelButton:f.treeNode.addSiblingMenuItem;m.useEffect(()=>{if(!s)return;const N=B=>{var P;(P=d.current)!=null&&P.contains(B.target)||i(!1)};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[s]);const F=m.useCallback(()=>{c.trim()&&e.submit(c.trim()),a(!1)},[c,e]),O=m.useCallback(N=>{N.key==="Enter"&&F(),N.key==="Escape"&&(u(e.data.name),a(!1))},[F,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(Ff,{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(wl,{size:14}):l.jsx(bn,{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:F,onKeyDown:O,onClick:N=>N.stopPropagation()}):l.jsx("span",{className:[it.title,_?it.titleLp:"",E?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(B=>!B)},"aria-label":f.treeNode.nodeOptionsAriaLabel,children:l.jsx(jf,{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(Ny,{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(Pf,{size:13})," ",T]}),e.data.parent&&b&&!_&&l.jsxs("button",{role:"menuitem",onClick:()=>{e.tree.create({parentId:e.data.parent}),i(!1)},children:[l.jsx(Cn,{size:13})," ",j]}),!C&&l.jsxs("button",{role:"menuitem",className:it.dangerItem,onClick:()=>{e.tree.delete(e.id),i(!1)},children:[l.jsx(Co,{size:13})," ",f.treeNode.deleteMenuItem]})]})]})]})};async function OD(e,t){var i,o;const n=((i=(await Re.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 ND(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 jD(e,t){var a;const r=await OD(e,t.name),n=await ND(r,t),s=new FormData;return s.append("fileUrl",n),s.append("mimeType",t.type||"text/csv"),{processId:(((a=(await Re.post(`/action/collection/v1/import/${e}`,s)).data)==null?void 0:a.result)??{}).processId??""}}async function PD(e){var r;return((r=(await Re.get(`/action/collection/v1/import/status/${e}`)).data)==null?void 0:r.result)??{status:"PENDING"}}async function wp(e){var n,s,i;const r=(i=(s=(n=(await Re.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 RD(e){return wp(e)}const FD="_container_jw2be_1",MD="_header_jw2be_13",BD="_title_jw2be_22",qD="_closeBtn_jw2be_29",$D="_body_jw2be_45",UD="_dropZone_jw2be_54",zD="_dragOver_jw2be_67",VD="_hasFile_jw2be_72",HD="_hiddenInput_jw2be_78",QD="_fileInfo_jw2be_82",WD="_fileIcon_jw2be_89",GD="_fileName_jw2be_93",KD="_fileSize_jw2be_100",YD="_dropHint_jw2be_105",ZD="_dropIcon_jw2be_112",XD="_dropText_jw2be_117",JD="_dropSubtext_jw2be_124",eL="_sampleLink_jw2be_130",tL="_statusBar_jw2be_145",rL="_status_uploading_jw2be_154",nL="_status_processing_jw2be_154",sL="_status_done_jw2be_159",iL="_status_error_jw2be_164",oL="_successDetail_jw2be_170",aL="_spinner_jw2be_175",lL="_spin_jw2be_175",cL="_errorMsg_jw2be_191",uL="_failedSection_jw2be_197",dL="_failedTitle_jw2be_203",fL="_tableWrap_jw2be_213",hL="_failedTable_jw2be_219",pL="_reasonCell_jw2be_244",mL="_footer_jw2be_248",Be={container:FD,header:MD,title:BD,closeBtn:qD,body:$D,dropZone:UD,dragOver:zD,hasFile:VD,hiddenInput:HD,fileInfo:QD,fileIcon:WD,fileName:GD,fileSize:KD,dropHint:YD,dropIcon:ZD,dropText:XD,dropSubtext:JD,sampleLink:eL,statusBar:tL,status_uploading:rL,status_processing:nL,status_done:sL,status_error:iL,successDetail:oL,spinner:aL,spin:lL,errorMsg:cL,failedSection:uL,failedTitle:dL,tableWrap:fL,failedTable:hL,reasonCell:pL,footer:mL},gL=({contentId:e,onComplete:t,onClose:r,mode:n="create"})=>{const s=ae(),[i,o]=m.useState(null),[a,c]=m.useState(!1),[u,d]=m.useState("idle"),[f,g]=m.useState(""),[p,b]=m.useState([]),[h,v]=m.useState(null),y=m.useRef(null),C=m.useRef(null),S=m.useCallback(()=>{C.current!==null&&(clearInterval(C.current),C.current=null)},[]);m.useEffect(()=>()=>S(),[S]);const _=O=>O.name.toLowerCase().endsWith(".csv")?O.size>50*1024*1024?(g(s.csvUpload.fileTooLarge),!1):!0:(g(s.csvUpload.invalidFileType),!1),x=m.useCallback(O=>{g(""),b([]),v(null),d("idle"),_(O)&&o(O)},[]),E=m.useCallback(O=>{O.preventDefault(),c(!1);const N=O.dataTransfer.files[0];N&&x(N)},[x]),D=m.useCallback(O=>{var B;const N=(B=O.target.files)==null?void 0:B[0];N&&x(N),O.target.value=""},[x]),T=m.useCallback(async()=>{try{const O=await RD(e),N=document.createElement("a");N.href=O,N.download="sample_hierarchy.csv",N.target="_blank",N.click()}catch{g(s.csvUpload.downloadSampleFailed)}},[e,s.csvUpload.downloadSampleFailed]),j=m.useCallback(async()=>{if(i){d("uploading"),g(""),b([]);try{const{processId:O}=await jD(e,i);if(!O){d("done"),v(null),setTimeout(t,1500);return}d("processing"),C.current=setInterval(async()=>{try{const N=await PD(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"),g(s.csvUpload.processingFailed),N.failedRecords&&b(N.failedRecords))}catch{S(),d("error"),g(s.csvUpload.connectionLost)}},2e3)}catch{d("error"),g(s.csvUpload.uploadFailed)}}},[e,i,t,S,s.csvUpload.processingFailed,s.csvUpload.connectionLost,s.csvUpload.uploadFailed]),F={idle:"",uploading:s.csvUpload.statusUploading,processing:s.csvUpload.statusProcessing,done:s.csvUpload.statusDone,error:s.csvUpload.statusError};return l.jsxs("div",{className:Be.container,children:[l.jsxs("div",{className:Be.header,children:[l.jsx("h2",{className:Be.title,children:n==="update"?s.csvUpload.titleUpdate:s.csvUpload.titleCreate}),l.jsx("button",{className:Be.closeBtn,onClick:r,"aria-label":s.csvUpload.closeAriaLabel,children:l.jsx(yr,{size:18})})]}),l.jsxs("div",{className:Be.body,children:[l.jsxs("div",{className:`${Be.dropZone} ${a?Be.dragOver:""} ${i?Be.hasFile:""}`,onDragEnter:O=>{O.preventDefault(),c(!0)},onDragOver:O=>{O.preventDefault(),c(!0)},onDragLeave:O=>{O.preventDefault(),c(!1)},onDrop:E,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:Be.hiddenInput,onChange:D,"aria-hidden":"true"}),i?l.jsxs("div",{className:Be.fileInfo,children:[l.jsx(Zs,{size:24,className:Be.fileIcon}),l.jsx("span",{className:Be.fileName,children:i.name}),l.jsxs("span",{className:Be.fileSize,children:["(",(i.size/1024).toFixed(1)," KB)"]})]}):l.jsxs("div",{className:Be.dropHint,children:[l.jsx(Fa,{size:32,className:Be.dropIcon}),l.jsx("p",{className:Be.dropText,children:s.csvUpload.dropText}),l.jsx("p",{className:Be.dropSubtext,children:s.csvUpload.dropSubtext})]})]}),l.jsx("button",{className:Be.sampleLink,onClick:T,type:"button",children:s.csvUpload.downloadSample}),u!=="idle"&&l.jsxs("div",{className:`${Be.statusBar} ${Be[`status_${u}`]}`,role:"status","aria-live":"polite",children:[u==="processing"&&l.jsx("span",{className:Be.spinner,"aria-hidden":"true"}),F[u],u==="done"&&h!==null&&l.jsx("span",{className:Be.successDetail,children:s.csvUpload.itemsImportedSuffix.replace("{count}",String(h))})]}),f&&l.jsx("p",{className:Be.errorMsg,role:"alert",children:f}),p.length>0&&l.jsxs("div",{className:Be.failedSection,children:[l.jsx("h4",{className:Be.failedTitle,children:s.csvUpload.failedRowsTitle.replace("{count}",String(p.length))}),l.jsx("div",{className:Be.tableWrap,children:l.jsxs("table",{className:Be.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:Be.reasonCell,children:O.reason??s.csvUpload.unknownError})]},N))})]})})]})]}),l.jsxs("div",{className:Be.footer,children:[l.jsx(qe,{variant:"ghost",onClick:r,disabled:u==="uploading"||u==="processing",children:s.csvUpload.cancel}),l.jsx(qe,{variant:"primary",isLoading:u==="uploading"||u==="processing",disabled:!i||u==="done",onClick:j,children:u==="done"?s.csvUpload.uploaded:s.csvUpload.upload})]})]})};function Vl(){var g,p,b,h,v;const e=ae(),t=ue(y=>y.treeData),r=ue(y=>y.treeCache),n=ue(y=>y.deleteNode),s=Hr(y=>y.activeAssessmentSlot),i=Hr(y=>y.setActiveAssessmentSlot),o=((g=t[0])==null?void 0:g.children)??[],a=o[0],c=o.length>1?o[o.length-1]:void 0,u=lt(a),d=lt(c),f=y=>{var D,T;const C=y==="pre"?a:c;if(!C)return;const S=t[0],_=S?((D=r[S.id])==null?void 0:D.policy)??((T=S.metadata)==null?void 0:T.policy):void 0,E=y==="pre"&&!!_&&wh.has(_)?e.learningPath.deletePriorAssessmentConfirm:e.learningPath.deleteAssessmentSlotConfirm;window.confirm(E)&&n(C.id)};return{pre:{level:a,filled:u,courseName:u?(b=(p=a==null?void 0:a.children)==null?void 0:p[0])==null?void 0:b.name:void 0},post:{level:c,filled:d,courseName:d?(v=(h=c==null?void 0:c.children)==null?void 0:h[0])==null?void 0:v.name:void 0},activeAssessmentSlot:s,setActiveAssessmentSlot:i,deleteSlot:f}}const vL="_container_2qylm_1",yL="_header_2qylm_8",bL="_sectionLabel_2qylm_18",CL="_headerActions_2qylm_26",SL="_iconBtn_2qylm_33",_L="_menuWrap_2qylm_51",wL="_dropdownMenu_2qylm_55",xL="_treeWrapper_2qylm_87",TL="_csvModal_2qylm_103",EL="_footer_2qylm_113",rr={container:vL,header:yL,sectionLabel:bL,headerActions:CL,iconBtn:SL,menuWrap:_L,dropdownMenu:wL,treeWrapper:xL,csvModal:TL,footer:EL},AL=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{var ce;const n=ae(),s=m.useRef(null),i=m.useRef(null),o=m.useRef(null),[a,c]=m.useState(400),[u,d]=m.useState(!1),[f,g]=m.useState(!1),[p,b]=m.useState("create"),{treeData:h,selectedNodeId:v,selectNode:y,addNode:C,deleteNode:S,reorderChildren:_,moveNode:x,setTreeData:E}=ue(),D=Z(Q=>Q.editorProfile),T=D.key==="learningPath",j=e==="edit",F=zl(),O=j&&F,N=T?n.learningPath.addLevelButton:n.outlineTree.addUnitButton,B=D.maxDepth>1,P=(((ce=h[0])==null?void 0:ce.children)??[]).some(Q=>Q.isFolder),{pre:U,post:ne,deleteSlot:H}=Vl(),{level:te}=U,{level:he}=ne,oe=Z(Q=>{var se,Te,me,ee;return((Te=(se=Q.editorConfig)==null?void 0:se.context)==null?void 0:Te.contentId)??((ee=(me=Q.editorConfig)==null?void 0:me.context)==null?void 0:ee.identifier)??""}),ge=Z(Q=>{var Te,me;const se=(me=(Te=Q.categoryMeta)==null?void 0:Te.sourcingSettings)==null?void 0:me.collection;return(se==null?void 0:se.enableBulkUpload)!==!1}),ve=D.features.csvUpload&≥m.useEffect(()=>{const Q=i.current;if(!Q)return;const se=new ResizeObserver(()=>{c(Q.clientHeight||400)});return se.observe(Q),c(Q.clientHeight||400),()=>se.disconnect()},[]),m.useEffect(()=>{if(!u)return;const Q=se=>{var Te;(Te=o.current)!=null&&Te.contains(se.target)||d(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[u]);const xe=m.useCallback(Q=>{Q.length>0&&y(Q[0].data.id)},[y]),ye=m.useCallback(({parentId:Q,index:se,dragIds:Te})=>{if(!Q)return;const me=Te[0],ee=sl(h,me);if(!ee)return;const He=ee.parent;if(He===Q){const Ge=sl(h,Q);if(!(Ge!=null&&Ge.children))return;const Ze=Ge.children.findIndex(Qe=>Qe.id===me);if(Ze<0)return;_(Q,Ze,se>Ze?se-1:se)}else x(me,He??"",Q)},[h,_,x]),R=m.useCallback(({ids:Q})=>{for(const se of Q){if(T&&(te==null?void 0:te.id)===se){H("pre");continue}if(T&&(he==null?void 0:he.id)===se){H("post");continue}S(se)}},[S,H,T,te,he]),M=m.useCallback(({parentId:Q})=>{var me;const se=Q??((me=h[0])==null?void 0:me.id)??"";if(!se)return{id:crypto.randomUUID()};const Te=C(se,"unit");return Te?{id:Te}:(we.error(n.outlineTree.maxDepthReachedToast),{id:crypto.randomUUID()})},[C,h,n]),Y=m.useCallback(()=>{var se;const Q=(se=h[0])==null?void 0:se.id;Q&&(C(Q,"unit")||we.error(n.outlineTree.maxDepthReachedToast))},[h,C,n]),le=m.useCallback(()=>{v&&(C(v,"subunit")||we.error(n.outlineTree.maxDepthReachedToast))},[v,C,n]),Ce=m.useCallback(async()=>{if(d(!1),!!oe)try{const Q=await wp(oe),se=await fetch(Q).then(ee=>ee.blob()),Te=URL.createObjectURL(se),me=document.createElement("a");me.href=Te,me.download=`${oe}-folders.csv`,me.style.display="none",document.body.appendChild(me),me.click(),document.body.removeChild(me),URL.revokeObjectURL(Te)}catch{we.error(n.outlineTree.downloadCsvFailedToast)}},[oe,n]),de=m.useCallback(async()=>{if(g(!1),!!oe)try{const{rootNode:Q}=await gh(oe);E([Q]),we.success(n.outlineTree.outlineRefreshedToast)}catch{we.error(n.outlineTree.outlineRefreshFailedToast)}},[oe,E,n]);return l.jsxs("div",{className:rr.container,children:[l.jsxs("div",{className:rr.header,children:[T&&l.jsx("span",{className:rr.sectionLabel,children:n.learningPath.pathStructureLabel}),l.jsxs("div",{className:rr.headerActions,children:[j&&ve&&l.jsxs("div",{className:rr.menuWrap,ref:o,children:[l.jsx("button",{type:"button",className:rr.iconBtn,onClick:()=>d(Q=>!Q),"aria-label":n.outlineTree.moreOptionsAriaLabel,title:n.outlineTree.moreOptionsTitle,"aria-haspopup":"true","aria-expanded":u,children:l.jsx(jf,{size:15})}),u&&l.jsxs("div",{className:rr.dropdownMenu,role:"menu",children:[l.jsx("button",{role:"menuitem",type:"button",disabled:P,title:P?n.outlineTree.foldersExistTitle:void 0,onClick:()=>{d(!1),b("create"),g(!0)},children:n.outlineTree.createFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!P,title:P?void 0:n.outlineTree.noFoldersYetTitle,onClick:Ce,children:n.outlineTree.downloadFoldersCsvButton}),l.jsx("button",{role:"menuitem",type:"button",disabled:!P,title:P?void 0:n.outlineTree.noFoldersYetTitle,onClick:()=>{d(!1),b("update"),g(!0)},children:n.outlineTree.updateFoldersCsvButton})]})]}),r&&l.jsx("button",{type:"button",className:rr.iconBtn,onClick:r,"aria-label":t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,title:t?n.outlineTree.expandOutlineAriaLabel:n.outlineTree.collapseOutlineAriaLabel,children:t?l.jsx(Ly,{size:15}):l.jsx(Dy,{size:15})})]})]}),l.jsx("div",{className:rr.treeWrapper,ref:i,children:l.jsx(aD,{ref:s,data:h,idAccessor:"id",childrenAccessor:"children",onSelect:xe,onMove:j?ye:void 0,onDelete:j?R:void 0,onCreate:j?M:void 0,disableEdit:!j,disableDrop:!j,selection:v??void 0,rowHeight:40,indent:20,paddingBottom:16,height:a,width:"100%",children:Q=>l.jsx(LD,{...Q,editorMode:e})})}),j&&l.jsxs("div",{className:rr.footer,children:[l.jsxs(qe,{variant:"ghost",size:"sm",onClick:Y,disabled:!O,children:[l.jsx(Cn,{size:14})," ",N]}),B&&l.jsxs(qe,{variant:"ghost",size:"sm",onClick:le,disabled:!O||!v,children:[l.jsx(Pf,{size:14})," ",n.outlineTree.addSubunitButton]})]}),f&&l.jsx("div",{className:rr.csvModal,children:l.jsx(gL,{contentId:oe,mode:p,onComplete:de,onClose:()=>g(!1)})})]})};function sl(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=sl(r.children,t);if(n)return n}}}const IL="_breadcrumb_zd1aj_1",kL="_crumb_zd1aj_10",DL="_sep_zd1aj_26",LL="_current_zd1aj_31",gs={breadcrumb:IL,crumb:kL,sep:DL,current:LL},OL=({crumbs:e})=>{const t=ue(n=>n.selectNode),r=ae();return e.length?l.jsxs("nav",{className:gs.breadcrumb,"aria-label":r.breadcrumb.nodePathAriaLabel,children:[l.jsx("button",{className:gs.crumb,onClick:()=>t(e[0].id),"aria-label":r.breadcrumb.homeAriaLabel,children:l.jsx(Ay,{size:13})}),e.map((n,s)=>l.jsxs(m.Fragment,{children:[l.jsx(wl,{size:13,className:gs.sep}),s<e.length-1?l.jsx("button",{className:gs.crumb,onClick:()=>t(n.id),children:n.name}):l.jsx("span",{className:gs.current,children:n.name})]},n.id))]}):null},NL="_tabBar_qhks1_1",jL="_tab_qhks1_1",PL="_active_qhks1_29",RL="_error_qhks1_35",FL="_errorDot_qhks1_39",vs={tabBar:NL,tab:jL,active:PL,error:RL,errorDot:FL},ML=({activeTab:e,onChange:t,errorTabs:r=[],visibleTabs:n})=>{const s=ae(),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:vs.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:[vs.tab,e===a.id?vs.active:"",r.includes(a.id)?vs.error:""].join(" "),onClick:()=>t(a.id),children:[a.label,r.includes(a.id)&&l.jsx("span",{className:vs.errorDot,"aria-label":s.tabBar.hasErrorsAriaLabel})]},a.id))})};var si=e=>e.type==="checkbox",tn=e=>e instanceof Date,vt=e=>e==null;const xp=e=>typeof e=="object";var Ye=e=>!vt(e)&&!Array.isArray(e)&&xp(e)&&!tn(e),il=e=>Ye(e)&&e.target?si(e.target)?e.target.checked:e.target.value:e,Tp=(e,t)=>t.split(".").some((r,n,s)=>!isNaN(Number(r))&&e.has(s.slice(0,n).join("."))),Ep=e=>{const t=e.constructor&&e.constructor.prototype;return Ye(t)&&t.hasOwnProperty("isPrototypeOf")},Oo=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(Oo&&(e instanceof Blob||t))return e;const r=Array.isArray(e);if(!r&&!(Ye(e)&&Ep(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 Nr={BLUR:"blur",FOCUS_OUT:"focusout",CHANGE:"change",SUBMIT:"submit",TRIGGER:"trigger",VALID:"valid"},ir={onBlur:"onBlur",onChange:"onChange",onSubmit:"onSubmit",onTouched:"onTouched",all:"all"},nr={max:"max",min:"min",maxLength:"maxLength",minLength:"minLength",pattern:"pattern",required:"required",validate:"validate"},ca="form",Ap="root",Ip=["__proto__","constructor","prototype"];var ii=e=>/^\w*$/.test(e),We=e=>e===void 0,No=e=>e.split(/[.[\]'"]/g).filter(Boolean),W=(e,t,r)=>{if(!t||!Ye(e))return r;const n=ii(t)?[t]:No(t);if(n.some(i=>Ip.includes(i)))return r;const s=n.reduce((i,o)=>vt(i)?void 0:i[o],e);return We(s)||s===e?We(e[t])?r:e[t]:s},Vt=e=>typeof e=="boolean",Et=e=>typeof e=="function",ze=(e,t,r)=>{let n=-1;const s=ii(t)?[t]:No(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=Ye(u)||Array.isArray(u)?u:isNaN(+s[n+1])?{}:[]}if(Ip.includes(a))return;e[a]=c,e=e[a]}};const Hl=m.createContext(null);Hl.displayName="HookFormControlContext";const Ql=()=>m.useContext(Hl);var kp=(e,t,r,n=!0)=>{const s={};for(const i in e)Object.defineProperty(s,i,{get:()=>{const o=i;return t._proxyFormState[o]!==ir.all&&(t._proxyFormState[o]=!n||ir.all),r&&(r[o]=!0),e[o]}});return s};const Wl=Oo?m.useLayoutEffect:m.useEffect;function BL(e){const t=Ql(),{control:r=t,disabled:n,name:s,exact:i}=e||{},[o,a]=m.useState(()=>({...r._formState,defaultValues:r._defaultValues})),c=m.useRef({isDirty:!1,isLoading:!1,dirtyFields:!1,touchedFields:!1,validatingFields:!1,isValidating:!1,isValid:!1,errors:!1});return Wl(()=>r._subscribe({name:s,formState:c.current,exact:i,callback:u=>{!n&&a({...r._formState,...u,defaultValues:r._defaultValues})}}),[s,n,i]),m.useEffect(()=>{c.current.isValid&&r._setValid(!0)},[r]),m.useMemo(()=>kp(o,r,c.current,!1),[o,r])}var At=e=>typeof e=="string",ol=(e,t,r,n,s)=>At(e)?(n&&t.watch.add(e),W(r,e,s)):Array.isArray(e)?e.map(i=>(n&&t.watch.add(i),W(r,i))):(n&&(t.watchAll=!0),r),al=e=>vt(e)||!xp(e);const sd=(e,t)=>t.length===0&&!Array.isArray(e)&&!Ep(e);function Ht(e,t,r=new WeakMap){if(e===t)return!0;if(al(e)||al(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(sd(e,n)||sd(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)||(Ye(a)||Array.isArray(a))&&(Ye(c)||Array.isArray(c))?!Ht(a,c,r):!Object.is(a,c))return!1}}return!0}function qL(e){const t=Ql(),{control:r=t,name:n,defaultValue:s,disabled:i,exact:o,compute:a}=e||{},c=m.useRef(s),u=m.useRef(a),d=m.useRef(void 0),f=m.useRef(r),g=m.useRef(n);u.current=a;const[p,b]=m.useState(()=>{const _=r._getWatch(n,c.current);return u.current?u.current(_):_}),h=m.useCallback(_=>{const x=ol(n,r._names,_||r._formValues,!1,c.current);return u.current?u.current(x):x},[r._formValues,r._names,n]),v=m.useCallback(_=>{if(!i){const x=ol(n,r._names,_||r._formValues,!1,c.current);if(u.current){const E=u.current(x);Ht(E,d.current)||(b(E),d.current=E)}else b(x)}},[r._formValues,r._names,i,n]);Wl(()=>((f.current!==r||!Ht(g.current,n))&&(f.current=r,g.current=n,v()),r._subscribe({name:n,formState:{values:!0},exact:o,callback:_=>{v(_.values)}})),[r,o,n,v]),m.useEffect(()=>r._removeUnmounted());const y=f.current!==r,C=g.current,S=m.useMemo(()=>{if(i)return null;const _=!y&&!Ht(C,n);return y||_?h():null},[i,y,n,C,h]);return S!==null?S:p}function oi(e){const t=Ql(),{name:r,disabled:n,control:s=t,shouldUnregister:i,defaultValue:o,exact:a=!0}=e,c=Tp(s._names.array,r),u=m.useMemo(()=>W(s._formValues,r,W(s._defaultValues,r,o)),[s,r,o]),d=qL({control:s,name:r,defaultValue:u,exact:a}),f=BL({control:s,name:r,exact:a}),g=m.useRef(e),p=m.useRef(null),b=m.useRef(s.register(r,{...e.rules,value:d,...Vt(e.disabled)?{disabled:e.disabled}:{}}));g.current=e;const h=m.useMemo(()=>Object.defineProperties({},{invalid:{enumerable:!0,get:()=>!!W(f.errors,r)},isDirty:{enumerable:!0,get:()=>!!W(f.dirtyFields,r)},isTouched:{enumerable:!0,get:()=>!!W(f.touchedFields,r)},isValidating:{enumerable:!0,get:()=>!!W(f.validatingFields,r)},error:{enumerable:!0,get:()=>W(f.errors,r)}}),[f,r]),v=m.useCallback(_=>{const x=il(_);return W(s._fields,r)||(b.current=s.register(r,{...g.current.rules,value:x})),b.current.onChange({target:{value:il(_),name:r},type:Nr.CHANGE})},[r,s]),y=m.useCallback(()=>b.current.onBlur({target:{value:W(s._formValues,r),name:r},type:Nr.BLUR}),[r,s._formValues]),C=m.useCallback(_=>{_&&(p.current={focus:()=>Et(_.focus)&&_.focus(),select:()=>Et(_.select)&&_.select(),setCustomValidity:E=>Et(_.setCustomValidity)&&_.setCustomValidity(E),reportValidity:()=>Et(_.reportValidity)&&_.reportValidity()});const x=W(s._fields,r);x&&x._f&&_&&(x._f.ref=p.current)},[s._fields,r]),S=m.useMemo(()=>({name:r,value:d,...Vt(n)||f.disabled?{disabled:f.disabled||n}:{},onChange:v,onBlur:y,ref:C}),[r,n,f.disabled,v,y,C,d]);return m.useEffect(()=>{const _=s._options.shouldUnregister||i;s.register(r,{...g.current.rules,...Vt(g.current.disabled)?{disabled:g.current.disabled}:{}});const x=(E,D)=>{const T=W(s._fields,E);T&&T._f&&(T._f.mount=D)};if(x(r,!0),_){const E=Xe(W(i?s._defaultValues:s._options.values||s._defaultValues,r,W(s._options.defaultValues,r,g.current.defaultValue)));ze(s._defaultValues,r,E),We(W(s._formValues,r))&&ze(s._formValues,r,E)}if(!c&&s.register(r),p.current){const E=W(s._fields,r);E&&E._f&&(E._f.ref=p.current)}return()=>{(c?_&&!s._state.action:_)?s.unregister(r):x(r,!1)}},[r,s,c,i]),m.useEffect(()=>{s._setDisabledField({disabled:n,name:r})},[n,r,s]),m.useMemo(()=>({field:S,formState:f,fieldState:h}),[S,f,h])}const $L=e=>e.render(oi(e)),Gl=m.createContext(null);Gl.displayName="HookFormContext";const er=()=>m.useContext(Gl),UL=({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:g,unregister:p,control:b,register:h,setFocus:v,subscribe:y})=>{const C=m.useMemo(()=>({watch:t,getValues:r,getFieldState:n,setError:s,clearErrors:i,setValue:o,setValues:a,trigger:c,formState:u,resetField:d,reset:f,handleSubmit:g,unregister:p,control:b,register:h,setFocus:v,subscribe:y}),[i,b,u,n,r,g,h,f,d,s,v,o,a,y,c,p,t]);return m.createElement(Gl.Provider,{value:C},m.createElement(Hl.Provider,{value:C.control},e))};var zL=(e,t,r,n,s)=>t?{...r[e],types:{...r[e]&&r[e].types?r[e].types:{},[n]:s||!0}}:{},Dp=e=>Array.isArray(e)?e.filter(Boolean):[],Mi=e=>Array.isArray(e)?e:[e],id=()=>{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 Lp(e,t){const r={};for(const n in e)if(e.hasOwnProperty(n)){const s=e[n],i=t[n];if(s&&Ye(s)&&i){const o=Lp(s,i);Ye(o)&&(r[n]=o)}else e[n]&&(r[n]=i)}return r}var ft=e=>Ye(e)&&!Object.keys(e).length,Kl=e=>e.type==="file",to=e=>{if(!Oo)return!1;const t=e?e.ownerDocument:0;return e instanceof(t&&t.defaultView?t.defaultView.HTMLElement:HTMLElement)},Op=e=>e.type==="select-multiple",Yl=e=>e.type==="radio",VL=e=>Yl(e)||si(e),ua=e=>to(e)&&e.isConnected;function HL(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 QL(e){for(const t in e)if(e.hasOwnProperty(t)&&!We(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:ii(t)?[t]:No(t),n=r.length===1?e:HL(e,r),s=r.length-1,i=r[s];return n&&delete n[i],s!==0&&(Ye(n)&&ft(n)||Array.isArray(n)&&QL(n))&&nt(e,r.slice(0,-1)),e}var WL=e=>{for(const t in e)if(Et(e[t]))return!0;return!1};function Np(e){return Array.isArray(e)||Ye(e)&&!WL(e)}function ll(e,t={}){for(const r in e){const n=e[r];Np(n)?(t[r]=Array.isArray(n)?[]:{},ll(n,t[r])):We(n)||(t[r]=!0)}return t}function cl(e){if(e!==!1){if(e===!0)return!0;if(Array.isArray(e)){const t=e.map(r=>cl(r));return t.some(r=>r!==void 0)?t:void 0}if(Ye(e)){const t={};for(const r in e){const n=cl(e[r]);We(n)||(t[r]=n)}return Object.keys(t).length?t:void 0}}}function Xr(e,t,r){r||(r=ll(t));for(const n in e){const s=e[n];if(Np(s))We(t)||al(r[n])?r[n]=ll(s,Array.isArray(s)?[]:{}):Xr(s,vt(t)?{}:t[n],r[n]);else{const i=t[n];r[n]=!Ht(s,i)}}return cl(r)||{}}const od={value:!1,isValid:!1},ad={value:!0,isValid:!0};var jp=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&&!We(e[0].attributes.value)?We(e[0].value)||e[0].value===""?ad:{value:e[0].value,isValid:!0}:ad:od}return od},Pp=(e,{valueAsNumber:t,valueAsDate:r,setValueAs:n})=>We(e)?e:t?e===""?NaN:e&&+e:r&&At(e)?new Date(e):n?n(e):e;const ld={isValid:!1,value:null};var Rp=e=>Array.isArray(e)?e.reduce((t,r)=>r&&r.checked&&!r.disabled?{isValid:!0,value:r.value}:t,ld):ld;function cd(e){const t=e.ref;return Kl(t)?t.files:Yl(t)?Rp(e.refs).value:Op(t)?[...t.selectedOptions].map(({value:r})=>r):si(t)?jp(e.refs).value:Pp(We(t.value)?e.ref.value:t.value,e)}var GL=(e,t,r,n)=>{const s={};for(const i of e){const o=W(t,i);o&&ze(s,i,o._f)}return{criteriaMode:r,names:[...e],fields:s,shouldUseNativeValidation:n}},ro=e=>e instanceof RegExp,ys=e=>We(e)?e:ro(e)?e.source:Ye(e)?ro(e.value)?e.value.source:e.value:e,ud=e=>({isOnSubmit:!e||e===ir.onSubmit,isOnBlur:e===ir.onBlur,isOnChange:e===ir.onChange,isOnAll:e===ir.all,isOnTouch:e===ir.onTouched});const dd="AsyncFunction";var KL=e=>!!e&&!!e.validate&&!!(Et(e.validate)&&e.validate.constructor.name===dd||Ye(e.validate)&&Object.values(e.validate).find(t=>t.constructor.name===dd)),YL=e=>e.mount&&(e.required||e.min||e.max||e.maxLength||e.minLength||e.pattern||e.validate),da=(e,t,r)=>!r&&(t.watchAll||t.watch.has(e)||[...t.watch].some(n=>e.startsWith(`${n}.`)));const Is=(e,t,r,n)=>{for(const s of r||Object.keys(e)){const i=W(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(Is(a,t))break}else if(Ye(a)&&Is(a,t))break}}};function fd(e,t,r){const n=W(e,r);if(n||ii(r))return{error:n,name:r};const s=r.split(".");for(;s.length;){const i=s.join("."),o=W(t,i),a=W(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 ZL=(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||ir.all))},XL=(e,t,r)=>!e||!t||e===t||Mi(e).some(n=>n&&(r?n===t:n.startsWith(t)||t.startsWith(n))),JL=(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,eO=(e,t)=>!Dp(W(e,t)).length&&nt(e,t),hd=(e,t,r)=>{const n=W(e,r),s=Array.isArray(n)?n:[];return ze(s,Ap,t[r]),ze(e,r,s),e};function pd(e,t,r="validate"){if(At(e)||Array.isArray(e)&&e.every(At)||Vt(e)&&!e)return{type:r,message:At(e)?e:"",ref:t}}var Ln=e=>Ye(e)&&!ro(e)?e:{value:e,message:""},md=async(e,t,r,n,s,i)=>{const{ref:o,refs:a,required:c,maxLength:u,minLength:d,min:f,max:g,pattern:p,validate:b,name:h,valueAsNumber:v,mount:y}=e._f,C=W(r,h);if(!y||t.has(h))return{};const S=a?a[0]:o,_=N=>{if(s&&S.reportValidity){const B=Vt(N)?"":N||"";a?a.forEach(P=>P.setCustomValidity(B)):S.setCustomValidity(B),S.reportValidity()}},x={},E=Yl(o),D=si(o),T=E||D,j=(v||Kl(o))&&We(o.value)&&We(C)||to(o)&&o.value===""||C===""||Array.isArray(C)&&!C.length,F=zL.bind(null,h,n,x),O=(N,B,P,U=nr.maxLength,ne=nr.minLength)=>{const H=N?B:P;x[h]={type:N?U:ne,message:H,ref:o,...F(N?U:ne,H)}};if(i?!Array.isArray(C)||!C.length:c&&(!T&&(j||vt(C))||Vt(C)&&!C||D&&!jp(a).isValid||E&&!Rp(a).isValid)){const{value:N,message:B}=At(c)?{value:!!c,message:c}:Ln(c);if(N&&(x[h]={type:nr.required,message:B,ref:S,...F(nr.required,B)},!n))return _(B),x}if(!j&&(!vt(f)||!vt(g))){let N,B;const P=Ln(g),U=Ln(f);if(!vt(C)&&!isNaN(C)){const ne=o.valueAsNumber||C&&+C;vt(P.value)||(N=ne>P.value),vt(U.value)||(B=ne<U.value)}else{const ne=o.valueAsDate||new Date(C),H=oe=>new Date(new Date().toDateString()+" "+oe),te=o.type=="time",he=o.type=="week";At(P.value)&&C&&(N=te?H(C)>H(P.value):he?C>P.value:ne>new Date(P.value)),At(U.value)&&C&&(B=te?H(C)<H(U.value):he?C<U.value:ne<new Date(U.value))}if((N||B)&&(O(!!N,P.message,U.message,nr.max,nr.min),!n))return _(x[h].message),x}if((u||d)&&!j&&(At(C)||i&&Array.isArray(C))){const N=Ln(u),B=Ln(d),P=!vt(N.value)&&C.length>+N.value,U=!vt(B.value)&&C.length<+B.value;if((P||U)&&(O(P,N.message,B.message),!n))return _(x[h].message),x}if(p&&!j&&At(C)){const{value:N,message:B}=Ln(p);if(ro(N)&&!C.match(N)&&(x[h]={type:nr.pattern,message:B,ref:o,...F(nr.pattern,B)},!n))return _(B),x}if(b){if(Et(b)){const N=await b(C,r),B=pd(N,S);if(B&&(x[h]={...B,...F(nr.validate,B.message)},!n))return _(B.message),x}else if(Ye(b)){let N={};for(const B in b){if(!ft(N)&&!n)break;const P=pd(await b[B](C,r),S,B);P&&(N={...P,...F(B,P.message)},_(P.message),n&&(x[h]=N))}if(!ft(N)&&(x[h]={ref:S,...N},!n))return x}}return _(!0),x};const tO={mode:ir.onSubmit,reValidateMode:ir.onChange,shouldFocusError:!0},Fp={submitCount:0,isDirty:!1,isReady:!1,isValidating:!1,isSubmitted:!1,isSubmitting:!1,isSubmitSuccessful:!1,isValid:!1,touchedFields:{},dirtyFields:{},validatingFields:{}};function rO(e={}){let t={...tO,...e},r={...Xe(Fp),isLoading:Et(t.defaultValues),errors:t.errors||{},disabled:t.disabled||!1},n={},s=Ye(t.defaultValues)||Ye(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 g={...f};const p={array:id(),state:id()},b=t.criteriaMode===ir.all,h=w=>k=>{clearTimeout(u),u=setTimeout(w,k)},v=async w=>{if(!o.keepIsValid&&!t.disabled&&(f.isValid||g.isValid||w)){let k;t.resolver?(k=ft((await F()).errors),y()):k=await B({fields:n,onlyCheckValid:!0,eventType:Nr.VALID}),k!==r.isValid&&p.state.next({isValid:k})}},y=(w,k)=>{!t.disabled&&(f.isValidating||f.validatingFields||g.isValidating||g.validatingFields)&&((w||Array.from(a.mount)).forEach(L=>{L&&(k?ze(r.validatingFields,L,k):nt(r.validatingFields,L))}),p.state.next({validatingFields:r.validatingFields,isValidating:!ft(r.validatingFields)}))},C=()=>{r.dirtyFields=Xr(s,i)},S=(w,k=[],L,z,V=!0,G=!0)=>{if(z&&L&&!t.disabled){if(o.action=!0,G&&Array.isArray(W(n,w))){const $=L(W(n,w),z.argA,z.argB);V&&ze(n,w,$)}if(G&&Array.isArray(W(r.errors,w))){const $=L(W(r.errors,w),z.argA,z.argB);V&&ze(r.errors,w,$),eO(r.errors,w)}if((f.touchedFields||g.touchedFields)&&G&&Array.isArray(W(r.touchedFields,w))){const $=L(W(r.touchedFields,w),z.argA,z.argB);V&&ze(r.touchedFields,w,$)}(f.dirtyFields||g.dirtyFields)&&C(),p.state.next({name:w,isDirty:U(w,k),dirtyFields:r.dirtyFields,errors:r.errors,isValid:r.isValid})}else ze(i,w,k)},_=(w,k)=>{ze(r.errors,w,k),r.errors={...r.errors},p.state.next({errors:r.errors})},x=w=>{r.errors=w,p.state.next({errors:r.errors,isValid:!1})},E=w=>{const k=ii(w)?[w]:No(w);let L=i,z=s;for(let V=0;V<k.length-1;V++){const G=k[V];if(L=vt(L)?L:L[G],z=vt(z)?z:z[G],L===null&&z!==null)return!0}return!1},D=(w,k,L,z)=>{const V=W(n,w);if(V){if(E(w))return;const G=We(W(i,w)),$=W(i,w,We(L)?W(s,w):L);We($)||z&&z.defaultChecked||k?ze(i,w,k?$:cd(V._f)):te(w,$),o.mount&&!o.action&&(v(),G&&r.isDirty&&(f.isDirty||g.isDirty)&&(U()||(r.isDirty=!1,p.state.next({...r}))),e.shouldUnregister&&G&&!We(W(i,w))&&da(w,a)&&(o.watch=!0))}},T=(w,k,L,z,V)=>{let G=!1,$=!1;const re={name:w};if(!t.disabled){if(!L||z){(f.isDirty||g.isDirty)&&($=r.isDirty,r.isDirty=re.isDirty=U(),G=$!==re.isDirty);const be=Ht(W(s,w),k);$=!!W(r.dirtyFields,w),be!==r.isDirty?r.dirtyFields=Xr(s,i):be?nt(r.dirtyFields,w):ze(r.dirtyFields,w,!0),re.dirtyFields=r.dirtyFields,G=G||(f.dirtyFields||g.dirtyFields)&&$!==!be}if(L){const be=W(r.touchedFields,w);be||(ze(r.touchedFields,w,L),re.touchedFields=r.touchedFields,G=G||(f.touchedFields||g.touchedFields)&&be!==L)}G&&V&&p.state.next(re)}return G?re:{}},j=(w,k,L,z)=>{const V=W(r.errors,w),G=(f.isValid||g.isValid)&&Vt(k)&&r.isValid!==k;if(t.delayError&&L?(c=h(()=>_(w,L)),c(t.delayError)):(clearTimeout(u),c=null,L?ze(r.errors,w,L):nt(r.errors,w),r.errors={...r.errors}),(L?!Ht(V,L):V)||!ft(z)||G){const $={...z,...G&&Vt(k)?{isValid:k}:{},errors:r.errors,name:w};r={...r,...$},p.state.next($)}},F=async w=>(y(w,!0),await t.resolver(i,t.context,GL(w||a.mount,n,t.criteriaMode,t.shouldUseNativeValidation))),O=async w=>{const{errors:k}=await F(w);if(y(w),w){for(const L of w){const z=W(k,L);z?a.array.has(L)&&Ye(z)&&!Object.keys(z).some(V=>!Number.isNaN(Number(V)))?hd(r.errors,{[L]:z},L):ze(r.errors,L,z):nt(r.errors,L)}r.errors={...r.errors}}else r.errors=k;return k},N=async({name:w,eventType:k})=>{if(e.validate){const L=await e.validate({formValues:i,formState:r,name:w,eventType:k});if(Ye(L))for(const z in L){const V=L[z];V&&Ce(`${ca}.${z}`,{message:At(V.message)?V.message:"",type:V.type||nr.validate})}else At(L)||!L?Ce(ca,{message:L||"",type:nr.validate}):le(ca);return L}return!0},B=async({fields:w,onlyCheckValid:k,name:L,eventType:z,context:V={valid:!0,runRootValidation:!1}})=>{if(e.validate&&(V.runRootValidation=!0,!await N({name:L,eventType:z})&&(V.valid=!1,k)))return V.valid;for(const G in w){const $=w[G];if($){const{_f:re,...be}=$;if(re){const $e=a.array.has(re.name),Ot=$._f&&KL($._f),Nt=f.validatingFields||f.isValidating||g.validatingFields||g.isValidating;Ot&&Nt&&y([re.name],!0);const br=await md($,a.disabled,i,b,t.shouldUseNativeValidation&&!k,$e);if(Ot&&Nt&&y([re.name]),br[re.name]&&(V.valid=!1,k)||(!k&&(W(br,re.name)?$e?hd(r.errors,br,re.name):ze(r.errors,re.name,br[re.name]):nt(r.errors,re.name)),e.shouldUseNativeValidation&&br[re.name]))break}!ft(be)&&await B({context:V,onlyCheckValid:k,fields:be,name:G,eventType:z})}}return V.valid},P=()=>{for(const w of a.unMount){const k=W(n,w);k&&(k._f.refs?k._f.refs.every(L=>!ua(L)):!ua(k._f.ref))&&se(w)}a.unMount=new Set},U=(w,k)=>!t.disabled&&(w&&k&&ze(i,w,k),!Ht(M(),s)),ne=(w,k,L)=>ol(w,a,{...o.mount?i:We(k)?s:At(w)?{[w]:k}:k},L,k),H=w=>Dp(W(o.mount?i:s,w,t.shouldUnregister?W(s,w,[]):[])),te=(w,k,L={},z=!1)=>{const V=W(n,w);let G=k;if(V){const $=V._f;$&&(!$.disabled&&ze(i,w,Pp(k,$)),G=to($.ref)&&vt(k)?"":k,Op($.ref)?[...$.ref.options].forEach(re=>re.selected=G.includes(re.value)):$.refs?si($.ref)?$.refs.forEach(re=>{(!re.defaultChecked||!re.disabled)&&(Array.isArray(G)?re.checked=!!G.find(be=>be===re.value):re.checked=G===re.value||!!G)}):$.refs.forEach(re=>re.checked=re.value===G):Kl($.ref)?$.ref.value="":($.ref.value=G,$.ref.type||p.state.next({name:w,values:z?i:Xe(i)})))}(L.shouldDirty||L.shouldTouch)&&T(w,G,L.shouldTouch,L.shouldDirty,!0),L.shouldValidate&&R(w)},he=(w,k,L,z=!1)=>{for(const V in k){if(!k.hasOwnProperty(V))return;const G=k[V],$=w+"."+V,re=W(n,$);(a.array.has(w)||Ye(G)||re&&!re._f)&&!tn(G)?he($,G,L,z):te($,G,L,z)}},oe=(w,k,L,z)=>{const V=W(n,w),G=a.array.has(w),$=z?k:Xe(k),re=W(i,w),be=Ht(re,$);if(be||ze(i,w,$),G)p.array.next({name:w,values:z?i:Xe(i)}),(f.isDirty||f.dirtyFields||g.isDirty||g.dirtyFields)&&L.shouldDirty&&(C(),p.state.next({name:w,dirtyFields:r.dirtyFields,isDirty:U(w,$)}));else{const $e=Array.isArray($)&&!$.length||ft($);!V||V._f||vt($)||$e?te(w,$,L,z):he(w,$,L,z)}if(!be){const $e=da(w,a),Ot=z?i:Xe(i);p.state.next({...$e&&r,name:o.mount||$e?w:void 0,values:Ot})}},ge=(w,k,L={})=>oe(w,k,L,!1),ve=(w,k={})=>{const L=Et(w)?w(i):w;if(!Ht(i,L)){i={...i,...L};for(const z of a.mount)oe(z,W(L,z),k,!0);p.state.next({...r,name:void 0,type:void 0,values:i}),k.shouldValidate&&v()}},xe=async w=>{o.mount=!0;const k=w.target;let L=k.name,z=!0;const V=W(n,L),G=be=>{z=Number.isNaN(be)||tn(be)&&isNaN(be.getTime())||Ht(be,W(i,L,be))},$=ud(t.mode),re=ud(t.reValidateMode);if(V){let be,$e;const Ot=k.type?cd(V._f):il(w),Nt=w.type===Nr.BLUR||w.type===Nr.FOCUS_OUT,br=!YL(V._f)&&!e.validate&&!t.resolver&&!W(r.errors,L)&&!V._f.deps||JL(Nt,W(r.touchedFields,L),r.isSubmitted,re,$),ls=da(L,a,Nt);ze(i,L,Ot),Nt?(!k||!k.readOnly)&&(V._f.onBlur&&V._f.onBlur(w),c&&c(0)):V._f.onChange&&V._f.onChange(w);const Yr=T(L,Ot,Nt),ct=!ft(Yr)||ls;if(!Nt&&p.state.next({name:L,type:w.type,values:Xe(i)}),br)return(f.isValid||g.isValid)&&(t.mode==="onBlur"?Nt&&v():Nt||v()),ct&&p.state.next({name:L,...ls?{}:Yr});if(!t.resolver&&e.validate&&await N({name:L,eventType:w.type}),!Nt&&ls&&p.state.next({...r}),t.resolver){const{errors:Ct}=await F([L]);if(y([L]),G(Ot),!z){!ft(Yr)&&p.state.next(Yr);return}const kt=fd(r.errors,n,L),tr=fd(Ct,n,kt.name||L);be=tr.error,L=tr.name,$e=ft(Ct)}else y([L],!0),be=(await md(V,a.disabled,i,b,t.shouldUseNativeValidation))[L],y([L]),G(Ot),z&&(be?$e=!1:(f.isValid||g.isValid)&&($e=await B({fields:n,onlyCheckValid:!0,name:L,eventType:w.type})));z&&(V._f.deps&&(!Array.isArray(V._f.deps)||V._f.deps.length>0)&&R(V._f.deps),j(L,$e,be,Yr))}},ye=(w,k)=>{if(W(r.errors,k)&&w.focus)return w.focus(),1},R=async(w,k={})=>{let L,z;const V=Mi(w);if(t.resolver){const G=await O(We(w)?w:V);L=ft(G),z=w?!V.some($=>W(G,$)):L}else w?(z=(await Promise.all(V.map(async G=>{const $=W(n,G);return await B({fields:$&&$._f?{[G]:$}:$,eventType:Nr.TRIGGER})}))).every(Boolean),!(!z&&!r.isValid)&&v()):z=L=await B({fields:n,name:w,eventType:Nr.TRIGGER});return p.state.next({...!At(w)||(f.isValid||g.isValid)&&L!==r.isValid?{}:{name:w},...t.resolver||!w?{isValid:L}:{},errors:r.errors}),k.shouldFocus&&!z&&Is(n,ye,w?V:a.mount),z},M=(w,k)=>{let L={...o.mount?i:s};return k&&(L=Lp(k.dirtyFields?r.dirtyFields:r.touchedFields,L)),We(w)?L:At(w)?W(L,w):w.map(z=>W(L,z))},Y=(w,k)=>({invalid:!!W((k||r).errors,w),isDirty:!!W((k||r).dirtyFields,w),error:W((k||r).errors,w),isValidating:!!W(r.validatingFields,w),isTouched:!!W((k||r).touchedFields,w)}),le=w=>{const k=w?Mi(w):void 0;k==null||k.forEach(L=>nt(r.errors,L)),k?k.forEach(L=>{p.state.next({name:L,errors:r.errors})}):p.state.next({errors:{}})},Ce=(w,k,L)=>{const z=(W(n,w,{_f:{}})._f||{}).ref,V=W(r.errors,w)||{},{ref:G,message:$,type:re,...be}=V;ze(r.errors,w,{...be,...k,ref:z}),p.state.next({name:w,errors:r.errors,isValid:!1}),L&&L.shouldFocus&&z&&z.focus&&z.focus()},de=(w,k)=>Et(w)?p.state.subscribe({next:L=>"values"in L&&w(L.values||ne(void 0,k),L)}):ne(w,k,!0),ce=w=>p.state.subscribe({next:k=>{if(XL(w.name,k.name,w.exact)&&ZL(k,w.formState||f,Kr,w.reRenderRoot)){const L={...i};w.callback({values:L,...r,...k,defaultValues:s})}}}).unsubscribe,Q=w=>(o.mount=!0,g={...g,...w.formState},ce({...w,formState:{...d,...w.formState}})),se=(w,k={})=>{for(const L of w?Mi(w):a.mount)a.mount.delete(L),a.array.delete(L),k.keepValue||(nt(n,L),nt(i,L)),!k.keepError&&nt(r.errors,L),!k.keepDirty&&nt(r.dirtyFields,L),!k.keepTouched&&nt(r.touchedFields,L),!k.keepIsValidating&&nt(r.validatingFields,L),!t.shouldUnregister&&!k.keepDefaultValue&&nt(s,L);p.state.next({values:Xe(i)}),p.state.next({...r,...k.keepDirty?{isDirty:U()}:{}}),!k.keepIsValid&&v()},Te=({disabled:w,name:k})=>{if(Vt(w)&&o.mount||w||a.disabled.has(k)){const V=a.disabled.has(k)!==!!w;w?a.disabled.add(k):a.disabled.delete(k),V&&o.mount&&!o.action&&v()}},me=(w,k={})=>{let L=W(n,w);const z=Vt(k.disabled)||Vt(t.disabled),V=!a.registerName.has(w)&&L&&L._f&&!L._f.mount;return ze(n,w,{...L||{},_f:{...L&&L._f?L._f:{ref:{name:w}},name:w,mount:!0,...k}}),a.mount.add(w),L&&!V?Te({disabled:Vt(k.disabled)?k.disabled:t.disabled,name:w}):D(w,!0,k.value),{...z?{disabled:k.disabled||t.disabled}:{},...t.progressive?{required:!!k.required,min:ys(k.min),max:ys(k.max),minLength:ys(k.minLength),maxLength:ys(k.maxLength),pattern:ys(k.pattern)}:{},name:w,onChange:xe,onBlur:xe,ref:G=>{if(G){a.registerName.add(w),me(w,k),a.registerName.delete(w),L=W(n,w);const $=We(G.value)&&G.querySelectorAll&&G.querySelectorAll("input,select,textarea")[0]||G,re=VL($),be=L._f.refs||[];if(re?be.find($e=>$e===$):$===L._f.ref)return;ze(n,w,{_f:{...L._f,...re?{refs:[...be.filter(ua),$,...Array.isArray(W(s,w))?[{}]:[]],ref:{type:$.type,name:w}}:{ref:$}}}),D(w,!1,void 0,$)}else L=W(n,w,{}),L._f&&(L._f.mount=!1),(t.shouldUnregister||k.shouldUnregister)&&!(Tp(a.array,w)&&o.action)&&a.unMount.add(w)}}},ee=()=>t.shouldFocusError&&!t.shouldUseNativeValidation&&Is(n,ye,a.mount),He=w=>{Vt(w)&&(p.state.next({disabled:w}),Is(n,(k,L)=>{const z=W(n,L);z&&(k.disabled=z._f.disabled||w,Array.isArray(z._f.refs)&&z._f.refs.forEach(V=>{V.disabled=z._f.disabled||w}))},0,!1))},Ge=(w,k)=>async L=>{let z;L&&(L.preventDefault&&L.preventDefault(),L.persist&&L.persist());let V=Xe(i);if(p.state.next({isSubmitting:!0}),t.resolver){const{errors:G,values:$}=await F();y(),r.errors=G,V=Xe($)}else await B({fields:n,eventType:Nr.SUBMIT});if(a.disabled.size)for(const G of a.disabled)nt(V,G);if(nt(r.errors,Ap),ft(r.errors)){p.state.next({errors:{}});try{await w(V,L)}catch(G){z=G}}else k&&await k({...r.errors},L),ee(),setTimeout(ee);if(p.state.next({isSubmitted:!0,isSubmitting:!1,isSubmitSuccessful:ft(r.errors)&&!z,submitCount:r.submitCount+1,errors:r.errors}),z)throw z},Ze=(w,k={})=>{W(n,w)&&(We(k.defaultValue)?ge(w,Xe(W(s,w))):(ge(w,k.defaultValue),ze(s,w,Xe(k.defaultValue))),k.keepTouched||nt(r.touchedFields,w),k.keepDirty||(nt(r.dirtyFields,w),r.isDirty=k.defaultValue?U(w,Xe(W(s,w))):U()),k.keepError||(nt(r.errors,w),f.isValid&&v()),p.state.next({...r}))},Qe=(w,k={})=>{const L=w?Xe(w):s,z=Xe(L),V=ft(w),G=z;if(k.keepDefaultValues||(s=L),!k.keepValues){if(k.keepDirtyValues){const $=new Set([...a.mount,...Object.keys(Xr(s,i))]);for(const re of Array.from($)){const be=W(r.dirtyFields,re),$e=W(i,re),Ot=W(G,re);be&&!We($e)?ze(G,re,$e):!be&&!We(Ot)&&ge(re,Ot)}}else{if(Oo&&We(w))for(const $ of a.mount){const re=W(n,$);if(re&&re._f){const be=Array.isArray(re._f.refs)?re._f.refs[0]:re._f.ref;if(to(be)){const $e=be.closest("form");if($e){$e.reset();break}}}}if(k.keepFieldsRef)for(const $ of a.mount)ge($,W(G,$));else n={}}if(t.shouldUnregister){if(i=k.keepDefaultValues?Xe(s):{},k.keepFieldsRef)for(const $ of a.mount)ze(i,$,W(G,$))}else i=Xe(G);p.array.next({values:{...G}}),p.state.next({values:{...G}})}a={mount:k.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||!!k.keepIsValid||!!k.keepDirtyValues||!t.shouldUnregister&&!ft(G),o.watch=!!t.shouldUnregister,o.keepIsValid=!!k.keepIsValid,o.action=!1,k.keepErrors||(r.errors={}),p.state.next({submitCount:k.keepSubmitCount?r.submitCount:0,isDirty:V?!1:k.keepDirty?r.isDirty:k.keepValues?U():!!(k.keepDefaultValues&&!Ht(w,s)),isSubmitted:k.keepIsSubmitted?r.isSubmitted:!1,dirtyFields:V?{}:k.keepDirtyValues?k.keepDefaultValues&&i?Xr(s,i):r.dirtyFields:k.keepDefaultValues&&w?Xr(s,w):k.keepDirty?r.dirtyFields:{},touchedFields:k.keepTouched?r.touchedFields:{},errors:k.keepErrors?r.errors:{},isSubmitSuccessful:k.keepIsSubmitSuccessful?r.isSubmitSuccessful:!1,isSubmitting:!1,defaultValues:s})},tt=(w,k)=>Qe(Et(w)?w(i):w,{...t.resetOptions,...k}),st=(w,k={})=>{const L=W(n,w),z=L&&L._f;if(z){const V=z.refs?z.refs[0]:z.ref;V.focus&&setTimeout(()=>{V.focus(),k.shouldSelect&&Et(V.select)&&V.select()})}},Kr=w=>{r={...r,...w}},_e={control:{register:me,unregister:se,getFieldState:Y,handleSubmit:Ge,setError:Ce,_subscribe:ce,_runSchema:F,_updateIsValidating:y,_focusError:ee,_getWatch:ne,_getDirty:U,_setValid:v,_setFieldArray:S,_setDisabledField:Te,_setErrors:x,_getFieldArray:H,_reset:Qe,_resetDefaultValues:()=>Et(t.defaultValues)&&t.defaultValues().then(w=>{tt(w,t.resetOptions),p.state.next({isLoading:!1})}),_removeUnmounted:P,_disableForm:He,_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:Q,trigger:R,register:me,handleSubmit:Ge,watch:de,setValue:ge,setValues:ve,getValues:M,reset:tt,resetField:Ze,resetDefaultValues:(w,k={})=>{if(s=Xe(w),!k.keepDirty){const L=Xr(s,i);r.dirtyFields=L,r.isDirty=!ft(L)}k.keepIsValid||v(),p.state.next({...r,defaultValues:s})},clearErrors:le,unregister:se,setError:Ce,setFocus:st,getFieldState:Y};return{..._e,formControl:_e}}function nO(e={}){const t=m.useRef(void 0),r=m.useRef(void 0),n=m.useRef(e.formControl),[s,i]=m.useState(()=>({...Xe(Fp),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}=rO(e);t.current={...c,formState:s}}const o=t.current.control;return o._options=e,Wl(()=>{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]),m.useEffect(()=>o._disableForm(e.disabled),[o,e.disabled]),m.useEffect(()=>{e.mode&&(o._options.mode=e.mode),e.reValidateMode&&(o._options.reValidateMode=e.reValidateMode)},[o,e.mode,e.reValidateMode]),m.useEffect(()=>{e.errors&&(o._setErrors(e.errors),o._focusError())},[o,e.errors]),m.useEffect(()=>{e.shouldUnregister&&o._subjects.state.next({values:o._getWatch()})},[o,e.shouldUnregister]),m.useEffect(()=>{if(o._proxyFormState.isDirty){const a=o._getDirty();a!==s.isDirty&&o._subjects.state.next({isDirty:a})}},[o,s.isDirty]),m.useEffect(()=>{var a;e.values&&!Ht(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]),m.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=m.useMemo(()=>kp(s,o),[o,s]),t.current}function sO(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}=Zn({queryKey:["framework-search",i.sort().join(","),r],queryFn:()=>y1({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 Mp(e){var r,n;return(n=(r=(await Re.get(`/action/channel/v1/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.channel}function iO(e){var r,n,s,i,o,a,c;const t=Zn({queryKey:["channel",e],queryFn:()=>Mp(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 oO(e){const{data:t}=Zn({queryKey:["user","read",e],enabled:!!e,staleTime:1/0,queryFn:()=>B1(e)});return t&&([t.firstName,t.lastName].filter(Boolean).join(" ").trim()||t.userName)||void 0}const Bp=[{label:"Strict",value:"Fixed"},{label:"Adaptive",value:"Diagnostic"},{label:"Prior learning",value:"PriorLearning"}],aO={"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."}},lO=new Set(["review","read","sourcingreview","orgreview"]),yi={"First Section":"details","Second Section":"details","Third Section":"details","Organisation Framework Terms":"details","Target Framework Terms":"audience","Fourth Section":"licensing","Sixth Section":"licensing"},cO={Categorisation:"Second Section","Basic Information":"First Section","Licensing & Attribution":"Fourth Section",Curriculum:"Organisation Framework Terms","Target Audience":"Target Framework Terms"},uO={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"},ai={board:"board",boardIds:"board",medium:"medium",gradeLevel:"gradeLevel",subject:"subject",subjectIds:"subject",topicsIds:"topic",topic:"topic",targetBoardIds:"board",targetMediumIds:"medium",targetGradeLevelIds:"gradeLevel",targetSubjectIds:"subject"},Zl=new Set(["targetBoardIds","targetMediumIds","targetGradeLevelIds","targetSubjectIds"]);function qp(e,t,r,n,s={}){if(!(e!=null&&e.length))return gd(kO(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"&&Zl.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=vO(c),f=yO(c,r,t,i,s),g=t[u],p=fO(u,$p(g,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:dO(u,c.editable!==!1,s),placeholder:c.placeholder,maxLength:c.maxLength,options:mO(f,p,d,r),depends:c.depends,tab:gO(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 gd(a,r,t,n,s)}function gd(e,t,r,n,s){var i;return((i=s.profile)==null?void 0:i.key)==="learningPath"?IO(e,t,r,n):AO(e,t,r,n)}function dO(e,t,r){var i;const n=r.editorMode??"edit";if(!lO.has(n))return t!==!1;const s=(i=r.editableFields)==null?void 0:i[n];return!!(s&&s.includes(e))}function fO(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!==""?hO(Number(a)):t}default:return t}}function hO(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 pO(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 mO(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=pO(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 gO(e){const t=e.section;if(t){if(yi[t])return yi[t];const n=cO[t];if(n&&yi[n])return yi[n]}const r=e.code??"";return uO[r]??"details"}function $p(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 vO(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 yO(e,t,r,n,s){var u;const i=e.code??"";if(((u=s.profile)==null?void 0:u.key)==="learningPath"&&i==="policy")return Bp;if(i==="maxQuestions"){const d=s.childCount??0;if(d>0)return Array.from({length:d},(f,g)=>({label:String(g+1),value:String(g+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,g=(f&&f.length?f:s.contextAdditionalCategories)??t.channelAdditionalCategories;return g!=null&&g.length?_O(g).map(p=>({label:p,value:p})):void 0}const c=e.sourceCategory??ai[i];if(c)return Up(i,c,e,t,r,n)}function bO(e,t){return Zl.has(e)||t.output==="identifier"||typeof t.section=="string"&&t.section.includes("Target")}function CO(e,t){return Zl.has(e)||typeof t.section=="string"&&t.section.includes("Target")}function fa(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 SO(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 _O(e){return Array.from(new Set(e))}function wO(e){return Array.isArray(e)?e:e!=null&&e!==""?[e]:[]}function Up(e,t,r,n,s,i){const o=bO(e,r),a=CO(e,r),c=h=>({label:h.name,value:o?h.identifier:h.name}),u=r.depends;if(!(u!=null&&u.length))return fa(n,t,a).map(c);const d=u.flatMap(h=>wO(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)??ai[h]??h;f.push(...fa(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=SO(p);return b.length?b.map(c):fa(n,t,a).map(c)}function bs(e,t){const r=ai[e];if(r)return Up(e,r,{},t,{},new Map)}function Je(e,t,r){return $p(e[t],r)}const xO=["board","medium","gradeLevel","subject"];function TO(e){var r;const t=((r=e.organisationFramework)==null?void 0:r.categories)??[];return t.length?t.some(n=>xO.includes(n.code)):!0}function EO(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 AO(e,t,r,n){var c;if(!n||TO(t))return e;const s=e.filter(u=>{const d=u.sourceCategory??ai[u.code];return!d||EO(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:Je(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 ha="Organisation Framework Terms";function IO(e,t,r,n){var g,p;if(!n)return e;const s=[...((g=t.organisationFramework)==null?void 0:g.categories)??[]].sort((b,h)=>(b.index??1/0)-(h.index??1/0));if(!s.length)return e;const i=(p=kh(s))==null?void 0:p.code,o=b=>b.sourceCategory??ai[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:ha}: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:ha,options:t.orgFrameworks,currentValue:Je(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:"multiselect",editable:!0,tab:"details",section:ha,options:(b.terms??[]).map(h=>({label:h.name,value:h.name})),currentValue:Je(r,b.code,"multiselect")}));return f.length?[...c.slice(0,u+1),...f,...c.slice(u+1)]:c}function kO(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:Je(e,"name","text")},{code:"description",label:"Description",inputType:"textarea",editable:!0,tab:"details",section:"First Section",maxLength:2e3,currentValue:Je(e,"description","textarea")},{code:"keywords",label:"Keywords",inputType:"chips",editable:!0,tab:"details",section:"First Section",currentValue:Je(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:Je(e,"framework","select")},{code:"policy",label:"Consumption policy",inputType:"select",required:!0,editable:!0,tab:"details",section:"Consumption policy",options:Bp,currentValue:Je(e,"policy","select")||"Fixed"}),s):(s.push({code:"primaryCategory",label:"Category",inputType:"select",editable:!1,tab:"details",section:"Second Section",currentValue:Je(e,"primaryCategory","select")},{code:"additionalCategories",label:"Additional Category",inputType:"multiselect",editable:!0,tab:"details",section:"Second Section",currentValue:Je(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:Je(e,"framework","select")},{code:"subjectIds",label:"Subjects covered",inputType:"multiselect",required:!0,editable:!0,tab:"details",section:"Organisation Framework Terms",options:bs("subjectIds",r),currentValue:Je(e,"subjectIds","multiselect")}),s.push({code:"audience",label:"Audience Type",inputType:"multiselect",editable:!0,tab:"audience",section:"Target Framework Terms",currentValue:Je(e,"audience","multiselect")},{code:"targetBoardIds",label:"Board/Syllabus of the audience",inputType:"select",required:!0,editable:!0,tab:"audience",section:"Target Framework Terms",options:bs("targetBoardIds",r),currentValue:Je(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:bs("targetMediumIds",r),currentValue:Je(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:bs("targetGradeLevelIds",r),currentValue:Je(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:bs("targetSubjectIds",r),currentValue:Je(e,"targetSubjectIds","multiselect")}),s.push({code:"creator",label:"Author",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"creator","text")},{code:"attributions",label:"Attributions",inputType:"text",editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"attributions","text")},{code:"copyright",label:"Copyright",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"copyright","text")},{code:"copyrightYear",label:"Copyright Year",inputType:"text",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"copyrightYear","text")},{code:"license",label:"License",inputType:"select",required:!0,editable:!0,tab:"licensing",section:"Fourth Section",currentValue:Je(e,"license","select")}),s):s}const DO=["allowECM","levels","setPeriod","instances"];function zp(e){const t={};return e.forEach((r,n)=>{t[`L${n+1}`]={label:r}}),t}function LO(e,t={}){const r={...e};for(const i of DO)delete r[i];const n=e.levels;Array.isArray(n)&&n.length&&(r.outcomeDeclaration={levels:zp(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 OO(e,t){return e==="allowECM"||e==="setPeriod"?null:e==="levels"?{outcomeDeclaration:{levels:Array.isArray(t)?zp(t):{}}}:e==="instances"?{instances:t!=null&&t!==""?{label:t}:""}:{[e]:t}}function NO(e,t){const{watch:r,setValue:n}=e,s=m.useRef(!1);m.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(g=>u.has(g))&&(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 jO="_section_qa0tm_1",PO="_header_qa0tm_11",RO="_title_qa0tm_17",FO="_description_qa0tm_24",MO="_divider_qa0tm_30",BO="_fields_qa0tm_36",On={section:jO,header:PO,title:RO,description:FO,divider:MO,fields:BO},qO=({title:e,description:t,children:r})=>l.jsxs("div",{className:On.section,children:[l.jsxs("div",{className:On.header,children:[l.jsx("h3",{className:On.title,children:e}),t&&l.jsx("p",{className:On.description,children:t})]}),l.jsx("hr",{className:On.divider}),l.jsx("div",{className:On.fields,children:r})]}),$O="_field_93co8_1",UO="_fullWidth_93co8_7",zO="_label_93co8_11",VO="_required_93co8_19",HO="_input_93co8_24",QO="_textarea_93co8_45",WO="_inputError_93co8_50",GO="_error_93co8_54",KO="_selectBtn_93co8_59",YO="_selectOpen_93co8_83",ZO="_placeholder_93co8_87",XO="_selectedVal_93co8_91",JO="_chevronUp_93co8_95",eN="_dropdown_93co8_100",tN="_option_93co8_116",rN="_optionSelected_93co8_134",nN="_noOpts_93co8_139",sN="_chipGroup_93co8_146",iN="_chipInput_93co8_158",oN="_addChipBtn_93co8_167",aN="_radioGroup_93co8_184",lN="_radioLabel_93co8_191",cN="_iconWrap_93co8_199",uN="_iconPreview_93co8_214",dN="_iconPlaceholder_93co8_220",fN="_removeIconBtn_93co8_233",hN="_tagChip_93co8_252",pN="_tagChipRemove_93co8_264",mN="_nestedSelectRow_93co8_278",gN="_dialcodeRow_93co8_287",vN="_validateBtn_93co8_293",yN="_dialcodeValid_93co8_315",bN="_dialcodeSpinner_93co8_325",q={field:$O,fullWidth:UO,label:zO,required:VO,input:HO,textarea:QO,inputError:WO,error:GO,selectBtn:KO,selectOpen:YO,placeholder:ZO,selectedVal:XO,chevronUp:JO,dropdown:eN,option:tN,optionSelected:rN,noOpts:nN,chipGroup:sN,chipInput:iN,addChipBtn:oN,radioGroup:aN,radioLabel:lN,iconWrap:cN,iconPreview:uN,iconPlaceholder:dN,removeIconBtn:fN,tagChip:hN,tagChipRemove:pN,nestedSelectRow:mN,dialcodeRow:gN,validateBtn:vN,dialcodeValid:yN,dialcodeSpinner:bN},vd=({name:e,label:t,required:r,disabled:n,multiline:s,maxLength:i,placeholder:o})=>{const a=ae(),{register:c,formState:{errors:u}}=er(),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)})]})},CN=({name:e,label:t,options:r,required:n,disabled:s})=>{var v;const i=ae(),[o,a]=m.useState(!1),c=m.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:g}}=er(),p=d(e),b=((v=r.find(y=>y.value===p))==null?void 0:v.label)??i.selectField.selectPlaceholder,h=g[e];return m.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(bn,{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(yn,{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)})]})},SN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=ae(),[o,a]=m.useState(!1),c=m.useRef(null),{register:u,watch:d,setValue:f,formState:{errors:g}}=er(),p=d(e)??[],b=g[e],h=p.length?`${p.length} ${i.multiSelectField.selectedCountSuffix}`:i.multiSelectField.selectPlaceholder;m.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(bn,{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(yn,{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)})]})},_N=({name:e,label:t,required:r,disabled:n,placeholder:s})=>{const i=ae(),o=s??i.chipGroupField.addPlaceholder,[a,c]=m.useState(""),[u,d]=m.useState(!1),f=m.useRef(null),{watch:g,setValue:p,formState:{errors:b}}=er(),h=g(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(Cn,{size:12})," ",i.chipGroupField.addButtonLabel]}))]}),v&&l.jsx("span",{className:q.error,children:String(v.message)})]})},wN=({name:e,label:t,options:r,required:n,disabled:s})=>{const i=ae(),{register:o,formState:{errors:a}}=er(),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 xN(e,t,r,n){var o,a;const i=(a=(o=(await Re.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 TN(e,t){var s,i;const n=(i=(s=(await Re.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 EN(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 AN(e,t,r){var o,a;const n=new FormData;n.append("fileUrl",t),n.append("mimeType",r);const i=(a=(o=(await Re.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 IN="_overlay_1bq5u_1",kN="_modal_1bq5u_12",DN="_header_1bq5u_24",LN="_title_1bq5u_33",ON="_closeBtn_1bq5u_39",NN="_tabs_1bq5u_57",jN="_tab_1bq5u_57",PN="_activeTab_1bq5u_83",RN="_body_1bq5u_88",FN="_searchWrap_1bq5u_99",MN="_searchIcon_1bq5u_104",BN="_searchInput_1bq5u_113",qN="_grid_1bq5u_132",$N="_imgCell_1bq5u_148",UN="_imgCellSelected_1bq5u_166",zN="_thumb_1bq5u_171",VN="_noThumb_1bq5u_177",HN="_checkBadge_1bq5u_183",QN="_loadMoreBtn_1bq5u_198",WN="_loadingRow_1bq5u_220",GN="_empty_1bq5u_230",KN="_spinner_1bq5u_237",YN="_uploadArea_1bq5u_247",ZN="_dropZone_1bq5u_256",XN="_uploadIcon_1bq5u_277",JN="_dropText_1bq5u_281",ej="_dropSubtext_1bq5u_288",tj="_uploadPreview_1bq5u_294",rj="_hiddenInput_1bq5u_301",nj="_fileName_1bq5u_305",sj="_errorText_1bq5u_311",ij="_footer_1bq5u_318",oj="_cancelBtn_1bq5u_328",aj="_confirmBtn_1bq5u_345",Ae={overlay:IN,modal:kN,header:DN,title:LN,closeBtn:ON,tabs:NN,tab:jN,activeTab:PN,body:RN,searchWrap:FN,searchIcon:MN,searchInput:BN,grid:qN,imgCell:$N,imgCellSelected:UN,thumb:zN,noThumb:VN,checkBadge:HN,loadMoreBtn:QN,loadingRow:WN,empty:GN,spinner:KN,uploadArea:YN,dropZone:ZN,uploadIcon:XN,dropText:JN,dropSubtext:ej,uploadPreview:tj,hiddenInput:rj,fileName:nj,errorText:sj,footer:ij,cancelBtn:oj,confirmBtn:aj},yd=18,Vp=({nodeId:e,currentValue:t,onSelect:r,onClose:n})=>{const s=ae(),[i,o]=m.useState("my"),[a,c]=m.useState(""),[u,d]=m.useState([]),[f,g]=m.useState(0),[p,b]=m.useState(!1),[h,v]=m.useState(null),[y,C]=m.useState(0),[S,_]=m.useState(null),[x,E]=m.useState(""),[D,T]=m.useState(!1),[j,F]=m.useState(""),O=m.useRef(null),N=Z(R=>{var M,Y;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.channel)??""}),B=Z(R=>{var M,Y;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.uid)??""}),P=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.cloudStorage)==null?void 0:le.presigned_headers)??{}}),U=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.config)==null?void 0:Y.assetConfig)==null?void 0:le.size)??1*1024*1024}),ne=Z(R=>{var M,Y,le;return((le=(Y=(M=R.editorConfig)==null?void 0:M.config)==null?void 0:Y.assetConfig)==null?void 0:le.accepted)??"image/png,image/jpeg"}),H=m.useCallback(async(R,M,Y=!1)=>{var le;b(!0);try{const Ce={status:["Live"],mediaType:["image"],mimeType:["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml"]};i==="my"&&B&&(Ce.createdBy=B),N&&(Ce.channel=N);const ce=((le=(await Re.post("/action/composite/v3/search",{request:{filters:Ce,query:R,limit:yd,offset:M,sort_by:{createdOn:"desc"},fields:["identifier","name","appIcon","artifactUrl","downloadUrl"]}},{headers:{"X-Source":"web"}})).data)==null?void 0:le.result)??{},Q=ce.content??[];g(ce.count??0),d(se=>Y?[...se,...Q]:Q)}catch{}finally{b(!1)}},[i,B,N]);m.useEffect(()=>{i!=="upload"&&(d([]),C(0),H(a,0))},[i]);const te=m.useRef(),he=R=>{c(R),clearTimeout(te.current),te.current=setTimeout(()=>{d([]),C(0),H(R,0)},400)},oe=()=>{const R=y+yd;C(R),H(a,R,!0)},ge=()=>{const R=(h==null?void 0:h.artifactUrl)??(h==null?void 0:h.appIcon)??(h==null?void 0:h.downloadUrl)??"";R&&r(R)};m.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]);const ve=R=>{var le;const M=(le=R.target.files)==null?void 0:le[0];if(R.target.value="",!M)return;const Y=ne.split(",").map(Ce=>Ce.trim());if(!Y.includes(M.type)){const Ce=Y.map(de=>de.replace("image/","").toUpperCase()).join(", ");F(s.appIconPickerModal.invalidFileTypeError.replace("{types}",Ce));return}if(M.size>U){const Ce=(U/1048576).toFixed(0);F(s.appIconPickerModal.fileTooLargeError.replace("{size}",Ce));return}x&&URL.revokeObjectURL(x),_(M),E(URL.createObjectURL(M)),F("")},xe=async()=>{if(S){T(!0),F("");try{const R=await xN(S.name.split(".").slice(0,-1).join(".")||S.name,S.type,B,N),M=await TN(R,S.name);await EN(M,S,P);const Y=M.split("?")[0],le=await AN(R,Y,S.type);r(le)}catch(R){F(R instanceof Error?R.message:s.appIconPickerModal.uploadFailedError)}finally{T(!1)}}},ye=u.length<f;return l.jsx("div",{className:Ae.overlay,role:"dialog","aria-modal":"true","aria-label":s.appIconPickerModal.dialogAriaLabel,children:l.jsxs("div",{className:Ae.modal,children:[l.jsxs("div",{className:Ae.header,children:[l.jsx("span",{className:Ae.title,children:s.appIconPickerModal.title}),l.jsx("button",{className:Ae.closeBtn,onClick:n,"aria-label":s.appIconPickerModal.closeAriaLabel,children:l.jsx(yr,{size:18})})]}),l.jsxs("div",{className:Ae.tabs,role:"tablist",children:[l.jsx("button",{role:"tab","aria-selected":i==="my",className:`${Ae.tab} ${i==="my"?Ae.activeTab:""}`,onClick:()=>o("my"),children:s.appIconPickerModal.myImagesTab}),l.jsx("button",{role:"tab","aria-selected":i==="all",className:`${Ae.tab} ${i==="all"?Ae.activeTab:""}`,onClick:()=>o("all"),children:s.appIconPickerModal.allImagesTab}),l.jsxs("button",{role:"tab","aria-selected":i==="upload",className:`${Ae.tab} ${i==="upload"?Ae.activeTab:""}`,onClick:()=>o("upload"),children:[l.jsx(Fa,{size:13,style:{marginRight:4}}),s.appIconPickerModal.uploadTab]})]}),l.jsx("div",{className:Ae.body,children:i!=="upload"?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:Ae.searchWrap,children:[l.jsx(Wi,{size:14,className:Ae.searchIcon}),l.jsx("input",{type:"search",className:Ae.searchInput,placeholder:s.appIconPickerModal.searchPlaceholder,value:a,onChange:R=>he(R.target.value)})]}),p&&u.length===0?l.jsxs("div",{className:Ae.loadingRow,children:[l.jsx(Ti,{size:20,className:Ae.spinner}),l.jsx("span",{children:s.appIconPickerModal.loadingText})]}):u.length===0?l.jsx("div",{className:Ae.empty,children:s.appIconPickerModal.noImagesFound}):l.jsx("div",{className:Ae.grid,children:u.map(R=>{const M=R.appIcon??R.artifactUrl??R.downloadUrl??"",Y=(h==null?void 0:h.identifier)===R.identifier;return l.jsxs("button",{type:"button",className:`${Ae.imgCell} ${Y?Ae.imgCellSelected:""}`,onClick:()=>v(R),title:R.name,children:[M?l.jsx("img",{src:M,alt:R.name,className:Ae.thumb}):l.jsx("div",{className:Ae.noThumb,children:s.appIconPickerModal.noThumbnailText}),Y&&l.jsx("div",{className:Ae.checkBadge,children:l.jsx(yn,{size:12})})]},R.identifier)})}),ye&&!p&&l.jsx("button",{className:Ae.loadMoreBtn,onClick:oe,children:s.appIconPickerModal.loadMoreButton}),p&&u.length>0&&l.jsx("div",{className:Ae.loadingRow,children:l.jsx(Ti,{size:16,className:Ae.spinner})})]}):l.jsxs("div",{className:Ae.uploadArea,children:[l.jsx("div",{className:Ae.dropZone,onClick:()=>{var R;return(R=O.current)==null?void 0:R.click()},onDragOver:R=>R.preventDefault(),onDrop:R=>{R.preventDefault();const M=R.dataTransfer.files[0];M&&ve({target:{files:[M],value:""}})},children:x?l.jsx("img",{src:x,alt:s.appIconPickerModal.previewAlt,className:Ae.uploadPreview}):l.jsxs(l.Fragment,{children:[l.jsx(Fa,{size:32,className:Ae.uploadIcon}),l.jsx("p",{className:Ae.dropText,children:s.appIconPickerModal.dropZoneText}),l.jsx("p",{className:Ae.dropSubtext,children:s.appIconPickerModal.acceptedTypesInfo.replace("{types}",ne.split(",").map(R=>R.replace("image/","").toUpperCase()).join(", ")).replace("{size}",(U/(1024*1024)).toFixed(0))})]})}),l.jsx("input",{ref:O,type:"file",accept:ne,className:Ae.hiddenInput,onChange:ve}),S&&l.jsx("p",{className:Ae.fileName,children:S.name}),j&&l.jsx("p",{className:Ae.errorText,children:j})]})}),l.jsxs("div",{className:Ae.footer,children:[l.jsx("button",{className:Ae.cancelBtn,onClick:n,children:s.appIconPickerModal.cancelButton}),i==="upload"?l.jsx("button",{className:Ae.confirmBtn,disabled:!S||D,onClick:xe,children:D?l.jsxs(l.Fragment,{children:[l.jsx(Ti,{size:14,className:Ae.spinner})," ",s.appIconPickerModal.uploadingText]}):s.appIconPickerModal.uploadAndUseButton}):l.jsx("button",{className:Ae.confirmBtn,disabled:!h,onClick:ge,children:s.appIconPickerModal.useSelectedButton})]})]})})},lj=({name:e,label:t,nodeId:r,required:n,disabled:s})=>{const i=ae(),[o,a]=m.useState(!1),{watch:c,setValue:u,register:d,formState:{errors:f}}=er(),g=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:g?l.jsx("img",{src:g,alt:i.appIconField.iconAlt,className:q.iconPreview}):l.jsxs("div",{className:q.iconPlaceholder,children:[l.jsx(Mf,{size:20}),l.jsx("span",{children:i.appIconField.selectIconLabel})]})}),g&&!s&&l.jsxs("button",{type:"button",className:q.removeIconBtn,onClick:h,"aria-label":i.appIconField.removeIconAriaLabel,children:[l.jsx(Co,{size:13}),l.jsx("span",{children:i.appIconField.removeLabel})]}),p&&l.jsx("span",{className:q.error,children:String(p.message)}),o&&l.jsx(Vp,{nodeId:r,currentValue:g,onSelect:b,onClose:()=>a(!1)})]})},cj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({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)})]})},uj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({name:e,control:i,rules:{required:r?s.keywordSuggestField.requiredError.replace("{field}",t):!1},defaultValue:[]}),[c,u]=m.useState(""),d=m.useRef(null),f=o.value??[],g=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(),g(c),u("")):v.key==="Backspace"&&c===""&&f.length>0&&p(f[f.length-1])},h=()=>{c.trim()&&(g(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(yr,{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)})]})},dj=({name:e,label:t,levels:r,required:n,disabled:s})=>{const i=ae(),{control:o}=er(),{field:a,fieldState:{error:c}}=oi({name:e,control:o,rules:{required:n?i.nestedSelectField.requiredError.replace("{field}",t):!1},defaultValue:{}}),u=a.value??{},d=(f,g,p)=>{const b={};for(let h=0;h<g;h++)b[r[h].code]=u[r[h].code]??"";b[f]=p;for(let h=g+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,g)=>{const p=g>0&&!u[r[g-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,g,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)})]})},bd=[{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"}],fj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),[i,o]=m.useState(!1),a=m.useRef(null),{register:c,watch:u,setValue:d,formState:{errors:f}}=er(),g=u(e),p=bd.find(v=>v.value===g),b=(p==null?void 0:p.label)??s.licenseSelectField.selectPlaceholder,h=f[e];return m.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:g?q.selectedVal:q.placeholder,children:b}),l.jsx(bn,{size:14,className:i?q.chevronUp:""})]}),i&&l.jsx("div",{className:q.dropdown,role:"listbox",children:bd.map(v=>l.jsxs("button",{type:"button",role:"option","aria-selected":g===v.value,className:[q.option,g===v.value?q.optionSelected:""].join(" "),onClick:()=>{d(e,v.value,{shouldDirty:!0,shouldValidate:!0}),o(!1)},children:[l.jsx("span",{children:v.label}),g===v.value&&l.jsx(yn,{size:13})]},v.value))}),h&&l.jsx("span",{className:q.error,children:String(h.message)})]})},hj=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),{field:o,fieldState:{error:a}}=oi({name:e,control:i,rules:{required:r?s.dialcodeInputField.requiredError.replace("{field}",t):!1},defaultValue:""}),[c,u]=m.useState("idle"),[d,f]=m.useState(""),g=async()=>{const b=(o.value??"").trim();if(!b){u("invalid"),f(s.dialcodeInputField.enterCodeMessage);return}u("loading"),f("");try{const h=await p0(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(Ti,{size:16,className:q.dialcodeSpinner}):c==="valid"?l.jsx(Nf,{size:16,color:"var(--sbx-success, #2e7d32)"}):c==="invalid"?l.jsx(Sy,{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:g,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})]})},pj="_cards_1oc2m_1",mj="_card_1oc2m_1",gj="_cardActive_1oc2m_30",vj="_cardIcon_1oc2m_35",yj="_cardIconPrimary_1oc2m_46",bj="_cardIconHover_1oc2m_50",Cj="_radioDot_1oc2m_54",Sj="_radioDotActive_1oc2m_65",_j="_cardTitle_1oc2m_70",wj="_cardTitleInk_1oc2m_76",xj="_cardDescription_1oc2m_80",Tj="_cardDescriptionCharcoal_1oc2m_86",$t={cards:pj,card:mj,cardActive:gj,cardIcon:vj,cardIconPrimary:yj,cardIconHover:bj,radioDot:Cj,radioDotActive:Sj,cardTitle:_j,cardTitleInk:wj,cardDescription:xj,cardDescriptionCharcoal:Tj},Ej=({name:e,label:t,required:r,disabled:n})=>{const s=ae(),{control:i}=er(),o=[{value:"Fixed",Icon:Bf,iconVariant:$t.cardIconPrimary,title:s.learningPath.policyStrictLabel,titleVariant:"",description:l.jsx(l.Fragment,{children:s.learningPath.policyStrictDescription}),descriptionVariant:""},{value:"Diagnostic",Icon:Hy,iconVariant:$t.cardIconPrimary,title:s.learningPath.policyAdaptiveLabel,titleVariant:$t.cardTitleInk,description:l.jsxs(l.Fragment,{children:[s.learningPath.policyAdaptiveDescriptionPre,l.jsx("span",{className:q.required,children:"*"}),s.learningPath.policyAdaptiveDescriptionPost]}),descriptionVariant:$t.cardDescriptionCharcoal},{value:"PriorLearning",Icon:My,iconVariant:$t.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($L,{name:e,control:i,rules:{required:r?s.selectField.requiredError.replace("{field}",t):!1},render:({field:a})=>l.jsx("div",{className:$t.cards,children:o.map(({value:c,Icon:u,iconVariant:d,title:f,titleVariant:g,description:p,descriptionVariant:b})=>{const h=a.value===c;return l.jsxs("button",{type:"button",disabled:n,className:[$t.card,h?$t.cardActive:""].join(" "),onClick:()=>a.onChange(c),children:[l.jsx("span",{className:[$t.cardIcon,d].join(" "),children:l.jsx(u,{size:16})}),l.jsx("span",{className:[$t.radioDot,h?$t.radioDotActive:""].join(" ")}),l.jsx("span",{className:[$t.cardTitle,g].join(" "),children:f}),l.jsx("span",{className:[$t.cardDescription,b].join(" "),children:p})]},c)})})})]})},Aj="_form_lktqh_1",Ij="_formLp_lktqh_7",kj="_ungrouped_lktqh_12",Dj="_ungroupedLp_lktqh_23",Lj="_fullWidthField_lktqh_27",Oj="_noFields_lktqh_31",Nn={form:Aj,formLp:Ij,ungrouped:kj,ungroupedLp:Dj,fullWidthField:Lj,noFields:Oj},Nj=({nodeMetadata:e,activeTab:t,isRoot:r,isFolder:n,editorMode:s,onFormValueChange:i,onFormStatusChange:o})=>{var ee,He,Ge,Ze,Qe,tt,st,Kr,_n;const a=ae(),c=Z(K=>K.editorConfig),u=Z(K=>K.editorProfile),d=u.key==="learningPath",f=Z(K=>K.rootFormConfig),g=Z(K=>K.unitFormConfig),p=Z(K=>K.categoryMeta),b=Z(K=>K.contentFramework),h=Z(K=>K.contentTargetFWIds),{organisationFramework:v,targetFrameworks:y,isLoading:C}=Eo(b??((ee=c==null?void 0:c.context)==null?void 0:ee.framework),h??((He=c==null?void 0:c.context)==null?void 0:He.targetFWIds)),{frameworks:S,collectionAdditionalCategories:_,contentAdditionalCategories:x,defaultLicense:E,name:D}=iO((Ge=c==null?void 0:c.context)==null?void 0:Ge.channel),T=oO(((Ze=c==null?void 0:c.context)==null?void 0:Ze.userId)??((Qe=c==null?void 0:c.context)==null?void 0:Qe.uid)),j=sO(S,(tt=p==null?void 0:p.frameworkMetadata)==null?void 0:tt.orgFWType,(st=c==null?void 0:c.context)==null?void 0:st.channel),F={organisationFramework:v,targetFrameworks:y,orgFrameworks:j,channelAdditionalCategories:_},O=ue(K=>K.selectedNodeId),N=ue(K=>K.treeData),B=ue(K=>K.treeCache),P=O?B[O]??{}:{},U={...e,...P},ne=m.useMemo(()=>{var _e;if(!O)return 0;const K=[...N];for(;K.length;){const w=K.shift();if(w.id===O)return((_e=w.children)==null?void 0:_e.length)??0;w.children&&K.push(...w.children)}return 0},[N,O]),H=(c==null?void 0:c.config)??{},te=(c==null?void 0:c.context)??{},he={editorMode:s,editableFields:H.editableFields,objectType:H.objectType,setDefaultCopyRight:H.setDefaultCopyRight===!0,defaultLicense:te.defaultLicense??E,contextAdditionalCategories:te.additionalCategories,userFullName:((Kr=te.user)==null?void 0:Kr.fullName)??T,channelName:D,collectionAdditionalCategories:_,contentAdditionalCategories:x,childCount:ne,profile:u},oe=r?f:g,ge=oe||(((_n=c==null?void 0:c.config.hierarchy)==null?void 0:_n.formConfig)??[]),ve=qp(ge,U,F,r,he),xe=ve.filter(K=>K.tab===t&&K.inputType!=="appIcon"&&K.visible!==!1),ye=nO({mode:"onChange",defaultValues:Object.fromEntries(ve.map(K=>{const _e=["multiselect","chips","keywords","tagsinput"],w=["nestedselect"];return _e.includes(K.inputType)?[K.code,K.currentValue??K.defaultValue??[]]:w.includes(K.inputType)?[K.code,K.currentValue??K.defaultValue??{}]:[K.code,K.currentValue??K.defaultValue??""]}))});NO(ye,ve);const{updateNode:R}=ue(),M=m.useRef(ve);M.current=ve;const Y=m.useRef(O);Y.current=O;const le=m.useRef(i);le.current=i;const Ce=m.useRef(o);Ce.current=o;const de=m.useRef(typeof U.shuffle=="boolean"?U.shuffle:void 0),ce=m.useRef(U.name??"");ce.current=U.name??"";const Q=m.useRef(s);Q.current=s;const se=["review","read","sourcingreview","orgreview"];m.useEffect(()=>{const K=Y.current;if(K){const _e=Object.fromEntries(M.current.filter(w=>w.currentValue!==void 0&&w.currentValue!==null).map(w=>[w.code,w.currentValue]));Object.keys(_e).length>0&&R(K,_e)}ye.trigger().then(()=>{const _e=ye.formState.errors,w=M.current,k=Array.from(new Set(Object.keys(_e).map(L=>{var z;return(z=w.find(V=>V.code===L))==null?void 0:z.tab}).filter(Boolean)));Ce.current(Object.keys(_e).length===0,k)})},[]),m.useEffect(()=>{const K=ye.watch((_e,{name:w})=>{const k=Y.current;if(!k)return;const L=M.current,z=new Set(L.map($=>$.code));if(w&&z.has(w)){let $=ye.getValues(w);if(w==="dialcodes"&&($=Array.isArray($)?$:$?[$]:[]),w==="shuffle"&&($===!0&&de.current===!1&&we(a.sparkMetaForm.shuffleEnabledMessage,{icon:l.jsx(Ps,{size:16})}),de.current=$),w==="framework"&&r&&typeof $=="string"&&$){const be=Z.getState();if(be.setContentFramework($,be.contentTargetFWIds),d){const $e=ue.getState().pruneCoursesByFramework($);$e>0&&we(a.learningPath.coursesRemovedFrameworkChangeToast.replace("{count}",String($e)),{icon:l.jsx(Ps,{size:16}),duration:5e3})}}const re=OO(w,$);re&&(R(k,re),le.current(re))}else if(!w){const $=ye.getValues(),re=Object.fromEntries(Object.entries($).filter(([$e])=>z.has($e))),be=LO(re,{isReview:se.includes(Q.current),nodeTitle:ce.current});Object.keys(be).length>0&&(R(k,be),le.current(be))}const V=ye.formState.errors,G=Array.from(new Set(Object.keys(V).map($=>{var re;return(re=L.find(be=>be.code===$))==null?void 0:re.tab}).filter(Boolean)));Ce.current(Object.keys(V).length===0,G)});return()=>K.unsubscribe()},[ye]),m.useEffect(()=>{for(const K of["author","creator","copyright","copyrightYear","license"]){const _e=M.current.find(k=>k.code===K);if(!_e||_e.currentValue===void 0||_e.currentValue===null||_e.currentValue==="")continue;const w=ye.getValues(K);(w==null||w==="")&&ye.setValue(K,_e.currentValue,{shouldDirty:!1})}},[T,D,ye]);const Te=xe.reduce((K,_e)=>{const w=K[K.length-1];return w&&w.section===_e.section?w.fields.push(_e):K.push({section:_e.section,fields:[_e]}),K},[]),me=K=>{const _e={key:K.code,name:K.code,label:K.label,required:K.required,disabled:K.editable===!1};if(d&&K.code==="policy")return l.jsx("div",{className:Nn.fullWidthField,children:l.jsx(Ej,{..._e})},K.code);switch(K.inputType){case"textarea":return l.jsx(vd,{..._e,multiline:!0,maxLength:K.maxLength});case"select":return l.jsx(CN,{..._e,options:K.options??[]});case"multiselect":return l.jsx(SN,{..._e,options:K.options??[]});case"chips":return l.jsx(_N,{..._e});case"radio":return l.jsx(wN,{..._e,options:K.options??[]});case"appIcon":return l.jsx(lj,{..._e,nodeId:O??""});case"datepicker":case"datetime":return l.jsx(cj,{..._e});case"keywords":case"tagsinput":return l.jsx(uj,{..._e});case"nestedselect":return l.jsx(dj,{..._e,levels:K.levels??[]});case"license":return l.jsx(fj,{..._e});case"dialcode":return l.jsx(hj,{..._e});default:return l.jsx(vd,{..._e,maxLength:K.maxLength})}};return l.jsx(UL,{...ye,children:l.jsxs("div",{className:[Nn.form,d?Nn.formLp:""].filter(Boolean).join(" "),children:[Te.map((K,_e)=>{const w=K.section?aO[K.section]:void 0;return w?l.jsx(qO,{title:w.title,description:w.description,children:K.fields.map(me)},K.section??_e):l.jsx("div",{className:[Nn.ungrouped,d?Nn.ungroupedLp:""].filter(Boolean).join(" "),children:K.fields.map(me)},_e)}),xe.length===0&&!C&&l.jsx("p",{className:Nn.noFields,children:a.sparkMetaForm.noFieldsMessage})]})})};function Hp(e,t,r){const n=e.slice();return n.splice(r<0?n.length+r:r,0,n.splice(t,1)[0]),n}function jj(e,t){return e.reduce((r,n,s)=>{const i=t.get(n);return i&&(r[s]=i),r},Array(e.length))}function bi(e){return e!==null&&e>=0}function Pj(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 Rj(e){return typeof e=="boolean"?{draggable:e,droppable:e}:e}const Qp=e=>{let{rects:t,activeIndex:r,overIndex:n,index:s}=e;const i=Hp(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}},Ci={scaleX:1,scaleY:1},Fj=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,...Ci}:null}const c=Mj(i,s,r);return s>r&&s<=o?{x:0,y:-a.height-c,...Ci}:s<r&&s>=o?{x:0,y:a.height+c,...Ci}:{x:0,y:0,...Ci}};function Mj(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 Wp="Sortable",Gp=m.createContext({activeIndex:-1,containerId:Wp,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Qp,disabled:{draggable:!1,droppable:!1}});function Bj(e){let{children:t,id:r,items:n,strategy:s=Qp,disabled:i=!1}=e;const{active:o,dragOverlay:a,droppableRects:c,over:u,measureDroppableContainers:d}=Lf(),f=Ks(Wp,r),g=a.rect!==null,p=m.useMemo(()=>n.map(E=>typeof E=="object"&&"id"in E?E.id:E),[n]),b=o!=null,h=o?p.indexOf(o.id):-1,v=u?p.indexOf(u.id):-1,y=m.useRef(p),C=!Pj(p,y.current),S=v!==-1&&h===-1||C,_=Rj(i);or(()=>{C&&b&&d(p)},[C,p,b,d]),m.useEffect(()=>{y.current=p},[p]);const x=m.useMemo(()=>({activeIndex:h,containerId:f,disabled:_,disableTransforms:S,items:p,overIndex:v,useDragOverlay:g,sortedRects:jj(p,c),strategy:s}),[h,f,_.draggable,_.droppable,S,p,v,c,g,s]);return m.createElement(Gp.Provider,{value:x},t)}const qj=e=>{let{id:t,items:r,activeIndex:n,overIndex:s}=e;return Hp(r,n,s).indexOf(t)},$j=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},Uj={duration:200,easing:"ease"},Kp="transform",zj=Vr.Transition.toString({property:Kp,duration:0,easing:"linear"}),Vj={roleDescription:"sortable"};function Hj(e){let{disabled:t,index:r,node:n,rect:s}=e;const[i,o]=m.useState(null),a=m.useRef(r);return or(()=>{if(!t&&r!==a.current&&n.current){const c=s.current;if(c){const u=ss(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]),m.useEffect(()=>{i&&o(null)},[i]),i}function Qj(e){let{animateLayoutChanges:t=$j,attributes:r,disabled:n,data:s,getNewIndex:i=qj,id:o,strategy:a,resizeObserverConfig:c,transition:u=Uj}=e;const{items:d,containerId:f,activeIndex:g,disabled:p,disableTransforms:b,sortedRects:h,overIndex:v,useDragOverlay:y,strategy:C}=m.useContext(Gp),S=Wj(n,p),_=d.indexOf(o),x=m.useMemo(()=>({sortable:{containerId:f,index:_,items:d},...s}),[f,s,_,d]),E=m.useMemo(()=>d.slice(d.indexOf(o)),[d,o]),{rect:D,node:T,isOver:j,setNodeRef:F}=Jv({id:o,data:x,disabled:S.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...c}}),{active:O,activatorEvent:N,activeNodeRect:B,attributes:P,setNodeRef:U,listeners:ne,isDragging:H,over:te,setActivatorNodeRef:he,transform:oe}=Df({id:o,data:x,attributes:{...Vj,...r},disabled:S.draggable}),ge=Mg(F,U),ve=!!O,xe=ve&&!b&&bi(g)&&bi(v),ye=!y&&H,R=ye&&xe?oe:null,Y=xe?R??(a??C)({rects:h,activeNodeRect:B,activeIndex:g,overIndex:v,index:_}):null,le=bi(g)&&bi(v)?i({id:o,items:d,activeIndex:g,overIndex:v}):_,Ce=O==null?void 0:O.id,de=m.useRef({activeId:Ce,items:d,newIndex:le,containerId:f}),ce=d!==de.current.items,Q=t({active:O,containerId:f,isDragging:H,isSorting:ve,id:o,index:_,items:d,newIndex:de.current.newIndex,previousItems:de.current.items,previousContainerId:de.current.containerId,transition:u,wasDragging:de.current.activeId!=null}),se=Hj({disabled:!Q,index:_,node:T,rect:D});return m.useEffect(()=>{ve&&de.current.newIndex!==le&&(de.current.newIndex=le),f!==de.current.containerId&&(de.current.containerId=f),d!==de.current.items&&(de.current.items=d)},[ve,le,f,d]),m.useEffect(()=>{if(Ce===de.current.activeId)return;if(Ce&&!de.current.activeId){de.current.activeId=Ce;return}const me=setTimeout(()=>{de.current.activeId=Ce},50);return()=>clearTimeout(me)},[Ce]),{active:O,activeIndex:g,attributes:P,data:x,rect:D,index:_,newIndex:le,items:d,isOver:j,isSorting:ve,isDragging:H,listeners:ne,node:T,overIndex:v,over:te,setNodeRef:ge,setActivatorNodeRef:he,setDroppableNodeRef:F,setDraggableNodeRef:U,transform:se??Y,transition:Te()};function Te(){if(se||ce&&de.current.newIndex===_)return zj;if(!(ye&&!uo(N)||!u)&&(ve||Q))return Vr.Transition.toString({...u,property:Kp})}}function Wj(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 no(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 Gj=[Oe.Down,Oe.Right,Oe.Up,Oe.Left],Kj=(e,t)=>{let{context:{active:r,collisionRect:n,droppableRects:s,droppableContainers:i,over:o,scrollableAncestors:a}}=t;if(Gj.includes(e.code)){if(e.preventDefault(),!r||!n)return;const c=[];i.getEnabled().forEach(f=>{if(!f||f!=null&&f.disabled)return;const g=s.get(f.id);if(g)switch(e.code){case Oe.Down:n.top<g.top&&c.push(f);break;case Oe.Up:n.top>g.top&&c.push(f);break;case Oe.Left:n.left>g.left&&c.push(f);break;case Oe.Right:n.left<g.left&&c.push(f);break}});const u=tv({collisionRect:n,droppableRects:s,droppableContainers:c});let d=hf(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),g=i.get(d),p=g?s.get(g.id):null,b=g==null?void 0:g.node.current;if(b&&p&&f&&g){const v=fo(b).some((E,D)=>a[D]!==E),y=Yp(f,g),C=Yj(f,g),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?_:Ns(_,S)}}}};function Yp(e,t){return!no(e)||!no(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Yj(e,t){return!no(e)||!no(t)||!Yp(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}const Zj="_row_1m6cn_1",Xj="_removeBtn_1m6cn_14",Jj="_grip_1m6cn_17",eP="_ctIcon_1m6cn_34",tP="_info_1m6cn_38",rP="_name_1m6cn_46",nP="_meta_1m6cn_55",Zr={row:Zj,removeBtn:Xj,grip:Jj,ctIcon:eP,info:tP,name:rP,meta:nP},sP={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},iP=({item:e,onRemove:t,isEditable:r})=>{const n=ae(),s=ni(e),i=sP[s.key]??Gr,{attributes:o,listeners:a,setNodeRef:c,transform:u,transition:d,isDragging:f}=Qj({id:e.id,disabled:!r}),g={transform:Vr.Transform.toString(u),transition:d,opacity:f?.5:1};return l.jsxs("div",{ref:c,style:g,className:Zr.row,role:"listitem",children:[r&&l.jsx("span",{className:Zr.grip,...o,...a,"aria-label":n.contentRow.dragToReorderAriaLabel,children:l.jsx(Ff,{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(yr,{size:14})})]})},oP="_container_1ls1w_1",aP="_header_1ls1w_7",lP="_heading_1ls1w_13",cP="_count_1ls1w_21",uP="_list_1ls1w_30",dP="_emptyState_1ls1w_36",fP="_skillPicker_1ls1w_52",hP="_skillsCovered_1ls1w_52",pP="_chips_1ls1w_64",mP="_chip_1ls1w_64",gP="_skillWarning_1ls1w_80",vP="_selectedSkills_1ls1w_85",yP="_skillPill_1ls1w_91",bP="_skillPillFlagged_1ls1w_103",CP="_skillPillRemove_1ls1w_107",SP="_skillSearchBox_1ls1w_122",_P="_skillSearchWrap_1ls1w_127",wP="_searchIcon_1ls1w_142",xP="_skillSearchInput_1ls1w_147",TP="_skillDropdown_1ls1w_160",EP="_skillOption_1ls1w_174",AP="_skillCheckbox_1ls1w_196",IP="_skillCheckboxChecked_1ls1w_208",kP="_skillDropdownEmpty_1ls1w_213",DP="_skillPickerNote_1ls1w_219",LP="_emptyHint_1ls1w_224",OP="_assessmentsCard_1ls1w_237",NP="_assessmentSlots_1ls1w_249",jP="_assessmentItemRow_1ls1w_255",PP="_assessmentItemIcon_1ls1w_266",RP="_assessmentItemInfo_1ls1w_278",FP="_assessmentItemTitle_1ls1w_285",MP="_assessmentItemMeta_1ls1w_294",BP="_addRowIcon_1ls1w_299",qP="_assessmentItemBadge_1ls1w_311",$P="_menuWrap_1ls1w_322",UP="_menuBtn_1ls1w_327",zP="_dropmenu_1ls1w_340",VP="_dangerItem_1ls1w_370",HP="_addRow_1ls1w_299",QP="_addRowAssessment_1ls1w_394",pe={container:oP,header:aP,heading:lP,count:cP,list:uP,emptyState:dP,skillPicker:fP,skillsCovered:hP,chips:pP,chip:mP,skillWarning:gP,selectedSkills:vP,skillPill:yP,skillPillFlagged:bP,skillPillRemove:CP,skillSearchBox:SP,skillSearchWrap:_P,searchIcon:wP,skillSearchInput:xP,skillDropdown:TP,skillOption:EP,skillCheckbox:AP,skillCheckboxChecked:IP,skillDropdownEmpty:kP,skillPickerNote:DP,emptyHint:LP,assessmentsCard:OP,assessmentSlots:NP,assessmentItemRow:jP,assessmentItemIcon:PP,assessmentItemInfo:RP,assessmentItemTitle:FP,assessmentItemMeta:MP,addRowIcon:BP,assessmentItemBadge:qP,menuWrap:$P,menuBtn:UP,dropmenu:zP,dangerItem:VP,addRow:HP,addRowAssessment:QP},WP=({options:e,selected:t,outOfScope:r,onChange:n,isEditable:s,description:i})=>{const o=ae(),[a,c]=m.useState(""),[u,d]=m.useState(!1),f=m.useRef(null);m.useEffect(()=>{if(!u)return;const h=v=>{var y;(y=f.current)!=null&&y.contains(v.target)||d(!1)};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[u]);const g=a?e.filter(h=>h.toLowerCase().includes(a.toLowerCase())):e,p=h=>{s&&n(t.includes(h)?t.filter(v=>v!==h):[...t,h])},b=h=>{s&&n(t.filter(v=>v!==h))};return l.jsxs("div",{className:pe.skillPicker,children:[l.jsxs("div",{className:pe.header,children:[l.jsx("span",{className:pe.heading,children:o.learningPath.skillsHeading}),l.jsx("span",{className:pe.count,children:t.length})]}),l.jsx("span",{className:pe.skillPickerNote,children:i}),r.length>0&&l.jsx("div",{className:pe.skillWarning,role:"alert",children:o.learningPath.skillsOutOfScopeWarning.replace("{skills}",r.join(", "))}),t.length>0&&l.jsx("div",{className:pe.selectedSkills,children:t.map(h=>{const v=r.includes(h);return l.jsxs("span",{className:[pe.skillPill,v?pe.skillPillFlagged:""].join(" "),children:[h,s&&l.jsx("button",{type:"button",className:pe.skillPillRemove,onClick:()=>b(h),"aria-label":o.learningPath.removeSkillAriaLabel.replace("{skill}",h),children:l.jsx(yr,{size:11})})]},h)})}),s?l.jsxs("div",{className:pe.skillSearchBox,ref:f,children:[l.jsxs("div",{className:pe.skillSearchWrap,onClick:()=>d(!0),children:[l.jsx("input",{type:"search",className:pe.skillSearchInput,placeholder:o.learningPath.searchSkillsPlaceholder,value:a,onChange:h=>c(h.target.value),onFocus:()=>d(!0),"aria-label":o.learningPath.searchSkillsPlaceholder}),l.jsx(Wi,{size:14,className:pe.searchIcon})]}),u&&l.jsx("div",{className:pe.skillDropdown,role:"listbox",children:e.length===0?l.jsx("div",{className:pe.skillDropdownEmpty,children:o.learningPath.noSkillsAvailable}):g.length===0?l.jsx("div",{className:pe.skillDropdownEmpty,children:o.learningPath.noMatchingSkills}):g.map(h=>{const v=t.includes(h);return l.jsxs("button",{type:"button",role:"option","aria-selected":v,className:pe.skillOption,onClick:()=>p(h),children:[l.jsx("span",{className:[pe.skillCheckbox,v?pe.skillCheckboxChecked:""].join(" "),children:v&&l.jsx(yn,{size:12})}),h]},h)})})]}):t.length===0&&l.jsx("span",{className:pe.emptyHint,children:o.learningPath.noSkillsSelectedYet})]})},ul=({slot:e,isEditable:t})=>{const r=ae(),{pre:n,post:s,setActiveAssessmentSlot:i,deleteSlot:o}=Vl(),a=ue(h=>h.selectNode),[c,u]=m.useState(!1),d=m.useRef(null),f=e==="pre"?n:s,g=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel;if(m.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:[pe.addRow,pe.addRowAssessment].join(" "),disabled:!t,onClick:()=>i(e),children:[l.jsx("span",{className:pe.addRowIcon,children:l.jsx(Cn,{size:16})}),r.learningPath.addAssessmentSlotButton.replace("{label}",g)]});const p=e==="pre"?r.learningPath.skillCheckBadge:r.learningPath.outcomeCheckBadge,b=()=>f.level&&a(f.level.id);return l.jsxs("div",{className:pe.assessmentItemRow,role:"button",tabIndex:0,onClick:b,onKeyDown:h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),b())},children:[l.jsx("span",{className:pe.assessmentItemIcon,children:l.jsx(Wr,{size:16})}),l.jsxs("div",{className:pe.assessmentItemInfo,children:[l.jsx("span",{className:pe.assessmentItemTitle,children:f.courseName||r.learningPath.courseNameUnavailable}),l.jsxs("span",{className:pe.assessmentItemMeta,children:[g," · ",r.learningPath.assessmentCourseMeta]})]}),l.jsx("span",{className:pe.assessmentItemBadge,children:p}),t&&l.jsxs("div",{className:pe.menuWrap,ref:d,children:[l.jsx("button",{type:"button",className:pe.menuBtn,onClick:h=>{h.stopPropagation(),u(v=>!v)},"aria-label":r.treeNode.nodeOptionsAriaLabel,children:"⋮"}),c&&l.jsxs("div",{className:pe.dropmenu,onClick:h=>h.stopPropagation(),children:[l.jsxs("button",{type:"button",onClick:()=>{u(!1),f.level&&a(f.level.id)},children:[l.jsx(xy,{size:12})," ",r.learningPath.viewCourseMenuItem]}),l.jsxs("button",{type:"button",className:pe.dangerItem,onClick:()=>{u(!1),o(e)},children:[l.jsx(Co,{size:12})," ",r.treeNode.deleteMenuItem]})]})]})]})},GP=({editorMode:e,isRoot:t=!1})=>{const r=ae(),{selectedNodeId:n,getChildrenOf:s,getNodeById:i,reorderChildren:o,deleteNode:a,activeNodeMeta:c,updateNode:u,treeData:d}=ue(),f=Z(N=>N.editorProfile),g=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}=Dh(),_=as(),x=_&&Array.isArray(c[_.code])?c[_.code]:[],E=S==="prior"?x.filter(N=>!C.includes(N)):[],D=y?u1(d[0],_==null?void 0:_.code):[],T=m.useCallback(N=>{!n||!(_!=null&&_.code)||u(n,{[_.code]:N},[_.code])},[n,_==null?void 0:_.code,u]),j=uf(Na(ho,{activationConstraint:{distance:5}}),Na(bl,{coordinateGetter:Kj})),F=m.useCallback(N=>{const{active:B,over:P}=N;if(!P||B.id===P.id||!n)return;const U=ue.getState().getChildrenOf(n),ne=U.findIndex(te=>te.id===B.id),H=U.findIndex(te=>te.id===P.id);ne<0||H<0||o(n,ne,H)},[n,o]),O=m.useCallback(N=>{window.confirm(r.unitContentList.removeConfirm)&&a(N)},[a,r.unitContentList.removeConfirm]);return n?l.jsxs("div",{className:pe.container,children:[y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:pe.skillsCovered,children:[l.jsx("span",{className:pe.heading,children:r.learningPath.skillsCoveredHeading}),l.jsx("span",{className:pe.emptyHint,children:r.learningPath.skillsCoveredDescription}),D.length>0&&l.jsx("div",{className:pe.chips,children:D.map(N=>l.jsx("span",{className:pe.chip,children:N},N))}),D.length===0&&l.jsx("span",{className:pe.emptyHint,children:r.learningPath.noSkillsYet})]}),l.jsxs("div",{className:pe.assessmentsCard,children:[l.jsx("span",{className:pe.heading,children:r.learningPath.assessmentsCardHeading}),l.jsx("span",{className:pe.emptyHint,children:r.learningPath.assessmentsCardDescription}),l.jsxs("div",{className:pe.assessmentSlots,children:[l.jsx(ul,{slot:"pre",isEditable:p}),l.jsx(ul,{slot:"post",isEditable:p})]})]})]}),v&&l.jsx(WP,{options:C,selected:x,outOfScope:E,onChange:T,isEditable:p,description:S==="prior"?r.learningPath.skillScopeFromPriorNote:r.learningPath.skillScopeManualNote}),!h&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:pe.header,children:[l.jsx("span",{className:pe.heading,children:r.unitContentList.heading}),l.jsx("span",{className:pe.count,children:g.length})]}),g.length>0?l.jsx(kf,{sensors:j,collisionDetection:ev,onDragEnd:F,children:l.jsx(Bj,{items:g.map(N=>N.id),strategy:Fj,children:l.jsx("div",{className:pe.list,role:"list",children:g.map(N=>l.jsx(iP,{item:N,onRemove:O,isEditable:p},N.id))})})}):l.jsxs("div",{className:pe.emptyState,children:[l.jsx("p",{children:r.unitContentList.emptyTitle}),l.jsx("span",{children:r.unitContentList.emptyHint})]}),p&&!lt(b)&&l.jsxs("button",{className:pe.addRow,type:"button","aria-label":r.unitContentList.addContentAriaLabel,children:[l.jsx(Cn,{size:14})," ",r.unitContentList.addContent]})]})]}):null},KP="_dropZone_ijo5w_1",YP="_active_ijo5w_14",Cd={dropZone:KP,active:YP},ZP=({isActive:e,label:t,nodeId:r,className:n})=>{const s=ae(),i=t??s.dropZone.dropHere;return l.jsx("div",{className:`${Cd.dropZone} ${e?Cd.active:""} ${n??""}`,"data-droppable":e?"true":void 0,"data-node-id":r,"aria-label":i,role:"region",children:l.jsx("span",{children:i})})},Zp=["identifier","name","mimeType","contentType","primaryCategory","appIcon","channel","organisation","pkgVersion"];async function XP(e){var o;const t={status:["Live"],...e.filters??{}};e.channel&&(t.channel=e.channel);const n=((o=(await Re.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??Zp}},{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 JP(e){var r,n;return(n=(r=(await Re.get(`/action/content/v3/read/${e}`)).data)==null?void 0:r.result)==null?void 0:n.content}const Sd="application/vnd.sunbird.question";function _d(e){return{cardinality:"single",type:"integer",defaultValue:e.maxScore??1}}function Xp(e,t,r){if(!e)return null;if(e.identifier===t)return{question:e,parent:r};for(const n of e.children??[]){const s=Xp(n,t,e);if(s)return s}return null}function eR(e,t){const r=Xp(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 tR(e,t){const r=((t==null?void 0:t.enabled)??!0)&&!!e;return Zn({queryKey:["quml","questionset",e],enabled:r,queryFn:async()=>{const n=await mh(e),s=d=>{if(!d)return[];const f=d.mimeType===Sd&&d.identifier?[d.identifier]:[],g=(d.children??[]).flatMap(s);return[...f,...g]},i=s(n),o=new Map;i.length&&(await Yx(i)).forEach(f=>{const g=f.identifier;g&&o.set(g,f)});const a=d=>{if(!d)return d;if(d.mimeType===Sd&&d.identifier){const f=o.get(d.identifier)??d,g=f.outcomeDeclaration;return g!=null&&g.maxScore||(f.outcomeDeclaration={...g??{},maxScore:_d(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:_d(c)}),c}})}const wd="/assets/quml-player/sunbird-quml-player.js",rR="/assets/quml-player/styles.css",xd="sunbird-quml-player";function nR(e){const t=e.children??[];return t.length?t.every(n=>n.objectType==="Question")?[e]:t:[]}const ut=class ut{constructor(){fs(this,"eventHandlers",new WeakMap)}loadScript(){return ut.scriptLoaded||customElements.get(xd)?(ut.scriptLoaded=!0,Promise.resolve()):(ut.scriptLoading||(ut.scriptLoading=new Promise((t,r)=>{const n=document.createElement("script");n.src=wd,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: ${wd}`))},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=rR,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:nR(t),identifier:t.identifier??""},metadata:t}}createElement(t){this.loadStyles();const r=document.createElement(xd);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))}};fs(ut,"scriptLoaded",!1),fs(ut,"scriptLoading"),fs(ut,"stylesLoaded",!1);let so=ut;const Si=new so,sR="_contentPlayerRoot_1rdfn_1",iR="_flowLayout_1rdfn_9",oR="_stage_1rdfn_13",aR="_aspectRatio_1rdfn_16",lR="_playerHeader_1rdfn_32",cR="_playerHeaderThumb_1rdfn_46",uR="_playerHeaderTitle_1rdfn_56",dR="_typeBadge_1rdfn_66",fR="_typeDot_1rdfn_105",hR="_playerFrame_1rdfn_125",pR="_coverOverlay_1rdfn_133",mR="_coverHidden_1rdfn_145",gR="_coverThumb_1rdfn_150",vR="_coverPlayRing_1rdfn_159",yR="_coverPlayIcon_1rdfn_172",bR="_coverLabel_1rdfn_181",CR="_coverSkeleton_1rdfn_187",SR="_playerWrapper_1rdfn_213",_R="_infoStrip_1rdfn_223",wR="_infoChip_1rdfn_239",xR="_infoChipLabel_1rdfn_258",TR="_infoChipIcon_1rdfn_267",ER="_playerError_1rdfn_273",AR="_playerErrorIcon_1rdfn_287",IR="_playerErrorMsg_1rdfn_292",kR="_qumlRoot_1rdfn_299",Ve={contentPlayerRoot:sR,flowLayout:iR,stage:oR,aspectRatio:aR,playerHeader:lR,playerHeaderThumb:cR,playerHeaderTitle:uR,typeBadge:dR,typeDot:fR,playerFrame:hR,coverOverlay:pR,coverHidden:mR,coverThumb:gR,coverPlayRing:vR,coverPlayIcon:yR,coverLabel:bR,coverSkeleton:CR,playerWrapper:SR,infoStrip:_R,infoChip:wR,infoChipLabel:xR,infoChipIcon:TR,playerError:ER,playerErrorIcon:AR,playerErrorMsg:IR,qumlRoot:kR},DR="application/vnd.sunbird.questionset";function LR(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===DR)return s.identifier;s=s.parent?r.get(s.parent):void 0}return null}const OR=[{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 NR(e){return OR.find(t=>t.mimes.includes(e))??{key:"other"}}function jR(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 PR={"pdf-player":["application/pdf"],"video-player":["video/mp4","video/webm"],"epub-player":["application/epub"]},RR={"pdf-player":"/assets/sunbird-pdf-player.js","video-player":"/assets/sunbird-video-player.js","epub-player":"/assets/sunbird-epub-player.js"},FR={"pdf-player":"sunbird-pdf-player","video-player":"sunbird-video-player","epub-player":"sunbird-epub-player"},MR="/content/preview/preview.html?webview=true&build_number=2.8.0.e552fcd";function pa(e){for(const[t,r]of Object.entries(PR))if(r.includes(e))return t;return"default-player"}function BR(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 qR(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 $R(e,t,r=100){await qR(RR[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 UR=[{key:"author",icon:zy},{key:"license",icon:Py},{key:"language",icon:Ey},{key:"gradeLevel",icon:Ry},{key:"subject",icon:Wr},{key:"contentType",icon:$y}];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 VR({node:e}){const t=ae(),r=e.metadata??{},n=UR.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:Ve.infoStrip,children:n.map(s=>l.jsxs("div",{className:Ve.infoChip,children:[s.icon&&l.jsx(s.icon,{size:13,className:Ve.infoChipIcon}),l.jsx("span",{className:Ve.infoChipLabel,children:s.label}),s.val]},s.key))}):null}function Jp({node:e,hidden:t}){var s;const r=ae(),n=e.appIcon??((s=e.metadata)==null?void 0:s.appIcon);return l.jsx("div",{className:`${Ve.coverOverlay} ${t?Ve.coverHidden:""}`,children:n?l.jsxs(l.Fragment,{children:[l.jsx("img",{src:n,alt:e.name,className:Ve.coverThumb}),l.jsx("div",{className:Ve.coverPlayRing,children:l.jsx("div",{className:Ve.coverPlayIcon})}),l.jsx("span",{className:Ve.coverLabel,children:r.contentPlayer.loadingPreview})]}):l.jsx("div",{className:Ve.coverSkeleton})})}function em({message:e}){return l.jsxs("div",{className:Ve.playerError,children:[l.jsx(Uy,{size:28,className:Ve.playerErrorIcon}),l.jsx("span",{className:Ve.playerErrorMsg,children:e})]})}function HR({mimeType:e}){const t=ae(),r=NR(e);return l.jsxs("span",{className:Ve.typeBadge,"data-type":r.key,children:[l.jsx("span",{className:Ve.typeDot}),jR(r.key,t)]})}const dl=({node:e,editorMode:t,type:r,singleQuestion:n,layout:s="fill"})=>{var o;if(r==="quml")return l.jsx(WR,{node:e,editorMode:t,singleQuestion:!!n});const i=e.appIcon??((o=e.metadata)==null?void 0:o.appIcon);return l.jsxs("div",{className:`${Ve.contentPlayerRoot} ${s==="flow"?Ve.flowLayout:""}`,children:[l.jsxs("div",{className:Ve.stage,children:[l.jsxs("div",{className:Ve.playerHeader,children:[i&&l.jsx("img",{src:i,alt:"",className:Ve.playerHeaderThumb}),l.jsx("span",{className:Ve.playerHeaderTitle,children:e.name}),l.jsx(HR,{mimeType:e.mimeType??""})]}),l.jsx(QR,{node:e})]}),l.jsx(VR,{node:e})]})};function QR({node:e}){var y;const t=ae(),r=Z(C=>C.editorConfig),[n,s]=m.useState(()=>pa(e.mimeType??"")),[i,o]=m.useState(!1),[a,c]=m.useState(null),[u,d]=m.useState(e.metadata??{}),[f,g]=m.useState(!1),p=m.useRef(null),b=m.useRef(null),h=((y=r==null?void 0:r.config)==null?void 0:y.previewCdnUrl)??MR;m.useEffect(()=>{let C=!1;return g(!1),o(!1),c(null),d(e.metadata??{}),s(pa(e.mimeType??"")),JP(e.identifier).then(S=>{if(C)return;const _={...e.metadata??{},...S};d(_);const x=S.mimeType??e.mimeType??"";s(pa(x)),g(!0)}).catch(()=>{C||g(!0)}),()=>{C=!0}},[e.identifier]);const v=BR(e,u,r);return m.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]),m.useEffect(()=>{if(!f||n==="default-player")return;const C=b.current;if(!C)return;const S=FR[n];if(!S)return;const _=v;$R(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:Ve.aspectRatio,children:[a?l.jsx(em,{message:a}):l.jsx(Jp,{node:e,hidden:i}),n==="default-player"?l.jsx("iframe",{ref:p,id:"contentPlayer",title:e.name,className:Ve.playerFrame,name:"contentPlayer",allowFullScreen:!0}):l.jsx("div",{ref:b,className:Ve.playerFrame})]})}function WR({node:e,editorMode:t,singleQuestion:r}){const n=ae(),s=Z(p=>p.editorConfig),i=ue(p=>p.treeData),o=m.useRef(null),a=r?LR(i,e.id):e.identifier,{data:c,isLoading:u,error:d}=tR(a??"",{enabled:!!a}),f=m.useMemo(()=>c?r?eR(c,e.identifier):c:null,[c,r,e.identifier]);m.useEffect(()=>{const p=o.current;if(!p||!f)return;let b=null,h=!1;return(async()=>{try{const v=await Si.createConfig(f,s==null?void 0:s.context,{mode:t==="edit"?"edit":"play"});if(h||!o.current)return;const y=Si.createElement(v);b=y,Si.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&&(Si.removeEventListeners(b),b.remove()),so.unloadStyles()}},[f,s,t,r]);const g=d?`${n.contentPlayer.unableToLoadQuestionset} ${d.message}`:r&&!a?n.contentPlayer.parentQuestionsetNotResolved:r&&c&&!f?n.contentPlayer.questionNotFoundInQuestionset:null;return l.jsxs("div",{className:Ve.qumlRoot,children:[g?l.jsx(em,{message:g}):u||!f?l.jsx(Jp,{node:e,hidden:!1}):null,l.jsx("div",{ref:o,className:Ve.playerWrapper})]})}const GR="_overlay_1b1xq_1",KR="_modal_1b1xq_11",YR="_header_1b1xq_21",ZR="_body_1b1xq_37",XR="_hint_1b1xq_43",JR="_list_1b1xq_49",eF="_item_1b1xq_55",tF="_selected_1b1xq_68",rF="_empty_1b1xq_73",nF="_footer_1b1xq_79",sF="_cancelBtn_1b1xq_87",iF="_moveBtn_1b1xq_95",Kt={overlay:GR,modal:KR,header:YR,body:ZR,hint:XR,list:JR,item:eF,selected:tF,empty:rF,footer:nF,cancelBtn:sF,moveBtn:iF};function oF(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 aF=({resourceId:e,resourceName:t,currentUnitId:r,onClose:n})=>{var f;const s=ae(),{treeData:i,moveNode:o}=ue(),a=oF(i,((f=i[0])==null?void 0:f.id)??"",r),[c,u]=m.useState(null),d=()=>{c&&(o(e,r,c),n())};return l.jsx("div",{className:Kt.overlay,role:"dialog","aria-label":s.resourceReorderDialog.dialogAriaLabel,children:l.jsxs("div",{className:Kt.modal,children:[l.jsxs("div",{className:Kt.header,children:[l.jsxs("span",{children:[s.resourceReorderDialog.moveHeaderPrefix,' "',t,'"']}),l.jsx("button",{onClick:n,"aria-label":s.resourceReorderDialog.closeAriaLabel,children:l.jsx(yr,{size:16})})]}),l.jsxs("div",{className:Kt.body,children:[l.jsx("p",{className:Kt.hint,children:s.resourceReorderDialog.selectUnitHint}),l.jsxs("ul",{className:Kt.list,children:[a.map(g=>l.jsxs("li",{className:`${Kt.item} ${c===g.id?Kt.selected:""}`,onClick:()=>u(g.id),children:[l.jsx(Ty,{size:14}),l.jsx("span",{children:g.name})]},g.id)),a.length===0&&l.jsx("li",{className:Kt.empty,children:s.resourceReorderDialog.noUnitsAvailable})]})]}),l.jsxs("div",{className:Kt.footer,children:[l.jsx("button",{className:Kt.cancelBtn,onClick:n,children:s.resourceReorderDialog.cancelButton}),l.jsx("button",{className:Kt.moveBtn,onClick:d,disabled:!c,children:s.resourceReorderDialog.moveButton})]})]})})},lF="_overlay_1d56g_1",cF="_modal_1d56g_11",uF="_header_1d56g_21",dF="_body_1d56g_37",fF="_table_1d56g_43",hF="_pageInput_1d56g_61",pF="_empty_1d56g_68",mF="_footer_1d56g_74",gF="_cancelBtn_1d56g_82",vF="_saveBtn_1d56g_90",fr={overlay:lF,modal:cF,header:uF,body:dF,table:fF,pageInput:hF,empty:pF,footer:mF,cancelBtn:gF,saveBtn:vF};function yF(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 bF=({onClose:e})=>{const t=ae(),{treeData:r,updateNode:n}=ue(),s=yF(r),[i,o]=m.useState(()=>Object.fromEntries(s.map(c=>{var u;return[c.id,String(((u=c.metadata)==null?void 0:u.pageNumber)??"")]}))),a=m.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(yr,{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(jy,{size:14})," ",t.assignPageNumber.saveButton]})]})]})})},CF="_container_p2feh_1",SF="_panelHeader_p2feh_10",_F="_panelHeaderLeft_p2feh_19",wF="_panelCollapseBtn_p2feh_27",xF="_titleRow_p2feh_46",TF="_field_p2feh_47",EF="_moveBtn_p2feh_64",AF="_icon_p2feh_84",IF="_nameInput_p2feh_93",kF="_fieldHeader_p2feh_118",DF="_label_p2feh_124",LF="_fieldCount_p2feh_133",OF="_chips_p2feh_170",NF="_chip_p2feh_170",jF="_chipRemove_p2feh_188",PF="_keywordInput_p2feh_202",RF="_input_p2feh_207",FF="_addBtn_p2feh_220",MF="_radioGroup_p2feh_234",BF="_radioLabel_p2feh_239",Ke={container:CF,panelHeader:SF,panelHeaderLeft:_F,panelCollapseBtn:wF,titleRow:xF,field:TF,moveBtn:EF,icon:AF,nameInput:IF,fieldHeader:kF,label:DF,fieldCount:LF,chips:OF,chip:NF,chipRemove:jF,keywordInput:PF,input:RF,addBtn:FF,radioGroup:MF,radioLabel:BF},qF=({node:e,editorMode:t,onMoveClick:r,reorderDialog:n})=>{var N,B;const{updateNode:s,markDirty:i}=ue(),o=t==="edit",a=ni(e),c=ae(),u=Z(P=>P.relationalFormConfig),d=P=>u==null?void 0:u.find(U=>U.code===P),f=P=>!u||!!d(P),g=(P,U)=>{var ne;return((ne=d(P))==null?void 0:ne.label)||U},[p,b]=m.useState(!0),h=((N=e.metadata)==null?void 0:N.relationalMetadata)??{},[v,y]=m.useState(h.name??e.name??""),[C,S]=m.useState(""),[_,x]=m.useState(Array.isArray(h.keywords)?h.keywords:Array.isArray((B=e.metadata)==null?void 0:B.keywords)?e.metadata.keywords:[]),[E,D]=m.useState(!!h.optional);m.useEffect(()=>{var U,ne;const P=((U=e.metadata)==null?void 0:U.relationalMetadata)??{};y(P.name??e.name??""),x(Array.isArray(P.keywords)?P.keywords:Array.isArray((ne=e.metadata)==null?void 0:ne.keywords)?e.metadata.keywords:[]),D(!!P.optional)},[e.id]);const T=()=>{v.trim()&&v!==e.name&&(s(e.id,{name:v.trim()}),i())},j=()=>{const P=C.trim();if(P&&!_.includes(P)){const U=[..._,P];x(U),s(e.id,{keywords:U}),i()}S("")},F=P=>{const U=_.filter(ne=>ne!==P);x(U),s(e.id,{keywords:U}),i()},O=P=>{D(P),s(e.id,{optional:P}),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(P=>!P),"aria-expanded":p,"aria-label":p?c.contentEditForm.collapseMetadataPanelAriaLabel:c.contentEditForm.expandMetadataPanelAriaLabel,title:p?c.contentEditForm.collapseTitle:c.contentEditForm.expandTitle,children:p?l.jsx(bn,{size:15}):l.jsx(Cy,{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:P=>y(P.target.value),onBlur:T,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:[g("keywords",c.contentEditForm.keywordsLabel),_.length>0&&l.jsx("span",{className:Ke.fieldCount,children:_.length})]})}),_.length>0&&l.jsx("div",{className:Ke.chips,children:_.map(P=>l.jsxs("span",{className:Ke.chip,children:[P,o&&l.jsx("button",{type:"button",className:Ke.chipRemove,onClick:()=>F(P),children:"×"})]},P))}),o&&l.jsxs("div",{className:Ke.keywordInput,children:[l.jsx("input",{type:"text",className:Ke.input,value:C,placeholder:c.contentEditForm.addKeywordPlaceholder,onChange:P=>S(P.target.value),onKeyDown:P=>{P.key==="Enter"&&(P.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:g("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:E===!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:E===!1,onChange:()=>O(!1),disabled:!o}),c.contentEditForm.noOption]})]})]})]}),n]})},$F="_iconBtn_gliz0_1",UF="_editable_gliz0_14",zF="_iconImg_gliz0_26",VF="_placeholder_gliz0_34",HF="_removeBtn_gliz0_41",Cs={iconBtn:$F,editable:UF,iconImg:zF,placeholder:VF,removeBtn:HF},QF=({nodeId:e,value:t,editable:r})=>{const[n,s]=m.useState(!1),{updateNode:i,markDirty:o}=ue(),a=ae(),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:[Cs.iconBtn,r?Cs.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:Cs.iconImg}):l.jsx("div",{className:Cs.placeholder,children:l.jsx(Mf,{size:24})}),t&&r&&l.jsx("button",{type:"button",className:Cs.removeBtn,onClick:u,"aria-label":a.titleAppIcon.removeIconAriaLabel,children:l.jsx(Co,{size:11})})]}),n&&l.jsx(Vp,{nodeId:e,currentValue:t,onSelect:c,onClose:()=>s(!1)})]})},WF="_courseDetails_1eby7_1",GF="_courseDetailsLoading_1eby7_7",KF="_courseDetailsError_1eby7_7",YF="_detailsCard_1eby7_12",ZF="_unitsCard_1eby7_12",XF="_cardTitle_1eby7_22",JF="_fieldGroup_1eby7_29",e2="_fieldGroupLast_1eby7_33",t2="_fieldLabel_1eby7_37",r2="_fieldValue_1eby7_47",n2="_fieldValueMultiline_1eby7_52",s2="_unitsLabel_1eby7_58",i2="_unitsDescription_1eby7_68",o2="_unitList_1eby7_74",a2="_unitCard_1eby7_80",l2="_unitHeader_1eby7_86",c2="_unitIcon_1eby7_99",u2="_unitTitle_1eby7_111",d2="_unitCount_1eby7_120",f2="_unitBody_1eby7_126",h2="_unitDescription_1eby7_131",p2="_unitKeywords_1eby7_138",m2="_keywordPill_1eby7_145",g2="_unitTopicsRow_1eby7_155",v2="_unitContents_1eby7_167",y2="_contentRow_1eby7_174",b2="_contentIcon_1eby7_180",C2="_contentTitle_1eby7_185",S2="_contentSkills_1eby7_193",_2="_skillPill_1eby7_200",je={courseDetails:WF,courseDetailsLoading:GF,courseDetailsError:KF,detailsCard:YF,unitsCard:ZF,cardTitle:XF,fieldGroup:JF,fieldGroupLast:e2,fieldLabel:t2,fieldValue:r2,fieldValueMultiline:n2,unitsLabel:s2,unitsDescription:i2,unitList:o2,unitCard:a2,unitHeader:l2,unitIcon:c2,unitTitle:u2,unitCount:d2,unitBody:f2,unitDescription:h2,unitKeywords:p2,keywordPill:m2,unitTopicsRow:g2,unitContents:v2,contentRow:y2,contentIcon:b2,contentTitle:C2,contentSkills:S2,skillPill:_2},w2={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr};function ma(e){return Array.isArray(e)?e.map(String):e?[String(e)]:[]}const tm=({courseId:e,variant:t="compact",title:r,onLoaded:n})=>{const s=ae(),i=as(),[o,a]=m.useState(null),[c,u]=m.useState(""),[d,f]=m.useState(null),[g,p]=m.useState({}),b=t==="full";m.useEffect(()=>{let C=!1;return a(null),u(""),f(null),vh(e).then(S=>{if(C)return;const x=(S.children??[]).map(E=>To(E));a(x),u(S.description??""),p(Object.fromEntries(x.map(E=>[E.id,!0]))),n==null||n({totalContents:x.reduce((E,D)=>{var T;return E+(((T=D.children)==null?void 0:T.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?ma((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:je.courseDetails,children:d?l.jsx("p",{className:je.courseDetailsError,children:d}):o===null?l.jsx("p",{className:je.courseDetailsLoading,children:s.learningPath.courseDetailsLoading}):l.jsxs(l.Fragment,{children:[b&&l.jsxs("div",{className:je.detailsCard,children:[l.jsx("h3",{className:je.cardTitle,children:s.learningPath.courseDetailsCardTitle}),l.jsxs("div",{className:je.fieldGroup,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.courseTitleFieldLabel}),l.jsx("div",{className:je.fieldValue,children:r})]}),l.jsxs("div",{className:je.fieldGroupLast,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.courseDescriptionFieldLabel}),l.jsx("div",{className:je.fieldValueMultiline,children:c||s.learningPath.noCourseDescriptionPlaceholder})]})]}),o.length===0?l.jsx("p",{className:je.courseDetailsLoading,children:s.learningPath.courseDetailsEmpty}):l.jsxs("div",{className:b?je.unitsCard:void 0,children:[l.jsx("span",{className:je.unitsLabel,children:s.learningPath.unitsSectionLabel}),b&&l.jsx("p",{className:je.unitsDescription,children:s.learningPath.unitsSectionDescription}),l.jsx("div",{className:je.unitList,children:o.map(C=>{var D,T;const S=!!g[C.id],_=(C.children??[]).length,x=ma((D=C.metadata)==null?void 0:D.keywords),E=ma((T=C.metadata)==null?void 0:T.topic);return l.jsxs("div",{className:je.unitCard,children:[l.jsxs("button",{type:"button",className:je.unitHeader,onClick:()=>h(C.id),"aria-expanded":S,children:[S?l.jsx(bn,{size:17}):l.jsx(wl,{size:17}),l.jsx("span",{className:je.unitIcon,children:l.jsx(Rf,{size:16})}),l.jsx("span",{className:je.unitTitle,children:C.name}),b&&l.jsx("span",{className:je.unitCount,children:y(_)})]}),S&&l.jsxs("div",{className:je.unitBody,children:[b&&C.description&&l.jsx("p",{className:je.unitDescription,children:C.description}),b&&x.length>0&&l.jsx("div",{className:je.unitKeywords,children:x.map(j=>l.jsx("span",{className:je.keywordPill,children:j},j))}),b&&E.length>0&&l.jsxs("div",{className:je.unitTopicsRow,children:[l.jsx("span",{className:je.fieldLabel,children:s.learningPath.unitTopicsFieldLabel}),l.jsx("span",{children:E.join(", ")})]}),l.jsx("div",{className:je.unitContents,children:(C.children??[]).map(j=>{const F=ni(j),O=w2[F.key]??Gr,N=v(j);return l.jsxs("div",{className:je.contentRow,children:[l.jsx(O,{size:16,className:je.contentIcon}),l.jsx("span",{className:je.contentTitle,children:j.name}),N.length>0&&l.jsx("div",{className:je.contentSkills,children:N.map(B=>l.jsx("span",{className:je.skillPill,children:B},B))})]},j.id)})})]})]},C.id)})})]})]})})},x2="_backToPathButton_42cuj_1",T2="_assessmentTitle_42cuj_15",E2="_slotPills_42cuj_22",A2="_slotPill_42cuj_22",I2="_slotPillHint_42cuj_40",k2="_slotPillPurpose_42cuj_45",D2="_slotPillWarning_42cuj_51",L2="_slotPillPrimary_42cuj_56",O2="_courseCard_42cuj_62",N2="_courseCardHeading_42cuj_72",j2="_courseCardDescription_42cuj_79",P2="_courseNotAdded_42cuj_85",R2="_assessmentExplainer_42cuj_93",F2="_assessmentExplainerHeading_42cuj_107",M2="_leafContentLayout_42cuj_117",B2="_container_42cuj_131",q2="_emptyState_42cuj_140",$2="_titleRow_42cuj_150",U2="_titleRowLp_42cuj_157",z2="_nodeTitle_42cuj_171",V2="_nodeTitleLpRoot_42cuj_193",H2="_nodeTitleSub_42cuj_198",Q2="_courseDetailHeader_42cuj_203",W2="_courseDetailIcon_42cuj_210",G2="_courseDetailTitle_42cuj_222",K2="_courseDetailMeta_42cuj_229",Y2="_formArea_42cuj_234",Z2="_contentListArea_42cuj_238",X2="_contentListAreaLp_42cuj_242",J2="_dropZone_42cuj_246",eM="_reviewComment_42cuj_253",tM="_reviewCommentLabel_42cuj_266",rM="_reviewCommentText_42cuj_272",Ie={backToPathButton:x2,assessmentTitle:T2,slotPills:E2,slotPill:A2,slotPillHint:I2,slotPillPurpose:k2,slotPillWarning:D2,slotPillPrimary:L2,courseCard:O2,courseCardHeading:N2,courseCardDescription:j2,courseNotAdded:P2,assessmentExplainer:R2,assessmentExplainerHeading:F2,leafContentLayout:M2,container:B2,emptyState:q2,titleRow:$2,titleRowLp:U2,nodeTitle:z2,nodeTitleLpRoot:V2,nodeTitleSub:H2,courseDetailHeader:Q2,courseDetailIcon:W2,courseDetailTitle:G2,courseDetailMeta:K2,formArea:Y2,contentListArea:Z2,contentListAreaLp:X2,dropZone:J2,reviewComment:eM,reviewCommentLabel:tM,reviewCommentText:rM},nM=({slot:e,isEditable:t})=>{var p;const r=ae(),n=ue(b=>b.treeData),s=ue(b=>b.selectNode),i=(p=n[0])==null?void 0:p.id,{pre:o,post:a}=Vl(),c=(e==="pre"?o:a).filled,u=e==="pre"?r.learningPath.priorAssessmentLabel:r.learningPath.outcomeAssessmentLabel,d=e==="pre"?Ps:yy,f=e==="pre"?r.learningPath.priorAssessmentExplainerTitle:r.learningPath.outcomeAssessmentExplainerTitle,g=e==="pre"?r.learningPath.priorAssessmentExplainerBody:r.learningPath.outcomeAssessmentExplainerBody;return l.jsxs("div",{className:Ie.container,children:[l.jsxs("button",{type:"button",className:Ie.backToPathButton,onClick:()=>i&&s(i),children:[l.jsx(_l,{size:14})," ",r.learningPath.backToPathButton]}),l.jsx("div",{className:Ie.assessmentTitle,children:u}),l.jsx("div",{className:Ie.slotPills,children:e==="pre"?l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillHint}`,children:[l.jsx(xc,{size:12})," ",r.learningPath.priorAssessmentHint]}),l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillPurpose}`,children:[l.jsx(gy,{size:12})," ",r.learningPath.priorAssessmentPurposeLabel]})]}):l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillWarning}`,children:[l.jsx(Bf,{size:12})," ",r.learningPath.outcomeUnlocksHint]}),l.jsxs("span",{className:`${Ie.slotPill} ${Ie.slotPillPrimary}`,children:[l.jsx(xc,{size:12})," ",r.learningPath.outcomeAssessmentHint]})]})}),l.jsxs("div",{className:Ie.formArea,children:[l.jsxs("div",{className:Ie.courseCard,children:[l.jsx("div",{className:Ie.courseCardHeading,children:r.learningPath.assessmentCourseSectionTitle}),l.jsx("p",{className:Ie.courseCardDescription,children:r.learningPath.assessmentCourseSectionDescription}),c?l.jsx(ul,{slot:e,isEditable:t}):l.jsx("div",{className:Ie.courseNotAdded,children:r.learningPath.assessmentNotAddedYet})]}),l.jsxs("div",{className:Ie.assessmentExplainer,children:[l.jsxs("div",{className:Ie.assessmentExplainerHeading,children:[l.jsx(d,{size:16}),l.jsx("span",{children:f})]}),l.jsx("p",{children:g})]})]})]})},sM="application/vnd.sunbird.questionset",rm="application/vnd.sunbird.question",iM=[sM,rm];function Td(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 oM=({editorMode:e,onToolbarEvent:t})=>{var oe,ge,ve,xe,ye;const r=ae(),[n,s]=m.useState("details"),[i,o]=m.useState([]),[a,c]=m.useState(null),[u,d]=m.useState(!1),[f,g]=m.useState(null),p=m.useRef(null),b=m.useRef(),{selectedNodeId:h,breadcrumb:v,activeNodeMeta:y,updateNode:C,treeData:S,selectNode:_}=ue(),x=Hr(R=>R.activeAssessmentSlot),E=Z(R=>{var M,Y,le,Ce;return((Y=(M=R.editorConfig)==null?void 0:M.context)==null?void 0:Y.contentId)??((Ce=(le=R.editorConfig)==null?void 0:le.context)==null?void 0:Ce.identifier)??""}),D=Z(R=>R.editorProfile.competencyScoped),T=h?nm(S,h):null;m.useEffect(()=>{g(null)},[T==null?void 0:T.identifier]);const j=!!T&&!T.parent,F=!!(T!=null&&T.isFolder),O=T&&iM.includes(T.mimeType??""),N=(T==null?void 0:T.mimeType)===rm,B=T&&!T.isFolder&&!O&&!j,U=D&&F&<(T??void 0)?((ve=(ge=(oe=S[0])==null?void 0:oe.children)==null?void 0:ge[0])==null?void 0:ve.id)===(T==null?void 0:T.id)?"pre":"post":D?x:null,ne=Td(T)??(j?Td(S[0]):void 0),H=m.useCallback(()=>{const R=p.current;if(!R||!h)return;const M=R.innerText.trim();clearTimeout(b.current),b.current=setTimeout(()=>{C(h,{name:M})},600)},[h,C]),te=m.useCallback(R=>{t({action:"onFormValueChange",data:R})},[t]),he=m.useCallback((R,M)=>{o(M),t({action:"onFormStatusChange",data:{isValid:R,nodeId:h}})},[t,h]);if(!T)return l.jsx("div",{className:Ie.emptyState,children:l.jsx("p",{children:r.contextualEditor.emptyStateMessage})});if(O)return l.jsx(dl,{node:T,editorMode:e,type:"quml",singleQuestion:N});if(D&&B&&T.primaryCategory==="Course"){const R=T.parent?a1(((xe=S[0])==null?void 0:xe.children)??[],T.parent):null,M=(R==null?void 0:R.role)==="pre"?r.learningPath.priorAssessmentLabel:(R==null?void 0:R.role)==="post"?r.learningPath.outcomeAssessmentLabel:(R==null?void 0:R.role)==="level"?r.learningPath.levelNumberPrefix.replace("{n}",String(R.levelNumber)):null,Y=f===null?"":` · ${(f===1?r.learningPath.contentCountLabel:r.learningPath.contentCountLabelPlural).replace("{count}",String(f))}`;return l.jsxs("div",{className:Ie.container,children:[l.jsxs("button",{type:"button",className:Ie.backToPathButton,onClick:()=>T.parent&&_(T.parent),children:[l.jsx(_l,{size:14}),M?r.learningPath.backToLevelButton.replace("{label}",M):r.learningPath.backToPathButton]}),l.jsxs("div",{className:Ie.courseDetailHeader,children:[l.jsx("span",{className:Ie.courseDetailIcon,children:l.jsx(Wr,{size:26})}),l.jsxs("div",{children:[l.jsx("h2",{className:Ie.courseDetailTitle,children:T.name}),l.jsxs("span",{className:Ie.courseDetailMeta,children:[T.primaryCategory,Y]})]})]}),l.jsx(tm,{courseId:T.identifier,variant:"full",title:T.name,onLoaded:({totalContents:le})=>g(le)},T.identifier)]})}return U?l.jsx(nM,{slot:U,isEditable:e==="edit"}):B?l.jsxs("div",{className:Ie.leafContentLayout,children:[l.jsx(dl,{node:T,editorMode:e,type:"content",layout:"flow"}),l.jsx(qF,{node:T,editorMode:e,onMoveClick:()=>c(T.identifier),reorderDialog:a?l.jsx(aF,{resourceId:a,resourceName:T.name,currentUnitId:T.parent??"",onClose:()=>c(null)}):null})]}):l.jsxs("div",{className:Ie.container,children:[l.jsx(OL,{crumbs:v}),ne&&l.jsxs("div",{className:Ie.reviewComment,role:"alert",children:[l.jsx("span",{className:Ie.reviewCommentLabel,children:r.contextualEditor.reviewCommentLabel}),l.jsx("span",{className:Ie.reviewCommentText,children:ne})]}),l.jsxs("div",{className:[Ie.titleRow,D?Ie.titleRowLp:""].filter(Boolean).join(" "),children:[j&&h&&l.jsx(QF,{nodeId:h,value:String(T.appIcon??((ye=T.metadata)==null?void 0:ye.appIcon)??""),editable:e==="edit"}),l.jsx("div",{ref:p,className:[Ie.nodeTitle,D&&j?Ie.nodeTitleLpRoot:"",D&&!j?Ie.nodeTitleSub:""].filter(Boolean).join(" "),contentEditable:e==="edit",suppressContentEditableWarning:!0,onInput:H,onBlur:H,"data-placeholder":r.contextualEditor.untitledPlaceholder,"aria-label":r.contextualEditor.nodeTitleAriaLabel,children:T.name})]}),l.jsx(ML,{activeTab:n,onChange:R=>s(R),errorTabs:i,visibleTabs:j&&!D?void 0:["details"]}),l.jsx("div",{className:Ie.formArea,children:l.jsx(Nj,{nodeMetadata:y,activeTab:n,isRoot:j,isFolder:F,editorMode:e,onFormValueChange:te,onFormStatusChange:he},`${h??"none"}:${j?"root":"node"}`)}),(F||j)&&n==="details"&&l.jsx("div",{className:[Ie.contentListArea,D?Ie.contentListAreaLp:""].filter(Boolean).join(" "),children:l.jsx(GP,{editorMode:e,isRoot:j})}),l.jsx(ZP,{isActive:!1,label:r.contextualEditor.dropZoneLabel,nodeId:h??void 0,className:Ie.dropZone}),u&&l.jsx(bF,{contentId:E,onClose:()=>d(!1)})]})};function nm(e,t){for(const r of e){if(r.id===t)return r;if(r.children){const n=nm(r.children,t);if(n)return n}}}const sm=Xs((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 aM(e,t,r,n){const s={primaryCategory:["Course"]};return n&&(s.framework=[n]),!e&&t.length&&r&&(s[r]=t),s}function lM(e,t){if(!(!e||!t))return[...Zp,t,"framework"]}function cM(e,t,r,n,s){return e?t?r&&!n&&s.length===0?"noSkills":null:"noCurriculum":null}const uM=20,dM=[];function im(){var u;const e=Z(d=>d.editorConfig),t=ue(d=>d.selectedNodeId),r=ue(d=>d.treeData),n=m.useCallback(()=>{if(!t||!r.length)return 0;function d(f,g,p=0){var b;for(const h of f){if(h.id===g)return p;if((b=h.children)!=null&&b.length){const v=d(h.children,g,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[...nd];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:[...nd]}function fM(){const e=sm(),t=Z(T=>{var j,F;return((F=(j=T.editorConfig)==null?void 0:j.context)==null?void 0:F.channel)??""}),r=im(),n=Z(T=>T.editorProfile),s=Hr(T=>T.activeAssessmentSlot),i=ue(T=>T.activeNodeMeta),o=ue(T=>T.treeData),a=ue(T=>T.treeCache),c=ue(T=>T.selectedNodeId),u=ue(T=>T.getNodeById),d=as(),f=n.competencyScoped?Sh(o[0],a):void 0,g=m.useRef(),p=d&&Array.isArray(i[d.code])?i[d.code]:dM,b=c?u(c):void 0,h=n.competencyScoped&&!!(b!=null&&b.isFolder)&&!!b.parent&&!lt(b),v=cM(n.competencyScoped,f,h,s,p),y=m.useCallback(async(T="",j="all",F={},O=!0,N=!1)=>{var B,P,U,ne,H;e.setLoading(!0);try{if(v){e.setContent([],0);return}let te;if(n.competencyScoped){const ve=aM(s,p,d==null?void 0:d.code,f);te={status:["Live"],...ve}}else te={status:["Live"],primaryCategory:j&&j!=="all"?[j]:r},(B=F==null?void 0:F.board)!=null&&B.length&&(te.board=F.board),(P=F==null?void 0:F.medium)!=null&&P.length&&(te.medium=F.medium),(U=F==null?void 0:F.gradeLevel)!=null&&U.length&&(te.gradeLevel=F.gradeLevel),(ne=F==null?void 0:F.subject)!=null&&ne.length&&(te.subject=F.subject),(H=F==null?void 0:F.primaryCategory)!=null&&H.length&&(te.primaryCategory=F.primaryCategory);const he=O?0:e.offset,{content:oe,count:ge}=await XP({filters:te,query:T,limit:T?50:uM,offset:he,channel:t||void 0,sortBy:N?{name:"asc"}:{lastUpdatedOn:"desc"},fields:lM(n.competencyScoped,d==null?void 0:d.code)});O?e.setContent(oe,ge):e.appendContent(oe,ge)}catch(te){console.error("[useLibrary] load error:",te)}finally{e.setLoading(!1)}},[r,t,n,s,p,d,f,v]);m.useEffect(()=>{clearTimeout(g.current),e.setSearch("")},[f]),m.useEffect(()=>{y()},[t]),m.useEffect(()=>{n.competencyScoped&&y()},[n.competencyScoped,s,p.join("|"),f,c]);const C=m.useCallback(T=>{e.setSearch(T),clearTimeout(g.current),g.current=setTimeout(()=>y(T,e.activeFilter,e.advancedFilters,!0,e.sortAZ),300)},[e.activeFilter,e.advancedFilters,e.sortAZ,y]),S=m.useCallback(T=>{e.setFilter(T),y(e.searchQuery,T,e.advancedFilters,!0,e.sortAZ)},[e.searchQuery,e.advancedFilters,e.sortAZ,y]),_=m.useCallback(T=>{e.setAdvancedFilters(T),y(e.searchQuery,e.activeFilter,T,!0,e.sortAZ)},[e.searchQuery,e.activeFilter,e.sortAZ,y]),x=m.useCallback(()=>{const T=!e.sortAZ;e.setSortAZ(T),y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,T)},[e.sortAZ,e.searchQuery,e.activeFilter,e.advancedFilters,y]),E=m.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:E,refetch:()=>y(e.searchQuery,e.activeFilter,e.advancedFilters,!0,e.sortAZ),activeAssessmentSlot:s,emptyReason:v}}function om(){var a;const e=ae(),t=Z(c=>c.editorProfile.competencyScoped),r=Hr(c=>c.activeAssessmentSlot),n=ue(c=>c.selectedNodeId),s=ue(c=>c.treeData),i=ue(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 hM="_card_1cmpg_1",pM="_addBtn_1cmpg_17",mM="_dragging_1cmpg_24",gM="_ctIcon_1cmpg_29",vM="_info_1cmpg_33",yM="_name_1cmpg_41",bM="_meta_1cmpg_50",CM="_skillTags_1cmpg_58",SM="_skillTag_1cmpg_58",_M="_addBtnMuted_1cmpg_93",wM="_added_1cmpg_102",xM="_addedBadge_1cmpg_111",Yt={card:hM,addBtn:pM,dragging:mM,ctIcon:gM,info:vM,name:yM,meta:bM,skillTags:CM,skillTag:SM,addBtnMuted:_M,added:wM,addedBadge:xM},TM={video:So,pdf:Zs,h5p:vo,scorm:bo,audio:yo,quiz:go,course:Wr,default:Gr},EM=({item:e,onAdd:t,onPreview:r,isDraggable:n,isAdded:s})=>{var S,_;const i=ae(),o=ni(e),a=TM[o.key]??Gr,c=zl(),u=lD(),d=c&&!s&&u,f=Z(x=>x.editorProfile.competencyScoped),g=as(),p=f&&g?(()=>{const x=e[g.code];return Array.isArray(x)?x:x?[String(x)]:[]})():[],{attributes:b,listeners:h,setNodeRef:v,isDragging:y}=Df({id:e.identifier,disabled:!n||!c||!u,data:{type:"library-item",item:e}}),C=()=>{r&&r(e)};return l.jsxs("div",{ref:v,className:[Yt.card,y?Yt.dragging:"",s?Yt.added:""].join(" "),"aria-label":e.name,...n?{...b,...h}:{},role:"listitem",onClick:C,children:[l.jsx("span",{className:[`sbx-ct-sq--${o.key}`,Yt.ctIcon].join(" "),"aria-hidden":"true",children:l.jsx(a,{size:14})}),l.jsxs("div",{className:Yt.info,children:[l.jsx("span",{className:Yt.name,title:e.name,children:e.name}),l.jsxs("span",{className:Yt.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:Yt.skillTags,children:p.slice(0,3).map(x=>l.jsx("span",{className:Yt.skillTag,children:x},x))})]}),s&&l.jsx("span",{className:Yt.addedBadge,"aria-label":i.libraryCard.alreadyAddedAriaLabel,title:i.libraryCard.alreadyAddedTitle,children:l.jsx(yn,{size:12})}),!s&&n&&l.jsx("button",{type:"button",className:[Yt.addBtn,!d&&c?Yt.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(Cn,{size:14})})]})},AM="_chips_xhhaq_1",IM="_chip_xhhaq_1",Ed={chips:AM,chip:IM},kM=({filters:e,active:t,onChange:r})=>{const n=ae();return l.jsx("div",{className:Ed.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",Ed.chip].join(" "),onClick:()=>r(s.value),children:s.label},s.value))})},DM="_panel_uame3_1",LM="_header_uame3_10",OM="_headerTitle_uame3_19",NM="_closeBtn_uame3_25",jM="_body_uame3_43",PM="_section_uame3_59",RM="_sectionLabel_uame3_65",FM="_chips_uame3_73",MM="_chip_uame3_73",BM="_active_uame3_96",qM="_footer_uame3_102",$M="_resetBtn_uame3_112",UM="_applyBtn_uame3_129",ht={panel:DM,header:LM,headerTitle:OM,closeBtn:NM,body:jM,section:PM,sectionLabel:RM,chips:FM,chip:MM,active:BM,footer:qM,resetBtn:$M,applyBtn:UM},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}],VM=new Set(["board","medium","gradeLevel","subject","topic"]),HM=({local:e,toggle:t})=>{const r=ae(),n=im();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},QM=({isOpen:e,filters:t,onApply:r,onClose:n})=>{var v,y;const s=ae(),i=Z(C=>C.editorConfig),o=Z(C=>C.searchFormConfig),a=Z(C=>C.contentFramework),c=Z(C=>C.contentTargetFWIds),{organisationFramework:u}=Eo(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]=m.useState(t),g=o!=null&&o.length?o.filter(C=>VM.has(C.code)).map(C=>({key:C.code,label:C.label||C.code})):zM(s);m.useEffect(()=>{f(t)},[t]);const p=(C,S)=>{f(_=>{const x=_[C]??[],E=x.includes(S)?x.filter(D=>D!==S):[...x,S];return{..._,[C]:E}})},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(yr,{size:16})})]}),l.jsxs("div",{className:ht.body,children:[g.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(HM,{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},WM="_header_1tvk1_10",GM="_headerCourse_1tvk1_20",KM="_courseIcon_1tvk1_25",YM="_titleGroup_1tvk1_37",ZM="_courseMeta_1tvk1_45",XM="_title_1tvk1_37",JM="_headerActions_1tvk1_67",eB="_iconBtn_1tvk1_74",tB="_playerArea_1tvk1_92",rB="_footer_1tvk1_100",nB="_footerCourse_1tvk1_109",sB="_addBtn_1tvk1_115",iB="_addBtnCourse_1tvk1_134",oB="_modalOverlay_1tvk1_159",aB="_modalOverlayCourse_1tvk1_174",lB="_modalPanel_1tvk1_178",cB="_modalPanelCourse_1tvk1_190",gt={header:WM,headerCourse:GM,courseIcon:KM,titleGroup:YM,courseMeta:ZM,title:XM,headerActions:JM,iconBtn:eB,playerArea:tB,footer:rB,footerCourse:nB,addBtn:sB,addBtnCourse:iB,modalOverlay:oB,modalOverlayCourse:aB,modalPanel:lB,modalPanelCourse:cB},uB="application/vnd.sunbird.questionset",dB=({content:e,editorMode:t,onAdd:r,onClose:n})=>{var f;const s=ae(),i=t==="edit",o=Z(g=>g.editorProfile.competencyScoped),a=om();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 Ur.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:g=>g.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(Wr,{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(yr,{size:16})})})]}),l.jsx("div",{className:gt.playerArea,children:c?l.jsx(tm,{courseId:e.identifier}):l.jsx(dl,{node:d,editorMode:"read",type:e.mimeType===uB?"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(Cn,{size:15})," ",a??s.libraryPreviewPanel.addToUnitButton]}):l.jsx("button",{type:"button",className:gt.addBtn,onClick:()=>r(e),children:s.libraryPreviewPanel.addToUnitButton})})]})}),document.body)},fB="_dock_2k0x7_1",hB="_header_2k0x7_8",pB="_libraryTargetLabel_2k0x7_18",mB="_headerLeft_2k0x7_28",gB="_headerTitle_2k0x7_36",vB="_count_2k0x7_42",yB="_searchRow_2k0x7_51",bB="_searchWrap_2k0x7_59",CB="_searchIcon_2k0x7_65",SB="_searchInput_2k0x7_74",_B="_filterToggleBtn_2k0x7_92",wB="_filterToggleBtnActive_2k0x7_111",xB="_filterBadge_2k0x7_117",TB="_filters_2k0x7_136",EB="_mainArea_2k0x7_146",AB="_sidePanelOverlay_2k0x7_155",IB="_cardList_2k0x7_164",kB="_skeleton_2k0x7_180",DB="_skeletonIcon_2k0x7_190",LB="_skeletonText_2k0x7_198",OB="_skeletonLine_2k0x7_205",NB="_skeletonLineSm_2k0x7_212",jB="_loadMoreBtn_2k0x7_227",PB="_emptyState_2k0x7_252",RB="_collapseBtn_2k0x7_272",Ue={dock:fB,header:hB,libraryTargetLabel:pB,headerLeft:mB,headerTitle:gB,count:vB,searchRow:yB,searchWrap:bB,searchIcon:CB,searchInput:SB,filterToggleBtn:_B,filterToggleBtnActive:wB,filterBadge:xB,filters:TB,mainArea:EB,sidePanelOverlay:AB,cardList:IB,skeleton:kB,skeletonIcon:DB,skeletonText:LB,skeletonLine:OB,skeletonLineSm:NB,loadMoreBtn:jB,emptyState:PB,collapseBtn:RB},FB=[{label:"Courses",value:"all"}];function MB(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 BB=({editorMode:e,collapsed:t=!1,onToggleCollapse:r})=>{const n=ae(),{content:s,isLoading:i,totalCount:o,activeFilter:a,searchQuery:c,sortAZ:u,hasMore:d,search:f,setFilter:g,applyAdvancedFilters:p,toggleSort:b,loadMore:h,activeAssessmentSlot:v,emptyReason:y}=fM(),{addResource:C,selectedNodeId:S,treeData:_,treeCache:x}=ue(),E=Hr(R=>R.setActiveAssessmentSlot),D=Z(R=>R.editorProfile.competencyScoped),T=e==="edit",j=om(),[F,O]=m.useState(!1),[N,B]=m.useState({}),[P,U]=m.useState(null),[ne,H]=m.useState(null),te=m.useMemo(()=>MB(_),[_]),he=m.useCallback(async(R,M)=>{var le,Ce;const Y=(le=_[0])==null?void 0:le.id;if(!(!Y||ne)){if(Fs(((Ce=_[0])==null?void 0:Ce.children)??[],M)){we.error(M==="pre"?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}H(R.identifier);try{const{qualifies:de,meta:ce}=await bh(R.identifier);if(!de){we.error(n.learningPath.notAssessmentCourseToast.replace("{name}",R.name));return}const Q={...R,...ce};if(C(Q,Y,{isAssessmentCourse:!0,slot:M})===!1){we.error(n.learningPath.bothSlotsFilledToast);return}we.success(n.libraryDock.itemAddedToast.replace("{name}",R.name)),E(null)}catch(de){console.error("[LibraryDock] assessment-course check failed:",de),we.error(n.learningPath.assessmentCheckFailedToast)}finally{H(null)}}},[_,C,E,ne,n]),oe=m.useCallback(R=>{var Ce,de,ce;if(D&&!_h(_[0],x)){we.error(n.learningPath.selectCurriculumFirstToast);return}if(v){he(R,v);return}if(!S){we.error(D?n.learningPath.selectLevelFirstToast:n.libraryDock.selectUnitFirstToast);return}const M=(Ce=_[0])==null?void 0:Ce.id,Y=ue.getState().getNodeById(S);if(D){const Q=((de=_[0])==null?void 0:de.children)??[],se=Y!=null&&Y.isFolder?Y:Y!=null&&Y.parent?ue.getState().getNodeById(Y.parent):void 0;if(se&&Qa(Q,se)){const Te=(ce=Q[0])==null?void 0:ce.id;we.error(se.id===Te?n.learningPath.priorSlotFilledToast:n.learningPath.outcomeSlotFilledToast);return}}if(S===M||!(Y!=null&&Y.isFolder)){we(D?n.learningPath.selectLevelFromOutlineToast:n.libraryDock.selectUnitFromOutlineToast,{icon:l.jsx(Ps,{size:16}),duration:4e3});return}if(C(R,S)===!1){we.error((D?n.learningPath.itemAlreadyInPathToast:n.libraryDock.itemAlreadyAddedToast).replace("{name}",R.name));return}we.success(n.libraryDock.itemAddedToast.replace("{name}",R.name))},[v,he,S,C,_,x,n,D]),ge=m.useCallback(R=>{B(R),p(R)},[p]),ve=m.useCallback(R=>{U(R)},[]),xe=m.useCallback(R=>{oe(R),U(null)},[oe]),ye=m.useMemo(()=>Object.values(N).reduce((R,M)=>R+((M==null?void 0:M.length)??0),0),[N]);return l.jsxs("div",{className:Ue.dock,children:[l.jsxs("div",{className:Ue.header,children:[l.jsxs("div",{className:Ue.headerLeft,children:[l.jsx("button",{type:"button",className:Ue.collapseBtn,onClick:r,"aria-label":n.libraryDock.collapseLibraryPanelAriaLabel,title:n.libraryDock.collapseLibraryTitle,children:l.jsx(Oy,{size:15})}),l.jsx(Iy,{size:16}),l.jsx("span",{className:Ue.headerTitle,children:n.libraryDock.headerTitle}),o>0&&l.jsx("span",{className:Ue.count,children:o})]}),j&&l.jsx("span",{className:Ue.libraryTargetLabel,children:j})]}),l.jsxs("div",{className:Ue.searchRow,children:[l.jsxs("div",{className:Ue.searchWrap,children:[l.jsx(Wi,{size:14,className:Ue.searchIcon}),l.jsx("input",{type:"search",className:Ue.searchInput,placeholder:n.libraryDock.searchPlaceholder,value:c,onChange:R=>f(R.target.value),"aria-label":n.libraryDock.searchAriaLabel})]}),l.jsx("button",{type:"button",className:[Ue.filterToggleBtn,u?Ue.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(vy,{size:15}):l.jsx(_y,{size:15})}),l.jsxs("button",{type:"button",className:[Ue.filterToggleBtn,F?Ue.filterToggleBtnActive:""].join(" "),onClick:()=>O(R=>!R),"aria-label":n.libraryDock.toggleAdvancedFiltersAriaLabel,"aria-pressed":F,title:n.libraryDock.advancedFiltersTitle,children:[l.jsx(qy,{size:15}),ye>0&&l.jsx("span",{className:Ue.filterBadge,children:ye})]})]}),l.jsx("div",{className:Ue.filters,children:l.jsx(kM,{filters:D?FB:cD,active:a,onChange:g})}),l.jsxs("div",{className:Ue.mainArea,children:[l.jsx("div",{className:Ue.cardList,role:"list","aria-label":n.libraryDock.libraryContentAriaLabel,children:i&&s.length===0?Array.from({length:4}).map((R,M)=>l.jsxs("div",{className:Ue.skeleton,"aria-hidden":"true",children:[l.jsx("div",{className:Ue.skeletonIcon}),l.jsxs("div",{className:Ue.skeletonText,children:[l.jsx("div",{className:Ue.skeletonLine}),l.jsx("div",{className:Ue.skeletonLineSm})]})]},M)):s.length>0?l.jsxs(l.Fragment,{children:[s.map(R=>l.jsx(EM,{item:R,onAdd:oe,onPreview:ve,isDraggable:T,isAdded:te.has(R.identifier)},R.identifier)),d&&l.jsx("button",{type:"button",className:Ue.loadMoreBtn,onClick:h,disabled:i,"aria-label":n.libraryDock.loadMoreAriaLabel,children:i?n.libraryDock.loadingText:n.libraryDock.loadMoreText})]}):l.jsxs("div",{className:Ue.emptyState,children:[l.jsx(Wi,{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})]})]})}),F&&l.jsx("div",{className:Ue.sidePanelOverlay,children:l.jsx(QM,{isOpen:F,filters:N,onApply:ge,onClose:()=>O(!1)})}),P&&l.jsx(dB,{content:P,editorMode:e,onAdd:xe,onClose:()=>U(null)})]})]})};function qB(e,t,r,n=El){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 g(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 E;if(y)E={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,...T}=v??{};E={...d(p.metadata??{},!0),...d(T,!1),name:p.name}}else{const{isNew:D,...T}=v??{};E={name:p.name,visibility:"Parent",...d(T,!0)}}s[h]={metadata:E,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(E=>E.identifier),...Object.keys(S).length>0?{relationalMetadata:S}:{},root:b},(p.children??[]).forEach(E=>g(E,!1))}return e.forEach((p,b)=>g(p,b===0)),{nodesModified:s,hierarchy:i}}function $B(){const[e,t]=m.useState(!1),r=ue(d=>d.treeCache),n=ue(d=>d.treeData),s=Z(d=>d.isDirty),i=Z(d=>d.lastSaved),{setIsDirty:o,setLastSaved:a}=Z(),c=Z(d=>d.editorConfig);return{save:m.useCallback(async()=>{if(!c||e)return;const d=c.context.contentId??c.context.identifier??"";if(!d)return;if(n.length===0){we.error("Collection is empty. Please reload before saving.");return}const f=c.context.channel??"",g=c.context.userId??c.context.uid??"";t(!0);try{const p=Z.getState().editorProfile,{nodesModified:b,hierarchy:h}=qB(n,r,f,p),{identifiers:v}=await Xx(d,b,h,g);v&&Object.keys(v).length>0&&ue.getState().replaceNodeIds(v);const y=new Date().toISOString();a(y),o(!1)}catch(p){console.error("[useSaveHierarchy] save failed:",p),we.error("Failed to save. Please try again.")}finally{t(!1)}},[c,e,n,r,o,a]),isSaving:e,isDirty:s,lastSaved:i}}const UB={};function zB(e){return e==null||e===""||Array.isArray(e)&&e.length===0}function VB(e,t,r,n,s,i=UB){const o=[],a=(c,u)=>{var d;for(const f of c){const g=u&&!f.parent,p=g?r:f.isFolder?n:null;if(p&&p.length>0){const b={...f.metadata??{},...t[f.id]??{}},v=qp(p,b,i,g,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 HB(e){var h,v;const t=Z(y=>y.editorConfig),r=Z(y=>y.setButtonLoader),n=Z(y=>y.validateAllForms),s=Z(y=>y.rootFormConfig),i=Z(y=>y.unitFormConfig),o=ue(y=>y.treeData),a=ue(y=>y.treeCache),c=ue(y=>y.selectNode),u=Z(y=>y.contentFramework),d=Z(y=>y.contentTargetFWIds),{organisationFramework:f,targetFrameworks:g}=Eo(u??((h=t==null?void 0:t.context)==null?void 0:h.framework),d??((v=t==null?void 0:t.context)==null?void 0:v.targetFWIds)),p=m.useCallback(()=>{var x,E,D;const y={editorMode:"edit",objectType:(x=t==null?void 0:t.config)==null?void 0:x.objectType,userFullName:(D=(E=t==null?void 0:t.context)==null?void 0:E.user)==null?void 0:D.fullName},C=VB(o,a,s,i,y,{organisationFramework:f,targetFrameworks:g});if(C.length===0)return!0;const S=C[0];we.error(`"${S.nodeName}": please fill required field${S.missing.length>1?"s":""} — ${S.missing.join(", ")}`);const{setFormStatus:_}=Z.getState();return C.forEach(T=>_(T.nodeId,!1)),c(S.nodeId),!1},[o,a,s,i,t,c,f,g]);return{runAction:m.useCallback(async(y,C)=>{var x,E,D,T;const S=((x=t==null?void 0:t.context)==null?void 0:x.contentId)??((E=t==null?void 0:t.context)==null?void 0:E.identifier)??"";if(!S)return we.error("No content identifier found."),!1;const _=((D=t==null?void 0:t.context)==null?void 0:D.userId)??((T=t==null?void 0:t.context)==null?void 0:T.uid)??"";try{switch(y){case"sendForReview":return p()?n(o)?(r("saveCollection",!0),await e(),await t1(S),we.success("Content sent for review"),!0):(we.error("Some units have missing required fields. Please fill them before sending for review."),!1):!1;case"reject":{r("rejectCollection",!0);const j=(C==null?void 0:C.comment)??"";return await r1(S,j),we.success("Content rejected and sent back to the author"),!0}case"publish":return p()?n(o)?(r("publishCollection",!0),await e(),await Jx(S,_),we.success("Content published successfully"),!0):(we.error("Some units have missing required fields. Please fill them before publishing."),!1):!1;default:return!1}}catch(j){console.error(`[useToolbarActions] ${y} failed`,j);const F=y==="sendForReview"?"send for review":y==="reject"?"reject":"publish";return we.error(`Failed to ${F}. Please try again.`),!1}finally{r("saveCollection",!1),r("rejectCollection",!1),r("publishCollection",!1)}},[t,e,r,p,n,o]),checkRequiredFields:p}}const QB="_shell_fu72l_1",WB="_workspace_fu72l_8",GB="_sidebarCollapsed_fu72l_16",KB="_dockCollapsed_fu72l_19",YB="_dock_fu72l_19",ZB="_outline_fu72l_40",XB="_reopenTab_fu72l_45",JB="_outlineHidden_fu72l_79",eq="_editor_fu72l_86",tq="_editorLp_fu72l_92",rq="_dockHidden_fu72l_105",nq="_dockReopenTab_fu72l_112",sq="_dragChip_fu72l_137",iq="_dragChipLabel_fu72l_152",jt={shell:QB,workspace:WB,sidebarCollapsed:GB,dockCollapsed:KB,dock:YB,outline:ZB,reopenTab:XB,outlineHidden:JB,editor:eq,editorLp:tq,dockHidden:rq,dockReopenTab:nq,dragChip:sq,dragChipLabel:iq},oq=({editorMode:e,onToolbarEvent:t,onContentAdded:r,onHierarchySaved:n})=>{const s=ae(),[i,o]=m.useState(null),[a,c]=m.useState(!1),[u,d]=m.useState(!1),[f,g]=m.useState(!1),{addResource:p,treeData:b,treeCache:h}=ue(),v=Z(H=>H.setFormStatus),y=Z(H=>H.editorProfile.key==="learningPath"),[C,S]=m.useState(!0),_=ue(H=>H.selectedNodeId),{save:x,isSaving:E,isDirty:D,lastSaved:T}=$B(),{runAction:j,checkRequiredFields:F}=HB(x);m.useEffect(()=>{if(!D)return;const H=te=>{te.preventDefault(),te.returnValue=""};return window.addEventListener("beforeunload",H),()=>window.removeEventListener("beforeunload",H)},[D]);const O=uf(Na(ho,{activationConstraint:{distance:8}})),N=m.useCallback(H=>{var he;const te=(he=H.active.data.current)==null?void 0:he.item;te&&o(te)},[]),B=m.useCallback(H=>{var R,M,Y,le,Ce;o(null);const te=(R=H.active.data.current)==null?void 0:R.item;if(!te)return;if(y&&!_h(b[0],h)){we.error(s.learningPath.selectCurriculumFirstToast);return}const he=H.over,oe=(he==null?void 0:he.id)??_??void 0,ge=y?s.learningPath.dropOntoLevelError:s.splitBuilderShell.dropOntoUnitError;if(!oe){we.error(ge);return}const ve=(M=b[0])==null?void 0:M.id;if(oe===ve){we.error(y?s.learningPath.dropOntoPathError:s.splitBuilderShell.dropOntoCourseError);return}const xe=ue.getState().getNodeById(oe);if(!(xe!=null&&xe.isFolder)){we.error(ge);return}if(y&<(xe)){const de=(Ce=(le=(Y=b[0])==null?void 0:Y.children)==null?void 0:le[0])==null?void 0:Ce.id;we.error(xe.id===de?s.learningPath.priorSlotFilledToast:s.learningPath.outcomeSlotFilledToast);return}if(!p(te,oe)){we.error((y?s.learningPath.itemAlreadyInPathToast:s.splitBuilderShell.alreadyInCollectionError).replace("{name}",te.name));return}r==null||r(te,oe),we.success((y?s.learningPath.addedToLevelSuccess:s.splitBuilderShell.addedToUnitSuccess).replace("{name}",te.name))},[_,p,b,h,r,s,y]),P=m.useCallback(async H=>{if(H.action==="onFormStatusChange"){const{isValid:te,nodeId:he}=H.data??{},oe=te!==!1;S(oe),he&&v(he,oe);return}if(H.action==="back"&&D&&e==="edit"){g(!0);return}if(H.action==="saveCollection"){if(!C){we.error(s.splitBuilderShell.fillRequiredMetadataError);return}if(!F())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,F,t,n,b,D,C,e,s]),U=m.useCallback(async()=>{if(!F()){g(!1);return}await x(),g(!1),n==null||n(b),t==null||t({action:"back"})},[x,F,n,t,b]),ne=m.useCallback(()=>{g(!1),t==null||t({action:"back"})},[t]);return l.jsxs(kf,{sensors:O,onDragStart:N,onDragEnd:B,children:[l.jsxs("div",{className:jt.shell,children:[l.jsx(G0,{editorMode:e,isSaving:E,isDirty:D,lastSaved:T,isFormValid:C,onToolbarEvent:P}),l.jsxs("div",{className:[jt.workspace,a?jt.sidebarCollapsed:"",u?jt.dockCollapsed:""].filter(Boolean).join(" "),children:[l.jsx("aside",{className:[jt.outline,a?jt.outlineHidden:""].join(" "),"aria-label":s.splitBuilderShell.outlineAriaLabel,"aria-hidden":a,children:l.jsx(AL,{editorMode:e,collapsed:a,onToggleCollapse:()=>c(H=>!H)})}),a&&l.jsx("button",{className:jt.reopenTab,onClick:()=>c(!1),title:s.splitBuilderShell.showOutlineTitle,type:"button",children:"›"}),l.jsx("main",{className:[jt.editor,y?jt.editorLp:""].filter(Boolean).join(" "),role:"main","aria-label":s.splitBuilderShell.editorAriaLabel,children:l.jsx(oM,{editorMode:e,onToolbarEvent:P})}),l.jsx("aside",{className:[jt.dock,u?jt.dockHidden:""].filter(Boolean).join(" "),"aria-label":s.splitBuilderShell.libraryAriaLabel,"aria-hidden":u,children:l.jsx(BB,{editorMode:e,collapsed:u,onToggleCollapse:()=>d(H=>!H)})}),u&&l.jsx("button",{className:jt.dockReopenTab,onClick:()=>d(!1),title:s.splitBuilderShell.showLibraryTitle,type:"button",children:"‹"})]})]}),l.jsx(fy,{dropAnimation:null,children:i?l.jsx("div",{className:jt.dragChip,children:l.jsx("span",{className:jt.dragChipLabel,children:i.name})}):null}),f&&l.jsx(K0,{onSave:U,onDiscard:ne,onCancel:()=>g(!1),isSaving:E})]})},aq="v1";function lq(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 Ad(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:lq(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 kr(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(Ad(o,s))}else n.code&&r.push(Ad(n));return r}function cq(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 uq(e,t,r="Collection",n=aq){var u,d;const i=(d=(u=(await Re.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:kr(o.create),unitForm:kr(o.unitMetadata),childForm:kr(o.childMetadata),searchForm:kr(o.search??o.searchConfig),relationalForm:kr(o.relationalMetadata),publishChecklist:kr(o.publishchecklist),reviewChecklist:kr(o.review),rfcChecklist:kr(o.requestforchangeschecklist),schemaDefaults:cq(a.schema),frameworkMetadata:c.frameworkMetadata??{},sourcingSettings:c.sourcingSettings??{}}}function Id(e,t,r){return{framework:e.framework??t??r.framework??null,targetFWIds:e.targetFWIds??r.targetFWIds??null}}function dq({config:e,onError:t}){const[r,n]=m.useState(!0),[s,i]=m.useState(null),[o,a]=m.useState(!1),{setEditorConfig:c,setEditorMode:u,setCategoryDefinition:d,setContentFramework:f,setEditorProfile:g}=Z(),{setTreeData:p,selectNode:b}=ue();return m.useEffect(()=>{let h=!1;async function v(){var y,C,S;try{n(!0),i(null),e.apiBaseUrl&&hh(e.apiBaseUrl),c(e),u(e.config.mode),g(ob(e));const _=e.context.contentId??e.context.identifier??"",x=e.context.channel??"";let E;if(x)try{E=(y=await Mp(x))==null?void 0:y.defaultFramework}catch{}let D=!1;if(_){const T=e.config.objectType==="QuestionSet";let{rootNode:j}=T?await Zx(_):await gh(_);if(j&&e.config.primaryCategory==="Learning Path"&&(j=await i1(j)),!h&&(p(j?[j]:[]),j)){b(j.id);const{framework:P,targetFWIds:U}=Id(j.metadata??{},E,e.context);f(P,U),D=!0}const F=e.config.primaryCategory??"Course",O=e.context.channel??"",N=e.config.categoryDefinitionApiVersion??"v1";try{const B=await uq(F,O,e.config.objectType??"Collection",N);if(!h){d(B);const P=((C=B.sourcingSettings)==null?void 0:C.collection)??{},U={};P.maxDepth&&!e.config.maxDepth&&(U.maxDepth=P.maxDepth),P.children&&!e.config.children&&(U.children=P.children),P.hierarchy&&!((S=e.config.hierarchy)!=null&&S.level1)&&(U.hierarchy={...e.config.hierarchy??{},...P.hierarchy}),Object.keys(U).length>0&&c({...e,config:{...e.config,...U}})}}catch{}}if(!h&&!D){const{framework:T,targetFWIds:j}=Id({},E,e.context);f(T,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 fq(){const e=Al(t=>t.setLanguage);m.useEffect(()=>{e(localStorage.getItem(Ba)||"en",{broadcast:!1});const t=n=>{n.key===Ba&&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(qa,r),()=>{window.removeEventListener("storage",t),window.removeEventListener(qa,r)}},[e])}const hq="_root_1itrv_1",pq="_loadingState_1itrv_10",mq="_loadingSpinner_1itrv_20",gq="_errorState_1itrv_34",ws={root:hq,loadingState:pq,loadingSpinner:mq,errorState:gq},vq=new Rm({defaultOptions:{queries:{retry:1,refetchOnWindowFocus:!1}}});function yq({error:e,onRetry:t}){const r=ae();return l.jsxs("div",{className:ws.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 bq extends m.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(yq,{error:this.state.error,onRetry:()=>this.setState({error:null})}):this.props.children}}function Cq(e){fq();const t=ae(),{isLoading:r,error:n}=dq({config:e,onError:e.onError}),s=Z(o=>o.editorMode),i=Z(o=>o.editorProfile);return r?l.jsxs("div",{className:ws.loadingState,children:[l.jsx("div",{className:ws.loadingSpinner}),l.jsx("p",{children:t.collectionEditor.loadingMessage})]}):n?l.jsxs("div",{className:ws.errorState,children:[l.jsx("h3",{children:t.collectionEditor.loadErrorTitle}),l.jsx("p",{children:n.message})]}):l.jsx("div",{className:["sb-split-builder",ws.root,i.key==="learningPath"?"sbx-lp-profile":""].filter(Boolean).join(" "),children:l.jsx(oq,{editorMode:s,onToolbarEvent:e.onToolbarEvent,onContentAdded:e.onContentAdded,onHierarchySaved:e.onHierarchySaved})})}const am=e=>l.jsx(bq,{onError:e.onError,children:l.jsxs(Mm,{client:vq,children:[l.jsx(Cq,{...e}),l.jsx(Fg,{position:"top-right",toastOptions:{duration:3e3,style:{fontFamily:"var(--sbx-font)"}}})]})}),io=Symbol.for("r2wc.reactRender"),kd=Symbol.for("r2wc.shouldRender"),_i=Symbol.for("r2wc.root");function Sq(e=""){return e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function _q(e=""){return e.replace(/-([a-z0-9])/g,function(t){return t[1].toUpperCase()})}var Dd={expando:function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:function(){return r},set:function(n){r=n,this[io]()}}),e[io]()}};function wq(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,g){return i&&(s[d]=!0),typeof d=="symbol"||s[d]||d in u?(e.propTypes&&d in e.propTypes&&Dd.expando(g,d,f),Reflect.set(u,d,f,g)):(Dd.expando(g,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[kd]=!0,this[io]()},a.disconnectedCallback=function(){typeof r.createRoot=="function"?this[_i].unmount():r.unmountComponentAtNode(this)},a[io]=function(){if(this[kd]===!0){var u={};Object.keys(this).forEach(function(g){s[g]!==!1&&(u[g]=this[g])},this),i=!0;const d=n.shadow?this.shadowRoot:this,f=t.createElement(e,u);typeof r.createRoot=="function"?(this[_i]||(this[_i]=r.createRoot(d)),this[_i].render(f)):r.render(f,d),i=!1}},e.propTypes&&(o.observedAttributes=n.dashStyleAttributes?Object.keys(e.propTypes).map(function(u){return Sq(u)}):Object.keys(e.propTypes),a.attributeChangedCallback=function(u,d,f){var g=n.dashStyleAttributes?_q(u):u;this[g]=f}),o}var jn={},Ld;function xq(){if(Ld)return jn;Ld=1;var e=Ur;if(process.env.NODE_ENV==="production")jn.createRoot=e.createRoot,jn.hydrateRoot=e.hydrateRoot;else{var t=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;jn.createRoot=function(r,n){t.usingClientEntryPoint=!0;try{return e.createRoot(r,n)}finally{t.usingClientEntryPoint=!1}},jn.hydrateRoot=function(r,n,s){t.usingClientEntryPoint=!0;try{return e.hydrateRoot(r,n,s)}finally{t.usingClientEntryPoint=!1}}}return jn}var Tq=xq();const Eq=xl(Tq);function Aq(){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 Iq(e="sb-collection-editor"){if(Aq(),typeof customElements>"u"||customElements.get(e))return;const t=wq(am,m,Eq,{});customElements.define(e,t)}exports.CollectionEditor=am;exports.registerCollectionEditor=Iq;exports.setApiBaseUrl=hh;exports.useEditorStore=Z;exports.useLibraryStore=sm;exports.useTreeStore=ue;
|