@trokky/studio 3.1.0 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{a as n,c as r,d as i,f as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./router-Dpg4KYTB.js";import{t as m}from"./vendor-igJJvL5X.js";import{_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,t as j,u as M,v as N,y as P}from"./query-CieM36kR.js";import{$ as F,A as I,B as L,C as ee,D as R,E as te,F as ne,G as re,H as ie,I as ae,J as z,K as oe,L as se,M as ce,N as le,O as ue,P as de,Q as fe,R as pe,S as me,T as he,U as ge,V as _e,W as ve,X as ye,Y as be,Z as xe,_ as Se,a as Ce,at as we,b as Te,c as Ee,ct as De,d as Oe,dt as ke,et as Ae,f as je,ft as Me,g as Ne,h as Pe,ht as Fe,i as Ie,it as Le,j as Re,k as ze,l as Be,lt as Ve,m as He,mt as Ue,n as We,nt as Ge,o as Ke,ot as qe,p as Je,pt as Ye,q as Xe,r as Ze,rt as Qe,s as $e,st as et,t as tt,tt as nt,u as rt,ut as it,v as at,w as ot,x as st,y as ct,z as lt}from"./ui-D5AGhrb0.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ut=class extends k{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||dt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function dt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ft=class extends v{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new ut({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=pt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){D.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>b(t,e))}findAll(e={}){return this.getAll().filter(t=>b(e,t))}notify(e){D.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return D.batch(()=>Promise.all(e.map(e=>e.continue().catch(T))))}};function pt(e){return e.options.scope?.id}var mt=class extends v{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??y(r,t),a=this.get(i);return a||(a=new E({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){D.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>O(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>O(e,t)):t}notify(e){D.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){D.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){D.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ht=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new mt,this.#t=e.mutationCache||new ft,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=A.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=g.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(x(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=w(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return D.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;D.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return D.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=D.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(T).catch(T)}invalidateQueries(e,t={}){return D.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=D.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(T)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(T)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(x(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(x(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(T).catch(T)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(T).catch(T)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return g.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(M(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{S(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(M(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{S(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=y(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===h&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},gt=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Ct(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},_t={},vt=(e,t,n,r)=>{Ct(n)&&_t[n]||(Ct(n)&&(_t[n]=new Date),gt(e,t,n,r))},yt=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},bt=(e,t,n)=>{e.loadNamespaces(t,yt(e,n))},xt=(e,t,n,r)=>{if(Ct(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return bt(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,yt(e,r))},St=(e,t,n={})=>!t.languages||!t.languages.length?(vt(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Ct=e=>typeof e==`string`,wt=e=>typeof e==`object`&&!!e,Tt=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Et={"&amp;":`&`,"&#38;":`&`,"&lt;":`<`,"&#60;":`<`,"&gt;":`>`,"&#62;":`>`,"&apos;":`'`,"&#39;":`'`,"&quot;":`"`,"&#34;":`"`,"&nbsp;":` `,"&#160;":` `,"&copy;":`©`,"&#169;":`©`,"&reg;":`®`,"&#174;":`®`,"&hellip;":`…`,"&#8230;":`…`,"&#x2F;":`/`,"&#47;":`/`},Dt=e=>Et[e],Ot={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(Tt,Dt)},kt=(e={})=>{Ot={...Ot,...e}},At=()=>Ot,jt,Mt=e=>{jt=e},Nt=()=>jt,Pt={type:`3rdParty`,init(e){kt(e.options.react),Mt(e)}},B=e(a()),Ft=(0,B.createContext)(),It=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},Lt=(e,t)=>{let n=(0,B.useRef)();return(0,B.useEffect)(()=>{n.current=t?n.current:e},[e,t]),n.current},Rt=(e,t,n,r)=>e.getFixedT(t,n,r),zt=(e,t,n,r)=>(0,B.useCallback)(Rt(e,t,n,r),[e,t,n,r]),Bt=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,B.useContext)(Ft)||{},a=n||r||Nt();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new It),!a){vt(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let e=(e,t)=>Ct(t)?t:wt(t)&&Ct(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e,t=[e,{},!1];return t.t=e,t.i18n={},t.ready=!1,t}a.options.react?.wait&&vt(a,`DEPRECATED_OPTION`,`useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.`);let o={...At(),...a.options.react,...t},{useSuspense:s,keyPrefix:c}=o,l=e||i||a.options?.defaultNS;l=Ct(l)?[l]:l||[`translation`],a.reportNamespaces.addUsedNamespaces?.(l);let u=(a.isInitialized||a.initializedStoreOnce)&&l.every(e=>St(e,a,o)),d=zt(a,t.lng||null,o.nsMode===`fallback`?l:l[0],c),f=()=>d,p=()=>Rt(a,t.lng||null,o.nsMode===`fallback`?l:l[0],c),[m,h]=(0,B.useState)(f),g=l.join();t.lng&&(g=`${t.lng}${g}`);let _=Lt(g),v=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let{bindI18n:e,bindI18nStore:n}=o;v.current=!0,!u&&!s&&(t.lng?xt(a,t.lng,l,()=>{v.current&&h(p)}):bt(a,l,()=>{v.current&&h(p)})),u&&_&&_!==g&&v.current&&h(p);let r=()=>{v.current&&h(p)};return e&&a?.on(e,r),n&&a?.store.on(n,r),()=>{v.current=!1,a&&e&&e?.split(` `).forEach(e=>a.off(e,r)),n&&a&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,g]),(0,B.useEffect)(()=>{v.current&&u&&h(f)},[a,c,u]);let y=[m,a,u];if(y.t=m,y.i18n=a,y.ready=u,u||!u&&!s)return y;throw new Promise(e=>{t.lng?xt(a,t.lng,l,()=>e()):bt(a,l,()=>e())})};function Vt({i18n:e,defaultNS:t,children:n}){let r=(0,B.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,B.createElement)(Ft.Provider,{value:r},n)}var Ht=e(i(),1),Ut=e(m(),1),V=_(),Wt=e=>typeof e==`string`,Gt=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},Kt=e=>e==null?``:``+e,qt=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},Jt=/###/g,Yt=e=>e&&e.indexOf(`###`)>-1?e.replace(Jt,`.`):e,Xt=e=>!e||Wt(e),Zt=(e,t,n)=>{let r=Wt(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(Xt(e))return{};let t=Yt(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return Xt(e)?{}:{obj:e,k:Yt(r[i])}},Qt=(e,t,n)=>{let{obj:r,k:i}=Zt(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=Zt(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=Zt(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},$t=(e,t,n,r)=>{let{obj:i,k:a}=Zt(e,t,Object);i[a]=i[a]||[],i[a].push(n)},en=(e,t)=>{let{obj:n,k:r}=Zt(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},tn=(e,t,n)=>{let r=en(e,n);return r===void 0?en(t,n):r},nn=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?Wt(e[r])||e[r]instanceof String||Wt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):nn(e[r],t[r],n):e[r]=t[r]);return e},rn=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),an={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},on=e=>Wt(e)?e.replace(/[&<>"'\/]/g,e=>an[e]):e,sn=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},cn=[` `,`,`,`?`,`!`,`;`],ln=new sn(20),un=(e,t,n)=>{t||=``,n||=``;let r=cn.filter(e=>t.indexOf(e)<0&&n.indexOf(e)<0);if(r.length===0)return!0;let i=ln.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},dn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`.`;if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].indexOf(typeof t)>-1&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},fn=e=>e?.replace(`_`,`-`),pn={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},mn=new class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,t)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=t.prefix||`i18next:`,this.logger=e||pn,this.options=t,this.debug=t.debug}log(){var e=[...arguments];return this.forward(e,`log`,``,!0)}warn(){var e=[...arguments];return this.forward(e,`warn`,``,!0)}error(){var e=[...arguments];return this.forward(e,`error`,``)}deprecate(){var e=[...arguments];return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(Wt(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},hn=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e){var t=[...arguments].slice(1);this.observers[e]&&Array.from(this.observers[e].entries()).forEach(e=>{let[n,r]=e;for(let e=0;e<r;e++)n(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(n=>{let[r,i]=n;for(let n=0;n<i;n++)r.apply(r,[e,...t])})}},gn=class extends hn{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:[`translation`],defaultNS:`translation`};super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.indexOf(`.`)>-1?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):Wt(n)&&i?o.push(...n.split(i)):o.push(n)));let s=en(this.data,o);return!s&&!t&&!n&&e.indexOf(`.`)>-1&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!Wt(n)?s:dn(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(`.`)>-1&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),Qt(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(let r in n)(Wt(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},o=[e,t];e.indexOf(`.`)>-1&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=en(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?nn(s,n,i):s={...s,...n},Qt(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},_n={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},vn={},yn=e=>!Wt(e)&&typeof e!=`boolean`&&typeof e!=`number`,bn=class e extends hn{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),qt([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=mn.create(`translator`)}changeLanguage(e){e&&(this.language=e)}exists(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};return e!=null&&this.resolve(e,t)?.res!==void 0}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!un(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:Wt(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(a[0])>-1)&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:Wt(i)?[i]:i}}translate(t,n,r){if(typeof n!=`object`&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n==`object`&&(n={...n}),n||={},t==null)return``;Array.isArray(t)||(t=[String(t)]);let i=n.returnDetails===void 0?this.options.returnDetails:n.returnDetails,a=n.keySeparator===void 0?this.options.keySeparator:n.keySeparator,{key:o,namespaces:s}=this.extractFromKey(t[t.length-1],n),c=s[s.length-1],l=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l?.toLowerCase()===`cimode`){if(u){let e=n.nsSeparator||this.options.nsSeparator;return i?{res:`${c}${e}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${e}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:o}let d=this.resolve(t,n),f=d?.res,p=d?.usedKey||o,m=d?.exactUsedKey||o,h=[`[object Number]`,`[object Function]`,`[object RegExp]`],g=n.joinArrays===void 0?this.options.joinArrays:n.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject,v=n.count!==void 0&&!Wt(n.count),y=e.hasDefaultValue(n),b=v?this.pluralResolver.getSuffix(l,n.count,n):``,x=n.ordinal&&v?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):``,S=v&&!n.ordinal&&n.count===0,C=S&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${b}`]||n[`defaultValue${x}`]||n.defaultValue,w=f;_&&!f&&y&&(w=C);let T=yn(w),E=Object.prototype.toString.apply(w);if(_&&w&&T&&h.indexOf(E)<0&&!(Wt(g)&&Array.isArray(w))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(p,w,{...n,ns:s}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(d.res=e,d.usedParams=this.getUsedParamsDetails(n),d):e}if(a){let e=Array.isArray(w),t=e?[]:{},r=e?m:p;for(let e in w)if(Object.prototype.hasOwnProperty.call(w,e)){let i=`${r}${a}${e}`;t[e]=y&&!f?this.translate(i,{...n,defaultValue:yn(C)?C[e]:void 0,joinArrays:!1,ns:s}):this.translate(i,{...n,joinArrays:!1,ns:s}),t[e]===i&&(t[e]=w[e])}f=t}}else if(_&&Wt(g)&&Array.isArray(f))f=f.join(g),f&&=this.extendTranslation(f,t,n,r);else{let e=!1,i=!1;!this.isValidLookup(f)&&y&&(e=!0,f=C),this.isValidLookup(f)||(i=!0,f=o);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:f,u=y&&C!==f&&this.options.updateMissing;if(i||e||u){if(this.logger.log(u?`updateKey`:`missingKey`,l,c,o,u?C:f),a){let e=this.resolve(o,{...n,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let i=y&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,u,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,u,n),this.emit(`missingKey`,e,c,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);S&&n[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],o+t,n[`defaultValue${t}`]||C)})}):r(e,o,C))}f=this.extendTranslation(f,t,n,d,r),i&&f===o&&this.options.appendNamespaceToMissingKey&&(f=`${c}:${o}`),(i||e)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${o}`:o,e?f:void 0))}return i?(d.res=f,d.usedParams=this.getUsedParamsDetails(n),d):f}extendTranslation(e,t,n,r,i){var a=this;if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let o=Wt(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),s;if(o){let t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let c=n.replace&&!Wt(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),e=this.interpolator.interpolate(e,c,n.lng||this.language||r.usedLng,n),o){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;s<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,function(){var e=[...arguments];return i?.[0]===e[0]&&!n.context?(a.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):a.translate(...e,t)},n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,s=Wt(o)?[o]:o;return e!=null&&s?.length&&n.applyPostProcessor!==!1&&(e=_n.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n,r,i,a,o;return Wt(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!Wt(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(Wt(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!vn[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(vn[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(o.push(c+e),t.ordinal&&e.indexOf(i)===0&&o.push(c+e.replace(i,this.options.pluralSeparator)),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator}${t.context}`;o.push(r),u&&(o.push(r+e),t.ordinal&&e.indexOf(i)===0&&o.push(r+e.replace(i,this.options.pluralSeparator)),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!Wt(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.substring(0,12)===`defaultValue`&&e[t]!==void 0)return!0;return!1}},xn=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=mn.create(`languageUtils`)}getScriptPartFromCode(e){if(e=fn(e),!e||e.indexOf(`-`)<0)return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=fn(e),!e||e.indexOf(`-`)<0)return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(Wt(e)&&e.indexOf(`-`)>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(e.indexOf(`-`)<0&&n.indexOf(`-`)<0)&&(e.indexOf(`-`)>0&&n.indexOf(`-`)<0&&e.substring(0,e.indexOf(`-`))===n||e.indexOf(n)===0&&n.length>1))return e})}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),Wt(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return Wt(e)&&(e.indexOf(`-`)>-1||e.indexOf(`_`)>-1)?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):Wt(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.indexOf(e)<0&&i(this.formatLanguageCode(e))}),r}},Sn={zero:0,one:1,two:2,few:3,many:4,other:5},Cn={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},wn=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=mn.create(`pluralResolver`),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=fn(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(!Intl)return this.logger.error(`No Intl support, please use an Intl polyfill!`),Cn;if(!e.match(/-|_/))return Cn;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>Sn[e]-Sn[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},Tn=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`.`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=tn(e,t,n);return!a&&i&&Wt(n)&&(a=dn(e,n,r),a===void 0&&(a=dn(t,n,r))),a},En=e=>e.replace(/\$/g,`$$$$`),Dn=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=mn.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?on:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?rn(i):a||`{{`,this.suffix=o?rn(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u||`-`,this.unescapeSuffix=this.unescapePrefix?``:l||``,this.nestingPrefix=d?rn(d):f||rn(`$t(`),this.nestingSuffix=p?rn(p):m||rn(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_!==void 0&&_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(e.indexOf(this.formatSeparator)<0){let i=Tn(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(Tn(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp();let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>En(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?En(this.escape(e)):En(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0){if(typeof l==`function`){let t=l(e,i,r);a=Wt(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``}else!Wt(a)&&!this.useRawValueToEscape&&(a=Kt(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;let r=e.split(RegExp(`${n}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!Wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=!1;if(r[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(r[1])){let e=r[1].split(this.formatSeparator).map(e=>e.trim());r[1]=e.shift(),s=e,c=!0}if(i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!Wt(i))return i;Wt(i)||(i=Kt(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),c&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},On=e=>{let t=e.toLowerCase().trim(),n={};if(e.indexOf(`(`)>-1){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].substring(0,r[1].length-1);t===`currency`&&i.indexOf(`:`)<0?n.currency||=i.trim():t===`relativetime`&&i.indexOf(`:`)<0?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},kn=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(fn(r),i),t[o]=s),s(n)}},An=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=mn.create(`formatter`),this.options=e,this.formats={number:kn((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:kn((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:kn((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:kn((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:kn((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})},this.init(e)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=t.interpolation.formatSeparator||`,`}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=kn(t)}format(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf(`(`)>1&&i[0].indexOf(`)`)<0&&i.find(e=>e.indexOf(`)`)>-1)){let e=i.findIndex(e=>e.indexOf(`)`)>-1);i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:a}=On(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},jn=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},Mn=class extends hn{constructor(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=mn.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{$t(n.loaded,[i],a),jn(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();Wt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Wt(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:``,n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},Nn=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,simplifyPluralSuffix:!0,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),Wt(e[1])&&(t.defaultValue=e[1]),Wt(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0}}),Pn=e=>(Wt(e.ns)&&(e.ns=[e.ns]),Wt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Wt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.(`cimode`)<0&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),typeof e.initImmediate==`boolean`&&(e.initAsync=e.initImmediate),e),Fn=()=>{},In=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Ln=class e extends hn{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Pn(e),this.services={},this.logger=mn,this.modules={external:[]},In(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof t==`function`&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Wt(t.ns)?t.defaultNS=t.ns:t.ns.indexOf(`translation`)<0&&(t.defaultNS=t.ns[0]));let r=Nn();this.options={...r,...this.options,...Pn(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);let i=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?mn.init(i(this.modules.logger),this.options):mn.init(null,this.options);let t;t=this.modules.formatter?this.modules.formatter:An;let n=new xn(this.options);this.store=new gn(this.options.resources,this.options);let a=this.services;a.logger=mn,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new wn(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),t&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(a.formatter=i(t),a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new Dn(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new Mn(i(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on(`*`,function(t){var n=[...arguments].slice(1);e.emit(t,...n)}),this.modules.languageDetector&&(a.languageDetector=i(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=i(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new bn(this.services,this.options),this.translator.on(`*`,function(t){var n=[...arguments].slice(1);e.emit(t,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||=Fn,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(t=>{this[t]=function(){return e.store[t](...arguments)}}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(t=>{this[t]=function(){return e.store[t](...arguments),e}});let a=Gt(),o=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),a.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fn,n=Wt(e)?e:this.language;if(typeof e==`function`&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return t();let e=[],r=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&e.indexOf(t)<0&&e.push(t)})};n?r(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>r(e)),this.options.preload?.forEach?.(e=>r(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,t,n){let r=Gt();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=Fn,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&_n.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!([`cimode`,`dev`].indexOf(e)>-1))for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!([`cimode`,`dev`].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}}changeLanguage(e,t){var n=this;this.isLanguageChangingTo=e;let r=Gt();this.emit(`languageChanging`,e);let i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(e,a)=>{a?(i(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,r.resolve(function(){return n.t(...arguments)}),t&&t(e,function(){return n.t(...arguments)})},o=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=Wt(t)?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||i(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{a(e,n)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,t,n){var r=this;let i=function(e,t){let a;if(typeof t!=`object`){var o=[...arguments].slice(2);a=r.options.overloadTranslationOptionHandler([e,t].concat(o))}else a={...t};a.lng=a.lng||i.lng,a.lngs=a.lngs||i.lngs,a.ns=a.ns||i.ns,a.keyPrefix!==``&&(a.keyPrefix=a.keyPrefix||n||i.keyPrefix);let s=r.options.keySeparator||`.`,c;return c=a.keyPrefix&&Array.isArray(e)?e.map(e=>`${a.keyPrefix}${s}${e}`):a.keyPrefix?`${a.keyPrefix}${s}${e}`:e,r.t(c,a)};return Wt(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}t(){var e=[...arguments];return this.translator?.translate(...e)}exists(){var e=[...arguments];return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=Gt();return this.options.ns?(Wt(e)&&(e=[e]),e.forEach(e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=Gt();Wt(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new xn(Nn());return t.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new e(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fn,r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);return(t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new gn(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),{})),{}),i),a.services.resourceStore=a.store),a.translator=new bn(a.services,i),a.translator.on(`*`,function(e){var t=[...arguments].slice(1);a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Rn=Ln.createInstance();Rn.createInstance=Ln.createInstance,Rn.createInstance,Rn.dir,Rn.init,Rn.loadResources,Rn.reloadResources,Rn.use,Rn.changeLanguage,Rn.getFixedT,Rn.t,Rn.exists,Rn.setDefaultNamespace,Rn.hasLoadedNamespace,Rn.loadNamespaces,Rn.loadLanguages;var{slice:zn,forEach:Bn}=[];function Vn(e){return Bn.call(zn.call(arguments,1),t=>{if(t)for(let n in t)e[n]===void 0&&(e[n]=t[n])}),e}function Hn(e){return typeof e==`string`&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(e))}var Un=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Wn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:`/`},r=`${e}=${encodeURIComponent(t)}`;if(n.maxAge>0){let e=n.maxAge-0;if(Number.isNaN(e))throw Error(`maxAge should be a Number`);r+=`; Max-Age=${Math.floor(e)}`}if(n.domain){if(!Un.test(n.domain))throw TypeError(`option domain is invalid`);r+=`; Domain=${n.domain}`}if(n.path){if(!Un.test(n.path))throw TypeError(`option path is invalid`);r+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!=`function`)throw TypeError(`option expires is invalid`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:r+=`; SameSite=Strict`;break;case`lax`:r+=`; SameSite=Lax`;break;case`strict`:r+=`; SameSite=Strict`;break;case`none`:r+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return n.partitioned&&(r+=`; Partitioned`),r},Gn={create(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:`/`,sameSite:`strict`};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Wn(e,t,i)},read(e){let t=`${e}=`,n=document.cookie.split(`;`);for(let e=0;e<n.length;e++){let r=n[e];for(;r.charAt(0)===` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return r.substring(t.length,r.length)}return null},remove(e,t){this.create(e,``,-1,t)}},Kn={name:`cookie`,lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<`u`)return Gn.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=t;n&&typeof document<`u`&&Gn.create(n,e,r,i,a)}},qn={name:`querystring`,lookup(e){let{lookupQuerystring:t}=e,n;if(typeof window<`u`){let{search:e}=window.location;!window.location.search&&window.location.hash?.indexOf(`?`)>-1&&(e=window.location.hash.substring(window.location.hash.indexOf(`?`)));let r=e.substring(1).split(`&`);for(let e=0;e<r.length;e++){let i=r[e].indexOf(`=`);i>0&&r[e].substring(0,i)===t&&(n=r[e].substring(i+1))}}return n}},Jn={name:`hash`,lookup(e){let{lookupHash:t,lookupFromHashIndex:n}=e,r;if(typeof window<`u`){let{hash:e}=window.location;if(e&&e.length>2){let i=e.substring(1);if(t){let e=i.split(`&`);for(let n=0;n<e.length;n++){let i=e[n].indexOf(`=`);i>0&&e[n].substring(0,i)===t&&(r=e[n].substring(i+1))}}if(r)return r;if(!r&&n>-1){let t=e.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof n==`number`?n:0]?.replace(`/`,``):void 0}}}return r}},Yn=null,Xn=()=>{if(Yn!==null)return Yn;try{if(Yn=typeof window<`u`&&window.localStorage!==null,!Yn)return!1;let e=`i18next.translate.boo`;window.localStorage.setItem(e,`foo`),window.localStorage.removeItem(e)}catch{Yn=!1}return Yn},Zn={name:`localStorage`,lookup(e){let{lookupLocalStorage:t}=e;if(t&&Xn())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:n}=t;n&&Xn()&&window.localStorage.setItem(n,e)}},Qn=null,$n=()=>{if(Qn!==null)return Qn;try{if(Qn=typeof window<`u`&&window.sessionStorage!==null,!Qn)return!1;let e=`i18next.translate.boo`;window.sessionStorage.setItem(e,`foo`),window.sessionStorage.removeItem(e)}catch{Qn=!1}return Qn},er={name:`sessionStorage`,lookup(e){let{lookupSessionStorage:t}=e;if(t&&$n())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:n}=t;n&&$n()&&window.sessionStorage.setItem(n,e)}},tr={name:`navigator`,lookup(e){let t=[];if(typeof navigator<`u`){let{languages:e,userLanguage:n,language:r}=navigator;if(e)for(let n=0;n<e.length;n++)t.push(e[n]);n&&t.push(n),r&&t.push(r)}return t.length>0?t:void 0}},nr={name:`htmlTag`,lookup(e){let{htmlTag:t}=e,n,r=t||(typeof document<`u`?document.documentElement:null);return r&&typeof r.getAttribute==`function`&&(n=r.getAttribute(`lang`)),n}},rr={name:`path`,lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>`u`)return;let n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(Array.isArray(n))return n[typeof t==`number`?t:0]?.replace(`/`,``)}},ir={name:`subdomain`,lookup(e){let{lookupFromSubdomainIndex:t}=e,n=typeof t==`number`?t+1:1,r=typeof window<`u`&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},ar=!1;try{document.cookie,ar=!0}catch{}var or=[`querystring`,`cookie`,`localStorage`,`sessionStorage`,`navigator`,`htmlTag`];ar||or.splice(1,1);var sr=()=>({order:or,lookupQuerystring:`lng`,lookupCookie:`i18next`,lookupLocalStorage:`i18nextLng`,lookupSessionStorage:`i18nextLng`,caches:[`localStorage`],excludeCacheFor:[`cimode`],convertDetectedLanguage:e=>e}),cr=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type=`languageDetector`,this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=Vn(t,this.options||{},sr()),typeof this.options.convertDetectedLanguage==`string`&&this.options.convertDetectedLanguage.indexOf(`15897`)>-1&&(this.options.convertDetectedLanguage=e=>e.replace(`-`,`_`)),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(Kn),this.addDetector(qn),this.addDetector(Zn),this.addDetector(er),this.addDetector(tr),this.addDetector(nr),this.addDetector(rr),this.addDetector(ir),this.addDetector(Jn)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(e=>{if(this.detectors[e]){let n=this.detectors[e].lookup(this.options);n&&typeof n==`string`&&(n=[n]),n&&(t=t.concat(n))}}),t=t.filter(e=>e!=null&&!Hn(e)).map(e=>this.options.convertDetectedLanguage(e)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(t=>{this.detectors[t]&&this.detectors[t].cacheUserLanguage(e,this.options)}))}};cr.type=`languageDetector`;var lr=`common`,ur=[`en`,`fr`],dr={en:`English`,fr:`Français`},fr={en:{common:{app:{loadingStudio:`Loading Studio...`},actions:{save:`Save`,cancel:`Cancel`,delete:`Delete`,edit:`Edit`,create:`Create`,add:`Add`,remove:`Remove`,close:`Close`,confirm:`Confirm`,submit:`Submit`,reset:`Reset`,search:`Search`,filter:`Filter`,clear:`Clear`,copy:`Copy`,download:`Download`,upload:`Upload`,refresh:`Refresh`,back:`Back`,next:`Next`,previous:`Previous`,loading:`Loading...`,saving:`Saving...`,deleting:`Deleting...`,updating:`Updating...`,creating:`Creating...`},status:{active:`Active`,inactive:`Inactive`,enabled:`Enabled`,disabled:`Disabled`,pending:`Pending`,success:`Success`,error:`Error`,warning:`Warning`,info:`Info`,loading:`Loading`,processing:`Processing`},labels:{name:`Name`,email:`Email`,username:`Username`,password:`Password`,description:`Description`,title:`Title`,type:`Type`,status:`Status`,date:`Date`,time:`Time`,created:`Created`,updated:`Updated`,actions:`Actions`,options:`Options`,settings:`Settings`,details:`Details`,none:`None`,all:`All`,select:`Select`,optional:`Optional`,required:`Required`},messages:{confirmDelete:`Are you sure you want to delete this item? This action cannot be undone.`,unsavedChanges:`You have unsaved changes. Are you sure you want to leave?`,noResults:`No results found`,noData:`No data available`,loadError:`Failed to load data`,saveSuccess:`Changes saved successfully`,saveError:`Failed to save changes`,deleteSuccess:`Item deleted successfully`,deleteError:`Failed to delete item`,networkError:`Network error. Please check your connection.`,sessionExpired:`Your session has expired. Please sign in again.`},time:{now:`Just now`,minutesAgo:`{{count}} minute ago`,minutesAgo_plural:`{{count}} minutes ago`,hoursAgo:`{{count}} hour ago`,hoursAgo_plural:`{{count}} hours ago`,daysAgo:`{{count}} day ago`,daysAgo_plural:`{{count}} days ago`,never:`Never`},pagination:{page:`Page`,of:`of`,items:`items`,showing:`Showing`,to:`to`,perPage:`per page`}},studio:{contentView:{filters:`Filters`,sort:`Sort`,clearAll:`Clear all`,selectedOfTotal:`{{selected}} of {{total}} selected`,selectedOfTotal_one:`{{selected}} of {{total}} selected`,selectedOfTotal_other:`{{selected}} of {{total}} selected`,itemsCount:`{{count}} items`,sortAsc:`{{label}} (A-Z)`,sortDesc:`{{label}} (Z-A)`,filterBy:`Filter by {{label}}`,allLabel:`All {{label}}`,all:`All`,yes:`Yes`,no:`No`},changeStatus:{title:`Change Status`,selectStatus:`Select the new status for {{count}} selected document`,selectStatus_plural:`Select the new status for {{count}} selected documents`,draft:`Draft`,draftDesc:`Save as draft`,published:`Published`,publishedDesc:`Make documents publicly available`,archived:`Archived`,archivedDesc:`Archive documents`,updating:`Updating...`,updateDocument:`Update {{count}} document`,updateDocument_plural:`Update {{count}} documents`},pagination:{showing:`Showing {{start}} to {{end}} of {{total}} results`,show:`Show:`,firstPage:`First page`,previousPage:`Previous page`,nextPage:`Next page`,lastPage:`Last page`},contentViews:{loadingDocuments:`Loading documents...`,noDocumentsFound:`No documents found`,edit:`Edit`,copyId:`Copy ID`,duplicate:`Duplicate`,delete:`Delete`,deleteConfirm:`Are you sure you want to delete this document? This action cannot be undone.`,deleteConfirmShort:`Are you sure you want to delete this document?`,deleteTitle:`Delete Document`,confirmDelete:`Delete`,actions:`Actions`,columns:`Columns`,showHideColumns:`Show/Hide Columns`,itemsCount:`{{count}} items`,yes:`Yes`,no:`No`,empty:`Empty`,noItemsInColumn:`No items in {{column}}`,addItem:`Add item`},mediaBrowser:{title:`Browse Media`,selectFile:`Select a file from your media library`,selectImage:`Select an image from your media library`,selectVideo:`Select a video from your media library`,selectAudio:`Select an audio from your media library`,selectDocument:`Select a document from your media library`,close:`Close`,searchPlaceholder:`Search media...`,backToGrid:`Back to Grid`,noPreviewAvailable:`Preview not available for this file type`,noPreviewUrl:`No preview URL available`,imageVariants:`Image Variants`,noVariantsAvailable:`No variants available for this image.`,regenerate:`Regenerate`,original:`Original`,fileDetails:`File Details`,filename:`Filename`,size:`Size`,type:`Type`,dimensions:`Dimensions`,selectVariant:`Select {{variant}}`,selectOriginal:`Select Original`,variant:`Variant`,select:`Select`,noMediaFound:`No media files found`,noMediaFoundMatching:`No media files found matching your search`,noTypeFound:`No {{type}} files found`,noTypeFoundMatching:`No {{type}} files found matching your search`,clearSearch:`Clear search`,paginationOf:`{{start}}-{{end}} of {{total}}`,prev:`Prev`,next:`Next`},nav:{content:`Content`,media:`Media`,settings:`Settings`,users:`Users`,auditLogs:`Audit Logs`,dashboard:`Dashboard`,search:`Search...`,searchPlaceholder:`Search...`},header:{create:`Create`,createNewDocument:`Create New Document`,noDocumentTypes:`No document types available for creation`,studioConfiguration:`Studio configuration`,manageUsersPermissions:`Manage users & permissions`,viewAllChanges:`View all content changes`,preferences:`Preferences`,changePassword:`Change Password`,signOut:`Sign out`,user:`User`,noEmail:`No email`},theme:{light:`Light`,dark:`Dark`,system:`System`,toggle:`Toggle theme`},usersPage:{title:`Users & Access`,subtitle:`Manage users, permissions, API tokens, and webhooks`,accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access user management features. Contact your administrator for access.`,tabs:{users:`Users`,tokens:`API Tokens`,webhooks:`Webhooks`}},userManagement:{title:`User Management`,subtitle:`Manage user accounts, roles, and permissions`,addUser:`Add User`,editUser:`Edit User`,createUser:`Create User`,searchPlaceholder:`Search users...`,tableHeaders:{user:`User`,role:`Role`,status:`Status`,lastLogin:`Last Login`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`},mfa:`MFA`,mfaEnabled:`MFA Enabled`,custom:`Custom`,customPermissionsTooltip:`Custom permissions - differs from role defaults`,never:`Never`,editUserTitle:`Edit user`,resetMfaTitle:`Reset MFA`,deleteUserTitle:`Delete user`,deleteConfirm:`Are you sure you want to delete user "{{username}}"? This action cannot be undone.`,resetMfaConfirm:`Are you sure you want to reset MFA for "{{username}}"? They will need to set up MFA again.`,failedResetMfa:`Failed to reset MFA. Please try again.`,modal:{editTitle:`Edit User`,createTitle:`Create User`,basicInfo:`Basic Information`,username:`Username`,email:`Email`,fullName:`Full Name`,newPassword:`New Password (optional)`,password:`Password`,generatePassword:`Generate`,role:`Role`,accessPermissions:`Access & Permissions`,reset:`Reset`,activeAccount:`Active user account`,studioAccess:`Studio Access`,customPermissions:`Custom permissions`,loadingSchemaPermissions:`Loading schema permissions...`,failedLoadSchemaPermissions:`Failed to load schema permissions: {{error}}`,allContentEnabled:`(All Content Operations enabled)`,coveredByAllContent:`(Covered by All Content Operations)`,customSchemaPermissions:`Custom Schema Permissions`,customPermissionPlaceholder:`e.g., custom:read, external:write, special:*`,addPermission:`Add`,customPermissionsLabel:`Custom permissions:`,permissionFormatHelp:`Format: schema:action (e.g., custom:read, external:write, special:*). Schema permissions are auto-generated above.`,permissionValidationError:`Permission must be in format "schema:action" (e.g., "articles:read", "products:write", "events:*")`,cancel:`Cancel`,updating:`Updating...`,creating:`Creating...`,updateUser:`Update User`,failedSave:`Failed to save user. Please try again.`},roles:{admin:`Administrator`,adminDesc:`Full access to all features`,editor:`Editor`,editorDesc:`Create, edit, and publish content`,writer:`Writer`,writerDesc:`Create and edit content, cannot publish`,author:`Author`,authorDesc:`Create and edit own content`,viewer:`Viewer`,viewerDesc:`Read-only access to content`},permissions:{allContent:`All Content Operations`,viewAllContent:`View All Content`,editAllContent:`Edit All Content`,deleteAllContent:`Delete All Content`,publishAllContent:`Publish All Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`,viewUsers:`View Users`,editUsers:`Edit Users`,deleteUsers:`Delete Users`,inviteUsers:`Invite Users`,viewSettings:`View Settings`,editSettings:`Edit Settings`,studioAccess:`Studio Access`,viewTokens:`View API Tokens`,createTokens:`Create API Tokens`,deleteTokens:`Delete API Tokens`,viewWebhooks:`View Webhooks`,createEditWebhooks:`Create/Edit Webhooks`,deleteWebhooks:`Delete Webhooks`,testWebhooks:`Test Webhooks`}},appTokens:{title:`API Tokens`,subtitle:`Create and manage API tokens for external applications`,createToken:`Create Token`,searchPlaceholder:`Search tokens...`,noTokensTitle:`No API tokens yet`,noTokensDesc:`Create your first API token to enable external access to your content.`,tableHeaders:{token:`Token`,status:`Status`,lastUsed:`Last Used`,expires:`Expires`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`,expired:`Expired`},never:`Never`,modal:{title:`Create API Token`,tokenName:`Token Name`,tokenNamePlaceholder:`e.g., Production API, Mobile App`,description:`Description`,descriptionPlaceholder:`What will this token be used for?`,expiration:`Expiration`,expiration30days:`30 days`,expiration90days:`90 days (recommended)`,expiration1year:`1 year`,expirationNever:`Never expires`,expirationCustom:`Custom date`,permissions:`Permissions`,cancel:`Cancel`,creating:`Creating...`,createToken:`Create Token`},tokenCreated:{title:`API Token Created`,warning:`This is the only time you'll see this token. Copy it now and store it securely.`,yourToken:`Your API Token`,copied:`Copied!`,close:`Close`},deleteConfirm:`Are you sure you want to delete the token "{{name}}"? This action cannot be undone.`,permissions:{viewContent:`View Content`,editContent:`Edit Content`,deleteContent:`Delete Content`,publishContent:`Publish Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`}},webhooks:{title:`Webhooks`,subtitle:`Receive real-time notifications when events occur`,createWebhook:`Create Webhook`,searchPlaceholder:`Search webhooks...`,noWebhooksTitle:`No webhooks configured`,noWebhooksDesc:`Create your first webhook to receive real-time notifications when events occur.`,tableHeaders:{webhook:`Webhook`,status:`Status`,events:`Events`,lastUpdated:`Last Updated`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`},eventsCount:`{{count}} event`,eventsCount_plural:`{{count}} events`,moreEvents:`+{{count}} more`,testWebhook:`Test webhook`,viewDeliveryHistory:`View delivery history`,editWebhook:`Edit webhook`,deleteWebhook:`Delete webhook`,deleteConfirm:`Are you sure you want to delete the webhook "{{name}}"? This action cannot be undone.`,modal:{editTitle:`Edit Webhook`,createTitle:`Create Webhook`,name:`Webhook Name`,namePlaceholder:`e.g., Content Sync, Slack Notifications`,url:`Endpoint URL`,urlPlaceholder:`https://api.example.com/webhooks/trokky`,events:`Events to Subscribe To`,secret:`Secret Key`,secretPlaceholder:`Leave empty to auto-generate`,secretDescription:`Used to verify webhook authenticity via HMAC signatures`,headers:`Custom Headers`,headerNamePlaceholder:`Header name`,headerValuePlaceholder:`Header value`,maxRetries:`Max Retries`,backoffStrategy:`Backoff Strategy`,linear:`Linear`,exponential:`Exponential`,active:`Active (webhook will receive events)`,updating:`Updating...`,creating:`Creating...`,update:`Update Webhook`,create:`Create Webhook`},deliveryModal:{title:`Delivery History: {{name}}`,noDeliveries:`No deliveries yet`,status:`Status`,response:`Response`,timestamp:`Time`,attempt:`Attempt`,success:`Success`,failed:`Failed`},events:{allDocuments:`All Document Events`,documentCreated:`Document Created`,documentUpdated:`Document Updated`,documentDeleted:`Document Deleted`,documentPublished:`Document Published`,documentUnpublished:`Document Unpublished`,allMedia:`All Media Events`,mediaUploaded:`Media Uploaded`,mediaUpdated:`Media Updated`,mediaDeleted:`Media Deleted`,allUsers:`All User Events`,userCreated:`User Created`,userUpdated:`User Updated`,userLogin:`User Login`,allSystem:`All System Events`,systemStartup:`System Startup`,systemError:`System Error`}},changePassword:{title:`Change Password`,currentPassword:`Current Password`,newPassword:`New Password`,confirmPassword:`Confirm New Password`,passwordHint:`At least 8 characters`,cancel:`Cancel`,changing:`Changing...`,changePassword:`Change Password`,success:`Password changed successfully!`,errors:{currentRequired:`Current password is required`,newRequired:`New password is required`,minLength:`New password must be at least 8 characters`,mismatch:`Passwords do not match`,sameAsOld:`New password must be different from current password`}},oauth:{accountLinked:`Account linked successfully`,unlinkSuccess:`{{provider}} account unlinked successfully`,unlinkFailed:`Failed to unlink account`,notConnected:`Not connected`,linked:`Linked {{date}}`,unlink:`Unlink`,comingSoon:`Coming Soon`,google:{signIn:`Sign in with Google`,linkAccount:`Link Google Account`,initFailed:`Failed to initialize Google login`}},mfa:{title:`Two-Factor Authentication`,subtitle:`Add an extra layer of security to your account`,enabled:`MFA Enabled`,notEnabled:`MFA Not Enabled`,authenticatorApp:`Authenticator App`,authenticatorAppDesc:`Use an app like Google Authenticator or Authy`,emailVerification:`Email Verification`,emailVerificationDesc:`Receive verification codes via email`,emailCode:`Email Code`,backupCode:`Backup Code`,backupCodes:`Backup Codes`,backupCodesRemaining:`{{count}} codes remaining`,totpDescription:`Enter the 6-digit code from your authenticator app`,emailDescriptionPending:`A code will be sent to your email`,emailDescriptionSent:`Enter the code sent to your email`,backupDescription:`Enter one of your backup codes (format: XXXX-XXXX)`,enterCode:`Please enter the verification code`,trustDevice:`Trust this device for 30 days`,trustedDevices:`Trusted Devices`,trustedDevicesCount:`{{count}} device trusted`,trustedDevicesCount_plural:`{{count}} devices trusted`,verifying:`Verifying...`,verify:`Verify`,sendingCode:`Sending...`,resendCode:`Didn't receive the code? Resend`,setUp:`Set Up`,disableMethod:`Disable`,manage:`Manage`,hide:`Hide`,regenerate:`Regenerate`,revokeAll:`Revoke All`,cancel:`Cancel`,next:`Next`,done:`Done`,copyAll:`Copy All`,copiedToClipboard:`Copied to clipboard`,setup:{authenticator:`Set Up Authenticator App`,scanQrCode:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`,orEnterManually:`Or enter this code manually:`,verifyAuthenticatorCode:`Verify Authenticator Code`,enterCodeToVerify:`Enter the 6-digit code from your authenticator app to verify setup.`,verifyEmailCode:`Verify Email Code`,enterEmailCode:`Enter the code sent to your email address.`,saveBackupCodes:`Save Your Backup Codes`,backupCodesImportant:`Save these backup codes in a secure place. You can use them to access your account if you lose your authenticator device.`,newBackupCodes:`Your New Backup Codes`,newBackupCodesImportant:`Save these backup codes in a secure place. Your previous codes are now invalid. You can use these codes to access your account if you lose your authenticator device.`},disable:{authenticator:`Disable Authenticator App`,email:`Disable Email Verification`,enterPassword:`Enter your password to disable this MFA method.`,all:`Disable All MFA`,allDesc:`This will remove all MFA methods and backup codes from your account`,allWarning:`This will completely disable two-factor authentication on your account. All MFA methods (authenticator app, email) and backup codes will be removed.`,confirmPassword:`Enter your password to confirm.`},regenerateBackupCodes:{title:`Regenerate Backup Codes`,description:`This will invalidate all your existing backup codes. Enter your password to confirm.`},trustedDevice:{trusted:`Trusted: {{date}}`,confirmRevokeAll:`Are you sure you want to revoke trust from all devices?`},toast:{loadFailed:`Failed to load MFA status`,totpInitFailed:`Failed to initialize TOTP setup`,totpEnabled:`Authenticator app enabled successfully!`,emailCodeSent:`Verification code sent to your email`,emailSendFailed:`Failed to send verification code`,emailEnabled:`Email verification enabled successfully!`,authenticatorDisabled:`Authenticator app disabled`,emailDisabled:`Email verification disabled`,allDisabled:`All MFA has been disabled`,backupCodesRegenerated:`Backup codes regenerated. Save them securely!`,deviceRevoked:`Device trust revoked`,deviceRevokeFailed:`Failed to revoke device trust`,allDevicesRevoked:`All device trusts revoked`,allDevicesRevokeFailed:`Failed to revoke device trusts`},errors:{passwordRequired:`Password is required`}},passkey:{signIn:`Sign in with Passkey`,optionsFailed:`Failed to start passkey authentication`,cancelled:`Authentication was cancelled`,notSupported:`Passkeys are not supported in this browser`,authFailed:`Passkey authentication failed`,verifyFailed:`Passkey verification failed`,unexpectedResponse:`Unexpected response from server`,manager:{title:`Passkeys`,description:`Sign in securely without a password using your fingerprint, face, or security key.`,loadFailed:`Failed to load passkeys`,renameFailed:`Failed to rename passkey`,deleteFailed:`Failed to delete passkey`,notConfigured:`Passkey authentication is not enabled`,notConfiguredDescription:`Passkey authentication needs to be configured by an administrator in the server settings.`,noPasskeys:`You haven't set up any passkeys yet.`,unnamed:`Passkey`,added:`Added`,lastUsed:`Last used`,synced:`Synced across devices`,deviceOnly:`This device only`},register:{addPasskey:`Add Passkey`,optionsFailed:`Failed to start passkey registration`,cancelled:`Registration was cancelled`,alreadyRegistered:`This passkey is already registered`,notSupported:`Passkeys are not supported in this browser`,failed:`Passkey registration failed`,verifyFailed:`Passkey registration verification failed`,namePlaceholder:`e.g., MacBook Pro Touch ID`,continue:`Continue`}},captcha:{loading:`Loading CAPTCHA...`,errors:{hcaptchaNotSupported:`hCaptcha is not yet supported`,providerNotSupported:`Provider "{{provider}}" is not supported`,scriptLoadFailed:`Failed to load CAPTCHA script`,renderFailed:`Failed to render CAPTCHA widget`,notAvailable:`{{provider}} not available`}},sessionTimeout:{title:`Session Expiring Soon`,expireIn:`Your session will expire in {{time}}.`,continueWorking:`Continue working to stay logged in.`,extendSession:`Extend Session`,dismiss:`Dismiss`,close:`Close`,expired:`Session expired`},users:{title:`User Management`,subtitle:`Manage user accounts, roles, and permissions`,addUser:`Add User`,editUser:`Edit User`,createUser:`Create User`,deleteUser:`Delete User`,searchPlaceholder:`Search users...`,table:{user:`User`,role:`Role`,status:`Status`,lastLogin:`Last Login`,actions:`Actions`},roles:{admin:`Administrator`,adminDescription:`Full access to all features`,editor:`Editor`,editorDescription:`Create, edit, and publish content`,author:`Author`,authorDescription:`Create and edit own content`,viewer:`Viewer`,viewerDescription:`Read-only access to content`},form:{basicInfo:`Basic Information`,accessPermissions:`Access & Permissions`,username:`Username`,email:`Email`,fullName:`Full Name`,password:`Password`,newPasswordOptional:`New Password (optional)`,role:`Role`,activeAccount:`Active user account`,studioAccess:`Studio Access`,customPermissions:`Custom permissions`,customSchemaPermissions:`Custom Schema Permissions`,permissionFormat:`Format: schema:action (e.g., custom:read, external:write, special:*). Schema permissions are auto-generated above.`,generate:`Generate`},permissions:{title:`Permissions`,reset:`Reset`,loading:`Loading schema permissions...`,loadError:`Failed to load schema permissions: {{error}}`,allContentOps:`All Content Operations`,viewContent:`View All Content`,editContent:`Edit All Content`,deleteContent:`Delete All Content`,publishContent:`Publish All Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`,viewUsers:`View Users`,editUsers:`Edit Users`,deleteUsers:`Delete Users`,inviteUsers:`Invite Users`,viewSettings:`View Settings`,editSettings:`Edit Settings`,studioAccess:`Studio Access`,viewTokens:`View API Tokens`,createTokens:`Create API Tokens`,deleteTokens:`Delete API Tokens`,viewWebhooks:`View Webhooks`,editWebhooks:`Create/Edit Webhooks`,deleteWebhooks:`Delete Webhooks`,testWebhooks:`Test Webhooks`,groups:{content:`Content`,media:`Media`,users:`Users`,settings:`Settings`,access:`Access`,tokens:`Tokens`,webhooks:`Webhooks`},allContentEnabled:`(All Content Operations enabled)`,coveredByAllContent:`(Covered by All Content Operations)`},confirmDelete:`Are you sure you want to delete user "{{username}}"? This action cannot be undone.`,confirmResetMFA:`Are you sure you want to reset MFA for "{{username}}"? They will need to set up MFA again.`,resetMFA:`Reset MFA`,mfaEnabled:`MFA Enabled`,custom:`Custom`},media:{title:`Media Library`,subtitle:`Upload and manage your media files`,upload:`Upload`,uploadFiles:`Upload Files`,dragAndDrop:`Drag and drop files here`,or:`or`,browseFiles:`Browse files`,noMedia:`No media files`,delete:`Delete`,download:`Download`,copyUrl:`Copy URL`,details:`Details`,filename:`Filename`,filesize:`File size`,dimensions:`Dimensions`,uploadedAt:`Uploaded at`,mimeType:`MIME type`,types:{all:`All Files`,images:`Images`,videos:`Videos`,audio:`Audio`,documents:`Documents`,archives:`Archives`},accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access the media library. Contact your administrator for access.`,searchPlaceholder:`Search media...`,view:{grid:`Grid View`,list:`List View`},filters:`Filters`,clearFilters:`Clear filters`,selected:`{{count}} selected`,deleteSelected:`Delete Selected`,confirmBulkDelete:`Are you sure you want to delete {{count}} file(s)? This action cannot be undone.`,confirmDelete:`Are you sure you want to delete this file? This action cannot be undone.`,editMetadata:`Edit Metadata`,preview:`Preview`,noResults:`No media files found`,uploadSuccess:`File uploaded successfully`,uploadError:`Failed to upload file`,deleteSuccess:`File deleted successfully`,deleteError:`Failed to delete file`,perPage:`per page`,sort:{dateDesc:`Newest first`,dateAsc:`Oldest first`,nameAsc:`Name A-Z`,nameDesc:`Name Z-A`,sizeDesc:`Largest first`,sizeAsc:`Smallest first`}},content:{title:`Content`,subtitle:`Manage all your content types and documents`,loading:`Loading content types...`,loadingDocuments:`Loading documents...`,loadingSingleton:`Loading singleton document...`,error:{loadingTypes:`Error loading content types`,loadingDocuments:`Error loading documents`,documentNotFound:`Document Not Found`},noTypes:`No content types found`,noTypesDescription:`Content types will appear here once your backend is configured with schemas.`,viewDocuments:`View Documents`,refresh:`Refresh`,tryAgain:`Try Again`,backToContent:`Back to Content`,manageDocuments:`Manage your documents`,viewExisting:`View existing documents`,create:`Create {{type}}`,deleteDocument:`Delete Document`,confirmDelete:`Are you sure you want to delete this document? This action cannot be undone.`,confirmBulkDelete:`Are you sure you want to delete {{count}} document(s)? This action cannot be undone.`,deleteAll:`Delete All`,changeStatus:`Change Status`,redirecting:`Redirecting...`,search:`Search {{type}}...`,views:{list:`List View`,grid:`Grid View`,table:`Table View`},filters:{status:`Status`,draft:`Draft`,published:`Published`,archived:`Archived`},sort:{title:`Title`,createdDate:`Created Date`,updatedDate:`Updated Date`},bulkActions:{changeStatus:`Change Status`,delete:`Delete`}},documents:{title:`Documents`,createNew:`Create New`,noDocuments:`No documents found`,untitled:`Untitled`,modified:`Modified`,created:`Created`,publish:`Publish`,unpublish:`Unpublish`,duplicate:`Duplicate`,delete:`Delete`,confirmDelete:`Are you sure you want to delete this document?`,saveChanges:`Save Changes`,discardChanges:`Discard Changes`,unsavedChanges:`You have unsaved changes`},settings:{title:`Settings`,subtitle:`Configure your Trokky Studio and content management`,loading:`Loading settings...`,general:`General`,generalSettings:`General Settings`,branding:`Branding`,security:`Security`,securitySettings:`Security Settings`,api:`API`,webhooks:`Webhooks`,tokens:`API Tokens`,accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access Studio settings. Contact your administrator for access.`,readOnlyMessage:`You have read-only access to settings. Contact your administrator to make changes.`,studioTitle:`Studio Title`,studioTitleDescription:`The title displayed in the Studio interface`,organizationName:`Organization Name`,organizationNameDescription:`Organization or company name displayed on the login page`,primaryColor:`Primary Brand Color`,primaryColorDescription:`Primary color for buttons, links, and accents`,secondaryColor:`Secondary Brand Color`,secondaryColorDescription:`Secondary color for subtle elements and backgrounds`,logoUrl:`Logo URL`,logoUrlDescription:`URL to your organization logo (displayed on login page)`,logoPreview:`Preview:`,publicUrl:`Public Website URL`,publicUrlDescription:`The public URL where your content will be displayed. Used for "View Live" links.`,defaultTheme:`Default Theme`,defaultThemeDescription:`Choose the default theme for new users`,mfa:{title:`Multi-Factor Authentication (MFA) Enforcement`,requireAll:`Require MFA for all users`,requireRoles:`Or require MFA for specific roles:`,allowedMethods:`Allowed MFA Methods`,allowedMethodsDescription:`Select which MFA methods users can choose from:`,totp:`Authenticator App (TOTP) - Recommended`,email:`Email OTP - Send one-time code to email`,atLeastOne:`At least one method must be enabled.`,roleDisabledNote:`Role-based selection is disabled when MFA is required for all users.`,enforcementNote:`When MFA is enforced, users without MFA set up will be prompted to configure it on their next login. They will receive a 15-minute setup window to complete the configuration.`},saveChanges:`Save Changes`,saving:`Saving...`,saveSuccess:`Settings saved successfully!`,saveError:`Failed to save settings: {{error}}`,loadError:`Failed to load settings. Using defaults.`},auditLogs:{title:`Audit Logs`,subtitle:`Complete history of all content changes in the CMS`,action:`Action`,user:`User`,resource:`Resource`,timestamp:`Timestamp`,details:`Details`,noLogs:`No audit logs found`,loading:`Loading audit logs...`,refresh:`Refresh`,search:`Search`,searchPlaceholder:`Search by document title, ID, or collection...`,filters:`Filters`,clearFilters:`Clear all filters`,collection:`Collection`,allCollections:`All collections`,allUsers:`All users`,operation:`Operation`,allOperations:`All operations`,showingResults:`Showing {{start}}-{{end}} of {{total}} entries`,noResults:`No entries found`,page:`Page {{current}} of {{total}}`,previous:`Previous`,next:`Next`,tryAgain:`Try again`,operations:{create:`Created`,update:`Updated`,delete:`Deleted`,publish:`Published`,unpublish:`Unpublished`,restore:`Restored`},technical:{revision:`Revision:`,documentId:`Document ID:`,ip:`IP:`,actorType:`Actor type:`},hideDetails:`Hide details`,showDetails:`Show details`,changedField:`Changed {{field}}`,changedFields:`Changed {{count}} fields`},dashboard:{welcome:`Welcome to Trokky Studio`,subtitle:`Content management made simple`,recentActivity:`Recent Activity`,quickActions:`Quick Actions`,quickStart:`Quick Start`,createFirstDocument:`Create Your First Document`,uploadMedia:`Upload Media`,studioSettings:`Studio Settings`,userPreferences:`User Preferences`,cards:{content:{title:`Content`,description:`Create and manage your content`},media:{title:`Media`,description:`Upload and organize media files`},users:{title:`Users`,description:`Manage users and permissions`}},stats:{loading:`Loading stats...`,contentOverview:`Content Overview`,totalContent:`Total Content`,singletons:`Singletons`,mediaFiles:`Media Files`,content:`Content`,thisWeek:`this week`,documents:`Documents`,media:`Media Files`,users:`Users`},activity:{title:`Recent Activity`,refresh:`Refresh activity`,loading:`Loading recent activity...`,unknownTime:`Unknown time`,tryAgain:`Try again`,noActivity:`No recent activity`,noActivityDescription:`Activity will appear here as content is created and edited`,failedToLoad:`Failed to load recent activity`,operations:{created:`created`,updated:`updated`,deleted:`deleted`,published:`published`,unpublished:`unpublished`,restored:`restored`},changedField:`Changed {{field}}`,changedFields:`Changed {{fields}}`,changedFieldsCount:`Changed {{count}} fields`,by:`by`}},language:{title:`Language`,select:`Select language`,current:`Current language`},sidebar:{navigation:`Navigation`,expand:`Expand sidebar`,collapse:`Collapse sidebar`,searchNavigation:`Search navigation...`,loadingNavigation:`Loading navigation...`,failedToLoad:`Failed to load navigation`,noResultsFor:`No results found for "{{query}}"`,clearSearch:`Clear search`},layout:{globalSearch:`Global Search`,searchPlaceholder:`Search functionality will be implemented here.`,expandContext:`Expand context sidebar`,collapseContext:`Collapse context sidebar`,resizeSidebar:`Drag to resize sidebar`},contextSidebar:{quickActions:`Quick Actions`,createContent:`Create Content`,createContentDesc:`Start with a new document`,uploadMedia:`Upload Media`,uploadMediaDesc:`Add images and files`,recentActivity:`Recent Activity`,noRecentActivity:`No recent activity`,contentTypes:`Content Types`,noContentTypes:`No content types available`,mediaLibrary:`Media Library`,mediaLibraryDesc:`Upload and manage your media files`,userOverview:`User Overview`,totalUsers:`Total Users`,active:`Active`,roles:`Roles`,usersLoggedInWeek:`{{count}} user logged in this week`,usersLoggedInWeek_plural:`{{count}} users logged in this week`,usersNeverLoggedIn:`{{count}} user never logged in`,usersNeverLoggedIn_plural:`{{count}} users never logged in`,inactiveUsers:`{{count}} inactive user`,inactiveUsers_plural:`{{count}} inactive users`,addNewUser:`Add New User`,manageApiTokens:`Manage API Tokens`,studioSettings:`Studio Settings`,configureStudio:`Configure your studio`,fieldsRegistry:`Fields Registry`,totalFields:`Total Fields`,initialized:`Initialized`,yes:`Yes`,no:`No`,availableTypes:`Available Types`,documentation:`Documentation`,docSelectFields:`Select fields from the sidebar to test different types`,docEditPreview:`Use the Edit/Preview tabs to see both modes`,docUseExamples:`Click example "Use" buttons to try different values`,docShowErrors:`Toggle "Show Errors" to test validation`,defaultContextInfo:`Context information will appear here based on the current page.`,widgets:{unknownType:`Unknown widget type: {{type}}`,recentDocuments:{defaultTitle:`Recent {{schema}}`,defaultTitleFallback:`Recent Documents`,noSchemaType:`No schema type specified`,failedToLoad:`Failed to load recent documents`,untitled:`Untitled`,noDocuments:`No recent documents`,by:`by`},stats:{total:`Total`,published:`Published`,calculating:`Calculating...`,notAvailable:`N/A`},category:{uncategorized:`Uncategorized`},recentlyEdited:{untitled:`Untitled`,by:`by`,author:`Author`}}},preferences:{title:`Preferences`,subtitle:`Customize your Studio experience`,appearance:`Appearance`,theme:`Theme`,themeSystem:`System Default`,themeLight:`Light`,themeDark:`Dark`,notifications:`Notifications`,emailNotifications:`Email Notifications`,emailNotificationsDescription:`Receive notifications via email`,pushNotifications:`Push Notifications`,pushNotificationsDescription:`Receive browser push notifications`,connectedAccounts:`Connected Accounts`,connectedAccountsDescription:`Link external accounts for easier sign-in`,security:`Security`,securityDescription:`Manage two-factor authentication and security settings`,passkeys:`Passkeys`,passkeysDescription:`Sign in securely without a password using your fingerprint, face, or security key.`,savePreferences:`Save Preferences`,saveSuccess:`Preferences saved successfully`,saveError:`Failed to update preferences`},notFound:{title:`Page not found`,message:`The page you're looking for doesn't exist or has been moved.`,goToDashboard:`Go to Dashboard`},auth:{forgotPassword:{title:`Forgot password?`,subtitle:`Enter your email address and we'll send you a link to reset your password.`,sendResetLink:`Send Reset Link`,sending:`Sending...`,backToSignIn:`Back to Sign In`,checkEmail:`Check your email`,emailSentMessage:`If an account exists for <strong>{{email}}</strong>, you will receive a password reset link shortly.`,linkExpires:`The link will expire in 1 hour.`,captchaRequired:`Please complete the CAPTCHA verification`,sendError:`Failed to send reset email`},resetPassword:{title:`Reset Password`,subtitle:`Enter your new password below.`,newPassword:`New password`,confirmPassword:`Confirm new password`,resetButton:`Reset Password`,resetting:`Resetting Password...`,verifying:`Verifying reset link...`,success:`Password Reset Successful`,successMessage:`Your password has been successfully reset. You can now sign in with your new password.`,signIn:`Sign In`,invalidLink:`Invalid Reset Link`,invalidLinkMessage:`This password reset link is invalid or has expired.`,linkExpireNote:`Reset links expire after 1 hour. Please request a new one.`,requestNewLink:`Request New Link`,noToken:`No reset token provided`,tokenInvalid:`Invalid or expired reset token`,tokenVerifyError:`Failed to verify reset token`,passwordMinLength:`Password must be at least 8 characters long`,passwordMismatch:`Passwords do not match`,captchaRequired:`Please complete the CAPTCHA verification`,resetError:`Failed to reset password`,linkExpiresIn:`Link expires in {{minutes}} minute`,linkExpiresIn_plural:`Link expires in {{minutes}} minutes`,strength:`Strength`,strengthTooShort:`Too short`,strengthWeak:`Weak`,strengthMedium:`Medium`,strengthGood:`Good`,strengthStrong:`Strong`,requirements:`Password must:`,requireLength:`Be at least 8 characters long`,requireUppercase:`Contain an uppercase letter (recommended)`,requireNumber:`Contain a number (recommended)`},oauth:{processing:`Processing...`,completingAuth:`Completing authentication with Google`,success:`Success!`,loginSuccess:`Login successful! Redirecting...`,mfaRequired:`MFA verification required. Redirecting...`,mfaSetupRequired:`MFA setup required. Redirecting...`,accountLinked:`Google account linked successfully`,failed:`Authentication Failed`,returnToLogin:`Return to Login`,invalidResponse:`Invalid response from server`},device:{pageTitle:`Trokky CLI Login`,loading:`Loading device information...`,authorizeDevice:`Authorize Device`,requestingAccess:`is requesting access to your account`,deviceCode:`Device Code`,allowApplication:`This will allow the application to:`,deny:`Deny`,authorize:`Authorize`,authorized:`Device Authorized`,authorizedMessage:`You can now close this window and return to the CLI.`,closeWindow:`Close Window`,denied:`Authorization Denied`,deniedMessage:`The device was not authorized. You can close this window.`,expired:`Code Expired`,expiredMessage:`The device code has expired. Please try again from the CLI.`,error:`Error`,noCode:`No device code provided`,fetchError:`Failed to fetch device information`,connectError:`Failed to connect to the server`,authError:`Authorization failed`,denyError:`Failed to deny authorization`,returnToStudio:`Return to Studio`,scopes:{openid:`Access your identity`,profile:`Access your profile information`,contentRead:`Read content`,contentWrite:`Create and update content`,contentDelete:`Delete content`,mediaRead:`Read media files`,mediaWrite:`Upload media files`,offlineAccess:`Stay logged in`}},authorize:{pageTitle:`Trokky`,validating:`Validating authorization request...`,authorizeApp:`Authorize Application`,wantsAccess:`wants to access your account`,allowApplication:`This will allow the application to:`,visitWebsite:`Visit application website`,deny:`Deny`,authorize:`Authorize`,consentNote:`By authorizing, you allow this application to access your data according to the permissions listed above.`,redirecting:`Redirecting...`,redirectingMessage:`You are being redirected back to the application.`,error:`Authorization Error`,missingParams:`Missing required authorization parameters`,invalidRequest:`Invalid authorization request`,validateError:`Failed to validate authorization request`,authFailed:`Authorization failed`,denyFailed:`Failed to deny authorization`,returnToStudio:`Return to Studio`}},documentEditor:{loadingSchema:`Loading schema...`,loadingDocument:`Loading document...`,backToDocuments:`Back to Documents`,schemaRequired:`Schema name is required`,documentPreview:`Document Preview`,newDocument:`New {{type}}`,backTo:`Back to {{type}}`,confirmStateChange:`Are you sure you want to change from {{from}} to {{to}}?`,edit:`Edit`,preview:`Preview`,readOnly:`Read Only`,readOnlyMode:`Read only mode`,unsavedChanges:`Unsaved changes`,validationErrors:`Validation errors`,discardChangesConfirm:`You have unsaved changes. Are you sure you want to cancel?`,discardChangesTitle:`Unsaved Changes`,discardChanges:`Discard Changes`,keepEditing:`Keep Editing`,documentInfo:`Document Info`,loadingForm:`Loading form...`,noFieldsDefined:`No fields defined in schema`,created:`Created`,lastUpdated:`Last Updated`,status:`Status`,published:`Published`,draft:`Draft`,publishedOn:`Published {{date}}`,tags:`Tags`,contributors:`Contributors`,contributorsLoading:`Loading...`,contributorsMore:`+{{count}} more`,references:`References`,referencesCount:`References ({{count}})`,referencesMore:`+{{count}}`,noReferences:`No references`,schema:`Schema`,fieldsCount:`{{count}} fields`,dangerZone:`Danger Zone`,deleteDocument:`Delete Document`,deleteConfirm:`Are you sure you want to delete "{{title}}"? This action cannot be undone.`,deleteTitle:`Delete Document`,cannotBeUndone:`This action cannot be undone.`,expandSidebar:`Expand sidebar`,collapseSidebar:`Collapse sidebar`},documentHistory:{title:`Document History`,refreshHistory:`Refresh history`,loading:`Loading...`,loadError:`Failed to load document history`,notAvailable:`Document history is not available`,noHistory:`No history yet`,moreChanges:`+{{count}} more changes`},changesDiff:{noVisibleChanges:`No visible changes`,changesCount:`Changes ({{count}})`,showSystemFields:`Show system fields`,hideSystemFields:`Hide system fields`,before:`Before:`,after:`After:`},auditEntry:{created:`Created`,updated:`Updated`,deleted:`Deleted`,published:`Published`,unpublished:`Unpublished`,restored:`Restored`,by:`by`,latest:`Latest`,changedField:`Changed {{field}}`,changedFieldsJoin:`Changed {{fields}}`,changedFieldsCount:`Changed {{count}} fields`,hideDetails:`Hide details`,showDetails:`Show details`,revision:`Revision:`,ipAddress:`IP Address:`,userAgent:`User Agent:`},common:{title:`Title`,cancel:`Cancel`,dismiss:`Dismiss`,note:`Important:`,save:`Save`,delete:`Delete`,selectAll:`Select all`,deselectAll:`Deselect all`,edit:`Edit`,create:`Create`,add:`Add`,remove:`Remove`,generate:`Generate`,close:`Close`,confirm:`Confirm`,loading:`Loading...`,error:`Error`,success:`Success`,warning:`Warning`,info:`Info`,yes:`Yes`,no:`No`,ok:`OK`,retry:`Retry`,back:`Back`,next:`Next`,previous:`Previous`,submit:`Submit`,reset:`Reset`,clear:`Clear`,tryAgain:`Try again`,refreshPage:`Refresh page`,copyErrorDetails:`Copy Error Details`,copied:`Copied!`,closeNotification:`Close notification`,notifications:`Notifications`},errorBoundary:{title:`Something went wrong`,subtitle:`The application encountered an unexpected error`,description:`Please try refreshing the page or contact support if the problem persists. You can copy the error details below to help with troubleshooting.`,errorMessage:`Error Message:`,stackTrace:`Stack Trace`,componentStack:`Component Stack`,environmentDetails:`Environment Details`,noStackTrace:`No stack trace available`,noComponentStack:`No component stack available`,url:`URL:`,timestamp:`Timestamp:`,userAgent:`User Agent:`,viewport:`Viewport:`},toast:{closeNotification:`Close notification`,notifications:`Notifications`},confirmDialog:{defaultConfirm:`Confirm`,defaultCancel:`Cancel`},search:{placeholder:`Search documents, media...`,clearSearch:`Clear search`,closeSearch:`Close search`,searching:`Searching...`,recentSearches:`Recent searches`,clear:`Clear`,clearHistory:`Clear search history`,foundResults:`Found {{count}} result`,foundResults_plural:`Found {{count}} results`,document:`Document`,media:`Media`,by:`by`,noResults:`No results found`,tryDifferent:`Try different search terms`,typeToSearch:`Type to search documents and media`,pressEscape:`Press Escape to close`,poweredBy:`Powered by Trokky`},permissionsDebug:{title:`Permissions Debug`,copyToClipboard:`Copy debug info to clipboard`,currentUser:`Current User`,username:`Username:`,email:`Email:`,role:`Role:`,admin:`Admin:`,notLoggedIn:`Not logged in`,notAvailable:`N/A`,guest:`guest`,yes:`Yes`,no:`No`,documentPermissions:`Document Permissions`,type:`Type:`,id:`ID:`,newDocument:`New Document`,canCreate:`Can Create`,canUpdate:`Can Update`,canDelete:`Can Delete`,canRead:`Can Read`,allowed:`Allowed`,denied:`Denied`,fieldStates:`Field States ({{count}})`,hideDetails:`Hide Details`,showDetails:`Show Details`,disabled:`Disabled`,readonly:`Readonly`,required:`Required`,hasError:`Has Error`,value:`Value:`,debugModeDev:`Debug mode is ON (dev)`,debugModeManual:`Debug mode is ON (manual)`,disableInProduction:`Disable in Production`,enableInProduction:`Enable in Production`}},fields:{types:JSON.parse(`{"string":{"label":"Text","placeholder":"Enter text...","description":"Single line text field","noValue":"No value","selection":"Selection"},"text":{"label":"Text Area","placeholder":"Enter text...","description":"Multi-line text field","words":"words","lines":"lines"},"number":{"label":"Number","placeholder":"Enter number","placeholderInteger":"Enter whole number","placeholderCurrency":"0.00","placeholderPercentage":"0.00%","description":"Numeric value field","noValue":"No value","increaseValue":"Increase value","decreaseValue":"Decrease value"},"boolean":{"label":"Boolean","description":"True/false toggle field","yes":"Yes","no":"No","toggle":"Toggle"},"date":{"label":"Date","placeholder":"Select date...","description":"Date picker field","noDateSet":"No date set","clearDate":"Clear date","dateOnly":"Date","dateAndTime":"Date & Time"},"datetime":{"label":"Date & Time","placeholder":"Select date and time...","description":"Date and time picker field"},"image":{"label":"Image","placeholder":"Select or upload an image","description":"Image upload field","selectImage":"Select Image","changeImage":"Change Image","removeImage":"Remove Image"},"file":{"label":"File","placeholder":"Select or upload a file","description":"File upload field","selectFile":"Select File","changeFile":"Change File","removeFile":"Remove File"},"reference":{"label":"Reference","placeholder":"Select reference...","description":"Reference to another document","noResults":"No results found","noResultsFor":"No results found for \\"{{query}}\\"","tryDifferentTerm":"Try a different search term","noDocumentsAvailable":"No documents available","createDocumentsFirst":"Create documents first to reference them here","loading":"Loading...","loadingTypes":"Loading document types...","searching":"Searching...","filterDocuments":"Filter documents...","allTypes":"All types","anyType":"Any type","available":"{{count}} available","references":"{{count}} reference","references_plural":"{{count}} references","ofMax":"of {{max}} max","removeReference":"Remove reference","dragToReorder":"Drag to reorder","close":"Close","clear":"Clear"},"array":{"label":"Array","description":"List of items","addItem":"Add item","addFirstItem":"Add first item","removeItem":"Remove item","moveUp":"Move Up","moveDown":"Move Down","empty":"No items added yet","items":"items","item":"item","itemCount":"{{count}} item","itemCount_plural":"{{count}} items","missingDefinition":"Array field missing 'of' definition","unknownType":"Unknown field type: {{type}}","availableTypes":"Available types: {{types}}","noOptionsConfigured":"No options configured for select layout","noMatchingOptions":"No matching options","holdCtrlToSelect":"Hold Ctrl/Cmd to select multiple","removeTag":"Remove tag \\"{{tag}}\\"?","addTag":"Add tag...","typeToSearch":"Type to search or add custom tags","selectFromOptions":"Select from available options","add":"Add","minimum":"Minimum {{count}} item","minimum_plural":"Minimum {{count}} items","maximum":"Maximum {{count}} item","maximum_plural":"Maximum {{count}} items","range":"{{min}} - {{max}} items"},"object":{"label":"Object","description":"Nested fields group","fields":"fields","field":"field","otherFields":"Other Fields","invalidConfig":"Invalid field configuration: expected object field","fieldNotRegistered":"Field type '{{type}}' is not registered. Please ensure the field plugin is loaded."},"select":{"label":"Select","placeholder":"Select an option...","description":"Dropdown selection field","noOptions":"No options available"},"richtext":{"label":"Rich Text","placeholder":"Start typing...","description":"Rich text editor field","noContent":"No content","loadingEditor":"Loading editor...","invalidConfig":"Invalid field configuration: expected richtext field","toolbar":{"bold":"Bold","italic":"Italic","underline":"Underline","strikethrough":"Strikethrough","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","quote":"Quote","addLink":"Add Link","insertImage":"Insert Image","bulletList":"Bullet List","numberedList":"Numbered List","insertTable":"Insert Table","codeBlock":"Code Block","undo":"Undo","redo":"Redo","viewEditSource":"View/Edit Source Code","fullscreen":"Fullscreen","exitFullscreen":"Exit Fullscreen"},"stats":{"words":"words","characters":"characters","minRead":"min read","exceedsLimit":"Exceeds character limit"},"imageToolbar":{"title":"Image Options:","variant":"Variant:","original":"Original","delete":"Delete","deleteTitle":"Delete Image"},"tableToolbar":{"title":"Table Options:","row":"Row","col":"Col","header":"Header","merge":"Merge","split":"Split","table":"Table","addRowAfter":"Add Row After","deleteRow":"Delete Row","addColumnAfter":"Add Column After","deleteColumn":"Delete Column","toggleHeaderRow":"Toggle Header Row","mergeSelectedCells":"Merge Selected Cells","splitCell":"Split Cell","deleteTable":"Delete Table"},"linkDialog":{"title":"Add Link","linkText":"Link Text","linkTextPlaceholder":"Enter link text","url":"URL","urlPlaceholder":"https://example.com","cancel":"Cancel","addLink":"Add Link","removeLink":"Remove Link"},"source":{"placeholder":"Edit HTML source code..."},"sanitization":{"warning":"Content was sanitized for security: {{warnings}}","dismissWarning":"Dismiss warning"}},"portableText":{"label":"Portable Text","placeholder":"Type something...","description":"Block content editor","noContent":"No content","emptyBlock":"Empty block","blocks":"Blocks:","characters":"Characters:","words":"Words:","blocksCount":"{{current}}/{{max}} blocks","charactersCount":"{{current}}/{{max}} characters","normal":"Normal","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","quote":"Quote","quotePlaceholder":"Quote...","bold":"Bold (⌘B)","italic":"Italic (⌘I)","underline":"Underline (⌘U)","strikethrough":"Strikethrough","code":"Code","addLink":"Add link","hideStats":"Hide stats","showStats":"Show stats","exitFullscreen":"Exit fullscreen","fullscreen":"Fullscreen","dragToReorder":"Drag to reorder (or use Alt+↑/↓)","deleteBlock":"Delete block","addBlock":"+ Add block","checkRequirements":"Please check the content requirements","linkDialog":{"title":"Add Link","url":"URL","textOptional":"Text (optional)","textPlaceholder":"Link text","cancel":"Cancel","add":"Add Link"},"deleteConfirm":"Are you sure you want to delete this block?","deleteConfirmWithText":"Are you sure you want to delete this block?\\n\\n\\"{{text}}\\"","deleteEmptyConfirm":"Are you sure you want to delete this empty block?"},"slug":{"label":"Slug","placeholder":"my-awesome-slug","description":"URL-friendly identifier","generate":"Generate","edit":"Edit","regenerate":"Regenerate slug from source field","editSlug":"Edit slug","unique":"unique","noSlugSet":"No slug set","autoGeneratedFrom":"Auto-generated from: {{source}}","manuallyEdited":"manually edited","slugTaken":"This slug is already taken. Please choose a different one.","checkingUniqueness":"Checking uniqueness...","slugIsUnique":"Slug is unique","slugExists":"Slug already exists","couldNotCheck":"Could not check uniqueness"},"email":{"label":"Email","placeholder":"email@example.com","description":"Email address field","enterEmail":"Enter email address"},"url":{"label":"URL","placeholder":"https://example.com","description":"Web address field"},"color":{"label":"Color","placeholder":"#000000","description":"Color picker field","openPicker":"Open color picker","pickFromScreen":"Pick color from screen","quickColors":"Quick Colors","selectColor":"Select {{color}}"},"geoCoordinate":{"label":"Geo Coordinate","description":"Geographic coordinate field","manual":"Manual","map":"Map","latitude":"Latitude","longitude":"Longitude","useCurrentLocation":"Use current location","altitude":"Altitude (meters)","accuracy":"Accuracy (meters)","interactiveMap":"Interactive Map","comingSoon":"(Coming soon)"},"info":{"label":"Info","description":"Informational display field","expand":"Expand","collapse":"Collapse"},"password":{"label":"Password","description":"Password input field","placeholder":"Enter password","generatePassword":"Generate password","showPassword":"Show password","hidePassword":"Hide password","passwordStrength":"Password strength:","strength":{"noPassword":"No password","veryWeak":"Very Weak","weak":"Weak","fair":"Fair","good":"Good","strong":"Strong"}},"icon":{"label":"Icon","description":"Icon picker field","selectIcon":"Select Icon","searchIcons":"Search icons...","style":"Style:","category":"Category:","allCategories":"All categories","iconCount":"{{count}} icons","noIconsFound":"No icons found","tryDifferentSearch":"Try a different search term or category","previous":"Previous","next":"Next","pageOf":"Page {{page}} of {{total}}","noLibrariesAvailable":"No icon libraries available","noIconSelected":"No icon selected","change":"Change","select":"Select","clearIcon":"Clear icon"},"media":{"label":"Media","description":"Media upload field","selectMedia":"Select media","clickToUploadOrBrowse":"Click to upload or browse","addMedia":"Add media","addImage":"Add image","addVideo":"Add video","addAudio":"Add audio","addDocument":"Add document","addArchive":"Add archive","dropFilesOrClick":"Drop files here or click to upload","clickToUpload":"Click to upload","maxSize":"Max size: {{size}}","selectFileToUpload":"Select a file to upload","allowed":"Allowed: {{types}}","upload":"Upload","browse":"Browse","cancel":"Cancel","change":"Change","remove":"Remove","uploading":"Uploading...","uploadFailed":"Upload failed. Please try again.","mediaAssetNotFound":"Media asset no longer exists","failedToLoadAsset":"Failed to load media asset","removeBrokenReference":"Remove broken media reference","changeMedia":"Change media","removeMedia":"Remove media","mediaDetails":"Media Details","altText":"Alt text","altTextPlaceholder":"Describe this image for accessibility","caption":"Caption","captionPlaceholder":"Add a caption","titleOverride":"Title override","titleOverridePlaceholder":"Override the asset title for this usage","mediaTypes":{"image":"Image","video":"Video","audio":"Audio","document":"Document","archive":"Archive","media":"Media"},"unknownSize":"Unknown size"}}`),validation:{required:`This field is required`,minLength:`Must be at least {{min}} characters`,maxLength:`Must be no more than {{max}} characters`,min:`Must be at least {{min}}`,max:`Must be no more than {{max}}`,pattern:`Invalid format`,email:`Must be a valid email address`,url:`Must be a valid URL`,unique:`This value must be unique`,invalidType:`Invalid value type`,invalidDate:`Invalid date`,invalidNumber:`Must be a valid number`,invalidInteger:`Must be a whole number`,positive:`Must be a positive number`,negative:`Must be a negative number`,fileSize:`File size must be less than {{max}}`,fileType:`Invalid file type`,imageSize:`Image dimensions must be {{width}}x{{height}} or smaller`},richtext:{bold:`Bold`,italic:`Italic`,underline:`Underline`,strikethrough:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,paragraph:`Paragraph`,bulletList:`Bullet List`,numberedList:`Numbered List`,blockquote:`Blockquote`,codeBlock:`Code Block`,link:`Link`,image:`Image`,table:`Table`,undo:`Undo`,redo:`Redo`,clear:`Clear Formatting`},noValue:`No value`,errors:{invalidFieldConfig:`Invalid field configuration: expected {{type}} field`,definitionMissing:`Error: Field definition is missing`},autoFields:{_thumbnail:{title:`Featured Image`,description:`Main image representing this content`},slug:{title:`URL`,description:`URL-friendly identifier for this content`}},common:{validating:`Validating...`},modal:{close:`Close`,done:`Done`,noFieldsDefined:`No fields defined`}},auth:{login:{title:`Sign In`,subtitle:`Welcome back`,emailOrUsername:`Email or username`,password:`Password`,rememberMe:`Stay signed in`,forgotPassword:`Forgot password?`,signIn:`Sign In`,signingIn:`Signing in...`,orContinueWith:`or continue with`,backToLogin:`Back to login`},logout:{title:`Sign Out`,confirm:`Are you sure you want to sign out?`,success:`You have been signed out`},forgotPassword:{title:`Forgot Password`,subtitle:`Enter your email to receive a reset link`,email:`Email address`,sendLink:`Send Reset Link`,sending:`Sending...`,success:`If an account exists with that email, you will receive a reset link shortly.`,backToLogin:`Back to login`},resetPassword:{title:`Reset Password`,subtitle:`Enter your new password`,newPassword:`New Password`,confirmPassword:`Confirm Password`,reset:`Reset Password`,resetting:`Resetting...`,success:`Your password has been reset successfully`,invalidToken:`Invalid or expired reset token`,passwordMismatch:`Passwords do not match`},changePassword:{title:`Change Password`,currentPassword:`Current Password`,newPassword:`New Password`,confirmPassword:`Confirm New Password`,change:`Change Password`,changing:`Changing...`,success:`Password changed successfully!`,minLength:`At least 8 characters`,errors:{currentRequired:`Current password is required`,newRequired:`New password is required`,minLength:`New password must be at least 8 characters`,mismatch:`Passwords do not match`,samePassword:`New password must be different from current password`,failed:`Failed to change password`}},mfa:{title:`Two-Factor Authentication`,required:`Two-Factor Authentication Required`,setupRequired:`Your organization requires MFA. Please set up two-factor authentication to continue.`,chooseMethod:`Choose your preferred authentication method:`,authenticatorApp:`Authenticator App`,authenticatorAppDesc:`Use Google Authenticator, Authy, etc.`,emailCode:`Email Code`,emailCodeDesc:`Receive a code via email`,scanQR:`Scan this QR code with your authenticator app:`,manualEntry:`Or enter this code manually:`,enterCode:`Enter the 6-digit code from your app:`,enterEmailCode:`Enter the 6-digit code:`,emailSent:`We've sent a verification code to your email address.`,verify:`Verify`,verifying:`Verifying...`,verifyComplete:`Verify & Complete Setup`,chooseDifferent:`Choose different method`,invalidCode:`Invalid verification code`,codeExpired:`Code has expired`,backupCodes:{title:`Save Your Backup Codes`,description:`These codes can be used to access your account if you lose your authenticator. Each code can only be used once.`,copy:`Copy Codes`,warning:`Important: Store these codes in a safe place. You won't be able to see them again after this page.`,continue:`I've Saved My Codes - Continue to Dashboard`}},oauth:{google:`Continue with Google`,signInWith:`Sign in with {{provider}}`},session:{expired:`Your session has expired. Please sign in again.`,invalid:`Invalid session. Please sign in again.`},errors:{invalidCredentials:`Invalid email or password`,accountLocked:`Account has been locked. Please contact support.`,accountDisabled:`Account has been disabled`,tooManyAttempts:`Too many failed attempts. Please try again later.`,networkError:`Network error. Please check your connection.`,serverError:`Server error. Please try again later.`,captchaRequired:`Please complete the CAPTCHA verification`,unauthorized:`You are not authorized to perform this action`},advanced:{title:`Advanced`,backendUrl:`Backend URL`,customEndpoint:`Custom backend API endpoint`}},errors:{codes:{DOCUMENT_NOT_FOUND:`Document not found`,SCHEMA_NOT_FOUND:`Schema not found`,VALIDATION_FAILED:`Validation failed`,UNAUTHORIZED:`You are not authorized to perform this action`,FORBIDDEN:`Access denied`,NOT_FOUND:`Resource not found`,CONFLICT:`A conflict occurred`,INTERNAL_ERROR:`An internal error occurred`,NETWORK_ERROR:`Network error. Please check your connection.`,TIMEOUT:`Request timed out. Please try again.`,RATE_LIMITED:`Too many requests. Please slow down.`,INVALID_INPUT:`Invalid input provided`,DUPLICATE_ENTRY:`This entry already exists`,FILE_TOO_LARGE:`File size exceeds the maximum allowed`,INVALID_FILE_TYPE:`This file type is not allowed`,UPLOAD_FAILED:`Failed to upload file`,DELETE_FAILED:`Failed to delete item`,UPDATE_FAILED:`Failed to update item`,CREATE_FAILED:`Failed to create item`,SESSION_EXPIRED:`Your session has expired. Please sign in again.`,INVALID_TOKEN:`Invalid or expired token`,MFA_REQUIRED:`Multi-factor authentication required`,MFA_INVALID:`Invalid or expired MFA token`,MFA_CODE_INVALID:`Invalid verification code`,PASSWORD_TOO_WEAK:`Password does not meet security requirements`,USER_NOT_FOUND:`User not found`,USER_ALREADY_EXISTS:`A user with this email already exists`,EMAIL_NOT_VERIFIED:`Email address not verified`,PERMISSION_DENIED:`You do not have permission to perform this action`,MEDIA_NOT_FOUND:`Media file not found`,WEBHOOK_DELIVERY_FAILED:`Failed to deliver webhook`},generic:{title:`Error`,unknown:`An unexpected error occurred`,tryAgain:`Please try again`,contactSupport:`If the problem persists, please contact support`,goBack:`Go Back`,refresh:`Refresh Page`},form:{invalidField:`{{field}} is invalid`,requiredField:`{{field}} is required`,fieldTooLong:`{{field}} is too long`,fieldTooShort:`{{field}} is too short`},api:{fetchError:`Failed to fetch data`,saveError:`Failed to save data`,deleteError:`Failed to delete data`,connectionError:`Unable to connect to the server`}}},fr:{common:{app:{loadingStudio:`Chargement du Studio...`},actions:{save:`Enregistrer`,cancel:`Annuler`,delete:`Supprimer`,edit:`Modifier`,create:`Créer`,add:`Ajouter`,remove:`Retirer`,close:`Fermer`,confirm:`Confirmer`,submit:`Soumettre`,reset:`Réinitialiser`,search:`Rechercher`,filter:`Filtrer`,clear:`Effacer`,copy:`Copier`,download:`Télécharger`,upload:`Importer`,refresh:`Actualiser`,back:`Retour`,next:`Suivant`,previous:`Précédent`,loading:`Chargement...`,saving:`Enregistrement...`,deleting:`Suppression...`,updating:`Mise à jour...`,creating:`Création...`},status:{active:`Actif`,inactive:`Inactif`,enabled:`Activé`,disabled:`Désactivé`,pending:`En attente`,success:`Succès`,error:`Erreur`,warning:`Avertissement`,info:`Information`,loading:`Chargement`,processing:`Traitement`},labels:{name:`Nom`,email:`E-mail`,username:`Nom d'utilisateur`,password:`Mot de passe`,description:`Description`,title:`Titre`,type:`Type`,status:`Statut`,date:`Date`,time:`Heure`,created:`Créé`,updated:`Mis à jour`,actions:`Actions`,options:`Options`,settings:`Paramètres`,details:`Détails`,none:`Aucun`,all:`Tous`,select:`Sélectionner`,optional:`Facultatif`,required:`Obligatoire`},messages:{confirmDelete:`Êtes-vous sûr de vouloir supprimer cet élément ? Cette action est irréversible.`,unsavedChanges:`Vous avez des modifications non enregistrées. Êtes-vous sûr de vouloir quitter ?`,noResults:`Aucun résultat trouvé`,noData:`Aucune donnée disponible`,loadError:`Échec du chargement des données`,saveSuccess:`Modifications enregistrées avec succès`,saveError:`Échec de l'enregistrement des modifications`,deleteSuccess:`Élément supprimé avec succès`,deleteError:`Échec de la suppression de l'élément`,networkError:`Erreur réseau. Veuillez vérifier votre connexion.`,sessionExpired:`Votre session a expiré. Veuillez vous reconnecter.`},time:{now:`À l'instant`,minutesAgo:`Il y a {{count}} minute`,minutesAgo_plural:`Il y a {{count}} minutes`,hoursAgo:`Il y a {{count}} heure`,hoursAgo_plural:`Il y a {{count}} heures`,daysAgo:`Il y a {{count}} jour`,daysAgo_plural:`Il y a {{count}} jours`,never:`Jamais`},pagination:{page:`Page`,of:`sur`,items:`éléments`,showing:`Affichage de`,to:`à`,perPage:`par page`}},studio:{contentView:{filters:`Filtres`,sort:`Trier`,clearAll:`Tout effacer`,selectedOfTotal:`{{selected}} sur {{total}} sélectionnés`,selectedOfTotal_one:`{{selected}} sur {{total}} sélectionné`,selectedOfTotal_other:`{{selected}} sur {{total}} sélectionnés`,itemsCount:`{{count}} éléments`,sortAsc:`{{label}} (A-Z)`,sortDesc:`{{label}} (Z-A)`,filterBy:`Filtrer par {{label}}`,allLabel:`Tous les {{label}}`,all:`Tous`,yes:`Oui`,no:`Non`},changeStatus:{title:`Changer le statut`,selectStatus:`Sélectionnez le nouveau statut pour {{count}} document sélectionné`,selectStatus_plural:`Sélectionnez le nouveau statut pour {{count}} documents sélectionnés`,draft:`Brouillon`,draftDesc:`Enregistrer comme brouillon`,published:`Publié`,publishedDesc:`Rendre les documents publiquement disponibles`,archived:`Archivé`,archivedDesc:`Archiver les documents`,updating:`Mise à jour...`,updateDocument:`Mettre à jour {{count}} document`,updateDocument_plural:`Mettre à jour {{count}} documents`},pagination:{showing:`Affichage de {{start}} à {{end}} sur {{total}} résultats`,show:`Afficher :`,firstPage:`Première page`,previousPage:`Page précédente`,nextPage:`Page suivante`,lastPage:`Dernière page`},contentViews:{loadingDocuments:`Chargement des documents...`,noDocumentsFound:`Aucun document trouvé`,edit:`Modifier`,copyId:`Copier l'ID`,duplicate:`Dupliquer`,delete:`Supprimer`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer ce document ? Cette action est irréversible.`,deleteConfirmShort:`Êtes-vous sûr de vouloir supprimer ce document ?`,deleteTitle:`Supprimer le document`,confirmDelete:`Supprimer`,actions:`Actions`,columns:`Colonnes`,showHideColumns:`Afficher/Masquer les colonnes`,itemsCount:`{{count}} éléments`,yes:`Oui`,no:`Non`,empty:`Vide`,noItemsInColumn:`Aucun élément dans {{column}}`,addItem:`Ajouter un élément`},mediaBrowser:{title:`Parcourir les médias`,selectFile:`Sélectionnez un fichier de votre bibliothèque de médias`,selectImage:`Sélectionnez une image de votre bibliothèque de médias`,selectVideo:`Sélectionnez une vidéo de votre bibliothèque de médias`,selectAudio:`Sélectionnez un audio de votre bibliothèque de médias`,selectDocument:`Sélectionnez un document de votre bibliothèque de médias`,close:`Fermer`,searchPlaceholder:`Rechercher des médias...`,backToGrid:`Retour à la grille`,noPreviewAvailable:`Aperçu non disponible pour ce type de fichier`,noPreviewUrl:`Aucune URL d'aperçu disponible`,imageVariants:`Variantes d'image`,noVariantsAvailable:`Aucune variante disponible pour cette image.`,regenerate:`Régénérer`,original:`Original`,fileDetails:`Détails du fichier`,filename:`Nom du fichier`,size:`Taille`,type:`Type`,dimensions:`Dimensions`,selectVariant:`Sélectionner {{variant}}`,selectOriginal:`Sélectionner l'original`,variant:`Variante`,select:`Sélectionner`,noMediaFound:`Aucun fichier média trouvé`,noMediaFoundMatching:`Aucun fichier média correspondant à votre recherche`,noTypeFound:`Aucun fichier {{type}} trouvé`,noTypeFoundMatching:`Aucun fichier {{type}} correspondant à votre recherche`,clearSearch:`Effacer la recherche`,paginationOf:`{{start}}-{{end}} sur {{total}}`,prev:`Préc`,next:`Suiv`},nav:{content:`Contenu`,media:`Médias`,settings:`Paramètres`,users:`Utilisateurs`,auditLogs:`Journaux d'audit`,dashboard:`Tableau de bord`,search:`Rechercher...`,searchPlaceholder:`Rechercher...`},header:{create:`Créer`,createNewDocument:`Créer un nouveau document`,noDocumentTypes:`Aucun type de document disponible pour la création`,studioConfiguration:`Configuration du studio`,manageUsersPermissions:`Gérer les utilisateurs et les permissions`,viewAllChanges:`Voir toutes les modifications`,preferences:`Préférences`,changePassword:`Changer le mot de passe`,signOut:`Se déconnecter`,user:`Utilisateur`,noEmail:`Pas d'e-mail`},theme:{light:`Clair`,dark:`Sombre`,system:`Système`,toggle:`Changer le thème`},usersPage:{title:`Utilisateurs & Accès`,subtitle:`Gérer les utilisateurs, permissions, jetons API et webhooks`,accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder aux fonctionnalités de gestion des utilisateurs. Contactez votre administrateur pour obtenir l'accès.`,tabs:{users:`Utilisateurs`,tokens:`Jetons API`,webhooks:`Webhooks`}},userManagement:{title:`Gestion des utilisateurs`,subtitle:`Gérer les comptes utilisateurs, les rôles et les permissions`,addUser:`Ajouter un utilisateur`,editUser:`Modifier l'utilisateur`,createUser:`Créer un utilisateur`,searchPlaceholder:`Rechercher des utilisateurs...`,tableHeaders:{user:`Utilisateur`,role:`Rôle`,status:`Statut`,lastLogin:`Dernière connexion`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`},mfa:`MFA`,mfaEnabled:`MFA activé`,custom:`Personnalisé`,customPermissionsTooltip:`Permissions personnalisées - diffère des valeurs par défaut du rôle`,never:`Jamais`,editUserTitle:`Modifier l'utilisateur`,resetMfaTitle:`Réinitialiser MFA`,deleteUserTitle:`Supprimer l'utilisateur`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer l'utilisateur "{{username}}" ? Cette action est irréversible.`,resetMfaConfirm:`Êtes-vous sûr de vouloir réinitialiser MFA pour "{{username}}" ? L'utilisateur devra reconfigurer MFA.`,failedResetMfa:`Échec de la réinitialisation MFA. Veuillez réessayer.`,modal:{editTitle:`Modifier l'utilisateur`,createTitle:`Créer un utilisateur`,basicInfo:`Informations de base`,username:`Nom d'utilisateur`,email:`E-mail`,fullName:`Nom complet`,newPassword:`Nouveau mot de passe (optionnel)`,password:`Mot de passe`,generatePassword:`Générer`,role:`Rôle`,accessPermissions:`Accès et permissions`,reset:`Réinitialiser`,activeAccount:`Compte utilisateur actif`,studioAccess:`Accès au Studio`,customPermissions:`Permissions personnalisées`,loadingSchemaPermissions:`Chargement des permissions de schéma...`,failedLoadSchemaPermissions:`Échec du chargement des permissions de schéma : {{error}}`,allContentEnabled:`(Toutes les opérations de contenu activées)`,coveredByAllContent:`(Couvert par Toutes les opérations de contenu)`,customSchemaPermissions:`Permissions de schéma personnalisées`,customPermissionPlaceholder:`ex. : custom:read, external:write, special:*`,addPermission:`Ajouter`,customPermissionsLabel:`Permissions personnalisées :`,permissionFormatHelp:`Format : schema:action (ex. : custom:read, external:write, special:*). Les permissions de schéma sont générées automatiquement ci-dessus.`,permissionValidationError:`La permission doit être au format "schema:action" (ex. : "articles:read", "products:write", "events:*")`,cancel:`Annuler`,updating:`Mise à jour...`,creating:`Création...`,updateUser:`Mettre à jour l'utilisateur`,failedSave:`Échec de l'enregistrement. Veuillez réessayer.`},roles:{admin:`Administrateur`,adminDesc:`Accès complet à toutes les fonctionnalités`,editor:`Éditeur`,editorDesc:`Créer, modifier et publier du contenu`,writer:`Rédacteur`,writerDesc:`Créer et modifier du contenu, sans publication`,author:`Auteur`,authorDesc:`Créer et modifier son propre contenu`,viewer:`Lecteur`,viewerDesc:`Accès en lecture seule au contenu`},permissions:{allContent:`Toutes les opérations de contenu`,viewAllContent:`Voir tout le contenu`,editAllContent:`Modifier tout le contenu`,deleteAllContent:`Supprimer tout le contenu`,publishAllContent:`Publier tout le contenu`,viewMedia:`Voir les médias`,uploadMedia:`Importer des médias`,editMedia:`Modifier les médias`,deleteMedia:`Supprimer les médias`,viewUsers:`Voir les utilisateurs`,editUsers:`Modifier les utilisateurs`,deleteUsers:`Supprimer les utilisateurs`,inviteUsers:`Inviter des utilisateurs`,viewSettings:`Voir les paramètres`,editSettings:`Modifier les paramètres`,studioAccess:`Accès au Studio`,viewTokens:`Voir les jetons API`,createTokens:`Créer des jetons API`,deleteTokens:`Supprimer les jetons API`,viewWebhooks:`Voir les webhooks`,createEditWebhooks:`Créer/Modifier les webhooks`,deleteWebhooks:`Supprimer les webhooks`,testWebhooks:`Tester les webhooks`}},media:{title:`Médiathèque`,subtitle:`Importez et gérez vos fichiers médias`,upload:`Importer`,uploadFiles:`Importer des fichiers`,dragAndDrop:`Glissez-déposez des fichiers ici`,or:`ou`,browseFiles:`Parcourir les fichiers`,noMedia:`Aucun fichier média`,delete:`Supprimer`,download:`Télécharger`,copyUrl:`Copier l'URL`,details:`Détails`,filename:`Nom du fichier`,filesize:`Taille du fichier`,dimensions:`Dimensions`,uploadedAt:`Importé le`,mimeType:`Type MIME`,types:{all:`Tous les fichiers`,images:`Images`,videos:`Vidéos`,audio:`Audio`,documents:`Documents`,archives:`Archives`},accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder à la médiathèque. Contactez votre administrateur pour obtenir l'accès.`,searchPlaceholder:`Rechercher des médias...`,view:{grid:`Vue grille`,list:`Vue liste`},filters:`Filtres`,clearFilters:`Effacer les filtres`,selected:`{{count}} sélectionné(s)`,deleteSelected:`Supprimer la sélection`,confirmBulkDelete:`Êtes-vous sûr de vouloir supprimer {{count}} fichier(s) ? Cette action est irréversible.`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce fichier ? Cette action est irréversible.`,editMetadata:`Modifier les métadonnées`,preview:`Aperçu`,noResults:`Aucun fichier média trouvé`,uploadSuccess:`Fichier importé avec succès`,uploadError:`Échec de l'importation du fichier`,deleteSuccess:`Fichier supprimé avec succès`,deleteError:`Échec de la suppression du fichier`,perPage:`par page`,sort:{dateDesc:`Plus récents`,dateAsc:`Plus anciens`,nameAsc:`Nom A-Z`,nameDesc:`Nom Z-A`,sizeDesc:`Plus grands`,sizeAsc:`Plus petits`}},content:{title:`Contenu`,subtitle:`Gérez tous vos types de contenu et documents`,loading:`Chargement des types de contenu...`,loadingDocuments:`Chargement des documents...`,loadingSingleton:`Chargement du document singleton...`,error:{loadingTypes:`Erreur lors du chargement des types de contenu`,loadingDocuments:`Erreur lors du chargement des documents`,documentNotFound:`Document non trouvé`},noTypes:`Aucun type de contenu trouvé`,noTypesDescription:`Les types de contenu apparaîtront ici une fois votre backend configuré avec des schémas.`,viewDocuments:`Voir les documents`,refresh:`Actualiser`,tryAgain:`Réessayer`,backToContent:`Retour au contenu`,manageDocuments:`Gérer vos documents`,viewExisting:`Voir les documents existants`,create:`Créer {{type}}`,deleteDocument:`Supprimer le document`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce document ? Cette action est irréversible.`,confirmBulkDelete:`Êtes-vous sûr de vouloir supprimer {{count}} document(s) ? Cette action est irréversible.`,deleteAll:`Tout supprimer`,changeStatus:`Changer le statut`,redirecting:`Redirection...`,search:`Rechercher {{type}}...`,views:{list:`Vue liste`,grid:`Vue grille`,table:`Vue tableau`},filters:{status:`Statut`,draft:`Brouillon`,published:`Publié`,archived:`Archivé`},sort:{title:`Titre`,createdDate:`Date de création`,updatedDate:`Date de modification`},bulkActions:{changeStatus:`Changer le statut`,delete:`Supprimer`}},documents:{title:`Documents`,createNew:`Créer nouveau`,noDocuments:`Aucun document trouvé`,untitled:`Sans titre`,modified:`Modifié`,created:`Créé`,publish:`Publier`,unpublish:`Dépublier`,duplicate:`Dupliquer`,delete:`Supprimer`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce document ?`,saveChanges:`Enregistrer les modifications`,discardChanges:`Annuler les modifications`,unsavedChanges:`Vous avez des modifications non enregistrées`},settings:{title:`Paramètres`,subtitle:`Configurez votre Trokky Studio et la gestion de contenu`,loading:`Chargement des paramètres...`,general:`Général`,generalSettings:`Paramètres généraux`,branding:`Marque`,security:`Sécurité`,securitySettings:`Paramètres de sécurité`,api:`API`,webhooks:`Webhooks`,tokens:`Jetons API`,accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder aux paramètres du Studio. Contactez votre administrateur pour obtenir l'accès.`,readOnlyMessage:`Vous avez un accès en lecture seule aux paramètres. Contactez votre administrateur pour effectuer des modifications.`,studioTitle:`Titre du Studio`,studioTitleDescription:`Le titre affiché dans l'interface du Studio`,organizationName:`Nom de l'organisation`,organizationNameDescription:`Nom de l'organisation ou de l'entreprise affiché sur la page de connexion`,primaryColor:`Couleur principale`,primaryColorDescription:`Couleur principale pour les boutons, liens et accents`,secondaryColor:`Couleur secondaire`,secondaryColorDescription:`Couleur secondaire pour les éléments subtils et arrière-plans`,logoUrl:`URL du logo`,logoUrlDescription:`URL vers le logo de votre organisation (affiché sur la page de connexion)`,logoPreview:`Aperçu :`,publicUrl:`URL du site web public`,publicUrlDescription:`L'URL publique où votre contenu sera affiché. Utilisé pour les liens "Voir en direct".`,defaultTheme:`Thème par défaut`,defaultThemeDescription:`Choisissez le thème par défaut pour les nouveaux utilisateurs`,mfa:{title:`Application de l'authentification multifacteur (MFA)`,requireAll:`Exiger la MFA pour tous les utilisateurs`,requireRoles:`Ou exiger la MFA pour des rôles spécifiques :`,allowedMethods:`Méthodes MFA autorisées`,allowedMethodsDescription:`Sélectionnez les méthodes MFA disponibles pour les utilisateurs :`,totp:`Application d'authentification (TOTP) - Recommandé`,email:`OTP par e-mail - Envoyer un code unique par e-mail`,atLeastOne:`Au moins une méthode doit être activée.`,roleDisabledNote:`La sélection par rôle est désactivée lorsque la MFA est requise pour tous les utilisateurs.`,enforcementNote:`Lorsque la MFA est appliquée, les utilisateurs sans MFA configurée seront invités à la configurer lors de leur prochaine connexion. Ils disposeront d'une fenêtre de 15 minutes pour terminer la configuration.`},saveChanges:`Enregistrer les modifications`,saving:`Enregistrement...`,saveSuccess:`Paramètres enregistrés avec succès !`,saveError:`Échec de l'enregistrement des paramètres : {{error}}`,loadError:`Échec du chargement des paramètres. Utilisation des valeurs par défaut.`},auditLogs:{title:`Journaux d'audit`,subtitle:`Historique complet de toutes les modifications de contenu dans le CMS`,action:`Action`,user:`Utilisateur`,resource:`Ressource`,timestamp:`Horodatage`,details:`Détails`,noLogs:`Aucun journal d'audit trouvé`,loading:`Chargement des journaux d'audit...`,refresh:`Actualiser`,search:`Rechercher`,searchPlaceholder:`Rechercher par titre de document, ID ou collection...`,filters:`Filtres`,clearFilters:`Effacer tous les filtres`,collection:`Collection`,allCollections:`Toutes les collections`,allUsers:`Tous les utilisateurs`,operation:`Opération`,allOperations:`Toutes les opérations`,showingResults:`Affichage de {{start}}-{{end}} sur {{total}} entrées`,noResults:`Aucune entrée trouvée`,page:`Page {{current}} sur {{total}}`,previous:`Précédent`,next:`Suivant`,tryAgain:`Réessayer`,operations:{create:`Créé`,update:`Modifié`,delete:`Supprimé`,publish:`Publié`,unpublish:`Dépublié`,restore:`Restauré`},technical:{revision:`Révision :`,documentId:`ID du document :`,ip:`IP :`,actorType:`Type d'acteur :`},hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,changedField:`Modifié {{field}}`,changedFields:`Modifié {{count}} champs`},dashboard:{welcome:`Bienvenue sur Trokky Studio`,subtitle:`La gestion de contenu simplifiée`,recentActivity:`Activité récente`,quickActions:`Actions rapides`,quickStart:`Démarrage rapide`,createFirstDocument:`Créer votre premier document`,uploadMedia:`Importer des médias`,studioSettings:`Paramètres du Studio`,userPreferences:`Préférences utilisateur`,cards:{content:{title:`Contenu`,description:`Créez et gérez votre contenu`},media:{title:`Médias`,description:`Importez et organisez vos fichiers`},users:{title:`Utilisateurs`,description:`Gérez les utilisateurs et permissions`}},stats:{loading:`Chargement des statistiques...`,contentOverview:`Aperçu du contenu`,totalContent:`Contenu total`,singletons:`Singletons`,mediaFiles:`Fichiers médias`,content:`Contenu`,thisWeek:`cette semaine`,documents:`Documents`,media:`Fichiers médias`,users:`Utilisateurs`},activity:{title:`Activité récente`,refresh:`Actualiser l'activité`,loading:`Chargement de l'activité récente...`,unknownTime:`Date inconnue`,tryAgain:`Réessayer`,noActivity:`Aucune activité récente`,noActivityDescription:`L'activité apparaîtra ici au fur et à mesure que le contenu sera créé et modifié`,failedToLoad:`Échec du chargement de l'activité récente`,operations:{created:`créé`,updated:`modifié`,deleted:`supprimé`,published:`publié`,unpublished:`dépublié`,restored:`restauré`},changedField:`Modifié {{field}}`,changedFields:`Modifié {{fields}}`,changedFieldsCount:`Modifié {{count}} champs`,by:`par`}},language:{title:`Langue`,select:`Sélectionner la langue`,current:`Langue actuelle`},sidebar:{navigation:`Navigation`,expand:`Agrandir le panneau`,collapse:`Réduire le panneau`,searchNavigation:`Rechercher dans la navigation...`,loadingNavigation:`Chargement de la navigation...`,failedToLoad:`Échec du chargement de la navigation`,noResultsFor:`Aucun résultat pour "{{query}}"`,clearSearch:`Effacer la recherche`},layout:{globalSearch:`Recherche globale`,searchPlaceholder:`La fonctionnalité de recherche sera implémentée ici.`,expandContext:`Agrandir la barre contextuelle`,collapseContext:`Réduire la barre contextuelle`,resizeSidebar:`Glisser pour redimensionner`},contextSidebar:{quickActions:`Actions rapides`,createContent:`Créer du contenu`,createContentDesc:`Commencer avec un nouveau document`,uploadMedia:`Importer des médias`,uploadMediaDesc:`Ajouter des images et des fichiers`,recentActivity:`Activité récente`,noRecentActivity:`Aucune activité récente`,contentTypes:`Types de contenu`,noContentTypes:`Aucun type de contenu disponible`,mediaLibrary:`Médiathèque`,mediaLibraryDesc:`Importez et gérez vos fichiers médias`,userOverview:`Aperçu des utilisateurs`,totalUsers:`Total utilisateurs`,active:`Actifs`,roles:`Rôles`,usersLoggedInWeek:`{{count}} utilisateur connecté cette semaine`,usersLoggedInWeek_plural:`{{count}} utilisateurs connectés cette semaine`,usersNeverLoggedIn:`{{count}} utilisateur jamais connecté`,usersNeverLoggedIn_plural:`{{count}} utilisateurs jamais connectés`,inactiveUsers:`{{count}} utilisateur inactif`,inactiveUsers_plural:`{{count}} utilisateurs inactifs`,addNewUser:`Ajouter un utilisateur`,manageApiTokens:`Gérer les jetons API`,studioSettings:`Paramètres du Studio`,configureStudio:`Configurez votre studio`,fieldsRegistry:`Registre des champs`,totalFields:`Total des champs`,initialized:`Initialisé`,yes:`Oui`,no:`Non`,availableTypes:`Types disponibles`,documentation:`Documentation`,docSelectFields:`Sélectionnez des champs dans la barre latérale pour tester différents types`,docEditPreview:`Utilisez les onglets Édition/Aperçu pour voir les deux modes`,docUseExamples:`Cliquez sur les boutons "Utiliser" pour essayer différentes valeurs`,docShowErrors:`Activez "Afficher les erreurs" pour tester la validation`,defaultContextInfo:`Les informations contextuelles apparaîtront ici en fonction de la page actuelle.`,widgets:{unknownType:`Type de widget inconnu : {{type}}`,recentDocuments:{defaultTitle:`{{schema}} récents`,defaultTitleFallback:`Documents récents`,noSchemaType:`Aucun type de schéma spécifié`,failedToLoad:`Échec du chargement des documents récents`,untitled:`Sans titre`,noDocuments:`Aucun document récent`,by:`par`},stats:{total:`Total`,published:`Publié`,calculating:`Calcul en cours...`,notAvailable:`N/D`},category:{uncategorized:`Non catégorisé`},recentlyEdited:{untitled:`Sans titre`,by:`par`,author:`Auteur`}}},preferences:{title:`Préférences`,subtitle:`Personnalisez votre expérience Studio`,appearance:`Apparence`,theme:`Thème`,themeSystem:`Système par défaut`,themeLight:`Clair`,themeDark:`Sombre`,notifications:`Notifications`,emailNotifications:`Notifications par e-mail`,emailNotificationsDescription:`Recevoir des notifications par e-mail`,pushNotifications:`Notifications push`,pushNotificationsDescription:`Recevoir des notifications push du navigateur`,connectedAccounts:`Comptes connectés`,connectedAccountsDescription:`Liez des comptes externes pour une connexion plus facile`,security:`Sécurité`,securityDescription:`Gérer l'authentification à deux facteurs et les paramètres de sécurité`,passkeys:`Passkeys`,passkeysDescription:`Connectez-vous en toute sécurité sans mot de passe en utilisant votre empreinte digitale, votre visage ou une clé de sécurité.`,savePreferences:`Enregistrer les préférences`,saveSuccess:`Préférences enregistrées avec succès`,saveError:`Échec de la mise à jour des préférences`},notFound:{title:`Page non trouvée`,message:`La page que vous recherchez n'existe pas ou a été déplacée.`,goToDashboard:`Aller au tableau de bord`},auth:{forgotPassword:{title:`Mot de passe oublié ?`,subtitle:`Entrez votre adresse e-mail et nous vous enverrons un lien pour réinitialiser votre mot de passe.`,sendResetLink:`Envoyer le lien`,sending:`Envoi...`,backToSignIn:`Retour à la connexion`,checkEmail:`Vérifiez vos e-mails`,emailSentMessage:`Si un compte existe pour <strong>{{email}}</strong>, vous recevrez un lien de réinitialisation sous peu.`,linkExpires:`Le lien expirera dans 1 heure.`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,sendError:`Échec de l'envoi de l'e-mail de réinitialisation`},resetPassword:{title:`Réinitialiser le mot de passe`,subtitle:`Entrez votre nouveau mot de passe ci-dessous.`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,resetButton:`Réinitialiser le mot de passe`,resetting:`Réinitialisation...`,verifying:`Vérification du lien...`,success:`Mot de passe réinitialisé`,successMessage:`Votre mot de passe a été réinitialisé avec succès. Vous pouvez maintenant vous connecter avec votre nouveau mot de passe.`,signIn:`Se connecter`,invalidLink:`Lien invalide`,invalidLinkMessage:`Ce lien de réinitialisation est invalide ou a expiré.`,linkExpireNote:`Les liens de réinitialisation expirent après 1 heure. Veuillez en demander un nouveau.`,requestNewLink:`Demander un nouveau lien`,noToken:`Aucun jeton de réinitialisation fourni`,tokenInvalid:`Jeton de réinitialisation invalide ou expiré`,tokenVerifyError:`Échec de la vérification du jeton`,passwordMinLength:`Le mot de passe doit contenir au moins 8 caractères`,passwordMismatch:`Les mots de passe ne correspondent pas`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,resetError:`Échec de la réinitialisation du mot de passe`,linkExpiresIn:`Le lien expire dans {{minutes}} minute`,linkExpiresIn_plural:`Le lien expire dans {{minutes}} minutes`,strength:`Force`,strengthTooShort:`Trop court`,strengthWeak:`Faible`,strengthMedium:`Moyen`,strengthGood:`Bon`,strengthStrong:`Fort`,requirements:`Le mot de passe doit :`,requireLength:`Contenir au moins 8 caractères`,requireUppercase:`Contenir une majuscule (recommandé)`,requireNumber:`Contenir un chiffre (recommandé)`},oauth:{processing:`Traitement...`,completingAuth:`Authentification avec Google en cours`,success:`Succès !`,loginSuccess:`Connexion réussie ! Redirection...`,mfaRequired:`Vérification MFA requise. Redirection...`,mfaSetupRequired:`Configuration MFA requise. Redirection...`,accountLinked:`Compte Google lié avec succès`,failed:`Échec de l'authentification`,returnToLogin:`Retour à la connexion`,invalidResponse:`Réponse invalide du serveur`},device:{pageTitle:`Connexion Trokky CLI`,loading:`Chargement des informations de l'appareil...`,authorizeDevice:`Autoriser l'appareil`,requestingAccess:`demande l'accès à votre compte`,deviceCode:`Code de l'appareil`,allowApplication:`Cela permettra à l'application de :`,deny:`Refuser`,authorize:`Autoriser`,authorized:`Appareil autorisé`,authorizedMessage:`Vous pouvez maintenant fermer cette fenêtre et retourner au CLI.`,closeWindow:`Fermer la fenêtre`,denied:`Autorisation refusée`,deniedMessage:`L'appareil n'a pas été autorisé. Vous pouvez fermer cette fenêtre.`,expired:`Code expiré`,expiredMessage:`Le code de l'appareil a expiré. Veuillez réessayer depuis le CLI.`,error:`Erreur`,noCode:`Aucun code d'appareil fourni`,fetchError:`Échec de la récupération des informations de l'appareil`,connectError:`Échec de la connexion au serveur`,authError:`Échec de l'autorisation`,denyError:`Échec du refus de l'autorisation`,returnToStudio:`Retour au Studio`,scopes:{openid:`Accéder à votre identité`,profile:`Accéder à vos informations de profil`,contentRead:`Lire le contenu`,contentWrite:`Créer et modifier le contenu`,contentDelete:`Supprimer le contenu`,mediaRead:`Lire les fichiers médias`,mediaWrite:`Importer des fichiers médias`,offlineAccess:`Rester connecté`}},authorize:{pageTitle:`Trokky`,validating:`Validation de la demande d'autorisation...`,authorizeApp:`Autoriser l'application`,wantsAccess:`souhaite accéder à votre compte`,allowApplication:`Cela permettra à l'application de :`,visitWebsite:`Visiter le site de l'application`,deny:`Refuser`,authorize:`Autoriser`,consentNote:`En autorisant, vous permettez à cette application d'accéder à vos données selon les permissions listées ci-dessus.`,redirecting:`Redirection...`,redirectingMessage:`Vous êtes redirigé vers l'application.`,error:`Erreur d'autorisation`,missingParams:`Paramètres d'autorisation requis manquants`,invalidRequest:`Demande d'autorisation invalide`,validateError:`Échec de la validation de la demande d'autorisation`,authFailed:`Échec de l'autorisation`,denyFailed:`Échec du refus de l'autorisation`,returnToStudio:`Retour au Studio`}},documentEditor:{loadingSchema:`Chargement du schéma...`,loadingDocument:`Chargement du document...`,backToDocuments:`Retour aux documents`,schemaRequired:`Le nom du schéma est requis`,documentPreview:`Aperçu du document`,newDocument:`Nouveau {{type}}`,backTo:`Retour à {{type}}`,confirmStateChange:`Êtes-vous sûr de vouloir passer de {{from}} à {{to}} ?`,edit:`Modifier`,preview:`Aperçu`,readOnly:`Lecture seule`,readOnlyMode:`Mode lecture seule`,unsavedChanges:`Modifications non enregistrées`,validationErrors:`Erreurs de validation`,discardChangesConfirm:`Vous avez des modifications non enregistrées. Êtes-vous sûr de vouloir annuler ?`,discardChangesTitle:`Modifications non enregistrées`,discardChanges:`Annuler les modifications`,keepEditing:`Continuer l'édition`,documentInfo:`Informations du document`,loadingForm:`Chargement du formulaire...`,noFieldsDefined:`Aucun champ défini dans le schéma`,created:`Créé`,lastUpdated:`Dernière modification`,status:`Statut`,published:`Publié`,draft:`Brouillon`,publishedOn:`Publié le {{date}}`,tags:`Étiquettes`,contributors:`Contributeurs`,contributorsLoading:`Chargement...`,contributorsMore:`+{{count}} autres`,references:`Références`,referencesCount:`Références ({{count}})`,referencesMore:`+{{count}}`,noReferences:`Aucune référence`,schema:`Schéma`,fieldsCount:`{{count}} champs`,dangerZone:`Zone de danger`,deleteDocument:`Supprimer le document`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer "{{title}}" ? Cette action est irréversible.`,deleteTitle:`Supprimer le document`,cannotBeUndone:`Cette action est irréversible.`,expandSidebar:`Agrandir la barre latérale`,collapseSidebar:`Réduire la barre latérale`},documentHistory:{title:`Historique du document`,refreshHistory:`Actualiser l'historique`,loading:`Chargement...`,loadError:`Échec du chargement de l'historique`,notAvailable:`L'historique du document n'est pas disponible`,noHistory:`Aucun historique`,moreChanges:`+{{count}} autres modifications`},changesDiff:{noVisibleChanges:`Aucune modification visible`,changesCount:`Modifications ({{count}})`,showSystemFields:`Afficher les champs système`,hideSystemFields:`Masquer les champs système`,before:`Avant :`,after:`Après :`},auditEntry:{created:`Créé`,updated:`Modifié`,deleted:`Supprimé`,published:`Publié`,unpublished:`Dépublié`,restored:`Restauré`,by:`par`,latest:`Dernier`,changedField:`Modifié {{field}}`,changedFieldsJoin:`Modifié {{fields}}`,changedFieldsCount:`Modifié {{count}} champs`,hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,revision:`Révision :`,ipAddress:`Adresse IP :`,userAgent:`Agent utilisateur :`},appTokens:{title:`Jetons API`,subtitle:`Créez et gérez les jetons API pour les applications externes`,createToken:`Créer un jeton`,searchPlaceholder:`Rechercher des jetons...`,noTokensTitle:`Aucun jeton API`,noTokensDesc:`Créez votre premier jeton API pour permettre aux applications externes d'accéder à votre contenu de manière sécurisée.`,tableHeaders:{token:`Jeton`,status:`Statut`,lastUsed:`Dernière utilisation`,expires:`Expire`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`,expired:`Expiré`},never:`Jamais`,modal:{title:`Créer un jeton API`,tokenName:`Nom du jeton`,tokenNamePlaceholder:`ex. : API de production, Application mobile`,description:`Description`,descriptionPlaceholder:`À quoi servira ce jeton ?`,expiration:`Expiration`,expiration30days:`30 jours`,expiration90days:`90 jours (recommandé)`,expiration1year:`1 an`,expirationNever:`N'expire jamais`,expirationCustom:`Date personnalisée`,permissions:`Permissions`,cancel:`Annuler`,creating:`Création en cours...`,createToken:`Créer le jeton`},tokenCreated:{title:`Jeton API créé`,warning:`C'est la seule fois que vous verrez ce jeton. Copiez-le et conservez-le en lieu sûr.`,yourToken:`Votre jeton API`,copied:`Copié !`,close:`Fermer`},deleteConfirm:`Êtes-vous sûr de vouloir supprimer le jeton "{{name}}" ? Cette action est irréversible.`,permissions:{viewContent:`Voir le contenu`,editContent:`Modifier le contenu`,deleteContent:`Supprimer le contenu`,publishContent:`Publier le contenu`,viewMedia:`Voir les médias`,uploadMedia:`Importer des médias`,editMedia:`Modifier les médias`,deleteMedia:`Supprimer les médias`}},webhooks:{title:`Webhooks`,subtitle:`Recevez des notifications en temps réel lorsque des événements se produisent`,createWebhook:`Créer un webhook`,searchPlaceholder:`Rechercher des webhooks...`,noWebhooksTitle:`Aucun webhook configuré`,noWebhooksDesc:`Créez votre premier webhook pour recevoir des notifications en temps réel lorsque des événements se produisent.`,tableHeaders:{webhook:`Webhook`,status:`Statut`,events:`Événements`,lastUpdated:`Dernière mise à jour`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`},eventsCount:`{{count}} événement`,eventsCount_plural:`{{count}} événements`,moreEvents:`+{{count}} de plus`,testWebhook:`Tester le webhook`,viewDeliveryHistory:`Voir l'historique des livraisons`,editWebhook:`Modifier le webhook`,deleteWebhook:`Supprimer le webhook`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer le webhook "{{name}}" ? Cette action est irréversible.`,modal:{editTitle:`Modifier le webhook`,createTitle:`Créer un webhook`,name:`Nom du webhook`,namePlaceholder:`ex. : Synchronisation de contenu, Notifications Slack`,url:`URL du point de terminaison`,urlPlaceholder:`https://api.example.com/webhooks/trokky`,events:`Événements à souscrire`,secret:`Clé secrète`,secretPlaceholder:`Laisser vide pour générer automatiquement`,secretDescription:`Utilisée pour vérifier l'authenticité du webhook via des signatures HMAC`,headers:`En-têtes personnalisés`,headerNamePlaceholder:`Nom de l'en-tête`,headerValuePlaceholder:`Valeur de l'en-tête`,maxRetries:`Tentatives max`,backoffStrategy:`Stratégie de recul`,linear:`Linéaire`,exponential:`Exponentiel`,active:`Actif (le webhook recevra des événements)`,updating:`Mise à jour...`,creating:`Création...`,update:`Mettre à jour le webhook`,create:`Créer le webhook`},deliveryModal:{title:`Historique des livraisons : {{name}}`,noDeliveries:`Aucune livraison pour le moment`,status:`Statut`,response:`Réponse`,timestamp:`Date`,attempt:`Tentative`,success:`Succès`,failed:`Échec`},events:{allDocuments:`Tous les événements de documents`,documentCreated:`Document créé`,documentUpdated:`Document mis à jour`,documentDeleted:`Document supprimé`,documentPublished:`Document publié`,documentUnpublished:`Document dépublié`,allMedia:`Tous les événements médias`,mediaUploaded:`Média importé`,mediaUpdated:`Média mis à jour`,mediaDeleted:`Média supprimé`,allUsers:`Tous les événements utilisateurs`,userCreated:`Utilisateur créé`,userUpdated:`Utilisateur mis à jour`,userLogin:`Connexion utilisateur`,allSystem:`Tous les événements système`,systemStartup:`Démarrage système`,systemError:`Erreur système`}},changePassword:{title:`Changer le mot de passe`,currentPassword:`Mot de passe actuel`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,submit:`Changer le mot de passe`,submitting:`Changement en cours...`,success:`Mot de passe changé avec succès`,errors:{currentRequired:`Le mot de passe actuel est requis`,newRequired:`Le nouveau mot de passe est requis`,confirmRequired:`Veuillez confirmer votre nouveau mot de passe`,mismatch:`Les mots de passe ne correspondent pas`,tooShort:`Le mot de passe doit contenir au moins 8 caractères`,sameAsCurrent:`Le nouveau mot de passe doit être différent de l'actuel`,failed:`Échec du changement de mot de passe`}},oauth:{linkedAccounts:`Comptes liés`,linkAccount:`Lier le compte {{provider}}`,unlinkAccount:`Délier le compte`,accountLinked:`Compte lié avec succès`,unlinkSuccess:`Compte {{provider}} délié avec succès`,unlinkFailed:`Échec de la déliaison du compte`,confirmUnlink:`Êtes-vous sûr de vouloir délier ce compte {{provider}} ? Vous ne pourrez plus vous connecter avec ce compte.`,lastLoginMethod:`Ceci est votre dernière méthode de connexion. Vous ne pouvez pas la délier.`,notConnected:`Non connecté`,linked:`Lié le {{date}}`,unlink:`Délier`,comingSoon:`Bientôt disponible`,google:{signIn:`Se connecter avec Google`,linkAccount:`Lier le compte Google`,initFailed:`Échec de l'initialisation de la connexion Google`}},mfa:{title:`Authentification à deux facteurs`,subtitle:`Ajoutez une couche de sécurité supplémentaire à votre compte`,enabled:`2FA activée`,notEnabled:`2FA non activée`,authenticatorApp:`Application d'authentification`,authenticatorAppDesc:`Utilisez une application comme Google Authenticator ou Authy`,emailVerification:`Vérification par e-mail`,emailVerificationDesc:`Recevez des codes de vérification par e-mail`,emailCode:`Code par e-mail`,backupCode:`Code de secours`,backupCodes:`Codes de secours`,backupCodesRemaining:`{{count}} codes restants`,totpDescription:`Entrez le code à 6 chiffres de votre application d'authentification`,emailDescriptionPending:`Un code sera envoyé à votre e-mail`,emailDescriptionSent:`Entrez le code envoyé à votre e-mail`,backupDescription:`Entrez l'un de vos codes de secours (format : XXXX-XXXX)`,enterCode:`Veuillez entrer le code de vérification`,trustDevice:`Faire confiance à cet appareil pendant 30 jours`,trustedDevices:`Appareils de confiance`,trustedDevicesCount:`{{count}} appareil de confiance`,trustedDevicesCount_plural:`{{count}} appareils de confiance`,verifying:`Vérification...`,verify:`Vérifier`,sendingCode:`Envoi...`,resendCode:`Vous n'avez pas reçu le code ? Renvoyer`,setUp:`Configurer`,disableMethod:`Désactiver`,manage:`Gérer`,hide:`Masquer`,regenerate:`Régénérer`,revokeAll:`Tout révoquer`,cancel:`Annuler`,next:`Suivant`,done:`Terminé`,copyAll:`Tout copier`,copiedToClipboard:`Copié dans le presse-papiers`,setup:{authenticator:`Configurer l'application d'authentification`,scanQrCode:`Scannez ce QR code avec votre application d'authentification (Google Authenticator, Authy, etc.)`,orEnterManually:`Ou entrez ce code manuellement :`,verifyAuthenticatorCode:`Vérifier le code d'authentification`,enterCodeToVerify:`Entrez le code à 6 chiffres de votre application d'authentification pour vérifier la configuration.`,verifyEmailCode:`Vérifier le code e-mail`,enterEmailCode:`Entrez le code envoyé à votre adresse e-mail.`,saveBackupCodes:`Enregistrez vos codes de secours`,backupCodesImportant:`Conservez ces codes de secours en lieu sûr. Vous pouvez les utiliser pour accéder à votre compte si vous perdez votre appareil d'authentification.`,newBackupCodes:`Vos nouveaux codes de secours`,newBackupCodesImportant:`Conservez ces codes de secours en lieu sûr. Vos codes précédents ne sont plus valides. Vous pouvez utiliser ces codes pour accéder à votre compte si vous perdez votre appareil d'authentification.`},disable:{authenticator:`Désactiver l'application d'authentification`,email:`Désactiver la vérification par e-mail`,enterPassword:`Entrez votre mot de passe pour désactiver cette méthode 2FA.`,all:`Désactiver toute la 2FA`,allDesc:`Cela supprimera toutes les méthodes 2FA et les codes de secours de votre compte`},disableDialog:{authenticator:`Désactiver l'application d'authentification`,email:`Désactiver la vérification par e-mail`,enterPassword:`Entrez votre mot de passe pour désactiver cette méthode 2FA.`,all:`Désactiver toute la 2FA`,allWarning:`Cela désactivera complètement l'authentification à deux facteurs sur votre compte. Toutes les méthodes 2FA (application d'authentification, e-mail) et les codes de secours seront supprimés.`,confirmPassword:`Entrez votre mot de passe pour confirmer.`},regenerateBackupCodes:{title:`Régénérer les codes de secours`,description:`Cela invalidera tous vos codes de secours existants. Entrez votre mot de passe pour confirmer.`},trustedDevice:{trusted:`Approuvé : {{date}}`,confirmRevokeAll:`Êtes-vous sûr de vouloir révoquer la confiance de tous les appareils ?`},toast:{loadFailed:`Échec du chargement du statut 2FA`,totpInitFailed:`Échec de l'initialisation de la configuration TOTP`,totpEnabled:`Application d'authentification activée avec succès !`,emailCodeSent:`Code de vérification envoyé à votre e-mail`,emailSendFailed:`Échec de l'envoi du code de vérification`,emailEnabled:`Vérification par e-mail activée avec succès !`,authenticatorDisabled:`Application d'authentification désactivée`,emailDisabled:`Vérification par e-mail désactivée`,allDisabled:`Toute la 2FA a été désactivée`,backupCodesRegenerated:`Codes de secours régénérés. Enregistrez-les en lieu sûr !`,deviceRevoked:`Confiance de l'appareil révoquée`,deviceRevokeFailed:`Échec de la révocation de la confiance de l'appareil`,allDevicesRevoked:`Confiance de tous les appareils révoquée`,allDevicesRevokeFailed:`Échec de la révocation de la confiance des appareils`},errors:{passwordRequired:`Le mot de passe est requis`}},passkey:{signIn:`Se connecter avec Passkey`,optionsFailed:`Échec du démarrage de l'authentification par passkey`,cancelled:`L'authentification a été annulée`,notSupported:`Les passkeys ne sont pas prises en charge dans ce navigateur`,authFailed:`Échec de l'authentification par passkey`,verifyFailed:`Échec de la vérification du passkey`,unexpectedResponse:`Réponse inattendue du serveur`,manager:{title:`Passkeys`,description:`Connectez-vous en toute sécurité sans mot de passe en utilisant votre empreinte digitale, votre visage ou une clé de sécurité.`,loadFailed:`Échec du chargement des passkeys`,renameFailed:`Échec du renommage du passkey`,deleteFailed:`Échec de la suppression du passkey`,notConfigured:`L'authentification par passkey n'est pas activée`,notConfiguredDescription:`L'authentification par passkey doit être configurée par un administrateur dans les paramètres du serveur.`,noPasskeys:`Vous n'avez pas encore configuré de passkey.`,unnamed:`Passkey`,added:`Ajouté le`,lastUsed:`Dernière utilisation`,synced:`Synchronisé sur tous les appareils`,deviceOnly:`Cet appareil uniquement`},register:{addPasskey:`Ajouter un Passkey`,optionsFailed:`Échec du démarrage de l'enregistrement du passkey`,cancelled:`L'enregistrement a été annulé`,alreadyRegistered:`Ce passkey est déjà enregistré`,notSupported:`Les passkeys ne sont pas prises en charge dans ce navigateur`,failed:`Échec de l'enregistrement du passkey`,verifyFailed:`Échec de la vérification de l'enregistrement du passkey`,namePlaceholder:`ex. : MacBook Pro Touch ID`,continue:`Continuer`}},captcha:{loading:`Chargement du CAPTCHA...`,errors:{hcaptchaNotSupported:`hCaptcha n'est pas encore pris en charge`,providerNotSupported:`Le fournisseur "{{provider}}" n'est pas pris en charge`,scriptLoadFailed:`Échec du chargement du script CAPTCHA`,renderFailed:`Échec du rendu du widget CAPTCHA`,notAvailable:`{{provider}} non disponible`}},sessionTimeout:{title:`Session expirant bientôt`,expireIn:`Votre session expirera dans {{time}}.`,stayLoggedIn:`Rester connecté`,logout:`Se déconnecter`,extended:`Session prolongée avec succès`},common:{title:`Titre`,cancel:`Annuler`,dismiss:`Ignorer`,note:`Note :`,save:`Enregistrer`,delete:`Supprimer`,edit:`Modifier`,create:`Créer`,add:`Ajouter`,remove:`Retirer`,generate:`Générer`,close:`Fermer`,confirm:`Confirmer`,loading:`Chargement...`,error:`Erreur`,success:`Succès`,warning:`Avertissement`,info:`Information`,yes:`Oui`,no:`Non`,ok:`OK`,retry:`Réessayer`,back:`Retour`,next:`Suivant`,previous:`Précédent`,submit:`Soumettre`,reset:`Réinitialiser`,clear:`Effacer`,search:`Rechercher`,filter:`Filtrer`,sort:`Trier`,view:`Afficher`,download:`Télécharger`,upload:`Importer`,copy:`Copier`,paste:`Coller`,select:`Sélectionner`,selectAll:`Tout sélectionner`,deselectAll:`Tout désélectionner`,refresh:`Actualiser`,more:`Plus`,less:`Moins`,expand:`Développer`,collapse:`Réduire`,show:`Afficher`,hide:`Masquer`,enable:`Activer`,disable:`Désactiver`,actions:`Actions`,options:`Options`,details:`Détails`,preview:`Aperçu`,tryAgain:`Réessayer`,refreshPage:`Rafraîchir la page`,copyErrorDetails:`Copier les détails de l'erreur`,copied:`Copié !`,closeNotification:`Fermer la notification`,notifications:`Notifications`},errorBoundary:{title:`Une erreur s'est produite`,subtitle:`L'application a rencontré une erreur inattendue`,description:`Veuillez essayer de rafraîchir la page ou contacter le support si le problème persiste. Vous pouvez copier les détails de l'erreur ci-dessous pour faciliter le dépannage.`,errorMessage:`Message d'erreur :`,stackTrace:`Trace de la pile`,componentStack:`Pile des composants`,environmentDetails:`Détails de l'environnement`,noStackTrace:`Aucune trace de pile disponible`,noComponentStack:`Aucune pile de composants disponible`,url:`URL :`,timestamp:`Horodatage :`,userAgent:`Agent utilisateur :`,viewport:`Fenêtre d'affichage :`},toast:{closeNotification:`Fermer la notification`,notifications:`Notifications`},confirmDialog:{defaultConfirm:`Confirmer`,defaultCancel:`Annuler`},search:{placeholder:`Rechercher documents, médias...`,clearSearch:`Effacer la recherche`,closeSearch:`Fermer la recherche`,searching:`Recherche en cours...`,recentSearches:`Recherches récentes`,clear:`Effacer`,clearHistory:`Effacer l'historique de recherche`,foundResults:`{{count}} résultat trouvé`,foundResults_plural:`{{count}} résultats trouvés`,document:`Document`,media:`Média`,by:`par`,noResults:`Aucun résultat trouvé`,tryDifferent:`Essayez d'autres termes de recherche`,typeToSearch:`Tapez pour rechercher documents et médias`,pressEscape:`Appuyez sur Échap pour fermer`,poweredBy:`Propulsé par Trokky`},permissionsDebug:{title:`Débogage des permissions`,copyToClipboard:`Copier les infos de débogage`,currentUser:`Utilisateur actuel`,username:`Nom d'utilisateur :`,email:`E-mail :`,role:`Rôle :`,admin:`Admin :`,notLoggedIn:`Non connecté`,notAvailable:`N/D`,guest:`invité`,yes:`Oui`,no:`Non`,documentPermissions:`Permissions du document`,type:`Type :`,id:`ID :`,newDocument:`Nouveau document`,canCreate:`Peut créer`,canUpdate:`Peut modifier`,canDelete:`Peut supprimer`,canRead:`Peut lire`,allowed:`Autorisé`,denied:`Refusé`,fieldStates:`États des champs ({{count}})`,hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,disabled:`Désactivé`,readonly:`Lecture seule`,required:`Requis`,hasError:`A une erreur`,value:`Valeur :`,debugModeDev:`Mode débogage activé (dev)`,debugModeManual:`Mode débogage activé (manuel)`,disableInProduction:`Désactiver en production`,enableInProduction:`Activer en production`}},fields:{types:JSON.parse(`{"string":{"label":"Texte","placeholder":"Saisissez du texte...","description":"Champ de texte sur une ligne","noValue":"Aucune valeur","selection":"Sélection"},"text":{"label":"Zone de texte","placeholder":"Saisissez du texte...","description":"Champ de texte multiligne","words":"mots","lines":"lignes"},"number":{"label":"Nombre","placeholder":"Saisissez un nombre","placeholderInteger":"Saisissez un nombre entier","placeholderCurrency":"0,00","placeholderPercentage":"0,00 %","description":"Champ de valeur numérique","noValue":"Aucune valeur","increaseValue":"Augmenter la valeur","decreaseValue":"Diminuer la valeur"},"boolean":{"label":"Booléen","description":"Champ vrai/faux","yes":"Oui","no":"Non","toggle":"Basculer"},"date":{"label":"Date","placeholder":"Sélectionnez une date...","description":"Sélecteur de date","noDateSet":"Aucune date définie","clearDate":"Effacer la date","dateOnly":"Date","dateAndTime":"Date et heure"},"datetime":{"label":"Date et heure","placeholder":"Sélectionnez une date et une heure...","description":"Sélecteur de date et heure"},"image":{"label":"Image","placeholder":"Sélectionnez ou importez une image","description":"Champ d'import d'image","selectImage":"Sélectionner une image","changeImage":"Changer l'image","removeImage":"Supprimer l'image"},"file":{"label":"Fichier","placeholder":"Sélectionnez ou importez un fichier","description":"Champ d'import de fichier","selectFile":"Sélectionner un fichier","changeFile":"Changer le fichier","removeFile":"Supprimer le fichier"},"reference":{"label":"Référence","placeholder":"Sélectionner une référence...","description":"Référence vers un autre document","noResults":"Aucun résultat trouvé","noResultsFor":"Aucun résultat trouvé pour \\"{{query}}\\"","tryDifferentTerm":"Essayez un autre terme de recherche","noDocumentsAvailable":"Aucun document disponible","createDocumentsFirst":"Créez d'abord des documents pour les référencer ici","loading":"Chargement...","loadingTypes":"Chargement des types de documents...","searching":"Recherche...","filterDocuments":"Filtrer les documents...","allTypes":"Tous les types","anyType":"Tout type","available":"{{count}} disponible(s)","references":"{{count}} référence","references_plural":"{{count}} références","ofMax":"sur {{max}} max","removeReference":"Supprimer la référence","dragToReorder":"Glisser pour réorganiser","close":"Fermer","clear":"Effacer"},"array":{"label":"Liste","description":"Liste d'éléments","addItem":"Ajouter un élément","addFirstItem":"Ajouter le premier élément","removeItem":"Supprimer l'élément","moveUp":"Déplacer vers le haut","moveDown":"Déplacer vers le bas","empty":"Aucun élément ajouté","items":"éléments","item":"élément","itemCount":"{{count}} élément","itemCount_plural":"{{count}} éléments","missingDefinition":"Définition 'of' manquante pour le champ tableau","unknownType":"Type de champ inconnu : {{type}}","availableTypes":"Types disponibles : {{types}}","noOptionsConfigured":"Aucune option configurée pour la disposition sélection","noMatchingOptions":"Aucune option correspondante","holdCtrlToSelect":"Maintenez Ctrl/Cmd pour sélectionner plusieurs","removeTag":"Supprimer le tag \\"{{tag}}\\" ?","addTag":"Ajouter un tag...","typeToSearch":"Tapez pour rechercher ou ajouter des tags personnalisés","selectFromOptions":"Sélectionnez parmi les options disponibles","add":"Ajouter","minimum":"Minimum {{count}} élément","minimum_plural":"Minimum {{count}} éléments","maximum":"Maximum {{count}} élément","maximum_plural":"Maximum {{count}} éléments","range":"{{min}} - {{max}} éléments"},"object":{"label":"Objet","description":"Groupe de champs imbriqués","fields":"champs","field":"champ","otherFields":"Autres champs","invalidConfig":"Configuration de champ invalide : champ objet attendu","fieldNotRegistered":"Le type de champ '{{type}}' n'est pas enregistré. Veuillez vous assurer que le plugin de champ est chargé."},"select":{"label":"Sélection","placeholder":"Sélectionnez une option...","description":"Champ de sélection déroulante","noOptions":"Aucune option disponible"},"richtext":{"label":"Texte enrichi","placeholder":"Commencez à écrire...","description":"Éditeur de texte enrichi","noContent":"Aucun contenu","loadingEditor":"Chargement de l'éditeur...","invalidConfig":"Configuration de champ invalide : champ richtext attendu","toolbar":{"bold":"Gras","italic":"Italique","underline":"Souligné","strikethrough":"Barré","heading1":"Titre 1","heading2":"Titre 2","heading3":"Titre 3","quote":"Citation","addLink":"Ajouter un lien","insertImage":"Insérer une image","bulletList":"Liste à puces","numberedList":"Liste numérotée","insertTable":"Insérer un tableau","codeBlock":"Bloc de code","undo":"Annuler","redo":"Rétablir","viewEditSource":"Voir/Modifier le code source","fullscreen":"Plein écran","exitFullscreen":"Quitter le plein écran"},"stats":{"words":"mots","characters":"caractères","minRead":"min de lecture","exceedsLimit":"Dépasse la limite de caractères"},"imageToolbar":{"title":"Options d'image :","variant":"Variante :","original":"Original","delete":"Supprimer","deleteTitle":"Supprimer l'image"},"tableToolbar":{"title":"Options de tableau :","row":"Ligne","col":"Col","header":"En-tête","merge":"Fusionner","split":"Diviser","table":"Tableau","addRowAfter":"Ajouter une ligne après","deleteRow":"Supprimer la ligne","addColumnAfter":"Ajouter une colonne après","deleteColumn":"Supprimer la colonne","toggleHeaderRow":"Activer/Désactiver la ligne d'en-tête","mergeSelectedCells":"Fusionner les cellules sélectionnées","splitCell":"Diviser la cellule","deleteTable":"Supprimer le tableau"},"linkDialog":{"title":"Ajouter un lien","linkText":"Texte du lien","linkTextPlaceholder":"Saisissez le texte du lien","url":"URL","urlPlaceholder":"https://exemple.com","cancel":"Annuler","addLink":"Ajouter le lien","removeLink":"Supprimer le lien"},"source":{"placeholder":"Modifier le code source HTML..."},"sanitization":{"warning":"Le contenu a été nettoyé pour des raisons de sécurité : {{warnings}}","dismissWarning":"Ignorer l'avertissement"}},"portableText":{"label":"Texte portable","placeholder":"Tapez quelque chose...","description":"Éditeur de contenu en blocs","noContent":"Aucun contenu","emptyBlock":"Bloc vide","blocks":"Blocs :","characters":"Caractères :","words":"Mots :","blocksCount":"{{current}}/{{max}} blocs","charactersCount":"{{current}}/{{max}} caractères","normal":"Normal","heading1":"Titre 1","heading2":"Titre 2","heading3":"Titre 3","quote":"Citation","quotePlaceholder":"Citation...","bold":"Gras (⌘B)","italic":"Italique (⌘I)","underline":"Souligné (⌘U)","strikethrough":"Barré","code":"Code","addLink":"Ajouter un lien","hideStats":"Masquer les stats","showStats":"Afficher les stats","exitFullscreen":"Quitter le plein écran","fullscreen":"Plein écran","dragToReorder":"Glisser pour réorganiser (ou Alt+↑/↓)","deleteBlock":"Supprimer le bloc","addBlock":"+ Ajouter un bloc","checkRequirements":"Veuillez vérifier les exigences de contenu","linkDialog":{"title":"Ajouter un lien","url":"URL","textOptional":"Texte (optionnel)","textPlaceholder":"Texte du lien","cancel":"Annuler","add":"Ajouter le lien"},"deleteConfirm":"Êtes-vous sûr de vouloir supprimer ce bloc ?","deleteConfirmWithText":"Êtes-vous sûr de vouloir supprimer ce bloc ?\\n\\n\\"{{text}}\\"","deleteEmptyConfirm":"Êtes-vous sûr de vouloir supprimer ce bloc vide ?"},"slug":{"label":"Slug","placeholder":"mon-super-slug","description":"Identifiant compatible URL","generate":"Générer","edit":"Modifier","regenerate":"Régénérer le slug à partir du champ source","editSlug":"Modifier le slug","unique":"unique","noSlugSet":"Aucun slug défini","autoGeneratedFrom":"Généré automatiquement à partir de : {{source}}","manuallyEdited":"modifié manuellement","slugTaken":"Ce slug est déjà pris. Veuillez en choisir un autre.","checkingUniqueness":"Vérification de l'unicité...","slugIsUnique":"Le slug est unique","slugExists":"Le slug existe déjà","couldNotCheck":"Impossible de vérifier l'unicité"},"email":{"label":"E-mail","placeholder":"email@exemple.com","description":"Champ d'adresse e-mail","enterEmail":"Entrez une adresse e-mail"},"url":{"label":"URL","placeholder":"https://exemple.com","description":"Champ d'adresse web"},"color":{"label":"Couleur","placeholder":"#000000","description":"Sélecteur de couleur","openPicker":"Ouvrir le sélecteur de couleur","pickFromScreen":"Choisir une couleur à l'écran","quickColors":"Couleurs rapides","selectColor":"Sélectionner {{color}}"},"geoCoordinate":{"label":"Coordonnée géographique","description":"Champ de coordonnée géographique","manual":"Manuel","map":"Carte","latitude":"Latitude","longitude":"Longitude","useCurrentLocation":"Utiliser la position actuelle","altitude":"Altitude (mètres)","accuracy":"Précision (mètres)","interactiveMap":"Carte interactive","comingSoon":"(Bientôt disponible)"},"info":{"label":"Info","description":"Champ d'affichage informatif","expand":"Développer","collapse":"Réduire"},"password":{"label":"Mot de passe","description":"Champ de mot de passe","placeholder":"Saisissez un mot de passe","generatePassword":"Générer un mot de passe","showPassword":"Afficher le mot de passe","hidePassword":"Masquer le mot de passe","passwordStrength":"Force du mot de passe :","strength":{"noPassword":"Aucun mot de passe","veryWeak":"Très faible","weak":"Faible","fair":"Moyen","good":"Bon","strong":"Fort"}},"icon":{"label":"Icône","description":"Sélecteur d'icônes","selectIcon":"Sélectionner une icône","searchIcons":"Rechercher des icônes...","style":"Style :","category":"Catégorie :","allCategories":"Toutes les catégories","iconCount":"{{count}} icônes","noIconsFound":"Aucune icône trouvée","tryDifferentSearch":"Essayez un autre terme de recherche ou une autre catégorie","previous":"Précédent","next":"Suivant","pageOf":"Page {{page}} sur {{total}}","noLibrariesAvailable":"Aucune bibliothèque d'icônes disponible","noIconSelected":"Aucune icône sélectionnée","change":"Changer","select":"Sélectionner","clearIcon":"Effacer l'icône"},"media":{"label":"Média","description":"Champ d'import de média","selectMedia":"Sélectionner un média","clickToUploadOrBrowse":"Cliquez pour importer ou parcourir","addMedia":"Ajouter un média","addImage":"Ajouter une image","addVideo":"Ajouter une vidéo","addAudio":"Ajouter un audio","addDocument":"Ajouter un document","addArchive":"Ajouter une archive","dropFilesOrClick":"Glissez des fichiers ici ou cliquez pour importer","clickToUpload":"Cliquez pour importer","maxSize":"Taille max : {{size}}","selectFileToUpload":"Sélectionnez un fichier à importer","allowed":"Autorisés : {{types}}","upload":"Importer","browse":"Parcourir","cancel":"Annuler","change":"Changer","remove":"Supprimer","uploading":"Import en cours...","uploadFailed":"Échec de l'import. Veuillez réessayer.","mediaAssetNotFound":"Le fichier média n'existe plus","failedToLoadAsset":"Échec du chargement du fichier média","removeBrokenReference":"Supprimer la référence média cassée","changeMedia":"Changer le média","removeMedia":"Supprimer le média","mediaDetails":"Détails du média","altText":"Texte alternatif","altTextPlaceholder":"Décrivez cette image pour l'accessibilité","caption":"Légende","captionPlaceholder":"Ajouter une légende","titleOverride":"Titre personnalisé","titleOverridePlaceholder":"Remplacer le titre du fichier pour cet usage","mediaTypes":{"image":"Image","video":"Vidéo","audio":"Audio","document":"Document","archive":"Archive","media":"Média"},"unknownSize":"Taille inconnue"}}`),validation:{required:`Ce champ est obligatoire`,minLength:`Doit contenir au moins {{min}} caractères`,maxLength:`Ne doit pas dépasser {{max}} caractères`,min:`Doit être au moins {{min}}`,max:`Ne doit pas dépasser {{max}}`,pattern:`Format invalide`,email:`Doit être une adresse e-mail valide`,url:`Doit être une URL valide`,unique:`Cette valeur doit être unique`,invalidType:`Type de valeur invalide`,invalidDate:`Date invalide`,invalidNumber:`Doit être un nombre valide`,invalidInteger:`Doit être un nombre entier`,positive:`Doit être un nombre positif`,negative:`Doit être un nombre négatif`,fileSize:`La taille du fichier doit être inférieure à {{max}}`,fileType:`Type de fichier invalide`,imageSize:`Les dimensions de l'image doivent être {{width}}x{{height}} ou moins`},richtext:{bold:`Gras`,italic:`Italique`,underline:`Souligné`,strikethrough:`Barré`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,paragraph:`Paragraphe`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,blockquote:`Citation`,codeBlock:`Bloc de code`,link:`Lien`,image:`Image`,table:`Tableau`,undo:`Annuler`,redo:`Rétablir`,clear:`Effacer le formatage`},noValue:`Aucune valeur`,errors:{invalidFieldConfig:`Configuration de champ invalide : champ {{type}} attendu`,definitionMissing:`Erreur : Définition de champ manquante`},autoFields:{_thumbnail:{title:`Image à la une`,description:`Image principale représentant ce contenu`},slug:{title:`URL`,description:`Identifiant compatible URL pour ce contenu`}},common:{validating:`Validation en cours...`},modal:{close:`Fermer`,done:`Terminé`,noFieldsDefined:`Aucun champ défini`}},auth:{login:{title:`Connexion`,subtitle:`Bon retour`,emailOrUsername:`E-mail ou nom d'utilisateur`,password:`Mot de passe`,rememberMe:`Rester connecté`,forgotPassword:`Mot de passe oublié ?`,signIn:`Se connecter`,signingIn:`Connexion en cours...`,orContinueWith:`ou continuer avec`,backToLogin:`Retour à la connexion`},logout:{title:`Déconnexion`,confirm:`Êtes-vous sûr de vouloir vous déconnecter ?`,success:`Vous avez été déconnecté`},forgotPassword:{title:`Mot de passe oublié`,subtitle:`Entrez votre e-mail pour recevoir un lien de réinitialisation`,email:`Adresse e-mail`,sendLink:`Envoyer le lien de réinitialisation`,sending:`Envoi en cours...`,success:`Si un compte existe avec cet e-mail, vous recevrez bientôt un lien de réinitialisation.`,backToLogin:`Retour à la connexion`},resetPassword:{title:`Réinitialiser le mot de passe`,subtitle:`Entrez votre nouveau mot de passe`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le mot de passe`,reset:`Réinitialiser le mot de passe`,resetting:`Réinitialisation...`,success:`Votre mot de passe a été réinitialisé avec succès`,invalidToken:`Jeton de réinitialisation invalide ou expiré`,passwordMismatch:`Les mots de passe ne correspondent pas`},changePassword:{title:`Changer le mot de passe`,currentPassword:`Mot de passe actuel`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,change:`Changer le mot de passe`,changing:`Changement en cours...`,success:`Mot de passe changé avec succès !`,minLength:`Au moins 8 caractères`,errors:{currentRequired:`Le mot de passe actuel est requis`,newRequired:`Le nouveau mot de passe est requis`,minLength:`Le nouveau mot de passe doit contenir au moins 8 caractères`,mismatch:`Les mots de passe ne correspondent pas`,samePassword:`Le nouveau mot de passe doit être différent du mot de passe actuel`,failed:`Échec du changement de mot de passe`}},mfa:{title:`Authentification à deux facteurs`,required:`Authentification à deux facteurs requise`,setupRequired:`Votre organisation exige l'authentification MFA. Veuillez configurer l'authentification à deux facteurs pour continuer.`,chooseMethod:`Choisissez votre méthode d'authentification préférée :`,authenticatorApp:`Application d'authentification`,authenticatorAppDesc:`Utilisez Google Authenticator, Authy, etc.`,emailCode:`Code par e-mail`,emailCodeDesc:`Recevez un code par e-mail`,scanQR:`Scannez ce code QR avec votre application d'authentification :`,manualEntry:`Ou entrez ce code manuellement :`,enterCode:`Entrez le code à 6 chiffres de votre application :`,enterEmailCode:`Entrez le code à 6 chiffres :`,emailSent:`Nous avons envoyé un code de vérification à votre adresse e-mail.`,verify:`Vérifier`,verifying:`Vérification...`,verifyComplete:`Vérifier et terminer la configuration`,chooseDifferent:`Choisir une autre méthode`,invalidCode:`Code de vérification invalide`,codeExpired:`Le code a expiré`,backupCodes:{title:`Enregistrez vos codes de secours`,description:`Ces codes peuvent être utilisés pour accéder à votre compte si vous perdez votre authentificateur. Chaque code ne peut être utilisé qu'une seule fois.`,copy:`Copier les codes`,warning:`Important : Conservez ces codes en lieu sûr. Vous ne pourrez plus les voir après cette page.`,continue:`J'ai enregistré mes codes - Continuer vers le tableau de bord`}},oauth:{google:`Continuer avec Google`,signInWith:`Se connecter avec {{provider}}`},session:{expired:`Votre session a expiré. Veuillez vous reconnecter.`,invalid:`Session invalide. Veuillez vous reconnecter.`},errors:{invalidCredentials:`E-mail ou mot de passe invalide`,accountLocked:`Le compte a été verrouillé. Veuillez contacter le support.`,accountDisabled:`Le compte a été désactivé`,tooManyAttempts:`Trop de tentatives échouées. Veuillez réessayer plus tard.`,networkError:`Erreur réseau. Veuillez vérifier votre connexion.`,serverError:`Erreur serveur. Veuillez réessayer plus tard.`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,unauthorized:`Vous n'êtes pas autorisé à effectuer cette action`},advanced:{title:`Avancé`,backendUrl:`URL du serveur`,customEndpoint:`Point de terminaison API personnalisé`}},errors:{codes:{DOCUMENT_NOT_FOUND:`Document non trouvé`,SCHEMA_NOT_FOUND:`Schéma non trouvé`,VALIDATION_FAILED:`Échec de la validation`,UNAUTHORIZED:`Vous n'êtes pas autorisé à effectuer cette action`,FORBIDDEN:`Accès refusé`,NOT_FOUND:`Ressource non trouvée`,CONFLICT:`Un conflit s'est produit`,INTERNAL_ERROR:`Une erreur interne s'est produite`,NETWORK_ERROR:`Erreur réseau. Veuillez vérifier votre connexion.`,TIMEOUT:`Délai d'attente dépassé. Veuillez réessayer.`,RATE_LIMITED:`Trop de requêtes. Veuillez ralentir.`,INVALID_INPUT:`Donnée d'entrée invalide`,DUPLICATE_ENTRY:`Cette entrée existe déjà`,FILE_TOO_LARGE:`La taille du fichier dépasse le maximum autorisé`,INVALID_FILE_TYPE:`Ce type de fichier n'est pas autorisé`,UPLOAD_FAILED:`Échec de l'import du fichier`,DELETE_FAILED:`Échec de la suppression de l'élément`,UPDATE_FAILED:`Échec de la mise à jour de l'élément`,CREATE_FAILED:`Échec de la création de l'élément`,SESSION_EXPIRED:`Votre session a expiré. Veuillez vous reconnecter.`,INVALID_TOKEN:`Jeton invalide ou expiré`,MFA_REQUIRED:`Authentification multi-facteurs requise`,MFA_INVALID:`Jeton MFA invalide ou expiré`,MFA_CODE_INVALID:`Code de vérification invalide`,PASSWORD_TOO_WEAK:`Le mot de passe ne répond pas aux exigences de sécurité`,USER_NOT_FOUND:`Utilisateur non trouvé`,USER_ALREADY_EXISTS:`Un utilisateur avec cet e-mail existe déjà`,EMAIL_NOT_VERIFIED:`Adresse e-mail non vérifiée`,PERMISSION_DENIED:`Vous n'avez pas la permission d'effectuer cette action`,MEDIA_NOT_FOUND:`Fichier média non trouvé`,WEBHOOK_DELIVERY_FAILED:`Échec de la livraison du webhook`},generic:{title:`Erreur`,unknown:`Une erreur inattendue s'est produite`,tryAgain:`Veuillez réessayer`,contactSupport:`Si le problème persiste, veuillez contacter le support`,goBack:`Retour`,refresh:`Actualiser la page`},form:{invalidField:`{{field}} est invalide`,requiredField:`{{field}} est requis`,fieldTooLong:`{{field}} est trop long`,fieldTooShort:`{{field}} est trop court`},api:{fetchError:`Échec de la récupération des données`,saveError:`Échec de l'enregistrement des données`,deleteError:`Échec de la suppression des données`,connectionError:`Impossible de se connecter au serveur`}}}},pr=`trokky_language`;function mr(e){return ur.includes(e)}function hr(){if(typeof window>`u`)return null;let e=localStorage.getItem(pr);return e&&mr(e)?e:null}function gr(e){typeof window>`u`||localStorage.setItem(pr,e)}var _r=null;function vr(e={}){let{defaultLocale:t=`en`,fallbackLocale:n=`en`,detectBrowserLanguage:r=!0,debug:i=!1}=e;return _r||(r&&typeof window<`u`&&Rn.use(cr),Rn.use(Pt).init({resources:fr,lng:hr()||t,fallbackLng:n,defaultNS:lr,ns:[`common`,`studio`,`fields`,`auth`,`errors`],interpolation:{escapeValue:!1},detection:r?{order:[`localStorage`,`navigator`,`htmlTag`],lookupLocalStorage:pr,caches:[`localStorage`]}:void 0,debug:i,saveMissing:i,missingKeyHandler:i?(e,t,n)=>{console.warn(`[i18n] Missing translation: ${t}:${n} for ${e.join(`, `)}`)}:void 0}),_r=Rn,Rn)}function yr(){return Rn.isInitialized||vr(),Rn}function br({children:e,config:t,initialLocale:n,onLanguageChange:r}){let i=(0,B.useMemo)(()=>{let e=vr(t);return n&&(e.changeLanguage(n),gr(n)),e},[t,n]);return(0,B.useEffect)(()=>{if(!r)return;let e=e=>{r(e)};return i.on(`languageChanged`,e),()=>{i.off(`languageChanged`,e)}},[i,r]),(0,V.jsx)(Vt,{i18n:i,children:e})}function H(e=`common`,t){return Bt(e,t)}function xr(){let{i18n:e}=Bt();return{locale:e.language,setLocale:(0,B.useCallback)(t=>{mr(t)?(e.changeLanguage(t),gr(t)):console.warn(`[i18n] Attempted to set unsupported locale: ${t}`)},[e]),locales:ur,getLocaleName:(0,B.useCallback)(e=>dr[e]||e,[]),i18n:e}}function Sr(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Sr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Cr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Sr(e))&&(r&&(r+=` `),r+=t);return r}function wr(...e){return Cr(e)}function U({variant:e=`primary`,size:t=`md`,loading:n=!1,asChild:r=!1,className:i,disabled:a,children:o,...s}){let c=`inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,l={primary:`bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500`,secondary:`bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500`,outline:`border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 focus:ring-primary-500`,ghost:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-primary-500`,danger:`bg-red-600 text-white hover:bg-red-700 focus:ring-red-500`},u={sm:`px-3 py-1.5 text-sm`,md:`px-4 py-2 text-sm`,lg:`px-6 py-3 text-base`};if(r){let r=o;return B.cloneElement(r,{className:wr(c,l[e],u[t],r.props.className,i),disabled:a||n,...s})}return(0,V.jsxs)(`button`,{className:wr(c,l[e],u[t],i),disabled:a||n,...s,children:[n&&(0,V.jsxs)(`svg`,{className:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,V.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,V.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),o]})}var Tr=`trokky_auth_token`,Er=`trokky_refresh_token`;function Dr(e){try{return localStorage.getItem(e)}catch{return null}}function Or(e,t){try{localStorage.setItem(e,t)}catch{}}function kr(e){try{localStorage.removeItem(e)}catch{}}var Ar=new class{tokens;listeners=new Set;refresher=null;inFlight=null;session=0;constructor(){this.tokens={token:Dr(Tr),refreshToken:Dr(Er)}}getTokens(){return{...this.tokens}}getToken(){return this.tokens.token}getRefreshToken(){return this.tokens.refreshToken}persist(e,t){this.tokens.token=e,Or(Tr,e),t&&(this.tokens.refreshToken=t,Or(Er,t)),this.emit()}clear(){this.session+=1,this.inFlight=null,this.tokens={token:null,refreshToken:null},kr(Tr),kr(Er),this.emit()}emit(){let e=this.getTokens();this.listeners.forEach(t=>t(e))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setRefresher(e){this.refresher=e}async refresh(){if(this.inFlight)return this.inFlight;let e=this.tokens.refreshToken;if(!e||!this.refresher)return null;let t=this.session;return this.inFlight=(async()=>{try{let n=await this.refresher(e);return t===this.session?n?.token?(this.persist(n.token,n.refreshToken),n):(this.clear(),null):null}catch{return t===this.session&&this.clear(),null}finally{t===this.session&&(this.inFlight=null)}})(),this.inFlight}},jr=class extends Error{status;code;details;constructor(e,t,n,r){super(e),this.status=t,this.code=n,this.details=r,this.name=`ApiClientError`}},Mr={debug:0,info:1,warn:2,error:3},Nr=typeof window<`u`&&window.__TROKKY_DEV__===!0?`warn`:`error`,Pr=class{config;constructor(e,t={}){this.config={level:Nr,enabled:!0,prefix:`[Studio:${e}]`,...t}}shouldLog(e){return this.config.enabled&&Mr[e]>=Mr[Nr]}formatMessage(e,t){return`${this.config.prefix}[${e}] ${t}`}debug(e,t){if(this.shouldLog(`debug`)){let n=this.formatMessage(`debug`,e);t?console.debug(n,t):console.debug(n)}}info(e,t){if(this.shouldLog(`info`)){let n=this.formatMessage(`info`,e);t?console.info(n,t):console.info(n)}}warn(e,t){if(this.shouldLog(`warn`)){let n=this.formatMessage(`warn`,e);t?console.warn(n,t):console.warn(n)}}error(e,t){if(this.shouldLog(`error`)){let n=this.formatMessage(`error`,e);t instanceof Error||t?console.error(n,t):console.error(n)}}};function Fr(e){return new Pr(e)}typeof window<`u`&&window.__TROKKY_LOG_LEVEL__&&(Nr=window.__TROKKY_LOG_LEVEL__),typeof window<`u`&&(window.TrokkyLogger={setLevel(e){Nr=e,typeof window<`u`&&(window.__TROKKY_LOG_LEVEL__=e)},getLevel(){return Nr},disable(){Nr=`error`},enable(){Nr=typeof window<`u`&&window.__TROKKY_DEV__===!0?`warn`:`error`}});var Ir=Fr(`Storage`),Lr={AUTH_TOKEN:`trokky_auth_token`,REFRESH_TOKEN:`trokky_refresh_token`,USER_DATA:`trokky_user_data`,THEME:`trokky_theme`,SIDEBAR_COLLAPSED:`trokky_sidebar_collapsed`,SIDEBAR_WIDTH:`trokky_sidebar_width`,CONTENT_VIEW:e=>`trokky_view_${e}`,COLUMN_VISIBILITY:e=>`trokky_columns_${e}`,GRID_SETTINGS:e=>`trokky_grid_${e}`,TABLE_SETTINGS:e=>`trokky_table_${e}`,STUDIO_CONFIG:`trokky_studio_config`,STRUCTURE_CACHE:`trokky_structure_cache`,DEBUG_ENABLED:`trokky_debug_enabled`,BACKEND_URL:`trokky_backend_url`,MEDIA_VIEW_MODE:`trokky_media_view_mode`,CONTEXT_SIDEBAR_VISIBLE:e=>`trokky_context_sidebar_${e}_visible`,CONTEXT_SIDEBAR_COLLAPSED:e=>`trokky_context_sidebar_${e}_collapsed`,CONTEXT_SIDEBAR_WIDTH:e=>`trokky_context_sidebar_${e}_width`,CONTEXT_SIDEBAR_POSITION:e=>`trokky_context_sidebar_${e}_position`,DOCUMENT_SIDEBAR_COLLAPSED:`trokky_document_sidebar_collapsed`,RECENT_SEARCHES:`trokky_recent_searches`},Rr=new class{isAvailable(){try{return typeof localStorage<`u`&&localStorage!==null}catch{return!1}}get(e,t){if(!this.isAvailable())return Ir.warn(`localStorage not available, returning default value`),t??null;try{let n=localStorage.getItem(e);if(n===null)return t??null;try{return JSON.parse(n)}catch{return n}}catch(n){return Ir.error(`Failed to get item from localStorage`,{key:e,error:n}),t??null}}set(e,t){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot set value`),!1;try{let n=typeof t==`string`?t:JSON.stringify(t);return localStorage.setItem(e,n),!0}catch(t){return Ir.error(`Failed to set item in localStorage`,{key:e,error:t}),!1}}remove(e){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot remove value`),!1;try{return localStorage.removeItem(e),!0}catch(t){return Ir.error(`Failed to remove item from localStorage`,{key:e,error:t}),!1}}exists(e){if(!this.isAvailable())return!1;try{return localStorage.getItem(e)!==null}catch{return!1}}clear(e){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot clear values`),!1;try{if(e){let t=this.getAllKeys().filter(t=>t.includes(e));t.forEach(e=>localStorage.removeItem(e)),Ir.info(`Cleared ${t.length} items matching pattern: ${e}`)}else{let e=this.getAllKeys().filter(e=>e.startsWith(`trokky_`));e.forEach(e=>localStorage.removeItem(e)),Ir.info(`Cleared ${e.length} trokky items`)}return!0}catch(t){return Ir.error(`Failed to clear localStorage`,{pattern:e,error:t}),!1}}getAllKeys(){if(!this.isAvailable())return[];try{return Object.keys(localStorage)}catch{return[]}}},zr={getContentView:(e,t=`list`)=>Rr.get(Lr.CONTENT_VIEW(e),t),setContentView:(e,t)=>Rr.set(Lr.CONTENT_VIEW(e),t),getColumnVisibility:(e,t={})=>Rr.get(Lr.COLUMN_VISIBILITY(e),t),setColumnVisibility:(e,t)=>Rr.set(Lr.COLUMN_VISIBILITY(e),t),getGridSettings:(e,t={cardSize:`medium`,columnsPerRow:null})=>Rr.get(Lr.GRID_SETTINGS(e),t),setGridSettings:(e,t)=>Rr.set(Lr.GRID_SETTINGS(e),t),getTableSettings:(e,t={density:`comfortable`,columnWidths:{}})=>Rr.get(Lr.TABLE_SETTINGS(e),t),setTableSettings:(e,t)=>Rr.set(Lr.TABLE_SETTINGS(e),t),getTheme:()=>Rr.get(Lr.THEME,`light`),setTheme:e=>Rr.set(Lr.THEME,e),getSidebarCollapsed:()=>Rr.get(Lr.SIDEBAR_COLLAPSED,!1),setSidebarCollapsed:e=>Rr.set(Lr.SIDEBAR_COLLAPSED,e),getSidebarWidth:()=>Rr.get(Lr.SIDEBAR_WIDTH,280),setSidebarWidth:e=>Rr.set(Lr.SIDEBAR_WIDTH,e),clearAll:()=>Rr.clear(),clearSchema:e=>Rr.clear(e),service:Rr},Br=[`/auth/refresh`,`/auth/validate`,`/auth/login`,`/auth/logout`],Vr=class{backendUrl=``;capabilities=null;logger=Fr(`ApiClient`);configured=!1;onUnauthorized=null;constructor(e){e&&(this.backendUrl=e,this.configured=!0)}get authToken(){return Ar.getToken()}initialize(){if(this.configured)return;this.configured=!0;let e=window.TROKKY_CONFIG?.backendUrl,t=Rr.get(Lr.BACKEND_URL);e?(this.setBackendUrl(e),t&&t!==e&&(Rr.remove(Lr.BACKEND_URL),this.logger.debug(`Cleared stale backend URL from localStorage`))):t?this.setBackendUrl(t):this.logger.info(`No backend URL configured. User will need to set it in login form.`),this.logger.info(`Studio initialized`,{backendUrl:this.backendUrl,hasAuthToken:!!this.authToken})}ensureConfigured(){this.configured||this.initialize()}setBackendUrl(e){this.backendUrl=e.replace(/\/$/,``),this.updateCapabilities(),this.logger.info(`Backend URL set`,{backendUrl:this.backendUrl})}updateCapabilities(){this.capabilities={version:`2.0.0`,features:{search:!1,media:!0,auth:!0,structure:!0,workflows:!1},endpoints:{documents:`/collections`,auth:`/auth`,structure:`/structure`,slugs:`/slugs`},limits:{maxUploadSize:104857600,maxResults:100,requestRate:1e3}}}get isInitialized(){return!!this.backendUrl&&!!this.capabilities}getCapabilities(){return this.capabilities}hasFeature(e){return this.capabilities?.features[e]??!1}setAuthToken(e){Ar.persist(e)}clearAuthToken(){Ar.clear()}async storeTokens(e,t){Ar.persist(e,t)}async request(e,t={},n=!1,r=!1){if(this.ensureConfigured(),!this.backendUrl)return{success:!1,error:{message:`Backend URL not configured. Please configure it in the login form.`,code:`NO_BACKEND_URL`}};let i=this.buildUrl(e),a={Accept:`application/json`,...t.headers||{}};t.body instanceof FormData||(a[`Content-Type`]=`application/json`),this.authToken&&!n&&(a.Authorization=`Bearer ${this.authToken}`);try{let o=await fetch(i,{...t,headers:a,credentials:`include`});if(!o.headers.get(`content-type`)?.includes(`application/json`)){if(!o.ok)throw new jr(`HTTP ${o.status}: ${o.statusText}`,o.status);return{success:!0,data:null}}let s=await o.json();if(!o.ok){if(o.status===401&&this.authToken&&!n&&!r&&!Br.some(t=>e.includes(t))&&(await this.onUnauthorized?.()??!1))return this.request(e,t,n,!0);throw new jr(s.error?.message||`HTTP ${o.status}`,o.status,s.error?.code,s.error?.details)}return{success:!0,data:s.data||s,meta:s.meta}}catch(e){throw e instanceof jr?e:new jr(`Network error: ${e instanceof Error?e.message:`Unknown error`}`)}}buildUrl(e){if(e.startsWith(`http`))return e;if(this.ensureConfigured(),!this.backendUrl)throw this.logger.warn(`Backend URL not set, cannot build URL for endpoint:`,e),new jr(`Backend URL not configured. Please set the backend URL.`);let t=e.startsWith(`/`)?e.slice(1):e,n=t?`${this.backendUrl}/${t}`:this.backendUrl;return this.logger.debug(`Building URL:`,{originalEndpoint:e,cleanEndpoint:t,backendUrl:this.backendUrl,finalUrl:n}),n}async get(e,t){let n=new URL(this.buildUrl(e));return t&&Object.entries(t).forEach(([e,t])=>{t!=null&&n.searchParams.append(e,String(t))}),this.request(n.toString(),{method:`GET`})}async post(e,t,n){return this.request(e,{method:`POST`,body:t?JSON.stringify(t):void 0,headers:n?.headers,signal:n?.signal})}async put(e,t){return this.request(e,{method:`PUT`,body:t?JSON.stringify(t):void 0})}async patch(e,t){return this.request(e,{method:`PATCH`,body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:`DELETE`})}};function Hr(e,t,n){return t?n?`${e}/media/${t}/variants/${n}`:`${e}/media/${t}/file`:``}function Ur(e,t,n=(t,n)=>Hr(e,t,n)){return!t||!t.id?t:{...t,url:n(t.id),...t.variants&&{variants:Object.keys(t.variants).reduce((e,r)=>(e[r]={...t.variants[r],url:n(t.id,r)},e),{})}}}async function Wr(e,t,n={}){let r=[];if(!n.types||n.types.includes(`documents`))try{let n=await e.getSchemas();if(n.success&&n.data)for(let i of n.data.slice(0,3)){let n=await e.getDocuments(i.name,{limit:5,search:t});n.success&&n.data?.documents&&r.push(...n.data.documents.map(e=>({id:e.id||e._id,type:`document`,title:e.title||e.name||e.id||e._id,url:`/content/${i.name}/${e.id||e._id}`,metadata:{status:e._status,createdAt:e._createdAt}})))}}catch(e){console.warn(`Document search failed:`,e)}return{success:!0,data:{results:r.slice(0,n.limit||20),totalCount:r.length,categories:{documents:r.filter(e=>e.type===`document`).length,media:0,users:0,schemas:0},query:t,searchTime:0}}}var W=new class extends Vr{async getSchemas(){let e=await this.get(`/collections`);return e.success&&e.data?.collections?{success:!0,data:e.data.collections,meta:e.meta}:{success:!1,data:[]}}async getSchema(e){return this.get(`/schemas/${e}`)}async getDocuments(e,t={}){return this.get(`/collections/${e}`,t)}async getDocument(e,t){return this.get(`/collections/${e}/${t}`)}async createDocument(e,t){return this.post(`/collections/${e}`,{data:t})}async updateDocument(e,t,n){return this.put(`/collections/${e}/${t}`,{data:n})}async deleteDocument(e,t){return this.delete(`/collections/${e}/${t}`)}async getMedia(e={}){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let t=await this.get(`/media`,e);return t.success&&t.data&&(t.data=t.data.map(e=>this.transformMediaObject(e))),t}async getMediaFile(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let t=await this.get(`/media/${e}`);return t.success&&t.data?.file&&(t.data.file=this.transformMediaObject(t.data.file)),t}async getMediaById(e){return this.getMediaFile(e)}async downloadMediaFile(e){this.ensureConfigured();let t={};this.authToken&&(t.Authorization=`Bearer ${this.authToken}`);let n=await fetch(this.buildUrl(`/media/${e}/file`),{headers:t,credentials:`include`});if(!n.ok)throw new jr(`HTTP ${n.status}: ${n.statusText}`,n.status);return n.blob()}async uploadMedia(e,t,n){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let r=n;t&&typeof t==`object`&&!n&&(r=t);let i=new FormData;i.append(`files`,e),r&&i.append(`metadata`,JSON.stringify(r));let a=await this.request(`/media/upload`,{method:`POST`,body:i});return a.success&&a.data&&(a.data=this.transformMediaObject(a.data)),a}async updateMedia(e,t){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let n=await this.put(`/media/${e}`,{metadata:t});return n.success&&n.data?.file&&(n.data.file=this.transformMediaObject(n.data.file)),n}async deleteMedia(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.delete(`/media/${e}`)}async bulkDeleteMedia(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.post(`/media/bulk-delete`,{ids:e})}async regenerateMediaVariants(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.post(`/media/${e}/regenerate-variants`,{})}transformMediaObject(e){return Ur(this.backendUrl,e,(e,t)=>this.getMediaUrl(e,t))}getMediaUrl(e,t){return Hr(this.backendUrl,e,t)}getBackendUrl(){return this.ensureConfigured(),this.backendUrl}getApiBasePath(){return this.backendUrl}async listDocuments(e,t={}){let n=new URLSearchParams;t.page&&n.set(`page`,String(t.page)),t.limit&&n.set(`limit`,String(t.limit)),t.search&&n.set(`search`,t.search),t.sort&&n.set(`sort`,t.sort),t.filter&&Object.entries(t.filter).forEach(([e,t])=>{t!=null&&t!==``&&n.set(`filter[${e}]`,String(t))});let r=`/collections/${e}${n.toString()?`?${n.toString()}`:``}`;return this.get(r)}async getCollectionStats(e){return this.get(`/stats/${e}`)}async search(e,t={}){return this.hasFeature(`search`)?this.get(`/search`,{q:e,...t}):this.clientSideSearch(e,t)}async clientSideSearch(e,t={}){return Wr(this,e,t)}async getCurrentUser(){if(!this.hasFeature(`auth`))throw new jr(`Auth feature not available`);return this.get(`/auth/me`)}async login(e,t,n,r,i){if(!this.hasFeature(`auth`))throw new jr(`Auth feature not available`);let a=await this.post(`/auth/login`,{username:e,password:t,rememberMe:n,deviceId:r,captchaToken:i});return a.success&&a.data?.token&&this.setAuthToken(a.data.token),a}async logout(){if(this.hasFeature(`auth`))try{await this.post(`/auth/logout`)}catch(e){console.warn(`Server logout failed:`,e)}return this.clearAuthToken(),{success:!0}}async checkSlugUniqueness(e,t,n){let r=new URLSearchParams({slug:e,collection:t});return n&&r.append(`excludeId`,n),this.get(`/slugs/check-unique?${r}`)}async getStructure(){return this.hasFeature(`structure`)?this.get(`/structure`):{success:!0,data:null}}};Ar.setRefresher(async e=>{let t=await W.post(`/auth/refresh`,{refreshToken:e});return t.success&&t.data?.token?t.data:null});var Gr=class{client;constructor(e){this.client=e}async generateFromSchemas(e={}){try{let t=await this.client.getSchemas();if(!t.success||!t.data)throw Error(`Failed to fetch schemas`);let n=t.data,{includeSchemas:r,excludeSchemas:i=[],groupBy:a=`none`,defaultPageSize:o=25}=e,s=n;r&&(s=n.filter(e=>r.includes(e.name))),s=s.filter(e=>!i.includes(e.name));let c=[];if(a===`none`)for(let e of s)c.push(this.createDocumentListItem(e,o));else{let e=this.groupSchemas(s,a);for(let[t,n]of Object.entries(e))n.length===1?c.push(this.createDocumentListItem(n[0],o)):c.push({type:`group`,title:this.formatGroupTitle(t),icon:this.getGroupIcon(t),items:n.map(e=>this.createDocumentListItem(e,o)),collapsible:!0,defaultCollapsed:!1})}return{title:`Content Management`,items:c,metadata:{version:`1.0.0`,description:`Auto-generated structure from schemas`}}}catch(e){return console.error(`Failed to generate structure from schemas:`,e),this.getFallbackStructure()}}buildNavigation(e,t){let n=[],r=0,i=0,a=(e,n=0)=>{switch(i=Math.max(i,n),r++,e.type){case`documentList`:return{id:e.id||`list-${e.schemaType}`,title:e.title,type:`documentList`,icon:e.icon||`document-text`,path:`/content/${e.schemaType}`,active:t===`/content/${e.schemaType}`,metadata:{schemaType:e.schemaType,filter:e.filter}};case`singleton`:let i=e.documentId||`singleton`;return{id:e.id||`singleton-${e.schemaType}`,title:e.title,type:`singleton`,icon:e.icon||`cog`,path:`/content/${e.schemaType}/${i}`,active:t===`/content/${e.schemaType}/${i}`,metadata:{schemaType:e.schemaType,documentId:i}};case`group`:let o=[];for(let t of e.items){let e=a(t,n+1);e&&o.push(e)}return{id:e.id||`group-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,title:e.title,type:`group`,icon:e.icon||`folder`,children:o,metadata:{collapsible:e.collapsible,defaultCollapsed:e.defaultCollapsed}};case`divider`:return{id:`divider-${r}`,title:e.title||``,type:`divider`};default:return null}};for(let t of e.items){let e=a(t);e&&n.push(e)}return{items:n,metadata:{totalItems:r,maxDepth:i}}}validate(e){let t=[];return e.title||t.push(`Structure title is required`),Array.isArray(e.items)?e.items.forEach((e,n)=>{this.validateItem(e,`items[${n}]`,t)}):t.push(`Structure items must be an array`),{isValid:t.length===0,errors:t}}validateItem(e,t,n){if(!e.type){n.push(`${t}: Item type is required`);return}switch(e.type){case`documentList`:case`singleton`:e.title||n.push(`${t}: Title is required`),e.schemaType||n.push(`${t}: Schema type is required`);break;case`group`:e.title||n.push(`${t}: Group title is required`),Array.isArray(e.items)?e.items.forEach((e,r)=>{this.validateItem(e,`${t}.items[${r}]`,n)}):n.push(`${t}: Group items must be an array`);break;case`divider`:break;default:n.push(`${t}: Unknown item type "${e.type}"`)}}createDocumentListItem(e,t){return{type:`documentList`,title:this.formatSchemaTitle(e.name),schemaType:e.name,icon:this.getSchemaIcon(e),defaultOrdering:[{field:`updatedAt`,direction:`desc`}],options:{pageSize:t,searchable:!0,searchFields:this.getSearchableFields(e)}}}groupSchemas(e,t){let n={};for(let r of e){let e=`Content`;t===`type`?e=r.singleton?`Settings`:`Content`:t===`category`&&(e=r.category||`Content`),n[e]||(n[e]=[]),n[e].push(r)}return n}formatSchemaTitle(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}formatGroupTitle(e){return e.charAt(0).toUpperCase()+e.slice(1)}getSchemaIcon(e){let t=e.name.toLowerCase();return t.includes(`post`)||t.includes(`article`)?`document-text`:t.includes(`page`)?`document`:t.includes(`user`)||t.includes(`author`)?`user`:t.includes(`category`)||t.includes(`tag`)?`tag`:t.includes(`media`)||t.includes(`image`)?`photo`:t.includes(`setting`)||t.includes(`config`)?`cog`:t.includes(`menu`)||t.includes(`navigation`)?`menu`:`document-text`}getGroupIcon(e){let t=e.toLowerCase();return t.includes(`content`)?`document-text`:t.includes(`setting`)?`cog`:t.includes(`user`)||t.includes(`people`)?`users`:t.includes(`media`)?`photo`:`folder`}getSearchableFields(e){let t=[`title`,`name`,`slug`];return e.fields?Object.keys(e.fields).filter(e=>t.some(t=>e.toLowerCase().includes(t))):[`title`]}getFallbackStructure(){return{title:`Content Management`,items:[{type:`documentList`,title:`Posts`,schemaType:`post`,icon:`document-text`,defaultOrdering:[{field:`updatedAt`,direction:`desc`}],options:{pageSize:25,searchable:!0,searchFields:[`title`]}},{type:`documentList`,title:`Authors`,schemaType:`author`,icon:`user`,defaultOrdering:[{field:`name`,direction:`asc`}],options:{pageSize:25,searchable:!0,searchFields:[`name`]}},{type:`singleton`,title:`Settings`,schemaType:`settings`,documentId:`site-settings`,icon:`cog`,options:{autoCreate:!0}}],metadata:{version:`1.0.0`,description:`Fallback structure`}}}},Kr=Fr(`structure-service`),qr=class{client;builder;cachedStructure=null;cachedNavigation=null;constructor(e){this.client=e,this.builder=new Gr(e)}async getStructure(e){if(!this.cachedStructure){try{let e=await this.client.get(`/config/structure`);if(e.success&&e.data)return this.cachedStructure=e.data.structure,Kr.debug(`Structure loaded from API endpoint`,{title:this.cachedStructure?.title,itemCount:this.cachedStructure?.items?.length||0}),this.cachedStructure}catch(e){Kr.warn(`Failed to fetch structure from API endpoint, falling back`,e)}let t=window.TROKKY_CONFIG;t?.structure&&typeof t.structure==`object`?(this.cachedStructure=t.structure,Kr.debug(`Using static structure from window config`)):(this.cachedStructure=await this.builder.generateFromSchemas(e),Kr.debug(`Auto-generated structure from schemas`))}return this.cachedStructure}async getNavigation(e,t){let n=await this.getStructure(t);return(!this.cachedNavigation||e)&&(this.cachedNavigation=this.builder.buildNavigation(n,e)),this.cachedNavigation}setStructure(e){let t=this.builder.validate(e);if(!t.isValid)throw Error(`Invalid structure: ${t.errors.join(`, `)}`);this.cachedStructure=e,this.cachedNavigation=null}clearCache(){this.cachedStructure=null,this.cachedNavigation=null,Kr.debug(`Structure cache cleared`)}async refreshFromEndpoint(){try{let e=await this.client.get(`/config/structure`,{_refresh:Date.now()});return e.success&&e.data?(this.cachedStructure=e.data.structure,this.cachedNavigation=null,Kr.debug(`Structure refreshed from endpoint`,{title:this.cachedStructure.title,itemCount:this.cachedStructure.items?.length||0}),this.cachedStructure):null}catch(e){return Kr.error(`Failed to refresh structure from endpoint`,e),null}}isCached(){return this.cachedStructure!==null}async getStructureItemBySchema(e){let t=await this.getStructure(),n=t=>{for(let r of t)if(r.type===`documentList`||r.type===`singleton`){if(r.schemaType===e)return r}else if(r.type===`group`&&r.items){let e=n(r.items);if(e)return e}return null};return n(t.items)}async getDocumentListItems(){let e=await this.getStructure(),t=e=>{let n=[];for(let r of e)r.type===`documentList`?n.push(r):r.type===`group`&&r.items&&n.push(...t(r.items));return n};return t(e.items)}async getSingletonItems(){let e=await this.getStructure(),t=e=>{let n=[];for(let r of e)r.type===`singleton`?n.push(r):r.type===`group`&&r.items&&n.push(...t(r.items));return n};return t(e.items)}async validateStructure(){let e=await this.getStructure();return this.builder.validate(e)}},Jr=null;function Yr(e){return Jr||=new qr(e),Jr}function Xr(){if(!Jr)throw Error(`Structure service not initialized. Call createStructureService first.`);return Jr}function Zr(){Jr?.clearCache()}var Qr=Fr(`useAuth`),$r=()=>{let e=window.TROKKY_CONFIG?.sessionConfig;return{REFRESH_BUFFER_MS:e?.refreshBufferMs||3e4,WARNING_BUFFER_MS:e?.warningBufferMs||0,CHECK_INTERVAL_MS:e?.checkIntervalMs||3e4,DEFAULT_TIMEOUT_MS:e?.defaultTimeoutMs||72e5,EXTENDED_TIMEOUT_MS:e?.extendedTimeoutMs||6048e5,INACTIVITY_TIMEOUT_MS:e?.inactivityTimeoutMs||18e5}},ei=(0,B.createContext)(void 0),ti=()=>({isAuthenticated:!1,user:null,token:null,refreshToken:null,isLoading:!1,sessionExpiresAt:null,showTimeoutWarning:!1,lastActivity:new Date});function ni({children:e}){let[t,n]=(0,B.useState)({...ti(),isLoading:!0}),r=P(),i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=(0,B.useRef)(t);(0,B.useEffect)(()=>{o.current=t},[t]);let s=(0,B.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),a.current&&=(clearInterval(a.current),null)},[]),c=(0,B.useCallback)(()=>{s(),Ar.clear(),r.clear(),Zr(),n(ti())},[r,s]),l=(0,B.useCallback)(()=>{n(e=>({...e,lastActivity:new Date}))},[]),u=(0,B.useCallback)(async()=>{let e=await Ar.refresh();return e?(n(t=>({...t,token:e.token,refreshToken:Ar.getRefreshToken(),sessionExpiresAt:e.expiresAt?new Date(e.expiresAt):t.sessionExpiresAt,showTimeoutWarning:!1})),Qr.info(`Session refreshed successfully`),!0):(Qr.warn(`Session refresh failed, ending session`),c(),!1)},[c]),d=(0,B.useCallback)(e=>{if(!e)return;s();let t=$r();i.current=setInterval(()=>{let n=e.getTime()-Date.now();n<=t.REFRESH_BUFFER_MS&&n>0&&u(),n<=0&&(Qr.warn(`Session expired, forcing logout`),c())},t.CHECK_INTERVAL_MS),a.current=setInterval(()=>{Date.now()-o.current.lastActivity.getTime()>=t.INACTIVITY_TIMEOUT_MS&&(Qr.warn(`User inactive for too long, forcing logout`),c())},t.CHECK_INTERVAL_MS)},[c,u,s]),f=(0,B.useCallback)(async()=>{try{n(e=>({...e,isLoading:!0}));let{token:e,refreshToken:t}=Ar.getTokens();if(Qr.info(`Checking auth`,{hasStoredToken:!!e,hasRefreshToken:!!t}),!e){Qr.info(`No stored token, showing login page`),n(ti());return}let r=await W.post(`/auth/validate`,{token:e});if(r.success&&r.data&&typeof r.data==`object`&&`valid`in r.data&&r.data.valid&&`session`in r.data&&r.data.session){Qr.info(`Authentication validated successfully`);let i=r.data.session,a=i.expiresAt?new Date(i.expiresAt):null;n({isAuthenticated:!0,user:i?.user||i,token:e,refreshToken:t,isLoading:!1,sessionExpiresAt:a,showTimeoutWarning:!1,lastActivity:new Date}),d(a);return}let i=await Ar.refresh();if(i?.token){let e=i.expiresAt?new Date(i.expiresAt):null;n({isAuthenticated:!0,user:i.user??null,token:i.token,refreshToken:Ar.getRefreshToken(),isLoading:!1,sessionExpiresAt:e,showTimeoutWarning:!1,lastActivity:new Date}),d(e),Qr.info(`Session restored via refresh token`);return}Qr.warn(`Stored tokens are invalid, clearing auth state`),c()}catch(e){Qr.error(`Auth check failed`,e),c()}},[c,d]),p=(0,B.useCallback)(async(e,t,r=!1)=>{try{let i=await W.post(`/auth/login`,{username:e,password:t,rememberMe:r});if(i.success&&i.data&&typeof i.data==`object`&&`user`in i.data&&`token`in i.data&&`expiresAt`in i.data){let{user:t,token:a,refreshToken:o,expiresAt:s}=i.data;Qr.info(`User login successful`,{username:e,rememberMe:r}),Ar.persist(a,o);let c=new Date(s);return n({isAuthenticated:!0,user:t,token:a,refreshToken:o||null,isLoading:!1,sessionExpiresAt:c,showTimeoutWarning:!1,lastActivity:new Date}),d(c),{success:!0}}return Qr.warn(`Login failed`,{username:e,error:i.error?.message}),{success:!1,error:i.error?.message||`Login failed`}}catch(t){return Qr.error(`Login error`,{username:e,error:t}),{success:!1,error:t instanceof Error?t.message:`Login failed`}}},[d]),m=(0,B.useCallback)(async()=>{try{s();let e=Ar.getRefreshToken();e&&await W.post(`/auth/logout`,{refreshToken:e}),Qr.info(`User logout successful`)}catch(e){Qr.error(`Logout failed`,e)}finally{c()}},[c,s]),h=(0,B.useCallback)(()=>{n(e=>({...e,showTimeoutWarning:!1}))},[]),g=(0,B.useCallback)(e=>{n(t=>({...t,user:e}))},[]);(0,B.useEffect)(()=>(W.onUnauthorized=async()=>u(),()=>{W.onUnauthorized=null}),[u]),(0,B.useEffect)(()=>{if(!t.isAuthenticated)return;let e=[`mousedown`,`mousemove`,`keypress`,`scroll`,`touchstart`,`click`],n=()=>l();return e.forEach(e=>{document.addEventListener(e,n,{passive:!0})}),()=>{e.forEach(e=>{document.removeEventListener(e,n)})}},[t.isAuthenticated,l]),(0,B.useEffect)(()=>(f(),()=>{s()}),[]),(0,B.useEffect)(()=>{t.isAuthenticated&&t.sessionExpiresAt&&d(t.sessionExpiresAt)},[t.sessionExpiresAt,t.isAuthenticated,d]);let _={...t,login:p,logout:m,checkAuth:f,refreshSession:u,dismissTimeoutWarning:h,updateActivity:l,updateUser:g};return B.createElement(ei.Provider,{value:_},e)}function ri(){let e=(0,B.useContext)(ei);if(e===void 0)throw Error(`useAuth must be used within an AuthProvider`);return e}var ii=Fr(`useCurrentUser`),ai=[`auth`,`me`];async function oi(){let e=await W.getCurrentUser();if(!e.success||!e.data)throw Error(e.error?.message||`Failed to fetch user data`);return ii.debug(`Current user data loaded`,{username:e.data.username}),e.data}function si(){let e=P(),t=j({queryKey:ai,queryFn:oi}),n=(0,B.useCallback)(t=>{let n=e.getQueryData(ai);if(!n)return;let r={...n,...t};e.setQueryData(ai,r),window.dispatchEvent(new CustomEvent(`trokky:user:updated`,{detail:{user:r}})),ii.debug(`User data updated locally`,{userData:t})},[e]);(0,B.useEffect)(()=>{let t=t=>{let{user:n}=t.detail;ii.debug(`Received user update event`,{user:n}),e.setQueryData(ai,n)};return window.addEventListener(`trokky:user:updated`,t),()=>{window.removeEventListener(`trokky:user:updated`,t)}},[e]);let r=(0,B.useCallback)(async()=>{await t.refetch()},[t]);return{user:t.data??null,loading:t.isPending,error:t.error?t.error.message:null,refetch:r,updateUser:n}}function ci(){let{user:e,loading:t,error:n,refetch:r}=si(),i=e?.permissions||[],a=t=>e?e.role===`admin`||i.includes(t):!1,o=t=>e?e.role===`admin`||t.some(e=>i.includes(e)):!1,s=t=>e?e.role===`admin`||t.every(e=>i.includes(e)):!1,c=(t,n)=>{if(!e)return!1;if(e.role===`admin`)return!0;let r=`${t}:${n}`;if(i.includes(r))return!0;let a=`${t}:*`;return!!(i.includes(a)||![`users`,`settings`,`tokens`,`webhooks`,`media`].includes(t.toLowerCase())&&(i.includes(`content:*`)||i.includes(`content:${n}`))||i.includes(`*`))};return{user:e,loading:t,error:n,refetch:r,hasPermission:a,hasGlobalPermission:e=>a(e),hasAnyPermission:o,hasAllPermissions:s,hasSchemaPermission:c,hasAnySchemaPermission:(t,n)=>e?e.role===`admin`||n.some(e=>c(t,e)):!1,canDeleteDocument:(t,n)=>e?!!(c(t,`delete`)||n?._createdBy&&(n._createdBy===e.id||n._createdBy===e.username)):!1,canPublish:e?e.role===`admin`||i.includes(`content:*`)||i.includes(`content:publish`):!1,userPermissions:i,isAdmin:e?.role===`admin`,isEditor:e?.role===`editor`,isAuthor:e?.role===`author`,isWriter:e?.role===`writer`,isViewer:e?.role===`viewer`,userId:e?.id||null}}var li={READ:`media:read`,UPLOAD:`media:upload`,EDIT:`media:edit`,DELETE:`media:delete`},ui={READ:`users:read`,WRITE:`users:write`,DELETE:`users:delete`,INVITE:`users:invite`},di={READ:`settings:read`,WRITE:`settings:write`},fi={READ:`tokens:read`,WRITE:`tokens:write`,DELETE:`tokens:delete`},pi={READ:`webhooks:read`,WRITE:`webhooks:write`,DELETE:`webhooks:delete`,TEST:`webhooks:test`};Object.values(li),Object.values(ui),Object.values(di),Object.values(fi),Object.values(pi);var mi=[di.READ,ui.READ,fi.READ,pi.READ,di.WRITE];function hi(e){if(typeof e!=`number`||!Number.isFinite(e))return`Unknown size`;if(e===0)return`0 B`;if(e<0)return`Unknown size`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/t**r).toFixed(1))+` `+n[r]}function gi(e){if(e.metadata?.imageVariants){let t=e.metadata.imageVariants;if(t.thumbnail)return`thumbnail`;if(t.small)return`small`}}var _i=({className:e})=>(0,V.jsx)(`svg`,{className:e,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})});function vi(e){return e.startsWith(`image/`)?`image`:e.startsWith(`video/`)?`video`:e.startsWith(`audio/`)?`audio`:e.includes(`pdf`)||e.includes(`document`)||e.includes(`word`)||e.includes(`excel`)||e.includes(`powerpoint`)||e===`text/plain`?`document`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`7z`)||e.includes(`tar`)||e.includes(`gzip`)?`archive`:`document`}function yi(e){let t=`w-full h-full`;switch(e){case`image`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z`})});case`video`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z`})});case`audio`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3`})});case`document`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})});case`archive`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4`})});default:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z`})})}}function bi(e,t,n,r){if(n)return n.getMediaUrl(e.id,t);if(r?.getMediaUrl)return r.getMediaUrl(e.id,t);if(e.url)return e.url;throw Error(`Cannot generate URL for media ${e.id}${t?` variant ${t}`:``}`)}function xi({onSelect:e,mediaTypeFilter:t,apiClient:n,logger:r,mediaUrlGenerator:i}){let{t:a}=H(`studio`),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(`original`),[g,_]=(0,B.useState)(`grid`),[v,y]=(0,B.useState)(1);(0,B.useEffect)(()=>{b()},[]);let b=async()=>{l(!0);try{if(r?.debug(`MediaBrowser: apiClient received`,{apiClient:!!n,type:typeof n,hasGetMedia:!!n?.getMedia}),n&&typeof n.getMedia==`function`){r?.debug(`MediaBrowser: Loading media from API...`);let e=await n.getMedia({limit:1e4});r?.debug(`MediaBrowser: API response received`,e),e?.success&&Array.isArray(e.data)?(r?.info(`MediaBrowser: Loaded media files from API`,{count:e.data.length,total:e.meta?.total}),s(e.data)):(r?.warn(`MediaBrowser: Invalid API response format`,e),s([]))}else{r?.warn(`MediaBrowser: No API client provided, using mock data`);let e=[{id:`asset-1`,filename:`hero-image.jpg`,contentType:`image/jpeg`,size:2048e3,url:`https://picsum.photos/800/600?random=1`,uploadedAt:new Date().toISOString(),metadata:{width:1920,height:1080,title:`Hero Banner Image`,author:`John Photographer`,originalDimensions:{width:1920,height:1080},imageVariants:{thumbnail:{url:`https://picsum.photos/150/150?random=1`,width:150,height:150,format:`jpeg`,size:12e3},small:{url:`https://picsum.photos/400/300?random=1`,width:400,height:300,format:`jpeg`,size:45e3},medium:{url:`https://picsum.photos/800/600?random=1`,width:800,height:600,format:`jpeg`,size:12e4},large:{url:`https://picsum.photos/1200/900?random=1`,width:1200,height:900,format:`jpeg`,size:28e4}}}},{id:`asset-2`,filename:`product-demo.mp4`,contentType:`video/mp4`,size:15728640,url:`https://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4`,uploadedAt:new Date().toISOString(),metadata:{width:1280,height:720,duration:30,title:`Product Demo Video`}},{id:`asset-3`,filename:`background-music.mp3`,contentType:`audio/mp3`,size:5242880,url:`#`,uploadedAt:new Date().toISOString(),metadata:{duration:180,title:`Background Music Track`}},{id:`asset-4`,filename:`user-manual.pdf`,contentType:`application/pdf`,size:1048576,url:`#`,uploadedAt:new Date().toISOString(),metadata:{title:`User Manual Document`}}];s(e)}}catch(e){r?.error(`Failed to load media files`,e),s([])}finally{l(!1)}},x=o.filter(e=>{if(t&&vi(e.contentType)!==t)return!1;if(!u)return!0;let n=u.toLowerCase();return e.filename.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||e.metadata?.title&&e.metadata.title.toLowerCase().includes(n)||e.metadata?.author&&e.metadata.author.toLowerCase().includes(n)||e.metadata?.credit&&e.metadata.credit.toLowerCase().includes(n)});(0,B.useEffect)(()=>{y(1)},[u,t]);let S=Math.ceil(x.length/20),C=(v-1)*20,w=C+20,T=x.slice(C,w),E=()=>{f&&(e({_type:`media`,asset:{_ref:f.id,_type:`mediaAsset`},alt:``,caption:``,title:``,variant:m}),p(null),h(`original`))};return(0,V.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 overflow-hidden`,children:[g===`grid`&&(0,V.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-gray-600`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(_i,{className:`absolute left-2.5 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,placeholder:a(`mediaBrowser.searchPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent`})]})}),g===`single`&&f?(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,V.jsx)(`div`,{className:`px-4 py-3 border-b border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800`,children:(0,V.jsxs)(`button`,{onClick:()=>{_(`grid`),p(null),h(`original`)},className:`flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors`,children:[(0,V.jsx)(`svg`,{className:`w-4 h-4 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})}),a(`mediaBrowser.backToGrid`)]})}),(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-y-auto`,children:[(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-gray-50 dark:bg-gray-900 p-4 min-h-[200px]`,children:(()=>{let e=vi(f.contentType);if(e===`image`){let e=m===`original`?bi(f,void 0,i,n):bi(f,m,i,n);return(0,V.jsx)(`div`,{className:`w-full h-full max-w-[800px] max-h-[400px] flex items-center justify-center`,children:e?(0,V.jsx)(`img`,{src:e,alt:f.metadata?.title||f.filename,className:`max-w-full max-h-full object-contain`,loading:`eager`,onLoad:()=>{},onError:e=>{f.url&&e.currentTarget.src!==f.url?e.currentTarget.src=f.url:e.currentTarget.onerror=null}},`${f.id}-${m}-${e}`):(0,V.jsx)(`div`,{className:`text-gray-500`,children:a(`mediaBrowser.noPreviewUrl`)})})}return e===`video`?(0,V.jsx)(`video`,{src:bi(f,void 0,i,n),controls:!0,className:`max-w-full max-h-full`}):e===`audio`?(0,V.jsx)(`audio`,{src:bi(f,void 0,i,n),controls:!0,className:`w-full max-w-md`}):(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-24 h-24 mx-auto mb-4 opacity-50`,children:yi(e)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-4`,children:a(`mediaBrowser.noPreviewAvailable`)})]})})()}),vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:a(`mediaBrowser.imageVariants`)}),n?.regenerateVariants&&(0,V.jsx)(`button`,{onClick:async()=>{try{r?.info(`Regenerating variants for`,{mediaId:f.id}),await n.regenerateVariants?.(f.id),b()}catch(e){r?.error(`Failed to regenerate variants`,e)}},className:`text-xs px-2 py-1 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 border border-blue-600 dark:border-blue-400 rounded hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors`,children:a(`mediaBrowser.regenerate`)})]}),(0,V.jsxs)(`div`,{className:`flex space-x-2 overflow-x-auto pb-1`,children:[(0,V.jsxs)(`div`,{className:`flex-shrink-0 group relative`,children:[(0,V.jsx)(`div`,{className:`cursor-pointer rounded border-2 transition-all ${m===`original`?`border-blue-500 ring-2 ring-blue-200 dark:ring-blue-800`:`border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600`}`,onClick:()=>h(`original`),children:(0,V.jsx)(`img`,{src:bi(f,void 0,i,n),alt:`Original`,className:`w-16 h-16 object-cover rounded`,loading:`lazy`})}),(0,V.jsxs)(`div`,{className:`mt-1 text-center`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 truncate`,children:a(`mediaBrowser.original`)}),(0,V.jsxs)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-500`,children:[f.metadata?.width,` ×`,` `,f.metadata?.height]})]})]}),Object.entries(f.metadata.imageVariants).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex-shrink-0 group relative`,children:[(0,V.jsx)(`div`,{className:`cursor-pointer rounded border-2 transition-all ${m===e?`border-blue-500 ring-2 ring-blue-200 dark:ring-blue-800`:`border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600`}`,onClick:()=>h(e),children:(0,V.jsx)(`img`,{src:bi(f,e,i,n),alt:`${e} variant`,className:`w-16 h-16 object-cover rounded`,loading:`lazy`})}),(0,V.jsxs)(`div`,{className:`mt-1 text-center`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 capitalize truncate`,children:e}),(0,V.jsxs)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-500`,children:[t.width,` × `,t.height]})]})]},e))]})]}),vi(f.contentType)===`image`&&(!f.metadata?.imageVariants||Object.keys(f.metadata.imageVariants).length===0)&&(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-2`,children:a(`mediaBrowser.imageVariants`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mb-3`,children:a(`mediaBrowser.noVariantsAvailable`)})]})})]}),(0,V.jsxs)(`div`,{className:`w-full md:w-64 bg-white dark:bg-gray-800 border-t md:border-t-0 md:border-l border-gray-200 dark:border-gray-700 flex flex-col flex-shrink-0`,children:[(0,V.jsxs)(`div`,{className:`p-3 md:p-4 flex-1`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-white mb-2`,children:a(`mediaBrowser.fileDetails`)}),(0,V.jsxs)(`dl`,{className:`space-y-1.5 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.filename`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white truncate ml-2 max-w-[150px]`,title:f.filename,children:f.filename})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.size`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white`,children:hi(f.size)})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.type`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white truncate ml-2 max-w-[100px]`,title:f.contentType,children:f.contentType.split(`/`)[1]||f.contentType})]}),f.metadata?.width&&f.metadata?.height&&(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.dimensions`)}),(0,V.jsxs)(`dd`,{className:`text-gray-900 dark:text-white`,children:[f.metadata.width,` × `,f.metadata.height]})]})]})]}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:(0,V.jsx)(`button`,{onClick:E,className:`w-full px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors`,children:m===`original`?a(`mediaBrowser.selectOriginal`):a(`mediaBrowser.selectVariant`,{variant:m})})})]})]})]}):(0,V.jsxs)(V.Fragment,{children:[f&&g===`grid`&&vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsx)(`div`,{className:`px-4 py-3 bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-gray-600`,children:(0,V.jsxs)(`div`,{className:`flex items-start space-x-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 rounded overflow-hidden bg-gray-100 dark:bg-gray-700 flex items-center justify-center flex-shrink-0`,children:(()=>{let e=vi(f.contentType);return e===`image`?(0,V.jsx)(`img`,{src:bi(f,gi(f),i,n),alt:f.filename,className:`w-full h-full object-cover`}):(0,V.jsx)(`div`,{className:`w-6 h-6 text-gray-500 dark:text-gray-400`,children:yi(e)})})()}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-white truncate`,title:f.filename,children:f.filename}),(0,V.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[f.metadata?.width&&f.metadata?.height?`${f.metadata.width} × ${f.metadata.height} • `:``,hi(f.size)]})]}),vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 dark:text-white mb-1`,children:a(`mediaBrowser.variant`)}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,V.jsxs)(`label`,{className:`cursor-pointer flex flex-col items-center px-2 py-1 rounded border text-xs transition-colors ${m===`original`?`border-blue-500 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`variant`,value:`original`,checked:m===`original`,onChange:e=>{console.log(`📝 Variant selection changed:`,{from:m,to:e.target.value}),h(e.target.value)},className:`sr-only`}),(0,V.jsx)(`div`,{className:`font-medium`,children:a(`mediaBrowser.original`)}),f.metadata?.originalDimensions&&(0,V.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:[f.metadata.originalDimensions.width,`×`,f.metadata.originalDimensions.height]})]}),Object.entries(f.metadata.imageVariants).map(([e,t])=>(0,V.jsxs)(`label`,{className:`cursor-pointer flex flex-col items-center px-2 py-1 rounded border text-xs transition-colors ${m===e?`border-blue-500 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`variant`,value:e,checked:m===e,onChange:e=>{console.log(`📝 Variant selection changed:`,{from:m,to:e.target.value}),h(e.target.value)},className:`sr-only`}),(0,V.jsx)(`div`,{className:`font-medium capitalize`,children:e}),(0,V.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:[t.width,`×`,t.height]})]},e))]})]}),(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:(0,V.jsx)(`button`,{onClick:E,className:`px-3 py-1 bg-blue-600 text-white text-xs rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors`,children:a(`mediaBrowser.select`)})})]})})]})}),(0,V.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 min-h-0`,children:c?(0,V.jsx)(`div`,{className:`flex items-center justify-center h-48`,children:(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600`})}):x.length>0?(0,V.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2`,children:T.map(t=>(0,V.jsxs)(`div`,{className:`relative cursor-pointer rounded-lg border transition-all duration-150 group overflow-hidden ${f?.id===t.id?`border-blue-500 ring-1 ring-blue-200 dark:ring-blue-900/50 shadow-md`:`border-gray-200 dark:border-gray-700 hover:border-blue-300 dark:hover:border-blue-600 hover:shadow-sm`} bg-white dark:bg-gray-800`,onClick:()=>{vi(t.contentType)===`image`?(p(t),h(`original`),_(`single`)):e({_type:`media`,asset:{_ref:t.id,_type:`mediaAsset`},alt:``,caption:``,title:``,variant:`original`})},children:[(0,V.jsxs)(`div`,{className:`h-20 relative overflow-hidden bg-gray-50 dark:bg-gray-900`,children:[(()=>{let e=t.metadata?.imageVariants?Object.keys(t.metadata.imageVariants).length:0;return e>0?(0,V.jsx)(`div`,{className:`absolute top-1 right-1 bg-blue-600 text-white text-[10px] px-1 py-0.5 rounded-full z-10 font-medium`,children:e}):null})(),(()=>{let e=vi(t.contentType);return e===`image`?(0,V.jsx)(`img`,{src:bi(t,gi(t),i,n),alt:t.metadata?.title||t.filename,className:`w-full h-full object-cover transition-transform duration-200 group-hover:scale-105`}):(0,V.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`w-6 h-6 text-gray-400 dark:text-gray-500`,children:yi(e)})})})()]}),(0,V.jsxs)(`div`,{className:`px-1.5 py-1`,children:[(0,V.jsx)(`p`,{className:`text-[10px] font-medium text-gray-900 dark:text-white truncate leading-tight`,title:t.filename,children:t.filename}),(0,V.jsx)(`p`,{className:`text-[10px] text-gray-500 dark:text-gray-400 leading-tight`,children:hi(t.size)})]})]},t.id))}):(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 text-gray-500 dark:text-gray-400`,children:[(0,V.jsx)(`div`,{className:`w-12 h-12 mb-3 opacity-50`,children:(0,V.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1,d:`M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z`})})}),(0,V.jsx)(`p`,{className:`text-sm text-center`,children:t?a(u?`mediaBrowser.noTypeFoundMatching`:`mediaBrowser.noTypeFound`,{type:t}):a(u?`mediaBrowser.noMediaFoundMatching`:`mediaBrowser.noMediaFound`)}),u&&(0,V.jsx)(`button`,{onClick:()=>d(``),className:`mt-2 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300`,children:a(`mediaBrowser.clearSearch`)})]})}),x.length>20&&g===`grid`&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50`,children:[(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.paginationOf`,{start:C+1,end:Math.min(w,x.length),total:x.length})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{onClick:()=>y(e=>Math.max(1,e-1)),disabled:v===1,className:`px-2 py-0.5 text-[10px] font-medium rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:a(`mediaBrowser.prev`)}),(0,V.jsxs)(`span`,{className:`text-[10px] text-gray-600 dark:text-gray-300 px-1`,children:[v,`/`,S]}),(0,V.jsx)(`button`,{onClick:()=>y(e=>Math.min(S,e+1)),disabled:v===S,className:`px-2 py-0.5 text-[10px] font-medium rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:a(`mediaBrowser.next`)})]})]})]})]})}var Si=`studio-overlays`;function Ci(){let e=[],t=new Map,n=new Set,r=0,i=t=>e.indexOf(t),a=()=>{r+=1,n.forEach(e=>e())};return{push(t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t),a()},remove(n){let r=e.indexOf(n);r!==-1&&e.splice(r,1),t.delete(n),r!==-1&&a()},setEscapeHandler(e,n){n?t.set(e,n):t.delete(e)},handleEscape(){if(e.length===0)return!1;let n=t.get(e[e.length-1]);return n&&n(),!0},depthOf:i,isTopmost(t){return e.length>0&&e[e.length-1]===t},zIndexOf(e){let t=i(e);return Math.min(50+(t<0?0:t),199)},size(){return e.length},ids(){return[...e]},version(){return r},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}var wi=Ci();function Ti(){return wi.size()>0}var Ei=new WeakSet;function Di(e){return e&&Ei.has(e)?!0:Ti()}function Oi(e,t,n){return!(!e||!e.isConnected||t>=0&&n>t)}function ki(e){let t=0,n=``;return{lock(){let r=e();t===0&&r&&(n=r.style.overflow,r.style.overflow=`hidden`),t+=1;let i=!1;return()=>{if(!i&&(i=!0,--t,t===0)){let t=e();t&&(t.style.overflow=n)}}},count(){return t}}}var Ai=ki(()=>typeof document>`u`?null:document.body),ji=0;function Mi(e){e.key===`Escape`&&wi.handleEscape()&&(Ei.add(e),e.stopPropagation())}function Ni(){ji===0&&typeof document<`u`&&document.addEventListener(`keydown`,Mi),ji+=1;let e=!1;return()=>{e||(e=!0,--ji,ji===0&&typeof document<`u`&&document.removeEventListener(`keydown`,Mi))}}var Pi=`data-dialog-inert`,Fi=new Map,Ii=null;function Li(e){return e.id===`studio-overlays`||e.hasAttribute(`data-dialog-exempt`)}function Ri(e){Li(e)||Fi.has(e)||(Fi.set(e,{hadInert:e.hasAttribute(`inert`),previousAriaHidden:e.getAttribute(`aria-hidden`)}),e.setAttribute(Pi,``),e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`))}function zi(e,t){e.removeAttribute(Pi),t.hadInert||e.removeAttribute(`inert`),t.previousAriaHidden===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,t.previousAriaHidden)}function Bi(e,t){let n=t??(typeof document>`u`?null:document.body);if(n){if(e){Array.from(n.children).forEach(Ri),!Ii&&typeof MutationObserver<`u`&&(Ii=new MutationObserver(e=>{for(let t of e)t.addedNodes.forEach(e=>{e instanceof Element&&Ri(e)})}),Ii.observe(n,{childList:!0}));return}Ii?.disconnect(),Ii=null,Fi.forEach((e,t)=>zi(t,e)),Fi.clear()}}var Vi=0;function Hi(){Vi===0&&Bi(!0),Vi+=1;let e=!1;return()=>{e||(e=!0,--Vi,Vi===0&&Bi(!1))}}var Ui={md:768,lg:1024};function Wi(e){return`(min-width: ${e}px)`}var Gi=e=>typeof window>`u`||typeof window.matchMedia!=`function`?null:window.matchMedia(e);function Ki(e,t,n=Gi){let r=n(e);if(!r)return()=>{};r.matches&&t();let i=e=>{e.matches&&t()};return r.addEventListener(`change`,i),()=>r.removeEventListener(`change`,i)}function qi(){if(typeof document>`u`)return null;let e=document.getElementById(Si);return e||(e=document.createElement(`div`),e.id=Si,document.body.appendChild(e)),e}var Ji=[`a[href]`,`button:not([disabled])`,`input:not([disabled]):not([type="hidden"])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Yi(e){return Array.from(e.querySelectorAll(Ji)).filter(e=>e.offsetParent!==null||e===document.activeElement)}var Xi=(0,B.createContext)(null);function Zi(){let e=(0,B.useContext)(Xi);if(!e)throw Error(`Dialog.Header, Dialog.Body and Dialog.Footer must be used inside a Dialog`);return e}var Qi={center:`items-end sm:items-center justify-center p-0 sm:p-4`,sheet:`items-end justify-center p-0`,"drawer-right":`items-stretch justify-end`,"drawer-left":`items-stretch justify-start`,fullscreen:`items-stretch justify-center`},$i={center:`rounded-t-lg sm:rounded-lg max-h-[100dvh] sm:max-h-[calc(100dvh-2rem)]`,sheet:`rounded-t-lg max-h-[90dvh]`,"drawer-right":`h-[100dvh] max-h-[100dvh] shadow-2xl`,"drawer-left":`h-[100dvh] max-h-[100dvh] shadow-2xl`,fullscreen:`h-[100dvh] max-h-[100dvh]`},ea={tall:{center:`h-[100dvh] sm:h-[85dvh]`,sheet:`h-[85dvh]`,"drawer-right":``,"drawer-left":``,fullscreen:``},fill:{center:`h-[100dvh] sm:h-[calc(100dvh-2rem)]`,sheet:`h-[90dvh]`,"drawer-right":``,"drawer-left":``,fullscreen:``}},ta={center:`animate-in fade-in slide-in-from-bottom`,sheet:`animate-in slide-in-from-bottom`,"drawer-right":`animate-in slide-in-from-right-full`,"drawer-left":`animate-in slide-in-from-left-full`,fullscreen:`animate-in fade-in`},na={xs:`sm:max-w-xs`,sm:`sm:max-w-md`,md:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-4xl`,full:`sm:max-w-7xl`},ra={xs:`max-w-[min(16rem,85vw)]`,sm:`max-w-[min(20rem,85vw)]`,md:`max-w-[min(32rem,85vw)]`,lg:`max-w-[min(42rem,90vw)]`,xl:`max-w-[min(56rem,90vw)]`,full:`max-w-[min(80rem,95vw)]`};function ia({open:e,onClose:t,variant:n=`center`,size:r=`md`,height:i=`auto`,title:a,description:o,dismissible:s=!0,closeOnBackdrop:c=!0,closeOnEscape:l=!0,initialFocus:u,ariaLabel:d,surface:f=`bg-white dark:bg-gray-800`,className:p,wrapperClassName:m,children:h}){let g=(0,B.useId)(),_=(0,B.useRef)(g),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(null),S=(0,B.useRef)(null),C=(0,B.useRef)(t);C.current=t;let w=(0,B.useSyncExternalStore)(wi.subscribe,()=>wi.zIndexOf(_.current),()=>50);if((0,B.useEffect)(()=>{x(qi())},[]),(0,B.useEffect)(()=>{if(!e)return;let t=_.current;S.current=document.activeElement,wi.push(t);let n=Ni(),r=Hi();return()=>{n(),r();let e=wi.depthOf(t);wi.remove(t);let i=S.current;S.current=null,Oi(i,e,wi.size())&&i?.focus?.()}},[e]),(0,B.useEffect)(()=>{e&&wi.setEscapeHandler(_.current,l?()=>C.current():null)},[e,l]),(0,B.useEffect)(()=>{if(e)return Ai.lock()},[e]),(0,B.useEffect)(()=>{e&&v&&(u?.current||Yi(v)[0]||v)?.focus?.()},[e,v,u]),(0,B.useEffect)(()=>{if(!e||!v)return;let t=e=>{if(e.key!==`Tab`||!wi.isTopmost(_.current))return;let t=Yi(v),n=document.activeElement;if(t.length===0){e.preventDefault(),v.focus();return}let r=t[0],i=t[t.length-1],a=!v.contains(n);e.shiftKey&&(a||n===r)?(e.preventDefault(),i.focus()):!e.shiftKey&&(a||n===i)&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e,v]),!e||!b)return null;let T=`${g}-title`,E=`${g}-description`,D={onClose:t,dismissible:s,titleId:T,descriptionId:E};return(0,Ht.createPortal)((0,V.jsx)(Xi.Provider,{value:D,children:(0,V.jsxs)(`div`,{className:wr(`fixed inset-0 flex`,Qi[n],m),style:{zIndex:w},"data-dialog-wrapper":``,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 bg-black/50 animate-in fade-in`,onClick:c?t:void 0,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{ref:y,role:`dialog`,"aria-modal":`true`,"aria-label":a?void 0:d,"aria-labelledby":a?T:void 0,"aria-describedby":o?E:void 0,tabIndex:-1,"data-dialog-panel":``,className:wr(`relative flex flex-col w-full min-h-0 shadow-xl focus:outline-none`,f,$i[n],i!==`auto`&&ea[i][n],n!==`fullscreen`&&(n===`drawer-left`||n===`drawer-right`?ra[r]:na[r]),ta[n],p),children:[a!=null&&(0,V.jsxs)(aa,{children:[(0,V.jsx)(`h2`,{id:T,className:`text-lg font-semibold text-gray-900 dark:text-white`,children:a}),o&&(0,V.jsx)(`p`,{id:E,className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:o})]}),h]})]})}),b)}function aa({children:e,className:t,padded:n=!0,showClose:r=!0}){let{onClose:i,dismissible:a}=Zi(),{t:o}=H(`studio`);return(0,V.jsxs)(`div`,{className:wr(`shrink-0 flex items-start justify-between gap-3 border-b border-gray-200 dark:border-gray-700`,n&&`px-6 py-4`,t),children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&a&&(0,V.jsx)(`button`,{type:`button`,onClick:i,"aria-label":o(`common.close`),className:`shrink-0 p-1 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:hover:text-gray-300 dark:hover:bg-gray-700 transition-colors`,children:(0,V.jsx)(tt,{className:`h-5 w-5`})})]})}function oa({children:e,className:t,scroll:n=!0,padded:r=!0}){return(0,V.jsx)(`div`,{className:wr(`flex-1 min-h-0`,n?`overflow-y-auto overscroll-contain`:`overflow-hidden`,r&&`px-6 py-4`,t),children:e})}var sa={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`};function ca({children:e,className:t,padded:n=!0,justify:r=`end`}){return(0,V.jsx)(`div`,{className:wr(`shrink-0 flex items-center gap-3 border-t border-gray-200 dark:border-gray-700`,sa[r],n&&`px-6 py-4`,t),children:e})}ia.Header=aa,ia.Body=oa,ia.Footer=ca;function la({isOpen:e,onClose:t,onSelect:n,mediaTypeFilter:r,showVariantSelector:i=!1,context:a,apiClient:o,logger:s,mediaUrlGenerator:c}){let{t:l}=H(`studio`);return(0,V.jsxs)(ia,{open:e,onClose:t,variant:`center`,size:`xl`,height:`tall`,className:`overflow-hidden`,ariaLabel:l(`mediaBrowser.title`),children:[(0,V.jsxs)(ia.Header,{padded:!1,className:`px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold text-gray-900 dark:text-white`,children:l(`mediaBrowser.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:(()=>{if(!r)return l(`mediaBrowser.selectFile`);switch(r){case`image`:return l(`mediaBrowser.selectImage`);case`video`:return l(`mediaBrowser.selectVideo`);case`audio`:return l(`mediaBrowser.selectAudio`);case`document`:return l(`mediaBrowser.selectDocument`);default:return l(`mediaBrowser.selectFile`)}})()})]}),(0,V.jsx)(ia.Body,{scroll:!1,padded:!1,children:(0,V.jsx)(xi,{onSelect:e=>{n(e),t()},mediaTypeFilter:r,showVariantSelector:i,context:a,apiClient:o,logger:s,mediaUrlGenerator:c})})]})}var ua=(0,B.createContext)(null),da=new class{listeners=new Map;fieldValues=new Map;fieldWatchers=new Map;emit(e,t){let n=this.listeners.get(e);n&&n.forEach(e=>e(t))}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{let n=this.listeners.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}}}getFieldValue(e){return this.fieldValues.get(e)}setFieldValue(e,t){this.fieldValues.set(e,t);let n=this.fieldWatchers.get(e);n&&n.forEach(e=>e(t))}watchField(e,t){this.fieldWatchers.has(e)||this.fieldWatchers.set(e,[]),this.fieldWatchers.get(e).push(t);let n=this.fieldValues.get(e);return n!==void 0&&t(n),()=>{let n=this.fieldWatchers.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}}}};function fa({children:e,branding:t}){let n=(0,B.useMemo)(()=>Fr(`Fields`),[]),[r,i]=(0,B.useState)(null),a=(0,B.useMemo)(()=>({getMediaUrl:(e,t)=>{if(r){let{options:n}=r,i=n.mediaConfig?.serving?.mode||`api`,a=n.mediaConfig?.serving?.staticBasePath||`/media`,o=W.getBackendUrl?.()||``;return i===`static`?`${o.replace(/\/[^\/]+$/,``)}${t?`${a}/${e}/${t}`:`${a}/${e}`}`:`${o}${t?`/media/${e}/variants/${t}`:`/media/${e}/file`}`}return W.getMediaUrl?W.getMediaUrl(e,t):`${W.getBackendUrl?.()||``}${t?`/media/${e}/variants/${t}`:`/media/${e}/file`}`}}),[r]);(0,B.useEffect)(()=>{(async()=>{try{let e=await W.get(`/config/studio`);if(e.success&&e.data?.studioConfig?.mediaUrlGenerator){let t=e.data.studioConfig.mediaUrlGenerator;i(t)}}catch{}})()},[]);let[o,s]=(0,B.useState)({isOpen:!1,config:null});(0,B.useEffect)(()=>{typeof window<`u`&&window.__TROKKY_DEV__},[]);let c=(0,B.useCallback)((e,t=`info`)=>{window.dispatchEvent(new CustomEvent(`studio:toast`,{detail:{message:e,type:t}}))},[]),l=(0,B.useCallback)(async(e,t)=>new Promise(n=>{window.dispatchEvent(new CustomEvent(`studio:confirm`,{detail:{message:e,title:t?.title,confirmText:t?.confirmText,cancelText:t?.cancelText,variant:t?.variant,resolve:n}}))}),[]),u=(0,B.useCallback)(e=>{s({isOpen:!0,config:e})},[]),d=(0,B.useCallback)(()=>{s({isOpen:!1,config:null})},[]),f=(0,B.useMemo)(()=>({apiClient:W,auth:{getCurrentUser:()=>{let e=localStorage.getItem(`currentUser`);return e?JSON.parse(e):null},hasPermission:e=>{let t=localStorage.getItem(`currentUser`);if(!t)return!1;let n=JSON.parse(t);return n.role===`admin`||n.permissions?.includes(e)||!1},getAccessToken:()=>Ar.getToken()},fieldEvents:{emit:da.emit.bind(da),on:da.on.bind(da),getFieldValue:da.getFieldValue.bind(da),watchField:da.watchField.bind(da)},utils:{showToast:c,showConfirm:l,showMediaBrowser:u},logger:{debug:n.debug.bind(n),info:n.info.bind(n),warn:n.warn.bind(n),error:n.error.bind(n)},mediaUrlGenerator:a,branding:t||void 0}),[c,l,u,n,a,t]);return(0,V.jsxs)(ua.Provider,{value:f,children:[e,o.isOpen&&o.config&&(0,V.jsx)(la,{isOpen:o.isOpen,onClose:d,onSelect:e=>{o.config?.onSelect(e),d()},mediaTypeFilter:o.config.mediaTypeFilter,showVariantSelector:o.config.showVariantSelector,context:o.config.context,apiClient:W,logger:n,mediaUrlGenerator:a})]})}function pa(){return(0,B.useContext)(ua)}var ma=[`structure`];function ha(){return Yr(W)}function ga(e){let t=P(),n=j({queryKey:[...ma,`root`,e??null],queryFn:()=>ha().getStructure(e)}),r=(0,B.useCallback)(()=>{ha().clearCache(),t.invalidateQueries({queryKey:ma})},[t]),i=(0,B.useCallback)(e=>{ha().setStructure(e),t.invalidateQueries({queryKey:ma})},[t]),a=n.data??null,o=n.error?n.error.message:null;return{structure:a,loading:n.isPending,error:o,refreshStructure:r,setCustomStructure:i,isReady:!n.isPending&&!o&&a!==null}}function _a(e){let t=d(),n=P(),r=j({queryKey:[...ma,`navigation`,t.pathname,e??null],queryFn:()=>ha().getNavigation(t.pathname,e)}),i=(0,B.useCallback)(()=>{ha().clearCache(),n.invalidateQueries({queryKey:ma})},[n]),a=r.data??null,o=r.error?r.error.message:null;return{navigation:a,loading:r.isPending,error:o,refreshNavigation:i,currentPath:t.pathname,isReady:!r.isPending&&!o&&a!==null}}function va(e){let t=j({queryKey:[...ma,`item`,e],queryFn:()=>ha().getStructureItemBySchema(e),enabled:!!e}),n=t.error?t.error.message:null,r=!!e&&t.isPending;return{item:t.data??null,loading:r,error:n,isReady:!r&&!n}}function ya(){let e=j({queryKey:[...ma,`documentTypes`],queryFn:async()=>{let e=ha(),[t,n]=await Promise.all([e.getDocumentListItems(),e.getSingletonItems()]);return{documentTypes:t,singletonTypes:n}}}),t=e.data?.documentTypes??[],n=e.data?.singletonTypes??[],r=e.error?e.error.message:null;return{documentTypes:t,singletonTypes:n,allTypes:[...t,...n],loading:e.isPending,error:r,isReady:!e.isPending&&!r}}function ba(e){return e?e.type===`singleton`||e.schemaIsSingleton===!0:!1}function xa(){let[e,t]=(0,B.useState)(!1);return{isOpen:e,openSearch:(0,B.useCallback)(()=>{t(!0)},[]),closeSearch:(0,B.useCallback)(()=>{t(!1)},[])}}function Sa(e){return e?e.replace(/<[^>]*>/g,``).replace(/!\[.*?\]\(.*?\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/javascript:/gi,``).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim():``}function Ca(e,t){if(!t||t.length<2)return Sa(e);let n=Sa(e),r=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return n.replace(r,`<mark class="bg-yellow-200 dark:bg-yellow-800">$1</mark>`)}function wa({isOpen:e,onClose:t}){let{t:n}=H(`studio`),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)([]),f=(0,B.useRef)(null),p=(0,B.useRef)(null),m=r(),h=W;(0,B.useEffect)(()=>{if(e){try{let e=localStorage.getItem(`trokky_recent_searches`);d(e?JSON.parse(e):[])}catch{d([])}setTimeout(()=>f.current?.focus(),100)}else p.current&&=(clearTimeout(p.current),null)},[e]);let g=async e=>{if(e.length<2){s([]);return}l(!0);try{let t=await h.get(`/search`,{q:e,limit:10});if(t.success&&t.data){let e=(t.data.results||[]).map(e=>({id:e.id,type:e.type,title:e.title,url:e.url,excerpt:e.excerpt,metadata:{schemaType:e.metadata?.schemaType,author:e.metadata?.author,createdAt:e.metadata?.createdAt,size:e.metadata?.size?hi(e.metadata.size):void 0}}));s(e)}else console.warn(`Search failed:`,t.error),s([])}catch(e){console.error(`Search failed:`,e),s([])}finally{l(!1)}},_=e=>{a(e),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{g(e)},300)},v=e=>{if(i.length>=2){let e=[i,...u.filter(e=>e!==i)].slice(0,5);d(e),localStorage.setItem(`trokky_recent_searches`,JSON.stringify(e))}m(e.url),t()},y=e=>{a(e),g(e)},b=()=>{d([]),localStorage.removeItem(`trokky_recent_searches`)},x=()=>{a(``),s([]),t()},S=!i&&u.length>0,C=i.length>=2&&o.length>0,w=i.length>=2&&!c&&o.length===0;return(0,V.jsxs)(ia,{open:e,onClose:x,variant:`center`,size:`lg`,className:`overflow-hidden`,initialFocus:f,ariaLabel:n(`search.placeholder`),children:[(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center px-4 py-3 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(ee,{className:`w-5 h-5 text-gray-400 mr-3`}),(0,V.jsx)(`input`,{ref:f,type:`text`,value:i,onChange:e=>_(e.target.value),placeholder:n(`search.placeholder`),className:`flex-1 bg-transparent text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none`,autoComplete:`off`}),i?(0,V.jsx)(`button`,{onClick:()=>{a(``),s([]),f.current?.focus()},className:`p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:n(`search.clearSearch`),children:(0,V.jsx)(tt,{className:`w-5 h-5`})}):(0,V.jsx)(`button`,{onClick:x,className:`p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:n(`search.closeSearch`),children:(0,V.jsx)(tt,{className:`w-5 h-5`})})]}),(0,V.jsxs)(ia.Body,{padded:!1,className:`h-96`,children:[c&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin w-6 h-6 border-2 border-gray-300 border-t-blue-600 rounded-full mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.searching`)})]}),S&&(0,V.jsxs)(`div`,{className:`p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(re,{className:`w-4 h-4 text-gray-400 mr-2`}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-600 dark:text-gray-300`,children:n(`search.recentSearches`)})]}),(0,V.jsxs)(`button`,{onClick:b,className:`flex items-center text-xs text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors`,title:n(`search.clearHistory`),children:[(0,V.jsx)(Be,{className:`w-3 h-3 mr-1`}),n(`search.clear`)]})]}),(0,V.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>(0,V.jsx)(`button`,{onClick:()=>y(e),className:`w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors`,children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e,i)}})},t))})]}),C&&(0,V.jsxs)(`div`,{className:`p-4`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-3`,children:n(`search.foundResults`,{count:o.length})}),(0,V.jsx)(`div`,{className:`space-y-2`,children:o.map(e=>(0,V.jsxs)(`button`,{onClick:()=>v(e),className:`w-full flex items-start space-x-3 p-3 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors text-left`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 bg-gray-100 dark:bg-gray-700 rounded-lg flex items-center justify-center`,children:e.type===`document`?(0,V.jsx)(pe,{className:`w-4 h-4 text-gray-600 dark:text-gray-300`}):(0,V.jsx)(at,{className:`w-4 h-4 text-gray-600 dark:text-gray-300`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e.title,i)}})}),e.excerpt&&(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 overflow-hidden`,style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`},children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e.excerpt,i)}})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded`,children:e.type===`document`?n(`search.document`):n(`search.media`)}),e.metadata?.schemaType&&(0,V.jsx)(`span`,{className:`text-xs text-blue-600 dark:text-blue-400`,children:e.metadata.schemaType}),e.metadata?.author&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[n(`search.by`),` `,e.metadata.author]}),e.metadata?.size&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.metadata.size}),e.metadata?.createdAt&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.metadata.createdAt).toLocaleDateString()})]})]})]},`${e.type}-${e.id}`))})]}),w&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(ee,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-900 dark:text-white font-medium mb-1`,children:n(`search.noResults`)}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.tryDifferent`)})]}),!i&&!S&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(ee,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.typeToSearch`)})]})]}),(0,V.jsxs)(ia.Footer,{padded:!1,justify:`between`,className:`px-4 py-3 text-xs text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-600`,children:[(0,V.jsx)(`span`,{children:n(`search.pressEscape`)}),(0,V.jsx)(`span`,{children:n(`search.poweredBy`)})]})]})}var Ta=Fr(`ChangePasswordModal`);function Ea({isOpen:e,onClose:t}){let{t:n}=H(`studio`),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),_=()=>{i(``),o(``),c(``),u(null),f(null),g(!1),t()};return(0,V.jsx)(ia,{open:e,onClose:_,variant:`center`,size:`sm`,title:n(`changePassword.title`),children:(0,V.jsx)(ia.Body,{children:h?(0,V.jsx)(`div`,{className:`bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`svg`,{className:`w-5 h-5 text-green-500 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})}),(0,V.jsx)(`p`,{className:`text-sm text-green-800 dark:text-green-200`,children:n(`changePassword.success`)})]})}):(0,V.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),u(null),f(null),!r){u(n(`changePassword.errors.currentRequired`)),f(`currentPassword`);return}if(!a){u(n(`changePassword.errors.newRequired`)),f(`newPassword`);return}if(a.length<8){u(n(`changePassword.errors.tooShort`)),f(`newPassword`);return}if(a!==s){u(n(`changePassword.errors.mismatch`)),f(`confirmPassword`);return}if(r===a){u(n(`changePassword.errors.sameAsCurrent`)),f(`newPassword`);return}m(!0);try{Ta.info(`Changing password`);let e=await W.post(`/auth/change-password`,{currentPassword:r,newPassword:a});if(e.success)Ta.info(`Password changed successfully`),g(!0),setTimeout(()=>{_()},2e3);else throw Error(e.error?.message||n(`changePassword.errors.failed`))}catch(e){Ta.error(`Failed to change password`,e),u(e.message||n(`changePassword.errors.failed`)),f(e.field||null)}finally{m(!1)}},children:[l&&(0,V.jsx)(`div`,{className:`mb-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md p-3`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-800 dark:text-red-200`,children:l})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`currentPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.currentPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`currentPassword`,value:r,onChange:e=>i(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`currentPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`current-password`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`newPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.newPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`newPassword`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`newPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`new-password`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:n(`changePassword.errors.tooShort`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`confirmPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.confirmPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`confirmPassword`,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`confirmPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`new-password`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:_,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md`,disabled:p,children:n(`common.cancel`)}),(0,V.jsx)(`button`,{type:`submit`,className:`px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md disabled:opacity-50 disabled:cursor-not-allowed`,disabled:p,children:n(p?`changePassword.submitting`:`changePassword.submit`)})]})]})})})}function Da({onOpenMobileMenu:e,showSearch:t=!0,showMedia:n=!0,showUserMenu:i=!0}){let{t:a}=H(`studio`),{logout:o}=ri(),{user:s,loading:l}=si(),{hasPermission:u,hasAnyPermission:d}=ci(),f=r(),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(`system`),{documentTypes:C,loading:w}=ya(),T=C.filter(e=>!ba(e)),E=pa()?.branding||{title:`Trokky Studio`},{isOpen:D,openSearch:O,closeSearch:k}=xa();(0,B.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),O())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[O]);let A=e=>{g(!1),f(`/content/${e}/new`)},j=e=>{S(e),e===`system`?document.documentElement.classList.remove(`light`,`dark`):(document.documentElement.classList.remove(`light`,`dark`),document.documentElement.classList.add(e)),localStorage.setItem(`trokky_theme`,e)},M=[{key:`light`,label:a(`theme.light`),icon:Oe},{key:`dark`,label:a(`theme.dark`),icon:me},{key:`system`,label:a(`theme.system`),icon:_e}];return(0,V.jsxs)(`header`,{className:`sticky top-0 z-sticky bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between h-16 px-4 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsx)(`button`,{onClick:e,className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 lg:hidden`,children:(0,V.jsx)(we,{className:`h-6 w-6`})}),(0,V.jsxs)(c,{to:`/`,className:`flex items-center space-x-3`,children:[E.logo?(0,V.jsx)(`img`,{src:E.logo,alt:`Logo`,className:`h-8 w-8 rounded-lg object-cover`}):(0,V.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-primary-600 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`text-white font-bold text-sm`,children:`T`})}),(0,V.jsx)(`div`,{children:(0,V.jsx)(`h1`,{className:`text-lg font-semibold text-gray-900 dark:text-white`,children:E.organizationName||E.title})})]})]}),t&&(0,V.jsx)(`div`,{className:`hidden lg:block flex-1 max-w-sm mx-4`,children:(0,V.jsxs)(`button`,{onClick:O,className:`w-full flex items-center px-3 py-1.5 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md text-left text-sm text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors`,children:[(0,V.jsx)(ee,{className:`h-4 w-4 mr-2 flex-shrink-0`}),(0,V.jsx)(`span`,{className:`flex-1 truncate`,children:a(`nav.searchPlaceholder`)}),(0,V.jsx)(`kbd`,{className:`hidden xl:inline-flex px-1.5 py-0.5 text-xs bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded`,children:`⌘K`})]})}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[t&&(0,V.jsx)(`button`,{onClick:O,className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 md:hidden`,children:(0,V.jsx)(ee,{className:`h-5 w-5`})}),(0,V.jsxs)(`div`,{className:`hidden sm:block relative`,children:[(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>g(!h),className:`inline-flex items-center`,disabled:w,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-1`}),a(`header.create`),(0,V.jsx)(ye,{className:`h-3 w-3 ml-1`})]}),h&&!w&&(0,V.jsx)(`div`,{className:`absolute right-0 mt-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:T.length>0?(0,V.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2`,children:a(`header.createNewDocument`)}),T.map(e=>(0,V.jsxs)(`button`,{onClick:()=>A(e.schemaType),className:`flex items-center w-full px-2 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors`,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:e.schemaTitle||e.title}),e.description&&(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]})]},e.schemaType||e.id))]}):(0,V.jsx)(`div`,{className:`px-4 py-3 text-sm text-gray-500 dark:text-gray-400 text-center`,children:a(`header.noDocumentTypes`)})})]}),n&&u(li.READ)&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,asChild:!0,className:`hidden sm:inline-flex`,children:(0,V.jsxs)(c,{to:`/media`,children:[(0,V.jsx)(at,{className:`h-4 w-4 mr-1`}),a(`nav.media`)]})}),d([...mi])&&(0,V.jsxs)(`div`,{className:`hidden sm:block relative`,children:[(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>v(!_),className:`inline-flex items-center`,children:[(0,V.jsx)(ge,{className:`h-4 w-4 mr-1`}),a(`nav.settings`),(0,V.jsx)(ye,{className:`h-3 w-3 ml-1`})]}),_&&(0,V.jsxs)(`div`,{className:`absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:[u(di.READ)&&(0,V.jsxs)(c,{to:`/settings`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(ge,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.settings`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.studioConfiguration`)})]})]}),d([ui.READ,fi.READ,pi.READ])&&(0,V.jsxs)(c,{to:`/users`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(Ce,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.users`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.manageUsersPermissions`)})]})]}),(0,V.jsxs)(c,{to:`/audit-logs`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.auditLogs`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.viewAllChanges`)})]})]})]})]}),(0,V.jsx)(`button`,{onClick:()=>{j(x===`light`?`dark`:x===`dark`?`system`:`light`)},className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 transition-colors`,title:`${a(`theme.toggle`)}: ${M.find(e=>e.key===x)?.label}`,children:x===`light`?(0,V.jsx)(Oe,{className:`h-5 w-5`}):x===`dark`?(0,V.jsx)(me,{className:`h-5 w-5`}):(0,V.jsx)(_e,{className:`h-5 w-5`})}),i&&(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsxs)(`button`,{onClick:()=>m(!p),className:`flex items-center space-x-2 px-3 py-2 rounded-lg text-gray-700 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-gray-700 transition-colors`,children:[l?(0,V.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-gray-300 dark:bg-gray-600 animate-pulse`}):s?.profileImage?(0,V.jsx)(`img`,{src:s.profileImage,alt:`Profile`,className:`h-6 w-6 rounded-full object-cover`}):(0,V.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-primary-600 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`text-white font-medium text-xs`,children:(s?.firstName?.[0]||s?.username?.[0]||`U`).toUpperCase()})}),(0,V.jsx)(`span`,{className:`hidden sm:block text-sm font-medium truncate max-w-24`,children:l?(0,V.jsx)(`div`,{className:`h-4 w-16 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`}):s?.firstName||s?.username||`User`}),(0,V.jsx)(ye,{className:wr(`h-4 w-4 transition-transform`,p&&`rotate-180`)})]}),p&&(0,V.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:[(0,V.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-gray-700`,children:l?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`h-4 w-32 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`}),(0,V.jsx)(`div`,{className:`h-3 w-24 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.username||a(`header.user`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:s?.email||a(`header.noEmail`)})]})}),(0,V.jsxs)(`div`,{className:`py-1`,children:[(0,V.jsxs)(c,{to:`/user/preferences`,className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:()=>m(!1),children:[(0,V.jsx)($e,{className:`h-4 w-4 mr-2 text-gray-400`}),a(`header.preferences`)]}),(0,V.jsxs)(`button`,{className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:()=>{m(!1),b(!0)},children:[(0,V.jsx)(te,{className:`h-4 w-4 mr-2 text-gray-400`}),a(`header.changePassword`)]}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 my-1`}),(0,V.jsxs)(`button`,{className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:async()=>{m(!1),await o()},children:[(0,V.jsx)(`svg`,{className:`h-4 w-4 mr-2 text-gray-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1`})}),a(`header.signOut`)]})]})]})]})]})]}),(p||h||_)&&(0,V.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>{m(!1),g(!1),v(!1)}}),(0,V.jsx)(wa,{isOpen:D,onClose:k}),(0,V.jsx)(Ea,{isOpen:y,onClose:()=>b(!1)})]})}var Oa={user:`M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z`,users:`M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z`,"user-group":`M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z`,home:`M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25`,document:`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`,"document-text":`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`,folder:`M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z`,"folder-open":`M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776`,"cog-6-tooth":`M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z`,"bars-3":`M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5`,"squares-2x2":`M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z`,"list-bullet":`M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z`,"information-circle":`M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z`,"question-mark-circle":`M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z`,"chart-bar":`M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z`,"presentation-chart-line":`M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5M9 11.25v1.5M12 9v3.75m3-6v6`,"building-office":`M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6H15m-1.5 3H15m-1.5 3H15M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21`,"map-pin":`M15 10.5a3 3 0 11-6 0 3 3 0 016 0z M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z`,"globe-alt":`M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418`,newspaper:`M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 01-2.25 2.25M16.5 7.5V18a2.25 2.25 0 002.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 002.25 2.25h13.5M6 7.5h3v3H6v-3z`,photo:`M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z`,heart:`M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z`,star:`M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z`,"check-circle":`M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z`,"hand-raised":`M10.05 4.575a1.575 1.575 0 10-3.15 0v3m3.15-3v-1.5a1.575 1.575 0 013.15 0v1.5m-3.15 0l.075 5.925m3.075.75V4.575m0 0a1.575 1.575 0 013.15 0V15M6.9 7.575a1.575 1.575 0 10-3.15 0v8.175a6.75 6.75 0 006.75 6.75h2.018a5.25 5.25 0 003.712-1.538l1.732-1.732a5.25 5.25 0 001.538-3.712l.003-2.024a.668.668 0 01.198-.471 1.575 1.575 0 10-2.228-2.228 3.818 3.818 0 00-1.12 2.687M6.9 7.575V12m6.27 4.318A4.49 4.49 0 0116.35 15m.002 0h-.002`,clock:`M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z`,calendar:`M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5`,tag:`M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 005.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 009.568 3z M6 6h.008v.008H6V6z`,scale:`M12 3v17.25m0 0c-1.472 0-2.882.265-4.185.75M12 20.25c1.472 0 2.882.265 4.185.75M18.75 4.97A48.416 48.416 0 0012 4.5c-2.291 0-4.545.16-6.75.47m13.5 0c1.01.143 2.01.317 3 .52m-3-.52l2.62 10.726c.122.499-.106 1.028-.589 1.202a5.988 5.988 0 01-2.031.352 5.988 5.988 0 01-2.031-.352c-.483-.174-.711-.703-.59-1.202L18.75 4.971zm-16.5.52c.99-.203 1.99-.377 3-.52m0 0l2.62 10.726c.122.499-.106 1.028-.589 1.202a5.989 5.989 0 01-2.031.352 5.989 5.989 0 01-2.031-.352c-.483-.174-.711-.703-.59-1.202L5.25 4.971z`,"academic-cap":`M4.26 10.147a60.436 60.436 0 00-.491 6.347A48.627 48.627 0 0112 20.904a48.627 48.627 0 018.232-4.41 60.46 60.46 0 00-.491-6.347m-15.482 0a50.57 50.57 0 00-2.658-.813A59.905 59.905 0 0112 3.493a59.902 59.902 0 0110.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.697 50.697 0 0112 13.489a50.702 50.702 0 017.74-3.342M6.75 15a.75.75 0 100-1.5.75.75 0 000 1.5zm0 0v-3.675A55.378 55.378 0 0112 8.443m-7.007 11.55A5.981 5.981 0 006.75 15.75v-1.5`,"book-open":`M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25`,briefcase:`M20.25 14.15v4.25c0 1.094-.787 2.036-1.872 2.18-2.087.277-4.216.42-6.378.42s-4.291-.143-6.378-.42c-1.085-.144-1.872-1.086-1.872-2.18v-4.25m16.5 0a2.18 2.18 0 00.75-1.661V8.706c0-1.081-.768-2.015-1.837-2.175a48.114 48.114 0 00-3.413-.387m4.5 8.006c-.194.165-.42.295-.673.38A23.978 23.978 0 0112 15.75c-2.648 0-5.195-.429-7.577-1.22a2.016 2.016 0 01-.673-.38m0 0A2.18 2.18 0 013 12.489V8.706c0-1.081.768-2.015 1.837-2.175a48.111 48.111 0 013.413-.387m7.5 0V5.25A2.25 2.25 0 0013.5 3h-3a2.25 2.25 0 00-2.25 2.25v.894m7.5 0a48.667 48.667 0 00-7.5 0M12 12.75h.008v.008H12v-.008z`,beaker:`M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23-.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0112 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5`,bolt:`M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z`,sparkles:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z`,"shield-check":`M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z`,"rocket-launch":`M15.59 14.37a6 6 0 01-5.84 7.38v-4.8m5.84-2.58a14.98 14.98 0 006.16-12.12A14.98 14.98 0 009.631 8.41m5.96 5.96a14.926 14.926 0 01-5.841 2.58m-.119-8.54a6 6 0 00-7.381 5.84h4.8m2.581-5.84a14.927 14.927 0 00-2.58 5.84m2.699 2.7c-.103.021-.207.041-.311.06a15.09 15.09 0 01-2.448-2.448 14.9 14.9 0 01.06-.312m-2.24 2.39a4.493 4.493 0 00-1.757 4.306 4.493 4.493 0 004.306-1.758M16.5 9a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z`,wrench:`M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z`,truck:`M8.25 18.75a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h6m-9 0H3.375a1.125 1.125 0 01-1.125-1.125V14.25m17.25 4.5a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h1.125c.621 0 1.129-.504 1.09-1.124a17.902 17.902 0 00-3.213-9.193 2.056 2.056 0 00-1.58-.86H14.25M16.5 18.75h-2.25m0-11.177v-.958c0-.568-.422-1.048-.987-1.106a48.554 48.554 0 00-10.026 0 1.106 1.106 0 00-.987 1.106v7.635m12-6.677v6.677m0 4.5v-4.5m0 0h-12`},ka={"fa-file-alt":`document-text`,"fa-file":`document`,"fa-folder":`folder`,"fa-folder-open":`folder-open`,"fa-home":`home`,"fa-cog":`cog-6-tooth`,"fa-cogs":`cog-6-tooth`,"fa-bars":`bars-3`,"fa-list":`list-bullet`,"fa-list-alt":`list-bullet`,"fa-th":`squares-2x2`,"fa-sitemap":`squares-2x2`,"fa-user":`user`,"fa-users":`users`,"fa-user-group":`user-group`,"fa-info-circle":`information-circle`,"fa-question-circle":`question-mark-circle`,"fa-chart-bar":`chart-bar`,"fa-chart-line":`presentation-chart-line`,"fa-building":`building-office`,"fa-briefcase":`briefcase`,"fa-map-marker-alt":`map-pin`,"fa-map-marked-alt":`map-pin`,"fa-map":`map-pin`,"fa-globe":`globe-alt`,"fa-newspaper":`newspaper`,"fa-image":`photo`,"fa-images":`photo`,"fa-heart":`heart`,"fa-star":`star`,"fa-check-circle":`check-circle`,"fa-hands-helping":`hand-raised`,"fa-handshake":`hand-raised`,"fa-clock":`clock`,"fa-history":`clock`,"fa-calendar":`calendar`,"fa-calendar-alt":`calendar`,"fa-tag":`tag`,"fa-tags":`tag`,"fa-balance-scale":`scale`,"fa-bullseye":`check-circle`,"fa-graduation-cap":`academic-cap`,"fa-book":`book-open`,"fa-book-open":`book-open`,"fa-flask":`beaker`,"fa-bolt":`bolt`,"fa-magic":`sparkles`,"fa-shield-alt":`shield-check`,"fa-rocket":`rocket-launch`,"fa-wrench":`wrench`,"fa-truck":`truck`};function Aa(e){return e.startsWith(`Fa`)&&!e.startsWith(`fa-`)?`fa-`+e.slice(2).replace(/([A-Z])/g,`-$1`).toLowerCase().replace(/^-/,``):e}function ja(e){if(!e)return{library:`heroicons`,name:`document`};if(e.startsWith(`svg-fill`)){let t=e.match(/^svg-fill\[([^\]]+)\]:(.+)$/);return t?{library:`custom-svg`,name:t[2],style:`fill`,viewBox:t[1]}:{library:`custom-svg`,name:e.slice(9),style:`fill`}}if(e.startsWith(`svg`)){let t=e.match(/^svg\[([^\]]+)\]:(.+)$/);if(t)return{library:`custom-svg`,name:t[2],style:`stroke`,viewBox:t[1]};if(e.startsWith(`svg:`))return{library:`custom-svg`,name:e.slice(4),style:`stroke`}}if(e.startsWith(`hi:`))return{library:`heroicons`,name:e.slice(3)};if(e.startsWith(`fa:`)){let t=e.slice(3),n=ka[`fa-${t}`]||ka[t];return n?{library:`heroicons`,name:n}:{library:`fontawesome`,name:t}}if(e.startsWith(`Fa`)){let t=Aa(e),n=ka[t];return n?{library:`heroicons`,name:n}:{library:`fontawesome`,name:t.replace(`fa-`,``)}}return{library:`heroicons`,name:e}}function Ma(e,t=16,n){let r=Oa[e];return r?(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:r})}):Ma(`document`,t,n)}function Na(e,t=16,n){let r=e.startsWith(`fa-`)?`fas ${e}`:`fas fa-${e}`;return(0,V.jsx)(`i`,{className:`${r} ${n||``}`,style:{fontSize:t,width:t,height:t,display:`inline-flex`,alignItems:`center`,justifyContent:`center`}})}function Pa(e,t=16,n,r=`stroke`,i=`0 0 24 24`){return r===`fill`?(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:i,fill:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{d:e})}):(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:i,strokeWidth:1.5,stroke:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:e})})}function Fa(e,t=16,n){let r=ja(e);return r.library===`custom-svg`?Pa(r.name,t,n,r.style,r.viewBox):r.library===`heroicons`?Ma(r.name,t,n):Na(r.name,t,n)}function Ia({isMobile:e=!1,onItemClick:t}){let{t:n}=H(`studio`),{t:r}=H(`common`),i=d(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(new Set),[l,f]=(0,B.useState)(``),{navigation:p,loading:m,error:h}=_a(),g=()=>{t&&t()},_=()=>{o(!a);try{localStorage.setItem(`trokky_sidebar_collapsed`,JSON.stringify(!a))}catch(e){console.warn(`Failed to save sidebar state:`,e)}};(0,B.useEffect)(()=>{if(!e)try{let e=localStorage.getItem(`trokky_sidebar_collapsed`);e&&o(JSON.parse(e))}catch(e){console.warn(`Failed to restore sidebar state:`,e)}},[e]);let v=e=>e===`/`?i.pathname===`/`:i.pathname===e||i.pathname.startsWith(e+`/`),y=e=>e.type!==`group`||!e.children?!1:e.children.some(e=>{if(e.type===`group`)return y(e);let t=e.path;if(!t){let n=e.schemaType;n&&(e.type===`documentList`?t=`/content/${n}`:e.type===`singleton`&&(t=`/content/${n}/${e.documentId||n}`))}return t?v(t):!1}),b=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,B.useEffect)(()=>{if(!p)return;let e=new Set,t=n=>{n.forEach(n=>{n.type===`group`&&y(n)&&(e.add(n.id),n.children&&t(n.children))})};t(p.items),c(e)},[i.pathname,p]);let x=e=>e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().trim(),S=(0,B.useMemo)(()=>{if(!p||!l.trim())return p;let e=x(l),t=n=>n.reduce((n,r)=>{let i=r.title?x(r.title).includes(e):!1;if(r.type===`group`&&r.children){let e=t(r.children);(e.length>0||i)&&n.push({...r,children:e.length>0?e:r.children})}else r.type===`divider`?n.length>0&&n.push(r):i&&n.push(r);return n},[]);return{...p,items:t(p.items)}},[p,l]);(0,B.useEffect)(()=>{if(!S||!l.trim())return;let e=new Set,t=n=>{n.forEach(n=>{n.type===`group`&&(e.add(n.id),n.children&&t(n.children))})};t(S.items),c(e)},[l,S]);let C=(e,t=0)=>{let n=e.icon||`document`,r=e.path;if(!r){let t=e.schemaType;t&&(e.type===`documentList`?r=`/content/${t}`:e.type===`singleton`&&(r=`/content/${t}/${e.documentId||t}`))}let i=r?v(r):!1;if(e.type===`divider`)return a?null:(0,V.jsx)(`div`,{className:wr(`border-t border-gray-200 dark:border-gray-700`,t===0?`mx-4 my-2`:`mx-2 my-1`),children:e.title&&(0,V.jsx)(`div`,{className:`px-3 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e.title})},e.id);if(e.type===`group`){if(a)return(0,V.jsx)(`div`,{children:e.children?.map(e=>C(e,t))},e.id);let n=s.has(e.id),r=y(e);return(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`button`,{onClick:()=>b(e.id),className:wr(`w-full flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider rounded-lg transition-colors`,r?`text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,V.jsx)(`span`,{children:e.title}),n?(0,V.jsx)(Xe,{className:`h-4 w-4`}):(0,V.jsx)(ye,{className:`h-4 w-4`})]}),n&&e.children&&(0,V.jsx)(`div`,{className:`space-y-1`,children:e.children.map(e=>C(e,t+1))})]},e.id)}return r?(0,V.jsxs)(u,{to:r,onClick:g,className:({isActive:e})=>wr(`flex items-center transition-colors`,a?`p-2 mx-1 rounded-lg justify-center`:`px-3 py-1.5 rounded-lg text-sm`,t>0&&!a&&`ml-4`,e||i?a?`bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300`:`bg-primary-50 text-primary-700 border-r-2 border-primary-500 dark:bg-primary-900/20 dark:text-primary-300`:`text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white`),title:a?e.title:void 0,children:[(0,V.jsx)(`span`,{className:wr(`flex-shrink-0`,a?``:`mr-2`),children:Fa(n,16)}),!a&&(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(`span`,{className:`block truncate`,children:e.title})})]},e.id):null};return(0,V.jsxs)(`div`,{className:wr(`h-full bg-white dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 flex flex-col transition-all duration-200`,e?`w-64`:a?`w-16`:`w-64`),children:[!e&&(0,V.jsxs)(`div`,{className:wr(`flex items-center p-4 border-b border-gray-200 dark:border-gray-700`,a?`justify-center`:`justify-between`),children:[!a&&(0,V.jsx)(`h2`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:n(`sidebar.navigation`)}),(0,V.jsx)(`button`,{onClick:_,className:`p-1 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 flex-shrink-0`,title:n(a?`sidebar.expand`:`sidebar.collapse`),children:a?(0,V.jsx)(z,{className:`h-4 w-4`}):(0,V.jsx)(be,{className:`h-4 w-4`})})]}),!a&&(0,V.jsx)(`div`,{className:`p-4 border-b border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,value:l,onChange:e=>f(e.target.value),placeholder:n(`sidebar.searchNavigation`),className:`w-full pl-9 pr-8 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent`}),l&&(0,V.jsx)(`button`,{onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600`,title:r(`actions.clear`),children:(0,V.jsx)(tt,{className:`h-4 w-4`})})]})}),(0,V.jsxs)(`nav`,{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-1`,children:[m&&(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,V.jsx)(`div`,{className:`animate-spin h-5 w-5 border-2 border-primary-500 border-t-transparent rounded-full`}),!a&&(0,V.jsx)(`span`,{className:`ml-2 text-sm text-gray-500 dark:text-gray-400`,children:n(`sidebar.loadingNavigation`)})]}),h&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n(`sidebar.failedToLoad`)})}),S&&S.items.length>0?(0,V.jsx)(V.Fragment,{children:S.items.map(e=>C(e))}):l&&p?(0,V.jsxs)(`div`,{className:`text-center py-8`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`sidebar.noResultsFor`,{query:l})}),(0,V.jsx)(`button`,{onClick:()=>f(``),className:`mt-2 text-sm text-primary-600 dark:text-primary-400 hover:underline`,children:n(`sidebar.clearSearch`)})]}):(0,V.jsxs)(V.Fragment,{children:[!a&&(0,V.jsx)(`div`,{className:`px-3 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:n(`nav.content`)}),(0,V.jsxs)(u,{to:`/content`,onClick:g,className:({isActive:e})=>wr(`flex items-center transition-colors`,a?`p-2 mx-1 rounded-lg justify-center`:`px-3 py-2 rounded-lg`,e?a?`bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300`:`bg-primary-50 text-primary-700 border-r-2 border-primary-500 dark:bg-primary-900/20 dark:text-primary-300`:`text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white`),title:a?n(`nav.content`):void 0,children:[(0,V.jsx)(pe,{className:wr(`h-5 w-5 flex-shrink-0`,a?``:`mr-3`)}),!a&&(0,V.jsx)(`span`,{className:`font-medium`,children:n(`nav.content`)})]})]})]}),!a&&(0,V.jsx)(`div`,{className:`p-4 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 text-center`,children:(0,V.jsx)(`p`,{children:`Trokky Studio`})})})]})}var La=(0,B.createContext)(null);function Ra({children:e}){let[t,n]=(0,B.useState)(()=>({currentPage:`default`,title:`Context`,isVisible:!0,isCollapsed:!1,width:256,position:`left`,content:null})),r=(0,B.useCallback)((e,t,n)=>{let r=t===`visible`?Lr.CONTEXT_SIDEBAR_VISIBLE(e):t===`collapsed`?Lr.CONTEXT_SIDEBAR_COLLAPSED(e):t===`width`?Lr.CONTEXT_SIDEBAR_WIDTH(e):t===`position`?Lr.CONTEXT_SIDEBAR_POSITION(e):``;r&&Rr.set(r,n)},[]),i=(0,B.useCallback)(e=>{let t=e.page;n(n=>{if(n.currentPage===t&&n.title===(e.title??`Context`)&&n.isVisible===(e.defaultVisible??!0))return n;let r=Rr.get(Lr.CONTEXT_SIDEBAR_COLLAPSED(t)),i=Rr.get(Lr.CONTEXT_SIDEBAR_WIDTH(t)),a=Rr.get(Lr.CONTEXT_SIDEBAR_POSITION(t)),o=e.defaultVisible??!0,s=r===null?e.defaultCollapsed??!1:r,c=i===null?e.defaultWidth??256:i,l=a===null?e.defaultPosition??`left`:a,u=n.currentPage!==t;return{...n,currentPage:t,title:e.title??`Context`,isVisible:o,isCollapsed:s,width:c,position:l,content:u?null:n.content}})},[]),a=(0,B.useCallback)(()=>{n(e=>(r(e.currentPage,`collapsed`,!0),{...e,isCollapsed:!0}))},[r]),o=(0,B.useCallback)(()=>{n(e=>(r(e.currentPage,`collapsed`,!1),{...e,isCollapsed:!1}))},[r]),s=(0,B.useCallback)(()=>{n(e=>{let t=!e.isCollapsed;return r(e.currentPage,`collapsed`,t),{...e,isCollapsed:t}})},[r]),c=(0,B.useCallback)(e=>{n(t=>(r(t.currentPage,`width`,e),{...t,width:e}))},[r]),l=(0,B.useCallback)(e=>{n(t=>(r(t.currentPage,`position`,e),{...t,position:e}))},[r]),u=(0,B.useCallback)(e=>n(t=>({...t,content:e})),[]),d=(0,B.useCallback)(()=>n(e=>({...e,content:null})),[]),f=(0,B.useCallback)(e=>n(t=>({...t,title:e})),[]),p=(0,B.useMemo)(()=>({configure:i,collapse:a,expand:o,toggleCollapse:s,setWidth:c,setPosition:l,setContent:u,clearContent:d,setTitle:f,currentPage:t.currentPage,title:t.title,isVisible:t.isVisible,isCollapsed:t.isCollapsed,width:t.width,position:t.position,content:t.content}),[i,a,o,s,c,l,u,d,f,t.currentPage,t.title,t.isVisible,t.isCollapsed,t.width,t.position,t.content]);return(0,V.jsx)(La.Provider,{value:p,children:e})}function za(e){let t=(0,B.useContext)(La);if(!t)throw Error(`useContextSidebar must be used within a ContextSidebarProvider`);let{configure:n}=t;return(0,B.useEffect)(()=>{e&&n(e)},[e?.page,e?.title,e?.defaultVisible,e?.defaultCollapsed,e?.defaultWidth,e?.defaultPosition,n]),t}function Ba({defaultWidth:e=256,minWidth:t=200,maxWidth:n=500,position:r=`left`}){let{t:i}=H(`studio`),a=za(),[o,s]=(0,B.useState)(!1),c=a.isCollapsed,l=a.width||e,u=a.isVisible,d=e=>{e.preventDefault(),s(!0);let i=e.clientX,o=l,c=e=>{let s=e.clientX-i,c=r===`right`?o-s:o+s;c>=t&&c<=n&&a.setWidth(c)},u=()=>{s(!1),document.removeEventListener(`mousemove`,c),document.removeEventListener(`mouseup`,u),document.body.style.cursor=``,document.body.style.userSelect=``};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,c),document.addEventListener(`mouseup`,u)},f=()=>{a.toggleCollapse()};return u?c?(0,V.jsxs)(`div`,{className:wr(`w-12 h-full bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-700 flex flex-col`,r===`left`?`border-r`:`border-l`),children:[(0,V.jsx)(`div`,{className:`p-2 flex-shrink-0`,children:(0,V.jsx)(`button`,{onClick:f,className:`w-8 h-8 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 flex items-center justify-center`,title:i(`layout.expandContext`),children:r===`left`?(0,V.jsx)(z,{className:`h-4 w-4`}):(0,V.jsx)(be,{className:`h-4 w-4`})})}),(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-4`,children:(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-400 whitespace-nowrap`,style:{writingMode:`vertical-rl`,textOrientation:`mixed`,transform:`rotate(180deg)`},title:a.title,children:a.title})})]}):(0,V.jsxs)(`div`,{className:wr(`h-full bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-700 flex flex-col relative`,r===`left`?`border-r`:`border-l`,o&&`select-none`),style:{width:`${l}px`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:a.title}),(0,V.jsx)(`button`,{onClick:f,className:`p-1 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700`,title:i(`layout.collapseContext`),children:r===`left`?(0,V.jsx)(be,{className:`h-4 w-4`}):(0,V.jsx)(z,{className:`h-4 w-4`})})]}),(0,V.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:a.content?a.content:null}),(0,V.jsx)(`div`,{className:wr(`absolute top-0 w-1 h-full cursor-col-resize hover:bg-blue-500 hover:w-1.5 transition-all duration-150`,r===`left`?`right-0`:`left-0`),onMouseDown:d,title:i(`layout.resizeSidebar`)})]}):null}function Va({showSearch:e=!0,showMedia:t=!0,showUserMenu:n=!0}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)(!1),s=za(),c=()=>{a(!0)},l=()=>{a(!1)};return(0,B.useEffect)(()=>{if(i)return Ki(Wi(Ui.lg),l)},[i]),(0,V.jsxs)(`div`,{className:`h-dvh flex flex-col bg-gray-50 dark:bg-gray-900`,children:[(0,V.jsx)(Da,{onOpenMobileMenu:c,showSearch:e,showMedia:t,showUserMenu:n}),(0,V.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`hidden lg:flex`,children:(0,V.jsx)(Ia,{})}),s.position===`left`&&(0,V.jsx)(`div`,{className:`flex`,children:(0,V.jsx)(Ba,{position:`left`})}),(0,V.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto bg-white dark:bg-gray-800`,children:(0,V.jsx)(o,{})}),s.position===`right`&&(0,V.jsx)(`div`,{className:`flex`,children:(0,V.jsx)(Ba,{position:`right`})})]}),(0,V.jsx)(ia,{open:i,onClose:l,variant:`drawer-left`,size:`xs`,wrapperClassName:`lg:hidden`,title:r(`sidebar.navigation`),children:(0,V.jsx)(ia.Body,{padded:!1,children:(0,V.jsx)(Ia,{isMobile:!0,onItemClick:l})})})]})}function Ha(e){return(0,V.jsx)(Ra,{children:(0,V.jsx)(Va,{...e})})}var Ua={title:`Something went wrong`,subtitle:`The application encountered an unexpected error`,description:`Please try refreshing the page or contact support if the problem persists. You can copy the error details below to help with troubleshooting.`,errorMessage:`Error Message:`,stackTrace:`Stack Trace`,componentStack:`Component Stack`,environmentDetails:`Environment Details`,noStackTrace:`No stack trace available`,noComponentStack:`No component stack available`,url:`URL:`,timestamp:`Timestamp:`,userAgent:`User Agent:`,viewport:`Viewport:`,tryAgain:`Try again`,refreshPage:`Refresh page`,copyErrorDetails:`Copy Error Details`,copied:`Copied!`},Wa=class extends B.Component{constructor(e){super(e),this.state={hasError:!1,copied:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e,copied:!1}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error:`,e,t),this.setState({errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0,copied:!1})};handleCopyError=async()=>{if(!this.state.error)return;let e=this.getErrorDetails();try{await navigator.clipboard.writeText(e),this.setState({copied:!0}),setTimeout(()=>this.setState({copied:!1}),2e3)}catch(e){console.error(`Failed to copy error details:`,e)}};getErrorDetails=()=>{let{error:e,errorInfo:t}=this.state;if(!e)return``;let n=new Date().toISOString(),r=navigator.userAgent;return`Trokky Studio Error Report
1
+ import{n as e,t}from"./rolldown-runtime-CbXtAM7H.js";import{a as n,c as r,d as i,f as a,i as o,l as s,n as c,o as l,r as u,s as d,t as f,u as p}from"./router-Dpg4KYTB.js";import{t as m}from"./vendor-igJJvL5X.js";import{_ as h,a as g,b as _,c as v,d as y,f as b,g as x,h as S,i as C,l as w,m as T,n as E,o as D,p as O,r as k,s as A,t as j,u as M,v as N,y as P}from"./query-CieM36kR.js";import{$ as F,A as I,B as L,C as ee,D as R,E as te,F as ne,G as re,H as ie,I as ae,J as z,K as oe,L as se,M as ce,N as le,O as ue,P as de,Q as fe,R as pe,S as me,T as he,U as ge,V as _e,W as ve,X as ye,Y as be,Z as xe,_ as Se,a as Ce,at as we,b as Te,c as Ee,ct as De,d as Oe,dt as ke,et as Ae,f as je,ft as Me,g as Ne,h as Pe,ht as Fe,i as Ie,it as Le,j as Re,k as ze,l as Be,lt as Ve,m as He,mt as Ue,n as We,nt as Ge,o as Ke,ot as qe,p as Je,pt as Ye,q as Xe,r as Ze,rt as Qe,s as $e,st as et,t as tt,tt as nt,u as rt,ut as it,v as at,w as ot,x as st,y as ct,z as lt}from"./ui-D5AGhrb0.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ut=class extends k{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||dt(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??(this.state.status===`pending`?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=C({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)}),i=this.state.status===`pending`,a=!r.canStart();try{if(i)t();else{this.#i({type:`pending`,variables:e,isPaused:a}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:a})}let o=await r.start();return await this.#n.config.onSuccess?.(o,e,this.state.context,this,n),await this.options.onSuccess?.(o,e,this.state.context,n),await this.#n.config.onSettled?.(o,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(o,null,e,this.state.context,n),this.#i({type:`success`,data:o}),o}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function dt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var ft=class extends v{#e;#t;#n;constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}build(e,t,n){let r=new ut({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t);if(n){if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=pt(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}return!0}runNext(e){let t=pt(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){D.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>b(t,e))}findAll(e={}){return this.getAll().filter(t=>b(e,t))}notify(e){D.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return D.batch(()=>Promise.all(e.map(e=>e.continue().catch(T))))}};function pt(e){return e.options.scope?.id}var mt=class extends v{#e;constructor(e={}){super(),this.config=e,this.#e=new Map}build(e,t,n){let r=t.queryKey,i=t.queryHash??y(r,t),a=this.get(i);return a||(a=new E({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){D.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>O(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>O(e,t)):t}notify(e){D.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){D.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){D.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ht=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new mt,this.#t=e.mutationCache||new ft,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=A.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=g.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(x(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=w(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return D.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;D.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return D.batch(()=>{let r=n.findAll(e),i=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,predicate:e=>i.has(e)},t)})}cancelQueries(e,t={}){let n={revert:!0,...t},r=D.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(T).catch(T)}invalidateQueries(e,t={}){return D.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=D.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(T)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(T)}async query(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t),r=n.isStaleByTime(x(t.staleTime,n))?await n.fetch(t):n.state.data,i=t.select;return i?i(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(x(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(T).catch(T)}infiniteQuery(e){return e._type=`infinite`,this.query(e)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(T).catch(T)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return g.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(M(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{S(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(M(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{S(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=y(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===h&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},gt=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Ct(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},_t={},vt=(e,t,n,r)=>{Ct(n)&&_t[n]||(Ct(n)&&(_t[n]=new Date),gt(e,t,n,r))},yt=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},bt=(e,t,n)=>{e.loadNamespaces(t,yt(e,n))},xt=(e,t,n,r)=>{if(Ct(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return bt(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,yt(e,r))},St=(e,t,n={})=>!t.languages||!t.languages.length?(vt(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Ct=e=>typeof e==`string`,wt=e=>typeof e==`object`&&!!e,Tt=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,Et={"&amp;":`&`,"&#38;":`&`,"&lt;":`<`,"&#60;":`<`,"&gt;":`>`,"&#62;":`>`,"&apos;":`'`,"&#39;":`'`,"&quot;":`"`,"&#34;":`"`,"&nbsp;":` `,"&#160;":` `,"&copy;":`©`,"&#169;":`©`,"&reg;":`®`,"&#174;":`®`,"&hellip;":`…`,"&#8230;":`…`,"&#x2F;":`/`,"&#47;":`/`},Dt=e=>Et[e],Ot={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(Tt,Dt)},kt=(e={})=>{Ot={...Ot,...e}},At=()=>Ot,jt,Mt=e=>{jt=e},Nt=()=>jt,Pt={type:`3rdParty`,init(e){kt(e.options.react),Mt(e)}},B=e(a()),Ft=(0,B.createContext)(),It=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},Lt=(e,t)=>{let n=(0,B.useRef)();return(0,B.useEffect)(()=>{n.current=t?n.current:e},[e,t]),n.current},Rt=(e,t,n,r)=>e.getFixedT(t,n,r),zt=(e,t,n,r)=>(0,B.useCallback)(Rt(e,t,n,r),[e,t,n,r]),Bt=(e,t={})=>{let{i18n:n}=t,{i18n:r,defaultNS:i}=(0,B.useContext)(Ft)||{},a=n||r||Nt();if(a&&!a.reportNamespaces&&(a.reportNamespaces=new It),!a){vt(a,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next`);let e=(e,t)=>Ct(t)?t:wt(t)&&Ct(t.defaultValue)?t.defaultValue:Array.isArray(e)?e[e.length-1]:e,t=[e,{},!1];return t.t=e,t.i18n={},t.ready=!1,t}a.options.react?.wait&&vt(a,`DEPRECATED_OPTION`,`useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.`);let o={...At(),...a.options.react,...t},{useSuspense:s,keyPrefix:c}=o,l=e||i||a.options?.defaultNS;l=Ct(l)?[l]:l||[`translation`],a.reportNamespaces.addUsedNamespaces?.(l);let u=(a.isInitialized||a.initializedStoreOnce)&&l.every(e=>St(e,a,o)),d=zt(a,t.lng||null,o.nsMode===`fallback`?l:l[0],c),f=()=>d,p=()=>Rt(a,t.lng||null,o.nsMode===`fallback`?l:l[0],c),[m,h]=(0,B.useState)(f),g=l.join();t.lng&&(g=`${t.lng}${g}`);let _=Lt(g),v=(0,B.useRef)(!0);(0,B.useEffect)(()=>{let{bindI18n:e,bindI18nStore:n}=o;v.current=!0,!u&&!s&&(t.lng?xt(a,t.lng,l,()=>{v.current&&h(p)}):bt(a,l,()=>{v.current&&h(p)})),u&&_&&_!==g&&v.current&&h(p);let r=()=>{v.current&&h(p)};return e&&a?.on(e,r),n&&a?.store.on(n,r),()=>{v.current=!1,a&&e&&e?.split(` `).forEach(e=>a.off(e,r)),n&&a&&n.split(` `).forEach(e=>a.store.off(e,r))}},[a,g]),(0,B.useEffect)(()=>{v.current&&u&&h(f)},[a,c,u]);let y=[m,a,u];if(y.t=m,y.i18n=a,y.ready=u,u||!u&&!s)return y;throw new Promise(e=>{t.lng?xt(a,t.lng,l,()=>e()):bt(a,l,()=>e())})};function Vt({i18n:e,defaultNS:t,children:n}){let r=(0,B.useMemo)(()=>({i18n:e,defaultNS:t}),[e,t]);return(0,B.createElement)(Ft.Provider,{value:r},n)}var Ht=e(i(),1),Ut=e(m(),1),V=_(),Wt=e=>typeof e==`string`,Gt=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},Kt=e=>e==null?``:``+e,qt=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},Jt=/###/g,Yt=e=>e&&e.indexOf(`###`)>-1?e.replace(Jt,`.`):e,Xt=e=>!e||Wt(e),Zt=(e,t,n)=>{let r=Wt(t)?t.split(`.`):t,i=0;for(;i<r.length-1;){if(Xt(e))return{};let t=Yt(r[i]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++i}return Xt(e)?{}:{obj:e,k:Yt(r[i])}},Qt=(e,t,n)=>{let{obj:r,k:i}=Zt(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=Zt(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=Zt(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},$t=(e,t,n,r)=>{let{obj:i,k:a}=Zt(e,t,Object);i[a]=i[a]||[],i[a].push(n)},en=(e,t)=>{let{obj:n,k:r}=Zt(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},tn=(e,t,n)=>{let r=en(e,n);return r===void 0?en(t,n):r},nn=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(r in e?Wt(e[r])||e[r]instanceof String||Wt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):nn(e[r],t[r],n):e[r]=t[r]);return e},rn=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),an={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`,"/":`&#x2F;`},on=e=>Wt(e)?e.replace(/[&<>"'\/]/g,e=>an[e]):e,sn=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},cn=[` `,`,`,`?`,`!`,`;`],ln=new sn(20),un=(e,t,n)=>{t||=``,n||=``;let r=cn.filter(e=>t.indexOf(e)<0&&n.indexOf(e)<0);if(r.length===0)return!0;let i=ln.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},dn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:`.`;if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].indexOf(typeof t)>-1&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},fn=e=>e?.replace(`_`,`-`),pn={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},mn=new class e{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.init(e,t)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=t.prefix||`i18next:`,this.logger=e||pn,this.options=t,this.debug=t.debug}log(){var e=[...arguments];return this.forward(e,`log`,``,!0)}warn(){var e=[...arguments];return this.forward(e,`warn`,``,!0)}error(){var e=[...arguments];return this.forward(e,`error`,``)}deprecate(){var e=[...arguments];return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(Wt(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},hn=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){if(this.observers[e]){if(!t){delete this.observers[e];return}this.observers[e].delete(t)}}emit(e){var t=[...arguments].slice(1);this.observers[e]&&Array.from(this.observers[e].entries()).forEach(e=>{let[n,r]=e;for(let e=0;e<r;e++)n(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(n=>{let[r,i]=n;for(let n=0;n<i;n++)r.apply(r,[e,...t])})}},gn=class extends hn{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:[`translation`],defaultNS:`translation`};super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,a=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,o;e.indexOf(`.`)>-1?o=e.split(`.`):(o=[e,t],n&&(Array.isArray(n)?o.push(...n):Wt(n)&&i?o.push(...n.split(i)):o.push(n)));let s=en(this.data,o);return!s&&!t&&!n&&e.indexOf(`.`)>-1&&(e=o[0],t=o[1],n=o.slice(2).join(`.`)),s||!a||!Wt(n)?s:dn(this.data?.[e]?.[t],n,i)}addResource(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.indexOf(`.`)>-1&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),Qt(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(let r in n)(Wt(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},o=[e,t];e.indexOf(`.`)>-1&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=en(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?nn(s,n,i):s={...s,...n},Qt(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>t[e]&&Object.keys(t[e]).length>0)}toJSON(){return this.data}},_n={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},vn={},yn=e=>!Wt(e)&&typeof e!=`boolean`&&typeof e!=`number`,bn=class e extends hn{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),qt([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=mn.create(`translator`)}changeLanguage(e){e&&(this.language=e)}exists(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};return e!=null&&this.resolve(e,t)?.res!==void 0}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,i=t.ns||this.options.defaultNS||[],a=n&&e.indexOf(n)>-1,o=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!un(e,n,r);if(a&&!o){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:Wt(i)?[i]:i};let a=e.split(n);(n!==r||n===r&&this.options.ns.indexOf(a[0])>-1)&&(i=a.shift()),e=a.join(r)}return{key:e,namespaces:Wt(i)?[i]:i}}translate(t,n,r){if(typeof n!=`object`&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n==`object`&&(n={...n}),n||={},t==null)return``;Array.isArray(t)||(t=[String(t)]);let i=n.returnDetails===void 0?this.options.returnDetails:n.returnDetails,a=n.keySeparator===void 0?this.options.keySeparator:n.keySeparator,{key:o,namespaces:s}=this.extractFromKey(t[t.length-1],n),c=s[s.length-1],l=n.lng||this.language,u=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l?.toLowerCase()===`cimode`){if(u){let e=n.nsSeparator||this.options.nsSeparator;return i?{res:`${c}${e}${o}`,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${e}${o}`}return i?{res:o,usedKey:o,exactUsedKey:o,usedLng:l,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:o}let d=this.resolve(t,n),f=d?.res,p=d?.usedKey||o,m=d?.exactUsedKey||o,h=[`[object Number]`,`[object Function]`,`[object RegExp]`],g=n.joinArrays===void 0?this.options.joinArrays:n.joinArrays,_=!this.i18nFormat||this.i18nFormat.handleAsObject,v=n.count!==void 0&&!Wt(n.count),y=e.hasDefaultValue(n),b=v?this.pluralResolver.getSuffix(l,n.count,n):``,x=n.ordinal&&v?this.pluralResolver.getSuffix(l,n.count,{ordinal:!1}):``,S=v&&!n.ordinal&&n.count===0,C=S&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${b}`]||n[`defaultValue${x}`]||n.defaultValue,w=f;_&&!f&&y&&(w=C);let T=yn(w),E=Object.prototype.toString.apply(w);if(_&&w&&T&&h.indexOf(E)<0&&!(Wt(g)&&Array.isArray(w))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(p,w,{...n,ns:s}):`key '${o} (${this.language})' returned an object instead of string.`;return i?(d.res=e,d.usedParams=this.getUsedParamsDetails(n),d):e}if(a){let e=Array.isArray(w),t=e?[]:{},r=e?m:p;for(let e in w)if(Object.prototype.hasOwnProperty.call(w,e)){let i=`${r}${a}${e}`;t[e]=y&&!f?this.translate(i,{...n,defaultValue:yn(C)?C[e]:void 0,joinArrays:!1,ns:s}):this.translate(i,{...n,joinArrays:!1,ns:s}),t[e]===i&&(t[e]=w[e])}f=t}}else if(_&&Wt(g)&&Array.isArray(f))f=f.join(g),f&&=this.extendTranslation(f,t,n,r);else{let e=!1,i=!1;!this.isValidLookup(f)&&y&&(e=!0,f=C),this.isValidLookup(f)||(i=!0,f=o);let s=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&i?void 0:f,u=y&&C!==f&&this.options.updateMissing;if(i||e||u){if(this.logger.log(u?`updateKey`:`missingKey`,l,c,o,u?C:f),a){let e=this.resolve(o,{...n,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(n.lng||this.language):e.push(n.lng||this.language);let r=(e,t,r)=>{let i=y&&r!==f?r:s;this.options.missingKeyHandler?this.options.missingKeyHandler(e,c,t,i,u,n):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,c,t,i,u,n),this.emit(`missingKey`,e,c,t,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&v?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,n);S&&n[`defaultValue${this.options.pluralSeparator}zero`]&&t.indexOf(`${this.options.pluralSeparator}zero`)<0&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{r([e],o+t,n[`defaultValue${t}`]||C)})}):r(e,o,C))}f=this.extendTranslation(f,t,n,d,r),i&&f===o&&this.options.appendNamespaceToMissingKey&&(f=`${c}:${o}`),(i||e)&&this.options.parseMissingKeyHandler&&(f=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${o}`:o,e?f:void 0))}return i?(d.res=f,d.usedParams=this.getUsedParamsDetails(n),d):f}extendTranslation(e,t,n,r,i){var a=this;if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let o=Wt(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),s;if(o){let t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let c=n.replace&&!Wt(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),e=this.interpolator.interpolate(e,c,n.lng||this.language||r.usedLng,n),o){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;s<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,function(){var e=[...arguments];return i?.[0]===e[0]&&!n.context?(a.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):a.translate(...e,t)},n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,s=Wt(o)?[o]:o;return e!=null&&s?.length&&n.applyPostProcessor!==!1&&(e=_n.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n,r,i,a,o;return Wt(e)&&(e=[e]),e.forEach(e=>{if(this.isValidLookup(n))return;let s=this.extractFromKey(e,t),c=s.key;r=c;let l=s.namespaces;this.options.fallbackNS&&(l=l.concat(this.options.fallbackNS));let u=t.count!==void 0&&!Wt(t.count),d=u&&!t.ordinal&&t.count===0,f=t.context!==void 0&&(Wt(t.context)||typeof t.context==`number`)&&t.context!==``,p=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);l.forEach(e=>{this.isValidLookup(n)||(o=e,!vn[`${p[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(o)&&(vn[`${p[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${p.join(`, `)}" won't get resolved as namespace "${o}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),p.forEach(r=>{if(this.isValidLookup(n))return;a=r;let o=[c];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(o,c,r,e,t);else{let e;u&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,i=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(u&&(o.push(c+e),t.ordinal&&e.indexOf(i)===0&&o.push(c+e.replace(i,this.options.pluralSeparator)),d&&o.push(c+n)),f){let r=`${c}${this.options.contextSeparator}${t.context}`;o.push(r),u&&(o.push(r+e),t.ordinal&&e.indexOf(i)===0&&o.push(r+e.replace(i,this.options.pluralSeparator)),d&&o.push(r+n))}}let s;for(;s=o.pop();)this.isValidLookup(n)||(i=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:i,usedLng:a,usedNS:o}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!Wt(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r.count=e.count),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.substring(0,12)===`defaultValue`&&e[t]!==void 0)return!0;return!1}},xn=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=mn.create(`languageUtils`)}getScriptPartFromCode(e){if(e=fn(e),!e||e.indexOf(`-`)<0)return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=fn(e),!e||e.indexOf(`-`)<0)return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(Wt(e)&&e.indexOf(`-`)>-1){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getLanguagePartFromCode(e);if(this.isSupportedCode(n))return t=n;t=this.options.supportedLngs.find(e=>{if(e===n||!(e.indexOf(`-`)<0&&n.indexOf(`-`)<0)&&(e.indexOf(`-`)>0&&n.indexOf(`-`)<0&&e.substring(0,e.indexOf(`-`))===n||e.indexOf(n)===0&&n.length>1))return e})}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),Wt(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),r=[],i=e=>{e&&(this.isSupportedCode(e)?r.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return Wt(e)&&(e.indexOf(`-`)>-1||e.indexOf(`_`)>-1)?(this.options.load!==`languageOnly`&&i(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&i(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&i(this.getLanguagePartFromCode(e))):Wt(e)&&i(this.formatLanguageCode(e)),n.forEach(e=>{r.indexOf(e)<0&&i(this.formatLanguageCode(e))}),r}},Sn={zero:0,one:1,two:2,few:3,many:4,other:5},Cn={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},wn=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=e,this.options=t,this.logger=mn.create(`pluralResolver`),this.pluralRulesCache={}}addRule(e,t){this.rules[e]=t}clearCache(){this.pluralRulesCache={}}getRule(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=fn(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(!Intl)return this.logger.error(`No Intl support, please use an Intl polyfill!`),Cn;if(!e.match(/-|_/))return Cn;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>Sn[e]-Sn[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},Tn=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:`.`,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,a=tn(e,t,n);return!a&&i&&Wt(n)&&(a=dn(e,n,r),a===void 0&&(a=dn(t,n,r))),a},En=e=>e.replace(/\$/g,`$$$$`),Dn=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=mn.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:_}=e.interpolation;this.escape=t===void 0?on:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?rn(i):a||`{{`,this.suffix=o?rn(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u||`-`,this.unescapeSuffix=this.unescapePrefix?``:l||``,this.nestingPrefix=d?rn(d):f||rn(`$t(`),this.nestingSuffix=p?rn(p):m||rn(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=_!==void 0&&_,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let i,a,o,s=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},c=e=>{if(e.indexOf(this.formatSeparator)<0){let i=Tn(t,s,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(Tn(t,s,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp();let l=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,u=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>En(e)},{regex:this.regexp,safeValue:e=>this.escapeValue?En(this.escape(e)):En(e)}].forEach(t=>{for(o=0;i=t.regex.exec(e);){let n=i[1].trim();if(a=c(n),a===void 0){if(typeof l==`function`){let t=l(e,i,r);a=Wt(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))a=``;else if(u){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),a=``}else!Wt(a)&&!this.useRawValueToEscape&&(a=Kt(a));let s=t.safeValue(a);if(e=e.replace(i[0],s),u?(t.regex.lastIndex+=a.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,o++,o>=this.maxReplaces)break}}),e}nest(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r,i,a,o=(e,t)=>{let n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;let r=e.split(RegExp(`${n}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,a);let o=i.match(/'/g),s=i.match(/"/g);((o?.length??0)%2==0&&!s||s.length%2!=0)&&(i=i.replace(/'/g,`"`));try{a=JSON.parse(i),t&&(a={...t,...a})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,e};for(;r=this.nestingRegexp.exec(e);){let s=[];a={...n},a=a.replace&&!Wt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let c=!1;if(r[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(r[1])){let e=r[1].split(this.formatSeparator).map(e=>e.trim());r[1]=e.shift(),s=e,c=!0}if(i=t(o.call(this,r[1].trim(),a),a),i&&r[0]===e&&!Wt(i))return i;Wt(i)||(i=Kt(i)),i||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),c&&(i=s.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),i.trim())),e=e.replace(r[0],i),this.regexp.lastIndex=0}return e}},On=e=>{let t=e.toLowerCase().trim(),n={};if(e.indexOf(`(`)>-1){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].substring(0,r[1].length-1);t===`currency`&&i.indexOf(`:`)<0?n.currency||=i.trim():t===`relativetime`&&i.indexOf(`:`)<0?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},kn=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(fn(r),i),t[o]=s),s(n)}},An=class{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=mn.create(`formatter`),this.options=e,this.formats={number:kn((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:kn((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:kn((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:kn((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:kn((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})},this.init(e)}init(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=t.interpolation.formatSeparator||`,`}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=kn(t)}format(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},i=t.split(this.formatSeparator);if(i.length>1&&i[0].indexOf(`(`)>1&&i[0].indexOf(`)`)<0&&i.find(e=>e.indexOf(`)`)>-1)){let e=i.findIndex(e=>e.indexOf(`)`)>-1);i[0]=[i[0],...i.splice(1,e)].join(this.formatSeparator)}return i.reduce((e,t)=>{let{formatName:i,formatOptions:a}=On(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},jn=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},Mn=class extends hn{constructor(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=mn.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{$t(n.loaded,[i],a),jn(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}if(o&&s&&r<this.maxRetries){setTimeout(()=>{this.read.call(this,e,t,n,r+1,i*2,a)},i);return}a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2){try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}return}return s(e,t,o)}prepareLoading(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();Wt(e)&&(e=this.languageUtils.toResolveHierarchy(e)),Wt(t)&&(t=[t]);let i=this.queueLoad(e,t,n,r);if(!i.toLoad.length)return i.pending.length||r(),null;i.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:``,n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t)){this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);return}if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},Nn=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,simplifyPluralSuffix:!0,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),Wt(e[1])&&(t.defaultValue=e[1]),Wt(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0}}),Pn=e=>(Wt(e.ns)&&(e.ns=[e.ns]),Wt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),Wt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs?.indexOf?.(`cimode`)<0&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),typeof e.initImmediate==`boolean`&&(e.initAsync=e.initImmediate),e),Fn=()=>{},In=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},Ln=class e extends hn{constructor(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;if(super(),this.options=Pn(e),this.services={},this.logger=mn,this.modules={external:[]},In(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(){var e=this;let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof t==`function`&&(n=t,t={}),t.defaultNS==null&&t.ns&&(Wt(t.ns)?t.defaultNS=t.ns:t.ns.indexOf(`translation`)<0&&(t.defaultNS=t.ns[0]));let r=Nn();this.options={...r,...this.options,...Pn(t)},this.options.interpolation={...r.interpolation,...this.options.interpolation},t.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=t.keySeparator),t.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=t.nsSeparator);let i=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?mn.init(i(this.modules.logger),this.options):mn.init(null,this.options);let t;t=this.modules.formatter?this.modules.formatter:An;let n=new xn(this.options);this.store=new gn(this.options.resources,this.options);let a=this.services;a.logger=mn,a.resourceStore=this.store,a.languageUtils=n,a.pluralResolver=new wn(n,{prepend:this.options.pluralSeparator,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),t&&(!this.options.interpolation.format||this.options.interpolation.format===r.interpolation.format)&&(a.formatter=i(t),a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new Dn(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new Mn(i(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on(`*`,function(t){var n=[...arguments].slice(1);e.emit(t,...n)}),this.modules.languageDetector&&(a.languageDetector=i(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=i(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new bn(this.services,this.options),this.translator.on(`*`,function(t){var n=[...arguments].slice(1);e.emit(t,...n)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,n||=Fn,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(t=>{this[t]=function(){return e.store[t](...arguments)}}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(t=>{this[t]=function(){return e.store[t](...arguments),e}});let a=Gt(),o=()=>{let e=(e,t)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),a.resolve(t),n(e,t)};if(this.languages&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?o():setTimeout(o,0),a}loadResources(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fn,n=Wt(e)?e:this.language;if(typeof e==`function`&&(t=e),!this.options.resources||this.options.partialBundledLanguages){if(n?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return t();let e=[],r=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&e.indexOf(t)<0&&e.push(t)})};n?r(n):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>r(e)),this.options.preload?.forEach?.(e=>r(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),t(e)})}else t(null)}reloadResources(e,t,n){let r=Gt();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=Fn,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&_n.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&!([`cimode`,`dev`].indexOf(e)>-1))for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(!([`cimode`,`dev`].indexOf(t)>-1)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}}changeLanguage(e,t){var n=this;this.isLanguageChangingTo=e;let r=Gt();this.emit(`languageChanging`,e);let i=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},a=(e,a)=>{a?(i(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,r.resolve(function(){return n.t(...arguments)}),t&&t(e,function(){return n.t(...arguments)})},o=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=Wt(t)?t:this.services.languageUtils.getBestMatchFromCodes(t);n&&(this.language||i(n),this.translator.language||this.translator.changeLanguage(n),this.services.languageDetector?.cacheUserLanguage?.(n)),this.loadResources(n,e=>{a(e,n)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?o(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(o):this.services.languageDetector.detect(o):o(e),r}getFixedT(e,t,n){var r=this;let i=function(e,t){let a;if(typeof t!=`object`){var o=[...arguments].slice(2);a=r.options.overloadTranslationOptionHandler([e,t].concat(o))}else a={...t};a.lng=a.lng||i.lng,a.lngs=a.lngs||i.lngs,a.ns=a.ns||i.ns,a.keyPrefix!==``&&(a.keyPrefix=a.keyPrefix||n||i.keyPrefix);let s=r.options.keySeparator||`.`,c;return c=a.keyPrefix&&Array.isArray(e)?e.map(e=>`${a.keyPrefix}${s}${e}`):a.keyPrefix?`${a.keyPrefix}${s}${e}`:e,r.t(c,a)};return Wt(e)?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}t(){var e=[...arguments];return this.translator?.translate(...e)}exists(){var e=[...arguments];return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}return!!(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(n,e)&&(!r||a(i,e)))}loadNamespaces(e,t){let n=Gt();return this.options.ns?(Wt(e)&&(e=[e]),e.forEach(e=>{this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=Gt();Wt(e)&&(e=[e]);let r=this.options.preload||[],i=e.filter(e=>r.indexOf(e)<0&&this.services.languageUtils.isSupportedCode(e));return i.length?(this.options.preload=r.concat(i),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new xn(Nn());return t.indexOf(n.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;return new e(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Fn,r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,...t,isClone:!0},a=new e(i);return(t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new gn(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),{})),{}),i),a.services.resourceStore=a.store),a.translator=new bn(a.services,i),a.translator.on(`*`,function(e){var t=[...arguments].slice(1);a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}},Rn=Ln.createInstance();Rn.createInstance=Ln.createInstance,Rn.createInstance,Rn.dir,Rn.init,Rn.loadResources,Rn.reloadResources,Rn.use,Rn.changeLanguage,Rn.getFixedT,Rn.t,Rn.exists,Rn.setDefaultNamespace,Rn.hasLoadedNamespace,Rn.loadNamespaces,Rn.loadLanguages;var{slice:zn,forEach:Bn}=[];function Vn(e){return Bn.call(zn.call(arguments,1),t=>{if(t)for(let n in t)e[n]===void 0&&(e[n]=t[n])}),e}function Hn(e){return typeof e==`string`&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(e))}var Un=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,Wn=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{path:`/`},r=`${e}=${encodeURIComponent(t)}`;if(n.maxAge>0){let e=n.maxAge-0;if(Number.isNaN(e))throw Error(`maxAge should be a Number`);r+=`; Max-Age=${Math.floor(e)}`}if(n.domain){if(!Un.test(n.domain))throw TypeError(`option domain is invalid`);r+=`; Domain=${n.domain}`}if(n.path){if(!Un.test(n.path))throw TypeError(`option path is invalid`);r+=`; Path=${n.path}`}if(n.expires){if(typeof n.expires.toUTCString!=`function`)throw TypeError(`option expires is invalid`);r+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(r+=`; HttpOnly`),n.secure&&(r+=`; Secure`),n.sameSite)switch(typeof n.sameSite==`string`?n.sameSite.toLowerCase():n.sameSite){case!0:r+=`; SameSite=Strict`;break;case`lax`:r+=`; SameSite=Lax`;break;case`strict`:r+=`; SameSite=Strict`;break;case`none`:r+=`; SameSite=None`;break;default:throw TypeError(`option sameSite is invalid`)}return n.partitioned&&(r+=`; Partitioned`),r},Gn={create(e,t,n,r){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:`/`,sameSite:`strict`};n&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+n*60*1e3)),r&&(i.domain=r),document.cookie=Wn(e,t,i)},read(e){let t=`${e}=`,n=document.cookie.split(`;`);for(let e=0;e<n.length;e++){let r=n[e];for(;r.charAt(0)===` `;)r=r.substring(1,r.length);if(r.indexOf(t)===0)return r.substring(t.length,r.length)}return null},remove(e,t){this.create(e,``,-1,t)}},Kn={name:`cookie`,lookup(e){let{lookupCookie:t}=e;if(t&&typeof document<`u`)return Gn.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:n,cookieMinutes:r,cookieDomain:i,cookieOptions:a}=t;n&&typeof document<`u`&&Gn.create(n,e,r,i,a)}},qn={name:`querystring`,lookup(e){let{lookupQuerystring:t}=e,n;if(typeof window<`u`){let{search:e}=window.location;!window.location.search&&window.location.hash?.indexOf(`?`)>-1&&(e=window.location.hash.substring(window.location.hash.indexOf(`?`)));let r=e.substring(1).split(`&`);for(let e=0;e<r.length;e++){let i=r[e].indexOf(`=`);i>0&&r[e].substring(0,i)===t&&(n=r[e].substring(i+1))}}return n}},Jn={name:`hash`,lookup(e){let{lookupHash:t,lookupFromHashIndex:n}=e,r;if(typeof window<`u`){let{hash:e}=window.location;if(e&&e.length>2){let i=e.substring(1);if(t){let e=i.split(`&`);for(let n=0;n<e.length;n++){let i=e[n].indexOf(`=`);i>0&&e[n].substring(0,i)===t&&(r=e[n].substring(i+1))}}if(r)return r;if(!r&&n>-1){let t=e.match(/\/([a-zA-Z-]*)/g);return Array.isArray(t)?t[typeof n==`number`?n:0]?.replace(`/`,``):void 0}}}return r}},Yn=null,Xn=()=>{if(Yn!==null)return Yn;try{if(Yn=typeof window<`u`&&window.localStorage!==null,!Yn)return!1;let e=`i18next.translate.boo`;window.localStorage.setItem(e,`foo`),window.localStorage.removeItem(e)}catch{Yn=!1}return Yn},Zn={name:`localStorage`,lookup(e){let{lookupLocalStorage:t}=e;if(t&&Xn())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:n}=t;n&&Xn()&&window.localStorage.setItem(n,e)}},Qn=null,$n=()=>{if(Qn!==null)return Qn;try{if(Qn=typeof window<`u`&&window.sessionStorage!==null,!Qn)return!1;let e=`i18next.translate.boo`;window.sessionStorage.setItem(e,`foo`),window.sessionStorage.removeItem(e)}catch{Qn=!1}return Qn},er={name:`sessionStorage`,lookup(e){let{lookupSessionStorage:t}=e;if(t&&$n())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:n}=t;n&&$n()&&window.sessionStorage.setItem(n,e)}},tr={name:`navigator`,lookup(e){let t=[];if(typeof navigator<`u`){let{languages:e,userLanguage:n,language:r}=navigator;if(e)for(let n=0;n<e.length;n++)t.push(e[n]);n&&t.push(n),r&&t.push(r)}return t.length>0?t:void 0}},nr={name:`htmlTag`,lookup(e){let{htmlTag:t}=e,n,r=t||(typeof document<`u`?document.documentElement:null);return r&&typeof r.getAttribute==`function`&&(n=r.getAttribute(`lang`)),n}},rr={name:`path`,lookup(e){let{lookupFromPathIndex:t}=e;if(typeof window>`u`)return;let n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(Array.isArray(n))return n[typeof t==`number`?t:0]?.replace(`/`,``)}},ir={name:`subdomain`,lookup(e){let{lookupFromSubdomainIndex:t}=e,n=typeof t==`number`?t+1:1,r=typeof window<`u`&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(r)return r[n]}},ar=!1;try{document.cookie,ar=!0}catch{}var or=[`querystring`,`cookie`,`localStorage`,`sessionStorage`,`navigator`,`htmlTag`];ar||or.splice(1,1);var sr=()=>({order:or,lookupQuerystring:`lng`,lookupCookie:`i18next`,lookupLocalStorage:`i18nextLng`,lookupSessionStorage:`i18nextLng`,caches:[`localStorage`],excludeCacheFor:[`cimode`],convertDetectedLanguage:e=>e}),cr=class{constructor(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.type=`languageDetector`,this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{languageUtils:{}},t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=e,this.options=Vn(t,this.options||{},sr()),typeof this.options.convertDetectedLanguage==`string`&&this.options.convertDetectedLanguage.indexOf(`15897`)>-1&&(this.options.convertDetectedLanguage=e=>e.replace(`-`,`_`)),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(Kn),this.addDetector(qn),this.addDetector(Zn),this.addDetector(er),this.addDetector(tr),this.addDetector(nr),this.addDetector(rr),this.addDetector(ir),this.addDetector(Jn)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:this.options.order,t=[];return e.forEach(e=>{if(this.detectors[e]){let n=this.detectors[e].lookup(this.options);n&&typeof n==`string`&&(n=[n]),n&&(t=t.concat(n))}}),t=t.filter(e=>e!=null&&!Hn(e)).map(e=>this.options.convertDetectedLanguage(e)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.options.caches;t&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(t=>{this.detectors[t]&&this.detectors[t].cacheUserLanguage(e,this.options)}))}};cr.type=`languageDetector`;var lr=`common`,ur=[`en`,`fr`],dr={en:`English`,fr:`Français`},fr={en:{common:{app:{loadingStudio:`Loading Studio...`},actions:{save:`Save`,cancel:`Cancel`,delete:`Delete`,edit:`Edit`,create:`Create`,add:`Add`,remove:`Remove`,close:`Close`,confirm:`Confirm`,submit:`Submit`,reset:`Reset`,search:`Search`,filter:`Filter`,clear:`Clear`,copy:`Copy`,download:`Download`,upload:`Upload`,refresh:`Refresh`,back:`Back`,next:`Next`,previous:`Previous`,loading:`Loading...`,saving:`Saving...`,deleting:`Deleting...`,updating:`Updating...`,creating:`Creating...`},status:{active:`Active`,inactive:`Inactive`,enabled:`Enabled`,disabled:`Disabled`,pending:`Pending`,success:`Success`,error:`Error`,warning:`Warning`,info:`Info`,loading:`Loading`,processing:`Processing`},labels:{name:`Name`,email:`Email`,username:`Username`,password:`Password`,description:`Description`,title:`Title`,type:`Type`,status:`Status`,date:`Date`,time:`Time`,created:`Created`,updated:`Updated`,actions:`Actions`,options:`Options`,settings:`Settings`,details:`Details`,none:`None`,all:`All`,select:`Select`,optional:`Optional`,required:`Required`},messages:{confirmDelete:`Are you sure you want to delete this item? This action cannot be undone.`,unsavedChanges:`You have unsaved changes. Are you sure you want to leave?`,noResults:`No results found`,noData:`No data available`,loadError:`Failed to load data`,saveSuccess:`Changes saved successfully`,saveError:`Failed to save changes`,deleteSuccess:`Item deleted successfully`,deleteError:`Failed to delete item`,networkError:`Network error. Please check your connection.`,sessionExpired:`Your session has expired. Please sign in again.`},time:{now:`Just now`,minutesAgo:`{{count}} minute ago`,minutesAgo_plural:`{{count}} minutes ago`,hoursAgo:`{{count}} hour ago`,hoursAgo_plural:`{{count}} hours ago`,daysAgo:`{{count}} day ago`,daysAgo_plural:`{{count}} days ago`,never:`Never`},pagination:{page:`Page`,of:`of`,items:`items`,showing:`Showing`,to:`to`,perPage:`per page`}},studio:{contentView:{filters:`Filters`,sort:`Sort`,clearAll:`Clear all`,selectedOfTotal:`{{selected}} of {{total}} selected`,selectedOfTotal_one:`{{selected}} of {{total}} selected`,selectedOfTotal_other:`{{selected}} of {{total}} selected`,itemsCount:`{{count}} items`,sortAsc:`{{label}} (A-Z)`,sortDesc:`{{label}} (Z-A)`,filterBy:`Filter by {{label}}`,allLabel:`All {{label}}`,all:`All`,yes:`Yes`,no:`No`},changeStatus:{title:`Change Status`,selectStatus:`Select the new status for {{count}} selected document`,selectStatus_plural:`Select the new status for {{count}} selected documents`,draft:`Draft`,draftDesc:`Save as draft`,published:`Published`,publishedDesc:`Make documents publicly available`,archived:`Archived`,archivedDesc:`Archive documents`,updating:`Updating...`,updateDocument:`Update {{count}} document`,updateDocument_plural:`Update {{count}} documents`},pagination:{showing:`Showing {{start}} to {{end}} of {{total}} results`,show:`Show:`,firstPage:`First page`,previousPage:`Previous page`,nextPage:`Next page`,lastPage:`Last page`},contentViews:{loadingDocuments:`Loading documents...`,noDocumentsFound:`No documents found`,edit:`Edit`,copyId:`Copy ID`,duplicate:`Duplicate`,delete:`Delete`,deleteConfirm:`Are you sure you want to delete this document? This action cannot be undone.`,deleteConfirmShort:`Are you sure you want to delete this document?`,deleteTitle:`Delete Document`,confirmDelete:`Delete`,actions:`Actions`,columns:`Columns`,showHideColumns:`Show/Hide Columns`,itemsCount:`{{count}} items`,yes:`Yes`,no:`No`,empty:`Empty`,noItemsInColumn:`No items in {{column}}`,addItem:`Add item`},mediaBrowser:{title:`Browse Media`,selectFile:`Select a file from your media library`,selectImage:`Select an image from your media library`,selectVideo:`Select a video from your media library`,selectAudio:`Select an audio from your media library`,selectDocument:`Select a document from your media library`,close:`Close`,searchPlaceholder:`Search media...`,backToGrid:`Back to Grid`,noPreviewAvailable:`Preview not available for this file type`,noPreviewUrl:`No preview URL available`,imageVariants:`Image Variants`,noVariantsAvailable:`No variants available for this image.`,regenerate:`Regenerate`,original:`Original`,fileDetails:`File Details`,filename:`Filename`,size:`Size`,type:`Type`,dimensions:`Dimensions`,selectVariant:`Select {{variant}}`,selectOriginal:`Select Original`,variant:`Variant`,select:`Select`,noMediaFound:`No media files found`,noMediaFoundMatching:`No media files found matching your search`,noTypeFound:`No {{type}} files found`,noTypeFoundMatching:`No {{type}} files found matching your search`,clearSearch:`Clear search`,paginationOf:`{{start}}-{{end}} of {{total}}`,prev:`Prev`,next:`Next`},nav:{content:`Content`,media:`Media`,settings:`Settings`,users:`Users`,auditLogs:`Audit Logs`,dashboard:`Dashboard`,search:`Search...`,searchPlaceholder:`Search...`},header:{create:`Create`,createNewDocument:`Create New Document`,noDocumentTypes:`No document types available for creation`,studioConfiguration:`Studio configuration`,manageUsersPermissions:`Manage users & permissions`,viewAllChanges:`View all content changes`,preferences:`Preferences`,changePassword:`Change Password`,signOut:`Sign out`,user:`User`,noEmail:`No email`},theme:{light:`Light`,dark:`Dark`,system:`System`,toggle:`Toggle theme`},usersPage:{title:`Users & Access`,subtitle:`Manage users, permissions, API tokens, and webhooks`,accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access user management features. Contact your administrator for access.`,tabs:{users:`Users`,tokens:`API Tokens`,webhooks:`Webhooks`}},userManagement:{title:`User Management`,subtitle:`Manage user accounts, roles, and permissions`,addUser:`Add User`,editUser:`Edit User`,createUser:`Create User`,searchPlaceholder:`Search users...`,tableHeaders:{user:`User`,role:`Role`,status:`Status`,lastLogin:`Last Login`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`},mfa:`MFA`,mfaEnabled:`MFA Enabled`,custom:`Custom`,customPermissionsTooltip:`Custom permissions - differs from role defaults`,never:`Never`,editUserTitle:`Edit user`,resetMfaTitle:`Reset MFA`,deleteUserTitle:`Delete user`,deleteConfirm:`Are you sure you want to delete user "{{username}}"? This action cannot be undone.`,resetMfaConfirm:`Are you sure you want to reset MFA for "{{username}}"? They will need to set up MFA again.`,failedResetMfa:`Failed to reset MFA. Please try again.`,modal:{editTitle:`Edit User`,createTitle:`Create User`,basicInfo:`Basic Information`,username:`Username`,email:`Email`,fullName:`Full Name`,newPassword:`New Password (optional)`,password:`Password`,generatePassword:`Generate`,role:`Role`,accessPermissions:`Access & Permissions`,reset:`Reset`,activeAccount:`Active user account`,studioAccess:`Studio Access`,customPermissions:`Custom permissions`,loadingSchemaPermissions:`Loading schema permissions...`,failedLoadSchemaPermissions:`Failed to load schema permissions: {{error}}`,allContentEnabled:`(All Content Operations enabled)`,coveredByAllContent:`(Covered by All Content Operations)`,customSchemaPermissions:`Custom Schema Permissions`,customPermissionPlaceholder:`e.g., custom:read, external:write, special:*`,addPermission:`Add`,customPermissionsLabel:`Custom permissions:`,permissionFormatHelp:`Format: schema:action (e.g., custom:read, external:write, special:*). Schema permissions are auto-generated above.`,permissionValidationError:`Permission must be in format "schema:action" (e.g., "articles:read", "products:write", "events:*")`,cancel:`Cancel`,updating:`Updating...`,creating:`Creating...`,updateUser:`Update User`,failedSave:`Failed to save user. Please try again.`},roles:{admin:`Administrator`,adminDesc:`Full access to all features`,editor:`Editor`,editorDesc:`Create, edit, and publish content`,writer:`Writer`,writerDesc:`Create and edit content, cannot publish`,author:`Author`,authorDesc:`Create and edit own content`,viewer:`Viewer`,viewerDesc:`Read-only access to content`},permissions:{allContent:`All Content Operations`,viewAllContent:`View All Content`,editAllContent:`Edit All Content`,deleteAllContent:`Delete All Content`,publishAllContent:`Publish All Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`,viewUsers:`View Users`,editUsers:`Edit Users`,deleteUsers:`Delete Users`,inviteUsers:`Invite Users`,viewSettings:`View Settings`,editSettings:`Edit Settings`,studioAccess:`Studio Access`,viewTokens:`View API Tokens`,createTokens:`Create API Tokens`,deleteTokens:`Delete API Tokens`,viewWebhooks:`View Webhooks`,createEditWebhooks:`Create/Edit Webhooks`,deleteWebhooks:`Delete Webhooks`,testWebhooks:`Test Webhooks`}},appTokens:{title:`API Tokens`,subtitle:`Create and manage API tokens for external applications`,createToken:`Create Token`,searchPlaceholder:`Search tokens...`,noTokensTitle:`No API tokens yet`,noTokensDesc:`Create your first API token to enable external access to your content.`,tableHeaders:{token:`Token`,status:`Status`,lastUsed:`Last Used`,expires:`Expires`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`,expired:`Expired`},never:`Never`,modal:{title:`Create API Token`,tokenName:`Token Name`,tokenNamePlaceholder:`e.g., Production API, Mobile App`,description:`Description`,descriptionPlaceholder:`What will this token be used for?`,expiration:`Expiration`,expiration30days:`30 days`,expiration90days:`90 days (recommended)`,expiration1year:`1 year`,expirationNever:`Never expires`,expirationCustom:`Custom date`,permissions:`Permissions`,cancel:`Cancel`,creating:`Creating...`,createToken:`Create Token`},tokenCreated:{title:`API Token Created`,warning:`This is the only time you'll see this token. Copy it now and store it securely.`,yourToken:`Your API Token`,copied:`Copied!`,close:`Close`},deleteConfirm:`Are you sure you want to delete the token "{{name}}"? This action cannot be undone.`,permissions:{viewContent:`View Content`,editContent:`Edit Content`,deleteContent:`Delete Content`,publishContent:`Publish Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`}},webhooks:{title:`Webhooks`,subtitle:`Receive real-time notifications when events occur`,createWebhook:`Create Webhook`,searchPlaceholder:`Search webhooks...`,noWebhooksTitle:`No webhooks configured`,noWebhooksDesc:`Create your first webhook to receive real-time notifications when events occur.`,tableHeaders:{webhook:`Webhook`,status:`Status`,events:`Events`,lastUpdated:`Last Updated`,actions:`Actions`},status:{active:`Active`,inactive:`Inactive`},eventsCount:`{{count}} event`,eventsCount_plural:`{{count}} events`,moreEvents:`+{{count}} more`,testWebhook:`Test webhook`,viewDeliveryHistory:`View delivery history`,editWebhook:`Edit webhook`,deleteWebhook:`Delete webhook`,deleteConfirm:`Are you sure you want to delete the webhook "{{name}}"? This action cannot be undone.`,modal:{editTitle:`Edit Webhook`,createTitle:`Create Webhook`,name:`Webhook Name`,namePlaceholder:`e.g., Content Sync, Slack Notifications`,url:`Endpoint URL`,urlPlaceholder:`https://api.example.com/webhooks/trokky`,events:`Events to Subscribe To`,secret:`Secret Key`,secretPlaceholder:`Leave empty to auto-generate`,secretDescription:`Used to verify webhook authenticity via HMAC signatures`,headers:`Custom Headers`,headerNamePlaceholder:`Header name`,headerValuePlaceholder:`Header value`,maxRetries:`Max Retries`,backoffStrategy:`Backoff Strategy`,linear:`Linear`,exponential:`Exponential`,active:`Active (webhook will receive events)`,updating:`Updating...`,creating:`Creating...`,update:`Update Webhook`,create:`Create Webhook`},deliveryModal:{title:`Delivery History: {{name}}`,noDeliveries:`No deliveries yet`,status:`Status`,response:`Response`,timestamp:`Time`,attempt:`Attempt`,success:`Success`,failed:`Failed`},events:{allDocuments:`All Document Events`,documentCreated:`Document Created`,documentUpdated:`Document Updated`,documentDeleted:`Document Deleted`,documentPublished:`Document Published`,documentUnpublished:`Document Unpublished`,allMedia:`All Media Events`,mediaUploaded:`Media Uploaded`,mediaUpdated:`Media Updated`,mediaDeleted:`Media Deleted`,allUsers:`All User Events`,userCreated:`User Created`,userUpdated:`User Updated`,userLogin:`User Login`,allSystem:`All System Events`,systemStartup:`System Startup`,systemError:`System Error`}},changePassword:{title:`Change Password`,currentPassword:`Current Password`,newPassword:`New Password`,confirmPassword:`Confirm New Password`,passwordHint:`At least 8 characters`,cancel:`Cancel`,changing:`Changing...`,changePassword:`Change Password`,success:`Password changed successfully!`,errors:{currentRequired:`Current password is required`,newRequired:`New password is required`,minLength:`New password must be at least 8 characters`,mismatch:`Passwords do not match`,sameAsOld:`New password must be different from current password`}},oauth:{accountLinked:`Account linked successfully`,unlinkSuccess:`{{provider}} account unlinked successfully`,unlinkFailed:`Failed to unlink account`,notConnected:`Not connected`,linked:`Linked {{date}}`,unlink:`Unlink`,comingSoon:`Coming Soon`,google:{signIn:`Sign in with Google`,linkAccount:`Link Google Account`,initFailed:`Failed to initialize Google login`}},mfa:{title:`Two-Factor Authentication`,subtitle:`Add an extra layer of security to your account`,enabled:`MFA Enabled`,notEnabled:`MFA Not Enabled`,authenticatorApp:`Authenticator App`,authenticatorAppDesc:`Use an app like Google Authenticator or Authy`,emailVerification:`Email Verification`,emailVerificationDesc:`Receive verification codes via email`,emailCode:`Email Code`,backupCode:`Backup Code`,backupCodes:`Backup Codes`,backupCodesRemaining:`{{count}} codes remaining`,totpDescription:`Enter the 6-digit code from your authenticator app`,emailDescriptionPending:`A code will be sent to your email`,emailDescriptionSent:`Enter the code sent to your email`,backupDescription:`Enter one of your backup codes (format: XXXX-XXXX)`,enterCode:`Please enter the verification code`,trustDevice:`Trust this device for 30 days`,trustedDevices:`Trusted Devices`,trustedDevicesCount:`{{count}} device trusted`,trustedDevicesCount_plural:`{{count}} devices trusted`,verifying:`Verifying...`,verify:`Verify`,sendingCode:`Sending...`,resendCode:`Didn't receive the code? Resend`,setUp:`Set Up`,disableMethod:`Disable`,manage:`Manage`,hide:`Hide`,regenerate:`Regenerate`,revokeAll:`Revoke All`,cancel:`Cancel`,next:`Next`,done:`Done`,copyAll:`Copy All`,copiedToClipboard:`Copied to clipboard`,setup:{authenticator:`Set Up Authenticator App`,scanQrCode:`Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)`,orEnterManually:`Or enter this code manually:`,verifyAuthenticatorCode:`Verify Authenticator Code`,enterCodeToVerify:`Enter the 6-digit code from your authenticator app to verify setup.`,verifyEmailCode:`Verify Email Code`,enterEmailCode:`Enter the code sent to your email address.`,saveBackupCodes:`Save Your Backup Codes`,backupCodesImportant:`Save these backup codes in a secure place. You can use them to access your account if you lose your authenticator device.`,newBackupCodes:`Your New Backup Codes`,newBackupCodesImportant:`Save these backup codes in a secure place. Your previous codes are now invalid. You can use these codes to access your account if you lose your authenticator device.`},disable:{authenticator:`Disable Authenticator App`,email:`Disable Email Verification`,enterPassword:`Enter your password to disable this MFA method.`,all:`Disable All MFA`,allDesc:`This will remove all MFA methods and backup codes from your account`,allWarning:`This will completely disable two-factor authentication on your account. All MFA methods (authenticator app, email) and backup codes will be removed.`,confirmPassword:`Enter your password to confirm.`},regenerateBackupCodes:{title:`Regenerate Backup Codes`,description:`This will invalidate all your existing backup codes. Enter your password to confirm.`},trustedDevice:{trusted:`Trusted: {{date}}`,confirmRevokeAll:`Are you sure you want to revoke trust from all devices?`},toast:{loadFailed:`Failed to load MFA status`,totpInitFailed:`Failed to initialize TOTP setup`,totpEnabled:`Authenticator app enabled successfully!`,emailCodeSent:`Verification code sent to your email`,emailSendFailed:`Failed to send verification code`,emailEnabled:`Email verification enabled successfully!`,authenticatorDisabled:`Authenticator app disabled`,emailDisabled:`Email verification disabled`,allDisabled:`All MFA has been disabled`,backupCodesRegenerated:`Backup codes regenerated. Save them securely!`,deviceRevoked:`Device trust revoked`,deviceRevokeFailed:`Failed to revoke device trust`,allDevicesRevoked:`All device trusts revoked`,allDevicesRevokeFailed:`Failed to revoke device trusts`},errors:{passwordRequired:`Password is required`}},passkey:{signIn:`Sign in with Passkey`,optionsFailed:`Failed to start passkey authentication`,cancelled:`Authentication was cancelled`,notSupported:`Passkeys are not supported in this browser`,authFailed:`Passkey authentication failed`,verifyFailed:`Passkey verification failed`,unexpectedResponse:`Unexpected response from server`,manager:{title:`Passkeys`,description:`Sign in securely without a password using your fingerprint, face, or security key.`,loadFailed:`Failed to load passkeys`,renameFailed:`Failed to rename passkey`,deleteFailed:`Failed to delete passkey`,notConfigured:`Passkey authentication is not enabled`,notConfiguredDescription:`Passkey authentication needs to be configured by an administrator in the server settings.`,noPasskeys:`You haven't set up any passkeys yet.`,unnamed:`Passkey`,added:`Added`,lastUsed:`Last used`,synced:`Synced across devices`,deviceOnly:`This device only`},register:{addPasskey:`Add Passkey`,optionsFailed:`Failed to start passkey registration`,cancelled:`Registration was cancelled`,alreadyRegistered:`This passkey is already registered`,notSupported:`Passkeys are not supported in this browser`,failed:`Passkey registration failed`,verifyFailed:`Passkey registration verification failed`,namePlaceholder:`e.g., MacBook Pro Touch ID`,continue:`Continue`}},captcha:{loading:`Loading CAPTCHA...`,errors:{hcaptchaNotSupported:`hCaptcha is not yet supported`,providerNotSupported:`Provider "{{provider}}" is not supported`,scriptLoadFailed:`Failed to load CAPTCHA script`,renderFailed:`Failed to render CAPTCHA widget`,notAvailable:`{{provider}} not available`}},sessionTimeout:{title:`Session Expiring Soon`,expireIn:`Your session will expire in {{time}}.`,continueWorking:`Continue working to stay logged in.`,extendSession:`Extend Session`,dismiss:`Dismiss`,close:`Close`,expired:`Session expired`},users:{title:`User Management`,subtitle:`Manage user accounts, roles, and permissions`,addUser:`Add User`,editUser:`Edit User`,createUser:`Create User`,deleteUser:`Delete User`,searchPlaceholder:`Search users...`,table:{user:`User`,role:`Role`,status:`Status`,lastLogin:`Last Login`,actions:`Actions`},roles:{admin:`Administrator`,adminDescription:`Full access to all features`,editor:`Editor`,editorDescription:`Create, edit, and publish content`,author:`Author`,authorDescription:`Create and edit own content`,viewer:`Viewer`,viewerDescription:`Read-only access to content`},form:{basicInfo:`Basic Information`,accessPermissions:`Access & Permissions`,username:`Username`,email:`Email`,fullName:`Full Name`,password:`Password`,newPasswordOptional:`New Password (optional)`,role:`Role`,activeAccount:`Active user account`,studioAccess:`Studio Access`,customPermissions:`Custom permissions`,customSchemaPermissions:`Custom Schema Permissions`,permissionFormat:`Format: schema:action (e.g., custom:read, external:write, special:*). Schema permissions are auto-generated above.`,generate:`Generate`},permissions:{title:`Permissions`,reset:`Reset`,loading:`Loading schema permissions...`,loadError:`Failed to load schema permissions: {{error}}`,allContentOps:`All Content Operations`,viewContent:`View All Content`,editContent:`Edit All Content`,deleteContent:`Delete All Content`,publishContent:`Publish All Content`,viewMedia:`View Media`,uploadMedia:`Upload Media`,editMedia:`Edit Media`,deleteMedia:`Delete Media`,viewUsers:`View Users`,editUsers:`Edit Users`,deleteUsers:`Delete Users`,inviteUsers:`Invite Users`,viewSettings:`View Settings`,editSettings:`Edit Settings`,studioAccess:`Studio Access`,viewTokens:`View API Tokens`,createTokens:`Create API Tokens`,deleteTokens:`Delete API Tokens`,viewWebhooks:`View Webhooks`,editWebhooks:`Create/Edit Webhooks`,deleteWebhooks:`Delete Webhooks`,testWebhooks:`Test Webhooks`,groups:{content:`Content`,media:`Media`,users:`Users`,settings:`Settings`,access:`Access`,tokens:`Tokens`,webhooks:`Webhooks`},allContentEnabled:`(All Content Operations enabled)`,coveredByAllContent:`(Covered by All Content Operations)`},confirmDelete:`Are you sure you want to delete user "{{username}}"? This action cannot be undone.`,confirmResetMFA:`Are you sure you want to reset MFA for "{{username}}"? They will need to set up MFA again.`,resetMFA:`Reset MFA`,mfaEnabled:`MFA Enabled`,custom:`Custom`},media:{title:`Media Library`,subtitle:`Upload and manage your media files`,upload:`Upload`,uploadFiles:`Upload Files`,dragAndDrop:`Drag and drop files here`,or:`or`,browseFiles:`Browse files`,noMedia:`No media files`,delete:`Delete`,download:`Download`,copyUrl:`Copy URL`,details:`Details`,filename:`Filename`,filesize:`File size`,dimensions:`Dimensions`,uploadedAt:`Uploaded at`,mimeType:`MIME type`,types:{all:`All Files`,images:`Images`,videos:`Videos`,audio:`Audio`,documents:`Documents`,archives:`Archives`},accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access the media library. Contact your administrator for access.`,searchPlaceholder:`Search media...`,view:{grid:`Grid View`,list:`List View`},filters:`Filters`,clearFilters:`Clear filters`,selected:`{{count}} selected`,deleteSelected:`Delete Selected`,confirmBulkDelete:`Are you sure you want to delete {{count}} file(s)? This action cannot be undone.`,confirmDelete:`Are you sure you want to delete this file? This action cannot be undone.`,editMetadata:`Edit Metadata`,preview:`Preview`,noResults:`No media files found`,uploadSuccess:`File uploaded successfully`,uploadError:`Failed to upload file`,deleteSuccess:`File deleted successfully`,deleteError:`Failed to delete file`,perPage:`per page`,sort:{dateDesc:`Newest first`,dateAsc:`Oldest first`,nameAsc:`Name A-Z`,nameDesc:`Name Z-A`,sizeDesc:`Largest first`,sizeAsc:`Smallest first`}},content:{title:`Content`,subtitle:`Manage all your content types and documents`,loading:`Loading content types...`,loadingDocuments:`Loading documents...`,loadingSingleton:`Loading singleton document...`,error:{loadingTypes:`Error loading content types`,loadingDocuments:`Error loading documents`,documentNotFound:`Document Not Found`},noTypes:`No content types found`,noTypesDescription:`Content types will appear here once your backend is configured with schemas.`,viewDocuments:`View Documents`,refresh:`Refresh`,tryAgain:`Try Again`,backToContent:`Back to Content`,manageDocuments:`Manage your documents`,viewExisting:`View existing documents`,create:`Create {{type}}`,deleteDocument:`Delete Document`,confirmDelete:`Are you sure you want to delete this document? This action cannot be undone.`,confirmBulkDelete:`Are you sure you want to delete {{count}} document(s)? This action cannot be undone.`,deleteAll:`Delete All`,changeStatus:`Change Status`,redirecting:`Redirecting...`,search:`Search {{type}}...`,views:{list:`List View`,grid:`Grid View`,table:`Table View`},filters:{status:`Status`,draft:`Draft`,published:`Published`,archived:`Archived`},sort:{title:`Title`,createdDate:`Created Date`,updatedDate:`Updated Date`},bulkActions:{changeStatus:`Change Status`,delete:`Delete`}},documents:{title:`Documents`,createNew:`Create New`,noDocuments:`No documents found`,untitled:`Untitled`,modified:`Modified`,created:`Created`,publish:`Publish`,unpublish:`Unpublish`,duplicate:`Duplicate`,delete:`Delete`,confirmDelete:`Are you sure you want to delete this document?`,saveChanges:`Save Changes`,discardChanges:`Discard Changes`,unsavedChanges:`You have unsaved changes`},settings:{title:`Settings`,subtitle:`Configure your Trokky Studio and content management`,loading:`Loading settings...`,general:`General`,generalSettings:`General Settings`,branding:`Branding`,security:`Security`,securitySettings:`Security Settings`,api:`API`,webhooks:`Webhooks`,tokens:`API Tokens`,accessDenied:`Access Denied`,accessDeniedMessage:`You don't have permission to access Studio settings. Contact your administrator for access.`,readOnlyMessage:`You have read-only access to settings. Contact your administrator to make changes.`,studioTitle:`Studio Title`,studioTitleDescription:`The title displayed in the Studio interface`,organizationName:`Organization Name`,organizationNameDescription:`Organization or company name displayed on the login page`,primaryColor:`Primary Brand Color`,primaryColorDescription:`Primary color for buttons, links, and accents`,secondaryColor:`Secondary Brand Color`,secondaryColorDescription:`Secondary color for subtle elements and backgrounds`,logoUrl:`Logo URL`,logoUrlDescription:`URL to your organization logo (displayed on login page)`,logoPreview:`Preview:`,publicUrl:`Public Website URL`,publicUrlDescription:`The public URL where your content will be displayed. Used for "View Live" links.`,defaultTheme:`Default Theme`,defaultThemeDescription:`Choose the default theme for new users`,mfa:{title:`Multi-Factor Authentication (MFA) Enforcement`,requireAll:`Require MFA for all users`,requireRoles:`Or require MFA for specific roles:`,allowedMethods:`Allowed MFA Methods`,allowedMethodsDescription:`Select which MFA methods users can choose from:`,totp:`Authenticator App (TOTP) - Recommended`,email:`Email OTP - Send one-time code to email`,atLeastOne:`At least one method must be enabled.`,roleDisabledNote:`Role-based selection is disabled when MFA is required for all users.`,enforcementNote:`When MFA is enforced, users without MFA set up will be prompted to configure it on their next login. They will receive a 15-minute setup window to complete the configuration.`},saveChanges:`Save Changes`,saving:`Saving...`,saveSuccess:`Settings saved successfully!`,saveError:`Failed to save settings: {{error}}`,loadError:`Failed to load settings. Using defaults.`},auditLogs:{title:`Audit Logs`,subtitle:`Complete history of all content changes in the CMS`,action:`Action`,user:`User`,resource:`Resource`,timestamp:`Timestamp`,details:`Details`,noLogs:`No audit logs found`,loading:`Loading audit logs...`,refresh:`Refresh`,search:`Search`,searchPlaceholder:`Search by document title, ID, or collection...`,filters:`Filters`,clearFilters:`Clear all filters`,collection:`Collection`,allCollections:`All collections`,allUsers:`All users`,operation:`Operation`,allOperations:`All operations`,showingResults:`Showing {{start}}-{{end}} of {{total}} entries`,noResults:`No entries found`,page:`Page {{current}} of {{total}}`,previous:`Previous`,next:`Next`,tryAgain:`Try again`,operations:{create:`Created`,update:`Updated`,delete:`Deleted`,publish:`Published`,unpublish:`Unpublished`,restore:`Restored`},technical:{revision:`Revision:`,documentId:`Document ID:`,ip:`IP:`,actorType:`Actor type:`},hideDetails:`Hide details`,showDetails:`Show details`,changedField:`Changed {{field}}`,changedFields:`Changed {{count}} fields`},dashboard:{welcome:`Welcome to Trokky Studio`,subtitle:`Content management made simple`,recentActivity:`Recent Activity`,quickActions:`Quick Actions`,quickStart:`Quick Start`,createFirstDocument:`Create Your First Document`,uploadMedia:`Upload Media`,studioSettings:`Studio Settings`,userPreferences:`User Preferences`,cards:{content:{title:`Content`,description:`Create and manage your content`},media:{title:`Media`,description:`Upload and organize media files`},users:{title:`Users`,description:`Manage users and permissions`}},stats:{loading:`Loading stats...`,contentOverview:`Content Overview`,totalContent:`Total Content`,singletons:`Singletons`,mediaFiles:`Media Files`,content:`Content`,thisWeek:`this week`,documents:`Documents`,media:`Media Files`,users:`Users`},activity:{title:`Recent Activity`,refresh:`Refresh activity`,loading:`Loading recent activity...`,unknownTime:`Unknown time`,tryAgain:`Try again`,noActivity:`No recent activity`,noActivityDescription:`Activity will appear here as content is created and edited`,failedToLoad:`Failed to load recent activity`,operations:{created:`created`,updated:`updated`,deleted:`deleted`,published:`published`,unpublished:`unpublished`,restored:`restored`},changedField:`Changed {{field}}`,changedFields:`Changed {{fields}}`,changedFieldsCount:`Changed {{count}} fields`,by:`by`}},language:{title:`Language`,select:`Select language`,current:`Current language`},sidebar:{navigation:`Navigation`,expand:`Expand sidebar`,collapse:`Collapse sidebar`,searchNavigation:`Search navigation...`,loadingNavigation:`Loading navigation...`,failedToLoad:`Failed to load navigation`,noResultsFor:`No results found for "{{query}}"`,clearSearch:`Clear search`},layout:{globalSearch:`Global Search`,searchPlaceholder:`Search functionality will be implemented here.`,expandContext:`Expand context sidebar`,collapseContext:`Collapse context sidebar`,resizeSidebar:`Drag to resize sidebar`},contextSidebar:{quickActions:`Quick Actions`,createContent:`Create Content`,createContentDesc:`Start with a new document`,uploadMedia:`Upload Media`,uploadMediaDesc:`Add images and files`,recentActivity:`Recent Activity`,noRecentActivity:`No recent activity`,contentTypes:`Content Types`,noContentTypes:`No content types available`,mediaLibrary:`Media Library`,mediaLibraryDesc:`Upload and manage your media files`,userOverview:`User Overview`,totalUsers:`Total Users`,active:`Active`,roles:`Roles`,usersLoggedInWeek:`{{count}} user logged in this week`,usersLoggedInWeek_plural:`{{count}} users logged in this week`,usersNeverLoggedIn:`{{count}} user never logged in`,usersNeverLoggedIn_plural:`{{count}} users never logged in`,inactiveUsers:`{{count}} inactive user`,inactiveUsers_plural:`{{count}} inactive users`,addNewUser:`Add New User`,manageApiTokens:`Manage API Tokens`,studioSettings:`Studio Settings`,configureStudio:`Configure your studio`,fieldsRegistry:`Fields Registry`,totalFields:`Total Fields`,initialized:`Initialized`,yes:`Yes`,no:`No`,availableTypes:`Available Types`,documentation:`Documentation`,docSelectFields:`Select fields from the sidebar to test different types`,docEditPreview:`Use the Edit/Preview tabs to see both modes`,docUseExamples:`Click example "Use" buttons to try different values`,docShowErrors:`Toggle "Show Errors" to test validation`,defaultContextInfo:`Context information will appear here based on the current page.`,widgets:{unknownType:`Unknown widget type: {{type}}`,recentDocuments:{defaultTitle:`Recent {{schema}}`,defaultTitleFallback:`Recent Documents`,noSchemaType:`No schema type specified`,failedToLoad:`Failed to load recent documents`,untitled:`Untitled`,noDocuments:`No recent documents`,by:`by`},stats:{total:`Total`,published:`Published`,calculating:`Calculating...`,notAvailable:`N/A`},category:{uncategorized:`Uncategorized`},recentlyEdited:{untitled:`Untitled`,by:`by`,author:`Author`}}},preferences:{title:`Preferences`,subtitle:`Customize your Studio experience`,appearance:`Appearance`,theme:`Theme`,themeSystem:`System Default`,themeLight:`Light`,themeDark:`Dark`,notifications:`Notifications`,emailNotifications:`Email Notifications`,emailNotificationsDescription:`Receive notifications via email`,pushNotifications:`Push Notifications`,pushNotificationsDescription:`Receive browser push notifications`,connectedAccounts:`Connected Accounts`,connectedAccountsDescription:`Link external accounts for easier sign-in`,security:`Security`,securityDescription:`Manage two-factor authentication and security settings`,passkeys:`Passkeys`,passkeysDescription:`Sign in securely without a password using your fingerprint, face, or security key.`,savePreferences:`Save Preferences`,saveSuccess:`Preferences saved successfully`,saveError:`Failed to update preferences`},notFound:{title:`Page not found`,message:`The page you're looking for doesn't exist or has been moved.`,goToDashboard:`Go to Dashboard`},auth:{forgotPassword:{title:`Forgot password?`,subtitle:`Enter your email address and we'll send you a link to reset your password.`,sendResetLink:`Send Reset Link`,sending:`Sending...`,backToSignIn:`Back to Sign In`,checkEmail:`Check your email`,emailSentMessage:`If an account exists for <strong>{{email}}</strong>, you will receive a password reset link shortly.`,linkExpires:`The link will expire in 1 hour.`,captchaRequired:`Please complete the CAPTCHA verification`,sendError:`Failed to send reset email`},resetPassword:{title:`Reset Password`,subtitle:`Enter your new password below.`,newPassword:`New password`,confirmPassword:`Confirm new password`,resetButton:`Reset Password`,resetting:`Resetting Password...`,verifying:`Verifying reset link...`,success:`Password Reset Successful`,successMessage:`Your password has been successfully reset. You can now sign in with your new password.`,signIn:`Sign In`,invalidLink:`Invalid Reset Link`,invalidLinkMessage:`This password reset link is invalid or has expired.`,linkExpireNote:`Reset links expire after 1 hour. Please request a new one.`,requestNewLink:`Request New Link`,noToken:`No reset token provided`,tokenInvalid:`Invalid or expired reset token`,tokenVerifyError:`Failed to verify reset token`,passwordMinLength:`Password must be at least 8 characters long`,passwordMismatch:`Passwords do not match`,captchaRequired:`Please complete the CAPTCHA verification`,resetError:`Failed to reset password`,linkExpiresIn:`Link expires in {{minutes}} minute`,linkExpiresIn_plural:`Link expires in {{minutes}} minutes`,strength:`Strength`,strengthTooShort:`Too short`,strengthWeak:`Weak`,strengthMedium:`Medium`,strengthGood:`Good`,strengthStrong:`Strong`,requirements:`Password must:`,requireLength:`Be at least 8 characters long`,requireUppercase:`Contain an uppercase letter (recommended)`,requireNumber:`Contain a number (recommended)`},oauth:{processing:`Processing...`,completingAuth:`Completing authentication with Google`,success:`Success!`,loginSuccess:`Login successful! Redirecting...`,mfaRequired:`MFA verification required. Redirecting...`,mfaSetupRequired:`MFA setup required. Redirecting...`,accountLinked:`Google account linked successfully`,failed:`Authentication Failed`,returnToLogin:`Return to Login`,invalidResponse:`Invalid response from server`},device:{pageTitle:`Trokky CLI Login`,loading:`Loading device information...`,authorizeDevice:`Authorize Device`,requestingAccess:`is requesting access to your account`,deviceCode:`Device Code`,allowApplication:`This will allow the application to:`,deny:`Deny`,authorize:`Authorize`,authorized:`Device Authorized`,authorizedMessage:`You can now close this window and return to the CLI.`,closeWindow:`Close Window`,denied:`Authorization Denied`,deniedMessage:`The device was not authorized. You can close this window.`,expired:`Code Expired`,expiredMessage:`The device code has expired. Please try again from the CLI.`,error:`Error`,noCode:`No device code provided`,fetchError:`Failed to fetch device information`,connectError:`Failed to connect to the server`,authError:`Authorization failed`,denyError:`Failed to deny authorization`,returnToStudio:`Return to Studio`,scopes:{openid:`Access your identity`,profile:`Access your profile information`,contentRead:`Read content`,contentWrite:`Create and update content`,contentDelete:`Delete content`,mediaRead:`Read media files`,mediaWrite:`Upload media files`,offlineAccess:`Stay logged in`}},authorize:{pageTitle:`Trokky`,validating:`Validating authorization request...`,authorizeApp:`Authorize Application`,wantsAccess:`wants to access your account`,allowApplication:`This will allow the application to:`,visitWebsite:`Visit application website`,deny:`Deny`,authorize:`Authorize`,consentNote:`By authorizing, you allow this application to access your data according to the permissions listed above.`,redirecting:`Redirecting...`,redirectingMessage:`You are being redirected back to the application.`,error:`Authorization Error`,missingParams:`Missing required authorization parameters`,invalidRequest:`Invalid authorization request`,validateError:`Failed to validate authorization request`,authFailed:`Authorization failed`,denyFailed:`Failed to deny authorization`,returnToStudio:`Return to Studio`}},documentEditor:{loadingSchema:`Loading schema...`,loadingDocument:`Loading document...`,backToDocuments:`Back to Documents`,schemaRequired:`Schema name is required`,documentPreview:`Document Preview`,newDocument:`New {{type}}`,backTo:`Back to {{type}}`,confirmStateChange:`Are you sure you want to change from {{from}} to {{to}}?`,edit:`Edit`,preview:`Preview`,readOnly:`Read Only`,readOnlyMode:`Read only mode`,unsavedChanges:`Unsaved changes`,validationErrors:`Validation errors`,discardChangesConfirm:`You have unsaved changes. Are you sure you want to cancel?`,discardChangesTitle:`Unsaved Changes`,discardChanges:`Discard Changes`,keepEditing:`Keep Editing`,documentInfo:`Document Info`,loadingForm:`Loading form...`,noFieldsDefined:`No fields defined in schema`,created:`Created`,lastUpdated:`Last Updated`,status:`Status`,published:`Published`,draft:`Draft`,publishedOn:`Published {{date}}`,tags:`Tags`,contributors:`Contributors`,contributorsLoading:`Loading...`,contributorsMore:`+{{count}} more`,references:`References`,referencesCount:`References ({{count}})`,referencesMore:`+{{count}}`,noReferences:`No references`,schema:`Schema`,fieldsCount:`{{count}} fields`,dangerZone:`Danger Zone`,deleteDocument:`Delete Document`,deleteConfirm:`Are you sure you want to delete "{{title}}"? This action cannot be undone.`,deleteTitle:`Delete Document`,cannotBeUndone:`This action cannot be undone.`,expandSidebar:`Expand sidebar`,collapseSidebar:`Collapse sidebar`},documentHistory:{title:`Document History`,refreshHistory:`Refresh history`,loading:`Loading...`,loadError:`Failed to load document history`,notAvailable:`Document history is not available`,noHistory:`No history yet`,moreChanges:`+{{count}} more changes`},changesDiff:{noVisibleChanges:`No visible changes`,changesCount:`Changes ({{count}})`,showSystemFields:`Show system fields`,hideSystemFields:`Hide system fields`,before:`Before:`,after:`After:`},auditEntry:{created:`Created`,updated:`Updated`,deleted:`Deleted`,published:`Published`,unpublished:`Unpublished`,restored:`Restored`,by:`by`,latest:`Latest`,changedField:`Changed {{field}}`,changedFieldsJoin:`Changed {{fields}}`,changedFieldsCount:`Changed {{count}} fields`,hideDetails:`Hide details`,showDetails:`Show details`,revision:`Revision:`,ipAddress:`IP Address:`,userAgent:`User Agent:`},common:{title:`Title`,cancel:`Cancel`,dismiss:`Dismiss`,note:`Important:`,save:`Save`,delete:`Delete`,selectAll:`Select all`,deselectAll:`Deselect all`,edit:`Edit`,create:`Create`,add:`Add`,remove:`Remove`,generate:`Generate`,close:`Close`,confirm:`Confirm`,loading:`Loading...`,error:`Error`,success:`Success`,warning:`Warning`,info:`Info`,yes:`Yes`,no:`No`,ok:`OK`,retry:`Retry`,back:`Back`,next:`Next`,previous:`Previous`,submit:`Submit`,reset:`Reset`,clear:`Clear`,tryAgain:`Try again`,refreshPage:`Refresh page`,copyErrorDetails:`Copy Error Details`,copied:`Copied!`,closeNotification:`Close notification`,notifications:`Notifications`},errorBoundary:{title:`Something went wrong`,subtitle:`The application encountered an unexpected error`,description:`Please try refreshing the page or contact support if the problem persists. You can copy the error details below to help with troubleshooting.`,errorMessage:`Error Message:`,stackTrace:`Stack Trace`,componentStack:`Component Stack`,environmentDetails:`Environment Details`,noStackTrace:`No stack trace available`,noComponentStack:`No component stack available`,url:`URL:`,timestamp:`Timestamp:`,userAgent:`User Agent:`,viewport:`Viewport:`},toast:{closeNotification:`Close notification`,notifications:`Notifications`},confirmDialog:{defaultConfirm:`Confirm`,defaultCancel:`Cancel`},search:{placeholder:`Search documents, media...`,clearSearch:`Clear search`,closeSearch:`Close search`,searching:`Searching...`,recentSearches:`Recent searches`,clear:`Clear`,clearHistory:`Clear search history`,foundResults:`Found {{count}} result`,foundResults_plural:`Found {{count}} results`,document:`Document`,media:`Media`,by:`by`,noResults:`No results found`,tryDifferent:`Try different search terms`,typeToSearch:`Type to search documents and media`,pressEscape:`Press Escape to close`,poweredBy:`Powered by Trokky`},permissionsDebug:{title:`Permissions Debug`,copyToClipboard:`Copy debug info to clipboard`,currentUser:`Current User`,username:`Username:`,email:`Email:`,role:`Role:`,admin:`Admin:`,notLoggedIn:`Not logged in`,notAvailable:`N/A`,guest:`guest`,yes:`Yes`,no:`No`,documentPermissions:`Document Permissions`,type:`Type:`,id:`ID:`,newDocument:`New Document`,canCreate:`Can Create`,canUpdate:`Can Update`,canDelete:`Can Delete`,canRead:`Can Read`,allowed:`Allowed`,denied:`Denied`,fieldStates:`Field States ({{count}})`,hideDetails:`Hide Details`,showDetails:`Show Details`,disabled:`Disabled`,readonly:`Readonly`,required:`Required`,hasError:`Has Error`,value:`Value:`,debugModeDev:`Debug mode is ON (dev)`,debugModeManual:`Debug mode is ON (manual)`,disableInProduction:`Disable in Production`,enableInProduction:`Enable in Production`}},fields:{types:JSON.parse(`{"string":{"label":"Text","placeholder":"Enter text...","description":"Single line text field","noValue":"No value","selection":"Selection"},"text":{"label":"Text Area","placeholder":"Enter text...","description":"Multi-line text field","words":"words","lines":"lines"},"number":{"label":"Number","placeholder":"Enter number","placeholderInteger":"Enter whole number","placeholderCurrency":"0.00","placeholderPercentage":"0.00%","description":"Numeric value field","noValue":"No value","increaseValue":"Increase value","decreaseValue":"Decrease value"},"boolean":{"label":"Boolean","description":"True/false toggle field","yes":"Yes","no":"No","toggle":"Toggle"},"date":{"label":"Date","placeholder":"Select date...","description":"Date picker field","noDateSet":"No date set","clearDate":"Clear date","dateOnly":"Date","dateAndTime":"Date & Time"},"datetime":{"label":"Date & Time","placeholder":"Select date and time...","description":"Date and time picker field"},"image":{"label":"Image","placeholder":"Select or upload an image","description":"Image upload field","selectImage":"Select Image","changeImage":"Change Image","removeImage":"Remove Image"},"file":{"label":"File","placeholder":"Select or upload a file","description":"File upload field","selectFile":"Select File","changeFile":"Change File","removeFile":"Remove File"},"reference":{"label":"Reference","placeholder":"Select reference...","description":"Reference to another document","noResults":"No results found","noResultsFor":"No results found for \\"{{query}}\\"","tryDifferentTerm":"Try a different search term","noDocumentsAvailable":"No documents available","createDocumentsFirst":"Create documents first to reference them here","loading":"Loading...","loadingTypes":"Loading document types...","searching":"Searching...","filterDocuments":"Filter documents...","allTypes":"All types","anyType":"Any type","available":"{{count}} available","references":"{{count}} reference","references_plural":"{{count}} references","ofMax":"of {{max}} max","removeReference":"Remove reference","dragToReorder":"Drag to reorder","close":"Close","clear":"Clear"},"array":{"label":"Array","description":"List of items","addItem":"Add item","addFirstItem":"Add first item","removeItem":"Remove item","moveUp":"Move Up","moveDown":"Move Down","empty":"No items added yet","items":"items","item":"item","itemCount":"{{count}} item","itemCount_plural":"{{count}} items","missingDefinition":"Array field missing 'of' definition","unknownType":"Unknown field type: {{type}}","availableTypes":"Available types: {{types}}","noOptionsConfigured":"No options configured for select layout","noMatchingOptions":"No matching options","holdCtrlToSelect":"Hold Ctrl/Cmd to select multiple","removeTag":"Remove tag \\"{{tag}}\\"?","addTag":"Add tag...","typeToSearch":"Type to search or add custom tags","selectFromOptions":"Select from available options","add":"Add","minimum":"Minimum {{count}} item","minimum_plural":"Minimum {{count}} items","maximum":"Maximum {{count}} item","maximum_plural":"Maximum {{count}} items","range":"{{min}} - {{max}} items"},"object":{"label":"Object","description":"Nested fields group","fields":"fields","field":"field","otherFields":"Other Fields","invalidConfig":"Invalid field configuration: expected object field","fieldNotRegistered":"Field type '{{type}}' is not registered. Please ensure the field plugin is loaded."},"select":{"label":"Select","placeholder":"Select an option...","description":"Dropdown selection field","noOptions":"No options available"},"richtext":{"label":"Rich Text","placeholder":"Start typing...","description":"Rich text editor field","noContent":"No content","loadingEditor":"Loading editor...","invalidConfig":"Invalid field configuration: expected richtext field","toolbar":{"bold":"Bold","italic":"Italic","underline":"Underline","strikethrough":"Strikethrough","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","quote":"Quote","addLink":"Add Link","insertImage":"Insert Image","bulletList":"Bullet List","numberedList":"Numbered List","insertTable":"Insert Table","codeBlock":"Code Block","undo":"Undo","redo":"Redo","viewEditSource":"View/Edit Source Code","fullscreen":"Fullscreen","exitFullscreen":"Exit Fullscreen"},"stats":{"words":"words","characters":"characters","minRead":"min read","exceedsLimit":"Exceeds character limit"},"imageToolbar":{"title":"Image Options:","variant":"Variant:","original":"Original","delete":"Delete","deleteTitle":"Delete Image"},"tableToolbar":{"title":"Table Options:","row":"Row","col":"Col","header":"Header","merge":"Merge","split":"Split","table":"Table","addRowAfter":"Add Row After","deleteRow":"Delete Row","addColumnAfter":"Add Column After","deleteColumn":"Delete Column","toggleHeaderRow":"Toggle Header Row","mergeSelectedCells":"Merge Selected Cells","splitCell":"Split Cell","deleteTable":"Delete Table"},"linkDialog":{"title":"Add Link","linkText":"Link Text","linkTextPlaceholder":"Enter link text","url":"URL","urlPlaceholder":"https://example.com","cancel":"Cancel","addLink":"Add Link","removeLink":"Remove Link"},"source":{"placeholder":"Edit HTML source code..."},"sanitization":{"warning":"Content was sanitized for security: {{warnings}}","dismissWarning":"Dismiss warning"}},"portableText":{"label":"Portable Text","placeholder":"Type something...","description":"Block content editor","noContent":"No content","emptyBlock":"Empty block","blocks":"Blocks:","characters":"Characters:","words":"Words:","blocksCount":"{{current}}/{{max}} blocks","charactersCount":"{{current}}/{{max}} characters","normal":"Normal","heading1":"Heading 1","heading2":"Heading 2","heading3":"Heading 3","quote":"Quote","quotePlaceholder":"Quote...","bold":"Bold (⌘B)","italic":"Italic (⌘I)","underline":"Underline (⌘U)","strikethrough":"Strikethrough","code":"Code","addLink":"Add link","hideStats":"Hide stats","showStats":"Show stats","exitFullscreen":"Exit fullscreen","fullscreen":"Fullscreen","dragToReorder":"Drag to reorder (or use Alt+↑/↓)","deleteBlock":"Delete block","addBlock":"+ Add block","checkRequirements":"Please check the content requirements","linkDialog":{"title":"Add Link","url":"URL","textOptional":"Text (optional)","textPlaceholder":"Link text","cancel":"Cancel","add":"Add Link"},"deleteConfirm":"Are you sure you want to delete this block?","deleteConfirmWithText":"Are you sure you want to delete this block?\\n\\n\\"{{text}}\\"","deleteEmptyConfirm":"Are you sure you want to delete this empty block?"},"slug":{"label":"Slug","placeholder":"my-awesome-slug","description":"URL-friendly identifier","generate":"Generate","edit":"Edit","regenerate":"Regenerate slug from source field","editSlug":"Edit slug","unique":"unique","noSlugSet":"No slug set","autoGeneratedFrom":"Auto-generated from: {{source}}","manuallyEdited":"manually edited","slugTaken":"This slug is already taken. Please choose a different one.","checkingUniqueness":"Checking uniqueness...","slugIsUnique":"Slug is unique","slugExists":"Slug already exists","couldNotCheck":"Could not check uniqueness"},"email":{"label":"Email","placeholder":"email@example.com","description":"Email address field","enterEmail":"Enter email address"},"url":{"label":"URL","placeholder":"https://example.com","description":"Web address field"},"color":{"label":"Color","placeholder":"#000000","description":"Color picker field","openPicker":"Open color picker","pickFromScreen":"Pick color from screen","quickColors":"Quick Colors","selectColor":"Select {{color}}"},"geoCoordinate":{"label":"Geo Coordinate","description":"Geographic coordinate field","manual":"Manual","map":"Map","latitude":"Latitude","longitude":"Longitude","useCurrentLocation":"Use current location","altitude":"Altitude (meters)","accuracy":"Accuracy (meters)","interactiveMap":"Interactive Map","comingSoon":"(Coming soon)"},"info":{"label":"Info","description":"Informational display field","expand":"Expand","collapse":"Collapse"},"password":{"label":"Password","description":"Password input field","placeholder":"Enter password","generatePassword":"Generate password","showPassword":"Show password","hidePassword":"Hide password","passwordStrength":"Password strength:","strength":{"noPassword":"No password","veryWeak":"Very Weak","weak":"Weak","fair":"Fair","good":"Good","strong":"Strong"}},"icon":{"label":"Icon","description":"Icon picker field","selectIcon":"Select Icon","searchIcons":"Search icons...","style":"Style:","category":"Category:","allCategories":"All categories","iconCount":"{{count}} icons","noIconsFound":"No icons found","tryDifferentSearch":"Try a different search term or category","previous":"Previous","next":"Next","pageOf":"Page {{page}} of {{total}}","noLibrariesAvailable":"No icon libraries available","noIconSelected":"No icon selected","change":"Change","select":"Select","clearIcon":"Clear icon"},"media":{"label":"Media","description":"Media upload field","selectMedia":"Select media","clickToUploadOrBrowse":"Click to upload or browse","addMedia":"Add media","addImage":"Add image","addVideo":"Add video","addAudio":"Add audio","addDocument":"Add document","addArchive":"Add archive","dropFilesOrClick":"Drop files here or click to upload","clickToUpload":"Click to upload","maxSize":"Max size: {{size}}","selectFileToUpload":"Select a file to upload","allowed":"Allowed: {{types}}","upload":"Upload","browse":"Browse","cancel":"Cancel","change":"Change","remove":"Remove","uploading":"Uploading...","uploadFailed":"Upload failed. Please try again.","mediaAssetNotFound":"Media asset no longer exists","failedToLoadAsset":"Failed to load media asset","removeBrokenReference":"Remove broken media reference","changeMedia":"Change media","removeMedia":"Remove media","mediaDetails":"Media Details","altText":"Alt text","altTextPlaceholder":"Describe this image for accessibility","caption":"Caption","captionPlaceholder":"Add a caption","titleOverride":"Title override","titleOverridePlaceholder":"Override the asset title for this usage","mediaTypes":{"image":"Image","video":"Video","audio":"Audio","document":"Document","archive":"Archive","media":"Media"},"unknownSize":"Unknown size"}}`),validation:{required:`This field is required`,minLength:`Must be at least {{min}} characters`,maxLength:`Must be no more than {{max}} characters`,min:`Must be at least {{min}}`,max:`Must be no more than {{max}}`,pattern:`Invalid format`,email:`Must be a valid email address`,url:`Must be a valid URL`,unique:`This value must be unique`,invalidType:`Invalid value type`,invalidDate:`Invalid date`,invalidNumber:`Must be a valid number`,invalidInteger:`Must be a whole number`,positive:`Must be a positive number`,negative:`Must be a negative number`,fileSize:`File size must be less than {{max}}`,fileType:`Invalid file type`,imageSize:`Image dimensions must be {{width}}x{{height}} or smaller`},richtext:{bold:`Bold`,italic:`Italic`,underline:`Underline`,strikethrough:`Strikethrough`,heading1:`Heading 1`,heading2:`Heading 2`,heading3:`Heading 3`,paragraph:`Paragraph`,bulletList:`Bullet List`,numberedList:`Numbered List`,blockquote:`Blockquote`,codeBlock:`Code Block`,link:`Link`,image:`Image`,table:`Table`,undo:`Undo`,redo:`Redo`,clear:`Clear Formatting`},noValue:`No value`,errors:{invalidFieldConfig:`Invalid field configuration: expected {{type}} field`,definitionMissing:`Error: Field definition is missing`},autoFields:{_thumbnail:{title:`Featured Image`,description:`Main image representing this content`},slug:{title:`URL`,description:`URL-friendly identifier for this content`}},common:{validating:`Validating...`},modal:{close:`Close`,done:`Done`,noFieldsDefined:`No fields defined`}},auth:{login:{title:`Sign In`,subtitle:`Welcome back`,emailOrUsername:`Email or username`,password:`Password`,rememberMe:`Stay signed in`,forgotPassword:`Forgot password?`,signIn:`Sign In`,signingIn:`Signing in...`,orContinueWith:`or continue with`,backToLogin:`Back to login`},logout:{title:`Sign Out`,confirm:`Are you sure you want to sign out?`,success:`You have been signed out`},forgotPassword:{title:`Forgot Password`,subtitle:`Enter your email to receive a reset link`,email:`Email address`,sendLink:`Send Reset Link`,sending:`Sending...`,success:`If an account exists with that email, you will receive a reset link shortly.`,backToLogin:`Back to login`},resetPassword:{title:`Reset Password`,subtitle:`Enter your new password`,newPassword:`New Password`,confirmPassword:`Confirm Password`,reset:`Reset Password`,resetting:`Resetting...`,success:`Your password has been reset successfully`,invalidToken:`Invalid or expired reset token`,passwordMismatch:`Passwords do not match`},changePassword:{title:`Change Password`,currentPassword:`Current Password`,newPassword:`New Password`,confirmPassword:`Confirm New Password`,change:`Change Password`,changing:`Changing...`,success:`Password changed successfully!`,minLength:`At least 8 characters`,errors:{currentRequired:`Current password is required`,newRequired:`New password is required`,minLength:`New password must be at least 8 characters`,mismatch:`Passwords do not match`,samePassword:`New password must be different from current password`,failed:`Failed to change password`}},mfa:{title:`Two-Factor Authentication`,required:`Two-Factor Authentication Required`,setupRequired:`Your organization requires MFA. Please set up two-factor authentication to continue.`,chooseMethod:`Choose your preferred authentication method:`,authenticatorApp:`Authenticator App`,authenticatorAppDesc:`Use Google Authenticator, Authy, etc.`,emailCode:`Email Code`,emailCodeDesc:`Receive a code via email`,scanQR:`Scan this QR code with your authenticator app:`,manualEntry:`Or enter this code manually:`,enterCode:`Enter the 6-digit code from your app:`,enterEmailCode:`Enter the 6-digit code:`,emailSent:`We've sent a verification code to your email address.`,verify:`Verify`,verifying:`Verifying...`,verifyComplete:`Verify & Complete Setup`,chooseDifferent:`Choose different method`,invalidCode:`Invalid verification code`,codeExpired:`Code has expired`,backupCodes:{title:`Save Your Backup Codes`,description:`These codes can be used to access your account if you lose your authenticator. Each code can only be used once.`,copy:`Copy Codes`,warning:`Important: Store these codes in a safe place. You won't be able to see them again after this page.`,continue:`I've Saved My Codes - Continue to Dashboard`}},oauth:{google:`Continue with Google`,signInWith:`Sign in with {{provider}}`},session:{expired:`Your session has expired. Please sign in again.`,invalid:`Invalid session. Please sign in again.`},errors:{invalidCredentials:`Invalid email or password`,accountLocked:`Account has been locked. Please contact support.`,accountDisabled:`Account has been disabled`,tooManyAttempts:`Too many failed attempts. Please try again later.`,networkError:`Network error. Please check your connection.`,serverError:`Server error. Please try again later.`,captchaRequired:`Please complete the CAPTCHA verification`,unauthorized:`You are not authorized to perform this action`},advanced:{title:`Advanced`,backendUrl:`Backend URL`,customEndpoint:`Custom backend API endpoint`},claim:{title:`Claim this Trokky`,subtitle:`Nobody owns this instance yet. Create the administrator account and it is yours.`,username:`Username`,email:`Email address`,password:`Password`,confirmPassword:`Confirm password`,secret:`Claim secret`,secretHelp:`This instance was deployed with a claim secret. Enter it to prove you own the deployment.`,passwordMismatch:`Passwords do not match`,claim:`Claim and sign in`,claiming:`Claiming...`,alreadyClaimed:`This instance has just been claimed by someone else.`,failed:`Claim failed`,openWarning:`Anyone who reaches this page can claim the instance. Do it now.`}},errors:{codes:{DOCUMENT_NOT_FOUND:`Document not found`,SCHEMA_NOT_FOUND:`Schema not found`,VALIDATION_FAILED:`Validation failed`,UNAUTHORIZED:`You are not authorized to perform this action`,FORBIDDEN:`Access denied`,NOT_FOUND:`Resource not found`,CONFLICT:`A conflict occurred`,INTERNAL_ERROR:`An internal error occurred`,NETWORK_ERROR:`Network error. Please check your connection.`,TIMEOUT:`Request timed out. Please try again.`,RATE_LIMITED:`Too many requests. Please slow down.`,INVALID_INPUT:`Invalid input provided`,DUPLICATE_ENTRY:`This entry already exists`,FILE_TOO_LARGE:`File size exceeds the maximum allowed`,INVALID_FILE_TYPE:`This file type is not allowed`,UPLOAD_FAILED:`Failed to upload file`,DELETE_FAILED:`Failed to delete item`,UPDATE_FAILED:`Failed to update item`,CREATE_FAILED:`Failed to create item`,SESSION_EXPIRED:`Your session has expired. Please sign in again.`,INVALID_TOKEN:`Invalid or expired token`,MFA_REQUIRED:`Multi-factor authentication required`,MFA_INVALID:`Invalid or expired MFA token`,MFA_CODE_INVALID:`Invalid verification code`,PASSWORD_TOO_WEAK:`Password does not meet security requirements`,USER_NOT_FOUND:`User not found`,USER_ALREADY_EXISTS:`A user with this email already exists`,EMAIL_NOT_VERIFIED:`Email address not verified`,PERMISSION_DENIED:`You do not have permission to perform this action`,MEDIA_NOT_FOUND:`Media file not found`,WEBHOOK_DELIVERY_FAILED:`Failed to deliver webhook`},generic:{title:`Error`,unknown:`An unexpected error occurred`,tryAgain:`Please try again`,contactSupport:`If the problem persists, please contact support`,goBack:`Go Back`,refresh:`Refresh Page`},form:{invalidField:`{{field}} is invalid`,requiredField:`{{field}} is required`,fieldTooLong:`{{field}} is too long`,fieldTooShort:`{{field}} is too short`},api:{fetchError:`Failed to fetch data`,saveError:`Failed to save data`,deleteError:`Failed to delete data`,connectionError:`Unable to connect to the server`}}},fr:{common:{app:{loadingStudio:`Chargement du Studio...`},actions:{save:`Enregistrer`,cancel:`Annuler`,delete:`Supprimer`,edit:`Modifier`,create:`Créer`,add:`Ajouter`,remove:`Retirer`,close:`Fermer`,confirm:`Confirmer`,submit:`Soumettre`,reset:`Réinitialiser`,search:`Rechercher`,filter:`Filtrer`,clear:`Effacer`,copy:`Copier`,download:`Télécharger`,upload:`Importer`,refresh:`Actualiser`,back:`Retour`,next:`Suivant`,previous:`Précédent`,loading:`Chargement...`,saving:`Enregistrement...`,deleting:`Suppression...`,updating:`Mise à jour...`,creating:`Création...`},status:{active:`Actif`,inactive:`Inactif`,enabled:`Activé`,disabled:`Désactivé`,pending:`En attente`,success:`Succès`,error:`Erreur`,warning:`Avertissement`,info:`Information`,loading:`Chargement`,processing:`Traitement`},labels:{name:`Nom`,email:`E-mail`,username:`Nom d'utilisateur`,password:`Mot de passe`,description:`Description`,title:`Titre`,type:`Type`,status:`Statut`,date:`Date`,time:`Heure`,created:`Créé`,updated:`Mis à jour`,actions:`Actions`,options:`Options`,settings:`Paramètres`,details:`Détails`,none:`Aucun`,all:`Tous`,select:`Sélectionner`,optional:`Facultatif`,required:`Obligatoire`},messages:{confirmDelete:`Êtes-vous sûr de vouloir supprimer cet élément ? Cette action est irréversible.`,unsavedChanges:`Vous avez des modifications non enregistrées. Êtes-vous sûr de vouloir quitter ?`,noResults:`Aucun résultat trouvé`,noData:`Aucune donnée disponible`,loadError:`Échec du chargement des données`,saveSuccess:`Modifications enregistrées avec succès`,saveError:`Échec de l'enregistrement des modifications`,deleteSuccess:`Élément supprimé avec succès`,deleteError:`Échec de la suppression de l'élément`,networkError:`Erreur réseau. Veuillez vérifier votre connexion.`,sessionExpired:`Votre session a expiré. Veuillez vous reconnecter.`},time:{now:`À l'instant`,minutesAgo:`Il y a {{count}} minute`,minutesAgo_plural:`Il y a {{count}} minutes`,hoursAgo:`Il y a {{count}} heure`,hoursAgo_plural:`Il y a {{count}} heures`,daysAgo:`Il y a {{count}} jour`,daysAgo_plural:`Il y a {{count}} jours`,never:`Jamais`},pagination:{page:`Page`,of:`sur`,items:`éléments`,showing:`Affichage de`,to:`à`,perPage:`par page`}},studio:{contentView:{filters:`Filtres`,sort:`Trier`,clearAll:`Tout effacer`,selectedOfTotal:`{{selected}} sur {{total}} sélectionnés`,selectedOfTotal_one:`{{selected}} sur {{total}} sélectionné`,selectedOfTotal_other:`{{selected}} sur {{total}} sélectionnés`,itemsCount:`{{count}} éléments`,sortAsc:`{{label}} (A-Z)`,sortDesc:`{{label}} (Z-A)`,filterBy:`Filtrer par {{label}}`,allLabel:`Tous les {{label}}`,all:`Tous`,yes:`Oui`,no:`Non`},changeStatus:{title:`Changer le statut`,selectStatus:`Sélectionnez le nouveau statut pour {{count}} document sélectionné`,selectStatus_plural:`Sélectionnez le nouveau statut pour {{count}} documents sélectionnés`,draft:`Brouillon`,draftDesc:`Enregistrer comme brouillon`,published:`Publié`,publishedDesc:`Rendre les documents publiquement disponibles`,archived:`Archivé`,archivedDesc:`Archiver les documents`,updating:`Mise à jour...`,updateDocument:`Mettre à jour {{count}} document`,updateDocument_plural:`Mettre à jour {{count}} documents`},pagination:{showing:`Affichage de {{start}} à {{end}} sur {{total}} résultats`,show:`Afficher :`,firstPage:`Première page`,previousPage:`Page précédente`,nextPage:`Page suivante`,lastPage:`Dernière page`},contentViews:{loadingDocuments:`Chargement des documents...`,noDocumentsFound:`Aucun document trouvé`,edit:`Modifier`,copyId:`Copier l'ID`,duplicate:`Dupliquer`,delete:`Supprimer`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer ce document ? Cette action est irréversible.`,deleteConfirmShort:`Êtes-vous sûr de vouloir supprimer ce document ?`,deleteTitle:`Supprimer le document`,confirmDelete:`Supprimer`,actions:`Actions`,columns:`Colonnes`,showHideColumns:`Afficher/Masquer les colonnes`,itemsCount:`{{count}} éléments`,yes:`Oui`,no:`Non`,empty:`Vide`,noItemsInColumn:`Aucun élément dans {{column}}`,addItem:`Ajouter un élément`},mediaBrowser:{title:`Parcourir les médias`,selectFile:`Sélectionnez un fichier de votre bibliothèque de médias`,selectImage:`Sélectionnez une image de votre bibliothèque de médias`,selectVideo:`Sélectionnez une vidéo de votre bibliothèque de médias`,selectAudio:`Sélectionnez un audio de votre bibliothèque de médias`,selectDocument:`Sélectionnez un document de votre bibliothèque de médias`,close:`Fermer`,searchPlaceholder:`Rechercher des médias...`,backToGrid:`Retour à la grille`,noPreviewAvailable:`Aperçu non disponible pour ce type de fichier`,noPreviewUrl:`Aucune URL d'aperçu disponible`,imageVariants:`Variantes d'image`,noVariantsAvailable:`Aucune variante disponible pour cette image.`,regenerate:`Régénérer`,original:`Original`,fileDetails:`Détails du fichier`,filename:`Nom du fichier`,size:`Taille`,type:`Type`,dimensions:`Dimensions`,selectVariant:`Sélectionner {{variant}}`,selectOriginal:`Sélectionner l'original`,variant:`Variante`,select:`Sélectionner`,noMediaFound:`Aucun fichier média trouvé`,noMediaFoundMatching:`Aucun fichier média correspondant à votre recherche`,noTypeFound:`Aucun fichier {{type}} trouvé`,noTypeFoundMatching:`Aucun fichier {{type}} correspondant à votre recherche`,clearSearch:`Effacer la recherche`,paginationOf:`{{start}}-{{end}} sur {{total}}`,prev:`Préc`,next:`Suiv`},nav:{content:`Contenu`,media:`Médias`,settings:`Paramètres`,users:`Utilisateurs`,auditLogs:`Journaux d'audit`,dashboard:`Tableau de bord`,search:`Rechercher...`,searchPlaceholder:`Rechercher...`},header:{create:`Créer`,createNewDocument:`Créer un nouveau document`,noDocumentTypes:`Aucun type de document disponible pour la création`,studioConfiguration:`Configuration du studio`,manageUsersPermissions:`Gérer les utilisateurs et les permissions`,viewAllChanges:`Voir toutes les modifications`,preferences:`Préférences`,changePassword:`Changer le mot de passe`,signOut:`Se déconnecter`,user:`Utilisateur`,noEmail:`Pas d'e-mail`},theme:{light:`Clair`,dark:`Sombre`,system:`Système`,toggle:`Changer le thème`},usersPage:{title:`Utilisateurs & Accès`,subtitle:`Gérer les utilisateurs, permissions, jetons API et webhooks`,accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder aux fonctionnalités de gestion des utilisateurs. Contactez votre administrateur pour obtenir l'accès.`,tabs:{users:`Utilisateurs`,tokens:`Jetons API`,webhooks:`Webhooks`}},userManagement:{title:`Gestion des utilisateurs`,subtitle:`Gérer les comptes utilisateurs, les rôles et les permissions`,addUser:`Ajouter un utilisateur`,editUser:`Modifier l'utilisateur`,createUser:`Créer un utilisateur`,searchPlaceholder:`Rechercher des utilisateurs...`,tableHeaders:{user:`Utilisateur`,role:`Rôle`,status:`Statut`,lastLogin:`Dernière connexion`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`},mfa:`MFA`,mfaEnabled:`MFA activé`,custom:`Personnalisé`,customPermissionsTooltip:`Permissions personnalisées - diffère des valeurs par défaut du rôle`,never:`Jamais`,editUserTitle:`Modifier l'utilisateur`,resetMfaTitle:`Réinitialiser MFA`,deleteUserTitle:`Supprimer l'utilisateur`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer l'utilisateur "{{username}}" ? Cette action est irréversible.`,resetMfaConfirm:`Êtes-vous sûr de vouloir réinitialiser MFA pour "{{username}}" ? L'utilisateur devra reconfigurer MFA.`,failedResetMfa:`Échec de la réinitialisation MFA. Veuillez réessayer.`,modal:{editTitle:`Modifier l'utilisateur`,createTitle:`Créer un utilisateur`,basicInfo:`Informations de base`,username:`Nom d'utilisateur`,email:`E-mail`,fullName:`Nom complet`,newPassword:`Nouveau mot de passe (optionnel)`,password:`Mot de passe`,generatePassword:`Générer`,role:`Rôle`,accessPermissions:`Accès et permissions`,reset:`Réinitialiser`,activeAccount:`Compte utilisateur actif`,studioAccess:`Accès au Studio`,customPermissions:`Permissions personnalisées`,loadingSchemaPermissions:`Chargement des permissions de schéma...`,failedLoadSchemaPermissions:`Échec du chargement des permissions de schéma : {{error}}`,allContentEnabled:`(Toutes les opérations de contenu activées)`,coveredByAllContent:`(Couvert par Toutes les opérations de contenu)`,customSchemaPermissions:`Permissions de schéma personnalisées`,customPermissionPlaceholder:`ex. : custom:read, external:write, special:*`,addPermission:`Ajouter`,customPermissionsLabel:`Permissions personnalisées :`,permissionFormatHelp:`Format : schema:action (ex. : custom:read, external:write, special:*). Les permissions de schéma sont générées automatiquement ci-dessus.`,permissionValidationError:`La permission doit être au format "schema:action" (ex. : "articles:read", "products:write", "events:*")`,cancel:`Annuler`,updating:`Mise à jour...`,creating:`Création...`,updateUser:`Mettre à jour l'utilisateur`,failedSave:`Échec de l'enregistrement. Veuillez réessayer.`},roles:{admin:`Administrateur`,adminDesc:`Accès complet à toutes les fonctionnalités`,editor:`Éditeur`,editorDesc:`Créer, modifier et publier du contenu`,writer:`Rédacteur`,writerDesc:`Créer et modifier du contenu, sans publication`,author:`Auteur`,authorDesc:`Créer et modifier son propre contenu`,viewer:`Lecteur`,viewerDesc:`Accès en lecture seule au contenu`},permissions:{allContent:`Toutes les opérations de contenu`,viewAllContent:`Voir tout le contenu`,editAllContent:`Modifier tout le contenu`,deleteAllContent:`Supprimer tout le contenu`,publishAllContent:`Publier tout le contenu`,viewMedia:`Voir les médias`,uploadMedia:`Importer des médias`,editMedia:`Modifier les médias`,deleteMedia:`Supprimer les médias`,viewUsers:`Voir les utilisateurs`,editUsers:`Modifier les utilisateurs`,deleteUsers:`Supprimer les utilisateurs`,inviteUsers:`Inviter des utilisateurs`,viewSettings:`Voir les paramètres`,editSettings:`Modifier les paramètres`,studioAccess:`Accès au Studio`,viewTokens:`Voir les jetons API`,createTokens:`Créer des jetons API`,deleteTokens:`Supprimer les jetons API`,viewWebhooks:`Voir les webhooks`,createEditWebhooks:`Créer/Modifier les webhooks`,deleteWebhooks:`Supprimer les webhooks`,testWebhooks:`Tester les webhooks`}},media:{title:`Médiathèque`,subtitle:`Importez et gérez vos fichiers médias`,upload:`Importer`,uploadFiles:`Importer des fichiers`,dragAndDrop:`Glissez-déposez des fichiers ici`,or:`ou`,browseFiles:`Parcourir les fichiers`,noMedia:`Aucun fichier média`,delete:`Supprimer`,download:`Télécharger`,copyUrl:`Copier l'URL`,details:`Détails`,filename:`Nom du fichier`,filesize:`Taille du fichier`,dimensions:`Dimensions`,uploadedAt:`Importé le`,mimeType:`Type MIME`,types:{all:`Tous les fichiers`,images:`Images`,videos:`Vidéos`,audio:`Audio`,documents:`Documents`,archives:`Archives`},accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder à la médiathèque. Contactez votre administrateur pour obtenir l'accès.`,searchPlaceholder:`Rechercher des médias...`,view:{grid:`Vue grille`,list:`Vue liste`},filters:`Filtres`,clearFilters:`Effacer les filtres`,selected:`{{count}} sélectionné(s)`,deleteSelected:`Supprimer la sélection`,confirmBulkDelete:`Êtes-vous sûr de vouloir supprimer {{count}} fichier(s) ? Cette action est irréversible.`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce fichier ? Cette action est irréversible.`,editMetadata:`Modifier les métadonnées`,preview:`Aperçu`,noResults:`Aucun fichier média trouvé`,uploadSuccess:`Fichier importé avec succès`,uploadError:`Échec de l'importation du fichier`,deleteSuccess:`Fichier supprimé avec succès`,deleteError:`Échec de la suppression du fichier`,perPage:`par page`,sort:{dateDesc:`Plus récents`,dateAsc:`Plus anciens`,nameAsc:`Nom A-Z`,nameDesc:`Nom Z-A`,sizeDesc:`Plus grands`,sizeAsc:`Plus petits`}},content:{title:`Contenu`,subtitle:`Gérez tous vos types de contenu et documents`,loading:`Chargement des types de contenu...`,loadingDocuments:`Chargement des documents...`,loadingSingleton:`Chargement du document singleton...`,error:{loadingTypes:`Erreur lors du chargement des types de contenu`,loadingDocuments:`Erreur lors du chargement des documents`,documentNotFound:`Document non trouvé`},noTypes:`Aucun type de contenu trouvé`,noTypesDescription:`Les types de contenu apparaîtront ici une fois votre backend configuré avec des schémas.`,viewDocuments:`Voir les documents`,refresh:`Actualiser`,tryAgain:`Réessayer`,backToContent:`Retour au contenu`,manageDocuments:`Gérer vos documents`,viewExisting:`Voir les documents existants`,create:`Créer {{type}}`,deleteDocument:`Supprimer le document`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce document ? Cette action est irréversible.`,confirmBulkDelete:`Êtes-vous sûr de vouloir supprimer {{count}} document(s) ? Cette action est irréversible.`,deleteAll:`Tout supprimer`,changeStatus:`Changer le statut`,redirecting:`Redirection...`,search:`Rechercher {{type}}...`,views:{list:`Vue liste`,grid:`Vue grille`,table:`Vue tableau`},filters:{status:`Statut`,draft:`Brouillon`,published:`Publié`,archived:`Archivé`},sort:{title:`Titre`,createdDate:`Date de création`,updatedDate:`Date de modification`},bulkActions:{changeStatus:`Changer le statut`,delete:`Supprimer`}},documents:{title:`Documents`,createNew:`Créer nouveau`,noDocuments:`Aucun document trouvé`,untitled:`Sans titre`,modified:`Modifié`,created:`Créé`,publish:`Publier`,unpublish:`Dépublier`,duplicate:`Dupliquer`,delete:`Supprimer`,confirmDelete:`Êtes-vous sûr de vouloir supprimer ce document ?`,saveChanges:`Enregistrer les modifications`,discardChanges:`Annuler les modifications`,unsavedChanges:`Vous avez des modifications non enregistrées`},settings:{title:`Paramètres`,subtitle:`Configurez votre Trokky Studio et la gestion de contenu`,loading:`Chargement des paramètres...`,general:`Général`,generalSettings:`Paramètres généraux`,branding:`Marque`,security:`Sécurité`,securitySettings:`Paramètres de sécurité`,api:`API`,webhooks:`Webhooks`,tokens:`Jetons API`,accessDenied:`Accès refusé`,accessDeniedMessage:`Vous n'avez pas la permission d'accéder aux paramètres du Studio. Contactez votre administrateur pour obtenir l'accès.`,readOnlyMessage:`Vous avez un accès en lecture seule aux paramètres. Contactez votre administrateur pour effectuer des modifications.`,studioTitle:`Titre du Studio`,studioTitleDescription:`Le titre affiché dans l'interface du Studio`,organizationName:`Nom de l'organisation`,organizationNameDescription:`Nom de l'organisation ou de l'entreprise affiché sur la page de connexion`,primaryColor:`Couleur principale`,primaryColorDescription:`Couleur principale pour les boutons, liens et accents`,secondaryColor:`Couleur secondaire`,secondaryColorDescription:`Couleur secondaire pour les éléments subtils et arrière-plans`,logoUrl:`URL du logo`,logoUrlDescription:`URL vers le logo de votre organisation (affiché sur la page de connexion)`,logoPreview:`Aperçu :`,publicUrl:`URL du site web public`,publicUrlDescription:`L'URL publique où votre contenu sera affiché. Utilisé pour les liens "Voir en direct".`,defaultTheme:`Thème par défaut`,defaultThemeDescription:`Choisissez le thème par défaut pour les nouveaux utilisateurs`,mfa:{title:`Application de l'authentification multifacteur (MFA)`,requireAll:`Exiger la MFA pour tous les utilisateurs`,requireRoles:`Ou exiger la MFA pour des rôles spécifiques :`,allowedMethods:`Méthodes MFA autorisées`,allowedMethodsDescription:`Sélectionnez les méthodes MFA disponibles pour les utilisateurs :`,totp:`Application d'authentification (TOTP) - Recommandé`,email:`OTP par e-mail - Envoyer un code unique par e-mail`,atLeastOne:`Au moins une méthode doit être activée.`,roleDisabledNote:`La sélection par rôle est désactivée lorsque la MFA est requise pour tous les utilisateurs.`,enforcementNote:`Lorsque la MFA est appliquée, les utilisateurs sans MFA configurée seront invités à la configurer lors de leur prochaine connexion. Ils disposeront d'une fenêtre de 15 minutes pour terminer la configuration.`},saveChanges:`Enregistrer les modifications`,saving:`Enregistrement...`,saveSuccess:`Paramètres enregistrés avec succès !`,saveError:`Échec de l'enregistrement des paramètres : {{error}}`,loadError:`Échec du chargement des paramètres. Utilisation des valeurs par défaut.`},auditLogs:{title:`Journaux d'audit`,subtitle:`Historique complet de toutes les modifications de contenu dans le CMS`,action:`Action`,user:`Utilisateur`,resource:`Ressource`,timestamp:`Horodatage`,details:`Détails`,noLogs:`Aucun journal d'audit trouvé`,loading:`Chargement des journaux d'audit...`,refresh:`Actualiser`,search:`Rechercher`,searchPlaceholder:`Rechercher par titre de document, ID ou collection...`,filters:`Filtres`,clearFilters:`Effacer tous les filtres`,collection:`Collection`,allCollections:`Toutes les collections`,allUsers:`Tous les utilisateurs`,operation:`Opération`,allOperations:`Toutes les opérations`,showingResults:`Affichage de {{start}}-{{end}} sur {{total}} entrées`,noResults:`Aucune entrée trouvée`,page:`Page {{current}} sur {{total}}`,previous:`Précédent`,next:`Suivant`,tryAgain:`Réessayer`,operations:{create:`Créé`,update:`Modifié`,delete:`Supprimé`,publish:`Publié`,unpublish:`Dépublié`,restore:`Restauré`},technical:{revision:`Révision :`,documentId:`ID du document :`,ip:`IP :`,actorType:`Type d'acteur :`},hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,changedField:`Modifié {{field}}`,changedFields:`Modifié {{count}} champs`},dashboard:{welcome:`Bienvenue sur Trokky Studio`,subtitle:`La gestion de contenu simplifiée`,recentActivity:`Activité récente`,quickActions:`Actions rapides`,quickStart:`Démarrage rapide`,createFirstDocument:`Créer votre premier document`,uploadMedia:`Importer des médias`,studioSettings:`Paramètres du Studio`,userPreferences:`Préférences utilisateur`,cards:{content:{title:`Contenu`,description:`Créez et gérez votre contenu`},media:{title:`Médias`,description:`Importez et organisez vos fichiers`},users:{title:`Utilisateurs`,description:`Gérez les utilisateurs et permissions`}},stats:{loading:`Chargement des statistiques...`,contentOverview:`Aperçu du contenu`,totalContent:`Contenu total`,singletons:`Singletons`,mediaFiles:`Fichiers médias`,content:`Contenu`,thisWeek:`cette semaine`,documents:`Documents`,media:`Fichiers médias`,users:`Utilisateurs`},activity:{title:`Activité récente`,refresh:`Actualiser l'activité`,loading:`Chargement de l'activité récente...`,unknownTime:`Date inconnue`,tryAgain:`Réessayer`,noActivity:`Aucune activité récente`,noActivityDescription:`L'activité apparaîtra ici au fur et à mesure que le contenu sera créé et modifié`,failedToLoad:`Échec du chargement de l'activité récente`,operations:{created:`créé`,updated:`modifié`,deleted:`supprimé`,published:`publié`,unpublished:`dépublié`,restored:`restauré`},changedField:`Modifié {{field}}`,changedFields:`Modifié {{fields}}`,changedFieldsCount:`Modifié {{count}} champs`,by:`par`}},language:{title:`Langue`,select:`Sélectionner la langue`,current:`Langue actuelle`},sidebar:{navigation:`Navigation`,expand:`Agrandir le panneau`,collapse:`Réduire le panneau`,searchNavigation:`Rechercher dans la navigation...`,loadingNavigation:`Chargement de la navigation...`,failedToLoad:`Échec du chargement de la navigation`,noResultsFor:`Aucun résultat pour "{{query}}"`,clearSearch:`Effacer la recherche`},layout:{globalSearch:`Recherche globale`,searchPlaceholder:`La fonctionnalité de recherche sera implémentée ici.`,expandContext:`Agrandir la barre contextuelle`,collapseContext:`Réduire la barre contextuelle`,resizeSidebar:`Glisser pour redimensionner`},contextSidebar:{quickActions:`Actions rapides`,createContent:`Créer du contenu`,createContentDesc:`Commencer avec un nouveau document`,uploadMedia:`Importer des médias`,uploadMediaDesc:`Ajouter des images et des fichiers`,recentActivity:`Activité récente`,noRecentActivity:`Aucune activité récente`,contentTypes:`Types de contenu`,noContentTypes:`Aucun type de contenu disponible`,mediaLibrary:`Médiathèque`,mediaLibraryDesc:`Importez et gérez vos fichiers médias`,userOverview:`Aperçu des utilisateurs`,totalUsers:`Total utilisateurs`,active:`Actifs`,roles:`Rôles`,usersLoggedInWeek:`{{count}} utilisateur connecté cette semaine`,usersLoggedInWeek_plural:`{{count}} utilisateurs connectés cette semaine`,usersNeverLoggedIn:`{{count}} utilisateur jamais connecté`,usersNeverLoggedIn_plural:`{{count}} utilisateurs jamais connectés`,inactiveUsers:`{{count}} utilisateur inactif`,inactiveUsers_plural:`{{count}} utilisateurs inactifs`,addNewUser:`Ajouter un utilisateur`,manageApiTokens:`Gérer les jetons API`,studioSettings:`Paramètres du Studio`,configureStudio:`Configurez votre studio`,fieldsRegistry:`Registre des champs`,totalFields:`Total des champs`,initialized:`Initialisé`,yes:`Oui`,no:`Non`,availableTypes:`Types disponibles`,documentation:`Documentation`,docSelectFields:`Sélectionnez des champs dans la barre latérale pour tester différents types`,docEditPreview:`Utilisez les onglets Édition/Aperçu pour voir les deux modes`,docUseExamples:`Cliquez sur les boutons "Utiliser" pour essayer différentes valeurs`,docShowErrors:`Activez "Afficher les erreurs" pour tester la validation`,defaultContextInfo:`Les informations contextuelles apparaîtront ici en fonction de la page actuelle.`,widgets:{unknownType:`Type de widget inconnu : {{type}}`,recentDocuments:{defaultTitle:`{{schema}} récents`,defaultTitleFallback:`Documents récents`,noSchemaType:`Aucun type de schéma spécifié`,failedToLoad:`Échec du chargement des documents récents`,untitled:`Sans titre`,noDocuments:`Aucun document récent`,by:`par`},stats:{total:`Total`,published:`Publié`,calculating:`Calcul en cours...`,notAvailable:`N/D`},category:{uncategorized:`Non catégorisé`},recentlyEdited:{untitled:`Sans titre`,by:`par`,author:`Auteur`}}},preferences:{title:`Préférences`,subtitle:`Personnalisez votre expérience Studio`,appearance:`Apparence`,theme:`Thème`,themeSystem:`Système par défaut`,themeLight:`Clair`,themeDark:`Sombre`,notifications:`Notifications`,emailNotifications:`Notifications par e-mail`,emailNotificationsDescription:`Recevoir des notifications par e-mail`,pushNotifications:`Notifications push`,pushNotificationsDescription:`Recevoir des notifications push du navigateur`,connectedAccounts:`Comptes connectés`,connectedAccountsDescription:`Liez des comptes externes pour une connexion plus facile`,security:`Sécurité`,securityDescription:`Gérer l'authentification à deux facteurs et les paramètres de sécurité`,passkeys:`Passkeys`,passkeysDescription:`Connectez-vous en toute sécurité sans mot de passe en utilisant votre empreinte digitale, votre visage ou une clé de sécurité.`,savePreferences:`Enregistrer les préférences`,saveSuccess:`Préférences enregistrées avec succès`,saveError:`Échec de la mise à jour des préférences`},notFound:{title:`Page non trouvée`,message:`La page que vous recherchez n'existe pas ou a été déplacée.`,goToDashboard:`Aller au tableau de bord`},auth:{forgotPassword:{title:`Mot de passe oublié ?`,subtitle:`Entrez votre adresse e-mail et nous vous enverrons un lien pour réinitialiser votre mot de passe.`,sendResetLink:`Envoyer le lien`,sending:`Envoi...`,backToSignIn:`Retour à la connexion`,checkEmail:`Vérifiez vos e-mails`,emailSentMessage:`Si un compte existe pour <strong>{{email}}</strong>, vous recevrez un lien de réinitialisation sous peu.`,linkExpires:`Le lien expirera dans 1 heure.`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,sendError:`Échec de l'envoi de l'e-mail de réinitialisation`},resetPassword:{title:`Réinitialiser le mot de passe`,subtitle:`Entrez votre nouveau mot de passe ci-dessous.`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,resetButton:`Réinitialiser le mot de passe`,resetting:`Réinitialisation...`,verifying:`Vérification du lien...`,success:`Mot de passe réinitialisé`,successMessage:`Votre mot de passe a été réinitialisé avec succès. Vous pouvez maintenant vous connecter avec votre nouveau mot de passe.`,signIn:`Se connecter`,invalidLink:`Lien invalide`,invalidLinkMessage:`Ce lien de réinitialisation est invalide ou a expiré.`,linkExpireNote:`Les liens de réinitialisation expirent après 1 heure. Veuillez en demander un nouveau.`,requestNewLink:`Demander un nouveau lien`,noToken:`Aucun jeton de réinitialisation fourni`,tokenInvalid:`Jeton de réinitialisation invalide ou expiré`,tokenVerifyError:`Échec de la vérification du jeton`,passwordMinLength:`Le mot de passe doit contenir au moins 8 caractères`,passwordMismatch:`Les mots de passe ne correspondent pas`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,resetError:`Échec de la réinitialisation du mot de passe`,linkExpiresIn:`Le lien expire dans {{minutes}} minute`,linkExpiresIn_plural:`Le lien expire dans {{minutes}} minutes`,strength:`Force`,strengthTooShort:`Trop court`,strengthWeak:`Faible`,strengthMedium:`Moyen`,strengthGood:`Bon`,strengthStrong:`Fort`,requirements:`Le mot de passe doit :`,requireLength:`Contenir au moins 8 caractères`,requireUppercase:`Contenir une majuscule (recommandé)`,requireNumber:`Contenir un chiffre (recommandé)`},oauth:{processing:`Traitement...`,completingAuth:`Authentification avec Google en cours`,success:`Succès !`,loginSuccess:`Connexion réussie ! Redirection...`,mfaRequired:`Vérification MFA requise. Redirection...`,mfaSetupRequired:`Configuration MFA requise. Redirection...`,accountLinked:`Compte Google lié avec succès`,failed:`Échec de l'authentification`,returnToLogin:`Retour à la connexion`,invalidResponse:`Réponse invalide du serveur`},device:{pageTitle:`Connexion Trokky CLI`,loading:`Chargement des informations de l'appareil...`,authorizeDevice:`Autoriser l'appareil`,requestingAccess:`demande l'accès à votre compte`,deviceCode:`Code de l'appareil`,allowApplication:`Cela permettra à l'application de :`,deny:`Refuser`,authorize:`Autoriser`,authorized:`Appareil autorisé`,authorizedMessage:`Vous pouvez maintenant fermer cette fenêtre et retourner au CLI.`,closeWindow:`Fermer la fenêtre`,denied:`Autorisation refusée`,deniedMessage:`L'appareil n'a pas été autorisé. Vous pouvez fermer cette fenêtre.`,expired:`Code expiré`,expiredMessage:`Le code de l'appareil a expiré. Veuillez réessayer depuis le CLI.`,error:`Erreur`,noCode:`Aucun code d'appareil fourni`,fetchError:`Échec de la récupération des informations de l'appareil`,connectError:`Échec de la connexion au serveur`,authError:`Échec de l'autorisation`,denyError:`Échec du refus de l'autorisation`,returnToStudio:`Retour au Studio`,scopes:{openid:`Accéder à votre identité`,profile:`Accéder à vos informations de profil`,contentRead:`Lire le contenu`,contentWrite:`Créer et modifier le contenu`,contentDelete:`Supprimer le contenu`,mediaRead:`Lire les fichiers médias`,mediaWrite:`Importer des fichiers médias`,offlineAccess:`Rester connecté`}},authorize:{pageTitle:`Trokky`,validating:`Validation de la demande d'autorisation...`,authorizeApp:`Autoriser l'application`,wantsAccess:`souhaite accéder à votre compte`,allowApplication:`Cela permettra à l'application de :`,visitWebsite:`Visiter le site de l'application`,deny:`Refuser`,authorize:`Autoriser`,consentNote:`En autorisant, vous permettez à cette application d'accéder à vos données selon les permissions listées ci-dessus.`,redirecting:`Redirection...`,redirectingMessage:`Vous êtes redirigé vers l'application.`,error:`Erreur d'autorisation`,missingParams:`Paramètres d'autorisation requis manquants`,invalidRequest:`Demande d'autorisation invalide`,validateError:`Échec de la validation de la demande d'autorisation`,authFailed:`Échec de l'autorisation`,denyFailed:`Échec du refus de l'autorisation`,returnToStudio:`Retour au Studio`}},documentEditor:{loadingSchema:`Chargement du schéma...`,loadingDocument:`Chargement du document...`,backToDocuments:`Retour aux documents`,schemaRequired:`Le nom du schéma est requis`,documentPreview:`Aperçu du document`,newDocument:`Nouveau {{type}}`,backTo:`Retour à {{type}}`,confirmStateChange:`Êtes-vous sûr de vouloir passer de {{from}} à {{to}} ?`,edit:`Modifier`,preview:`Aperçu`,readOnly:`Lecture seule`,readOnlyMode:`Mode lecture seule`,unsavedChanges:`Modifications non enregistrées`,validationErrors:`Erreurs de validation`,discardChangesConfirm:`Vous avez des modifications non enregistrées. Êtes-vous sûr de vouloir annuler ?`,discardChangesTitle:`Modifications non enregistrées`,discardChanges:`Annuler les modifications`,keepEditing:`Continuer l'édition`,documentInfo:`Informations du document`,loadingForm:`Chargement du formulaire...`,noFieldsDefined:`Aucun champ défini dans le schéma`,created:`Créé`,lastUpdated:`Dernière modification`,status:`Statut`,published:`Publié`,draft:`Brouillon`,publishedOn:`Publié le {{date}}`,tags:`Étiquettes`,contributors:`Contributeurs`,contributorsLoading:`Chargement...`,contributorsMore:`+{{count}} autres`,references:`Références`,referencesCount:`Références ({{count}})`,referencesMore:`+{{count}}`,noReferences:`Aucune référence`,schema:`Schéma`,fieldsCount:`{{count}} champs`,dangerZone:`Zone de danger`,deleteDocument:`Supprimer le document`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer "{{title}}" ? Cette action est irréversible.`,deleteTitle:`Supprimer le document`,cannotBeUndone:`Cette action est irréversible.`,expandSidebar:`Agrandir la barre latérale`,collapseSidebar:`Réduire la barre latérale`},documentHistory:{title:`Historique du document`,refreshHistory:`Actualiser l'historique`,loading:`Chargement...`,loadError:`Échec du chargement de l'historique`,notAvailable:`L'historique du document n'est pas disponible`,noHistory:`Aucun historique`,moreChanges:`+{{count}} autres modifications`},changesDiff:{noVisibleChanges:`Aucune modification visible`,changesCount:`Modifications ({{count}})`,showSystemFields:`Afficher les champs système`,hideSystemFields:`Masquer les champs système`,before:`Avant :`,after:`Après :`},auditEntry:{created:`Créé`,updated:`Modifié`,deleted:`Supprimé`,published:`Publié`,unpublished:`Dépublié`,restored:`Restauré`,by:`par`,latest:`Dernier`,changedField:`Modifié {{field}}`,changedFieldsJoin:`Modifié {{fields}}`,changedFieldsCount:`Modifié {{count}} champs`,hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,revision:`Révision :`,ipAddress:`Adresse IP :`,userAgent:`Agent utilisateur :`},appTokens:{title:`Jetons API`,subtitle:`Créez et gérez les jetons API pour les applications externes`,createToken:`Créer un jeton`,searchPlaceholder:`Rechercher des jetons...`,noTokensTitle:`Aucun jeton API`,noTokensDesc:`Créez votre premier jeton API pour permettre aux applications externes d'accéder à votre contenu de manière sécurisée.`,tableHeaders:{token:`Jeton`,status:`Statut`,lastUsed:`Dernière utilisation`,expires:`Expire`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`,expired:`Expiré`},never:`Jamais`,modal:{title:`Créer un jeton API`,tokenName:`Nom du jeton`,tokenNamePlaceholder:`ex. : API de production, Application mobile`,description:`Description`,descriptionPlaceholder:`À quoi servira ce jeton ?`,expiration:`Expiration`,expiration30days:`30 jours`,expiration90days:`90 jours (recommandé)`,expiration1year:`1 an`,expirationNever:`N'expire jamais`,expirationCustom:`Date personnalisée`,permissions:`Permissions`,cancel:`Annuler`,creating:`Création en cours...`,createToken:`Créer le jeton`},tokenCreated:{title:`Jeton API créé`,warning:`C'est la seule fois que vous verrez ce jeton. Copiez-le et conservez-le en lieu sûr.`,yourToken:`Votre jeton API`,copied:`Copié !`,close:`Fermer`},deleteConfirm:`Êtes-vous sûr de vouloir supprimer le jeton "{{name}}" ? Cette action est irréversible.`,permissions:{viewContent:`Voir le contenu`,editContent:`Modifier le contenu`,deleteContent:`Supprimer le contenu`,publishContent:`Publier le contenu`,viewMedia:`Voir les médias`,uploadMedia:`Importer des médias`,editMedia:`Modifier les médias`,deleteMedia:`Supprimer les médias`}},webhooks:{title:`Webhooks`,subtitle:`Recevez des notifications en temps réel lorsque des événements se produisent`,createWebhook:`Créer un webhook`,searchPlaceholder:`Rechercher des webhooks...`,noWebhooksTitle:`Aucun webhook configuré`,noWebhooksDesc:`Créez votre premier webhook pour recevoir des notifications en temps réel lorsque des événements se produisent.`,tableHeaders:{webhook:`Webhook`,status:`Statut`,events:`Événements`,lastUpdated:`Dernière mise à jour`,actions:`Actions`},status:{active:`Actif`,inactive:`Inactif`},eventsCount:`{{count}} événement`,eventsCount_plural:`{{count}} événements`,moreEvents:`+{{count}} de plus`,testWebhook:`Tester le webhook`,viewDeliveryHistory:`Voir l'historique des livraisons`,editWebhook:`Modifier le webhook`,deleteWebhook:`Supprimer le webhook`,deleteConfirm:`Êtes-vous sûr de vouloir supprimer le webhook "{{name}}" ? Cette action est irréversible.`,modal:{editTitle:`Modifier le webhook`,createTitle:`Créer un webhook`,name:`Nom du webhook`,namePlaceholder:`ex. : Synchronisation de contenu, Notifications Slack`,url:`URL du point de terminaison`,urlPlaceholder:`https://api.example.com/webhooks/trokky`,events:`Événements à souscrire`,secret:`Clé secrète`,secretPlaceholder:`Laisser vide pour générer automatiquement`,secretDescription:`Utilisée pour vérifier l'authenticité du webhook via des signatures HMAC`,headers:`En-têtes personnalisés`,headerNamePlaceholder:`Nom de l'en-tête`,headerValuePlaceholder:`Valeur de l'en-tête`,maxRetries:`Tentatives max`,backoffStrategy:`Stratégie de recul`,linear:`Linéaire`,exponential:`Exponentiel`,active:`Actif (le webhook recevra des événements)`,updating:`Mise à jour...`,creating:`Création...`,update:`Mettre à jour le webhook`,create:`Créer le webhook`},deliveryModal:{title:`Historique des livraisons : {{name}}`,noDeliveries:`Aucune livraison pour le moment`,status:`Statut`,response:`Réponse`,timestamp:`Date`,attempt:`Tentative`,success:`Succès`,failed:`Échec`},events:{allDocuments:`Tous les événements de documents`,documentCreated:`Document créé`,documentUpdated:`Document mis à jour`,documentDeleted:`Document supprimé`,documentPublished:`Document publié`,documentUnpublished:`Document dépublié`,allMedia:`Tous les événements médias`,mediaUploaded:`Média importé`,mediaUpdated:`Média mis à jour`,mediaDeleted:`Média supprimé`,allUsers:`Tous les événements utilisateurs`,userCreated:`Utilisateur créé`,userUpdated:`Utilisateur mis à jour`,userLogin:`Connexion utilisateur`,allSystem:`Tous les événements système`,systemStartup:`Démarrage système`,systemError:`Erreur système`}},changePassword:{title:`Changer le mot de passe`,currentPassword:`Mot de passe actuel`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,submit:`Changer le mot de passe`,submitting:`Changement en cours...`,success:`Mot de passe changé avec succès`,errors:{currentRequired:`Le mot de passe actuel est requis`,newRequired:`Le nouveau mot de passe est requis`,confirmRequired:`Veuillez confirmer votre nouveau mot de passe`,mismatch:`Les mots de passe ne correspondent pas`,tooShort:`Le mot de passe doit contenir au moins 8 caractères`,sameAsCurrent:`Le nouveau mot de passe doit être différent de l'actuel`,failed:`Échec du changement de mot de passe`}},oauth:{linkedAccounts:`Comptes liés`,linkAccount:`Lier le compte {{provider}}`,unlinkAccount:`Délier le compte`,accountLinked:`Compte lié avec succès`,unlinkSuccess:`Compte {{provider}} délié avec succès`,unlinkFailed:`Échec de la déliaison du compte`,confirmUnlink:`Êtes-vous sûr de vouloir délier ce compte {{provider}} ? Vous ne pourrez plus vous connecter avec ce compte.`,lastLoginMethod:`Ceci est votre dernière méthode de connexion. Vous ne pouvez pas la délier.`,notConnected:`Non connecté`,linked:`Lié le {{date}}`,unlink:`Délier`,comingSoon:`Bientôt disponible`,google:{signIn:`Se connecter avec Google`,linkAccount:`Lier le compte Google`,initFailed:`Échec de l'initialisation de la connexion Google`}},mfa:{title:`Authentification à deux facteurs`,subtitle:`Ajoutez une couche de sécurité supplémentaire à votre compte`,enabled:`2FA activée`,notEnabled:`2FA non activée`,authenticatorApp:`Application d'authentification`,authenticatorAppDesc:`Utilisez une application comme Google Authenticator ou Authy`,emailVerification:`Vérification par e-mail`,emailVerificationDesc:`Recevez des codes de vérification par e-mail`,emailCode:`Code par e-mail`,backupCode:`Code de secours`,backupCodes:`Codes de secours`,backupCodesRemaining:`{{count}} codes restants`,totpDescription:`Entrez le code à 6 chiffres de votre application d'authentification`,emailDescriptionPending:`Un code sera envoyé à votre e-mail`,emailDescriptionSent:`Entrez le code envoyé à votre e-mail`,backupDescription:`Entrez l'un de vos codes de secours (format : XXXX-XXXX)`,enterCode:`Veuillez entrer le code de vérification`,trustDevice:`Faire confiance à cet appareil pendant 30 jours`,trustedDevices:`Appareils de confiance`,trustedDevicesCount:`{{count}} appareil de confiance`,trustedDevicesCount_plural:`{{count}} appareils de confiance`,verifying:`Vérification...`,verify:`Vérifier`,sendingCode:`Envoi...`,resendCode:`Vous n'avez pas reçu le code ? Renvoyer`,setUp:`Configurer`,disableMethod:`Désactiver`,manage:`Gérer`,hide:`Masquer`,regenerate:`Régénérer`,revokeAll:`Tout révoquer`,cancel:`Annuler`,next:`Suivant`,done:`Terminé`,copyAll:`Tout copier`,copiedToClipboard:`Copié dans le presse-papiers`,setup:{authenticator:`Configurer l'application d'authentification`,scanQrCode:`Scannez ce QR code avec votre application d'authentification (Google Authenticator, Authy, etc.)`,orEnterManually:`Ou entrez ce code manuellement :`,verifyAuthenticatorCode:`Vérifier le code d'authentification`,enterCodeToVerify:`Entrez le code à 6 chiffres de votre application d'authentification pour vérifier la configuration.`,verifyEmailCode:`Vérifier le code e-mail`,enterEmailCode:`Entrez le code envoyé à votre adresse e-mail.`,saveBackupCodes:`Enregistrez vos codes de secours`,backupCodesImportant:`Conservez ces codes de secours en lieu sûr. Vous pouvez les utiliser pour accéder à votre compte si vous perdez votre appareil d'authentification.`,newBackupCodes:`Vos nouveaux codes de secours`,newBackupCodesImportant:`Conservez ces codes de secours en lieu sûr. Vos codes précédents ne sont plus valides. Vous pouvez utiliser ces codes pour accéder à votre compte si vous perdez votre appareil d'authentification.`},disable:{authenticator:`Désactiver l'application d'authentification`,email:`Désactiver la vérification par e-mail`,enterPassword:`Entrez votre mot de passe pour désactiver cette méthode 2FA.`,all:`Désactiver toute la 2FA`,allDesc:`Cela supprimera toutes les méthodes 2FA et les codes de secours de votre compte`},disableDialog:{authenticator:`Désactiver l'application d'authentification`,email:`Désactiver la vérification par e-mail`,enterPassword:`Entrez votre mot de passe pour désactiver cette méthode 2FA.`,all:`Désactiver toute la 2FA`,allWarning:`Cela désactivera complètement l'authentification à deux facteurs sur votre compte. Toutes les méthodes 2FA (application d'authentification, e-mail) et les codes de secours seront supprimés.`,confirmPassword:`Entrez votre mot de passe pour confirmer.`},regenerateBackupCodes:{title:`Régénérer les codes de secours`,description:`Cela invalidera tous vos codes de secours existants. Entrez votre mot de passe pour confirmer.`},trustedDevice:{trusted:`Approuvé : {{date}}`,confirmRevokeAll:`Êtes-vous sûr de vouloir révoquer la confiance de tous les appareils ?`},toast:{loadFailed:`Échec du chargement du statut 2FA`,totpInitFailed:`Échec de l'initialisation de la configuration TOTP`,totpEnabled:`Application d'authentification activée avec succès !`,emailCodeSent:`Code de vérification envoyé à votre e-mail`,emailSendFailed:`Échec de l'envoi du code de vérification`,emailEnabled:`Vérification par e-mail activée avec succès !`,authenticatorDisabled:`Application d'authentification désactivée`,emailDisabled:`Vérification par e-mail désactivée`,allDisabled:`Toute la 2FA a été désactivée`,backupCodesRegenerated:`Codes de secours régénérés. Enregistrez-les en lieu sûr !`,deviceRevoked:`Confiance de l'appareil révoquée`,deviceRevokeFailed:`Échec de la révocation de la confiance de l'appareil`,allDevicesRevoked:`Confiance de tous les appareils révoquée`,allDevicesRevokeFailed:`Échec de la révocation de la confiance des appareils`},errors:{passwordRequired:`Le mot de passe est requis`}},passkey:{signIn:`Se connecter avec Passkey`,optionsFailed:`Échec du démarrage de l'authentification par passkey`,cancelled:`L'authentification a été annulée`,notSupported:`Les passkeys ne sont pas prises en charge dans ce navigateur`,authFailed:`Échec de l'authentification par passkey`,verifyFailed:`Échec de la vérification du passkey`,unexpectedResponse:`Réponse inattendue du serveur`,manager:{title:`Passkeys`,description:`Connectez-vous en toute sécurité sans mot de passe en utilisant votre empreinte digitale, votre visage ou une clé de sécurité.`,loadFailed:`Échec du chargement des passkeys`,renameFailed:`Échec du renommage du passkey`,deleteFailed:`Échec de la suppression du passkey`,notConfigured:`L'authentification par passkey n'est pas activée`,notConfiguredDescription:`L'authentification par passkey doit être configurée par un administrateur dans les paramètres du serveur.`,noPasskeys:`Vous n'avez pas encore configuré de passkey.`,unnamed:`Passkey`,added:`Ajouté le`,lastUsed:`Dernière utilisation`,synced:`Synchronisé sur tous les appareils`,deviceOnly:`Cet appareil uniquement`},register:{addPasskey:`Ajouter un Passkey`,optionsFailed:`Échec du démarrage de l'enregistrement du passkey`,cancelled:`L'enregistrement a été annulé`,alreadyRegistered:`Ce passkey est déjà enregistré`,notSupported:`Les passkeys ne sont pas prises en charge dans ce navigateur`,failed:`Échec de l'enregistrement du passkey`,verifyFailed:`Échec de la vérification de l'enregistrement du passkey`,namePlaceholder:`ex. : MacBook Pro Touch ID`,continue:`Continuer`}},captcha:{loading:`Chargement du CAPTCHA...`,errors:{hcaptchaNotSupported:`hCaptcha n'est pas encore pris en charge`,providerNotSupported:`Le fournisseur "{{provider}}" n'est pas pris en charge`,scriptLoadFailed:`Échec du chargement du script CAPTCHA`,renderFailed:`Échec du rendu du widget CAPTCHA`,notAvailable:`{{provider}} non disponible`}},sessionTimeout:{title:`Session expirant bientôt`,expireIn:`Votre session expirera dans {{time}}.`,stayLoggedIn:`Rester connecté`,logout:`Se déconnecter`,extended:`Session prolongée avec succès`},common:{title:`Titre`,cancel:`Annuler`,dismiss:`Ignorer`,note:`Note :`,save:`Enregistrer`,delete:`Supprimer`,edit:`Modifier`,create:`Créer`,add:`Ajouter`,remove:`Retirer`,generate:`Générer`,close:`Fermer`,confirm:`Confirmer`,loading:`Chargement...`,error:`Erreur`,success:`Succès`,warning:`Avertissement`,info:`Information`,yes:`Oui`,no:`Non`,ok:`OK`,retry:`Réessayer`,back:`Retour`,next:`Suivant`,previous:`Précédent`,submit:`Soumettre`,reset:`Réinitialiser`,clear:`Effacer`,search:`Rechercher`,filter:`Filtrer`,sort:`Trier`,view:`Afficher`,download:`Télécharger`,upload:`Importer`,copy:`Copier`,paste:`Coller`,select:`Sélectionner`,selectAll:`Tout sélectionner`,deselectAll:`Tout désélectionner`,refresh:`Actualiser`,more:`Plus`,less:`Moins`,expand:`Développer`,collapse:`Réduire`,show:`Afficher`,hide:`Masquer`,enable:`Activer`,disable:`Désactiver`,actions:`Actions`,options:`Options`,details:`Détails`,preview:`Aperçu`,tryAgain:`Réessayer`,refreshPage:`Rafraîchir la page`,copyErrorDetails:`Copier les détails de l'erreur`,copied:`Copié !`,closeNotification:`Fermer la notification`,notifications:`Notifications`},errorBoundary:{title:`Une erreur s'est produite`,subtitle:`L'application a rencontré une erreur inattendue`,description:`Veuillez essayer de rafraîchir la page ou contacter le support si le problème persiste. Vous pouvez copier les détails de l'erreur ci-dessous pour faciliter le dépannage.`,errorMessage:`Message d'erreur :`,stackTrace:`Trace de la pile`,componentStack:`Pile des composants`,environmentDetails:`Détails de l'environnement`,noStackTrace:`Aucune trace de pile disponible`,noComponentStack:`Aucune pile de composants disponible`,url:`URL :`,timestamp:`Horodatage :`,userAgent:`Agent utilisateur :`,viewport:`Fenêtre d'affichage :`},toast:{closeNotification:`Fermer la notification`,notifications:`Notifications`},confirmDialog:{defaultConfirm:`Confirmer`,defaultCancel:`Annuler`},search:{placeholder:`Rechercher documents, médias...`,clearSearch:`Effacer la recherche`,closeSearch:`Fermer la recherche`,searching:`Recherche en cours...`,recentSearches:`Recherches récentes`,clear:`Effacer`,clearHistory:`Effacer l'historique de recherche`,foundResults:`{{count}} résultat trouvé`,foundResults_plural:`{{count}} résultats trouvés`,document:`Document`,media:`Média`,by:`par`,noResults:`Aucun résultat trouvé`,tryDifferent:`Essayez d'autres termes de recherche`,typeToSearch:`Tapez pour rechercher documents et médias`,pressEscape:`Appuyez sur Échap pour fermer`,poweredBy:`Propulsé par Trokky`},permissionsDebug:{title:`Débogage des permissions`,copyToClipboard:`Copier les infos de débogage`,currentUser:`Utilisateur actuel`,username:`Nom d'utilisateur :`,email:`E-mail :`,role:`Rôle :`,admin:`Admin :`,notLoggedIn:`Non connecté`,notAvailable:`N/D`,guest:`invité`,yes:`Oui`,no:`Non`,documentPermissions:`Permissions du document`,type:`Type :`,id:`ID :`,newDocument:`Nouveau document`,canCreate:`Peut créer`,canUpdate:`Peut modifier`,canDelete:`Peut supprimer`,canRead:`Peut lire`,allowed:`Autorisé`,denied:`Refusé`,fieldStates:`États des champs ({{count}})`,hideDetails:`Masquer les détails`,showDetails:`Afficher les détails`,disabled:`Désactivé`,readonly:`Lecture seule`,required:`Requis`,hasError:`A une erreur`,value:`Valeur :`,debugModeDev:`Mode débogage activé (dev)`,debugModeManual:`Mode débogage activé (manuel)`,disableInProduction:`Désactiver en production`,enableInProduction:`Activer en production`}},fields:{types:JSON.parse(`{"string":{"label":"Texte","placeholder":"Saisissez du texte...","description":"Champ de texte sur une ligne","noValue":"Aucune valeur","selection":"Sélection"},"text":{"label":"Zone de texte","placeholder":"Saisissez du texte...","description":"Champ de texte multiligne","words":"mots","lines":"lignes"},"number":{"label":"Nombre","placeholder":"Saisissez un nombre","placeholderInteger":"Saisissez un nombre entier","placeholderCurrency":"0,00","placeholderPercentage":"0,00 %","description":"Champ de valeur numérique","noValue":"Aucune valeur","increaseValue":"Augmenter la valeur","decreaseValue":"Diminuer la valeur"},"boolean":{"label":"Booléen","description":"Champ vrai/faux","yes":"Oui","no":"Non","toggle":"Basculer"},"date":{"label":"Date","placeholder":"Sélectionnez une date...","description":"Sélecteur de date","noDateSet":"Aucune date définie","clearDate":"Effacer la date","dateOnly":"Date","dateAndTime":"Date et heure"},"datetime":{"label":"Date et heure","placeholder":"Sélectionnez une date et une heure...","description":"Sélecteur de date et heure"},"image":{"label":"Image","placeholder":"Sélectionnez ou importez une image","description":"Champ d'import d'image","selectImage":"Sélectionner une image","changeImage":"Changer l'image","removeImage":"Supprimer l'image"},"file":{"label":"Fichier","placeholder":"Sélectionnez ou importez un fichier","description":"Champ d'import de fichier","selectFile":"Sélectionner un fichier","changeFile":"Changer le fichier","removeFile":"Supprimer le fichier"},"reference":{"label":"Référence","placeholder":"Sélectionner une référence...","description":"Référence vers un autre document","noResults":"Aucun résultat trouvé","noResultsFor":"Aucun résultat trouvé pour \\"{{query}}\\"","tryDifferentTerm":"Essayez un autre terme de recherche","noDocumentsAvailable":"Aucun document disponible","createDocumentsFirst":"Créez d'abord des documents pour les référencer ici","loading":"Chargement...","loadingTypes":"Chargement des types de documents...","searching":"Recherche...","filterDocuments":"Filtrer les documents...","allTypes":"Tous les types","anyType":"Tout type","available":"{{count}} disponible(s)","references":"{{count}} référence","references_plural":"{{count}} références","ofMax":"sur {{max}} max","removeReference":"Supprimer la référence","dragToReorder":"Glisser pour réorganiser","close":"Fermer","clear":"Effacer"},"array":{"label":"Liste","description":"Liste d'éléments","addItem":"Ajouter un élément","addFirstItem":"Ajouter le premier élément","removeItem":"Supprimer l'élément","moveUp":"Déplacer vers le haut","moveDown":"Déplacer vers le bas","empty":"Aucun élément ajouté","items":"éléments","item":"élément","itemCount":"{{count}} élément","itemCount_plural":"{{count}} éléments","missingDefinition":"Définition 'of' manquante pour le champ tableau","unknownType":"Type de champ inconnu : {{type}}","availableTypes":"Types disponibles : {{types}}","noOptionsConfigured":"Aucune option configurée pour la disposition sélection","noMatchingOptions":"Aucune option correspondante","holdCtrlToSelect":"Maintenez Ctrl/Cmd pour sélectionner plusieurs","removeTag":"Supprimer le tag \\"{{tag}}\\" ?","addTag":"Ajouter un tag...","typeToSearch":"Tapez pour rechercher ou ajouter des tags personnalisés","selectFromOptions":"Sélectionnez parmi les options disponibles","add":"Ajouter","minimum":"Minimum {{count}} élément","minimum_plural":"Minimum {{count}} éléments","maximum":"Maximum {{count}} élément","maximum_plural":"Maximum {{count}} éléments","range":"{{min}} - {{max}} éléments"},"object":{"label":"Objet","description":"Groupe de champs imbriqués","fields":"champs","field":"champ","otherFields":"Autres champs","invalidConfig":"Configuration de champ invalide : champ objet attendu","fieldNotRegistered":"Le type de champ '{{type}}' n'est pas enregistré. Veuillez vous assurer que le plugin de champ est chargé."},"select":{"label":"Sélection","placeholder":"Sélectionnez une option...","description":"Champ de sélection déroulante","noOptions":"Aucune option disponible"},"richtext":{"label":"Texte enrichi","placeholder":"Commencez à écrire...","description":"Éditeur de texte enrichi","noContent":"Aucun contenu","loadingEditor":"Chargement de l'éditeur...","invalidConfig":"Configuration de champ invalide : champ richtext attendu","toolbar":{"bold":"Gras","italic":"Italique","underline":"Souligné","strikethrough":"Barré","heading1":"Titre 1","heading2":"Titre 2","heading3":"Titre 3","quote":"Citation","addLink":"Ajouter un lien","insertImage":"Insérer une image","bulletList":"Liste à puces","numberedList":"Liste numérotée","insertTable":"Insérer un tableau","codeBlock":"Bloc de code","undo":"Annuler","redo":"Rétablir","viewEditSource":"Voir/Modifier le code source","fullscreen":"Plein écran","exitFullscreen":"Quitter le plein écran"},"stats":{"words":"mots","characters":"caractères","minRead":"min de lecture","exceedsLimit":"Dépasse la limite de caractères"},"imageToolbar":{"title":"Options d'image :","variant":"Variante :","original":"Original","delete":"Supprimer","deleteTitle":"Supprimer l'image"},"tableToolbar":{"title":"Options de tableau :","row":"Ligne","col":"Col","header":"En-tête","merge":"Fusionner","split":"Diviser","table":"Tableau","addRowAfter":"Ajouter une ligne après","deleteRow":"Supprimer la ligne","addColumnAfter":"Ajouter une colonne après","deleteColumn":"Supprimer la colonne","toggleHeaderRow":"Activer/Désactiver la ligne d'en-tête","mergeSelectedCells":"Fusionner les cellules sélectionnées","splitCell":"Diviser la cellule","deleteTable":"Supprimer le tableau"},"linkDialog":{"title":"Ajouter un lien","linkText":"Texte du lien","linkTextPlaceholder":"Saisissez le texte du lien","url":"URL","urlPlaceholder":"https://exemple.com","cancel":"Annuler","addLink":"Ajouter le lien","removeLink":"Supprimer le lien"},"source":{"placeholder":"Modifier le code source HTML..."},"sanitization":{"warning":"Le contenu a été nettoyé pour des raisons de sécurité : {{warnings}}","dismissWarning":"Ignorer l'avertissement"}},"portableText":{"label":"Texte portable","placeholder":"Tapez quelque chose...","description":"Éditeur de contenu en blocs","noContent":"Aucun contenu","emptyBlock":"Bloc vide","blocks":"Blocs :","characters":"Caractères :","words":"Mots :","blocksCount":"{{current}}/{{max}} blocs","charactersCount":"{{current}}/{{max}} caractères","normal":"Normal","heading1":"Titre 1","heading2":"Titre 2","heading3":"Titre 3","quote":"Citation","quotePlaceholder":"Citation...","bold":"Gras (⌘B)","italic":"Italique (⌘I)","underline":"Souligné (⌘U)","strikethrough":"Barré","code":"Code","addLink":"Ajouter un lien","hideStats":"Masquer les stats","showStats":"Afficher les stats","exitFullscreen":"Quitter le plein écran","fullscreen":"Plein écran","dragToReorder":"Glisser pour réorganiser (ou Alt+↑/↓)","deleteBlock":"Supprimer le bloc","addBlock":"+ Ajouter un bloc","checkRequirements":"Veuillez vérifier les exigences de contenu","linkDialog":{"title":"Ajouter un lien","url":"URL","textOptional":"Texte (optionnel)","textPlaceholder":"Texte du lien","cancel":"Annuler","add":"Ajouter le lien"},"deleteConfirm":"Êtes-vous sûr de vouloir supprimer ce bloc ?","deleteConfirmWithText":"Êtes-vous sûr de vouloir supprimer ce bloc ?\\n\\n\\"{{text}}\\"","deleteEmptyConfirm":"Êtes-vous sûr de vouloir supprimer ce bloc vide ?"},"slug":{"label":"Slug","placeholder":"mon-super-slug","description":"Identifiant compatible URL","generate":"Générer","edit":"Modifier","regenerate":"Régénérer le slug à partir du champ source","editSlug":"Modifier le slug","unique":"unique","noSlugSet":"Aucun slug défini","autoGeneratedFrom":"Généré automatiquement à partir de : {{source}}","manuallyEdited":"modifié manuellement","slugTaken":"Ce slug est déjà pris. Veuillez en choisir un autre.","checkingUniqueness":"Vérification de l'unicité...","slugIsUnique":"Le slug est unique","slugExists":"Le slug existe déjà","couldNotCheck":"Impossible de vérifier l'unicité"},"email":{"label":"E-mail","placeholder":"email@exemple.com","description":"Champ d'adresse e-mail","enterEmail":"Entrez une adresse e-mail"},"url":{"label":"URL","placeholder":"https://exemple.com","description":"Champ d'adresse web"},"color":{"label":"Couleur","placeholder":"#000000","description":"Sélecteur de couleur","openPicker":"Ouvrir le sélecteur de couleur","pickFromScreen":"Choisir une couleur à l'écran","quickColors":"Couleurs rapides","selectColor":"Sélectionner {{color}}"},"geoCoordinate":{"label":"Coordonnée géographique","description":"Champ de coordonnée géographique","manual":"Manuel","map":"Carte","latitude":"Latitude","longitude":"Longitude","useCurrentLocation":"Utiliser la position actuelle","altitude":"Altitude (mètres)","accuracy":"Précision (mètres)","interactiveMap":"Carte interactive","comingSoon":"(Bientôt disponible)"},"info":{"label":"Info","description":"Champ d'affichage informatif","expand":"Développer","collapse":"Réduire"},"password":{"label":"Mot de passe","description":"Champ de mot de passe","placeholder":"Saisissez un mot de passe","generatePassword":"Générer un mot de passe","showPassword":"Afficher le mot de passe","hidePassword":"Masquer le mot de passe","passwordStrength":"Force du mot de passe :","strength":{"noPassword":"Aucun mot de passe","veryWeak":"Très faible","weak":"Faible","fair":"Moyen","good":"Bon","strong":"Fort"}},"icon":{"label":"Icône","description":"Sélecteur d'icônes","selectIcon":"Sélectionner une icône","searchIcons":"Rechercher des icônes...","style":"Style :","category":"Catégorie :","allCategories":"Toutes les catégories","iconCount":"{{count}} icônes","noIconsFound":"Aucune icône trouvée","tryDifferentSearch":"Essayez un autre terme de recherche ou une autre catégorie","previous":"Précédent","next":"Suivant","pageOf":"Page {{page}} sur {{total}}","noLibrariesAvailable":"Aucune bibliothèque d'icônes disponible","noIconSelected":"Aucune icône sélectionnée","change":"Changer","select":"Sélectionner","clearIcon":"Effacer l'icône"},"media":{"label":"Média","description":"Champ d'import de média","selectMedia":"Sélectionner un média","clickToUploadOrBrowse":"Cliquez pour importer ou parcourir","addMedia":"Ajouter un média","addImage":"Ajouter une image","addVideo":"Ajouter une vidéo","addAudio":"Ajouter un audio","addDocument":"Ajouter un document","addArchive":"Ajouter une archive","dropFilesOrClick":"Glissez des fichiers ici ou cliquez pour importer","clickToUpload":"Cliquez pour importer","maxSize":"Taille max : {{size}}","selectFileToUpload":"Sélectionnez un fichier à importer","allowed":"Autorisés : {{types}}","upload":"Importer","browse":"Parcourir","cancel":"Annuler","change":"Changer","remove":"Supprimer","uploading":"Import en cours...","uploadFailed":"Échec de l'import. Veuillez réessayer.","mediaAssetNotFound":"Le fichier média n'existe plus","failedToLoadAsset":"Échec du chargement du fichier média","removeBrokenReference":"Supprimer la référence média cassée","changeMedia":"Changer le média","removeMedia":"Supprimer le média","mediaDetails":"Détails du média","altText":"Texte alternatif","altTextPlaceholder":"Décrivez cette image pour l'accessibilité","caption":"Légende","captionPlaceholder":"Ajouter une légende","titleOverride":"Titre personnalisé","titleOverridePlaceholder":"Remplacer le titre du fichier pour cet usage","mediaTypes":{"image":"Image","video":"Vidéo","audio":"Audio","document":"Document","archive":"Archive","media":"Média"},"unknownSize":"Taille inconnue"}}`),validation:{required:`Ce champ est obligatoire`,minLength:`Doit contenir au moins {{min}} caractères`,maxLength:`Ne doit pas dépasser {{max}} caractères`,min:`Doit être au moins {{min}}`,max:`Ne doit pas dépasser {{max}}`,pattern:`Format invalide`,email:`Doit être une adresse e-mail valide`,url:`Doit être une URL valide`,unique:`Cette valeur doit être unique`,invalidType:`Type de valeur invalide`,invalidDate:`Date invalide`,invalidNumber:`Doit être un nombre valide`,invalidInteger:`Doit être un nombre entier`,positive:`Doit être un nombre positif`,negative:`Doit être un nombre négatif`,fileSize:`La taille du fichier doit être inférieure à {{max}}`,fileType:`Type de fichier invalide`,imageSize:`Les dimensions de l'image doivent être {{width}}x{{height}} ou moins`},richtext:{bold:`Gras`,italic:`Italique`,underline:`Souligné`,strikethrough:`Barré`,heading1:`Titre 1`,heading2:`Titre 2`,heading3:`Titre 3`,paragraph:`Paragraphe`,bulletList:`Liste à puces`,numberedList:`Liste numérotée`,blockquote:`Citation`,codeBlock:`Bloc de code`,link:`Lien`,image:`Image`,table:`Tableau`,undo:`Annuler`,redo:`Rétablir`,clear:`Effacer le formatage`},noValue:`Aucune valeur`,errors:{invalidFieldConfig:`Configuration de champ invalide : champ {{type}} attendu`,definitionMissing:`Erreur : Définition de champ manquante`},autoFields:{_thumbnail:{title:`Image à la une`,description:`Image principale représentant ce contenu`},slug:{title:`URL`,description:`Identifiant compatible URL pour ce contenu`}},common:{validating:`Validation en cours...`},modal:{close:`Fermer`,done:`Terminé`,noFieldsDefined:`Aucun champ défini`}},auth:{login:{title:`Connexion`,subtitle:`Bon retour`,emailOrUsername:`E-mail ou nom d'utilisateur`,password:`Mot de passe`,rememberMe:`Rester connecté`,forgotPassword:`Mot de passe oublié ?`,signIn:`Se connecter`,signingIn:`Connexion en cours...`,orContinueWith:`ou continuer avec`,backToLogin:`Retour à la connexion`},logout:{title:`Déconnexion`,confirm:`Êtes-vous sûr de vouloir vous déconnecter ?`,success:`Vous avez été déconnecté`},forgotPassword:{title:`Mot de passe oublié`,subtitle:`Entrez votre e-mail pour recevoir un lien de réinitialisation`,email:`Adresse e-mail`,sendLink:`Envoyer le lien de réinitialisation`,sending:`Envoi en cours...`,success:`Si un compte existe avec cet e-mail, vous recevrez bientôt un lien de réinitialisation.`,backToLogin:`Retour à la connexion`},resetPassword:{title:`Réinitialiser le mot de passe`,subtitle:`Entrez votre nouveau mot de passe`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le mot de passe`,reset:`Réinitialiser le mot de passe`,resetting:`Réinitialisation...`,success:`Votre mot de passe a été réinitialisé avec succès`,invalidToken:`Jeton de réinitialisation invalide ou expiré`,passwordMismatch:`Les mots de passe ne correspondent pas`},changePassword:{title:`Changer le mot de passe`,currentPassword:`Mot de passe actuel`,newPassword:`Nouveau mot de passe`,confirmPassword:`Confirmer le nouveau mot de passe`,change:`Changer le mot de passe`,changing:`Changement en cours...`,success:`Mot de passe changé avec succès !`,minLength:`Au moins 8 caractères`,errors:{currentRequired:`Le mot de passe actuel est requis`,newRequired:`Le nouveau mot de passe est requis`,minLength:`Le nouveau mot de passe doit contenir au moins 8 caractères`,mismatch:`Les mots de passe ne correspondent pas`,samePassword:`Le nouveau mot de passe doit être différent du mot de passe actuel`,failed:`Échec du changement de mot de passe`}},mfa:{title:`Authentification à deux facteurs`,required:`Authentification à deux facteurs requise`,setupRequired:`Votre organisation exige l'authentification MFA. Veuillez configurer l'authentification à deux facteurs pour continuer.`,chooseMethod:`Choisissez votre méthode d'authentification préférée :`,authenticatorApp:`Application d'authentification`,authenticatorAppDesc:`Utilisez Google Authenticator, Authy, etc.`,emailCode:`Code par e-mail`,emailCodeDesc:`Recevez un code par e-mail`,scanQR:`Scannez ce code QR avec votre application d'authentification :`,manualEntry:`Ou entrez ce code manuellement :`,enterCode:`Entrez le code à 6 chiffres de votre application :`,enterEmailCode:`Entrez le code à 6 chiffres :`,emailSent:`Nous avons envoyé un code de vérification à votre adresse e-mail.`,verify:`Vérifier`,verifying:`Vérification...`,verifyComplete:`Vérifier et terminer la configuration`,chooseDifferent:`Choisir une autre méthode`,invalidCode:`Code de vérification invalide`,codeExpired:`Le code a expiré`,backupCodes:{title:`Enregistrez vos codes de secours`,description:`Ces codes peuvent être utilisés pour accéder à votre compte si vous perdez votre authentificateur. Chaque code ne peut être utilisé qu'une seule fois.`,copy:`Copier les codes`,warning:`Important : Conservez ces codes en lieu sûr. Vous ne pourrez plus les voir après cette page.`,continue:`J'ai enregistré mes codes - Continuer vers le tableau de bord`}},oauth:{google:`Continuer avec Google`,signInWith:`Se connecter avec {{provider}}`},session:{expired:`Votre session a expiré. Veuillez vous reconnecter.`,invalid:`Session invalide. Veuillez vous reconnecter.`},errors:{invalidCredentials:`E-mail ou mot de passe invalide`,accountLocked:`Le compte a été verrouillé. Veuillez contacter le support.`,accountDisabled:`Le compte a été désactivé`,tooManyAttempts:`Trop de tentatives échouées. Veuillez réessayer plus tard.`,networkError:`Erreur réseau. Veuillez vérifier votre connexion.`,serverError:`Erreur serveur. Veuillez réessayer plus tard.`,captchaRequired:`Veuillez compléter la vérification CAPTCHA`,unauthorized:`Vous n'êtes pas autorisé à effectuer cette action`},advanced:{title:`Avancé`,backendUrl:`URL du serveur`,customEndpoint:`Point de terminaison API personnalisé`},claim:{title:`Prendre possession de ce Trokky`,subtitle:`Cette instance n'a pas encore de propriétaire. Créez le compte administrateur et elle est à vous.`,username:`Nom d'utilisateur`,email:`Adresse e-mail`,password:`Mot de passe`,confirmPassword:`Confirmer le mot de passe`,secret:`Secret de prise de possession`,secretHelp:`Cette instance a été déployée avec un secret. Saisissez-le pour prouver que le déploiement est le vôtre.`,passwordMismatch:`Les mots de passe ne correspondent pas`,claim:`Prendre possession et se connecter`,claiming:`Prise de possession en cours...`,alreadyClaimed:`Quelqu'un vient de prendre possession de cette instance.`,failed:`La prise de possession a échoué`,openWarning:`Quiconque atteint cette page peut prendre possession de l'instance. Faites-le maintenant.`}},errors:{codes:{DOCUMENT_NOT_FOUND:`Document non trouvé`,SCHEMA_NOT_FOUND:`Schéma non trouvé`,VALIDATION_FAILED:`Échec de la validation`,UNAUTHORIZED:`Vous n'êtes pas autorisé à effectuer cette action`,FORBIDDEN:`Accès refusé`,NOT_FOUND:`Ressource non trouvée`,CONFLICT:`Un conflit s'est produit`,INTERNAL_ERROR:`Une erreur interne s'est produite`,NETWORK_ERROR:`Erreur réseau. Veuillez vérifier votre connexion.`,TIMEOUT:`Délai d'attente dépassé. Veuillez réessayer.`,RATE_LIMITED:`Trop de requêtes. Veuillez ralentir.`,INVALID_INPUT:`Donnée d'entrée invalide`,DUPLICATE_ENTRY:`Cette entrée existe déjà`,FILE_TOO_LARGE:`La taille du fichier dépasse le maximum autorisé`,INVALID_FILE_TYPE:`Ce type de fichier n'est pas autorisé`,UPLOAD_FAILED:`Échec de l'import du fichier`,DELETE_FAILED:`Échec de la suppression de l'élément`,UPDATE_FAILED:`Échec de la mise à jour de l'élément`,CREATE_FAILED:`Échec de la création de l'élément`,SESSION_EXPIRED:`Votre session a expiré. Veuillez vous reconnecter.`,INVALID_TOKEN:`Jeton invalide ou expiré`,MFA_REQUIRED:`Authentification multi-facteurs requise`,MFA_INVALID:`Jeton MFA invalide ou expiré`,MFA_CODE_INVALID:`Code de vérification invalide`,PASSWORD_TOO_WEAK:`Le mot de passe ne répond pas aux exigences de sécurité`,USER_NOT_FOUND:`Utilisateur non trouvé`,USER_ALREADY_EXISTS:`Un utilisateur avec cet e-mail existe déjà`,EMAIL_NOT_VERIFIED:`Adresse e-mail non vérifiée`,PERMISSION_DENIED:`Vous n'avez pas la permission d'effectuer cette action`,MEDIA_NOT_FOUND:`Fichier média non trouvé`,WEBHOOK_DELIVERY_FAILED:`Échec de la livraison du webhook`},generic:{title:`Erreur`,unknown:`Une erreur inattendue s'est produite`,tryAgain:`Veuillez réessayer`,contactSupport:`Si le problème persiste, veuillez contacter le support`,goBack:`Retour`,refresh:`Actualiser la page`},form:{invalidField:`{{field}} est invalide`,requiredField:`{{field}} est requis`,fieldTooLong:`{{field}} est trop long`,fieldTooShort:`{{field}} est trop court`},api:{fetchError:`Échec de la récupération des données`,saveError:`Échec de l'enregistrement des données`,deleteError:`Échec de la suppression des données`,connectionError:`Impossible de se connecter au serveur`}}}},pr=`trokky_language`;function mr(e){return ur.includes(e)}function hr(){if(typeof window>`u`)return null;let e=localStorage.getItem(pr);return e&&mr(e)?e:null}function gr(e){typeof window>`u`||localStorage.setItem(pr,e)}var _r=null;function vr(e={}){let{defaultLocale:t=`en`,fallbackLocale:n=`en`,detectBrowserLanguage:r=!0,debug:i=!1}=e;return _r||(r&&typeof window<`u`&&Rn.use(cr),Rn.use(Pt).init({resources:fr,lng:hr()||t,fallbackLng:n,defaultNS:lr,ns:[`common`,`studio`,`fields`,`auth`,`errors`],interpolation:{escapeValue:!1},detection:r?{order:[`localStorage`,`navigator`,`htmlTag`],lookupLocalStorage:pr,caches:[`localStorage`]}:void 0,debug:i,saveMissing:i,missingKeyHandler:i?(e,t,n)=>{console.warn(`[i18n] Missing translation: ${t}:${n} for ${e.join(`, `)}`)}:void 0}),_r=Rn,Rn)}function yr(){return Rn.isInitialized||vr(),Rn}function br({children:e,config:t,initialLocale:n,onLanguageChange:r}){let i=(0,B.useMemo)(()=>{let e=vr(t);return n&&(e.changeLanguage(n),gr(n)),e},[t,n]);return(0,B.useEffect)(()=>{if(!r)return;let e=e=>{r(e)};return i.on(`languageChanged`,e),()=>{i.off(`languageChanged`,e)}},[i,r]),(0,V.jsx)(Vt,{i18n:i,children:e})}function H(e=`common`,t){return Bt(e,t)}function xr(){let{i18n:e}=Bt();return{locale:e.language,setLocale:(0,B.useCallback)(t=>{mr(t)?(e.changeLanguage(t),gr(t)):console.warn(`[i18n] Attempted to set unsupported locale: ${t}`)},[e]),locales:ur,getLocaleName:(0,B.useCallback)(e=>dr[e]||e,[]),i18n:e}}function Sr(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=Sr(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function Cr(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=Sr(e))&&(r&&(r+=` `),r+=t);return r}function wr(...e){return Cr(e)}function U({variant:e=`primary`,size:t=`md`,loading:n=!1,asChild:r=!1,className:i,disabled:a,children:o,...s}){let c=`inline-flex items-center justify-center font-medium rounded-lg transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed`,l={primary:`bg-primary-600 text-white hover:bg-primary-700 focus:ring-primary-500`,secondary:`bg-gray-600 text-white hover:bg-gray-700 focus:ring-gray-500`,outline:`border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-600 focus:ring-primary-500`,ghost:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 focus:ring-primary-500`,danger:`bg-red-600 text-white hover:bg-red-700 focus:ring-red-500`},u={sm:`px-3 py-1.5 text-sm`,md:`px-4 py-2 text-sm`,lg:`px-6 py-3 text-base`};if(r){let r=o;return B.cloneElement(r,{className:wr(c,l[e],u[t],r.props.className,i),disabled:a||n,...s})}return(0,V.jsxs)(`button`,{className:wr(c,l[e],u[t],i),disabled:a||n,...s,children:[n&&(0,V.jsxs)(`svg`,{className:`animate-spin -ml-1 mr-2 h-4 w-4`,fill:`none`,viewBox:`0 0 24 24`,children:[(0,V.jsx)(`circle`,{className:`opacity-25`,cx:`12`,cy:`12`,r:`10`,stroke:`currentColor`,strokeWidth:`4`}),(0,V.jsx)(`path`,{className:`opacity-75`,fill:`currentColor`,d:`M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z`})]}),o]})}var Tr=`trokky_auth_token`,Er=`trokky_refresh_token`;function Dr(e){try{return localStorage.getItem(e)}catch{return null}}function Or(e,t){try{localStorage.setItem(e,t)}catch{}}function kr(e){try{localStorage.removeItem(e)}catch{}}var Ar=new class{tokens;listeners=new Set;refresher=null;inFlight=null;session=0;constructor(){this.tokens={token:Dr(Tr),refreshToken:Dr(Er)}}getTokens(){return{...this.tokens}}getToken(){return this.tokens.token}getRefreshToken(){return this.tokens.refreshToken}persist(e,t){this.tokens.token=e,Or(Tr,e),t&&(this.tokens.refreshToken=t,Or(Er,t)),this.emit()}clear(){this.session+=1,this.inFlight=null,this.tokens={token:null,refreshToken:null},kr(Tr),kr(Er),this.emit()}emit(){let e=this.getTokens();this.listeners.forEach(t=>t(e))}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}setRefresher(e){this.refresher=e}async refresh(){if(this.inFlight)return this.inFlight;let e=this.tokens.refreshToken;if(!e||!this.refresher)return null;let t=this.session;return this.inFlight=(async()=>{try{let n=await this.refresher(e);return t===this.session?n?.token?(this.persist(n.token,n.refreshToken),n):(this.clear(),null):null}catch{return t===this.session&&this.clear(),null}finally{t===this.session&&(this.inFlight=null)}})(),this.inFlight}},jr=class extends Error{status;code;details;constructor(e,t,n,r){super(e),this.status=t,this.code=n,this.details=r,this.name=`ApiClientError`}},Mr={debug:0,info:1,warn:2,error:3},Nr=typeof window<`u`&&window.__TROKKY_DEV__===!0?`warn`:`error`,Pr=class{config;constructor(e,t={}){this.config={level:Nr,enabled:!0,prefix:`[Studio:${e}]`,...t}}shouldLog(e){return this.config.enabled&&Mr[e]>=Mr[Nr]}formatMessage(e,t){return`${this.config.prefix}[${e}] ${t}`}debug(e,t){if(this.shouldLog(`debug`)){let n=this.formatMessage(`debug`,e);t?console.debug(n,t):console.debug(n)}}info(e,t){if(this.shouldLog(`info`)){let n=this.formatMessage(`info`,e);t?console.info(n,t):console.info(n)}}warn(e,t){if(this.shouldLog(`warn`)){let n=this.formatMessage(`warn`,e);t?console.warn(n,t):console.warn(n)}}error(e,t){if(this.shouldLog(`error`)){let n=this.formatMessage(`error`,e);t instanceof Error||t?console.error(n,t):console.error(n)}}};function Fr(e){return new Pr(e)}typeof window<`u`&&window.__TROKKY_LOG_LEVEL__&&(Nr=window.__TROKKY_LOG_LEVEL__),typeof window<`u`&&(window.TrokkyLogger={setLevel(e){Nr=e,typeof window<`u`&&(window.__TROKKY_LOG_LEVEL__=e)},getLevel(){return Nr},disable(){Nr=`error`},enable(){Nr=typeof window<`u`&&window.__TROKKY_DEV__===!0?`warn`:`error`}});var Ir=Fr(`Storage`),Lr={AUTH_TOKEN:`trokky_auth_token`,REFRESH_TOKEN:`trokky_refresh_token`,USER_DATA:`trokky_user_data`,THEME:`trokky_theme`,SIDEBAR_COLLAPSED:`trokky_sidebar_collapsed`,SIDEBAR_WIDTH:`trokky_sidebar_width`,CONTENT_VIEW:e=>`trokky_view_${e}`,COLUMN_VISIBILITY:e=>`trokky_columns_${e}`,GRID_SETTINGS:e=>`trokky_grid_${e}`,TABLE_SETTINGS:e=>`trokky_table_${e}`,STUDIO_CONFIG:`trokky_studio_config`,STRUCTURE_CACHE:`trokky_structure_cache`,DEBUG_ENABLED:`trokky_debug_enabled`,BACKEND_URL:`trokky_backend_url`,MEDIA_VIEW_MODE:`trokky_media_view_mode`,CONTEXT_SIDEBAR_VISIBLE:e=>`trokky_context_sidebar_${e}_visible`,CONTEXT_SIDEBAR_COLLAPSED:e=>`trokky_context_sidebar_${e}_collapsed`,CONTEXT_SIDEBAR_WIDTH:e=>`trokky_context_sidebar_${e}_width`,CONTEXT_SIDEBAR_POSITION:e=>`trokky_context_sidebar_${e}_position`,DOCUMENT_SIDEBAR_COLLAPSED:`trokky_document_sidebar_collapsed`,RECENT_SEARCHES:`trokky_recent_searches`},Rr=new class{isAvailable(){try{return typeof localStorage<`u`&&localStorage!==null}catch{return!1}}get(e,t){if(!this.isAvailable())return Ir.warn(`localStorage not available, returning default value`),t??null;try{let n=localStorage.getItem(e);if(n===null)return t??null;try{return JSON.parse(n)}catch{return n}}catch(n){return Ir.error(`Failed to get item from localStorage`,{key:e,error:n}),t??null}}set(e,t){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot set value`),!1;try{let n=typeof t==`string`?t:JSON.stringify(t);return localStorage.setItem(e,n),!0}catch(t){return Ir.error(`Failed to set item in localStorage`,{key:e,error:t}),!1}}remove(e){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot remove value`),!1;try{return localStorage.removeItem(e),!0}catch(t){return Ir.error(`Failed to remove item from localStorage`,{key:e,error:t}),!1}}exists(e){if(!this.isAvailable())return!1;try{return localStorage.getItem(e)!==null}catch{return!1}}clear(e){if(!this.isAvailable())return Ir.warn(`localStorage not available, cannot clear values`),!1;try{if(e){let t=this.getAllKeys().filter(t=>t.includes(e));t.forEach(e=>localStorage.removeItem(e)),Ir.info(`Cleared ${t.length} items matching pattern: ${e}`)}else{let e=this.getAllKeys().filter(e=>e.startsWith(`trokky_`));e.forEach(e=>localStorage.removeItem(e)),Ir.info(`Cleared ${e.length} trokky items`)}return!0}catch(t){return Ir.error(`Failed to clear localStorage`,{pattern:e,error:t}),!1}}getAllKeys(){if(!this.isAvailable())return[];try{return Object.keys(localStorage)}catch{return[]}}},zr={getContentView:(e,t=`list`)=>Rr.get(Lr.CONTENT_VIEW(e),t),setContentView:(e,t)=>Rr.set(Lr.CONTENT_VIEW(e),t),getColumnVisibility:(e,t={})=>Rr.get(Lr.COLUMN_VISIBILITY(e),t),setColumnVisibility:(e,t)=>Rr.set(Lr.COLUMN_VISIBILITY(e),t),getGridSettings:(e,t={cardSize:`medium`,columnsPerRow:null})=>Rr.get(Lr.GRID_SETTINGS(e),t),setGridSettings:(e,t)=>Rr.set(Lr.GRID_SETTINGS(e),t),getTableSettings:(e,t={density:`comfortable`,columnWidths:{}})=>Rr.get(Lr.TABLE_SETTINGS(e),t),setTableSettings:(e,t)=>Rr.set(Lr.TABLE_SETTINGS(e),t),getTheme:()=>Rr.get(Lr.THEME,`light`),setTheme:e=>Rr.set(Lr.THEME,e),getSidebarCollapsed:()=>Rr.get(Lr.SIDEBAR_COLLAPSED,!1),setSidebarCollapsed:e=>Rr.set(Lr.SIDEBAR_COLLAPSED,e),getSidebarWidth:()=>Rr.get(Lr.SIDEBAR_WIDTH,280),setSidebarWidth:e=>Rr.set(Lr.SIDEBAR_WIDTH,e),clearAll:()=>Rr.clear(),clearSchema:e=>Rr.clear(e),service:Rr},Br=[`/auth/refresh`,`/auth/validate`,`/auth/login`,`/auth/logout`],Vr=class{backendUrl=``;capabilities=null;logger=Fr(`ApiClient`);configured=!1;onUnauthorized=null;constructor(e){e&&(this.backendUrl=e,this.configured=!0)}get authToken(){return Ar.getToken()}initialize(){if(this.configured)return;this.configured=!0;let e=window.TROKKY_CONFIG?.backendUrl,t=Rr.get(Lr.BACKEND_URL);e?(this.setBackendUrl(e),t&&t!==e&&(Rr.remove(Lr.BACKEND_URL),this.logger.debug(`Cleared stale backend URL from localStorage`))):t?this.setBackendUrl(t):this.logger.info(`No backend URL configured. User will need to set it in login form.`),this.logger.info(`Studio initialized`,{backendUrl:this.backendUrl,hasAuthToken:!!this.authToken})}ensureConfigured(){this.configured||this.initialize()}setBackendUrl(e){this.backendUrl=e.replace(/\/$/,``),this.updateCapabilities(),this.logger.info(`Backend URL set`,{backendUrl:this.backendUrl})}updateCapabilities(){this.capabilities={version:`2.0.0`,features:{search:!1,media:!0,auth:!0,structure:!0,workflows:!1},endpoints:{documents:`/collections`,auth:`/auth`,structure:`/structure`,slugs:`/slugs`},limits:{maxUploadSize:104857600,maxResults:100,requestRate:1e3}}}get isInitialized(){return!!this.backendUrl&&!!this.capabilities}getCapabilities(){return this.capabilities}hasFeature(e){return this.capabilities?.features[e]??!1}setAuthToken(e){Ar.persist(e)}clearAuthToken(){Ar.clear()}async storeTokens(e,t){Ar.persist(e,t)}async request(e,t={},n=!1,r=!1){if(this.ensureConfigured(),!this.backendUrl)return{success:!1,error:{message:`Backend URL not configured. Please configure it in the login form.`,code:`NO_BACKEND_URL`}};let i=this.buildUrl(e),a={Accept:`application/json`,...t.headers||{}};t.body instanceof FormData||(a[`Content-Type`]=`application/json`),this.authToken&&!n&&(a.Authorization=`Bearer ${this.authToken}`);try{let o=await fetch(i,{...t,headers:a,credentials:`include`});if(!o.headers.get(`content-type`)?.includes(`application/json`)){if(!o.ok)throw new jr(`HTTP ${o.status}: ${o.statusText}`,o.status);return{success:!0,data:null}}let s=await o.json();if(!o.ok){if(o.status===401&&this.authToken&&!n&&!r&&!Br.some(t=>e.includes(t))&&(await this.onUnauthorized?.()??!1))return this.request(e,t,n,!0);throw new jr(s.error?.message||`HTTP ${o.status}`,o.status,s.error?.code,s.error?.details)}return{success:!0,data:s.data||s,meta:s.meta}}catch(e){throw e instanceof jr?e:new jr(`Network error: ${e instanceof Error?e.message:`Unknown error`}`)}}buildUrl(e){if(e.startsWith(`http`))return e;if(this.ensureConfigured(),!this.backendUrl)throw this.logger.warn(`Backend URL not set, cannot build URL for endpoint:`,e),new jr(`Backend URL not configured. Please set the backend URL.`);let t=e.startsWith(`/`)?e.slice(1):e,n=t?`${this.backendUrl}/${t}`:this.backendUrl;return this.logger.debug(`Building URL:`,{originalEndpoint:e,cleanEndpoint:t,backendUrl:this.backendUrl,finalUrl:n}),n}async get(e,t){let n=new URL(this.buildUrl(e));return t&&Object.entries(t).forEach(([e,t])=>{t!=null&&n.searchParams.append(e,String(t))}),this.request(n.toString(),{method:`GET`})}async post(e,t,n){return this.request(e,{method:`POST`,body:t?JSON.stringify(t):void 0,headers:n?.headers,signal:n?.signal})}async put(e,t){return this.request(e,{method:`PUT`,body:t?JSON.stringify(t):void 0})}async patch(e,t){return this.request(e,{method:`PATCH`,body:t?JSON.stringify(t):void 0})}async delete(e){return this.request(e,{method:`DELETE`})}};function Hr(e,t,n){return t?n?`${e}/media/${t}/variants/${n}`:`${e}/media/${t}/file`:``}function Ur(e,t,n=(t,n)=>Hr(e,t,n)){return!t||!t.id?t:{...t,url:n(t.id),...t.variants&&{variants:Object.keys(t.variants).reduce((e,r)=>(e[r]={...t.variants[r],url:n(t.id,r)},e),{})}}}async function Wr(e,t,n={}){let r=[];if(!n.types||n.types.includes(`documents`))try{let n=await e.getSchemas();if(n.success&&n.data)for(let i of n.data.slice(0,3)){let n=await e.getDocuments(i.name,{limit:5,search:t});n.success&&n.data?.documents&&r.push(...n.data.documents.map(e=>({id:e.id||e._id,type:`document`,title:e.title||e.name||e.id||e._id,url:`/content/${i.name}/${e.id||e._id}`,metadata:{status:e._status,createdAt:e._createdAt}})))}}catch(e){console.warn(`Document search failed:`,e)}return{success:!0,data:{results:r.slice(0,n.limit||20),totalCount:r.length,categories:{documents:r.filter(e=>e.type===`document`).length,media:0,users:0,schemas:0},query:t,searchTime:0}}}var W=new class extends Vr{async getSchemas(){let e=await this.get(`/collections`);return e.success&&e.data?.collections?{success:!0,data:e.data.collections,meta:e.meta}:{success:!1,data:[]}}async getSchema(e){return this.get(`/schemas/${e}`)}async getDocuments(e,t={}){return this.get(`/collections/${e}`,t)}async getDocument(e,t){return this.get(`/collections/${e}/${t}`)}async createDocument(e,t){return this.post(`/collections/${e}`,{data:t})}async updateDocument(e,t,n){return this.put(`/collections/${e}/${t}`,{data:n})}async deleteDocument(e,t){return this.delete(`/collections/${e}/${t}`)}async getMedia(e={}){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let t=await this.get(`/media`,e);return t.success&&t.data&&(t.data=t.data.map(e=>this.transformMediaObject(e))),t}async getMediaFile(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let t=await this.get(`/media/${e}`);return t.success&&t.data?.file&&(t.data.file=this.transformMediaObject(t.data.file)),t}async getMediaById(e){return this.getMediaFile(e)}async downloadMediaFile(e){this.ensureConfigured();let t={};this.authToken&&(t.Authorization=`Bearer ${this.authToken}`);let n=await fetch(this.buildUrl(`/media/${e}/file`),{headers:t,credentials:`include`});if(!n.ok)throw new jr(`HTTP ${n.status}: ${n.statusText}`,n.status);return n.blob()}async uploadMedia(e,t,n){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let r=n;t&&typeof t==`object`&&!n&&(r=t);let i=new FormData;i.append(`files`,e),r&&i.append(`metadata`,JSON.stringify(r));let a=await this.request(`/media/upload`,{method:`POST`,body:i});return a.success&&a.data&&(a.data=this.transformMediaObject(a.data)),a}async updateMedia(e,t){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);let n=await this.put(`/media/${e}`,{metadata:t});return n.success&&n.data?.file&&(n.data.file=this.transformMediaObject(n.data.file)),n}async deleteMedia(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.delete(`/media/${e}`)}async bulkDeleteMedia(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.post(`/media/bulk-delete`,{ids:e})}async regenerateMediaVariants(e){if(!this.hasFeature(`media`))throw new jr(`Media feature not available`);return this.post(`/media/${e}/regenerate-variants`,{})}transformMediaObject(e){return Ur(this.backendUrl,e,(e,t)=>this.getMediaUrl(e,t))}getMediaUrl(e,t){return Hr(this.backendUrl,e,t)}getBackendUrl(){return this.ensureConfigured(),this.backendUrl}getApiBasePath(){return this.backendUrl}async listDocuments(e,t={}){let n=new URLSearchParams;t.page&&n.set(`page`,String(t.page)),t.limit&&n.set(`limit`,String(t.limit)),t.search&&n.set(`search`,t.search),t.sort&&n.set(`sort`,t.sort),t.filter&&Object.entries(t.filter).forEach(([e,t])=>{t!=null&&t!==``&&n.set(`filter[${e}]`,String(t))});let r=`/collections/${e}${n.toString()?`?${n.toString()}`:``}`;return this.get(r)}async getCollectionStats(e){return this.get(`/stats/${e}`)}async search(e,t={}){return this.hasFeature(`search`)?this.get(`/search`,{q:e,...t}):this.clientSideSearch(e,t)}async clientSideSearch(e,t={}){return Wr(this,e,t)}async getCurrentUser(){if(!this.hasFeature(`auth`))throw new jr(`Auth feature not available`);return this.get(`/auth/me`)}async getClaimStatus(){return this.get(`/auth/claim`)}async claimInstance(e){let t=await this.post(`/auth/claim`,e);return t.success&&t.data?.token&&this.setAuthToken(t.data.token),t}async login(e,t,n,r,i){if(!this.hasFeature(`auth`))throw new jr(`Auth feature not available`);let a=await this.post(`/auth/login`,{username:e,password:t,rememberMe:n,deviceId:r,captchaToken:i});return a.success&&a.data?.token&&this.setAuthToken(a.data.token),a}async logout(){if(this.hasFeature(`auth`))try{await this.post(`/auth/logout`)}catch(e){console.warn(`Server logout failed:`,e)}return this.clearAuthToken(),{success:!0}}async checkSlugUniqueness(e,t,n){let r=new URLSearchParams({slug:e,collection:t});return n&&r.append(`excludeId`,n),this.get(`/slugs/check-unique?${r}`)}async getStructure(){return this.hasFeature(`structure`)?this.get(`/structure`):{success:!0,data:null}}};Ar.setRefresher(async e=>{let t=await W.post(`/auth/refresh`,{refreshToken:e});return t.success&&t.data?.token?t.data:null});var Gr=class{client;constructor(e){this.client=e}async generateFromSchemas(e={}){try{let t=await this.client.getSchemas();if(!t.success||!t.data)throw Error(`Failed to fetch schemas`);let n=t.data,{includeSchemas:r,excludeSchemas:i=[],groupBy:a=`none`,defaultPageSize:o=25}=e,s=n;r&&(s=n.filter(e=>r.includes(e.name))),s=s.filter(e=>!i.includes(e.name));let c=[];if(a===`none`)for(let e of s)c.push(this.createDocumentListItem(e,o));else{let e=this.groupSchemas(s,a);for(let[t,n]of Object.entries(e))n.length===1?c.push(this.createDocumentListItem(n[0],o)):c.push({type:`group`,title:this.formatGroupTitle(t),icon:this.getGroupIcon(t),items:n.map(e=>this.createDocumentListItem(e,o)),collapsible:!0,defaultCollapsed:!1})}return{title:`Content Management`,items:c,metadata:{version:`1.0.0`,description:`Auto-generated structure from schemas`}}}catch(e){return console.error(`Failed to generate structure from schemas:`,e),this.getFallbackStructure()}}buildNavigation(e,t){let n=[],r=0,i=0,a=(e,n=0)=>{switch(i=Math.max(i,n),r++,e.type){case`documentList`:return{id:e.id||`list-${e.schemaType}`,title:e.title,type:`documentList`,icon:e.icon||`document-text`,path:`/content/${e.schemaType}`,active:t===`/content/${e.schemaType}`,metadata:{schemaType:e.schemaType,filter:e.filter}};case`singleton`:let i=e.documentId||`singleton`;return{id:e.id||`singleton-${e.schemaType}`,title:e.title,type:`singleton`,icon:e.icon||`cog`,path:`/content/${e.schemaType}/${i}`,active:t===`/content/${e.schemaType}/${i}`,metadata:{schemaType:e.schemaType,documentId:i}};case`group`:let o=[];for(let t of e.items){let e=a(t,n+1);e&&o.push(e)}return{id:e.id||`group-${e.title.toLowerCase().replace(/\s+/g,`-`)}`,title:e.title,type:`group`,icon:e.icon||`folder`,children:o,metadata:{collapsible:e.collapsible,defaultCollapsed:e.defaultCollapsed}};case`divider`:return{id:`divider-${r}`,title:e.title||``,type:`divider`};default:return null}};for(let t of e.items){let e=a(t);e&&n.push(e)}return{items:n,metadata:{totalItems:r,maxDepth:i}}}validate(e){let t=[];return e.title||t.push(`Structure title is required`),Array.isArray(e.items)?e.items.forEach((e,n)=>{this.validateItem(e,`items[${n}]`,t)}):t.push(`Structure items must be an array`),{isValid:t.length===0,errors:t}}validateItem(e,t,n){if(!e.type){n.push(`${t}: Item type is required`);return}switch(e.type){case`documentList`:case`singleton`:e.title||n.push(`${t}: Title is required`),e.schemaType||n.push(`${t}: Schema type is required`);break;case`group`:e.title||n.push(`${t}: Group title is required`),Array.isArray(e.items)?e.items.forEach((e,r)=>{this.validateItem(e,`${t}.items[${r}]`,n)}):n.push(`${t}: Group items must be an array`);break;case`divider`:break;default:n.push(`${t}: Unknown item type "${e.type}"`)}}createDocumentListItem(e,t){return{type:`documentList`,title:this.formatSchemaTitle(e.name),schemaType:e.name,icon:this.getSchemaIcon(e),defaultOrdering:[{field:`updatedAt`,direction:`desc`}],options:{pageSize:t,searchable:!0,searchFields:this.getSearchableFields(e)}}}groupSchemas(e,t){let n={};for(let r of e){let e=`Content`;t===`type`?e=r.singleton?`Settings`:`Content`:t===`category`&&(e=r.category||`Content`),n[e]||(n[e]=[]),n[e].push(r)}return n}formatSchemaTitle(e){return e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase()).trim()}formatGroupTitle(e){return e.charAt(0).toUpperCase()+e.slice(1)}getSchemaIcon(e){let t=e.name.toLowerCase();return t.includes(`post`)||t.includes(`article`)?`document-text`:t.includes(`page`)?`document`:t.includes(`user`)||t.includes(`author`)?`user`:t.includes(`category`)||t.includes(`tag`)?`tag`:t.includes(`media`)||t.includes(`image`)?`photo`:t.includes(`setting`)||t.includes(`config`)?`cog`:t.includes(`menu`)||t.includes(`navigation`)?`menu`:`document-text`}getGroupIcon(e){let t=e.toLowerCase();return t.includes(`content`)?`document-text`:t.includes(`setting`)?`cog`:t.includes(`user`)||t.includes(`people`)?`users`:t.includes(`media`)?`photo`:`folder`}getSearchableFields(e){let t=[`title`,`name`,`slug`];return e.fields?Object.keys(e.fields).filter(e=>t.some(t=>e.toLowerCase().includes(t))):[`title`]}getFallbackStructure(){return{title:`Content Management`,items:[{type:`documentList`,title:`Posts`,schemaType:`post`,icon:`document-text`,defaultOrdering:[{field:`updatedAt`,direction:`desc`}],options:{pageSize:25,searchable:!0,searchFields:[`title`]}},{type:`documentList`,title:`Authors`,schemaType:`author`,icon:`user`,defaultOrdering:[{field:`name`,direction:`asc`}],options:{pageSize:25,searchable:!0,searchFields:[`name`]}},{type:`singleton`,title:`Settings`,schemaType:`settings`,documentId:`site-settings`,icon:`cog`,options:{autoCreate:!0}}],metadata:{version:`1.0.0`,description:`Fallback structure`}}}},Kr=Fr(`structure-service`),qr=class{client;builder;cachedStructure=null;cachedNavigation=null;constructor(e){this.client=e,this.builder=new Gr(e)}async getStructure(e){if(!this.cachedStructure){try{let e=await this.client.get(`/config/structure`);if(e.success&&e.data)return this.cachedStructure=e.data.structure,Kr.debug(`Structure loaded from API endpoint`,{title:this.cachedStructure?.title,itemCount:this.cachedStructure?.items?.length||0}),this.cachedStructure}catch(e){Kr.warn(`Failed to fetch structure from API endpoint, falling back`,e)}let t=window.TROKKY_CONFIG;t?.structure&&typeof t.structure==`object`?(this.cachedStructure=t.structure,Kr.debug(`Using static structure from window config`)):(this.cachedStructure=await this.builder.generateFromSchemas(e),Kr.debug(`Auto-generated structure from schemas`))}return this.cachedStructure}async getNavigation(e,t){let n=await this.getStructure(t);return(!this.cachedNavigation||e)&&(this.cachedNavigation=this.builder.buildNavigation(n,e)),this.cachedNavigation}setStructure(e){let t=this.builder.validate(e);if(!t.isValid)throw Error(`Invalid structure: ${t.errors.join(`, `)}`);this.cachedStructure=e,this.cachedNavigation=null}clearCache(){this.cachedStructure=null,this.cachedNavigation=null,Kr.debug(`Structure cache cleared`)}async refreshFromEndpoint(){try{let e=await this.client.get(`/config/structure`,{_refresh:Date.now()});return e.success&&e.data?(this.cachedStructure=e.data.structure,this.cachedNavigation=null,Kr.debug(`Structure refreshed from endpoint`,{title:this.cachedStructure.title,itemCount:this.cachedStructure.items?.length||0}),this.cachedStructure):null}catch(e){return Kr.error(`Failed to refresh structure from endpoint`,e),null}}isCached(){return this.cachedStructure!==null}async getStructureItemBySchema(e){let t=await this.getStructure(),n=t=>{for(let r of t)if(r.type===`documentList`||r.type===`singleton`){if(r.schemaType===e)return r}else if(r.type===`group`&&r.items){let e=n(r.items);if(e)return e}return null};return n(t.items)}async getDocumentListItems(){let e=await this.getStructure(),t=e=>{let n=[];for(let r of e)r.type===`documentList`?n.push(r):r.type===`group`&&r.items&&n.push(...t(r.items));return n};return t(e.items)}async getSingletonItems(){let e=await this.getStructure(),t=e=>{let n=[];for(let r of e)r.type===`singleton`?n.push(r):r.type===`group`&&r.items&&n.push(...t(r.items));return n};return t(e.items)}async validateStructure(){let e=await this.getStructure();return this.builder.validate(e)}},Jr=null;function Yr(e){return Jr||=new qr(e),Jr}function Xr(){if(!Jr)throw Error(`Structure service not initialized. Call createStructureService first.`);return Jr}function Zr(){Jr?.clearCache()}var Qr=Fr(`useAuth`),$r=()=>{let e=window.TROKKY_CONFIG?.sessionConfig;return{REFRESH_BUFFER_MS:e?.refreshBufferMs||3e4,WARNING_BUFFER_MS:e?.warningBufferMs||0,CHECK_INTERVAL_MS:e?.checkIntervalMs||3e4,DEFAULT_TIMEOUT_MS:e?.defaultTimeoutMs||72e5,EXTENDED_TIMEOUT_MS:e?.extendedTimeoutMs||6048e5,INACTIVITY_TIMEOUT_MS:e?.inactivityTimeoutMs||18e5}},ei=(0,B.createContext)(void 0),ti=()=>({isAuthenticated:!1,user:null,token:null,refreshToken:null,isLoading:!1,sessionExpiresAt:null,showTimeoutWarning:!1,lastActivity:new Date});function ni({children:e}){let[t,n]=(0,B.useState)({...ti(),isLoading:!0}),r=P(),i=(0,B.useRef)(null),a=(0,B.useRef)(null),o=(0,B.useRef)(t);(0,B.useEffect)(()=>{o.current=t},[t]);let s=(0,B.useCallback)(()=>{i.current&&=(clearInterval(i.current),null),a.current&&=(clearInterval(a.current),null)},[]),c=(0,B.useCallback)(()=>{s(),Ar.clear(),r.clear(),Zr(),n(ti())},[r,s]),l=(0,B.useCallback)(()=>{n(e=>({...e,lastActivity:new Date}))},[]),u=(0,B.useCallback)(async()=>{let e=await Ar.refresh();return e?(n(t=>({...t,token:e.token,refreshToken:Ar.getRefreshToken(),sessionExpiresAt:e.expiresAt?new Date(e.expiresAt):t.sessionExpiresAt,showTimeoutWarning:!1})),Qr.info(`Session refreshed successfully`),!0):(Qr.warn(`Session refresh failed, ending session`),c(),!1)},[c]),d=(0,B.useCallback)(e=>{if(!e)return;s();let t=$r();i.current=setInterval(()=>{let n=e.getTime()-Date.now();n<=t.REFRESH_BUFFER_MS&&n>0&&u(),n<=0&&(Qr.warn(`Session expired, forcing logout`),c())},t.CHECK_INTERVAL_MS),a.current=setInterval(()=>{Date.now()-o.current.lastActivity.getTime()>=t.INACTIVITY_TIMEOUT_MS&&(Qr.warn(`User inactive for too long, forcing logout`),c())},t.CHECK_INTERVAL_MS)},[c,u,s]),f=(0,B.useCallback)(async()=>{try{n(e=>({...e,isLoading:!0}));let{token:e,refreshToken:t}=Ar.getTokens();if(Qr.info(`Checking auth`,{hasStoredToken:!!e,hasRefreshToken:!!t}),!e){Qr.info(`No stored token, showing login page`),n(ti());return}let r=await W.post(`/auth/validate`,{token:e});if(r.success&&r.data&&typeof r.data==`object`&&`valid`in r.data&&r.data.valid&&`session`in r.data&&r.data.session){Qr.info(`Authentication validated successfully`);let i=r.data.session,a=i.expiresAt?new Date(i.expiresAt):null;n({isAuthenticated:!0,user:i?.user||i,token:e,refreshToken:t,isLoading:!1,sessionExpiresAt:a,showTimeoutWarning:!1,lastActivity:new Date}),d(a);return}let i=await Ar.refresh();if(i?.token){let e=i.expiresAt?new Date(i.expiresAt):null;n({isAuthenticated:!0,user:i.user??null,token:i.token,refreshToken:Ar.getRefreshToken(),isLoading:!1,sessionExpiresAt:e,showTimeoutWarning:!1,lastActivity:new Date}),d(e),Qr.info(`Session restored via refresh token`);return}Qr.warn(`Stored tokens are invalid, clearing auth state`),c()}catch(e){Qr.error(`Auth check failed`,e),c()}},[c,d]),p=(0,B.useCallback)(async(e,t,r=!1)=>{try{let i=await W.post(`/auth/login`,{username:e,password:t,rememberMe:r});if(i.success&&i.data&&typeof i.data==`object`&&`user`in i.data&&`token`in i.data&&`expiresAt`in i.data){let{user:t,token:a,refreshToken:o,expiresAt:s}=i.data;Qr.info(`User login successful`,{username:e,rememberMe:r}),Ar.persist(a,o);let c=new Date(s);return n({isAuthenticated:!0,user:t,token:a,refreshToken:o||null,isLoading:!1,sessionExpiresAt:c,showTimeoutWarning:!1,lastActivity:new Date}),d(c),{success:!0}}return Qr.warn(`Login failed`,{username:e,error:i.error?.message}),{success:!1,error:i.error?.message||`Login failed`}}catch(t){return Qr.error(`Login error`,{username:e,error:t}),{success:!1,error:t instanceof Error?t.message:`Login failed`}}},[d]),m=(0,B.useCallback)(async()=>{try{s();let e=Ar.getRefreshToken();e&&await W.post(`/auth/logout`,{refreshToken:e}),Qr.info(`User logout successful`)}catch(e){Qr.error(`Logout failed`,e)}finally{c()}},[c,s]),h=(0,B.useCallback)(()=>{n(e=>({...e,showTimeoutWarning:!1}))},[]),g=(0,B.useCallback)(e=>{n(t=>({...t,user:e}))},[]);(0,B.useEffect)(()=>(W.onUnauthorized=async()=>u(),()=>{W.onUnauthorized=null}),[u]),(0,B.useEffect)(()=>{if(!t.isAuthenticated)return;let e=[`mousedown`,`mousemove`,`keypress`,`scroll`,`touchstart`,`click`],n=()=>l();return e.forEach(e=>{document.addEventListener(e,n,{passive:!0})}),()=>{e.forEach(e=>{document.removeEventListener(e,n)})}},[t.isAuthenticated,l]),(0,B.useEffect)(()=>(f(),()=>{s()}),[]),(0,B.useEffect)(()=>{t.isAuthenticated&&t.sessionExpiresAt&&d(t.sessionExpiresAt)},[t.sessionExpiresAt,t.isAuthenticated,d]);let _={...t,login:p,logout:m,checkAuth:f,refreshSession:u,dismissTimeoutWarning:h,updateActivity:l,updateUser:g};return B.createElement(ei.Provider,{value:_},e)}function ri(){let e=(0,B.useContext)(ei);if(e===void 0)throw Error(`useAuth must be used within an AuthProvider`);return e}var ii=Fr(`useCurrentUser`),ai=[`auth`,`me`];async function oi(){let e=await W.getCurrentUser();if(!e.success||!e.data)throw Error(e.error?.message||`Failed to fetch user data`);return ii.debug(`Current user data loaded`,{username:e.data.username}),e.data}function si(){let e=P(),t=j({queryKey:ai,queryFn:oi}),n=(0,B.useCallback)(t=>{let n=e.getQueryData(ai);if(!n)return;let r={...n,...t};e.setQueryData(ai,r),window.dispatchEvent(new CustomEvent(`trokky:user:updated`,{detail:{user:r}})),ii.debug(`User data updated locally`,{userData:t})},[e]);(0,B.useEffect)(()=>{let t=t=>{let{user:n}=t.detail;ii.debug(`Received user update event`,{user:n}),e.setQueryData(ai,n)};return window.addEventListener(`trokky:user:updated`,t),()=>{window.removeEventListener(`trokky:user:updated`,t)}},[e]);let r=(0,B.useCallback)(async()=>{await t.refetch()},[t]);return{user:t.data??null,loading:t.isPending,error:t.error?t.error.message:null,refetch:r,updateUser:n}}function ci(){let{user:e,loading:t,error:n,refetch:r}=si(),i=e?.permissions||[],a=t=>e?e.role===`admin`||i.includes(t):!1,o=t=>e?e.role===`admin`||t.some(e=>i.includes(e)):!1,s=t=>e?e.role===`admin`||t.every(e=>i.includes(e)):!1,c=(t,n)=>{if(!e)return!1;if(e.role===`admin`)return!0;let r=`${t}:${n}`;if(i.includes(r))return!0;let a=`${t}:*`;return!!(i.includes(a)||![`users`,`settings`,`tokens`,`webhooks`,`media`].includes(t.toLowerCase())&&(i.includes(`content:*`)||i.includes(`content:${n}`))||i.includes(`*`))};return{user:e,loading:t,error:n,refetch:r,hasPermission:a,hasGlobalPermission:e=>a(e),hasAnyPermission:o,hasAllPermissions:s,hasSchemaPermission:c,hasAnySchemaPermission:(t,n)=>e?e.role===`admin`||n.some(e=>c(t,e)):!1,canDeleteDocument:(t,n)=>e?!!(c(t,`delete`)||n?._createdBy&&(n._createdBy===e.id||n._createdBy===e.username)):!1,canPublish:e?e.role===`admin`||i.includes(`content:*`)||i.includes(`content:publish`):!1,userPermissions:i,isAdmin:e?.role===`admin`,isEditor:e?.role===`editor`,isAuthor:e?.role===`author`,isWriter:e?.role===`writer`,isViewer:e?.role===`viewer`,userId:e?.id||null}}var li={READ:`media:read`,UPLOAD:`media:upload`,EDIT:`media:edit`,DELETE:`media:delete`},ui={READ:`users:read`,WRITE:`users:write`,DELETE:`users:delete`,INVITE:`users:invite`},di={READ:`settings:read`,WRITE:`settings:write`},fi={READ:`tokens:read`,WRITE:`tokens:write`,DELETE:`tokens:delete`},pi={READ:`webhooks:read`,WRITE:`webhooks:write`,DELETE:`webhooks:delete`,TEST:`webhooks:test`};Object.values(li),Object.values(ui),Object.values(di),Object.values(fi),Object.values(pi);var mi=[di.READ,ui.READ,fi.READ,pi.READ,di.WRITE];function hi(e){if(typeof e!=`number`||!Number.isFinite(e))return`Unknown size`;if(e===0)return`0 B`;if(e<0)return`Unknown size`;let t=1024,n=[`B`,`KB`,`MB`,`GB`,`TB`],r=Math.min(Math.floor(Math.log(e)/Math.log(t)),n.length-1);return parseFloat((e/t**r).toFixed(1))+` `+n[r]}function gi(e){if(e.metadata?.imageVariants){let t=e.metadata.imageVariants;if(t.thumbnail)return`thumbnail`;if(t.small)return`small`}}var _i=({className:e})=>(0,V.jsx)(`svg`,{className:e,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})});function vi(e){return e.startsWith(`image/`)?`image`:e.startsWith(`video/`)?`video`:e.startsWith(`audio/`)?`audio`:e.includes(`pdf`)||e.includes(`document`)||e.includes(`word`)||e.includes(`excel`)||e.includes(`powerpoint`)||e===`text/plain`?`document`:e.includes(`zip`)||e.includes(`rar`)||e.includes(`7z`)||e.includes(`tar`)||e.includes(`gzip`)?`archive`:`document`}function yi(e){let t=`w-full h-full`;switch(e){case`image`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z`})});case`video`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z`})});case`audio`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3`})});case`document`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z`})});case`archive`:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 8h14M5 8a2 2 0 110-4h14a2 2 0 110 4M5 8v10a2 2 0 002 2h10a2 2 0 002-2V8m-9 4h4`})});default:return(0,V.jsx)(`svg`,{className:t,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z`})})}}function bi(e,t,n,r){if(n)return n.getMediaUrl(e.id,t);if(r?.getMediaUrl)return r.getMediaUrl(e.id,t);if(e.url)return e.url;throw Error(`Cannot generate URL for media ${e.id}${t?` variant ${t}`:``}`)}function xi({onSelect:e,mediaTypeFilter:t,apiClient:n,logger:r,mediaUrlGenerator:i}){let{t:a}=H(`studio`),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(`original`),[g,_]=(0,B.useState)(`grid`),[v,y]=(0,B.useState)(1);(0,B.useEffect)(()=>{b()},[]);let b=async()=>{l(!0);try{if(r?.debug(`MediaBrowser: apiClient received`,{apiClient:!!n,type:typeof n,hasGetMedia:!!n?.getMedia}),n&&typeof n.getMedia==`function`){r?.debug(`MediaBrowser: Loading media from API...`);let e=await n.getMedia({limit:1e4});r?.debug(`MediaBrowser: API response received`,e),e?.success&&Array.isArray(e.data)?(r?.info(`MediaBrowser: Loaded media files from API`,{count:e.data.length,total:e.meta?.total}),s(e.data)):(r?.warn(`MediaBrowser: Invalid API response format`,e),s([]))}else{r?.warn(`MediaBrowser: No API client provided, using mock data`);let e=[{id:`asset-1`,filename:`hero-image.jpg`,contentType:`image/jpeg`,size:2048e3,url:`https://picsum.photos/800/600?random=1`,uploadedAt:new Date().toISOString(),metadata:{width:1920,height:1080,title:`Hero Banner Image`,author:`John Photographer`,originalDimensions:{width:1920,height:1080},imageVariants:{thumbnail:{url:`https://picsum.photos/150/150?random=1`,width:150,height:150,format:`jpeg`,size:12e3},small:{url:`https://picsum.photos/400/300?random=1`,width:400,height:300,format:`jpeg`,size:45e3},medium:{url:`https://picsum.photos/800/600?random=1`,width:800,height:600,format:`jpeg`,size:12e4},large:{url:`https://picsum.photos/1200/900?random=1`,width:1200,height:900,format:`jpeg`,size:28e4}}}},{id:`asset-2`,filename:`product-demo.mp4`,contentType:`video/mp4`,size:15728640,url:`https://sample-videos.com/zip/10/mp4/SampleVideo_1280x720_1mb.mp4`,uploadedAt:new Date().toISOString(),metadata:{width:1280,height:720,duration:30,title:`Product Demo Video`}},{id:`asset-3`,filename:`background-music.mp3`,contentType:`audio/mp3`,size:5242880,url:`#`,uploadedAt:new Date().toISOString(),metadata:{duration:180,title:`Background Music Track`}},{id:`asset-4`,filename:`user-manual.pdf`,contentType:`application/pdf`,size:1048576,url:`#`,uploadedAt:new Date().toISOString(),metadata:{title:`User Manual Document`}}];s(e)}}catch(e){r?.error(`Failed to load media files`,e),s([])}finally{l(!1)}},x=o.filter(e=>{if(t&&vi(e.contentType)!==t)return!1;if(!u)return!0;let n=u.toLowerCase();return e.filename.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||e.metadata?.title&&e.metadata.title.toLowerCase().includes(n)||e.metadata?.author&&e.metadata.author.toLowerCase().includes(n)||e.metadata?.credit&&e.metadata.credit.toLowerCase().includes(n)});(0,B.useEffect)(()=>{y(1)},[u,t]);let S=Math.ceil(x.length/20),C=(v-1)*20,w=C+20,T=x.slice(C,w),E=()=>{f&&(e({_type:`media`,asset:{_ref:f.id,_type:`mediaAsset`},alt:``,caption:``,title:``,variant:m}),p(null),h(`original`))};return(0,V.jsxs)(`div`,{className:`flex flex-col h-full min-h-0 overflow-hidden`,children:[g===`grid`&&(0,V.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-gray-600`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(_i,{className:`absolute left-2.5 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,placeholder:a(`mediaBrowser.searchPlaceholder`),value:u,onChange:e=>d(e.target.value),className:`w-full pl-8 pr-3 py-1.5 text-sm border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-400 rounded-md focus:outline-none focus:ring-1 focus:ring-blue-500 focus:border-transparent`})]})}),g===`single`&&f?(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,V.jsx)(`div`,{className:`px-4 py-3 border-b border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-800`,children:(0,V.jsxs)(`button`,{onClick:()=>{_(`grid`),p(null),h(`original`)},className:`flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors`,children:[(0,V.jsx)(`svg`,{className:`w-4 h-4 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M15 19l-7-7 7-7`})}),a(`mediaBrowser.backToGrid`)]})}),(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col md:flex-row overflow-y-auto`,children:[(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0`,children:[(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center bg-gray-50 dark:bg-gray-900 p-4 min-h-[200px]`,children:(()=>{let e=vi(f.contentType);if(e===`image`){let e=m===`original`?bi(f,void 0,i,n):bi(f,m,i,n);return(0,V.jsx)(`div`,{className:`w-full h-full max-w-[800px] max-h-[400px] flex items-center justify-center`,children:e?(0,V.jsx)(`img`,{src:e,alt:f.metadata?.title||f.filename,className:`max-w-full max-h-full object-contain`,loading:`eager`,onLoad:()=>{},onError:e=>{f.url&&e.currentTarget.src!==f.url?e.currentTarget.src=f.url:e.currentTarget.onerror=null}},`${f.id}-${m}-${e}`):(0,V.jsx)(`div`,{className:`text-gray-500`,children:a(`mediaBrowser.noPreviewUrl`)})})}return e===`video`?(0,V.jsx)(`video`,{src:bi(f,void 0,i,n),controls:!0,className:`max-w-full max-h-full`}):e===`audio`?(0,V.jsx)(`audio`,{src:bi(f,void 0,i,n),controls:!0,className:`w-full max-w-md`}):(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-24 h-24 mx-auto mb-4 opacity-50`,children:yi(e)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-4`,children:a(`mediaBrowser.noPreviewAvailable`)})]})})()}),vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:a(`mediaBrowser.imageVariants`)}),n?.regenerateVariants&&(0,V.jsx)(`button`,{onClick:async()=>{try{r?.info(`Regenerating variants for`,{mediaId:f.id}),await n.regenerateVariants?.(f.id),b()}catch(e){r?.error(`Failed to regenerate variants`,e)}},className:`text-xs px-2 py-1 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 border border-blue-600 dark:border-blue-400 rounded hover:bg-blue-50 dark:hover:bg-blue-900/20 transition-colors`,children:a(`mediaBrowser.regenerate`)})]}),(0,V.jsxs)(`div`,{className:`flex space-x-2 overflow-x-auto pb-1`,children:[(0,V.jsxs)(`div`,{className:`flex-shrink-0 group relative`,children:[(0,V.jsx)(`div`,{className:`cursor-pointer rounded border-2 transition-all ${m===`original`?`border-blue-500 ring-2 ring-blue-200 dark:ring-blue-800`:`border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600`}`,onClick:()=>h(`original`),children:(0,V.jsx)(`img`,{src:bi(f,void 0,i,n),alt:`Original`,className:`w-16 h-16 object-cover rounded`,loading:`lazy`})}),(0,V.jsxs)(`div`,{className:`mt-1 text-center`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 truncate`,children:a(`mediaBrowser.original`)}),(0,V.jsxs)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-500`,children:[f.metadata?.width,` ×`,` `,f.metadata?.height]})]})]}),Object.entries(f.metadata.imageVariants).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex-shrink-0 group relative`,children:[(0,V.jsx)(`div`,{className:`cursor-pointer rounded border-2 transition-all ${m===e?`border-blue-500 ring-2 ring-blue-200 dark:ring-blue-800`:`border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600`}`,onClick:()=>h(e),children:(0,V.jsx)(`img`,{src:bi(f,e,i,n),alt:`${e} variant`,className:`w-16 h-16 object-cover rounded`,loading:`lazy`})}),(0,V.jsxs)(`div`,{className:`mt-1 text-center`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 capitalize truncate`,children:e}),(0,V.jsxs)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-500`,children:[t.width,` × `,t.height]})]})]},e))]})]}),vi(f.contentType)===`image`&&(!f.metadata?.imageVariants||Object.keys(f.metadata.imageVariants).length===0)&&(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-2`,children:a(`mediaBrowser.imageVariants`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mb-3`,children:a(`mediaBrowser.noVariantsAvailable`)})]})})]}),(0,V.jsxs)(`div`,{className:`w-full md:w-64 bg-white dark:bg-gray-800 border-t md:border-t-0 md:border-l border-gray-200 dark:border-gray-700 flex flex-col flex-shrink-0`,children:[(0,V.jsxs)(`div`,{className:`p-3 md:p-4 flex-1`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-white mb-2`,children:a(`mediaBrowser.fileDetails`)}),(0,V.jsxs)(`dl`,{className:`space-y-1.5 text-xs`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.filename`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white truncate ml-2 max-w-[150px]`,title:f.filename,children:f.filename})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.size`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white`,children:hi(f.size)})]}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.type`)}),(0,V.jsx)(`dd`,{className:`text-gray-900 dark:text-white truncate ml-2 max-w-[100px]`,title:f.contentType,children:f.contentType.split(`/`)[1]||f.contentType})]}),f.metadata?.width&&f.metadata?.height&&(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`dt`,{className:`font-medium text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.dimensions`)}),(0,V.jsxs)(`dd`,{className:`text-gray-900 dark:text-white`,children:[f.metadata.width,` × `,f.metadata.height]})]})]})]}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-3`,children:(0,V.jsx)(`button`,{onClick:E,className:`w-full px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors`,children:m===`original`?a(`mediaBrowser.selectOriginal`):a(`mediaBrowser.selectVariant`,{variant:m})})})]})]})]}):(0,V.jsxs)(V.Fragment,{children:[f&&g===`grid`&&vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsx)(`div`,{className:`px-4 py-3 bg-blue-50 dark:bg-blue-900/20 border-b border-gray-200 dark:border-gray-600`,children:(0,V.jsxs)(`div`,{className:`flex items-start space-x-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 rounded overflow-hidden bg-gray-100 dark:bg-gray-700 flex items-center justify-center flex-shrink-0`,children:(()=>{let e=vi(f.contentType);return e===`image`?(0,V.jsx)(`img`,{src:bi(f,gi(f),i,n),alt:f.filename,className:`w-full h-full object-cover`}):(0,V.jsx)(`div`,{className:`w-6 h-6 text-gray-500 dark:text-gray-400`,children:yi(e)})})()}),(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-white truncate`,title:f.filename,children:f.filename}),(0,V.jsxs)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[f.metadata?.width&&f.metadata?.height?`${f.metadata.width} × ${f.metadata.height} • `:``,hi(f.size)]})]}),vi(f.contentType)===`image`&&f.metadata?.imageVariants&&Object.keys(f.metadata.imageVariants).length>0&&(0,V.jsxs)(`div`,{className:`flex-shrink-0`,children:[(0,V.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 dark:text-white mb-1`,children:a(`mediaBrowser.variant`)}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,V.jsxs)(`label`,{className:`cursor-pointer flex flex-col items-center px-2 py-1 rounded border text-xs transition-colors ${m===`original`?`border-blue-500 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`variant`,value:`original`,checked:m===`original`,onChange:e=>{console.log(`📝 Variant selection changed:`,{from:m,to:e.target.value}),h(e.target.value)},className:`sr-only`}),(0,V.jsx)(`div`,{className:`font-medium`,children:a(`mediaBrowser.original`)}),f.metadata?.originalDimensions&&(0,V.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:[f.metadata.originalDimensions.width,`×`,f.metadata.originalDimensions.height]})]}),Object.entries(f.metadata.imageVariants).map(([e,t])=>(0,V.jsxs)(`label`,{className:`cursor-pointer flex flex-col items-center px-2 py-1 rounded border text-xs transition-colors ${m===e?`border-blue-500 bg-blue-100 dark:bg-blue-900/50 text-blue-700 dark:text-blue-300`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,children:[(0,V.jsx)(`input`,{type:`radio`,name:`variant`,value:e,checked:m===e,onChange:e=>{console.log(`📝 Variant selection changed:`,{from:m,to:e.target.value}),h(e.target.value)},className:`sr-only`}),(0,V.jsx)(`div`,{className:`font-medium capitalize`,children:e}),(0,V.jsxs)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:[t.width,`×`,t.height]})]},e))]})]}),(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:(0,V.jsx)(`button`,{onClick:E,className:`px-3 py-1 bg-blue-600 text-white text-xs rounded hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors`,children:a(`mediaBrowser.select`)})})]})})]})}),(0,V.jsx)(`div`,{className:`flex-1 overflow-y-auto p-3 min-h-0`,children:c?(0,V.jsx)(`div`,{className:`flex items-center justify-center h-48`,children:(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600`})}):x.length>0?(0,V.jsx)(`div`,{className:`grid grid-cols-3 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 gap-2`,children:T.map(t=>(0,V.jsxs)(`div`,{className:`relative cursor-pointer rounded-lg border transition-all duration-150 group overflow-hidden ${f?.id===t.id?`border-blue-500 ring-1 ring-blue-200 dark:ring-blue-900/50 shadow-md`:`border-gray-200 dark:border-gray-700 hover:border-blue-300 dark:hover:border-blue-600 hover:shadow-sm`} bg-white dark:bg-gray-800`,onClick:()=>{vi(t.contentType)===`image`?(p(t),h(`original`),_(`single`)):e({_type:`media`,asset:{_ref:t.id,_type:`mediaAsset`},alt:``,caption:``,title:``,variant:`original`})},children:[(0,V.jsxs)(`div`,{className:`h-20 relative overflow-hidden bg-gray-50 dark:bg-gray-900`,children:[(()=>{let e=t.metadata?.imageVariants?Object.keys(t.metadata.imageVariants).length:0;return e>0?(0,V.jsx)(`div`,{className:`absolute top-1 right-1 bg-blue-600 text-white text-[10px] px-1 py-0.5 rounded-full z-10 font-medium`,children:e}):null})(),(()=>{let e=vi(t.contentType);return e===`image`?(0,V.jsx)(`img`,{src:bi(t,gi(t),i,n),alt:t.metadata?.title||t.filename,className:`w-full h-full object-cover transition-transform duration-200 group-hover:scale-105`}):(0,V.jsx)(`div`,{className:`w-full h-full flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`w-6 h-6 text-gray-400 dark:text-gray-500`,children:yi(e)})})})()]}),(0,V.jsxs)(`div`,{className:`px-1.5 py-1`,children:[(0,V.jsx)(`p`,{className:`text-[10px] font-medium text-gray-900 dark:text-white truncate leading-tight`,title:t.filename,children:t.filename}),(0,V.jsx)(`p`,{className:`text-[10px] text-gray-500 dark:text-gray-400 leading-tight`,children:hi(t.size)})]})]},t.id))}):(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 text-gray-500 dark:text-gray-400`,children:[(0,V.jsx)(`div`,{className:`w-12 h-12 mb-3 opacity-50`,children:(0,V.jsx)(`svg`,{fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:1,d:`M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z`})})}),(0,V.jsx)(`p`,{className:`text-sm text-center`,children:t?a(u?`mediaBrowser.noTypeFoundMatching`:`mediaBrowser.noTypeFound`,{type:t}):a(u?`mediaBrowser.noMediaFoundMatching`:`mediaBrowser.noMediaFound`)}),u&&(0,V.jsx)(`button`,{onClick:()=>d(``),className:`mt-2 text-xs text-blue-600 dark:text-blue-400 hover:text-blue-700 dark:hover:text-blue-300`,children:a(`mediaBrowser.clearSearch`)})]})}),x.length>20&&g===`grid`&&(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-t border-gray-200 dark:border-gray-700 bg-gray-50 dark:bg-gray-800/50`,children:[(0,V.jsx)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-400`,children:a(`mediaBrowser.paginationOf`,{start:C+1,end:Math.min(w,x.length),total:x.length})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,V.jsx)(`button`,{onClick:()=>y(e=>Math.max(1,e-1)),disabled:v===1,className:`px-2 py-0.5 text-[10px] font-medium rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:a(`mediaBrowser.prev`)}),(0,V.jsxs)(`span`,{className:`text-[10px] text-gray-600 dark:text-gray-300 px-1`,children:[v,`/`,S]}),(0,V.jsx)(`button`,{onClick:()=>y(e=>Math.min(S,e+1)),disabled:v===S,className:`px-2 py-0.5 text-[10px] font-medium rounded border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-600 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:a(`mediaBrowser.next`)})]})]})]})]})}var Si=`studio-overlays`;function Ci(){let e=[],t=new Map,n=new Set,r=0,i=t=>e.indexOf(t),a=()=>{r+=1,n.forEach(e=>e())};return{push(t){let n=e.indexOf(t);n!==-1&&e.splice(n,1),e.push(t),a()},remove(n){let r=e.indexOf(n);r!==-1&&e.splice(r,1),t.delete(n),r!==-1&&a()},setEscapeHandler(e,n){n?t.set(e,n):t.delete(e)},handleEscape(){if(e.length===0)return!1;let n=t.get(e[e.length-1]);return n&&n(),!0},depthOf:i,isTopmost(t){return e.length>0&&e[e.length-1]===t},zIndexOf(e){let t=i(e);return Math.min(50+(t<0?0:t),199)},size(){return e.length},ids(){return[...e]},version(){return r},subscribe(e){return n.add(e),()=>{n.delete(e)}}}}var wi=Ci();function Ti(){return wi.size()>0}var Ei=new WeakSet;function Di(e){return e&&Ei.has(e)?!0:Ti()}function Oi(e,t,n){return!(!e||!e.isConnected||t>=0&&n>t)}function ki(e){let t=0,n=``;return{lock(){let r=e();t===0&&r&&(n=r.style.overflow,r.style.overflow=`hidden`),t+=1;let i=!1;return()=>{if(!i&&(i=!0,--t,t===0)){let t=e();t&&(t.style.overflow=n)}}},count(){return t}}}var Ai=ki(()=>typeof document>`u`?null:document.body),ji=0;function Mi(e){e.key===`Escape`&&wi.handleEscape()&&(Ei.add(e),e.stopPropagation())}function Ni(){ji===0&&typeof document<`u`&&document.addEventListener(`keydown`,Mi),ji+=1;let e=!1;return()=>{e||(e=!0,--ji,ji===0&&typeof document<`u`&&document.removeEventListener(`keydown`,Mi))}}var Pi=`data-dialog-inert`,Fi=new Map,Ii=null;function Li(e){return e.id===`studio-overlays`||e.hasAttribute(`data-dialog-exempt`)}function Ri(e){Li(e)||Fi.has(e)||(Fi.set(e,{hadInert:e.hasAttribute(`inert`),previousAriaHidden:e.getAttribute(`aria-hidden`)}),e.setAttribute(Pi,``),e.setAttribute(`inert`,``),e.setAttribute(`aria-hidden`,`true`))}function zi(e,t){e.removeAttribute(Pi),t.hadInert||e.removeAttribute(`inert`),t.previousAriaHidden===null?e.removeAttribute(`aria-hidden`):e.setAttribute(`aria-hidden`,t.previousAriaHidden)}function Bi(e,t){let n=t??(typeof document>`u`?null:document.body);if(n){if(e){Array.from(n.children).forEach(Ri),!Ii&&typeof MutationObserver<`u`&&(Ii=new MutationObserver(e=>{for(let t of e)t.addedNodes.forEach(e=>{e instanceof Element&&Ri(e)})}),Ii.observe(n,{childList:!0}));return}Ii?.disconnect(),Ii=null,Fi.forEach((e,t)=>zi(t,e)),Fi.clear()}}var Vi=0;function Hi(){Vi===0&&Bi(!0),Vi+=1;let e=!1;return()=>{e||(e=!0,--Vi,Vi===0&&Bi(!1))}}var Ui={md:768,lg:1024};function Wi(e){return`(min-width: ${e}px)`}var Gi=e=>typeof window>`u`||typeof window.matchMedia!=`function`?null:window.matchMedia(e);function Ki(e,t,n=Gi){let r=n(e);if(!r)return()=>{};r.matches&&t();let i=e=>{e.matches&&t()};return r.addEventListener(`change`,i),()=>r.removeEventListener(`change`,i)}function qi(){if(typeof document>`u`)return null;let e=document.getElementById(Si);return e||(e=document.createElement(`div`),e.id=Si,document.body.appendChild(e)),e}var Ji=[`a[href]`,`button:not([disabled])`,`input:not([disabled]):not([type="hidden"])`,`select:not([disabled])`,`textarea:not([disabled])`,`[tabindex]:not([tabindex="-1"])`].join(`,`);function Yi(e){return Array.from(e.querySelectorAll(Ji)).filter(e=>e.offsetParent!==null||e===document.activeElement)}var Xi=(0,B.createContext)(null);function Zi(){let e=(0,B.useContext)(Xi);if(!e)throw Error(`Dialog.Header, Dialog.Body and Dialog.Footer must be used inside a Dialog`);return e}var Qi={center:`items-end sm:items-center justify-center p-0 sm:p-4`,sheet:`items-end justify-center p-0`,"drawer-right":`items-stretch justify-end`,"drawer-left":`items-stretch justify-start`,fullscreen:`items-stretch justify-center`},$i={center:`rounded-t-lg sm:rounded-lg max-h-[100dvh] sm:max-h-[calc(100dvh-2rem)]`,sheet:`rounded-t-lg max-h-[90dvh]`,"drawer-right":`h-[100dvh] max-h-[100dvh] shadow-2xl`,"drawer-left":`h-[100dvh] max-h-[100dvh] shadow-2xl`,fullscreen:`h-[100dvh] max-h-[100dvh]`},ea={tall:{center:`h-[100dvh] sm:h-[85dvh]`,sheet:`h-[85dvh]`,"drawer-right":``,"drawer-left":``,fullscreen:``},fill:{center:`h-[100dvh] sm:h-[calc(100dvh-2rem)]`,sheet:`h-[90dvh]`,"drawer-right":``,"drawer-left":``,fullscreen:``}},ta={center:`animate-in fade-in slide-in-from-bottom`,sheet:`animate-in slide-in-from-bottom`,"drawer-right":`animate-in slide-in-from-right-full`,"drawer-left":`animate-in slide-in-from-left-full`,fullscreen:`animate-in fade-in`},na={xs:`sm:max-w-xs`,sm:`sm:max-w-md`,md:`sm:max-w-lg`,lg:`sm:max-w-2xl`,xl:`sm:max-w-4xl`,full:`sm:max-w-7xl`},ra={xs:`max-w-[min(16rem,85vw)]`,sm:`max-w-[min(20rem,85vw)]`,md:`max-w-[min(32rem,85vw)]`,lg:`max-w-[min(42rem,90vw)]`,xl:`max-w-[min(56rem,90vw)]`,full:`max-w-[min(80rem,95vw)]`};function ia({open:e,onClose:t,variant:n=`center`,size:r=`md`,height:i=`auto`,title:a,description:o,dismissible:s=!0,closeOnBackdrop:c=!0,closeOnEscape:l=!0,initialFocus:u,ariaLabel:d,surface:f=`bg-white dark:bg-gray-800`,className:p,wrapperClassName:m,children:h}){let g=(0,B.useId)(),_=(0,B.useRef)(g),[v,y]=(0,B.useState)(null),[b,x]=(0,B.useState)(null),S=(0,B.useRef)(null),C=(0,B.useRef)(t);C.current=t;let w=(0,B.useSyncExternalStore)(wi.subscribe,()=>wi.zIndexOf(_.current),()=>50);if((0,B.useEffect)(()=>{x(qi())},[]),(0,B.useEffect)(()=>{if(!e)return;let t=_.current;S.current=document.activeElement,wi.push(t);let n=Ni(),r=Hi();return()=>{n(),r();let e=wi.depthOf(t);wi.remove(t);let i=S.current;S.current=null,Oi(i,e,wi.size())&&i?.focus?.()}},[e]),(0,B.useEffect)(()=>{e&&wi.setEscapeHandler(_.current,l?()=>C.current():null)},[e,l]),(0,B.useEffect)(()=>{if(e)return Ai.lock()},[e]),(0,B.useEffect)(()=>{e&&v&&(u?.current||Yi(v)[0]||v)?.focus?.()},[e,v,u]),(0,B.useEffect)(()=>{if(!e||!v)return;let t=e=>{if(e.key!==`Tab`||!wi.isTopmost(_.current))return;let t=Yi(v),n=document.activeElement;if(t.length===0){e.preventDefault(),v.focus();return}let r=t[0],i=t[t.length-1],a=!v.contains(n);e.shiftKey&&(a||n===r)?(e.preventDefault(),i.focus()):!e.shiftKey&&(a||n===i)&&(e.preventDefault(),r.focus())};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e,v]),!e||!b)return null;let T=`${g}-title`,E=`${g}-description`,D={onClose:t,dismissible:s,titleId:T,descriptionId:E};return(0,Ht.createPortal)((0,V.jsx)(Xi.Provider,{value:D,children:(0,V.jsxs)(`div`,{className:wr(`fixed inset-0 flex`,Qi[n],m),style:{zIndex:w},"data-dialog-wrapper":``,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 bg-black/50 animate-in fade-in`,onClick:c?t:void 0,"aria-hidden":`true`}),(0,V.jsxs)(`div`,{ref:y,role:`dialog`,"aria-modal":`true`,"aria-label":a?void 0:d,"aria-labelledby":a?T:void 0,"aria-describedby":o?E:void 0,tabIndex:-1,"data-dialog-panel":``,className:wr(`relative flex flex-col w-full min-h-0 shadow-xl focus:outline-none`,f,$i[n],i!==`auto`&&ea[i][n],n!==`fullscreen`&&(n===`drawer-left`||n===`drawer-right`?ra[r]:na[r]),ta[n],p),children:[a!=null&&(0,V.jsxs)(aa,{children:[(0,V.jsx)(`h2`,{id:T,className:`text-lg font-semibold text-gray-900 dark:text-white`,children:a}),o&&(0,V.jsx)(`p`,{id:E,className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:o})]}),h]})]})}),b)}function aa({children:e,className:t,padded:n=!0,showClose:r=!0}){let{onClose:i,dismissible:a}=Zi(),{t:o}=H(`studio`);return(0,V.jsxs)(`div`,{className:wr(`shrink-0 flex items-start justify-between gap-3 border-b border-gray-200 dark:border-gray-700`,n&&`px-6 py-4`,t),children:[(0,V.jsx)(`div`,{className:`min-w-0 flex-1`,children:e}),r&&a&&(0,V.jsx)(`button`,{type:`button`,onClick:i,"aria-label":o(`common.close`),className:`shrink-0 p-1 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 dark:hover:text-gray-300 dark:hover:bg-gray-700 transition-colors`,children:(0,V.jsx)(tt,{className:`h-5 w-5`})})]})}function oa({children:e,className:t,scroll:n=!0,padded:r=!0}){return(0,V.jsx)(`div`,{className:wr(`flex-1 min-h-0`,n?`overflow-y-auto overscroll-contain`:`overflow-hidden`,r&&`px-6 py-4`,t),children:e})}var sa={start:`justify-start`,center:`justify-center`,end:`justify-end`,between:`justify-between`};function ca({children:e,className:t,padded:n=!0,justify:r=`end`}){return(0,V.jsx)(`div`,{className:wr(`shrink-0 flex items-center gap-3 border-t border-gray-200 dark:border-gray-700`,sa[r],n&&`px-6 py-4`,t),children:e})}ia.Header=aa,ia.Body=oa,ia.Footer=ca;function la({isOpen:e,onClose:t,onSelect:n,mediaTypeFilter:r,showVariantSelector:i=!1,context:a,apiClient:o,logger:s,mediaUrlGenerator:c}){let{t:l}=H(`studio`);return(0,V.jsxs)(ia,{open:e,onClose:t,variant:`center`,size:`xl`,height:`tall`,className:`overflow-hidden`,ariaLabel:l(`mediaBrowser.title`),children:[(0,V.jsxs)(ia.Header,{padded:!1,className:`px-4 py-3`,children:[(0,V.jsx)(`h2`,{className:`text-base font-semibold text-gray-900 dark:text-white`,children:l(`mediaBrowser.title`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:(()=>{if(!r)return l(`mediaBrowser.selectFile`);switch(r){case`image`:return l(`mediaBrowser.selectImage`);case`video`:return l(`mediaBrowser.selectVideo`);case`audio`:return l(`mediaBrowser.selectAudio`);case`document`:return l(`mediaBrowser.selectDocument`);default:return l(`mediaBrowser.selectFile`)}})()})]}),(0,V.jsx)(ia.Body,{scroll:!1,padded:!1,children:(0,V.jsx)(xi,{onSelect:e=>{n(e),t()},mediaTypeFilter:r,showVariantSelector:i,context:a,apiClient:o,logger:s,mediaUrlGenerator:c})})]})}var ua=(0,B.createContext)(null),da=new class{listeners=new Map;fieldValues=new Map;fieldWatchers=new Map;emit(e,t){let n=this.listeners.get(e);n&&n.forEach(e=>e(t))}on(e,t){return this.listeners.has(e)||this.listeners.set(e,[]),this.listeners.get(e).push(t),()=>{let n=this.listeners.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}}}getFieldValue(e){return this.fieldValues.get(e)}setFieldValue(e,t){this.fieldValues.set(e,t);let n=this.fieldWatchers.get(e);n&&n.forEach(e=>e(t))}watchField(e,t){this.fieldWatchers.has(e)||this.fieldWatchers.set(e,[]),this.fieldWatchers.get(e).push(t);let n=this.fieldValues.get(e);return n!==void 0&&t(n),()=>{let n=this.fieldWatchers.get(e);if(n){let e=n.indexOf(t);e>-1&&n.splice(e,1)}}}};function fa({children:e,branding:t}){let n=(0,B.useMemo)(()=>Fr(`Fields`),[]),[r,i]=(0,B.useState)(null),a=(0,B.useMemo)(()=>({getMediaUrl:(e,t)=>{if(r){let{options:n}=r,i=n.mediaConfig?.serving?.mode||`api`,a=n.mediaConfig?.serving?.staticBasePath||`/media`,o=W.getBackendUrl?.()||``;return i===`static`?`${o.replace(/\/[^\/]+$/,``)}${t?`${a}/${e}/${t}`:`${a}/${e}`}`:`${o}${t?`/media/${e}/variants/${t}`:`/media/${e}/file`}`}return W.getMediaUrl?W.getMediaUrl(e,t):`${W.getBackendUrl?.()||``}${t?`/media/${e}/variants/${t}`:`/media/${e}/file`}`}}),[r]);(0,B.useEffect)(()=>{(async()=>{try{let e=await W.get(`/config/studio`);if(e.success&&e.data?.studioConfig?.mediaUrlGenerator){let t=e.data.studioConfig.mediaUrlGenerator;i(t)}}catch{}})()},[]);let[o,s]=(0,B.useState)({isOpen:!1,config:null});(0,B.useEffect)(()=>{typeof window<`u`&&window.__TROKKY_DEV__},[]);let c=(0,B.useCallback)((e,t=`info`)=>{window.dispatchEvent(new CustomEvent(`studio:toast`,{detail:{message:e,type:t}}))},[]),l=(0,B.useCallback)(async(e,t)=>new Promise(n=>{window.dispatchEvent(new CustomEvent(`studio:confirm`,{detail:{message:e,title:t?.title,confirmText:t?.confirmText,cancelText:t?.cancelText,variant:t?.variant,resolve:n}}))}),[]),u=(0,B.useCallback)(e=>{s({isOpen:!0,config:e})},[]),d=(0,B.useCallback)(()=>{s({isOpen:!1,config:null})},[]),f=(0,B.useMemo)(()=>({apiClient:W,auth:{getCurrentUser:()=>{let e=localStorage.getItem(`currentUser`);return e?JSON.parse(e):null},hasPermission:e=>{let t=localStorage.getItem(`currentUser`);if(!t)return!1;let n=JSON.parse(t);return n.role===`admin`||n.permissions?.includes(e)||!1},getAccessToken:()=>Ar.getToken()},fieldEvents:{emit:da.emit.bind(da),on:da.on.bind(da),getFieldValue:da.getFieldValue.bind(da),watchField:da.watchField.bind(da)},utils:{showToast:c,showConfirm:l,showMediaBrowser:u},logger:{debug:n.debug.bind(n),info:n.info.bind(n),warn:n.warn.bind(n),error:n.error.bind(n)},mediaUrlGenerator:a,branding:t||void 0}),[c,l,u,n,a,t]);return(0,V.jsxs)(ua.Provider,{value:f,children:[e,o.isOpen&&o.config&&(0,V.jsx)(la,{isOpen:o.isOpen,onClose:d,onSelect:e=>{o.config?.onSelect(e),d()},mediaTypeFilter:o.config.mediaTypeFilter,showVariantSelector:o.config.showVariantSelector,context:o.config.context,apiClient:W,logger:n,mediaUrlGenerator:a})]})}function pa(){return(0,B.useContext)(ua)}var ma=[`structure`];function ha(){return Yr(W)}function ga(e){let t=P(),n=j({queryKey:[...ma,`root`,e??null],queryFn:()=>ha().getStructure(e)}),r=(0,B.useCallback)(()=>{ha().clearCache(),t.invalidateQueries({queryKey:ma})},[t]),i=(0,B.useCallback)(e=>{ha().setStructure(e),t.invalidateQueries({queryKey:ma})},[t]),a=n.data??null,o=n.error?n.error.message:null;return{structure:a,loading:n.isPending,error:o,refreshStructure:r,setCustomStructure:i,isReady:!n.isPending&&!o&&a!==null}}function _a(e){let t=d(),n=P(),r=j({queryKey:[...ma,`navigation`,t.pathname,e??null],queryFn:()=>ha().getNavigation(t.pathname,e)}),i=(0,B.useCallback)(()=>{ha().clearCache(),n.invalidateQueries({queryKey:ma})},[n]),a=r.data??null,o=r.error?r.error.message:null;return{navigation:a,loading:r.isPending,error:o,refreshNavigation:i,currentPath:t.pathname,isReady:!r.isPending&&!o&&a!==null}}function va(e){let t=j({queryKey:[...ma,`item`,e],queryFn:()=>ha().getStructureItemBySchema(e),enabled:!!e}),n=t.error?t.error.message:null,r=!!e&&t.isPending;return{item:t.data??null,loading:r,error:n,isReady:!r&&!n}}function ya(){let e=j({queryKey:[...ma,`documentTypes`],queryFn:async()=>{let e=ha(),[t,n]=await Promise.all([e.getDocumentListItems(),e.getSingletonItems()]);return{documentTypes:t,singletonTypes:n}}}),t=e.data?.documentTypes??[],n=e.data?.singletonTypes??[],r=e.error?e.error.message:null;return{documentTypes:t,singletonTypes:n,allTypes:[...t,...n],loading:e.isPending,error:r,isReady:!e.isPending&&!r}}function ba(e){return e?e.type===`singleton`||e.schemaIsSingleton===!0:!1}function xa(){let[e,t]=(0,B.useState)(!1);return{isOpen:e,openSearch:(0,B.useCallback)(()=>{t(!0)},[]),closeSearch:(0,B.useCallback)(()=>{t(!1)},[])}}function Sa(e){return e?e.replace(/<[^>]*>/g,``).replace(/!\[.*?\]\(.*?\)/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/javascript:/gi,``).replace(/[*_`#]/g,``).replace(/\s+/g,` `).trim():``}function Ca(e,t){if(!t||t.length<2)return Sa(e);let n=Sa(e),r=RegExp(`(${t.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)})`,`gi`);return n.replace(r,`<mark class="bg-yellow-200 dark:bg-yellow-800">$1</mark>`)}function wa({isOpen:e,onClose:t}){let{t:n}=H(`studio`),[i,a]=(0,B.useState)(``),[o,s]=(0,B.useState)([]),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)([]),f=(0,B.useRef)(null),p=(0,B.useRef)(null),m=r(),h=W;(0,B.useEffect)(()=>{if(e){try{let e=localStorage.getItem(`trokky_recent_searches`);d(e?JSON.parse(e):[])}catch{d([])}setTimeout(()=>f.current?.focus(),100)}else p.current&&=(clearTimeout(p.current),null)},[e]);let g=async e=>{if(e.length<2){s([]);return}l(!0);try{let t=await h.get(`/search`,{q:e,limit:10});if(t.success&&t.data){let e=(t.data.results||[]).map(e=>({id:e.id,type:e.type,title:e.title,url:e.url,excerpt:e.excerpt,metadata:{schemaType:e.metadata?.schemaType,author:e.metadata?.author,createdAt:e.metadata?.createdAt,size:e.metadata?.size?hi(e.metadata.size):void 0}}));s(e)}else console.warn(`Search failed:`,t.error),s([])}catch(e){console.error(`Search failed:`,e),s([])}finally{l(!1)}},_=e=>{a(e),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>{g(e)},300)},v=e=>{if(i.length>=2){let e=[i,...u.filter(e=>e!==i)].slice(0,5);d(e),localStorage.setItem(`trokky_recent_searches`,JSON.stringify(e))}m(e.url),t()},y=e=>{a(e),g(e)},b=()=>{d([]),localStorage.removeItem(`trokky_recent_searches`)},x=()=>{a(``),s([]),t()},S=!i&&u.length>0,C=i.length>=2&&o.length>0,w=i.length>=2&&!c&&o.length===0;return(0,V.jsxs)(ia,{open:e,onClose:x,variant:`center`,size:`lg`,className:`overflow-hidden`,initialFocus:f,ariaLabel:n(`search.placeholder`),children:[(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center px-4 py-3 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(ee,{className:`w-5 h-5 text-gray-400 mr-3`}),(0,V.jsx)(`input`,{ref:f,type:`text`,value:i,onChange:e=>_(e.target.value),placeholder:n(`search.placeholder`),className:`flex-1 bg-transparent text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none`,autoComplete:`off`}),i?(0,V.jsx)(`button`,{onClick:()=>{a(``),s([]),f.current?.focus()},className:`p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:n(`search.clearSearch`),children:(0,V.jsx)(tt,{className:`w-5 h-5`})}):(0,V.jsx)(`button`,{onClick:x,className:`p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:n(`search.closeSearch`),children:(0,V.jsx)(tt,{className:`w-5 h-5`})})]}),(0,V.jsxs)(ia.Body,{padded:!1,className:`h-96`,children:[c&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin w-6 h-6 border-2 border-gray-300 border-t-blue-600 rounded-full mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.searching`)})]}),S&&(0,V.jsxs)(`div`,{className:`p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(re,{className:`w-4 h-4 text-gray-400 mr-2`}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-gray-600 dark:text-gray-300`,children:n(`search.recentSearches`)})]}),(0,V.jsxs)(`button`,{onClick:b,className:`flex items-center text-xs text-gray-500 dark:text-gray-400 hover:text-red-600 dark:hover:text-red-400 transition-colors`,title:n(`search.clearHistory`),children:[(0,V.jsx)(Be,{className:`w-3 h-3 mr-1`}),n(`search.clear`)]})]}),(0,V.jsx)(`div`,{className:`space-y-1`,children:u.map((e,t)=>(0,V.jsx)(`button`,{onClick:()=>y(e),className:`w-full text-left px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors`,children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e,i)}})},t))})]}),C&&(0,V.jsxs)(`div`,{className:`p-4`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-3`,children:n(`search.foundResults`,{count:o.length})}),(0,V.jsx)(`div`,{className:`space-y-2`,children:o.map(e=>(0,V.jsxs)(`button`,{onClick:()=>v(e),className:`w-full flex items-start space-x-3 p-3 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-lg transition-colors text-left`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 w-8 h-8 bg-gray-100 dark:bg-gray-700 rounded-lg flex items-center justify-center`,children:e.type===`document`?(0,V.jsx)(pe,{className:`w-4 h-4 text-gray-600 dark:text-gray-300`}):(0,V.jsx)(at,{className:`w-4 h-4 text-gray-600 dark:text-gray-300`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e.title,i)}})}),e.excerpt&&(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 overflow-hidden`,style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`},children:(0,V.jsx)(`span`,{dangerouslySetInnerHTML:{__html:Ca(e.excerpt,i)}})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 bg-gray-100 dark:bg-gray-700 px-2 py-0.5 rounded`,children:e.type===`document`?n(`search.document`):n(`search.media`)}),e.metadata?.schemaType&&(0,V.jsx)(`span`,{className:`text-xs text-blue-600 dark:text-blue-400`,children:e.metadata.schemaType}),e.metadata?.author&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[n(`search.by`),` `,e.metadata.author]}),e.metadata?.size&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.metadata.size}),e.metadata?.createdAt&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:new Date(e.metadata.createdAt).toLocaleDateString()})]})]})]},`${e.type}-${e.id}`))})]}),w&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(ee,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-900 dark:text-white font-medium mb-1`,children:n(`search.noResults`)}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.tryDifferent`)})]}),!i&&!S&&(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(ee,{className:`w-12 h-12 text-gray-300 dark:text-gray-600 mx-auto mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:n(`search.typeToSearch`)})]})]}),(0,V.jsxs)(ia.Footer,{padded:!1,justify:`between`,className:`px-4 py-3 text-xs text-gray-500 dark:text-gray-400 bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-600`,children:[(0,V.jsx)(`span`,{children:n(`search.pressEscape`)}),(0,V.jsx)(`span`,{children:n(`search.poweredBy`)})]})]})}var Ta=Fr(`ChangePasswordModal`);function Ea({isOpen:e,onClose:t}){let{t:n}=H(`studio`),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(null),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),_=()=>{i(``),o(``),c(``),u(null),f(null),g(!1),t()};return(0,V.jsx)(ia,{open:e,onClose:_,variant:`center`,size:`sm`,title:n(`changePassword.title`),children:(0,V.jsx)(ia.Body,{children:h?(0,V.jsx)(`div`,{className:`bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-md p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`svg`,{className:`w-5 h-5 text-green-500 mr-2`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})}),(0,V.jsx)(`p`,{className:`text-sm text-green-800 dark:text-green-200`,children:n(`changePassword.success`)})]})}):(0,V.jsxs)(`form`,{onSubmit:async e=>{if(e.preventDefault(),u(null),f(null),!r){u(n(`changePassword.errors.currentRequired`)),f(`currentPassword`);return}if(!a){u(n(`changePassword.errors.newRequired`)),f(`newPassword`);return}if(a.length<8){u(n(`changePassword.errors.tooShort`)),f(`newPassword`);return}if(a!==s){u(n(`changePassword.errors.mismatch`)),f(`confirmPassword`);return}if(r===a){u(n(`changePassword.errors.sameAsCurrent`)),f(`newPassword`);return}m(!0);try{Ta.info(`Changing password`);let e=await W.post(`/auth/change-password`,{currentPassword:r,newPassword:a});if(e.success)Ta.info(`Password changed successfully`),g(!0),setTimeout(()=>{_()},2e3);else throw Error(e.error?.message||n(`changePassword.errors.failed`))}catch(e){Ta.error(`Failed to change password`,e),u(e.message||n(`changePassword.errors.failed`)),f(e.field||null)}finally{m(!1)}},children:[l&&(0,V.jsx)(`div`,{className:`mb-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md p-3`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-800 dark:text-red-200`,children:l})}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`currentPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.currentPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`currentPassword`,value:r,onChange:e=>i(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`currentPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`current-password`})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`newPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.newPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`newPassword`,value:a,onChange:e=>o(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`newPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`new-password`}),(0,V.jsx)(`p`,{className:`mt-1 text-xs text-gray-500 dark:text-gray-400`,children:n(`changePassword.errors.tooShort`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{htmlFor:`confirmPassword`,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:n(`changePassword.confirmPassword`)}),(0,V.jsx)(`input`,{type:`password`,id:`confirmPassword`,value:s,onChange:e=>c(e.target.value),className:`w-full px-3 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:bg-gray-700 dark:text-white ${d===`confirmPassword`?`border-red-500 dark:border-red-500`:`border-gray-300 dark:border-gray-600`}`,disabled:p,autoComplete:`new-password`})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 flex justify-end gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:_,className:`px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded-md`,disabled:p,children:n(`common.cancel`)}),(0,V.jsx)(`button`,{type:`submit`,className:`px-4 py-2 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md disabled:opacity-50 disabled:cursor-not-allowed`,disabled:p,children:n(p?`changePassword.submitting`:`changePassword.submit`)})]})]})})})}function Da({onOpenMobileMenu:e,showSearch:t=!0,showMedia:n=!0,showUserMenu:i=!0}){let{t:a}=H(`studio`),{logout:o}=ri(),{user:s,loading:l}=si(),{hasPermission:u,hasAnyPermission:d}=ci(),f=r(),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(`system`),{documentTypes:C,loading:w}=ya(),T=C.filter(e=>!ba(e)),E=pa()?.branding||{title:`Trokky Studio`},{isOpen:D,openSearch:O,closeSearch:k}=xa();(0,B.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&e.key===`k`&&(e.preventDefault(),O())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[O]);let A=e=>{g(!1),f(`/content/${e}/new`)},j=e=>{S(e),e===`system`?document.documentElement.classList.remove(`light`,`dark`):(document.documentElement.classList.remove(`light`,`dark`),document.documentElement.classList.add(e)),localStorage.setItem(`trokky_theme`,e)},M=[{key:`light`,label:a(`theme.light`),icon:Oe},{key:`dark`,label:a(`theme.dark`),icon:me},{key:`system`,label:a(`theme.system`),icon:_e}];return(0,V.jsxs)(`header`,{className:`sticky top-0 z-sticky bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700 shadow-sm`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between h-16 px-4 sm:px-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsx)(`button`,{onClick:e,className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 lg:hidden`,children:(0,V.jsx)(we,{className:`h-6 w-6`})}),(0,V.jsxs)(c,{to:`/`,className:`flex items-center space-x-3`,children:[E.logo?(0,V.jsx)(`img`,{src:E.logo,alt:`Logo`,className:`h-8 w-8 rounded-lg object-cover`}):(0,V.jsx)(`div`,{className:`h-8 w-8 rounded-lg bg-primary-600 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`text-white font-bold text-sm`,children:`T`})}),(0,V.jsx)(`div`,{children:(0,V.jsx)(`h1`,{className:`text-lg font-semibold text-gray-900 dark:text-white`,children:E.organizationName||E.title})})]})]}),t&&(0,V.jsx)(`div`,{className:`hidden lg:block flex-1 max-w-sm mx-4`,children:(0,V.jsxs)(`button`,{onClick:O,className:`w-full flex items-center px-3 py-1.5 bg-gray-50 dark:bg-gray-700 border border-gray-300 dark:border-gray-600 rounded-md text-left text-sm text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-600 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors`,children:[(0,V.jsx)(ee,{className:`h-4 w-4 mr-2 flex-shrink-0`}),(0,V.jsx)(`span`,{className:`flex-1 truncate`,children:a(`nav.searchPlaceholder`)}),(0,V.jsx)(`kbd`,{className:`hidden xl:inline-flex px-1.5 py-0.5 text-xs bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded`,children:`⌘K`})]})}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[t&&(0,V.jsx)(`button`,{onClick:O,className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 md:hidden`,children:(0,V.jsx)(ee,{className:`h-5 w-5`})}),(0,V.jsxs)(`div`,{className:`hidden sm:block relative`,children:[(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>g(!h),className:`inline-flex items-center`,disabled:w,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-1`}),a(`header.create`),(0,V.jsx)(ye,{className:`h-3 w-3 ml-1`})]}),h&&!w&&(0,V.jsx)(`div`,{className:`absolute right-0 mt-2 w-64 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:T.length>0?(0,V.jsxs)(`div`,{className:`px-3 py-2`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wide mb-2`,children:a(`header.createNewDocument`)}),T.map(e=>(0,V.jsxs)(`button`,{onClick:()=>A(e.schemaType),className:`flex items-center w-full px-2 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 rounded transition-colors`,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:e.schemaTitle||e.title}),e.description&&(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e.description})]})]},e.schemaType||e.id))]}):(0,V.jsx)(`div`,{className:`px-4 py-3 text-sm text-gray-500 dark:text-gray-400 text-center`,children:a(`header.noDocumentTypes`)})})]}),n&&u(li.READ)&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,asChild:!0,className:`hidden sm:inline-flex`,children:(0,V.jsxs)(c,{to:`/media`,children:[(0,V.jsx)(at,{className:`h-4 w-4 mr-1`}),a(`nav.media`)]})}),d([...mi])&&(0,V.jsxs)(`div`,{className:`hidden sm:block relative`,children:[(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>v(!_),className:`inline-flex items-center`,children:[(0,V.jsx)(ge,{className:`h-4 w-4 mr-1`}),a(`nav.settings`),(0,V.jsx)(ye,{className:`h-3 w-3 ml-1`})]}),_&&(0,V.jsxs)(`div`,{className:`absolute right-0 mt-2 w-48 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:[u(di.READ)&&(0,V.jsxs)(c,{to:`/settings`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(ge,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.settings`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.studioConfiguration`)})]})]}),d([ui.READ,fi.READ,pi.READ])&&(0,V.jsxs)(c,{to:`/users`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(Ce,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.users`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.manageUsersPermissions`)})]})]}),(0,V.jsxs)(c,{to:`/audit-logs`,onClick:()=>v(!1),className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700 transition-colors`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-2 text-gray-400`}),(0,V.jsxs)(`div`,{className:`flex-1 text-left`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:a(`nav.auditLogs`)}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:a(`header.viewAllChanges`)})]})]})]})]}),(0,V.jsx)(`button`,{onClick:()=>{j(x===`light`?`dark`:x===`dark`?`system`:`light`)},className:`p-2 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 transition-colors`,title:`${a(`theme.toggle`)}: ${M.find(e=>e.key===x)?.label}`,children:x===`light`?(0,V.jsx)(Oe,{className:`h-5 w-5`}):x===`dark`?(0,V.jsx)(me,{className:`h-5 w-5`}):(0,V.jsx)(_e,{className:`h-5 w-5`})}),i&&(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsxs)(`button`,{onClick:()=>m(!p),className:`flex items-center space-x-2 px-3 py-2 rounded-lg text-gray-700 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-300 dark:hover:text-white dark:hover:bg-gray-700 transition-colors`,children:[l?(0,V.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-gray-300 dark:bg-gray-600 animate-pulse`}):s?.profileImage?(0,V.jsx)(`img`,{src:s.profileImage,alt:`Profile`,className:`h-6 w-6 rounded-full object-cover`}):(0,V.jsx)(`div`,{className:`h-6 w-6 rounded-full bg-primary-600 flex items-center justify-center`,children:(0,V.jsx)(`span`,{className:`text-white font-medium text-xs`,children:(s?.firstName?.[0]||s?.username?.[0]||`U`).toUpperCase()})}),(0,V.jsx)(`span`,{className:`hidden sm:block text-sm font-medium truncate max-w-24`,children:l?(0,V.jsx)(`div`,{className:`h-4 w-16 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`}):s?.firstName||s?.username||`User`}),(0,V.jsx)(ye,{className:wr(`h-4 w-4 transition-transform`,p&&`rotate-180`)})]}),p&&(0,V.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-gray-800 rounded-lg shadow-lg border border-gray-200 dark:border-gray-700 py-1 z-50`,children:[(0,V.jsx)(`div`,{className:`px-3 py-2 border-b border-gray-200 dark:border-gray-700`,children:l?(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`div`,{className:`h-4 w-32 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`}),(0,V.jsx)(`div`,{className:`h-3 w-24 bg-gray-300 dark:bg-gray-600 rounded animate-pulse`})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:s?.firstName&&s?.lastName?`${s.firstName} ${s.lastName}`:s?.username||a(`header.user`)}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 truncate`,children:s?.email||a(`header.noEmail`)})]})}),(0,V.jsxs)(`div`,{className:`py-1`,children:[(0,V.jsxs)(c,{to:`/user/preferences`,className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:()=>m(!1),children:[(0,V.jsx)($e,{className:`h-4 w-4 mr-2 text-gray-400`}),a(`header.preferences`)]}),(0,V.jsxs)(`button`,{className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:()=>{m(!1),b(!0)},children:[(0,V.jsx)(te,{className:`h-4 w-4 mr-2 text-gray-400`}),a(`header.changePassword`)]}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 my-1`}),(0,V.jsxs)(`button`,{className:`flex items-center w-full px-3 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:text-gray-300 dark:hover:bg-gray-700 transition-colors`,onClick:async()=>{m(!1),await o()},children:[(0,V.jsx)(`svg`,{className:`h-4 w-4 mr-2 text-gray-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1`})}),a(`header.signOut`)]})]})]})]})]})]}),(p||h||_)&&(0,V.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>{m(!1),g(!1),v(!1)}}),(0,V.jsx)(wa,{isOpen:D,onClose:k}),(0,V.jsx)(Ea,{isOpen:y,onClose:()=>b(!1)})]})}var Oa={user:`M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z`,users:`M15 19.128a9.38 9.38 0 002.625.372 9.337 9.337 0 004.121-.952 4.125 4.125 0 00-7.533-2.493M15 19.128v-.003c0-1.113-.285-2.16-.786-3.07M15 19.128v.106A12.318 12.318 0 018.624 21c-2.331 0-4.512-.645-6.374-1.766l-.001-.109a6.375 6.375 0 0111.964-3.07M12 6.375a3.375 3.375 0 11-6.75 0 3.375 3.375 0 016.75 0zm8.25 2.25a2.625 2.625 0 11-5.25 0 2.625 2.625 0 015.25 0z`,"user-group":`M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z`,home:`M2.25 12l8.954-8.955c.44-.439 1.152-.439 1.591 0L21.75 12M4.5 9.75v10.125c0 .621.504 1.125 1.125 1.125H9.75v-4.875c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125V21h4.125c.621 0 1.125-.504 1.125-1.125V9.75M8.25 21h8.25`,document:`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m2.25 0H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`,"document-text":`M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z`,folder:`M2.25 12.75V12A2.25 2.25 0 014.5 9.75h15A2.25 2.25 0 0121.75 12v.75m-8.69-6.44l-2.12-2.12a1.5 1.5 0 00-1.061-.44H4.5A2.25 2.25 0 002.25 6v12a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9a2.25 2.25 0 00-2.25-2.25h-5.379a1.5 1.5 0 01-1.06-.44z`,"folder-open":`M3.75 9.776c.112-.017.227-.026.344-.026h15.812c.117 0 .232.009.344.026m-16.5 0a2.25 2.25 0 00-1.883 2.542l.857 6a2.25 2.25 0 002.227 1.932H19.05a2.25 2.25 0 002.227-1.932l.857-6a2.25 2.25 0 00-1.883-2.542m-16.5 0V6A2.25 2.25 0 016 3.75h3.879a1.5 1.5 0 011.06.44l2.122 2.12a1.5 1.5 0 001.06.44H18A2.25 2.25 0 0120.25 9v.776`,"cog-6-tooth":`M9.594 3.94c.09-.542.56-.94 1.11-.94h2.593c.55 0 1.02.398 1.11.94l.213 1.281c.063.374.313.686.645.87.074.04.147.083.22.127.324.196.72.257 1.075.124l1.217-.456a1.125 1.125 0 011.37.49l1.296 2.247a1.125 1.125 0 01-.26 1.431l-1.003.827c-.293.24-.438.613-.431.992a6.759 6.759 0 010 .255c-.007.378.138.75.43.99l1.005.828c.424.35.534.954.26 1.43l-1.298 2.247a1.125 1.125 0 01-1.369.491l-1.217-.456c-.355-.133-.75-.072-1.076.124a6.57 6.57 0 01-.22.128c-.331.183-.581.495-.644.869l-.213 1.28c-.09.543-.56.941-1.11.941h-2.594c-.55 0-1.02-.398-1.11-.94l-.213-1.281c-.062-.374-.312-.686-.644-.87a6.52 6.52 0 01-.22-.127c-.325-.196-.72-.257-1.076-.124l-1.217.456a1.125 1.125 0 01-1.369-.49l-1.297-2.247a1.125 1.125 0 01.26-1.431l1.004-.827c.292-.24.437-.613.43-.992a6.932 6.932 0 010-.255c.007-.378-.138-.75-.43-.99l-1.004-.828a1.125 1.125 0 01-.26-1.43l1.297-2.247a1.125 1.125 0 011.37-.491l1.216.456c.356.133.751.072 1.076-.124.072-.044.146-.087.22-.128.332-.183.582-.495.644-.869l.214-1.281z`,"bars-3":`M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5`,"squares-2x2":`M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z`,"list-bullet":`M8.25 6.75h12M8.25 12h12m-12 5.25h12M3.75 6.75h.007v.008H3.75V6.75zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zM3.75 12h.007v.008H3.75V12zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0zm-.375 5.25h.007v.008H3.75v-.008zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z`,"information-circle":`M11.25 11.25l.041-.02a.75.75 0 011.063.852l-.708 2.836a.75.75 0 001.063.853l.041-.021M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9-3.75h.008v.008H12V8.25z`,"question-mark-circle":`M9.879 7.519c1.171-1.025 3.071-1.025 4.242 0 1.172 1.025 1.172 2.687 0 3.712-.203.179-.43.326-.67.442-.745.361-1.45.999-1.45 1.827v.75M21 12a9 9 0 11-18 0 9 9 0 0118 0zm-9 5.25h.008v.008H12v-.008z`,"chart-bar":`M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z`,"presentation-chart-line":`M3.75 3v11.25A2.25 2.25 0 006 16.5h2.25M3.75 3h-1.5m1.5 0h16.5m0 0h1.5m-1.5 0v11.25A2.25 2.25 0 0118 16.5h-2.25m-7.5 0h7.5m-7.5 0l-1 3m8.5-3l1 3m0 0l.5 1.5m-.5-1.5h-9.5m0 0l-.5 1.5M9 11.25v1.5M12 9v3.75m3-6v6`,"building-office":`M3.75 21h16.5M4.5 3h15M5.25 3v18m13.5-18v18M9 6.75h1.5m-1.5 3h1.5m-1.5 3h1.5m3-6H15m-1.5 3H15m-1.5 3H15M9 21v-3.375c0-.621.504-1.125 1.125-1.125h3.75c.621 0 1.125.504 1.125 1.125V21`,"map-pin":`M15 10.5a3 3 0 11-6 0 3 3 0 016 0z M19.5 10.5c0 7.142-7.5 11.25-7.5 11.25S4.5 17.642 4.5 10.5a7.5 7.5 0 1115 0z`,"globe-alt":`M12 21a9.004 9.004 0 008.716-6.747M12 21a9.004 9.004 0 01-8.716-6.747M12 21c2.485 0 4.5-4.03 4.5-9S14.485 3 12 3m0 18c-2.485 0-4.5-4.03-4.5-9S9.515 3 12 3m0 0a8.997 8.997 0 017.843 4.582M12 3a8.997 8.997 0 00-7.843 4.582m15.686 0A11.953 11.953 0 0112 10.5c-2.998 0-5.74-1.1-7.843-2.918m15.686 0A8.959 8.959 0 0121 12c0 .778-.099 1.533-.284 2.253m0 0A17.919 17.919 0 0112 16.5c-3.162 0-6.133-.815-8.716-2.247m0 0A9.015 9.015 0 013 12c0-1.605.42-3.113 1.157-4.418`,newspaper:`M12 7.5h1.5m-1.5 3h1.5m-7.5 3h7.5m-7.5 3h7.5m3-9h3.375c.621 0 1.125.504 1.125 1.125V18a2.25 2.25 0 01-2.25 2.25M16.5 7.5V18a2.25 2.25 0 002.25 2.25M16.5 7.5V4.875c0-.621-.504-1.125-1.125-1.125H4.125C3.504 3.75 3 4.254 3 4.875V18a2.25 2.25 0 002.25 2.25h13.5M6 7.5h3v3H6v-3z`,photo:`M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z`,heart:`M21 8.25c0-2.485-2.099-4.5-4.688-4.5-1.935 0-3.597 1.126-4.312 2.733-.715-1.607-2.377-2.733-4.313-2.733C5.1 3.75 3 5.765 3 8.25c0 7.22 9 12 9 12s9-4.78 9-12z`,star:`M11.48 3.499a.562.562 0 011.04 0l2.125 5.111a.563.563 0 00.475.345l5.518.442c.499.04.701.663.321.988l-4.204 3.602a.563.563 0 00-.182.557l1.285 5.385a.562.562 0 01-.84.61l-4.725-2.885a.563.563 0 00-.586 0L6.982 20.54a.562.562 0 01-.84-.61l1.285-5.386a.562.562 0 00-.182-.557l-4.204-3.602a.563.563 0 01.321-.988l5.518-.442a.563.563 0 00.475-.345L11.48 3.5z`,"check-circle":`M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z`,"hand-raised":`M10.05 4.575a1.575 1.575 0 10-3.15 0v3m3.15-3v-1.5a1.575 1.575 0 013.15 0v1.5m-3.15 0l.075 5.925m3.075.75V4.575m0 0a1.575 1.575 0 013.15 0V15M6.9 7.575a1.575 1.575 0 10-3.15 0v8.175a6.75 6.75 0 006.75 6.75h2.018a5.25 5.25 0 003.712-1.538l1.732-1.732a5.25 5.25 0 001.538-3.712l.003-2.024a.668.668 0 01.198-.471 1.575 1.575 0 10-2.228-2.228 3.818 3.818 0 00-1.12 2.687M6.9 7.575V12m6.27 4.318A4.49 4.49 0 0116.35 15m.002 0h-.002`,clock:`M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z`,calendar:`M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5`,tag:`M9.568 3H5.25A2.25 2.25 0 003 5.25v4.318c0 .597.237 1.17.659 1.591l9.581 9.581c.699.699 1.78.872 2.607.33a18.095 18.095 0 005.223-5.223c.542-.827.369-1.908-.33-2.607L11.16 3.66A2.25 2.25 0 009.568 3z M6 6h.008v.008H6V6z`,scale:`M12 3v17.25m0 0c-1.472 0-2.882.265-4.185.75M12 20.25c1.472 0 2.882.265 4.185.75M18.75 4.97A48.416 48.416 0 0012 4.5c-2.291 0-4.545.16-6.75.47m13.5 0c1.01.143 2.01.317 3 .52m-3-.52l2.62 10.726c.122.499-.106 1.028-.589 1.202a5.988 5.988 0 01-2.031.352 5.988 5.988 0 01-2.031-.352c-.483-.174-.711-.703-.59-1.202L18.75 4.971zm-16.5.52c.99-.203 1.99-.377 3-.52m0 0l2.62 10.726c.122.499-.106 1.028-.589 1.202a5.989 5.989 0 01-2.031.352 5.989 5.989 0 01-2.031-.352c-.483-.174-.711-.703-.59-1.202L5.25 4.971z`,"academic-cap":`M4.26 10.147a60.436 60.436 0 00-.491 6.347A48.627 48.627 0 0112 20.904a48.627 48.627 0 018.232-4.41 60.46 60.46 0 00-.491-6.347m-15.482 0a50.57 50.57 0 00-2.658-.813A59.905 59.905 0 0112 3.493a59.902 59.902 0 0110.399 5.84c-.896.248-1.783.52-2.658.814m-15.482 0A50.697 50.697 0 0112 13.489a50.702 50.702 0 017.74-3.342M6.75 15a.75.75 0 100-1.5.75.75 0 000 1.5zm0 0v-3.675A55.378 55.378 0 0112 8.443m-7.007 11.55A5.981 5.981 0 006.75 15.75v-1.5`,"book-open":`M12 6.042A8.967 8.967 0 006 3.75c-1.052 0-2.062.18-3 .512v14.25A8.987 8.987 0 016 18c2.305 0 4.408.867 6 2.292m0-14.25a8.966 8.966 0 016-2.292c1.052 0 2.062.18 3 .512v14.25A8.987 8.987 0 0018 18a8.967 8.967 0 00-6 2.292m0-14.25v14.25`,briefcase:`M20.25 14.15v4.25c0 1.094-.787 2.036-1.872 2.18-2.087.277-4.216.42-6.378.42s-4.291-.143-6.378-.42c-1.085-.144-1.872-1.086-1.872-2.18v-4.25m16.5 0a2.18 2.18 0 00.75-1.661V8.706c0-1.081-.768-2.015-1.837-2.175a48.114 48.114 0 00-3.413-.387m4.5 8.006c-.194.165-.42.295-.673.38A23.978 23.978 0 0112 15.75c-2.648 0-5.195-.429-7.577-1.22a2.016 2.016 0 01-.673-.38m0 0A2.18 2.18 0 013 12.489V8.706c0-1.081.768-2.015 1.837-2.175a48.111 48.111 0 013.413-.387m7.5 0V5.25A2.25 2.25 0 0013.5 3h-3a2.25 2.25 0 00-2.25 2.25v.894m7.5 0a48.667 48.667 0 00-7.5 0M12 12.75h.008v.008H12v-.008z`,beaker:`M9.75 3.104v5.714a2.25 2.25 0 01-.659 1.591L5 14.5M9.75 3.104c-.251.023-.501.05-.75.082m.75-.082a24.301 24.301 0 014.5 0m0 0v5.714c0 .597.237 1.17.659 1.591L19.8 15.3M14.25 3.104c.251.023.501.05.75.082M19.8 15.3l-1.57.393A9.065 9.065 0 0112 15a9.065 9.065 0 00-6.23-.693L5 14.5m14.8.8l1.402 1.402c1.232 1.232.65 3.318-1.067 3.611A48.309 48.309 0 0112 21c-2.773 0-5.491-.235-8.135-.687-1.718-.293-2.3-2.379-1.067-3.61L5 14.5`,bolt:`M3.75 13.5l10.5-11.25L12 10.5h8.25L9.75 21.75 12 13.5H3.75z`,sparkles:`M9.813 15.904L9 18.75l-.813-2.846a4.5 4.5 0 00-3.09-3.09L2.25 12l2.846-.813a4.5 4.5 0 003.09-3.09L9 5.25l.813 2.846a4.5 4.5 0 003.09 3.09L15.75 12l-2.846.813a4.5 4.5 0 00-3.09 3.09zM18.259 8.715L18 9.75l-.259-1.035a3.375 3.375 0 00-2.455-2.456L14.25 6l1.036-.259a3.375 3.375 0 002.455-2.456L18 2.25l.259 1.035a3.375 3.375 0 002.456 2.456L21.75 6l-1.035.259a3.375 3.375 0 00-2.456 2.456zM16.894 20.567L16.5 21.75l-.394-1.183a2.25 2.25 0 00-1.423-1.423L13.5 18.75l1.183-.394a2.25 2.25 0 001.423-1.423l.394-1.183.394 1.183a2.25 2.25 0 001.423 1.423l1.183.394-1.183.394a2.25 2.25 0 00-1.423 1.423z`,"shield-check":`M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 013.598 6 11.99 11.99 0 003 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.248-8.25-3.285z`,"rocket-launch":`M15.59 14.37a6 6 0 01-5.84 7.38v-4.8m5.84-2.58a14.98 14.98 0 006.16-12.12A14.98 14.98 0 009.631 8.41m5.96 5.96a14.926 14.926 0 01-5.841 2.58m-.119-8.54a6 6 0 00-7.381 5.84h4.8m2.581-5.84a14.927 14.927 0 00-2.58 5.84m2.699 2.7c-.103.021-.207.041-.311.06a15.09 15.09 0 01-2.448-2.448 14.9 14.9 0 01.06-.312m-2.24 2.39a4.493 4.493 0 00-1.757 4.306 4.493 4.493 0 004.306-1.758M16.5 9a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z`,wrench:`M11.42 15.17L17.25 21A2.652 2.652 0 0021 17.25l-5.877-5.877M11.42 15.17l2.496-3.03c.317-.384.74-.626 1.208-.766M11.42 15.17l-4.655 5.653a2.548 2.548 0 11-3.586-3.586l6.837-5.63m5.108-.233c.55-.164 1.163-.188 1.743-.14a4.5 4.5 0 004.486-6.336l-3.276 3.277a3.004 3.004 0 01-2.25-2.25l3.276-3.276a4.5 4.5 0 00-6.336 4.486c.091 1.076-.071 2.264-.904 2.95l-.102.085m-1.745 1.437L5.909 7.5H4.5L2.25 3.75l1.5-1.5L7.5 4.5v1.409l4.26 4.26m-1.745 1.437l1.745-1.437m6.615 8.206L15.75 15.75M4.867 19.125h.008v.008h-.008v-.008z`,truck:`M8.25 18.75a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h6m-9 0H3.375a1.125 1.125 0 01-1.125-1.125V14.25m17.25 4.5a1.5 1.5 0 01-3 0m3 0a1.5 1.5 0 00-3 0m3 0h1.125c.621 0 1.129-.504 1.09-1.124a17.902 17.902 0 00-3.213-9.193 2.056 2.056 0 00-1.58-.86H14.25M16.5 18.75h-2.25m0-11.177v-.958c0-.568-.422-1.048-.987-1.106a48.554 48.554 0 00-10.026 0 1.106 1.106 0 00-.987 1.106v7.635m12-6.677v6.677m0 4.5v-4.5m0 0h-12`},ka={"fa-file-alt":`document-text`,"fa-file":`document`,"fa-folder":`folder`,"fa-folder-open":`folder-open`,"fa-home":`home`,"fa-cog":`cog-6-tooth`,"fa-cogs":`cog-6-tooth`,"fa-bars":`bars-3`,"fa-list":`list-bullet`,"fa-list-alt":`list-bullet`,"fa-th":`squares-2x2`,"fa-sitemap":`squares-2x2`,"fa-user":`user`,"fa-users":`users`,"fa-user-group":`user-group`,"fa-info-circle":`information-circle`,"fa-question-circle":`question-mark-circle`,"fa-chart-bar":`chart-bar`,"fa-chart-line":`presentation-chart-line`,"fa-building":`building-office`,"fa-briefcase":`briefcase`,"fa-map-marker-alt":`map-pin`,"fa-map-marked-alt":`map-pin`,"fa-map":`map-pin`,"fa-globe":`globe-alt`,"fa-newspaper":`newspaper`,"fa-image":`photo`,"fa-images":`photo`,"fa-heart":`heart`,"fa-star":`star`,"fa-check-circle":`check-circle`,"fa-hands-helping":`hand-raised`,"fa-handshake":`hand-raised`,"fa-clock":`clock`,"fa-history":`clock`,"fa-calendar":`calendar`,"fa-calendar-alt":`calendar`,"fa-tag":`tag`,"fa-tags":`tag`,"fa-balance-scale":`scale`,"fa-bullseye":`check-circle`,"fa-graduation-cap":`academic-cap`,"fa-book":`book-open`,"fa-book-open":`book-open`,"fa-flask":`beaker`,"fa-bolt":`bolt`,"fa-magic":`sparkles`,"fa-shield-alt":`shield-check`,"fa-rocket":`rocket-launch`,"fa-wrench":`wrench`,"fa-truck":`truck`};function Aa(e){return e.startsWith(`Fa`)&&!e.startsWith(`fa-`)?`fa-`+e.slice(2).replace(/([A-Z])/g,`-$1`).toLowerCase().replace(/^-/,``):e}function ja(e){if(!e)return{library:`heroicons`,name:`document`};if(e.startsWith(`svg-fill`)){let t=e.match(/^svg-fill\[([^\]]+)\]:(.+)$/);return t?{library:`custom-svg`,name:t[2],style:`fill`,viewBox:t[1]}:{library:`custom-svg`,name:e.slice(9),style:`fill`}}if(e.startsWith(`svg`)){let t=e.match(/^svg\[([^\]]+)\]:(.+)$/);if(t)return{library:`custom-svg`,name:t[2],style:`stroke`,viewBox:t[1]};if(e.startsWith(`svg:`))return{library:`custom-svg`,name:e.slice(4),style:`stroke`}}if(e.startsWith(`hi:`))return{library:`heroicons`,name:e.slice(3)};if(e.startsWith(`fa:`)){let t=e.slice(3),n=ka[`fa-${t}`]||ka[t];return n?{library:`heroicons`,name:n}:{library:`fontawesome`,name:t}}if(e.startsWith(`Fa`)){let t=Aa(e),n=ka[t];return n?{library:`heroicons`,name:n}:{library:`fontawesome`,name:t.replace(`fa-`,``)}}return{library:`heroicons`,name:e}}function Ma(e,t=16,n){let r=Oa[e];return r?(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:1.5,stroke:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:r})}):Ma(`document`,t,n)}function Na(e,t=16,n){let r=e.startsWith(`fa-`)?`fas ${e}`:`fas fa-${e}`;return(0,V.jsx)(`i`,{className:`${r} ${n||``}`,style:{fontSize:t,width:t,height:t,display:`inline-flex`,alignItems:`center`,justifyContent:`center`}})}function Pa(e,t=16,n,r=`stroke`,i=`0 0 24 24`){return r===`fill`?(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:i,fill:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{d:e})}):(0,V.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:i,strokeWidth:1.5,stroke:`currentColor`,width:t,height:t,className:n,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:e})})}function Fa(e,t=16,n){let r=ja(e);return r.library===`custom-svg`?Pa(r.name,t,n,r.style,r.viewBox):r.library===`heroicons`?Ma(r.name,t,n):Na(r.name,t,n)}function Ia({isMobile:e=!1,onItemClick:t}){let{t:n}=H(`studio`),{t:r}=H(`common`),i=d(),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(new Set),[l,f]=(0,B.useState)(``),{navigation:p,loading:m,error:h}=_a(),g=()=>{t&&t()},_=()=>{o(!a);try{localStorage.setItem(`trokky_sidebar_collapsed`,JSON.stringify(!a))}catch(e){console.warn(`Failed to save sidebar state:`,e)}};(0,B.useEffect)(()=>{if(!e)try{let e=localStorage.getItem(`trokky_sidebar_collapsed`);e&&o(JSON.parse(e))}catch(e){console.warn(`Failed to restore sidebar state:`,e)}},[e]);let v=e=>e===`/`?i.pathname===`/`:i.pathname===e||i.pathname.startsWith(e+`/`),y=e=>e.type!==`group`||!e.children?!1:e.children.some(e=>{if(e.type===`group`)return y(e);let t=e.path;if(!t){let n=e.schemaType;n&&(e.type===`documentList`?t=`/content/${n}`:e.type===`singleton`&&(t=`/content/${n}/${e.documentId||n}`))}return t?v(t):!1}),b=e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})};(0,B.useEffect)(()=>{if(!p)return;let e=new Set,t=n=>{n.forEach(n=>{n.type===`group`&&y(n)&&(e.add(n.id),n.children&&t(n.children))})};t(p.items),c(e)},[i.pathname,p]);let x=e=>e.normalize(`NFD`).replace(/[\u0300-\u036f]/g,``).toLowerCase().trim(),S=(0,B.useMemo)(()=>{if(!p||!l.trim())return p;let e=x(l),t=n=>n.reduce((n,r)=>{let i=r.title?x(r.title).includes(e):!1;if(r.type===`group`&&r.children){let e=t(r.children);(e.length>0||i)&&n.push({...r,children:e.length>0?e:r.children})}else r.type===`divider`?n.length>0&&n.push(r):i&&n.push(r);return n},[]);return{...p,items:t(p.items)}},[p,l]);(0,B.useEffect)(()=>{if(!S||!l.trim())return;let e=new Set,t=n=>{n.forEach(n=>{n.type===`group`&&(e.add(n.id),n.children&&t(n.children))})};t(S.items),c(e)},[l,S]);let C=(e,t=0)=>{let n=e.icon||`document`,r=e.path;if(!r){let t=e.schemaType;t&&(e.type===`documentList`?r=`/content/${t}`:e.type===`singleton`&&(r=`/content/${t}/${e.documentId||t}`))}let i=r?v(r):!1;if(e.type===`divider`)return a?null:(0,V.jsx)(`div`,{className:wr(`border-t border-gray-200 dark:border-gray-700`,t===0?`mx-4 my-2`:`mx-2 my-1`),children:e.title&&(0,V.jsx)(`div`,{className:`px-3 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e.title})},e.id);if(e.type===`group`){if(a)return(0,V.jsx)(`div`,{children:e.children?.map(e=>C(e,t))},e.id);let n=s.has(e.id),r=y(e);return(0,V.jsxs)(`div`,{className:`space-y-1`,children:[(0,V.jsxs)(`button`,{onClick:()=>b(e.id),className:wr(`w-full flex items-center justify-between px-3 py-2 text-xs font-medium uppercase tracking-wider rounded-lg transition-colors`,r?`text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`text-gray-500 dark:text-gray-400 hover:bg-gray-100 dark:hover:bg-gray-700 hover:text-gray-700 dark:hover:text-gray-300`),children:[(0,V.jsx)(`span`,{children:e.title}),n?(0,V.jsx)(Xe,{className:`h-4 w-4`}):(0,V.jsx)(ye,{className:`h-4 w-4`})]}),n&&e.children&&(0,V.jsx)(`div`,{className:`space-y-1`,children:e.children.map(e=>C(e,t+1))})]},e.id)}return r?(0,V.jsxs)(u,{to:r,onClick:g,className:({isActive:e})=>wr(`flex items-center transition-colors`,a?`p-2 mx-1 rounded-lg justify-center`:`px-3 py-1.5 rounded-lg text-sm`,t>0&&!a&&`ml-4`,e||i?a?`bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300`:`bg-primary-50 text-primary-700 border-r-2 border-primary-500 dark:bg-primary-900/20 dark:text-primary-300`:`text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white`),title:a?e.title:void 0,children:[(0,V.jsx)(`span`,{className:wr(`flex-shrink-0`,a?``:`mr-2`),children:Fa(n,16)}),!a&&(0,V.jsx)(`div`,{className:`flex-1 min-w-0`,children:(0,V.jsx)(`span`,{className:`block truncate`,children:e.title})})]},e.id):null};return(0,V.jsxs)(`div`,{className:wr(`h-full bg-white dark:bg-gray-800 border-r border-gray-200 dark:border-gray-700 flex flex-col transition-all duration-200`,e?`w-64`:a?`w-16`:`w-64`),children:[!e&&(0,V.jsxs)(`div`,{className:wr(`flex items-center p-4 border-b border-gray-200 dark:border-gray-700`,a?`justify-center`:`justify-between`),children:[!a&&(0,V.jsx)(`h2`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:n(`sidebar.navigation`)}),(0,V.jsx)(`button`,{onClick:_,className:`p-1 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 flex-shrink-0`,title:n(a?`sidebar.expand`:`sidebar.collapse`),children:a?(0,V.jsx)(z,{className:`h-4 w-4`}):(0,V.jsx)(be,{className:`h-4 w-4`})})]}),!a&&(0,V.jsx)(`div`,{className:`p-4 border-b border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,value:l,onChange:e=>f(e.target.value),placeholder:n(`sidebar.searchNavigation`),className:`w-full pl-9 pr-8 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 placeholder-gray-400 dark:placeholder-gray-500 focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent`}),l&&(0,V.jsx)(`button`,{onClick:()=>f(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 rounded-md text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-600`,title:r(`actions.clear`),children:(0,V.jsx)(tt,{className:`h-4 w-4`})})]})}),(0,V.jsxs)(`nav`,{className:`flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-1`,children:[m&&(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-8`,children:[(0,V.jsx)(`div`,{className:`animate-spin h-5 w-5 border-2 border-primary-500 border-t-transparent rounded-full`}),!a&&(0,V.jsx)(`span`,{className:`ml-2 text-sm text-gray-500 dark:text-gray-400`,children:n(`sidebar.loadingNavigation`)})]}),h&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:n(`sidebar.failedToLoad`)})}),S&&S.items.length>0?(0,V.jsx)(V.Fragment,{children:S.items.map(e=>C(e))}):l&&p?(0,V.jsxs)(`div`,{className:`text-center py-8`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`sidebar.noResultsFor`,{query:l})}),(0,V.jsx)(`button`,{onClick:()=>f(``),className:`mt-2 text-sm text-primary-600 dark:text-primary-400 hover:underline`,children:n(`sidebar.clearSearch`)})]}):(0,V.jsxs)(V.Fragment,{children:[!a&&(0,V.jsx)(`div`,{className:`px-3 py-2 text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:n(`nav.content`)}),(0,V.jsxs)(u,{to:`/content`,onClick:g,className:({isActive:e})=>wr(`flex items-center transition-colors`,a?`p-2 mx-1 rounded-lg justify-center`:`px-3 py-2 rounded-lg`,e?a?`bg-primary-100 text-primary-700 dark:bg-primary-900/30 dark:text-primary-300`:`bg-primary-50 text-primary-700 border-r-2 border-primary-500 dark:bg-primary-900/20 dark:text-primary-300`:`text-gray-700 hover:bg-gray-100 hover:text-gray-900 dark:text-gray-300 dark:hover:bg-gray-700 dark:hover:text-white`),title:a?n(`nav.content`):void 0,children:[(0,V.jsx)(pe,{className:wr(`h-5 w-5 flex-shrink-0`,a?``:`mr-3`)}),!a&&(0,V.jsx)(`span`,{className:`font-medium`,children:n(`nav.content`)})]})]})]}),!a&&(0,V.jsx)(`div`,{className:`p-4 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 text-center`,children:(0,V.jsx)(`p`,{children:`Trokky Studio`})})})]})}var La=(0,B.createContext)(null);function Ra({children:e}){let[t,n]=(0,B.useState)(()=>({currentPage:`default`,title:`Context`,isVisible:!0,isCollapsed:!1,width:256,position:`left`,content:null})),r=(0,B.useCallback)((e,t,n)=>{let r=t===`visible`?Lr.CONTEXT_SIDEBAR_VISIBLE(e):t===`collapsed`?Lr.CONTEXT_SIDEBAR_COLLAPSED(e):t===`width`?Lr.CONTEXT_SIDEBAR_WIDTH(e):t===`position`?Lr.CONTEXT_SIDEBAR_POSITION(e):``;r&&Rr.set(r,n)},[]),i=(0,B.useCallback)(e=>{let t=e.page;n(n=>{if(n.currentPage===t&&n.title===(e.title??`Context`)&&n.isVisible===(e.defaultVisible??!0))return n;let r=Rr.get(Lr.CONTEXT_SIDEBAR_COLLAPSED(t)),i=Rr.get(Lr.CONTEXT_SIDEBAR_WIDTH(t)),a=Rr.get(Lr.CONTEXT_SIDEBAR_POSITION(t)),o=e.defaultVisible??!0,s=r===null?e.defaultCollapsed??!1:r,c=i===null?e.defaultWidth??256:i,l=a===null?e.defaultPosition??`left`:a,u=n.currentPage!==t;return{...n,currentPage:t,title:e.title??`Context`,isVisible:o,isCollapsed:s,width:c,position:l,content:u?null:n.content}})},[]),a=(0,B.useCallback)(()=>{n(e=>(r(e.currentPage,`collapsed`,!0),{...e,isCollapsed:!0}))},[r]),o=(0,B.useCallback)(()=>{n(e=>(r(e.currentPage,`collapsed`,!1),{...e,isCollapsed:!1}))},[r]),s=(0,B.useCallback)(()=>{n(e=>{let t=!e.isCollapsed;return r(e.currentPage,`collapsed`,t),{...e,isCollapsed:t}})},[r]),c=(0,B.useCallback)(e=>{n(t=>(r(t.currentPage,`width`,e),{...t,width:e}))},[r]),l=(0,B.useCallback)(e=>{n(t=>(r(t.currentPage,`position`,e),{...t,position:e}))},[r]),u=(0,B.useCallback)(e=>n(t=>({...t,content:e})),[]),d=(0,B.useCallback)(()=>n(e=>({...e,content:null})),[]),f=(0,B.useCallback)(e=>n(t=>({...t,title:e})),[]),p=(0,B.useMemo)(()=>({configure:i,collapse:a,expand:o,toggleCollapse:s,setWidth:c,setPosition:l,setContent:u,clearContent:d,setTitle:f,currentPage:t.currentPage,title:t.title,isVisible:t.isVisible,isCollapsed:t.isCollapsed,width:t.width,position:t.position,content:t.content}),[i,a,o,s,c,l,u,d,f,t.currentPage,t.title,t.isVisible,t.isCollapsed,t.width,t.position,t.content]);return(0,V.jsx)(La.Provider,{value:p,children:e})}function za(e){let t=(0,B.useContext)(La);if(!t)throw Error(`useContextSidebar must be used within a ContextSidebarProvider`);let{configure:n}=t;return(0,B.useEffect)(()=>{e&&n(e)},[e?.page,e?.title,e?.defaultVisible,e?.defaultCollapsed,e?.defaultWidth,e?.defaultPosition,n]),t}function Ba({defaultWidth:e=256,minWidth:t=200,maxWidth:n=500,position:r=`left`}){let{t:i}=H(`studio`),a=za(),[o,s]=(0,B.useState)(!1),c=a.isCollapsed,l=a.width||e,u=a.isVisible,d=e=>{e.preventDefault(),s(!0);let i=e.clientX,o=l,c=e=>{let s=e.clientX-i,c=r===`right`?o-s:o+s;c>=t&&c<=n&&a.setWidth(c)},u=()=>{s(!1),document.removeEventListener(`mousemove`,c),document.removeEventListener(`mouseup`,u),document.body.style.cursor=``,document.body.style.userSelect=``};document.body.style.cursor=`col-resize`,document.body.style.userSelect=`none`,document.addEventListener(`mousemove`,c),document.addEventListener(`mouseup`,u)},f=()=>{a.toggleCollapse()};return u?c?(0,V.jsxs)(`div`,{className:wr(`w-12 h-full bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-700 flex flex-col`,r===`left`?`border-r`:`border-l`),children:[(0,V.jsx)(`div`,{className:`p-2 flex-shrink-0`,children:(0,V.jsx)(`button`,{onClick:f,className:`w-8 h-8 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700 flex items-center justify-center`,title:i(`layout.expandContext`),children:r===`left`?(0,V.jsx)(z,{className:`h-4 w-4`}):(0,V.jsx)(be,{className:`h-4 w-4`})})}),(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center py-4`,children:(0,V.jsx)(`div`,{className:`text-xs font-medium text-gray-600 dark:text-gray-400 whitespace-nowrap`,style:{writingMode:`vertical-rl`,textOrientation:`mixed`,transform:`rotate(180deg)`},title:a.title,children:a.title})})]}):(0,V.jsxs)(`div`,{className:wr(`h-full bg-gray-50 dark:bg-gray-900 border-gray-200 dark:border-gray-700 flex flex-col relative`,r===`left`?`border-r`:`border-l`,o&&`select-none`),style:{width:`${l}px`},children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`h2`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:a.title}),(0,V.jsx)(`button`,{onClick:f,className:`p-1 rounded-md text-gray-600 hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-gray-200 dark:hover:bg-gray-700`,title:i(`layout.collapseContext`),children:r===`left`?(0,V.jsx)(be,{className:`h-4 w-4`}):(0,V.jsx)(z,{className:`h-4 w-4`})})]}),(0,V.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:a.content?a.content:null}),(0,V.jsx)(`div`,{className:wr(`absolute top-0 w-1 h-full cursor-col-resize hover:bg-blue-500 hover:w-1.5 transition-all duration-150`,r===`left`?`right-0`:`left-0`),onMouseDown:d,title:i(`layout.resizeSidebar`)})]}):null}function Va({showSearch:e=!0,showMedia:t=!0,showUserMenu:n=!0}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)(!1),s=za(),c=()=>{a(!0)},l=()=>{a(!1)};return(0,B.useEffect)(()=>{if(i)return Ki(Wi(Ui.lg),l)},[i]),(0,V.jsxs)(`div`,{className:`h-dvh flex flex-col bg-gray-50 dark:bg-gray-900`,children:[(0,V.jsx)(Da,{onOpenMobileMenu:c,showSearch:e,showMedia:t,showUserMenu:n}),(0,V.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`hidden lg:flex`,children:(0,V.jsx)(Ia,{})}),s.position===`left`&&(0,V.jsx)(`div`,{className:`flex`,children:(0,V.jsx)(Ba,{position:`left`})}),(0,V.jsx)(`main`,{className:`flex-1 min-w-0 overflow-auto bg-white dark:bg-gray-800`,children:(0,V.jsx)(o,{})}),s.position===`right`&&(0,V.jsx)(`div`,{className:`flex`,children:(0,V.jsx)(Ba,{position:`right`})})]}),(0,V.jsx)(ia,{open:i,onClose:l,variant:`drawer-left`,size:`xs`,wrapperClassName:`lg:hidden`,title:r(`sidebar.navigation`),children:(0,V.jsx)(ia.Body,{padded:!1,children:(0,V.jsx)(Ia,{isMobile:!0,onItemClick:l})})})]})}function Ha(e){return(0,V.jsx)(Ra,{children:(0,V.jsx)(Va,{...e})})}var Ua={title:`Something went wrong`,subtitle:`The application encountered an unexpected error`,description:`Please try refreshing the page or contact support if the problem persists. You can copy the error details below to help with troubleshooting.`,errorMessage:`Error Message:`,stackTrace:`Stack Trace`,componentStack:`Component Stack`,environmentDetails:`Environment Details`,noStackTrace:`No stack trace available`,noComponentStack:`No component stack available`,url:`URL:`,timestamp:`Timestamp:`,userAgent:`User Agent:`,viewport:`Viewport:`,tryAgain:`Try again`,refreshPage:`Refresh page`,copyErrorDetails:`Copy Error Details`,copied:`Copied!`},Wa=class extends B.Component{constructor(e){super(e),this.state={hasError:!1,copied:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e,copied:!1}}componentDidCatch(e,t){console.error(`ErrorBoundary caught an error:`,e,t),this.setState({errorInfo:t})}handleReset=()=>{this.setState({hasError:!1,error:void 0,errorInfo:void 0,copied:!1})};handleCopyError=async()=>{if(!this.state.error)return;let e=this.getErrorDetails();try{await navigator.clipboard.writeText(e),this.setState({copied:!0}),setTimeout(()=>this.setState({copied:!1}),2e3)}catch(e){console.error(`Failed to copy error details:`,e)}};getErrorDetails=()=>{let{error:e,errorInfo:t}=this.state;if(!e)return``;let n=new Date().toISOString(),r=navigator.userAgent;return`Trokky Studio Error Report
2
2
  Timestamp: ${n}
3
3
  URL: ${window.location.href}
4
4
  User Agent: ${r}
@@ -734,9 +734,9 @@ This field accepts the following values:
734
734
  See [documentation](https://example.com) for more details.`,options:{variant:`info`,markdown:!0,collapsible:!0,defaultCollapsed:!1}}}]}};function n$(){Jo.register($o,`builtin`),Jo.register(as,`builtin`),Jo.register(ds,`builtin`),Jo.register(gs,`builtin`),Jo.register(Es,`builtin`),Jo.register(Ns,`builtin`),Jo.register(Gs,`builtin`),Jo.register(Qs,`builtin`),Jo.register(Pc,`builtin`),Jo.register(Zc,`builtin`),Jo.register(Sl,`builtin`),Jo.register(El,`builtin`),Jo.register(Al,`builtin`),Jo.register(Nl,`builtin`),Jo.register(Ll,`builtin`),Jo.register(UR,`builtin`),Jo.register(vz,`builtin`),Jo.register(Ql,`builtin`),Jo.register(wz,`builtin`),Jo.register(fV,`builtin`),Jo.register(gV,`builtin`),Jo.register(qQ,`builtin`),Jo.register(t$,`builtin`),Jo.markInitialized()}if(typeof globalThis<`u`){let e=globalThis;e.__TROKKY_BUILTIN_FIELDS_REGISTERED__||=(n$(),!0)}else n$();function r$({fieldId:e,value:t,onChange:n,definition:r,hasError:i,error:a,validationState:o,isDisabled:s,isReadonly:c,documentContext:l,onValidationChange:u,onFocus:d,onBlur:f,mode:p=`edit`,compact:m=!1,maxLength:h,...g}){let _=Jo.get(r.type);if(!_){let t=`Unsupported field type: ${r.type}`;return p===`preview`?(0,V.jsx)(`span`,{className:`text-gray-500 dark:text-gray-400 italic text-sm`,children:t}):(0,V.jsx)(qc,{fieldId:e,definition:r,hasError:i,error:a,validationState:o,children:(0,V.jsx)(`div`,{className:`text-sm text-gray-500 italic`,children:t})})}if(p===`preview`){let p=_.previewComponent;return p?(0,V.jsx)(p,{fieldId:e,value:t,onChange:n,definition:r,hasError:i,error:a,validationState:o,isDisabled:s,isReadonly:c,documentContext:l,onValidationChange:u,onFocus:d,onBlur:f,compact:m,maxLength:h,...g}):(0,V.jsx)(`span`,{className:`text-gray-900 dark:text-gray-100 text-sm`,children:typeof t==`string`?t:JSON.stringify(t)})}let v=_.component;return(0,V.jsx)(qc,{fieldId:e,definition:r,hasError:i,error:a,validationState:o,children:(0,V.jsx)(v,{fieldId:e,value:t,onChange:n,definition:r,hasError:i,error:a,validationState:o,isDisabled:s,isReadonly:c,mode:p,documentContext:l,onValidationChange:u,onFocus:d,onBlur:f,...g})})}var i$=Fr(`DocumentForm`);function a$(e){return e.replace(/([A-Z])/g,` $1`).replace(/[_-]/g,` `).split(` `).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `).trim()}function o$(){i$.debug(`Component initializing`);let{t:e}=H(`studio`),{documentId:t}=s(),{schema:n,document:r,errors:i,onDocumentChange:a,onFieldBlur:o,onValidationChange:c,isNewDocument:l,isReadOnly:u}=Ko(),d=pa(),f=(0,B.useCallback)(e=>{if(i$.debug(`DocumentForm - Processing fields`,{fields:e,isArray:Array.isArray(e),isObject:e&&typeof e==`object`,keys:e?Object.keys(e):null}),Array.isArray(e))return i$.debug(`DocumentForm - Using array fields`,{count:e.length}),e;if(e&&typeof e==`object`){let t=Object.entries(e).map(([e,t])=>({name:e,title:t.title||a$(e),...t}));return i$.debug(`Converted object fields to array`,{originalFieldCount:Object.keys(e).length,convertedFieldCount:t.length}),t}return i$.warn(`No valid fields found`,{fieldsType:typeof e}),[]},[]),p=(0,B.useCallback)((e,t)=>{a({[e]:t})},[a]),m=(0,B.useCallback)(e=>{o([e])},[o]),h=(0,B.useCallback)(e=>{if(i[e])return i[e];let t=Object.keys(i).find(t=>t.startsWith(`${e}.`)||t.startsWith(`${e}[`));return t?i[t]:void 0},[i]),g=(0,B.useMemo)(()=>{if(n&&r)return{documentId:t||void 0,schema:n.name,isNewDocument:l||!1,allValues:r,nestingLevel:0}},[n,r,t,l]),_=(0,B.useCallback)(e=>{let t=r?.[e.name],n=h(e.name);return(0,V.jsx)(r$,{fieldId:e.name,value:t,onChange:u?()=>{}:t=>p(e.name,t),onBlur:u?()=>{}:()=>m(e.name),definition:e,hasError:!!n,error:n,mode:`edit`,isDisabled:u,disabled:u,studioContext:d||void 0,documentContext:g},e.name)},[r,h,p,m,d,g,u]),v=e=>(0,V.jsx)(`div`,{className:`space-y-6`,children:e.map(_)}),y=(0,B.useMemo)(()=>f(n?.fields),[n?.fields,f]),b=(0,B.useMemo)(()=>!y||!r?y||[]:y.filter(e=>{let t=Lc({name:e.name,conditional:e.conditional,hidden:e.hidden},r);return i$.debug(`Field visibility evaluation`,{fieldName:e.name,visible:t.visible,reason:t.reason}),t.visible}),[y,r]),x=(0,B.useMemo)(()=>new Set(b.map(e=>e.name)),[b]),S=(0,B.useMemo)(()=>Object.keys(i).filter(e=>{let[t]=e.split(/[.[]/);return x.has(t)}).length,[i,x]);return(0,B.useEffect)(()=>{c(S>0)},[S,c]),!n||!r?(i$.debug(`Waiting for schema or document to load`,{hasSchema:!!n,hasDocument:!!r}),(0,V.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:e(`documentEditor.loadingForm`)})})):(i$.debug(`Schema loaded successfully`,{schemaName:n.name,fieldsType:typeof n.fields}),(0,V.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,V.jsx)(`div`,{className:`max-w-4xl mx-auto px-3 py-4 md:px-8 md:py-6`,children:(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`px-4 py-4 md:px-8 md:py-6`,children:[b.length>0&&v(b),b.length===0&&(0,V.jsx)(`div`,{className:`text-center py-12`,children:(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:e(`documentEditor.noFieldsDefined`)})})]})})})}))}function s$(e){return e.reduce((e,t)=>typeof t==`number`?`${e}[${t}]`:e?`${e}.${t}`:String(t),``)}function c$(e,t){let n=e;for(let e of t){if(n==null)return;n=n[e]}return n}function l$(e,t,n){if(t.length===0)return n;let[r,...i]=t;if(typeof r==`string`&&!ac(r))return e;if(typeof r==`number`){let t=Array.isArray(e)?e:[],a=t.slice();return a[r]=l$(t[r],i,n),a}let a=e&&typeof e==`object`&&!Array.isArray(e)?e:{};return{...a,[r]:l$(a[r],i,n)}}var u$=new Set([rc]);function d$(e,t){return Object.keys(e).filter(n=>!t.has(n)&&e[n]!==void 0)}function f$(e,t,n=new Set){if(Object.is(e,t))return!0;if(e instanceof Date||t instanceof Date)return e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime();if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!f$(e[r],t[r],n))return!1;return!0}if(e===null||t===null||typeof e!=`object`||typeof t!=`object`)return!1;let r=d$(e,n),i=d$(t,n);return r.length===i.length&&r.every(r=>Object.prototype.hasOwnProperty.call(t,r)&&f$(e[r],t[r],n))}function p$(e=null){let t=e==null?e:cc(e);return{initial:t??null,current:t??null,errors:{},status:`idle`}}function m$(e,t){switch(t.type){case`load`:return p$(t.document);case`setValue`:{if(t.path.length===0)return e;let n=l$(e.current??{},t.path,cc(t.value));if(n===e.current)return e;let r=s$(t.path),i=e.errors;if(Object.keys(i).some(e=>e===r||e.startsWith(`${r}.`)||e.startsWith(`${r}[`))){i={};for(let[t,n]of Object.entries(e.errors))t===r||t.startsWith(`${r}.`)||t.startsWith(`${r}[`)||(i[t]=n)}return{...e,current:n,errors:i,status:`idle`}}case`reset`:return{...e,current:e.initial,errors:{},status:`idle`};case`resetField`:{if(t.path.length===0)return e;let n=c$(e.initial,t.path),r=l$(e.current??{},t.path,n),i=s$(t.path),a={...e.errors};return delete a[i],{...e,current:r,errors:a,status:`idle`}}case`setErrors`:return{...e,errors:t.errors};case`markSaved`:{let n=t.document===void 0?e.current:t.document,r=n==null?n:cc(n);return{initial:r??null,current:r??null,errors:{},status:`saved`}}case`setStatus`:return{...e,status:t.status};default:return e}}var h$=new WeakMap;function g$(e){let t=h$.get(e);if(t!==void 0)return t;let n=e.initial!==e.current&&!f$(e.initial,e.current,u$);return h$.set(e,n),n}function _$(e,t){return t?.title||e}function v$(e,t,n,r,i,a){let o=n?.type;if(n?.required&&dc(e)){i[s$(r)]=`${_$(t,n)} is required`;return}if(dc(e))return;if(o===`object`&&n?.fields){if(!e||typeof e!=`object`||Array.isArray(e))return;for(let t of ec(n))(!a.isVisible||a.isVisible({name:t.name,...t.definition},e))&&v$(e[t.name],t.name,t.definition,[...r,t.name],i,a);return}if(o===`array`){if(!Array.isArray(e))return;let o=n?.of;if(!o)return;e.forEach((e,s)=>{v$(e,`${_$(t,n)} item ${s+1}`,o,[...r,s],i,a)});return}let s=a.getPlugin?.(o);if(s&&typeof s.validate==`function`)try{let a=s.validate(e,{...n,title:_$(t,n)});a&&a.isValid===!1&&a.errors?.length&&(i[s$(r)]=a.errors[0])}catch{}}function y$(e,t,n={}){let r={},i=e&&typeof e==`object`?e:{},a=n.rootPath?.[0];for(let{name:e,definition:o}of ec(t))(a===void 0||e===a)&&(!n.isVisible||n.isVisible({name:e,...o},i))&&v$(i[e],e,o,[e],r,n);return r}function b$(){let[e,t]=(0,B.useReducer)(m$,null,()=>p$(null)),n=(0,B.useRef)(e);n.current=e;let r=(0,B.useMemo)(()=>({load:e=>t({type:`load`,document:e}),setValue:(e,n)=>t({type:`setValue`,path:e,value:n}),reset:()=>t({type:`reset`}),resetField:e=>t({type:`resetField`,path:e}),setErrors:e=>t({type:`setErrors`,errors:e}),markSaved:e=>t({type:`markSaved`,document:e}),setStatus:e=>t({type:`setStatus`,status:e})}),[]),i=g$(e),a=(0,B.useCallback)(()=>n.current,[]);return{state:e,document:e.current,errors:e.errors,status:e.status,isDirty:i,getState:a,...r}}function x$(){let{t:e}=H(`studio`),{schema:t,document:n,documentState:r,currentMode:i,isNewDocument:a,hasUnsavedChanges:o,hasValidationErrors:s,isReadOnly:c,hasPublishPermission:l,saving:u,onStateChange:d,onModeChange:f,onSave:p,onCancel:m,onToggleMobileSidebar:h}=Ko(),[g,_]=(0,B.useState)(!1),v=async t=>{(!qo.requiresConfirmation(r,t)||confirm(e(`documentEditor.confirmStateChange`,{from:qo.getStateName(r),to:qo.getStateName(t)})))&&(await d(t),_(!1))},y=(0,B.useMemo)(()=>{let r=t?.title||t?.name||`Document`;if(!n)return e(`documentEditor.newDocument`,{type:r});if(t?.fields){let e=(Array.isArray(t.fields)?t.fields:Object.entries(t.fields).map(([e,t])=>({name:e,...t})))[0];if(e&&n[e.name]){let t=n[e.name];if(typeof t==`string`&&t.trim()&&!t.startsWith(`New `))return t}}return n.title&&!n.title.startsWith(`New `)?n.title:n.name&&!n.name.startsWith(`New `)?n.name:n.slug?n.slug:e(`documentEditor.newDocument`,{type:r})},[n,t,e]),b=t?.singleton===!0,x=o,S=qo.getAvailableTransitions(r);return(0,V.jsxs)(`div`,{className:`flex-shrink-0 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`px-6 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[!b&&(0,V.jsxs)(`button`,{onClick:m,className:`flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors`,title:e(`documentEditor.backTo`,{type:t?.title||t?.name}),children:[(0,V.jsx)(be,{className:`h-4 w-4 mr-1`}),(0,V.jsx)(`span`,{className:`hidden sm:inline`,children:e(`documentEditor.backTo`,{type:t?.title||t?.name})}),(0,V.jsx)(`span`,{className:`sm:hidden`,children:e(`common.back`)})]}),(0,V.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[t?.title||t?.name,` `,a?`(New)`:``]}),l?(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsxs)(`button`,{onClick:()=>_(!g),className:`inline-flex items-center px-3 py-1.5 rounded-md text-sm font-medium border ${S$(r)}`,children:[(0,V.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full mr-2 ${C$(r)}`}),e(r===`published`?`documentEditor.published`:`documentEditor.draft`),(0,V.jsx)(ye,{className:`ml-1 h-4 w-4`})]}),g&&(0,V.jsx)(`div`,{className:`absolute top-full left-0 mt-1 w-48 bg-white dark:bg-gray-800 rounded-md shadow-lg border border-gray-200 dark:border-gray-700 z-10`,children:(0,V.jsx)(`div`,{className:`py-1`,children:S.map(t=>(0,V.jsxs)(`button`,{onClick:()=>v(t),className:`block w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700`,children:[(0,V.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full mr-2 ${C$(t)}`}),e(t===`published`?`documentEditor.published`:`documentEditor.draft`)]},t))})})]}):(0,V.jsxs)(`span`,{className:`inline-flex items-center px-3 py-1.5 rounded-md text-sm font-medium border ${S$(r)}`,children:[(0,V.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full mr-2 ${C$(r)}`}),e(r===`published`?`documentEditor.published`:`documentEditor.draft`)]})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center bg-gray-100 dark:bg-gray-700 rounded-lg p-1`,children:[(0,V.jsxs)(`button`,{onClick:()=>f(`form`),className:`flex items-center px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${i===`form`?`bg-white dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm`:`text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white`}`,children:[(0,V.jsx)(ct,{className:`h-4 w-4 mr-1.5`}),e(`documentEditor.edit`)]}),(0,V.jsxs)(`button`,{onClick:()=>f(`preview`),className:`flex items-center px-3 py-1.5 rounded-md text-sm font-medium transition-colors ${i===`preview`?`bg-white dark:bg-gray-600 text-gray-900 dark:text-white shadow-sm`:`text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white`}`,children:[(0,V.jsx)(ce,{className:`h-4 w-4 mr-1.5`}),e(`documentEditor.preview`)]})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[x&&(0,V.jsxs)(U,{variant:`outline`,onClick:m,children:[(0,V.jsx)(tt,{className:`h-4 w-4 mr-1.5`}),e(`common.cancel`)]}),(0,V.jsxs)(U,{onClick:p,loading:u,disabled:c||u||!o||s,title:c?e(`documentEditor.readOnlyMode`):void 0,children:[(0,V.jsx)(ve,{className:`h-4 w-4 mr-1.5`}),e(c?`documentEditor.readOnly`:a?`common.create`:`common.save`)]})]})]})]}),(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 mb-2`}),(0,V.jsxs)(`div`,{className:`mb-2 flex items-start justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`h1`,{className:`text-lg font-semibold text-gray-900 dark:text-white truncate`,children:y}),(o||s||c)&&(0,V.jsxs)(`div`,{className:`flex items-center space-x-2 mt-0.5`,children:[c&&(0,V.jsxs)(`span`,{className:`text-xs text-blue-600 dark:text-blue-400`,children:[`• `,e(`documentEditor.readOnlyMode`)]}),o&&(0,V.jsxs)(`span`,{className:`text-xs text-amber-600 dark:text-amber-400`,children:[`• `,e(`documentEditor.unsavedChanges`)]}),s&&(0,V.jsxs)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:[`• `,e(`documentEditor.validationErrors`)]})]})]}),(0,V.jsx)(`button`,{onClick:()=>h(!0),className:`md:hidden flex-shrink-0 ml-2 p-1.5 text-blue-600 hover:text-blue-700 dark:text-blue-400 dark:hover:text-blue-300 hover:bg-blue-50 dark:hover:bg-blue-900/20 rounded-full transition-colors`,title:e(`documentEditor.documentInfo`),children:(0,V.jsx)(ue,{className:`h-6 w-6`})})]})]}),g&&(0,V.jsx)(`div`,{className:`fixed inset-0 z-0`,onClick:()=>_(!1)})]})}function S$(e){let t=`border`;switch(e){case`draft`:return`${t} border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-300`;case`published`:return`${t} border-green-300 dark:border-green-600 bg-green-50 dark:bg-green-900 text-green-700 dark:text-green-300`;default:return`${t} border-gray-300 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-700 dark:text-gray-300`}}function C$(e){switch(e){case`draft`:return`bg-gray-400 dark:bg-gray-500`;case`published`:return`bg-green-500 dark:bg-green-400`;default:return`bg-gray-400 dark:bg-gray-500`}}function w$({before:e,after:t,operation:n}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)(!1),o=()=>{let r=[];return n===`create`&&t?(Object.entries(t).forEach(([e,t])=>{(i||!e.startsWith(`_`))&&r.push({field:e,beforeValue:void 0,afterValue:t,changeType:`added`})}),r):n===`delete`&&e?(Object.entries(e).forEach(([e,t])=>{(i||!e.startsWith(`_`))&&r.push({field:e,beforeValue:t,afterValue:void 0,changeType:`removed`})}),r):(e&&t&&new Set([...Object.keys(e),...Object.keys(t)]).forEach(n=>{if(!i&&n.startsWith(`_`))return;let a=e[n],o=t[n];if(!s(a,o)){let e;e=a===void 0?`added`:o===void 0?`removed`:`modified`,r.push({field:n,beforeValue:a,afterValue:o,changeType:e})}}),r)},s=(e,t)=>{if(e===t)return!0;if(e==null||t==null||typeof e!=typeof t)return!1;if(typeof e==`object`)try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}return!1},c=e=>{if(e===null)return`null`;if(e===void 0)return`undefined`;if(typeof e==`string`)return e.length>100?`${e.substring(0,100)}...`:e;if(typeof e==`boolean`||typeof e==`number`)return e.toString();if(typeof e==`object`)try{let t=JSON.stringify(e,null,2);return t.length>200?`${t.substring(0,200)}...`:t}catch{return`[Object]`}return String(e)},l=e=>{switch(e){case`added`:return{icon:Ne,bgColor:`bg-green-50 dark:bg-green-900/20`,textColor:`text-green-800 dark:text-green-200`,borderColor:`border-green-200 dark:border-green-800`};case`removed`:return{icon:Ne,bgColor:`bg-red-50 dark:bg-red-900/20`,textColor:`text-red-800 dark:text-red-200`,borderColor:`border-red-200 dark:border-red-800`};case`modified`:return{icon:Ne,bgColor:`bg-blue-50 dark:bg-blue-900/20`,textColor:`text-blue-800 dark:text-blue-200`,borderColor:`border-blue-200 dark:border-blue-800`}}},u=o();return u.length===0?(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 text-center py-2`,children:r(`changesDiff.noVisibleChanges`)}):(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`span`,{className:`text-xs font-medium text-gray-700 dark:text-gray-300`,children:r(`changesDiff.changesCount`,{count:u.length})}),(0,V.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center space-x-1 text-xs text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:[i?(0,V.jsx)(le,{className:`h-3 w-3`}):(0,V.jsx)(ce,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{children:r(i?`changesDiff.hideSystemFields`:`changesDiff.showSystemFields`)})]})]}),(0,V.jsx)(`div`,{className:`space-y-2`,children:u.map((e,t)=>{let n=l(e.changeType),i=n.icon;return(0,V.jsx)(`div`,{className:`border rounded p-2 ${n.bgColor} ${n.borderColor}`,children:(0,V.jsxs)(`div`,{className:`flex items-start space-x-2`,children:[(0,V.jsx)(i,{className:`h-4 w-4 mt-0.5 flex-shrink-0 ${n.textColor}`}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-xs font-medium ${n.textColor}`,children:e.field}),(e.changeType===`removed`||e.changeType===`modified`)&&e.beforeValue!==void 0&&(0,V.jsxs)(`div`,{className:`mt-1`,children:[(0,V.jsxs)(`div`,{className:`text-xs text-red-600 dark:text-red-400 font-medium`,children:[`- `,r(`changesDiff.before`)]}),(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 bg-red-100 dark:bg-red-900/30 rounded px-2 py-1 mt-1 font-mono`,children:c(e.beforeValue)})]}),(e.changeType===`added`||e.changeType===`modified`)&&e.afterValue!==void 0&&(0,V.jsxs)(`div`,{className:`mt-1`,children:[(0,V.jsxs)(`div`,{className:`text-xs text-green-600 dark:text-green-400 font-medium`,children:[`+ `,r(`changesDiff.after`)]}),(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 bg-green-100 dark:bg-green-900/30 rounded px-2 py-1 mt-1 font-mono`,children:c(e.afterValue)})]})]})]})},`${e.field}-${t}`)})})]})}var T$=Fr(`AuditLogEntry`);function E$({auditLog:e,isExpanded:t,onToggleExpansion:n,isLatest:r=!1}){let{t:i}=H(`studio`),{timeAgo:a,fullDate:o}=(e=>{try{let t=new Date(e);return{timeAgo:ko(t,{addSuffix:!0}),fullDate:t.toLocaleString()}}catch(t){return T$.warn(`Failed to format timestamp`,t),{timeAgo:`Unknown time`,fullDate:e}}})(e.timestamp),s=(e=>{switch(e){case`create`:return{icon:Ne,text:i(`auditEntry.created`),color:`text-green-600 dark:text-green-400`};case`update`:return{icon:ct,text:i(`auditEntry.updated`),color:`text-blue-600 dark:text-blue-400`};case`delete`:return{icon:Be,text:i(`auditEntry.deleted`),color:`text-red-600 dark:text-red-400`};case`publish`:return{icon:ce,text:i(`auditEntry.published`),color:`text-purple-600 dark:text-purple-400`};case`unpublish`:return{icon:ce,text:i(`auditEntry.unpublished`),color:`text-orange-600 dark:text-orange-400`};case`restore`:return{icon:re,text:i(`auditEntry.restored`),color:`text-indigo-600 dark:text-indigo-400`};default:return{icon:ct,text:e,color:`text-gray-600 dark:text-gray-400`}}})(e.operation),c=s.icon,l=(()=>{if(!e.changes?.fields||e.changes.fields.length===0)return null;let t=e.changes.fields;return t.length===1?i(`auditEntry.changedField`,{field:t[0]}):t.length<=3?i(`auditEntry.changedFieldsJoin`,{fields:t.join(`, `)}):i(`auditEntry.changedFieldsCount`,{count:t.length})})();return(0,V.jsxs)(`div`,{className:`rounded-lg ${r?`bg-blue-50 dark:bg-blue-900/20`:`bg-gray-50 dark:bg-gray-800/50`}`,children:[(0,V.jsx)(`div`,{className:`px-3 py-2`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-2 flex-1 min-w-0`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 w-6 h-6 rounded-full flex items-center justify-center ${e.operation===`create`?`bg-green-100 dark:bg-green-900/50`:e.operation===`update`?`bg-blue-100 dark:bg-blue-900/50`:e.operation===`delete`?`bg-red-100 dark:bg-red-900/50`:`bg-gray-100 dark:bg-gray-700`}`,children:(0,V.jsx)(c,{className:`h-3 w-3 ${s.color}`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-1 text-xs`,children:[(0,V.jsx)(`span`,{className:`font-medium ${s.color}`,children:s.text}),(0,V.jsx)(`span`,{className:`text-gray-400`,children:i(`auditEntry.by`)}),(0,V.jsx)(`span`,{className:`text-gray-600 dark:text-gray-300 font-medium truncate`,children:e.actorUsername?e.actorUsername:e.actorId===`system`?`System`:e.actorId?.startsWith(`user-`)?`User`:e.actorId||`Unknown`}),r&&(0,V.jsx)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-700 dark:bg-blue-800 dark:text-blue-200`,children:i(`auditEntry.latest`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2 text-xs text-gray-500 dark:text-gray-400 mt-0.5`,children:[l&&(0,V.jsx)(`span`,{className:`truncate`,children:l}),(0,V.jsxs)(`span`,{title:o,children:[`• `,a]})]})]})]}),e.changes&&(e.changes.before||e.changes.after)&&(0,V.jsx)(`button`,{onClick:n,className:`flex-shrink-0 p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:i(t?`auditEntry.hideDetails`:`auditEntry.showDetails`),children:t?(0,V.jsx)(ye,{className:`h-3 w-3`}):(0,V.jsx)(z,{className:`h-3 w-3`})})]})}),t&&e.changes&&(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-600 p-3 bg-gray-50 dark:bg-gray-750`,children:[(0,V.jsx)(w$,{before:e.changes.before,after:e.changes.after,operation:e.operation}),(0,V.jsx)(`div`,{className:`mt-3 pt-3 border-t border-gray-200 dark:border-gray-600`,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 text-xs text-gray-500 dark:text-gray-400`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:i(`auditEntry.revision`)}),` `,e.revision]}),e.ipAddress&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:i(`auditEntry.ipAddress`)}),` `,e.ipAddress]}),e.userAgent&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:i(`auditEntry.userAgent`)}),` `,(0,V.jsx)(`span`,{className:`truncate`,title:e.userAgent,children:e.userAgent.length>50?`${e.userAgent.substring(0,50)}...`:e.userAgent})]})]})})]})]})}var D$=Fr(`DocumentHistoryPanel`);function O$({documentId:e,collection:t,isVisible:n=!0}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(new Set);(0,B.useEffect)(()=>{e&&n&&p()},[e,n]);let f=async(e,t)=>{if(t[e])return t[e];if(e===`system`)return`System`;try{let t=await W.get(`/users/${e}`);if(t.success&&t.data?.user){let e=t.data.user;return e.username||e.name||e.email||`User`}}catch{}return e.startsWith(`user-`)?`User`:e},p=async()=>{if(e){s(!0),l(null);try{D$.debug(`Loading audit logs for document`,{documentId:e,collection:t});let n=await W.get(`/audit-logs/documents/${e}`,{params:{limit:50,offset:0}});if(n.success&&n.data?.auditLogs){let t=n.data.auditLogs,r={},i=[...new Set(t.map(e=>e.actorId).filter(Boolean))];for(let e of i)r[e]=await f(e,r);let o=t.map(e=>({...e,actorUsername:r[e.actorId]||e.actorUsername}));a(o),D$.info(`Audit logs loaded successfully`,{documentId:e,count:o.length})}else D$.warn(`Failed to load audit logs`,n),l(r(`documentHistory.loadError`))}catch(e){D$.error(`Error loading audit logs`,e),e.response?.status===501?l(r(`documentHistory.notAvailable`)):l(r(`documentHistory.loadError`))}finally{s(!1)}}},m=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t)};return n?(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-1.5 text-gray-500 dark:text-gray-400`}),(0,V.jsx)(`h3`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`documentHistory.title`)})]}),(0,V.jsx)(`button`,{onClick:()=>{p()},disabled:o,className:`p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 disabled:opacity-50`,title:r(`documentHistory.refreshHistory`),children:(0,V.jsx)(ke,{className:`h-3.5 w-3.5 ${o?`animate-spin`:``}`})})]}),(0,V.jsxs)(`div`,{children:[o&&(0,V.jsxs)(`div`,{className:`flex items-center py-4`,children:[(0,V.jsx)(Ao,{}),(0,V.jsx)(`span`,{className:`ml-2 text-xs text-gray-500 dark:text-gray-400`,children:r(`documentHistory.loading`)})]}),c&&(0,V.jsx)(`div`,{className:`py-4`,children:(0,V.jsx)(`div`,{className:`text-xs text-red-600 dark:text-red-400`,children:c})}),!o&&!c&&i.length===0&&(0,V.jsxs)(`div`,{className:`text-center py-4`,children:[(0,V.jsx)(re,{className:`h-6 w-6 mx-auto text-gray-300 dark:text-gray-600 mb-1`}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`documentHistory.noHistory`)})]}),!o&&!c&&i.length>0&&(0,V.jsxs)(`div`,{className:`space-y-1.5`,children:[i.slice(0,10).map((e,t)=>(0,V.jsx)(E$,{auditLog:e,isExpanded:u.has(e.id),onToggleExpansion:()=>m(e.id),isLatest:t===0},e.id)),i.length>10&&(0,V.jsx)(`div`,{className:`text-center pt-1`,children:(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:r(`documentHistory.moreChanges`,{count:i.length-10})})})]})]})]}):null}var k$=Fr(`DocumentSidebar`);function A$(){let{t:e}=H(`studio`),t=r(),n=pa(),{schema:i,document:a,documentState:o,isNewDocument:s,isMobileSidebarOpen:c,onToggleMobileSidebar:l}=Ko(),{canDeleteDocument:u}=ci(),d=i?.name?u(i.name,a):!1,[f,p]=(0,B.useState)(()=>{try{return localStorage.getItem(`trokky_document_sidebar_collapsed`)===`true`}catch{return!1}});(0,B.useEffect)(()=>{if(c)return Ki(Wi(Ui.md),()=>l(!1))},[c,l]);let[m,h]=(0,B.useState)(null),[g,_]=(0,B.useState)(!1),[,v]=(0,B.useState)(null),[y,b]=(0,B.useState)([]),[x,S]=(0,B.useState)({}),C=e=>{p(e);try{localStorage.setItem(`trokky_document_sidebar_collapsed`,String(e))}catch(e){k$.warn(`Failed to save sidebar state`,e)}};(0,B.useEffect)(()=>{let e=a?._id||a?.id;!s&&e&&(D(),w(),T())},[a?._id,a?.id,a?.author,a?.category,s]);let w=async()=>{let e=await k();v(e)},T=async()=>{let e=a?._id||a?.id;if(e)try{let t=await W.get(`/audit-logs/documents/${e}`,{params:{limit:50}});if(t.success&&t.data?.auditLogs){let e=t.data.auditLogs,n=new Map;for(let t of e)if(t.actorId&&!n.has(t.actorId)){let e=t.actorUsername||await E(t.actorId),r=t.actorId===a?._createdBy?`Creator`:`Editor`;n.set(t.actorId,{id:t.actorId,username:e,role:r})}b(Array.from(n.values()))}}catch(e){k$.warn(`Failed to load contributors from audit logs`,e)}},E=async e=>{if(x[e])return x[e];if(e===`system`)return`System`;try{let t=await W.get(`/users/${e}`);if(t.success&&t.data?.user){let n=t.data.user,r=n.username||n.name||n.email||e;return S(t=>({...t,[e]:r})),r}}catch{k$.debug(`Could not resolve username for`,e)}return e.startsWith(`user-`)?`User`:e},D=async()=>{let e=a?._id||a?.id;if(e&&i)try{_(!0);let t=[];k$.debug(`Loading relationships for document`,{documentId:e,schemaName:i.name});let n=async(e,n,r,i)=>{let a=null,o=null;if(typeof e==`string`?a=e:typeof e==`object`&&e&&(a=e._ref||e._id||e.id,o=e._cached?.name||e._cached?.title||e.name||e.title),a){if(!o)try{let e=await W.getDocument(n,a);if(e.success&&e.data?.document){let t=e.data.document;o=t.name||t.title||t.label||a}}catch(e){k$.warn(`Failed to resolve reference for ${r}`,e),o=a}t.push({id:a,title:o||a,fieldName:r,fieldTitle:i,targetCollection:n,type:n})}},r=async(e,t,i=``,a=``)=>{if(!e||!t)return;let o=Array.isArray(e)?e.map(e=>[e.name,e]):Object.entries(e);for(let[e,s]of o){let o=s,c=i?`${i}.${e}`:e,l=a?`${a} > ${o.title||e}`:o.title||e,u=t[e];if(u){if(o.type===`reference`){let t=o.to||o.reference||e;await n(u,t,c,l)}else if(o.type===`array`&&o.of?.type===`reference`){let t=o.of.to||o.of.reference||e,r=o.title||e;if(Array.isArray(u)){for(let e=0;e<Math.min(u.length,5);e++)await n(u[e],t,`${c}[${e}]`,r);u.length>5&&k$.debug(`Truncated ${u.length-5} more references in ${c}`)}}else o.type===`object`&&o.fields&&await r(o.fields,u,c,o.title||e)}}};await r(i.fields,a),h({references:t,referencedBy:[],similar:[]}),k$.info(`Relationships loaded`,{documentId:e,relationshipCount:t.length,references:t.map(e=>({field:e.fieldName,title:e.title}))})}catch(e){k$.error(`Failed to load relationships`,e),h({references:[],referencedBy:[],similar:[]})}finally{_(!1)}},O=e=>e?new Date(e).toLocaleDateString(`en-US`,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):`Unknown`,k=async()=>{if(!a||s)return null;try{let e=await W.get(`/config/settings`),t=window.location.origin;e.success&&e.data?.settings?.publicUrl&&(t=e.data.settings.publicUrl),t=t.replace(/\/$/,``);let n=a.slug||a.id;return i?.name===`page`||i?.type===`singleton`?n===`homepage`||n===`home`?t:`${t}/${n}`:`${t}/${i?.name}/${n}`}catch(e){k$.warn(`Failed to get settings for document URL, using fallback`,e);let t=window.location.origin.replace(/\/$/,``),n=a.slug||a.id;return i?.name===`page`||i?.type===`singleton`?n===`homepage`||n===`home`?t:`${t}/${n}`:`${t}/${i?.name}/${n}`}},A=(0,V.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[(0,V.jsxs)(`div`,{className:`p-4 space-y-4`,children:[!s&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.created`)}),(0,V.jsxs)(`div`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-2`}),O(a?._createdAt)]}),a?._createdBy&&(0,V.jsxs)(`div`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400 mt-1`,children:[(0,V.jsx)(Ke,{className:`h-4 w-4 mr-2`}),a._createdBy]})]}),!s&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.lastUpdated`)}),(0,V.jsxs)(`div`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-2`}),O(a?._updatedAt)]}),a?._updatedBy&&(0,V.jsxs)(`div`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400 mt-1`,children:[(0,V.jsx)(Ke,{className:`h-4 w-4 mr-2`}),a._updatedBy]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.status`)}),(0,V.jsx)(`div`,{className:`text-sm`,children:(0,V.jsx)(`span`,{className:`inline-flex items-center px-2 py-1 rounded-full text-xs font-medium ${j$(o)}`,children:e(o===`published`?`documentEditor.published`:`documentEditor.draft`)})}),o===`published`&&a?.publishedAt&&(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:e(`documentEditor.publishedOn`,{date:O(a.publishedAt)})})]}),a?.tags&&a.tags.length>0&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.tags`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.tags.map((e,t)=>(0,V.jsxs)(`span`,{className:`inline-flex items-center px-2 py-1 rounded text-xs bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300`,children:[(0,V.jsx)(rt,{className:`h-3 w-3 mr-1`}),e]},t))})]}),!s&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.contributors`)}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[y.length>0?y.slice(0,5).map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs bg-gray-100 dark:bg-gray-800 text-gray-700 dark:text-gray-300`,title:`${e.username} (${e.role})`,children:[(0,V.jsx)(Ke,{className:`h-3 w-3 mr-1`}),e.username]},e.id)):(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`documentEditor.contributorsLoading`)}),y.length>5&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`documentEditor.contributorsMore`,{count:y.length-5})})]})]})]}),!s&&(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 p-4`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:m?.references?.length>0?e(`documentEditor.referencesCount`,{count:m.references.length}):e(`documentEditor.references`)}),g?(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`common.loading`)}):m?.references?.length>0?(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[m.references.slice(0,8).map((e,n)=>(0,V.jsxs)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-xs bg-blue-50 dark:bg-blue-900/30 text-blue-700 dark:text-blue-300 hover:bg-blue-100 dark:hover:bg-blue-900/50 cursor-pointer transition-colors`,onClick:()=>t(`/content/${e.targetCollection}/${e.id}`),title:`${e.fieldTitle}: ${e.title}`,children:[(0,V.jsxs)(`span`,{className:`text-blue-500 dark:text-blue-400 mr-1`,children:[`[`,e.targetCollection,`]`]}),e.title.length>15?`${e.title.substring(0,15)}...`:e.title]},n)),m.references.length>8&&(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 self-center`,children:e(`documentEditor.referencesMore`,{count:m.references.length-8})})]}):(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:e(`documentEditor.noReferences`)})]}),(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 p-4`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-2`,children:e(`documentEditor.schema`)}),(0,V.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:i?.title||i?.name}),i?.description&&(0,V.jsx)(`div`,{className:`text-xs mt-1`,children:i.description}),(0,V.jsx)(`div`,{className:`text-xs mt-1`,children:e(`documentEditor.fieldsCount`,{count:M$(i)})})]})]}),!s&&(0,V.jsx)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 p-4`,children:(0,V.jsx)(O$,{documentId:a?._id||a?.id||``,collection:i?.name||``,isVisible:!0})}),!s&&d&&(0,V.jsxs)(`div`,{className:`border-t border-gray-200 dark:border-gray-700 p-4`,children:[(0,V.jsx)(`h4`,{className:`text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider mb-3`,children:e(`documentEditor.dangerZone`)}),(0,V.jsxs)(`button`,{onClick:async()=>{if(!a||!i||s)return;let e=a._id||a.id;if(!e){k$.error(`Cannot delete document: no ID found`),n?.utils?.showToast?.(`Cannot delete document: no ID found`,`error`);return}let r=a.title||a.name||`this document`;if(await n?.utils?.showConfirm?.(`Are you sure you want to delete "${r}"? This action cannot be undone.`,{title:`Delete Document`,confirmText:`Delete`,cancelText:`Cancel`,variant:`danger`}))try{k$.info(`Deleting document`,{schema:i.name,documentId:e,title:r});let a=await W.deleteDocument(i.name,e);if(a.success)n?.utils?.showToast?.(`Document deleted`,`success`),k$.info(`Document deleted successfully`,{schema:i.name,documentId:e}),t(`/content/${i.name}`);else throw Error(a.error?.message||`Failed to delete document`)}catch(e){k$.error(`Failed to delete document`,e);let t=e instanceof Error?e.message:`Failed to delete document`;n?.utils?.showToast?.(t,`error`)}},className:`w-full flex items-center justify-center px-3 py-2 border border-red-300 dark:border-red-600 rounded-md text-sm font-medium text-red-700 dark:text-red-400 bg-white dark:bg-gray-800 hover:bg-red-50 dark:hover:bg-red-900/20 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800 transition-colors`,title:e(`documentEditor.deleteDocument`),children:[(0,V.jsx)(Be,{className:`h-4 w-4 mr-2`}),e(`documentEditor.deleteDocument`)]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2`,children:e(`documentEditor.cannotBeUndone`)})]})]});return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(ia,{open:c,onClose:()=>l(!1),variant:`drawer-right`,size:`sm`,wrapperClassName:`md:hidden`,surface:`bg-gray-50 dark:bg-gray-900`,ariaLabel:e(`documentEditor.documentInfo`),children:[(0,V.jsx)(ia.Header,{padded:!1,className:`p-4`,children:(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:e(`documentEditor.documentInfo`)})}),(0,V.jsx)(ia.Body,{scroll:!1,padded:!1,className:`flex flex-col`,children:A})]}),f&&(0,V.jsx)(`div`,{className:`hidden md:block w-12 bg-gray-50 dark:bg-gray-900 border-l border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`button`,{onClick:()=>C(!1),className:`w-full p-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:e(`documentEditor.expandSidebar`),children:(0,V.jsx)(z,{className:`h-5 w-5 mx-auto`})})}),!f&&(0,V.jsxs)(`div`,{className:`hidden md:flex w-80 bg-gray-50 dark:bg-gray-900 border-l border-gray-200 dark:border-gray-700 flex-col`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:e(`documentEditor.documentInfo`)}),(0,V.jsx)(`button`,{onClick:()=>C(!0),className:`text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,title:e(`documentEditor.collapseSidebar`),children:(0,V.jsx)(ye,{className:`h-5 w-5`})})]}),A]})]})}function j$(e){switch(e){case`published`:return`bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100`;case`draft`:return`bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-100`;default:return`bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-100`}}function M$(e){return e?.fields?Array.isArray(e.fields)?e.fields.length:typeof e.fields==`object`?Object.keys(e.fields).length:0:0}var N$=Fr(`DocumentEditor`),P$=e=>[`schema`,e],F$=(e,t)=>[`document`,e,t];function I$(e,t){return e?t?.title?t.title:e.charAt(0).toUpperCase()+e.slice(1):`Document`}function L$(e,t){if(!Array.isArray(t)||t.length===0)return e;let n=t.map(e=>e?.field).filter(e=>typeof e==`string`&&e.length>0);return n.length===0?e:`${e}: ${n.join(`, `)}`}function R$({schemaName:e,documentId:t,mode:n=`form`,onSave:i,onCancel:a}){let{t:o}=H(`studio`),s=r(),c=P(),u=d();Uo();let f=pa(),p=ci(),m=u.state?.duplicateData;(0,B.useEffect)(()=>{N$.debug(`Permissions object state`,{hasPermissions:!!p,isAdmin:p?.isAdmin,userPermissions:p?.userPermissions,schemaName:e})},[p,e]);let h=f?.utils?.showToast||((e,t)=>console.log(`Toast: ${t} - ${e}`)),g=t===`new`||!t,_=(0,B.useMemo)(()=>p?p.hasSchemaPermission(e,`write`):!1,[p,e,p?.isAdmin,p?.userPermissions?.length]),v=(0,B.useMemo)(()=>p?p.hasSchemaPermission(e,`publish`):!1,[p,e,p?.isAdmin,p?.userPermissions?.length]);N$.debug(`Initializing document editor`,{schemaName:e,documentId:t,isNewDocument:g});let y=b$(),b=y.document,[x,S]=(0,B.useState)(null),[C,w]=(0,B.useState)(!0),[T,E]=(0,B.useState)(!1),[D,O]=(0,B.useState)(null),[k,A]=(0,B.useState)(n),[j,M]=(0,B.useState)(`draft`),N=y.isDirty,[F,I]=(0,B.useState)(!1),[L,ee]=(0,B.useState)(!1),R=(0,B.useRef)(!1),te=(0,B.useMemo)(()=>({getPlugin:e=>Jo.get(e),isVisible:(e,t)=>Lc(e,t||{}).visible}),[]);(0,B.useEffect)(()=>{if(!N)return;let e=e=>(e.preventDefault(),e.returnValue=``,``);return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[N]);let ne=l(({currentLocation:e,nextLocation:t})=>R.current?(R.current=!1,!1):N&&e.pathname!==t.pathname),re=(0,B.useRef)(ne);re.current=ne,(0,B.useEffect)(()=>{if(ne.state!==`blocked`)return;let e=!1;return(async()=>{let t=f?.utils?.showConfirm?await f.utils.showConfirm(`You have unsaved changes. Are you sure you want to leave?`,{title:`Unsaved Changes`,confirmText:`Discard Changes`,cancelText:`Keep Editing`,variant:`danger`}):window.confirm(`You have unsaved changes. Are you sure you want to leave?`);e||(t?re.current.proceed?.():re.current.reset?.())})(),()=>{e=!0}},[ne.state,f]),(0,B.useEffect)(()=>{e&&ie()},[e,t]);let ie=async()=>{try{N$.debug(`Loading editor data`,{schemaName:e,documentId:t}),w(!0),O(null);let n=await c.fetchQuery({queryKey:P$(e),queryFn:()=>W.getSchema(e),retry:!1});if(N$.debug(`Schema loaded`,{success:n.success,hasData:!!n.data}),!n.success||!n.data||!n.data.schema)throw Error(`Schema '${e}' not found`);let r=n.data.schema;if(N$.debug(`Schema loaded for editing`,{schemaName:e,hasFields:!!r.fields}),N$.debug(`Schema extracted`,{schemaName:r?.name,singleton:r?.singleton}),S(r),!g&&t){let n=await c.fetchQuery({queryKey:F$(e,t),queryFn:()=>W.getDocument(e,t),staleTime:0,retry:!1});if(N$.debug(`Document response received`,{success:n.success,hasData:!!n.data}),n.success&&n.data&&n.data.document){let e=n.data.document;y.load(e);let r=z(e);M(r),N$.debug(`Existing document loaded`,{documentId:t,state:r})}else{N$.warn(`Document not found, attempting auto-creation for singleton`,{schema:e,documentId:t});let n=ae(r);n.id=t,y.load(n),M(`draft`),N$.debug(`Singleton document initialized`,{documentId:t})}}else{let e=m?{...ae(r),...m}:ae(r);y.load(e),M(`draft`),N$.debug(`New document initialized`,{isDuplicate:!!m})}N$.info(`Editor data loaded successfully`,{schema:e,isNew:g})}catch(e){N$.error(`Failed to load editor data`,e),O(e instanceof Error?e.message:`Failed to load editor data`)}finally{w(!1)}},ae=t=>{let n={_type:e,_status:`draft`,_createdAt:new Date().toISOString(),_updatedAt:new Date().toISOString()};!n.title&&!n.name&&(n.title=n.id&&n.id!==`new`?I$(e,t):`New ${I$(e,t)}`);let r=e=>hc(e,e=>Jo.get(e));return t.fields&&(Array.isArray(t.fields)?t.fields.forEach(e=>{e.default!==void 0&&(n[e.name]=r(e))}):typeof t.fields==`object`&&Object.entries(t.fields).forEach(([e,t])=>{t.default!==void 0&&(n[e]=r({name:e,...t}))})),n},z=e=>e._status?e._status:e._state?e._state:e.status?e.status:e.published===!0?`published`:(e.published,`draft`),oe=(0,B.useCallback)(e=>{e&&typeof e==`object`&&Object.entries(e).forEach(([e,t])=>{y.setValue([e],t)})},[y.setValue]),se=(0,B.useCallback)(e=>{if(!x||e.length===0)return;let{current:t,errors:n}=y.getState(),r=y$(t,x,{...te,rootPath:e}),i=String(e[0]),a={};for(let[e,t]of Object.entries(n))e===i||e.startsWith(`${i}.`)||e.startsWith(`${i}[`)||(a[e]=t);Object.assign(a,r),y.setErrors(a)},[x,y.getState,y.setErrors,te]),ce=(0,B.useCallback)(e=>{I(e)},[]),le=(0,B.useCallback)(async n=>{if(!qo.canTransition(j,n)){N$.warn(`Invalid state transition`,{from:j,to:n});return}let r=n===`published`&&j!==`published`;if((r||n!==`published`&&j===`published`)&&!v){let e=o(r?`publish`:`unpublish`);h(o(`documentEditor.noPublishPermission`,{action:e}),`error`),N$.warn(`User lacks publish permission for state change`,{from:j,to:n,hasPublishPermission:v});return}try{y.setValue([`_status`],n),n===`published`?y.setValue([`publishedAt`],new Date().toISOString()):n===`draft`&&y.setValue([`publishedAt`],null),y.setValue([`_state`],void 0),y.setValue([`published`],void 0),M(n),N$.info(`Document state changed`,{schema:e,documentId:t,oldState:j,newState:n})}catch(e){N$.error(`Failed to change document state`,e),alert(`Failed to change document state`)}},[j,y.setValue,e,t,v,h,o]),ue=(0,B.useCallback)(async()=>{let n=y.getState().current;if(n&&x){if(!_){h(`You don't have permission to edit ${I$(e,x)}`,`error`);return}try{E(!0),O(null),y.setStatus(`saving`);let r=y$(n,x,te);if(y.setErrors(r),Object.keys(r).length>0){N$.warn(`Document validation failed - check inline field errors`,{errors:r}),h(Object.values(r).join(`, `),`error`),y.setStatus(`error`),E(!1);return}let a=fc(n,x,j,y.getState().initial),o;if(o=g?await W.createDocument(e,a):await W.updateDocument(e,t,a),o.success&&o.data){let n=o.data.document||o.data;N$.info(`Document saved successfully`,{schema:e,id:n.id||n._id,isNewDocument:g,savedDocumentData:n}),y.markSaved(n),c.invalidateQueries({queryKey:F$(e,t)}),h(`Saved`,`success`),i?.(n),g?(R.current=!0,s(`/content/${e}/${n.id||n._id}`)):N$.debug(`Updated existing document, refreshing UI state`)}else{let e=o.error?.message||`Failed to save document`;N$.error(`Save failed with API error`,{error:o.error,fullResponse:o,documentData:n}),y.setStatus(`error`),h(L$(e,o.error?.details),`error`)}}catch(e){N$.error(`Failed to save document`,e);let t=e instanceof jr?e.message:`Failed to save document`,n=e instanceof jr?e.details:void 0;y.setStatus(`error`),h(L$(t,n),`error`)}finally{E(!1)}}},[x,g,e,t,j,i,s,_,h,y.getState,y.setErrors,y.setStatus,y.markSaved,te]),de=(0,B.useCallback)(async()=>{(!N||await f?.utils?.showConfirm?.(`You have unsaved changes. Are you sure you want to cancel?`,{title:`Unsaved Changes`,confirmText:`Discard Changes`,cancelText:`Keep Editing`,variant:`danger`}))&&(R.current=!0,a?a():s(`/content/${e}`))},[N,a,s,e,f]),fe=(0,B.useMemo)(()=>({schema:x,document:b,documentState:j,currentMode:k,isNewDocument:g,hasUnsavedChanges:N,hasValidationErrors:F,errors:y.errors,isReadOnly:!_,hasPublishPermission:v,isMobileSidebarOpen:L,onToggleMobileSidebar:ee,loading:C,saving:T,error:D,onDocumentChange:oe,onFieldBlur:se,onStateChange:le,onModeChange:A,onSave:ue,onCancel:de,onValidationChange:ce}),[x,b,j,k,g,N,F,y.errors,_,v,L,C,T,D,oe,se,le,ue,de,ce]),pe=p?.loading===!0;return C||pe?(0,V.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:o(g?`documentEditor.loadingSchema`:`documentEditor.loadingDocument`)})]})}):D?(0,V.jsx)(`div`,{className:`h-full flex items-center justify-center`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`text-red-500 mb-4`,children:(0,V.jsx)(`h3`,{className:`text-lg font-medium`,children:o(`common.error`)})}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:D}),(0,V.jsx)(U,{onClick:de,children:o(`documentEditor.backToDocuments`)})]})}):(0,V.jsx)(Go,{value:fe,children:(0,V.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,V.jsx)(x$,{}),(0,V.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[k===`form`&&(0,V.jsx)(o$,{}),k===`preview`&&(0,V.jsx)(z$,{})]}),(0,V.jsx)(A$,{})]})]})})}function z$(){let{t:e}=H(`studio`),{document:t}=Ko();return(0,V.jsx)(`div`,{className:`flex-1 p-6 overflow-auto`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-4`,children:e(`documentEditor.documentPreview`)}),(0,V.jsx)(`pre`,{className:`text-sm text-gray-600 dark:text-gray-400 whitespace-pre-wrap`,children:JSON.stringify(t,null,2)})]})})}function B$({availableViews:e,currentView:t,onViewChange:n,searchQuery:r,onSearchChange:i,searchPlaceholder:a,availableFilters:o,activeFilters:s,onFilterChange:c,onClearFilters:l,availableSorts:u,currentSort:d,onSortChange:f,onCreateNew:p,createNewLabel:m,totalItems:h=0,selectedItems:g=0,bulkActions:_=[],onBulkAction:v}){let{t:y}=H(`studio`),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(!1),w=(0,B.useRef)(null),T=a||y(`nav.searchPlaceholder`),E=m||y(`common.create`),D=Object.values(s).filter(e=>e!=null&&e!==``).length,O=D>0;return(0,B.useEffect)(()=>{let e=e=>{w.current&&!w.current.contains(e.target)&&C(!1)};if(S)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[S]),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`div`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(ee,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.target.value),placeholder:T,className:`pl-10 pr-4 py-2 w-64 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm focus:ring-2 focus:ring-blue-500 focus:border-transparent`})]}),o.length>0&&(0,V.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>x(!b),className:wr(O&&`bg-blue-50 border-blue-200 text-blue-700 dark:bg-blue-900/20 dark:border-blue-800 dark:text-blue-300`),children:[(0,V.jsx)(Re,{className:`h-4 w-4 mr-2`}),y(`contentView.filters`),D>0&&(0,V.jsx)(`span`,{className:`ml-2 px-2 py-0.5 text-xs bg-blue-100 text-blue-700 dark:bg-blue-800 dark:text-blue-200 rounded-full`,children:D})]}),u.length>0&&(0,V.jsxs)(`div`,{ref:w,className:`relative`,children:[(0,V.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>C(!S),className:wr(d&&`bg-blue-50 border-blue-200 text-blue-700 dark:bg-blue-900/20 dark:border-blue-800 dark:text-blue-300`),children:[(0,V.jsx)(qe,{className:`h-4 w-4 mr-2`}),y(`contentView.sort`),d&&(0,V.jsx)(`span`,{className:`ml-2 text-xs`,children:u.find(e=>e.field===d.field)?.label||d.field})]}),S&&(0,V.jsx)(`div`,{className:`absolute top-full left-0 mt-1 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10`,children:(0,V.jsx)(`div`,{className:`py-1`,children:u.map(e=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`button`,{onClick:()=>{f(e.field,`asc`),C(!1)},className:wr(`w-full text-left px-4 py-2 text-sm text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700`,d?.field===e.field&&d?.direction===`asc`&&`bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300`),children:y(`contentView.sortAsc`,{label:e.label})}),(0,V.jsx)(`button`,{onClick:()=>{f(e.field,`desc`),C(!1)},className:wr(`w-full text-left px-4 py-2 text-sm text-gray-900 dark:text-gray-100 hover:bg-gray-50 dark:hover:bg-gray-700`,d?.field===e.field&&d?.direction===`desc`&&`bg-blue-50 text-blue-700 dark:bg-blue-900/20 dark:text-blue-300`),children:y(`contentView.sortDesc`,{label:e.label})})]},e.field))})})]}),O&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:l,className:`text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:y(`contentView.clearAll`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:g>0?(0,V.jsx)(`span`,{children:y(`contentView.selectedOfTotal`,{selected:g,total:h,count:g})}):(0,V.jsx)(`span`,{children:y(`contentView.itemsCount`,{count:h})})}),g>0&&_.length>0&&(0,V.jsx)(`div`,{className:`flex items-center space-x-2`,children:_.map(e=>(0,V.jsxs)(U,{size:`sm`,variant:(e.variant,`outline`),onClick:()=>v?.(e.id),disabled:e.disabled,className:wr(e.variant===`destructive`&&`text-red-600 hover:text-red-700 border-red-200 hover:border-red-300 dark:text-red-400 dark:border-red-800 dark:hover:border-red-700`),children:[e.icon&&(0,V.jsx)(e.icon,{className:`h-4 w-4 mr-2`}),e.label]},e.id))}),e.filter(e=>e.enabled).length>1&&(0,V.jsx)(`div`,{className:`flex items-center bg-gray-100 dark:bg-gray-700 rounded-lg p-1`,children:e.filter(e=>e.enabled).map(e=>(0,V.jsx)(`button`,{onClick:()=>n(e.type),className:wr(`p-2 rounded-md transition-colors`,t===e.type?`bg-white dark:bg-gray-600 text-blue-600 dark:text-blue-400 shadow-sm`:`text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-200`),title:e.title,children:(0,V.jsx)(e.icon,{className:`h-4 w-4`})},e.type))}),p&&(0,V.jsxs)(U,{onClick:p,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),E]})]})]})}),b&&o.length>0&&(0,V.jsx)(`div`,{className:`px-6 py-4 bg-gray-50 dark:bg-gray-900 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4`,children:o.map(e=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e.label}),e.type===`text`&&(0,V.jsx)(`input`,{type:`text`,value:s[e.id]||``,onChange:t=>c(e.id,t.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,placeholder:y(`contentView.filterBy`,{label:e.label.toLowerCase()})}),e.type===`select`&&(0,V.jsxs)(`select`,{value:s[e.id]||``,onChange:t=>c(e.id,t.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:``,children:y(`contentView.allLabel`,{label:e.label})}),e.options?.map(e=>(0,V.jsx)(`option`,{value:e.value,children:e.label},e.value))]}),e.type===`boolean`&&(0,V.jsxs)(`select`,{value:s[e.id]||``,onChange:t=>c(e.id,t.target.value===`true`||t.target.value!==`false`&&``),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:``,children:y(`contentView.all`)}),(0,V.jsx)(`option`,{value:`true`,children:y(`contentView.yes`)}),(0,V.jsx)(`option`,{value:`false`,children:y(`contentView.no`)})]}),e.type===`date`&&(0,V.jsx)(`input`,{type:`date`,value:s[e.id]||``,onChange:t=>c(e.id,t.target.value),className:`w-full px-3 py-2 text-sm border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`})]},e.id))})})]})}function V$({checked:e=!1,onChange:t,disabled:n=!1,id:r,className:i,indeterminate:a=!1,"aria-label":o,...s}){return(0,V.jsxs)(`div`,{className:`relative inline-flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:r,checked:e,onChange:e=>{t&&t(e.target.checked)},disabled:n,"aria-label":o,ref:e=>{e&&(e.indeterminate=a)},className:`sr-only`,...s}),(0,V.jsxs)(`div`,{className:wr(`h-4 w-4 rounded border-2 transition-all duration-200 relative cursor-pointer`,`focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-blue-500`,`border-gray-300 bg-white`,`dark:border-gray-600 dark:bg-gray-700`,!n&&`hover:border-gray-400 dark:hover:border-gray-500`,e&&`!border-blue-600 !bg-blue-600`,e&&`dark:!border-blue-600 dark:!bg-blue-600`,n&&`opacity-50 cursor-not-allowed`,i),onClick:r=>{!n&&t&&(r.preventDefault(),t(!e))},children:[e&&(0,V.jsx)(`svg`,{className:`absolute inset-0 w-4 h-4 pointer-events-none`,fill:`none`,viewBox:`0 0 24 24`,style:{stroke:`#ffffff`,strokeWidth:3},children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M5 13l4 4L19 7`})}),a&&!e&&(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`w-2 h-0.5 bg-white dark:bg-gray-300`})})]})]})}function H$(e,t){if(!e)return`Untitled`;if(t?.fields){let n=(Array.isArray(t.fields)?t.fields:Object.entries(t.fields).map(([e,t])=>({name:e,...t})))[0];if(n&&e[n.name]){let t=e[n.name];if(typeof t==`string`&&t.trim()&&!t.startsWith(`New `))return t}}return e.name&&!e.name.startsWith(`New `)?e.name:e.title&&!e.title.startsWith(`New `)?e.title:e.slug?e.slug:e.title||e.name||e.slug||`Untitled`}function U$(e,t){return t.split(`.`).reduce((e,t)=>e?.[t],e)}function W$({documents:e,columns:t,schemaName:n,loading:i=!1,selectedItems:a,onItemSelect:o,onSelectAll:s,sortField:c,sortDirection:l,onSort:u,onDocumentAction:d,canDelete:f}){let{t:p}=H(`studio`),m=r(),h=pa(),[g,_]=(0,B.useState)(null),[v,y]=(0,B.useState)(null),b=(0,B.useRef)(null),x=(0,B.useRef)(null),S=(0,B.useRef)(null),C=e.length>0&&a.length===e.length,w=a.length>0&&a.length<e.length;(0,B.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&(console.log(`Click outside dropdown detected, closing dropdown`),_(null))};if(g)return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[g]);let T=t=>{if(!t.sortable||!u)return;let n=t.key;t.key===`title`&&e&&e.length>0&&(n=e[0].name?`name`:`title`),u(n,c===n&&l===`asc`?`desc`:`asc`)},E=(e,t,n)=>{if(t.render)return t.render(e,n);if(t.key===`title`||t.key===`name`){let e=H$(n);if(e!==`Untitled`)return e}return e==null?(0,V.jsx)(`span`,{className:`text-gray-400`,children:`—`}):typeof e==`boolean`?(0,V.jsx)(`span`,{className:wr(`inline-flex px-2 py-1 text-xs font-semibold rounded-full`,e?`bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100`:`bg-gray-100 text-gray-800 dark:bg-gray-800 dark:text-gray-100`),children:p(e?`contentViews.yes`:`contentViews.no`)}):e instanceof Date||typeof e==`string`&&!isNaN(Date.parse(e))?new Date(e).toLocaleDateString():Array.isArray(e)?e.length>0?e.join(`, `):(0,V.jsx)(`span`,{className:`text-gray-400`,children:p(`contentViews.empty`)}):String(e)},D=e=>e.id||e._id;return i?(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:p(`contentViews.loadingDocuments`)})]})}):e.length===0?(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`p-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:p(`contentViews.noDocumentsFound`)})})}):(0,V.jsxs)(`div`,{ref:b,className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`overflow-x-auto overflow-y-visible`,children:(0,V.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-700`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-3 py-3 text-left w-8`,children:(0,V.jsx)(V$,{checked:C,indeterminate:w,onChange:s})}),t.map((e,t)=>(0,V.jsx)(`th`,{className:wr(`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider`,e.sortable&&`cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600`,e.width&&`w-${e.width}`,t===0&&`w-96`,t===1&&`w-24`,t===2&&`w-24`,t===3&&`w-24`),onClick:()=>T(e),children:(0,V.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,V.jsx)(`span`,{children:e.title}),e.sortable&&(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(Xe,{className:wr(`h-3 w-3 -mb-1`,c===e.key&&l===`asc`?`text-blue-600 dark:text-blue-400`:`text-gray-400`)}),(0,V.jsx)(ye,{className:wr(`h-3 w-3`,c===e.key&&l===`desc`?`text-blue-600 dark:text-blue-400`:`text-gray-400`)})]})]})},e.key)),(0,V.jsx)(`th`,{className:`px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider w-20`,children:p(`contentViews.actions`)})]})}),(0,V.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-gray-600`,children:e.map(e=>{let r=D(e),i=a.includes(r);return(0,V.jsxs)(`tr`,{className:wr(`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors`,i&&`bg-blue-50 dark:bg-blue-900/20`),children:[(0,V.jsx)(`td`,{className:`px-3 py-4 whitespace-nowrap`,children:(0,V.jsx)(V$,{checked:i,onChange:e=>o(r,e)})}),t.map(i=>{let a=U$(e,i.key),o=i===t[0];return(0,V.jsx)(`td`,{className:wr(`px-6 py-4`,o?`max-w-xs`:`whitespace-nowrap`),children:o?(0,V.jsxs)(`button`,{onClick:()=>m(`/content/${n}/${r}`),className:`text-left hover:text-blue-600 dark:hover:text-blue-400 transition-colors w-full`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,title:String(E(a,i,e)),children:E(a,i,e)}),e.slug&&(0,V.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400 truncate`,title:`/${e.slug}`,children:[`/`,e.slug]})]}):(0,V.jsx)(`div`,{className:`text-sm text-gray-900 dark:text-white`,children:E(a,i,e)})},i.key)}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-right text-sm font-medium`,children:(0,V.jsx)(`div`,{className:`relative`,children:(0,V.jsx)(`button`,{ref:S,onClick:e=>{if(g===r)_(null),y(null);else{let t=e.currentTarget.getBoundingClientRect(),n=t.bottom+window.scrollY+4,i=t.right+window.scrollX-192;t.bottom+200>window.innerHeight&&(n=t.top+window.scrollY-200-4),i<0&&(i=t.left+window.scrollX),y({top:n,left:i}),_(r)}},className:`p-1 rounded-full text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700`,children:(0,V.jsx)(ae,{className:`h-5 w-5`})})})})]},r)})})]})}),g&&v&&(0,Ht.createPortal)((0,V.jsx)(`div`,{ref:x,className:`absolute w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50`,style:{top:v.top,left:v.left},children:(0,V.jsxs)(`div`,{className:`py-1 flex flex-col`,children:[(0,V.jsx)(`button`,{onClick:()=>{m(`/content/${n}/${g}`),_(null),y(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:p(`contentViews.edit`)}),(0,V.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(g),_(null),y(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:p(`contentViews.copyId`)}),(0,V.jsx)(`button`,{onClick:()=>{d?.(g,`duplicate`),_(null),y(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:p(`contentViews.duplicate`)}),(()=>{let t=e.find(e=>(e._id||e.id)===g);return!f||t&&f(t)?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`hr`,{className:`my-1 border-gray-200 dark:border-gray-600`}),(0,V.jsx)(`button`,{onClick:async()=>{await h?.utils?.showConfirm?.(p(`contentViews.deleteConfirm`),{title:p(`contentViews.deleteTitle`),confirmText:p(`contentViews.confirmDelete`),cancelText:p(`common.cancel`),variant:`danger`})&&d?.(g,`delete`),_(null),y(null)},className:`w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:p(`contentViews.delete`)})]}):null})()]})}),document.body)]})}var G$=()=>[{key:`title`,title:`Title`,sortable:!0,render:(e,t)=>H$(t)},{key:`_status`,title:`Status`,sortable:!0,render:(e,t)=>{let n=e||`draft`;return(0,V.jsx)(`span`,{className:wr(`inline-flex px-2 py-1 text-xs font-semibold rounded-full`,n===`published`?`bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100`:`bg-yellow-100 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-100`),children:n.charAt(0).toUpperCase()+n.slice(1)})}},{key:`_createdAt`,title:`Created`,sortable:!0,render:e=>e?new Date(e).toLocaleDateString():`—`},{key:`_updatedAt`,title:`Updated`,sortable:!0,render:e=>e?new Date(e).toLocaleDateString():`—`}];function K$({documents:e,schemaName:t,loading:n=!1,selectedItems:i,onItemSelect:a,onDocumentAction:o,canDelete:s,cardSize:c=`medium`,columnsPerRow:l,subtitleField:u=`subtitle`,descriptionField:d=`description`,dateField:f=`_updatedAt`,authorField:p=`author`}){let{t:m}=H(`studio`),h=r(),g=pa(),[_,v]=(0,B.useState)(null),y=()=>{if(l)return`grid-cols-${l}`;switch(c){case`small`:return`grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6`;case`medium`:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`;case`large`:return`grid-cols-1 sm:grid-cols-2 lg:grid-cols-3`;default:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4`}},b=()=>{switch(c){case`small`:return`h-56`;case`medium`:return`h-72`;case`large`:return`h-80`;default:return`h-72`}},x=e=>e.id||e._id,S=e=>H$(e),C=e=>U$(e,u)||e.subtitle,w=e=>{let t=U$(e,d)||e.description||e.excerpt;if(typeof t==`string`){if(t.length>140){let e=t.substring(0,140),n=e.lastIndexOf(` `);return n>100?e.substring(0,n)+`...`:e+`...`}return t}return t},T=e=>{for(let t of[`featuredImage`,`image`,`thumbnail`,`cover`,`photo`,`mainImage`,`hero`]){let n=U$(e,t);if(n){if(n.asset?._ref||n._ref){let e=n.asset?._ref||n._ref;return console.log(`Found image reference in ${t}:`,e),W.getMediaUrl(e,`thumbnail`)}if(typeof n==`string`&&n.trim())return console.log(`Found direct image URL in ${t}:`,n),n;if(n?.url&&typeof n.url==`string`)return console.log(`Found image URL in ${t}.url:`,n.url),n.url;if(n?.src&&typeof n.src==`string`)return console.log(`Found image URL in ${t}.src:`,n.src),n.src}}return console.log(`No image found for document:`,e.title||e.name),null},E=e=>{let t=U$(e,f)||e._updatedAt||e._createdAt;return t?new Date(t).toLocaleDateString():null},D=e=>{let t=U$(e,p);return typeof t==`string`?t:t?.name?t.name:t?.title?t.title:null},O=e=>e.published||e._status===`published`?`bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100`:`bg-yellow-100 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-100`,k=e=>e.published||e._status===`published`?m(`documentEditor.published`):m(`documentEditor.draft`);return n?(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:m(`contentViews.loadingDocuments`)})]}):e.length===0?(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(pe,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:m(`contentViews.noDocumentsFound`)})]}):(0,V.jsx)(`div`,{className:wr(`grid gap-6`,y()),children:e.map(e=>{let n=x(e),r=i.includes(n),c=T(e),l=S(e),u=C(e),d=w(e),f=E(e),p=D(e);return(0,V.jsxs)(`div`,{className:wr(`bg-white dark:bg-gray-800 rounded-xl border border-gray-200 dark:border-gray-700 overflow-hidden transition-all duration-300 hover:shadow-xl hover:shadow-gray-200/50 dark:hover:shadow-gray-900/50 hover:-translate-y-1 group`,b(),r&&`ring-2 ring-blue-500 border-blue-500 shadow-lg`),children:[(0,V.jsx)(`div`,{className:`absolute top-3 left-3 z-10`,children:(0,V.jsx)(V$,{checked:r,onChange:e=>a(n,e),className:`bg-white/90 dark:bg-gray-700/90 backdrop-blur-sm`})}),(0,V.jsx)(`div`,{className:`absolute top-3 right-3 z-10`,children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`button`,{onClick:()=>v(_===n?null:n),className:`p-1 rounded-full text-white/80 hover:text-white hover:bg-black/20 backdrop-blur-sm bg-black/10 opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,V.jsx)(ae,{className:`h-5 w-5`})}),_===n&&(0,V.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg`,children:(0,V.jsxs)(`div`,{className:`py-1`,children:[(0,V.jsx)(`button`,{onClick:()=>{h(`/content/${t}/${n}`),v(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:m(`contentViews.edit`)}),(0,V.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(n),v(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:m(`contentViews.copyId`)}),(0,V.jsx)(`button`,{onClick:()=>{o?.(n,`duplicate`),v(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:m(`contentViews.duplicate`)}),(!s||s(e))&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`hr`,{className:`my-1 border-gray-200 dark:border-gray-600`}),(0,V.jsx)(`button`,{onClick:async()=>{await g?.utils?.showConfirm?.(m(`contentViews.deleteConfirm`),{title:m(`contentViews.deleteTitle`),confirmText:m(`contentViews.confirmDelete`),cancelText:m(`common.cancel`),variant:`danger`})&&o?.(n,`delete`),v(null)},className:`w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:m(`contentViews.delete`)})]})]})})]})}),(0,V.jsxs)(`button`,{onClick:()=>h(`/content/${t}/${n}`),className:`w-full h-full flex flex-col text-left`,children:[(0,V.jsxs)(`div`,{className:`flex-shrink-0 h-40 relative overflow-hidden`,children:[c?(0,V.jsx)(`div`,{className:`w-full h-full bg-cover bg-center bg-no-repeat`,style:{backgroundImage:`url(${c})`},children:(0,V.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-t from-black/60 via-black/20 to-transparent`})}):(0,V.jsx)(`div`,{className:`w-full h-full bg-gradient-to-br from-gray-100 to-gray-200 dark:from-gray-700 dark:to-gray-800 flex items-center justify-center`,children:(0,V.jsx)(pe,{className:`h-12 w-12 text-gray-400`})}),(0,V.jsx)(`div`,{className:`absolute top-3 left-3`,children:(0,V.jsx)(`span`,{className:wr(`inline-flex px-2 py-1 text-xs font-semibold rounded-full backdrop-blur-sm`,O(e)),children:k(e)})})]}),(0,V.jsxs)(`div`,{className:`flex-1 p-4 flex flex-col min-h-0`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-semibold text-gray-900 dark:text-white mb-2 leading-tight overflow-hidden`,style:{display:`-webkit-box`,WebkitLineClamp:2,WebkitBoxOrient:`vertical`},title:l,children:l}),u&&(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2 font-medium overflow-hidden whitespace-nowrap text-ellipsis`,title:u,children:u}),d&&(0,V.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-300 leading-relaxed mb-3 flex-1 overflow-hidden`,style:{display:`-webkit-box`,WebkitLineClamp:3,WebkitBoxOrient:`vertical`},title:d,children:d}),(0,V.jsx)(`div`,{className:`flex items-center justify-between text-xs text-gray-500 dark:text-gray-400 mt-auto pt-2 border-t border-gray-100 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`flex items-center space-x-3 min-w-0`,children:[p&&(0,V.jsxs)(`div`,{className:`flex items-center space-x-1 min-w-0`,children:[(0,V.jsx)(Ke,{className:`h-3 w-3 flex-shrink-0`}),(0,V.jsx)(`span`,{className:`truncate`,children:p})]}),f&&(0,V.jsxs)(`div`,{className:`flex items-center space-x-1 flex-shrink-0`,children:[(0,V.jsx)(Ge,{className:`h-3 w-3`}),(0,V.jsx)(`span`,{children:f})]})]})})]})]})]},n)})})}function q$({documents:e,columns:t,schemaName:n,loading:i=!1,selectedItems:a,onItemSelect:o,onSelectAll:s,sortField:c,sortDirection:l,onSort:u,onDocumentAction:d,canDelete:f,onColumnResize:p,onColumnVisibilityChange:m,density:h=`comfortable`}){let{t:g}=H(`studio`),_=r(),v=pa(),[y,b]=(0,B.useState)(null),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(null),T=(0,B.useRef)(null),E=e.length>0&&a.length===e.length,D=a.length>0&&a.length<e.length,O=t.filter(e=>e.visible!==!1);(0,B.useEffect)(()=>{let e=e=>{T.current&&!T.current.contains(e.target)&&(b(null),S(!1))};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[]);let k=()=>{switch(h){case`compact`:return`py-2`;case`comfortable`:return`py-3`;case`spacious`:return`py-4`;default:return`py-3`}},A=e=>{if(!e.sortable||!u)return;let t=c===e.key&&l===`asc`?`desc`:`asc`;u(e.key,t)},j=(e,t,n)=>{if(!p)return;w(e);let r=r=>{let i=r.clientX-t;p(e,Math.max(50,n+i))},i=()=>{w(null),document.removeEventListener(`mousemove`,r),document.removeEventListener(`mouseup`,i)};document.addEventListener(`mousemove`,r),document.addEventListener(`mouseup`,i)},M=(e,t,n)=>{if(t.render)return t.render(e,n);if(t.key===`title`||t.key===`name`){let e=H$(n);if(e!==`Untitled`)return e}return e==null?(0,V.jsx)(`span`,{className:`text-gray-400`,children:`—`}):typeof e==`boolean`?(0,V.jsx)(`span`,{className:wr(`inline-flex px-2 py-1 text-xs font-medium rounded-md`,e?`bg-green-100 text-green-700 dark:bg-green-900/30 dark:text-green-400`:`bg-gray-100 text-gray-700 dark:bg-gray-800 dark:text-gray-300`),children:g(e?`contentViews.yes`:`contentViews.no`)}):e instanceof Date||typeof e==`string`&&!isNaN(Date.parse(e))?new Date(e).toLocaleDateString():Array.isArray(e)?e.length>0?(0,V.jsxs)(`span`,{title:e.join(`, `),children:[e.slice(0,2).join(`, `),e.length>2?`...`:``]}):(0,V.jsx)(`span`,{className:`text-gray-400`,children:g(`contentViews.empty`)}):typeof e==`string`&&e.length>50?(0,V.jsxs)(`span`,{title:e,children:[e.substring(0,50),`...`]}):String(e)},N=e=>e.id||e._id;return i?(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:g(`contentViews.loadingDocuments`)})]})}):e.length===0?(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`p-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:g(`contentViews.noDocumentsFound`)})})}):(0,V.jsxs)(`div`,{ref:T,className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`px-4 py-2 bg-gray-50 dark:bg-gray-700/50 border-b border-gray-200 dark:border-gray-600 flex items-center justify-between`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:g(`contentViews.itemsCount`,{count:e.length})}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>S(!x),children:[(0,V.jsx)(Fe,{className:`h-4 w-4 mr-2`}),g(`contentViews.columns`)]}),x&&(0,V.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-64 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-10`,children:(0,V.jsxs)(`div`,{className:`p-3`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-3`,children:g(`contentViews.showHideColumns`)}),(0,V.jsx)(`div`,{className:`space-y-2`,children:t.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(V$,{checked:e.visible===!0,onChange:t=>m?.(e.key,t),className:`mr-2`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:e.title})]},e.key))})]})})]})]}),(0,V.jsx)(`div`,{className:`overflow-x-auto overflow-y-visible`,children:(0,V.jsxs)(`table`,{className:`w-full`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-700`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-4 py-3 text-left w-12`,children:(0,V.jsx)(V$,{checked:E,indeterminate:D,onChange:s})}),O.map(e=>(0,V.jsxs)(`th`,{className:wr(`px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider relative`,e.sortable&&`cursor-pointer hover:bg-gray-100 dark:hover:bg-gray-600`,C===e.key&&`bg-blue-50 dark:bg-blue-900/20`),style:{width:e.width,minWidth:e.minWidth||100},onClick:()=>A(e),children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[(0,V.jsx)(`span`,{children:e.title}),e.sortable&&(0,V.jsxs)(`div`,{className:`flex flex-col`,children:[(0,V.jsx)(Xe,{className:wr(`h-3 w-3 -mb-1`,c===e.key&&l===`asc`?`text-blue-600 dark:text-blue-400`:`text-gray-400`)}),(0,V.jsx)(ye,{className:wr(`h-3 w-3`,c===e.key&&l===`desc`?`text-blue-600 dark:text-blue-400`:`text-gray-400`)})]})]}),e.resizable&&p&&(0,V.jsx)(`div`,{className:`absolute right-0 top-0 w-2 h-full cursor-col-resize hover:bg-blue-500/20 group`,onMouseDown:t=>{t.preventDefault(),t.stopPropagation();let n=t.currentTarget.closest(`th`).getBoundingClientRect();j(e.key,t.clientX,n.width)},children:(0,V.jsx)(`div`,{className:`w-0.5 h-full bg-gray-300 dark:bg-gray-600 ml-auto group-hover:bg-blue-500`})})]},e.key)),(0,V.jsx)(`th`,{className:`px-4 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-300 uppercase tracking-wider w-20`,children:g(`contentViews.actions`)})]})}),(0,V.jsx)(`tbody`,{className:`divide-y divide-gray-200 dark:divide-gray-600`,children:e.map(e=>{let t=N(e),r=a.includes(t);return(0,V.jsxs)(`tr`,{className:wr(`hover:bg-gray-50 dark:hover:bg-gray-700 transition-colors`,r&&`bg-blue-50 dark:bg-blue-900/20`),children:[(0,V.jsx)(`td`,{className:wr(`px-4 whitespace-nowrap`,k()),children:(0,V.jsx)(V$,{checked:r,onChange:e=>o(t,e)})}),O.map((r,i)=>{let a=U$(e,r.key),o=i===0;return(0,V.jsx)(`td`,{className:wr(`px-4 whitespace-nowrap`,k()),style:{width:r.width,minWidth:r.minWidth||100},children:o?(0,V.jsxs)(`button`,{onClick:()=>_(`/content/${n}/${t}`),className:`text-left hover:text-blue-600 dark:hover:text-blue-400 transition-colors`,children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:M(a,r,e)}),e.slug&&(0,V.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[`/`,e.slug]})]}):(0,V.jsx)(`div`,{className:`text-sm text-gray-900 dark:text-white`,children:M(a,r,e)})},r.key)}),(0,V.jsx)(`td`,{className:wr(`px-4 whitespace-nowrap text-right text-sm font-medium`,k()),children:(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(`button`,{onClick:()=>b(y===t?null:t),className:`p-1 rounded-full text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700`,children:(0,V.jsx)(ae,{className:`h-5 w-5`})}),y===t&&(0,V.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 rounded-lg shadow-lg z-50 min-w-max`,children:(0,V.jsxs)(`div`,{className:`py-1`,children:[(0,V.jsx)(`button`,{onClick:()=>{_(`/content/${n}/${t}`),b(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:g(`contentViews.edit`)}),(0,V.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(t),b(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:g(`contentViews.copyId`)}),(0,V.jsx)(`button`,{onClick:()=>{d?.(t,`duplicate`),b(null)},className:`w-full text-left px-4 py-2 text-sm text-gray-700 dark:text-gray-300 hover:bg-gray-50 dark:hover:bg-gray-700`,children:g(`contentViews.duplicate`)}),(!f||f(e))&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`hr`,{className:`my-1 border-gray-200 dark:border-gray-600`}),(0,V.jsx)(`button`,{onClick:async()=>{await v?.utils?.showConfirm?.(g(`contentViews.deleteConfirm`),{title:g(`contentViews.deleteTitle`),confirmText:g(`contentViews.confirmDelete`),cancelText:g(`common.cancel`),variant:`danger`})&&d?.(t,`delete`),b(null)},className:`w-full text-left px-4 py-2 text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-900/20`,children:g(`contentViews.delete`)})]})]})})]})})]},t)})})]})})]})}function J$({currentPage:e,totalPages:t,pageSize:n,totalItems:r,onPageChange:i,onPageSizeChange:a,showPageSizeSelector:o=!0,pageSizeOptions:s=[10,25,50,100],showFirstLast:c=!0,maxVisiblePages:l=7}){let{t:u}=H(`studio`),d=(e-1)*n+1,f=Math.min(e*n,r),p=(()=>{let n=[];if(t<=l)for(let e=1;e<=t;e++)n.push(e);else{n.push(1);let r=Math.floor(l/2)-1,i=Math.max(2,e-r),a=Math.min(t-1,e+r);e<=r+2&&(a=Math.min(t-1,l-1)),e>=t-r-1&&(i=Math.max(2,t-l+2)),i>2&&n.push(`...`);for(let e=i;e<=a;e++)n.push(e);a<t-1&&n.push(`...`),t>1&&n.push(t)}return n})();return t<=1&&!o?null:(0,V.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-3 bg-white dark:bg-gray-800 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-6`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:u(`pagination.showing`,{start:d,end:f,total:r})}),o&&a&&(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(`label`,{className:`text-sm text-gray-700 dark:text-gray-300`,children:u(`pagination.show`)}),(0,V.jsx)(`select`,{value:n,onChange:e=>a(Number(e.target.value)),className:`px-3 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-blue-500 focus:border-transparent`,children:s.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))})]})]}),t>1&&(0,V.jsxs)(`div`,{className:`flex items-center space-x-1`,children:[c&&(0,V.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>i(1),disabled:e===1,className:`p-2`,title:u(`pagination.firstPage`),children:(0,V.jsx)(fe,{className:`h-4 w-4`})}),(0,V.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>i(e-1),disabled:e===1,className:`p-2`,title:u(`pagination.previousPage`),children:(0,V.jsx)(be,{className:`h-4 w-4`})}),(0,V.jsx)(`div`,{className:`flex items-center space-x-1`,children:p.map((t,n)=>(0,V.jsx)(`div`,{children:t===`...`?(0,V.jsx)(`span`,{className:`px-3 py-2 text-sm text-gray-500 dark:text-gray-400`,children:`...`}):(0,V.jsx)(U,{variant:e===t?`primary`:`outline`,size:`sm`,onClick:()=>i(t),className:wr(`min-w-[2.5rem] px-3 py-2`,e===t&&`bg-blue-600 text-white border-blue-600 hover:bg-blue-700`),children:t})},n))}),(0,V.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>i(e+1),disabled:e===t,className:`p-2`,title:u(`pagination.nextPage`),children:(0,V.jsx)(z,{className:`h-4 w-4`})}),c&&(0,V.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>i(t),disabled:e===t,className:`p-2`,title:u(`pagination.lastPage`),children:(0,V.jsx)(xe,{className:`h-4 w-4`})})]})]})}function Y$({isOpen:e,onClose:t,onConfirm:n,selectedCount:r,loading:i=!1}){let{t:a}=H(`studio`),[o,s]=(0,B.useState)(`published`),c=[{value:`draft`,label:a(`changeStatus.draft`),description:a(`changeStatus.draftDesc`)},{value:`published`,label:a(`changeStatus.published`),description:a(`changeStatus.publishedDesc`)},{value:`archived`,label:a(`changeStatus.archived`),description:a(`changeStatus.archivedDesc`)}];return(0,V.jsxs)(ia,{open:e,onClose:t,variant:`center`,size:`sm`,title:a(`changeStatus.title`),children:[(0,V.jsxs)(ia.Body,{children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:a(`changeStatus.selectStatus`,{count:r})}),(0,V.jsx)(`div`,{className:`space-y-2`,children:c.map(e=>(0,V.jsxs)(`label`,{className:wr(`flex items-start p-4 border-2 rounded-lg cursor-pointer transition-all`,o===e.value?`border-blue-500 bg-blue-50 dark:bg-blue-900/20`:`border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600`),children:[(0,V.jsx)(`input`,{type:`radio`,name:`status`,value:e.value,checked:o===e.value,onChange:e=>s(e.target.value),className:`mt-1 h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300`}),(0,V.jsxs)(`div`,{className:`ml-3 flex-1`,children:[(0,V.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-white`,children:e.label}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e.description})]})]},e.value))})]}),(0,V.jsxs)(ia.Footer,{children:[(0,V.jsx)(U,{variant:`outline`,onClick:t,disabled:i,children:a(`common.cancel`)}),(0,V.jsx)(U,{onClick:async()=>{await n(o)},disabled:i,children:i?a(`changeStatus.updating`):a(`changeStatus.updateDocument`,{count:r})})]})]})}var X$=Fr(`ContentPage`);function Z$(e){return e?{article:`Article`,author:`Author`,category:`Category`,homePage:`Home Page`,post:`Post`}[e]||e.charAt(0).toUpperCase()+e.slice(1):`Document`}function Q$(){let{schemaName:e,documentId:t}=s(),n=r(),i=va(e||``);if(Uo(),t)return t===`new`&&ba(i.item)?(0,V.jsx)(n1,{schemaName:e}):(0,V.jsx)(R$,{schemaName:e,documentId:t,onCancel:()=>n(`/content/${e}`)});if(e){if(i.item?.type===`singleton`){let t=i.item.documentId||e;return(0,V.jsx)(e1,{schemaName:e,documentId:t,autoCreate:!1,onCancel:()=>n(`/content`)})}return(0,V.jsx)($$,{schemaName:e},e)}return(0,V.jsx)(t1,{})}function $$({schemaName:e}){let t=r(),{t:n}=H(`studio`),i=pa(),a=va(e),o=ci(),s=o.hasSchemaPermission(e,`publish`),c=t=>o.canDeleteDocument(e,t),[l,u]=(0,B.useState)([]),[d,f]=(0,B.useState)(!0),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)([]),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(()=>zr.getContentView(e,`list`)),[C,w]=(0,B.useState)(``),[T,E]=(0,B.useState)({}),[D,O]=(0,B.useState)(null),[k,A]=(0,B.useState)(()=>{let t=zr.getColumnVisibility(e,{}),n=G$(),r={...t};return n.forEach(e=>{r[e.key]===void 0&&(r[e.key]=!0)}),r}),[j]=(0,B.useState)(()=>zr.getGridSettings(e,{cardSize:`medium`,columnsPerRow:null})),[M]=(0,B.useState)(()=>zr.getTableSettings(e,{density:`comfortable`,columnWidths:{}})),[N,P]=(0,B.useState)(1),[F,I]=(0,B.useState)(25),[L,ee]=(0,B.useState)(0);(0,B.useEffect)(()=>{R()},[e,T,D,C,N,F]),(0,B.useEffect)(()=>{P(1)},[T,D,C]);let R=async()=>{try{f(!0),m(null);let t={page:N,limit:F,search:C||void 0,filter:Object.keys(T).length>0?T:void 0,sort:D?`${D.direction===`desc`?`-`:``}${D.field}`:void 0};X$.info(`Loading documents with filters`,{schemaName:e,activeFilters:T,queryParams:t});let n=await W.listDocuments(e,t);if(n.success&&n.data?.documents){u(n.data.documents),ee(n.data.pagination?.total||n.data.documents.length);let t=n.data.documents.reduce((e,t)=>{let n=t._status||`undefined`;return e[n]=(e[n]||0)+1,e},{});X$.info(`Documents loaded`,{schema:e,count:n.data.documents.length,total:n.data.pagination?.total,page:N,statusBreakdown:t,sampleStatuses:n.data.documents.slice(0,3).map(e=>({id:e.id||e._id,title:e.title,_status:e._status,published:e.published}))})}else u([]),ee(0)}catch(e){X$.error(`Failed to load documents`,e),m(e instanceof jr?e.message:`Failed to load documents`),u([])}finally{f(!1)}},te=async(r,a)=>{try{switch(a){case`delete`:if(!await i?.utils?.showConfirm?.(n(`content.confirmDelete`),{title:n(`content.deleteDocument`),confirmText:n(`common.delete`),cancelText:n(`common.cancel`),variant:`danger`}))return;await W.deleteDocument(e,r),X$.info(`Document deleted`,{schema:e,id:r}),await R(),g(e=>e.filter(e=>e!==r));break;case`duplicate`:let o=await W.getDocument(e,r);if(o.success&&o.data){let n={...o.data};delete n._id,delete n.id,delete n._createdAt,delete n._updatedAt,delete n._revision,delete n._collection,n._status=`draft`,n.name?n.name=`${n.name} (Copy)`:n.title&&=`${n.title} (Copy)`,delete n.slug,t(`/content/${e}/new`,{state:{duplicateData:n}})}break;default:X$.warn(`Unknown document action`,{action:a,documentId:r})}}catch(e){X$.error(`Document action failed`,{action:a,documentId:r,error:e}),alert(`Failed to ${a} document: ${e instanceof jr?e.message:`Unknown error`}`)}},ne=(e,t)=>{g(n=>t?[...n,e]:n.filter(t=>t!==e))},re=e=>{g(e?l.map(e=>e.id||e._id):[])},ie=(e,t)=>{E(n=>({...n,[e]:t}))},ae=()=>{E({}),w(``)},z=(e,t)=>{O({field:e,direction:t})},oe=t=>{S(t),zr.setContentView(e,t)},se=(t,n)=>{let r={...k,[t]:n};A(r),zr.setColumnVisibility(e,r)},ce=e=>e===`draft`||e===`published`||e===`archived`,le=async t=>{if(!ce(t))return;let r=h.map(e=>l.find(t=>t._id===e)?._status),a=t===`published`&&r.some(e=>e!==`published`),o=t!==`published`&&r.some(e=>e===`published`);if((a||o)&&!s){let e=n(a?`publish`:`unpublish`);i?.utils?.showToast?.(n(`content.noPublishPermission`,{action:e})||`You don't have permission to ${e} documents`,`error`),X$.warn(`User lacks publish permission for bulk status change`,{newStatus:t,isPublishing:a,isUnpublishing:o,hasPublishPermission:s});return}try{b(!0),await Promise.all(h.map(n=>W.updateDocument(e,n,{_status:t}))),X$.info(`Bulk status change completed`,{count:h.length,newStatus:t}),v(!1),g([]),await R()}catch(e){X$.error(`Bulk status change failed`,e),alert(`Failed to update document status: ${e instanceof jr?e.message:`Unknown error`}`)}finally{b(!1)}},ue=[{type:`list`,title:n(`content.views.list`),icon:we,enabled:!0},{type:`grid`,title:n(`content.views.grid`),icon:pe,enabled:!0},{type:`table`,title:n(`content.views.table`),icon:lt,enabled:!0}],de=[{id:`_status`,label:n(`content.filters.status`),field:`_status`,type:`select`,options:[{label:n(`content.filters.draft`),value:`draft`},{label:n(`content.filters.published`),value:`published`},{label:n(`content.filters.archived`),value:`archived`}]}],fe=[{field:l&&l.length>0&&l[0].name?`name`:`title`,direction:`asc`,label:n(`content.sort.title`)},{field:`_createdAt`,direction:`desc`,label:n(`content.sort.createdDate`)},{field:`_updatedAt`,direction:`desc`,label:n(`content.sort.updatedDate`)}],me=[...s?[{id:`change-status`,label:n(`content.bulkActions.changeStatus`),icon:ke}]:[],{id:`delete`,label:n(`content.bulkActions.delete`),icon:Be,variant:`destructive`}],he=G$().map(e=>e.key===`_status`?{...e,render:e=>{let t=(e||`draft`)===`published`;return(0,V.jsx)(`span`,{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${t?`bg-green-100 text-green-800 dark:bg-green-800 dark:text-green-100`:`bg-yellow-100 text-yellow-800 dark:bg-yellow-800 dark:text-yellow-100`}`,children:n(t?`documentEditor.published`:`documentEditor.draft`)})}}:e);return p?(0,V.jsx)(`div`,{className:`p-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`text-red-500 mb-4`,children:(0,V.jsx)(`h3`,{className:`text-lg font-medium`,children:n(`content.error.loadingDocuments`)})}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:p}),(0,V.jsx)(U,{onClick:R,children:n(`content.tryAgain`)})]})}):(0,V.jsxs)(`div`,{className:`h-full flex flex-col`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 px-6 py-4 bg-white dark:bg-gray-800 border-b border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:a?.item?.title||`${Z$(e)} Documents`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:a?.item?.type===`singleton`?n(`content.viewExisting`):n(`content.manageDocuments`)})]}),!ba(a?.item)&&(0,V.jsxs)(U,{onClick:()=>t(`/content/${e}/new`),children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),n(`content.create`,{type:Z$(e)})]})]})}),(0,V.jsx)(B$,{availableViews:ue,currentView:x,onViewChange:oe,searchQuery:C,onSearchChange:w,searchPlaceholder:n(`content.search`,{type:e}),availableFilters:de,activeFilters:T,onFilterChange:ie,onClearFilters:ae,availableSorts:fe,currentSort:D,onSortChange:z,totalItems:L,selectedItems:h.length,bulkActions:me,onBulkAction:async t=>{if(h.length!==0)switch(t){case`change-status`:v(!0);break;case`duplicate`:try{b(!0);for(let e of h)await te(e,`duplicate`);g([]),await R()}catch(e){X$.error(`Bulk duplicate failed`,e),alert(`Failed to duplicate documents: ${e instanceof jr?e.message:`Unknown error`}`)}finally{b(!1)}break;case`delete`:if(!await i?.utils?.showConfirm?.(n(`content.confirmBulkDelete`,{count:h.length}),{title:n(`content.deleteDocument`),confirmText:n(`content.deleteAll`),cancelText:n(`common.cancel`),variant:`danger`}))return;try{b(!0),await Promise.all(h.map(t=>W.deleteDocument(e,t))),g([]),await R()}catch(e){X$.error(`Bulk delete failed`,e),alert(`Failed to delete documents: ${e instanceof jr?e.message:`Unknown error`}`)}finally{b(!1)}}}}),(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col overflow-hidden`,children:[(0,V.jsxs)(`div`,{className:`flex-1 overflow-auto p-6`,children:[x===`list`&&(0,V.jsx)(W$,{documents:l,columns:he,schemaName:e,loading:d,selectedItems:h,onItemSelect:ne,onSelectAll:re,sortField:D?.field,sortDirection:D?.direction,onSort:z,onDocumentAction:te,canDelete:c}),x===`grid`&&(0,V.jsx)(K$,{documents:l,schemaName:e,loading:d,selectedItems:h,onItemSelect:ne,onDocumentAction:te,canDelete:c,cardSize:j?.cardSize||`medium`,columnsPerRow:j?.columnsPerRow||void 0}),x===`table`&&(0,V.jsx)(q$,{documents:l,columns:he.map(e=>({key:e.key,title:e.title,sortable:e.sortable,render:e.render,visible:k[e.key]===!0,resizable:!0,minWidth:100})),schemaName:e,loading:d,selectedItems:h,onItemSelect:ne,onSelectAll:re,sortField:D?.field,sortDirection:D?.direction,onSort:z,onDocumentAction:te,canDelete:c,onColumnVisibilityChange:se,density:M?.density||`comfortable`})]}),L>0&&(0,V.jsx)(J$,{currentPage:N,totalPages:Math.ceil(L/F),pageSize:F,totalItems:L,onPageChange:P,onPageSizeChange:e=>{I(e),P(1)},showPageSizeSelector:!0,pageSizeOptions:[10,25,50,100],showFirstLast:!0})]}),(0,V.jsx)(Y$,{isOpen:_,onClose:()=>v(!1),onConfirm:le,selectedCount:h.length,loading:y})]})}function e1({schemaName:e,documentId:t,autoCreate:n,onCancel:i}){let[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(null),l=r(),{t:u}=H(`studio`);(0,B.useEffect)(()=>{d()},[e,t]);let d=async()=>{try{o(!0),c(null);let r=await W.getDocument(e,t);r.success&&r.data?l(`/content/${e}/${t}`,{replace:!0}):n?await f():c(`Document '${t}' not found. Only existing documents can be viewed.`)}catch(e){X$.error(`Failed to check singleton document`,e),n&&e instanceof jr&&e.status===404?await f():c(e instanceof jr?`Document not found. Only existing documents can be viewed.`:`Failed to load document`)}finally{o(!1)}},f=async()=>{try{X$.info(`Auto-creating singleton document`,{schemaName:e,documentId:t}),(await W.createDocument(e,{id:t,title:`${e} Configuration`,_type:e})).success?(X$.info(`Singleton document created`,{schemaName:e,documentId:t}),l(`/content/${e}/${t}`,{replace:!0})):c(`Failed to create singleton document`)}catch(e){X$.error(`Failed to create singleton document`,e),c(e instanceof jr?e.message:`Failed to create singleton document`)}};return a?(0,V.jsx)(`div`,{className:`p-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:u(`content.loadingSingleton`)})]})}):s?(0,V.jsx)(`div`,{className:`p-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsxs)(`div`,{className:`text-amber-500 mb-4`,children:[(0,V.jsx)(pe,{className:`h-12 w-12 mx-auto mb-2`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium`,children:u(`content.error.documentNotFound`)})]}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:s}),(0,V.jsxs)(`div`,{className:`flex justify-center space-x-4`,children:[(0,V.jsx)(U,{onClick:d,children:u(`content.tryAgain`)}),(0,V.jsx)(U,{variant:`outline`,onClick:i,children:u(`content.backToContent`)})]})]})}):(0,V.jsx)(R$,{schemaName:e,documentId:t,onCancel:i})}function t1(){let e=r(),{t}=H(`studio`),[n,i]=(0,B.useState)([]),[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(null);(0,B.useEffect)(()=>{l()},[]);let l=async()=>{try{o(!0),c(null);let e=await W.get(`/collections`);e.success&&e.data?.collections?(i(e.data.collections),X$.info(`Collections loaded`,{count:e.data.collections.length})):c(`No collections found`)}catch(e){X$.error(`Failed to load collections`,e),c(e instanceof jr?e.message:`Failed to load collections`)}finally{o(!1)}};return a?(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:t(`content.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:t(`content.subtitle`)})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:t(`content.loading`)})]})]}):s?(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:t(`content.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:t(`content.subtitle`)})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsxs)(`div`,{className:`text-red-500 mb-4`,children:[(0,V.jsx)(pe,{className:`h-12 w-12 mx-auto mb-2`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium`,children:t(`content.error.loadingTypes`)})]}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:s}),(0,V.jsx)(U,{onClick:l,children:t(`content.tryAgain`)})]})]}):n.length===0?(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:t(`content.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:t(`content.subtitle`)})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(pe,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-2`,children:t(`content.noTypes`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:t(`content.noTypesDescription`)}),(0,V.jsx)(U,{onClick:l,children:t(`content.refresh`)})]})]}):(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:t(`content.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:t(`content.subtitle`)})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6`,children:n.map(n=>(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 hover:shadow-md transition-shadow`,children:(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center mb-4`,children:[(0,V.jsx)(pe,{className:`h-8 w-8 text-blue-600 mr-3`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white`,children:n.title}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n.name})]})]}),(0,V.jsx)(`div`,{className:`flex space-x-2`,children:(0,V.jsx)(U,{size:`sm`,onClick:()=>e(`/content/${n.name}`),children:t(`content.viewDocuments`)})})]})},n.name))})]})}function n1({schemaName:e}){let t=r(),{t:n}=H(`studio`);return(0,B.useEffect)(()=>{t(`/content/${e}`,{replace:!0})},[t,e]),(0,V.jsx)(`div`,{className:`p-6`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(`div`,{className:`animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:n(`content.redirecting`)})]})})}function r1(e,t){switch(t){case`images`:return e.contentType.startsWith(`image/`);case`videos`:return e.contentType.startsWith(`video/`);case`audio`:return e.contentType.startsWith(`audio/`);case`documents`:return e.contentType.includes(`pdf`)||e.contentType.includes(`text/`)||e.contentType.includes(`application/`);case`archives`:return e.contentType.includes(`zip`)||e.contentType.includes(`rar`)||e.contentType.includes(`tar`);default:return!0}}function i1(e,t){return!!(e.filename.toLowerCase().includes(t)||e.metadata?.title?.toLowerCase().includes(t)||e.metadata?.alt?.toLowerCase().includes(t)||e.metadata?.author?.toLowerCase().includes(t)||e.metadata?.credit?.toLowerCase().includes(t)||e.metadata?.tags?.some(e=>e.toLowerCase().includes(t)))}function a1(e,t,n,r,i){let a=e;if(t!==`all`&&(a=a.filter(e=>r1(e,t))),n.trim()){let e=n.toLowerCase();a=a.filter(t=>i1(t,e))}return a=[...a].sort((e,t)=>{let n=0;switch(r){case`date`:n=new Date(t._createdAt).getTime()-new Date(e._createdAt).getTime();break;case`name`:n=e.filename.localeCompare(t.filename);break;case`size`:n=t.size-e.size}return i===`asc`?-n:n}),a}function o1(e){return e.startsWith(`image/`)?at:e.startsWith(`video/`)?Ie:e.startsWith(`audio/`)?Je:e.includes(`zip`)||e.includes(`rar`)||e.includes(`tar`)?Ue:se}var s1={all:se,images:at,videos:Ie,audio:Je,documents:se,archives:Ue};function c1(e,t){return t===`all`?e.length:e.filter(e=>r1(e,t)).length}function l1(e){return e.metadata?.imageVariants?Object.keys(e.metadata.imageVariants).length:0}function u1(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(()=>{try{let e=localStorage.getItem(`trokky-media-view-mode`);return e===`list`||e===`grid`?e:`grid`}catch{return`grid`}}),[c,l]=(0,B.useState)(``),[u,d]=(0,B.useState)(`all`),[f,p]=(0,B.useState)(1),[,m]=(0,B.useState)(0),[h,g]=(0,B.useState)(()=>{let e=[28,56,84,112];try{let t=localStorage.getItem(`trokky-media-items-per-page`),n=t?parseInt(t,10):56;return e.includes(n)?n:56}catch{return 56}}),[_,v]=(0,B.useState)(`date`),[y,b]=(0,B.useState)(`desc`),x=(0,B.useRef)(!1),S=Fr(`MediaPage`),C=(0,B.useCallback)(e=>{s(e);try{localStorage.setItem(`trokky-media-view-mode`,e)}catch(e){S.warn(`Failed to save view mode to localStorage:`,e)}},[S]),w=(0,B.useCallback)(e=>{g(e),p(1);try{localStorage.setItem(`trokky-media-items-per-page`,String(e))}catch{}},[]),T=(0,B.useCallback)(async()=>{if(!x.current){x.current=!0,a(!0);try{if(!W.hasFeature(`media`)){S.info(`Media feature not available, using empty state`),t([]);return}let e=await W.getMedia({limit:1e4});t(e.data||[]),m(e.meta?.total||e.data?.length||0),S.info(`Media files loaded successfully`,{count:e.data?.length||0,total:e.meta?.total})}catch(e){S.error(`Failed to load media files:`,e),t([])}finally{x.current=!1,a(!1)}}},[W]);(0,B.useEffect)(()=>{r(a1(e,u,c,_,y)),p(1)},[e,u,c,_,y]);let E=Math.ceil(n.length/h),D=(f-1)*h,O=D+h,k=n.slice(D,O);return(0,B.useEffect)(()=>{T()},[]),{mediaFiles:e,setMediaFiles:t,filteredFiles:n,isUploading:i,setIsUploading:a,viewMode:o,updateViewMode:C,searchQuery:c,setSearchQuery:l,selectedType:u,setSelectedType:d,currentPage:f,setCurrentPage:p,itemsPerPage:h,updateItemsPerPage:w,sortBy:_,setSortBy:v,sortDirection:y,setSortDirection:b,totalPages:E,startIndex:D,endIndex:O,paginatedFiles:k,loadMediaFiles:T,logger:S}}function d1({filteredFiles:e,selectedType:t,searchQuery:n,canDelete:r,isViewerOpen:i,isEditModalOpen:a,isDeleteModalOpen:o,isBulkDeleteModalOpen:s,setIsBulkDeleteModalOpen:c}){let[l,u]=(0,B.useState)(new Set),[d,f]=(0,B.useState)(null),p=(0,B.useCallback)((t,n,r=!1)=>{u(i=>{let a=new Set(i);if(r&&d&&n){let n=e.findIndex(e=>e.id===t),r=e.findIndex(e=>e.id===d);if(n!==-1&&r!==-1){let t=Math.min(n,r),i=Math.max(n,r);for(let n=t;n<=i;n++)a.add(e[n].id)}}else n?a.add(t):a.delete(t);return a}),n&&f(t)},[e,d]),m=(0,B.useCallback)(()=>{l.size===e.length?u(new Set):u(new Set(e.map(e=>e.id)))},[e,l.size]),h=(0,B.useCallback)(()=>{u(new Set),f(null)},[]),g=(0,B.useCallback)(()=>{l.size!==0&&r&&c(!0)},[l.size,r]);return(0,B.useEffect)(()=>{h()},[t,n,h]),(0,B.useEffect)(()=>{if(i||a||o||s)return;let e=e=>{let t=e.target;if(!(t.tagName===`INPUT`||t.tagName===`TEXTAREA`||t.isContentEditable)){if((e.metaKey||e.ctrlKey)&&e.key===`a`){e.preventDefault(),m();return}if(e.key===`Escape`&&l.size>0){e.preventDefault(),h();return}if((e.key===`Delete`||e.key===`Backspace`)&&l.size>0&&r){e.preventDefault(),g();return}}};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i,a,o,s,l.size,r,m,h,g]),{selectedIds:l,handleItemSelect:p,handleSelectAll:m,clearSelection:h,handleBulkDelete:g}}function f1({canUpload:e,logger:t,showToast:n,setIsUploading:r,loadMediaFiles:i}){let[a,o]=(0,B.useState)(!1),s=(0,B.useRef)(null),c=t=>{t.preventDefault(),e&&W.hasFeature(`media`)&&o(!0)},l=e=>{e.preventDefault();let t=e.currentTarget.getBoundingClientRect(),n=e.clientX,r=e.clientY;(n<t.left||n>t.right||r<t.top||r>t.bottom)&&o(!1)},u=async t=>{if(t.preventDefault(),o(!1),!e||!W.hasFeature(`media`))return;let n=Array.from(t.dataTransfer.files);n.length>0&&await d(n)},d=async a=>{if(!e){n(`You do not have permission to upload files`,`error`);return}if(!W.hasFeature(`media`)){t.warn(`Upload attempted but media feature not available`),n(`Media upload feature is not available`,`error`);return}r(!0);try{for(let e of a)await W.uploadMedia(e);await i();let e=a.length===1?`Successfully uploaded "${a[0].name}"`:`Successfully uploaded ${a.length} files`;t.info(e),n(a.length===1?`Uploaded`:`${a.length} files uploaded`,`success`)}catch(e){let t=`Upload failed. Please try again.`;e instanceof Error&&(t=e.message.includes(`File size exceeds`)?`File size exceeds 100MB limit. Please choose a smaller file.`:e.message.includes(`File type`)&&e.message.includes(`not allowed`)?`File type not supported. Please choose a different file format.`:e.message.includes(`network`)||e.message.includes(`fetch`)?`Network error. Please check your connection and try again.`:e.message),n(t,`error`)}finally{r(!1)}};return{isDragging:a,fileInputRef:s,handleDragOver:c,handleDragLeave:l,handleDrop:u,handleFileInputChange:e=>{let t=Array.from(e.target.files||[]);t.length>0&&d(t)},handleUploadClick:()=>{if(!e){n(`You do not have permission to upload files`,`error`);return}if(!W.hasFeature(`media`)){t.warn(`Upload button clicked but media feature not available`),n(`Media upload feature is not available`,`error`);return}s.current?.click()}}}function p1({canEdit:e,canDelete:t,logger:n,loadMediaFiles:r,setMediaFiles:i,selectedFile:a,setSelectedFile:o,editingFile:s,setEditingFile:c,isViewerOpen:l,setIsViewerOpen:u,setIsEditModalOpen:d,setIsDeleteModalOpen:f,setIsBulkDeleteModalOpen:p,selectedIds:m,clearSelection:h,isDeleting:g,setIsDeleting:_,showToast:v}){return{handleEdit:async e=>{try{let t=await W.getMediaFile(e.id);t.success&&t.data?.file?c({...t.data.file}):c({...e}),d(!0)}catch(t){n.error(`Failed to fetch latest file data for editing:`,t),c({...e}),d(!0)}},handleDelete:e=>{c(e),f(!0)},confirmDelete:async()=>{if(s&&t){if(!W.hasFeature(`media`)){n.warn(`Delete attempted but media feature not available`);return}try{await W.deleteMedia(s.id),await r(),f(!1),c(null),l&&a?.id===s.id&&u(!1),n.info(`Successfully deleted media file: ${s.filename}`)}catch(e){n.error(`Delete failed:`,e)}}},saveEdit:async()=>{if(s&&e){if(!W.hasFeature(`media`)){n.warn(`Edit save attempted but media feature not available`);return}try{let e=await W.updateMedia(s.id,{title:s.metadata?.title||``,alt:s.metadata?.alt||``,author:s.metadata?.author||``,credit:s.metadata?.credit||``});n.info(`Media metadata updated successfully:`,e.data?.file),i(t=>t.map(t=>t.id===s.id?{...t,metadata:e.data?.file?.metadata||t.metadata}:t)),a?.id===s.id&&o({...a,metadata:e.data?.file?.metadata||a.metadata}),d(!1),c(null)}catch(e){n.error(`Save failed:`,e)}}},handleRegenerateVariants:async e=>{if(t){if(!W.hasFeature(`media`)){n.warn(`Regenerate variants attempted but media feature not available`);return}if(!e.contentType.startsWith(`image/`)){n.warn(`Regenerate variants attempted on non-image file`);return}try{n.info(`Regenerating variants for:`,e.filename);let t=await W.regenerateMediaVariants(e.id);t.success&&t.data?.file&&(i(n=>n.map(n=>n.id===e.id&&t.data?.file||n)),a?.id===e.id&&t.data?.file&&o(t.data.file),n.info(`Variants regenerated successfully`))}catch(e){n.error(`Failed to regenerate variants:`,e)}}},confirmBulkDelete:async()=>{if(m.size!==0&&t&&!g){if(!W.hasFeature(`media`)){n.warn(`Bulk delete attempted but media feature not available`);return}_(!0);try{let e=Array.from(m),t=await W.bulkDeleteMedia(e);if(t.success){let{successCount:e,errorCount:n}=t.data||{successCount:0,errorCount:0};n>0?v(`Deleted ${e} file(s), ${n} failed`,`warning`):v(e===1?`File deleted`:`${e} files deleted`,`success`),await r(),h(),l&&a&&m.has(a.id)&&u(!1)}}catch(e){n.error(`Bulk delete failed:`,e),v(`Failed to delete files`,`error`)}finally{_(!1),p(!1)}}}}}function m1({isDragging:e,isUploading:t,fileInputRef:n,onDragOver:r,onDragLeave:i,onDrop:a,onUploadClick:o,onFileInputChange:s}){let{t:c}=H(`studio`);return(0,V.jsx)(`div`,{className:`mb-8`,children:(0,V.jsxs)(`div`,{className:`relative border-2 border-dashed rounded-lg p-8 text-center transition-colors ${e?`border-primary-400 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`}`,onDragOver:r,onDragLeave:i,onDrop:a,children:[(0,V.jsx)(at,{className:`h-16 w-16 text-gray-400 mx-auto mb-4`}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`p`,{className:`text-lg font-medium text-gray-900 dark:text-white`,children:[(0,V.jsx)(U,{variant:`ghost`,className:`text-primary-600 hover:text-primary-500`,onClick:o,disabled:t,children:c(t?`common.loading`:`media.browseFiles`)}),` `,c(`media.or`),` `,c(`media.dragAndDrop`)]}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:`PNG, JPG, GIF, MP4, PDF up to 100MB`})]}),(0,V.jsx)(`input`,{ref:n,type:`file`,multiple:!0,className:`hidden`,accept:`image/*,video/*,audio/*,.pdf,.txt,.doc,.docx`,onChange:s})]})})}function h1({label:e,error:t,helperText:n,className:r,id:i,...a}){let o=i||`input-${Math.random().toString(36).substr(2,9)}`;return(0,V.jsxs)(`div`,{className:`w-full`,children:[e&&(0,V.jsx)(`label`,{htmlFor:o,className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e}),(0,V.jsx)(`input`,{id:o,className:wr(`w-full px-3 py-2 border rounded-md transition-colors`,`bg-white dark:bg-gray-700`,`text-gray-900 dark:text-white`,`placeholder-gray-400 dark:placeholder-gray-500`,`focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent`,t?`border-red-300 dark:border-red-600`:`border-gray-300 dark:border-gray-600 hover:border-gray-400 dark:hover:border-gray-500`,`disabled:opacity-50 disabled:cursor-not-allowed`,r),...a}),t&&(0,V.jsx)(`p`,{className:`mt-1 text-sm text-red-600 dark:text-red-400`,children:t}),n&&!t&&(0,V.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:n})]})}function g1({searchQuery:e,onSearchQueryChange:t,onToggleFilterSidebar:n,sortBy:r,sortDirection:i,onSortChange:a,itemsPerPage:o,onItemsPerPageChange:s,viewMode:c,onViewModeChange:l}){let{t:u}=H(`studio`);return(0,V.jsxs)(`div`,{className:`mb-6 flex flex-col sm:flex-row gap-4`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(ee,{className:`absolute left-3 top-1/2 transform -translate-y-1/2 h-5 w-5 text-gray-400`}),(0,V.jsx)(h1,{placeholder:u(`media.searchPlaceholder`),value:e,onChange:e=>t(e.target.value),className:`pl-10`})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 flex-wrap`,children:[(0,V.jsx)(U,{variant:`ghost`,size:`sm`,className:`lg:hidden`,onClick:n,children:(0,V.jsx)(Re,{className:`h-4 w-4`})}),(0,V.jsxs)(`select`,{value:`${r}-${i}`,onChange:e=>{let[t,n]=e.target.value.split(`-`);a(t,n)},className:`px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,V.jsx)(`option`,{value:`date-desc`,children:u(`media.sort.dateDesc`)}),(0,V.jsx)(`option`,{value:`date-asc`,children:u(`media.sort.dateAsc`)}),(0,V.jsx)(`option`,{value:`name-asc`,children:u(`media.sort.nameAsc`)}),(0,V.jsx)(`option`,{value:`name-desc`,children:u(`media.sort.nameDesc`)}),(0,V.jsx)(`option`,{value:`size-desc`,children:u(`media.sort.sizeDesc`)}),(0,V.jsx)(`option`,{value:`size-asc`,children:u(`media.sort.sizeAsc`)})]}),(0,V.jsxs)(`select`,{value:o,onChange:e=>{s(parseInt(e.target.value,10))},className:`px-3 py-2 text-sm border border-gray-200 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-700 dark:text-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500`,children:[(0,V.jsxs)(`option`,{value:`28`,children:[`28 `,u(`media.perPage`)]}),(0,V.jsxs)(`option`,{value:`56`,children:[`56 `,u(`media.perPage`)]}),(0,V.jsxs)(`option`,{value:`84`,children:[`84 `,u(`media.perPage`)]}),(0,V.jsxs)(`option`,{value:`112`,children:[`112 `,u(`media.perPage`)]})]}),(0,V.jsxs)(`div`,{className:`flex border border-gray-200 dark:border-gray-600 rounded-lg overflow-hidden`,children:[(0,V.jsx)(`button`,{onClick:()=>l(`grid`),className:`px-3 py-2 text-sm transition-colors ${c===`grid`?`bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900`:`bg-white text-gray-700 hover:bg-gray-50 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600`}`,children:(0,V.jsx)(Ze,{className:`h-4 w-4`})}),(0,V.jsx)(`button`,{onClick:()=>l(`list`),className:`px-3 py-2 text-sm transition-colors border-l border-gray-200 dark:border-gray-600 ${c===`list`?`bg-gray-900 text-white dark:bg-gray-100 dark:text-gray-900`:`bg-white text-gray-700 hover:bg-gray-50 dark:bg-gray-700 dark:text-gray-300 dark:hover:bg-gray-600`}`,children:(0,V.jsx)(we,{className:`h-4 w-4`})})]})]})]})}function _1({isOpen:e,onClose:t,mediaTypes:n,selectedType:r,onSelectType:i}){let{t:a}=H(`studio`);return(0,V.jsx)(`div`,{className:`${e?`block`:`hidden`} lg:block w-48 lg:w-56 flex-shrink-0`,children:(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,V.jsxs)(`h3`,{className:`text-xs font-medium text-gray-900 dark:text-white uppercase tracking-wide`,children:[(0,V.jsx)(Re,{className:`h-3 w-3 inline mr-1`}),a(`media.filters`)]}),(0,V.jsx)(`button`,{onClick:t,className:`lg:hidden p-1 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:(0,V.jsx)(tt,{className:`h-3 w-3`})})]}),(0,V.jsx)(`div`,{className:`space-y-0.5`,children:Object.entries(n).map(([e,t])=>{let n=t.icon;return(0,V.jsxs)(`button`,{onClick:()=>i(e),className:`w-full flex items-center justify-between px-2 py-1.5 text-xs rounded-md transition-colors ${r===e?`bg-primary-100 text-primary-700 dark:bg-primary-900 dark:text-primary-300`:`text-gray-700 dark:text-gray-300 hover:bg-gray-100 dark:hover:bg-gray-700`}`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(n,{className:`h-3 w-3 mr-1.5`}),t.label]}),(0,V.jsx)(`span`,{className:`text-xs text-gray-500 dark:text-gray-400 font-medium`,children:t.count})]},e)})})]})})}function v1({selectedCount:e,totalCount:t,isDeleting:n,onSelectAll:r,onClearSelection:i,onBulkDelete:a}){let{t:o}=H(`studio`);return(0,V.jsxs)(`div`,{className:`mb-4 flex items-center justify-between bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(V$,{checked:e===t,indeterminate:e>0&&e<t,onChange:r,"aria-label":o(`common.selectAll`)}),(0,V.jsx)(`span`,{className:`text-sm font-medium text-blue-800 dark:text-blue-200`,children:o(`media.selected`,{count:e})})]}),(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:i,className:`text-blue-600 dark:text-blue-400 hover:text-blue-800 dark:hover:text-blue-200`,children:o(`common.deselectAll`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:r,className:`text-blue-600 dark:text-blue-400`,children:o(e===t?`common.deselectAll`:`common.selectAll`)}),(0,V.jsxs)(U,{variant:`danger`,size:`sm`,onClick:a,disabled:n,children:[(0,V.jsx)(Be,{className:`h-4 w-4 mr-2`}),o(n?`common.loading`:`media.deleteSelected`)]})]})]})}function y1({file:e,viewMode:t,isSelected:n,canEdit:r,canDelete:i,getMediaUrl:a,onItemSelect:o,onOpenViewer:s,onEdit:c,onDelete:l}){let u=o1(e.contentType),d=e.contentType.startsWith(`image/`),f=l1(e);return t===`grid`?(0,V.jsxs)(`div`,{className:`group relative bg-white dark:bg-gray-800 rounded-lg border overflow-hidden hover:shadow-md transition-all cursor-pointer ${n?`ring-2 ring-blue-500 border-blue-500 shadow-lg`:`border-gray-200 dark:border-gray-700`}`,onClick:t=>{t.shiftKey&&i?(t.preventDefault(),o(e.id,!0,!0)):s(e)},children:[i&&(0,V.jsx)(`div`,{className:`absolute top-2 left-2 z-10`,onClick:e=>e.stopPropagation(),children:(0,V.jsx)(V$,{checked:n,onChange:t=>o(e.id,t),"aria-label":`Select ${e.metadata?.title||e.filename}`})}),(0,V.jsx)(`div`,{className:`aspect-square flex items-center justify-center bg-gray-50 dark:bg-gray-900`,children:d?(0,V.jsx)(`img`,{src:a(e,gi(e)),alt:e.metadata?.alt||e.filename,className:`w-full h-full object-cover`,loading:`lazy`}):(0,V.jsx)(u,{className:`h-12 w-12 text-gray-400`})}),f>0&&(0,V.jsx)(`div`,{className:`absolute top-2 right-2 bg-primary-600 text-white text-xs px-2 py-1 rounded-full`,children:f}),(0,V.jsx)(`div`,{className:`absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-40 transition-opacity flex items-center justify-center opacity-0 group-hover:opacity-100`,children:(0,V.jsxs)(`div`,{className:`flex space-x-2`,children:[(0,V.jsx)(U,{size:`sm`,variant:`secondary`,onClick:t=>{t.stopPropagation(),s(e)},children:(0,V.jsx)(ce,{className:`h-4 w-4`})}),(r||i)&&(0,V.jsxs)(V.Fragment,{children:[r&&(0,V.jsx)(U,{size:`sm`,variant:`secondary`,onClick:t=>{t.stopPropagation(),c(e)},children:(0,V.jsx)(ct,{className:`h-4 w-4`})}),i&&(0,V.jsx)(U,{size:`sm`,variant:`danger`,onClick:t=>{t.stopPropagation(),l(e)},children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]})]})}),(0,V.jsxs)(`div`,{className:`p-3`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:e.metadata?.title||e.filename}),(0,V.jsx)(`div`,{className:`flex items-center justify-between`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:hi(e.size)})})]})]}):(0,V.jsxs)(`div`,{className:`flex items-center space-x-4 p-4 bg-white dark:bg-gray-800 rounded-lg border hover:shadow-sm transition-all cursor-pointer ${n?`ring-2 ring-blue-500 border-blue-500 shadow-lg`:`border-gray-200 dark:border-gray-700`}`,onClick:t=>{t.shiftKey&&i?(t.preventDefault(),o(e.id,!0,!0)):s(e)},children:[i&&(0,V.jsx)(`div`,{className:`flex-shrink-0`,onClick:e=>e.stopPropagation(),children:(0,V.jsx)(V$,{checked:n,onChange:t=>o(e.id,t),"aria-label":`Select ${e.metadata?.title||e.filename}`})}),(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:d?(0,V.jsx)(`img`,{src:a(e,gi(e)),alt:e.metadata?.alt||e.filename,className:`w-12 h-12 object-cover rounded`,loading:`lazy`}):(0,V.jsx)(`div`,{className:`w-12 h-12 bg-gray-100 dark:bg-gray-700 rounded flex items-center justify-center`,children:(0,V.jsx)(u,{className:`h-6 w-6 text-gray-400`})})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-white truncate`,children:e.metadata?.title||e.filename}),(0,V.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[hi(e.size),` • `,e.contentType]}),e.metadata?.alt&&(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500 truncate`,children:e.metadata.alt})]}),(r||i)&&(0,V.jsxs)(`div`,{className:`flex space-x-1`,children:[r&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:t=>{t.stopPropagation(),c(e)},children:(0,V.jsx)(ct,{className:`h-4 w-4`})}),i&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:t=>{t.stopPropagation(),l(e)},children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]})]})}function b1({isOpen:e,onClose:t,title:n,size:r=`md`,children:i,closeOnOverlayClick:a=!0}){return(0,V.jsx)(ia,{open:e,onClose:t,variant:`center`,size:r,title:n,closeOnBackdrop:a,children:(0,V.jsx)(ia.Body,{padded:!1,className:`p-6`,children:i})})}function x1({isOpen:e,editingFile:t,onEditingFileChange:n,onClose:r,onSave:i}){let{t:a}=H(`studio`);return(0,V.jsx)(b1,{isOpen:e,onClose:r,title:a(`media.editMetadata`),children:(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:a(`common.title`)||`Title`}),(0,V.jsx)(h1,{value:t.metadata?.title||``,onChange:e=>n({...t,metadata:{...t.metadata,title:e.target.value}})})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:`Alt Text`}),(0,V.jsx)(h1,{value:t.metadata?.alt||``,onChange:e=>n({...t,metadata:{...t.metadata,alt:e.target.value}})})]}),(0,V.jsxs)(`div`,{className:`flex space-x-3 pt-4`,children:[(0,V.jsx)(U,{onClick:i,className:`flex-1`,children:a(`common.save`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:r,className:`flex-1`,children:a(`common.cancel`)})]})]})})}function S1({isOpen:e,editingFile:t,onClose:n,onConfirm:r}){let{t:i}=H(`studio`);return(0,V.jsx)(b1,{isOpen:e,onClose:n,title:i(`media.delete`),children:(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,V.jsx)(de,{className:`h-6 w-6 text-red-600 mt-1`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-gray-900 dark:text-white`,children:i(`media.confirmDelete`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mt-1`,children:(0,V.jsx)(`strong`,{children:t.metadata?.title||t.filename})})]})]}),(0,V.jsxs)(`div`,{className:`flex space-x-3 pt-4`,children:[(0,V.jsx)(U,{variant:`danger`,onClick:r,className:`flex-1`,children:i(`common.delete`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:n,className:`flex-1`,children:i(`common.cancel`)})]})]})})}function C1({isOpen:e,selectedCount:t,isDeleting:n,onClose:r,onConfirm:i}){let{t:a}=H(`studio`);return(0,V.jsx)(b1,{isOpen:e,onClose:r,title:a(`media.deleteSelected`),children:(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-start space-x-3`,children:[(0,V.jsx)(de,{className:`h-6 w-6 text-red-600 mt-1`}),(0,V.jsx)(`div`,{children:(0,V.jsx)(`p`,{className:`text-gray-900 dark:text-white`,children:a(`media.confirmBulkDelete`,{count:t})})})]}),(0,V.jsxs)(`div`,{className:`flex space-x-3 pt-4`,children:[(0,V.jsx)(U,{variant:`danger`,onClick:i,className:`flex-1`,disabled:n,children:a(n?`common.loading`:`common.delete`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:r,className:`flex-1`,disabled:n,children:a(`common.cancel`)})]})]})})}function w1(){let{t:e}=H(`studio`);za({page:`media`,title:e(`media.title`),defaultVisible:!1,defaultPosition:`left`});let t=pa(),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(!1),[f,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(0),[y,b]=(0,B.useState)(!1),{hasPermission:x}=ci(),S=x(li.UPLOAD),C=x(li.EDIT),w=x(li.DELETE),[T,E]=p(),{mediaFiles:D,setMediaFiles:O,filteredFiles:k,isUploading:A,setIsUploading:j,viewMode:M,updateViewMode:N,searchQuery:P,setSearchQuery:F,selectedType:I,setSelectedType:L,currentPage:ee,setCurrentPage:R,itemsPerPage:te,updateItemsPerPage:ne,sortBy:re,setSortBy:ie,sortDirection:ae,setSortDirection:oe,totalPages:se,startIndex:ce,endIndex:le,paginatedFiles:ue,loadMediaFiles:fe,logger:pe}=u1(),{selectedIds:me,handleItemSelect:he,handleSelectAll:ge,clearSelection:_e,handleBulkDelete:ve}=d1({filteredFiles:k,selectedType:I,searchQuery:P,canDelete:w,isViewerOpen:o,isEditModalOpen:c,isDeleteModalOpen:u,isBulkDeleteModalOpen:f,setIsBulkDeleteModalOpen:m}),{isDragging:ye,fileInputRef:xe,handleDragOver:Se,handleDragLeave:Ce,handleDrop:we,handleFileInputChange:Te,handleUploadClick:Ee}=f1({canUpload:S,logger:pe,showToast:(e,n)=>t?.utils.showToast(e,n),setIsUploading:j,loadMediaFiles:fe}),De={all:{label:e(`media.types.all`),icon:s1.all,count:c1(D,`all`)},images:{label:e(`media.types.images`),icon:s1.images,count:c1(D,`images`)},videos:{label:e(`media.types.videos`),icon:s1.videos,count:c1(D,`videos`)},audio:{label:e(`media.types.audio`),icon:s1.audio,count:c1(D,`audio`)},documents:{label:e(`media.types.documents`),icon:s1.documents,count:c1(D,`documents`)},archives:{label:e(`media.types.archives`),icon:s1.archives,count:c1(D,`archives`)}},Oe=e=>{let t=k.findIndex(t=>t.id===e.id);v(t>=0?t:-1),r(e),s(!0)},Ae=e=>{if(_===-1){let t=e===`prev`?k.length-1:0;k[t]&&(v(t),r(k[t]));return}let t=e===`prev`?Math.max(0,_-1):Math.min(k.length-1,_+1);k[t]&&(v(t),r(k[t]))};(0,B.useEffect)(()=>{let e=T.get(`file`);if(e&&D.length>0){let t=D.find(t=>t.id===e);t&&(!n||n.id!==e)&&(Oe(t),pe.debug(`Opening media file from URL parameter`,{fileId:e,filename:t.filename}))}},[T,D]),(0,B.useEffect)(()=>{if(o&&n){let e=new URLSearchParams(T);e.set(`file`,n.id),E(e,{replace:!0})}else if(!o&&D.length>0){let e=new URLSearchParams(T);e.has(`file`)&&(e.delete(`file`),E(e,{replace:!0}))}},[o,n,D.length]),(0,B.useEffect)(()=>{if(!o)return;let e=e=>{if(e.key===`Escape`){if(Di(e))return;s(!1)}else e.key===`ArrowLeft`?Ae(`prev`):e.key===`ArrowRight`&&Ae(`next`)};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,_,k]);let{handleEdit:je,handleDelete:Me,confirmDelete:Pe,saveEdit:Fe,handleRegenerateVariants:Ie,confirmBulkDelete:Le}=p1({canEdit:C,canDelete:w,logger:pe,loadMediaFiles:fe,setMediaFiles:O,selectedFile:n,setSelectedFile:r,editingFile:h,setEditingFile:g,isViewerOpen:o,setIsViewerOpen:s,setIsEditModalOpen:l,setIsDeleteModalOpen:d,setIsBulkDeleteModalOpen:m,selectedIds:me,clearSelection:_e,isDeleting:y,setIsDeleting:b,showToast:(e,n)=>t?.utils.showToast(e,n)}),Re=(e,n)=>{let r=t?.mediaUrlGenerator;return r?r.getMediaUrl(e.id,n):(pe.warn(`MediaUrlGenerator not available in MediaPage, using fallback URL`,{mediaId:e.id,variant:n}),e.url)};return(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`media.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`media.subtitle`)})]}),S&&W.hasFeature(`media`)&&(0,V.jsx)(m1,{isDragging:ye,isUploading:A,fileInputRef:xe,onDragOver:Se,onDragLeave:Ce,onDrop:we,onUploadClick:Ee,onFileInputChange:Te}),!W.hasFeature(`media`)&&(0,V.jsx)(`div`,{className:`mb-8 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-6 w-6 text-yellow-600 dark:text-yellow-400 mr-3`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:`Media Management Not Available`}),(0,V.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:`Media upload and management features are not enabled in this Studio instance. Contact your administrator to enable media capabilities.`})]})]})}),(0,V.jsx)(g1,{searchQuery:P,onSearchQueryChange:F,onToggleFilterSidebar:()=>a(!i),sortBy:re,sortDirection:ae,onSortChange:(e,t)=>{ie(e),oe(t)},itemsPerPage:te,onItemsPerPageChange:ne,viewMode:M,onViewModeChange:N}),me.size>0&&w&&(0,V.jsx)(v1,{selectedCount:me.size,totalCount:k.length,isDeleting:y,onSelectAll:ge,onClearSelection:_e,onBulkDelete:ve}),(0,V.jsxs)(`div`,{className:`flex gap-4 lg:gap-6`,children:[(0,V.jsx)(_1,{isOpen:i,onClose:()=>a(!1),mediaTypes:De,selectedType:I,onSelectType:e=>{L(e),window.innerWidth<1024&&a(!1)}}),(0,V.jsx)(`div`,{className:`flex-1`,children:k.length===0?(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(at,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-2`,children:e(P||I!==`all`?`media.noResults`:`media.noMedia`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:e(P||I!==`all`?`media.noResults`:`media.subtitle`)}),S&&W.hasFeature(`media`)&&!P&&I===`all`&&(0,V.jsxs)(U,{onClick:Ee,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`media.uploadFiles`)]})]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:M===`grid`?`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7 gap-3 lg:gap-4`:`space-y-2`,children:ue.map(e=>(0,V.jsx)(y1,{file:e,viewMode:M,isSelected:me.has(e.id),canEdit:C,canDelete:w,getMediaUrl:Re,onItemSelect:he,onOpenViewer:Oe,onEdit:je,onDelete:Me},e.id))}),k.length>te&&(0,V.jsxs)(`div`,{className:`mt-6 flex items-center justify-between px-4 py-3 bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:[ce+1,`-`,Math.min(le,k.length),` / `,k.length]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>R(e=>Math.max(1,e-1)),disabled:ee===1,children:[(0,V.jsx)(be,{className:`h-4 w-4 mr-1`}),e(`common.previous`)]}),(0,V.jsxs)(`span`,{className:`text-sm text-gray-600 dark:text-gray-300 px-3`,children:[ee,` / `,se]}),(0,V.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:()=>R(e=>Math.min(se,e+1)),disabled:ee===se,children:[e(`common.next`),(0,V.jsx)(z,{className:`h-4 w-4 ml-1`})]})]})]})]})})]}),o&&n&&(0,V.jsxs)(ia,{open:o,onClose:()=>s(!1),variant:`center`,size:`xl`,height:`tall`,className:`overflow-hidden`,ariaLabel:n.metadata?.title||n.filename,children:[(0,V.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-4 min-w-0 flex-1`,children:[(0,V.jsxs)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400 flex-shrink-0`,children:[_+1,` of `,k.length]}),(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-white truncate`,children:n.metadata?.title||n.filename})]}),(0,V.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>Ae(`prev`),disabled:_===0,children:(0,V.jsx)(be,{className:`h-4 w-4`})}),(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>Ae(`next`),disabled:_===k.length-1,children:(0,V.jsx)(z,{className:`h-4 w-4`})}),(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{let e=document.createElement(`a`);e.href=Re(n),e.download=n.filename,document.body.appendChild(e),e.click(),document.body.removeChild(e)},children:(0,V.jsx)(Ye,{className:`h-4 w-4`})}),(C||w)&&(0,V.jsxs)(V.Fragment,{children:[C&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{je(n),s(!1)},children:(0,V.jsx)(ct,{className:`h-4 w-4`})}),C&&n.contentType.startsWith(`image/`)&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>Ie(n),title:`Regenerate image variants`,children:(0,V.jsx)(ke,{className:`h-4 w-4`})}),w&&(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>{Me(n),s(!1)},children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]}),(0,V.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>s(!1),children:(0,V.jsx)(tt,{className:`h-4 w-4`})})]})]}),(0,V.jsxs)(ia.Body,{scroll:!1,padded:!1,className:`flex flex-col md:flex-row`,children:[(0,V.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 min-w-0`,children:[(0,V.jsx)(`div`,{className:`flex-1 min-h-0 overflow-hidden flex items-center justify-center bg-gray-50 dark:bg-gray-900 p-4`,children:n.contentType.startsWith(`image/`)?(0,V.jsx)(`img`,{src:Re(n),alt:n.metadata?.alt||n.filename,className:`max-w-full max-h-full object-contain`}):n.contentType.startsWith(`video/`)?(0,V.jsx)(`video`,{src:Re(n),controls:!0,className:`max-w-full max-h-full`}):n.contentType.startsWith(`audio/`)?(0,V.jsx)(`audio`,{src:Re(n),controls:!0,className:`w-full max-w-md`}):(0,V.jsxs)(`div`,{className:`text-center`,children:[B.createElement(o1(n.contentType),{className:`h-24 w-24 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-4`,children:e(`media.preview`)}),(0,V.jsxs)(U,{onClick:()=>{let e=document.createElement(`a`);e.href=Re(n),e.download=n.filename,document.body.appendChild(e),e.click(),document.body.removeChild(e)},children:[(0,V.jsx)(Ye,{className:`h-4 w-4 mr-2`}),e(`media.download`)]})]})}),n.contentType.startsWith(`image/`)&&n.metadata?.imageVariants&&Object.keys(n.metadata.imageVariants).length>0&&(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:`Image Variants`}),C&&(0,V.jsxs)(U,{variant:`ghost`,size:`sm`,onClick:()=>Ie(n),title:`Regenerate all variants`,className:`text-xs`,children:[(0,V.jsx)(ke,{className:`h-3 w-3 mr-1`}),`Regenerate`]})]}),(0,V.jsx)(`div`,{className:`flex space-x-3 overflow-x-auto pb-2`,children:Object.entries(n.metadata.imageVariants).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex-shrink-0 group relative`,children:[(0,V.jsx)(`img`,{src:Re(n,e),alt:`${e} variant`,className:`w-20 h-20 object-cover rounded border border-gray-200 dark:border-gray-600`,loading:`lazy`}),(0,V.jsx)(`div`,{className:`absolute inset-0 bg-black bg-opacity-0 group-hover:bg-opacity-50 transition-opacity rounded flex items-center justify-center opacity-0 group-hover:opacity-100`,children:(0,V.jsxs)(`div`,{className:`flex space-x-1`,children:[(0,V.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(Re(n,e))},className:`text-[10px] bg-white bg-opacity-90 text-gray-800 px-1.5 py-0.5 rounded hover:bg-opacity-100 transition-all`,title:`Copy URL`,children:`Copy`}),(0,V.jsx)(`a`,{href:Re(n,e),target:`_blank`,rel:`noopener noreferrer`,className:`text-[10px] bg-primary-600 bg-opacity-90 text-white px-1.5 py-0.5 rounded hover:bg-opacity-100 transition-all`,children:`View`})]})}),(0,V.jsxs)(`div`,{className:`mt-1 text-center`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 capitalize truncate`,children:e}),(0,V.jsxs)(`div`,{className:`text-[10px] text-gray-500 dark:text-gray-500`,children:[t.width,` × `,t.height]})]})]},e))})]}),n.contentType.startsWith(`image/`)&&(!n.metadata?.imageVariants||Object.keys(n.metadata.imageVariants).length===0)&&(0,V.jsx)(`div`,{className:`shrink-0 border-t border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-4`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-2`,children:`Image Variants`}),(0,V.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mb-3`,children:`No variants generated for this image.`}),C&&(0,V.jsxs)(U,{variant:`primary`,size:`sm`,onClick:()=>Ie(n),className:`text-xs`,children:[(0,V.jsx)(ke,{className:`h-4 w-4 mr-2`}),`Generate Variants`]})]})})]}),(0,V.jsxs)(`div`,{className:`w-full md:w-80 shrink-0 overflow-y-auto bg-white dark:bg-gray-800 border-l border-gray-200 dark:border-gray-700 p-4 md:p-6`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-white mb-4`,children:e(`media.details`)}),(0,V.jsxs)(`dl`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400`,children:e(`media.filename`)}),(0,V.jsx)(`dd`,{className:`text-sm text-gray-900 dark:text-white`,children:n.filename})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400`,children:e(`media.filesize`)}),(0,V.jsx)(`dd`,{className:`text-sm text-gray-900 dark:text-white`,children:hi(n.size)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400`,children:e(`media.mimeType`)}),(0,V.jsx)(`dd`,{className:`text-sm text-gray-900 dark:text-white`,children:n.contentType})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400`,children:e(`media.uploadedAt`)}),(0,V.jsx)(`dd`,{className:`text-sm text-gray-900 dark:text-white`,children:new Date(n._createdAt).toLocaleString()})]}),n.metadata?.width&&n.metadata?.height&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`text-sm font-medium text-gray-500 dark:text-gray-400`,children:e(`media.dimensions`)}),(0,V.jsxs)(`dd`,{className:`text-sm text-gray-900 dark:text-white`,children:[n.metadata.width,` × `,n.metadata.height,`px`]})]})]})]})]})]}),c&&h&&(0,V.jsx)(x1,{isOpen:c,editingFile:h,onEditingFileChange:g,onClose:()=>l(!1),onSave:Fe}),u&&h&&(0,V.jsx)(S1,{isOpen:u,editingFile:h,onClose:()=>d(!1),onConfirm:Pe}),f&&me.size>0&&(0,V.jsx)(C1,{isOpen:f,selectedCount:me.size,isDeleting:y,onClose:()=>m(!1),onConfirm:Le})]})}var T1=Fr(`useDynamicPermissions`);function E1(){let[e,t]=(0,B.useState)([]),[n,r]=(0,B.useState)(!0),[i,a]=(0,B.useState)(null);return(0,B.useEffect)(()=>{async function e(){try{r(!0),a(null);let e=await W.get(`/config/structure`);if(e.success&&e.data?.structure?.items){let n=e.data.structure.items.filter(e=>(e.type===`documentList`||e.type===`singleton`)&&e.schemaType).map(e=>({type:e.type,title:e.title,schemaType:e.schemaType}));t(n),T1.debug(`Loaded schemas for dynamic permissions`,{count:n.length,schemas:n.map(e=>e.schemaType)})}else T1.warn(`No structure data found in API response`),t([])}catch(e){let n=e instanceof Error?e.message:`Failed to load schemas`;a(n),T1.error(`Failed to fetch schemas for permissions`,e),t([])}finally{r(!1)}}e()},[]),{dynamicPermissions:(0,B.useMemo)(()=>{let t=[];return e.forEach(e=>{let{schemaType:n,title:r,type:i}=e,a=`${r} (Content)`;t.push({value:`${n}:read`,label:`View ${r}`,group:a},{value:`${n}:write`,label:`Edit ${r}`,group:a}),i===`documentList`&&t.push({value:`${n}:delete`,label:`Delete ${r}`,group:a})}),t},[e]),schemas:e,loading:n,error:i,isReady:!n&&!i}}var D1={admin:[`content:*`,`media:read`,`media:upload`,`media:edit`,`media:delete`,`users:read`,`users:write`,`users:delete`,`users:invite`,`settings:read`,`settings:write`,`studio:access`,`tokens:read`,`tokens:write`,`tokens:delete`,`webhooks:read`,`webhooks:write`,`webhooks:delete`,`webhooks:test`],editor:[`content:*`,`media:read`,`media:upload`,`media:edit`,`media:delete`,`studio:access`,`webhooks:read`,`webhooks:test`],author:[`content:read`,`content:write`,`content:publish`,`media:read`,`media:upload`,`studio:access`],writer:[`content:read`,`content:write`,`media:read`,`media:upload`,`studio:access`],viewer:[`content:read`,`media:read`,`studio:access`]};function O1(e){if(e<=0)throw Error(`Max must be positive`);let t=new Uint32Array(1);crypto.getRandomValues(t);let n=Math.floor(4294967295/e)*e,r=t[0];for(;r>=n;)crypto.getRandomValues(t),r=t[0];return r%e}function k1(e){let t=[...e];for(let e=t.length-1;e>0;e--){let n=O1(e+1);[t[e],t[n]]=[t[n],t[e]]}return t}function A1(e={}){let{length:t=16,includeUppercase:n=!0,includeLowercase:r=!0,includeNumbers:i=!0,includeSpecialChars:a=!0,customChars:o=``,excludeSimilar:s=!1}=e;if(t<1)throw Error(`Password length must be at least 1`);if(t>1e3)throw Error(`Password length too large`);let c=``,l=[];if(r){let e=s?`abcdefghijkmnopqrstuvwxyz`:`abcdefghijklmnopqrstuvwxyz`;c+=e,l.push(e[O1(e.length)])}if(n){let e=s?`ABCDEFGHJKLMNPQRSTUVWXYZ`:`ABCDEFGHIJKLMNOPQRSTUVWXYZ`;c+=e,l.push(e[O1(e.length)])}if(i){let e=s?`23456789`:`0123456789`;c+=e,l.push(e[O1(e.length)])}if(a){let e=`!@#$%^&*()_+-=[]{}|;:,.<>?`;c+=e,l.push(e[O1(26)])}if(o&&(c+=o),!c)throw Error(`At least one character type must be included`);let u=c.split(``),d=[...l];for(;d.length<t;){let e=O1(u.length);d.push(u[e])}return k1(d).join(``)}var j1=Fr(`UserManagement`),M1=[`admin`,`editor`,`writer`,`author`,`viewer`],N1=[{value:`content:*`,labelKey:`userManagement.permissions.allContent`,group:`Content`},{value:`content:read`,labelKey:`userManagement.permissions.viewAllContent`,group:`Content`},{value:`content:write`,labelKey:`userManagement.permissions.editAllContent`,group:`Content`},{value:`content:delete`,labelKey:`userManagement.permissions.deleteAllContent`,group:`Content`},{value:`content:publish`,labelKey:`userManagement.permissions.publishAllContent`,group:`Content`},{value:`media:read`,labelKey:`userManagement.permissions.viewMedia`,group:`Media`},{value:`media:upload`,labelKey:`userManagement.permissions.uploadMedia`,group:`Media`},{value:`media:edit`,labelKey:`userManagement.permissions.editMedia`,group:`Media`},{value:`media:delete`,labelKey:`userManagement.permissions.deleteMedia`,group:`Media`},{value:`users:read`,labelKey:`userManagement.permissions.viewUsers`,group:`Users`},{value:`users:write`,labelKey:`userManagement.permissions.editUsers`,group:`Users`},{value:`users:delete`,labelKey:`userManagement.permissions.deleteUsers`,group:`Users`},{value:`users:invite`,labelKey:`userManagement.permissions.inviteUsers`,group:`Users`},{value:`settings:read`,labelKey:`userManagement.permissions.viewSettings`,group:`Settings`},{value:`settings:write`,labelKey:`userManagement.permissions.editSettings`,group:`Settings`},{value:`studio:access`,labelKey:`userManagement.permissions.studioAccess`,group:`Access`},{value:`tokens:read`,labelKey:`userManagement.permissions.viewTokens`,group:`Tokens`},{value:`tokens:write`,labelKey:`userManagement.permissions.createTokens`,group:`Tokens`},{value:`tokens:delete`,labelKey:`userManagement.permissions.deleteTokens`,group:`Tokens`},{value:`webhooks:read`,labelKey:`userManagement.permissions.viewWebhooks`,group:`Webhooks`},{value:`webhooks:write`,labelKey:`userManagement.permissions.createEditWebhooks`,group:`Webhooks`},{value:`webhooks:delete`,labelKey:`userManagement.permissions.deleteWebhooks`,group:`Webhooks`},{value:`webhooks:test`,labelKey:`userManagement.permissions.testWebhooks`,group:`Webhooks`}];function P1({user:e,isOpen:t,onClose:n,onSave:r}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)({username:``,email:``,fullName:``,role:`viewer`,permissions:[],password:``,active:!0}),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(null),{dynamicPermissions:p,loading:m,error:h}=E1(),[g,_]=(0,B.useState)(!1),[v,y]=(0,B.useState)(``),b=(e,t)=>{let n=[...D1[e]||[]].sort(),r=[...t].sort();return n.join(`,`)!==r.join(`,`)},x=e=>{let t=D1[e]||[];o(n=>({...n,role:e,permissions:t})),_(!1)},S=e=>{o(t=>{let n=t.permissions.includes(e)?t.permissions.filter(t=>t!==e):[...t.permissions,e],r=b(t.role,n);return _(r),{...t,permissions:n}})},C=()=>{let e=D1[a.role]||[];o(t=>({...t,permissions:e})),_(!1)},w=()=>{if(!v.trim())return;if(!/^[a-z][a-z0-9_-]*:(read|write|delete|\*)$/i.test(v.trim())){alert(i(`userManagement.modal.permissionValidationError`));return}let e=v.trim();a.permissions.includes(e)||(o(t=>({...t,permissions:[...t.permissions,e]})),_(!0)),y(``)},T=e=>{o(t=>({...t,permissions:t.permissions.filter(t=>t!==e)}))},E=()=>{let e=A1({length:12,includeUppercase:!0,includeLowercase:!0,includeNumbers:!0,includeSpecialChars:!0,excludeSimilar:!0});o(t=>({...t,password:e}))};(0,B.useEffect)(()=>{if(f(null),e){let t=e.permissions||[],n=b(e.role,t);o({username:e.username,email:e.email,fullName:`${e.firstName} ${e.lastName}`,role:e.role,permissions:t,password:``,active:e.isActive}),_(n)}else{let e=D1.viewer;o({username:``,email:``,fullName:``,role:`viewer`,permissions:e,password:``,active:!0}),_(!1)}},[e,t]);let D=async e=>{e.preventDefault(),c(!0),f(null);try{await r(a),n()}catch(e){j1.error(`Failed to save user`,e);let t=e?.message||`Failed to save user. Please try again.`;f(t)}finally{c(!1)}},O=N1.map(e=>({value:e.value,label:i(e.labelKey),group:e.group})),k=O.filter(e=>e.group===`Content`),A=O.filter(e=>e.group!==`Content`&&e.value!==`studio:access`),j=[...k,...p,...A],M=j.reduce((e,t)=>(e[t.group]||(e[t.group]=[]),e[t.group].push(t),e),{});return t?(0,V.jsx)(b1,{isOpen:t,onClose:n,title:i(e?`userManagement.modal.editTitle`:`userManagement.modal.createTitle`),size:`xl`,children:(0,V.jsxs)(`form`,{onSubmit:D,className:`space-y-4`,children:[d&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-5 w-5 text-red-600 dark:text-red-400 mr-2 flex-shrink-0`}),(0,V.jsx)(`span`,{className:`text-sm text-red-800 dark:text-red-200`,children:d})]})}),(0,V.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-1`,children:i(`userManagement.modal.basicInfo`)}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[i(`userManagement.modal.username`),` *`]}),(0,V.jsx)(h1,{type:`text`,value:a.username,onChange:e=>o(t=>({...t,username:e.target.value})),required:!0,disabled:s})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[i(`userManagement.modal.email`),` *`]}),(0,V.jsx)(h1,{type:`email`,value:a.email,onChange:e=>o(t=>({...t,email:e.target.value})),required:!0,disabled:s})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:[i(`userManagement.modal.fullName`),` *`]}),(0,V.jsx)(h1,{type:`text`,value:a.fullName,onChange:e=>o(t=>({...t,fullName:e.target.value})),required:!0,disabled:s})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e?i(`userManagement.modal.newPassword`):`${i(`userManagement.modal.password`)} *`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(`div`,{className:`relative flex-1`,children:[(0,V.jsx)(h1,{type:l?`text`:`password`,value:a.password,onChange:e=>o(t=>({...t,password:e.target.value})),required:!e,disabled:s,className:`pr-10`}),(0,V.jsx)(`button`,{type:`button`,className:`absolute inset-y-0 right-0 flex items-center pr-3`,onClick:()=>u(!l),children:l?(0,V.jsx)(le,{className:`h-4 w-4 text-gray-400`}):(0,V.jsx)(ce,{className:`h-4 w-4 text-gray-400`})})]}),(0,V.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:E,disabled:s,className:`px-3`,children:i(`userManagement.modal.generatePassword`)})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:i(`userManagement.modal.role`)}),(0,V.jsx)(`select`,{value:a.role,onChange:e=>x(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white text-sm`,disabled:s,children:M1.map(e=>(0,V.jsxs)(`option`,{value:e,children:[i(`userManagement.roles.${e}`),` - `,i(`userManagement.roles.${e}Desc`)]},e))})]})]}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white border-b border-gray-200 dark:border-gray-700 pb-1`,children:i(`userManagement.modal.accessPermissions`)}),g&&(0,V.jsx)(`button`,{type:`button`,onClick:C,className:`text-xs text-primary-600 hover:text-primary-700 dark:text-primary-400 dark:hover:text-primary-300`,children:i(`userManagement.modal.reset`)})]}),(0,V.jsx)(`div`,{className:`p-3 bg-gray-50 dark:bg-gray-900 rounded-md`,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:a.active,onChange:e=>o(t=>({...t,active:e.target.checked})),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`}),(0,V.jsx)(`span`,{className:`ml-2 text-sm font-medium text-gray-700 dark:text-gray-300`,children:i(`userManagement.modal.activeAccount`)})]}),(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:a.permissions.includes(`studio:access`),onChange:()=>S(`studio:access`),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`}),(0,V.jsx)(`span`,{className:`ml-2 text-sm font-medium text-gray-700 dark:text-gray-300`,children:i(`userManagement.modal.studioAccess`)})]})]})}),g&&(0,V.jsx)(`div`,{className:`p-2 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-4 w-4 text-amber-600 dark:text-amber-400 mr-2`}),(0,V.jsx)(`span`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:i(`userManagement.modal.customPermissions`)})]})}),(0,V.jsxs)(`div`,{className:`border border-gray-300 dark:border-gray-600 rounded-md p-3 max-h-80 overflow-y-auto`,children:[m&&(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),(0,V.jsx)(`span`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:i(`userManagement.modal.loadingSchemaPermissions`)})]}),h&&(0,V.jsx)(`div`,{className:`p-3 bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md mb-3`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-4 w-4 text-amber-600 dark:text-amber-400 mr-2`}),(0,V.jsx)(`span`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:i(`userManagement.modal.failedLoadSchemaPermissions`,{error:h})})]})}),!m&&Object.entries(M).map(([e,t])=>{let n=a.permissions.includes(`content:*`),r=e===`Content`,o=e.endsWith(`(Content)`);return(0,V.jsxs)(`div`,{className:`mb-3 last:mb-0`,children:[(0,V.jsxs)(`h4`,{className:`text-xs font-medium text-gray-900 dark:text-white mb-1 border-b border-gray-200 dark:border-gray-700 pb-1`,children:[e,(r||o)&&n&&(0,V.jsx)(`span`,{className:`ml-2 text-xs text-gray-500 dark:text-gray-400`,children:i(r?`userManagement.modal.allContentEnabled`:`userManagement.modal.coveredByAllContent`)})]}),(0,V.jsx)(`div`,{className:`grid grid-cols-1 gap-1`,children:t.map(e=>{let t=(r||o)&&n&&e.value!==`content:*`;return(0,V.jsxs)(`label`,{className:`flex items-center ${t?`opacity-50`:``}`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:a.permissions.includes(e.value),onChange:()=>S(e.value),disabled:t,className:`h-3 w-3 text-primary-600 focus:ring-primary-500 border-gray-300 rounded disabled:opacity-50 disabled:cursor-not-allowed`}),(0,V.jsx)(`span`,{className:`ml-2 text-xs text-gray-600 dark:text-gray-400`,children:e.label})]},e.value)})})]},e)})]}),!a.permissions.includes(`content:*`)&&(0,V.jsxs)(`div`,{className:`mt-4`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`userManagement.modal.customSchemaPermissions`)}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:i(`userManagement.modal.customPermissionPlaceholder`),className:`flex-1 rounded-md border-gray-300 dark:border-gray-600 dark:bg-gray-700 dark:text-white text-sm`,onKeyPress:e=>e.key===`Enter`&&w()}),(0,V.jsx)(U,{type:`button`,size:`sm`,onClick:w,disabled:!v.trim(),children:i(`userManagement.modal.addPermission`)})]}),a.permissions.filter(e=>!j.some(t=>t.value===e)).length>0&&(0,V.jsxs)(`div`,{className:`border border-gray-200 dark:border-gray-700 rounded-md p-2 bg-gray-50 dark:bg-gray-800`,children:[(0,V.jsx)(`div`,{className:`text-xs text-gray-600 dark:text-gray-400 mb-1`,children:i(`userManagement.modal.customPermissionsLabel`)}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:a.permissions.filter(e=>!j.some(t=>t.value===e)).map(e=>(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 bg-blue-100 dark:bg-blue-900 text-blue-800 dark:text-blue-200 text-xs rounded`,children:[e,(0,V.jsx)(`button`,{type:`button`,onClick:()=>T(e),className:`hover:text-blue-600 dark:hover:text-blue-300`,children:`×`})]},e))})]}),(0,V.jsx)(`div`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:i(`userManagement.modal.permissionFormatHelp`)})]})]})]})]}),(0,V.jsxs)(`div`,{className:`flex justify-end space-x-3 pt-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(U,{variant:`ghost`,onClick:n,disabled:s,children:i(`userManagement.modal.cancel`)}),(0,V.jsx)(U,{type:`submit`,onClick:D,disabled:s,children:s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),i(e?`userManagement.modal.updating`:`userManagement.modal.creating`)]}):i(e?`userManagement.modal.updateUser`:`userManagement.createUser`)})]})]})}):null}function F1(){let{t:e}=H(`studio`),{user:t}=ri(),{hasPermission:n}=ci(),[r,i]=p(),[a,o]=(0,B.useState)([]),[s,c]=(0,B.useState)(!0),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1),[m,h]=(0,B.useState)(``),g=n(ui.WRITE)||n(ui.INVITE),_=n(ui.WRITE),v=n(ui.DELETE),y=async()=>{try{c(!0);let e=await W.get(`/users`);e.success&&e.data&&e.data.users&&o(e.data.users)}catch(e){j1.error(`Failed to load users`,e)}finally{c(!1)}};(0,B.useEffect)(()=>{y(),r.get(`action`)===`add`&&(b(),i(e=>(e.delete(`action`),e)))},[r,i]);let b=()=>{u(null),f(!0)},x=e=>{u(e),f(!0)},S=async e=>{try{if(l){let n=await W.put(`/users/${l.id}`,e);n.success&&n.data&&(await y(),t?.id===l.id&&(window.dispatchEvent(new CustomEvent(`trokky:user:updated`,{detail:{user:n.data}})),j1.debug(`Emitted user update event for current user`)))}else(await W.post(`/users`,e)).success&&await y()}catch(e){throw j1.error(`Failed to save user`,e),e}},C=async t=>{if(confirm(e(`userManagement.deleteConfirm`,{username:t.username})))try{(await W.delete(`/users/${t.id}`)).success&&await y()}catch(e){j1.error(`Failed to delete user`,e)}},w=async t=>{if(confirm(e(`userManagement.resetMfaConfirm`,{username:t.username})))try{(await W.post(`/admin/users/${t.id}/mfa/reset`,{})).success&&(await y(),j1.info(`MFA reset for user`,{userId:t.id,username:t.username}))}catch(t){j1.error(`Failed to reset MFA`,t),alert(e(`userManagement.failedResetMfa`))}},T=e=>e.mfa?.enabled&&e.mfa?.methods?.some(e=>e.enabled&&e.verified),E=Array.isArray(a)?a.filter(e=>e.username.toLowerCase().includes(m.toLowerCase())||e.email.toLowerCase().includes(m.toLowerCase())||(e.firstName&&e.lastName?`${e.firstName} ${e.lastName}`:``).toLowerCase().includes(m.toLowerCase())):[],D=e=>{switch(e){case`admin`:return`bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400`;case`editor`:return`bg-blue-100 text-blue-800 dark:bg-blue-900/20 dark:text-blue-400`;case`writer`:return`bg-purple-100 text-purple-800 dark:bg-purple-900/20 dark:text-purple-400`;case`author`:return`bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400`;case`viewer`:return`bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400`;default:return`bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400`}},O=e=>{let t=D1[e.role]||[],n=e.permissions||[],r=[...t].sort(),i=[...n].sort();return r.join(`,`)!==i.join(`,`)};return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`userManagement.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`userManagement.subtitle`)})]}),g&&(0,V.jsxs)(U,{onClick:b,children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`userManagement.addUser`)]})]}),(0,V.jsx)(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:(0,V.jsx)(`div`,{className:`flex-1`,children:(0,V.jsx)(h1,{placeholder:e(`userManagement.searchPlaceholder`),value:m,onChange:e=>h(e.target.value)})})}),s?(0,V.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,V.jsx)(Ao,{})}):(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-200 dark:divide-gray-700`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`userManagement.tableHeaders.user`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`userManagement.tableHeaders.role`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`userManagement.tableHeaders.status`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`userManagement.tableHeaders.lastLogin`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`userManagement.tableHeaders.actions`)})]})}),(0,V.jsx)(`tbody`,{className:`bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700`,children:E.map(n=>(0,V.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-gray-700`,children:[(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:n.firstName&&n.lastName?`${n.firstName} ${n.lastName}`:n.username}),(0,V.jsxs)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[n.username,` • `,n.email]})]})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${D(n.role)}`,children:n.role}),O(n)&&(0,V.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-amber-100 text-amber-800 dark:bg-amber-900/20 dark:text-amber-400 rounded-full`,title:e(`userManagement.customPermissionsTooltip`),children:[(0,V.jsx)(de,{className:`h-3 w-3 mr-1`}),e(`userManagement.custom`)]})]})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${n.isActive?`bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400`:`bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400`}`,children:n.isActive?e(`userManagement.status.active`):e(`userManagement.status.inactive`)}),T(n)&&(0,V.jsxs)(`span`,{className:`inline-flex items-center px-1.5 py-0.5 text-xs font-medium bg-purple-100 text-purple-800 dark:bg-purple-900/20 dark:text-purple-400 rounded-full`,title:e(`userManagement.mfaEnabled`),children:[(0,V.jsx)(He,{className:`h-3 w-3 mr-1`}),e(`userManagement.mfa`)]})]})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:n.lastLoginAt?new Date(n.lastLoginAt).toLocaleDateString():e(`userManagement.never`)}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-right text-sm font-medium`,children:(0,V.jsxs)(`div`,{className:`flex justify-end space-x-2`,children:[_&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>x(n),title:e(`userManagement.editUserTitle`),children:(0,V.jsx)(ct,{className:`h-4 w-4`})}),_&&T(n)&&t?.id!==n.id&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>w(n),className:`text-amber-600 hover:text-amber-700 dark:text-amber-400 dark:hover:text-amber-300`,title:e(`userManagement.resetMfaTitle`),children:(0,V.jsx)(ke,{className:`h-4 w-4`})}),v&&t?.id!==n.id&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>C(n),className:`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,title:e(`userManagement.deleteUserTitle`),children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]})})]},n.id))})]})})}),(0,V.jsx)(P1,{user:l,isOpen:d,onClose:()=>f(!1),onSave:S})]})}var I1=Fr(`AppTokenManagement`),L1=[{value:`content:read`,labelKey:`appTokens.permissions.viewContent`,group:`Content`},{value:`content:write`,labelKey:`appTokens.permissions.editContent`,group:`Content`},{value:`content:delete`,labelKey:`appTokens.permissions.deleteContent`,group:`Content`},{value:`content:publish`,labelKey:`appTokens.permissions.publishContent`,group:`Content`},{value:`media:read`,labelKey:`appTokens.permissions.viewMedia`,group:`Media`},{value:`media:upload`,labelKey:`appTokens.permissions.uploadMedia`,group:`Media`},{value:`media:edit`,labelKey:`appTokens.permissions.editMedia`,group:`Media`},{value:`media:delete`,labelKey:`appTokens.permissions.deleteMedia`,group:`Media`}];function R1({isOpen:e,onClose:t,onSave:n}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)({name:``,description:``,permissions:[`content:read`,`media:read`],expiresAt:void 0}),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(`90days`),[u,d]=(0,B.useState)(``);(0,B.useEffect)(()=>{e&&(a({name:``,description:``,permissions:[`content:read`,`media:read`],expiresAt:void 0}),l(`90days`),d(``))},[e]);let f=async e=>{e.preventDefault(),s(!0);try{let e;if(c===`never`)e=void 0;else if(c===`custom`)e=new Date(u);else{let t={"30days":30,"90days":90,"1year":365}[c];e=new Date(Date.now()+t*24*60*60*1e3)}await n({...i,expiresAt:e}),t()}catch(e){I1.error(`Failed to create token`,e)}finally{s(!1)}},p=e=>{a(t=>({...t,permissions:t.permissions.includes(e)?t.permissions.filter(t=>t!==e):[...t.permissions,e]}))},m=L1.map(e=>({value:e.value,label:r(e.labelKey),group:e.group})).reduce((e,t)=>(e[t.group]||(e[t.group]=[]),e[t.group].push(t),e),{});return(0,V.jsx)(b1,{isOpen:e,onClose:t,title:r(`appTokens.modal.title`),size:`lg`,children:(0,V.jsxs)(`form`,{onSubmit:f,className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[r(`appTokens.modal.tokenName`),` *`]}),(0,V.jsx)(h1,{type:`text`,value:i.name,onChange:e=>a(t=>({...t,name:e.target.value})),placeholder:r(`appTokens.modal.tokenNamePlaceholder`),required:!0,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:r(`appTokens.modal.description`)}),(0,V.jsx)(`textarea`,{value:i.description,onChange:e=>a(t=>({...t,description:e.target.value})),placeholder:r(`appTokens.modal.descriptionPlaceholder`),rows:3,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white resize-none`,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:r(`appTokens.modal.expiration`)}),(0,V.jsxs)(`select`,{value:c,onChange:e=>l(e.target.value),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,disabled:o,children:[(0,V.jsx)(`option`,{value:`30days`,children:r(`appTokens.modal.expiration30days`)}),(0,V.jsx)(`option`,{value:`90days`,children:r(`appTokens.modal.expiration90days`)}),(0,V.jsx)(`option`,{value:`1year`,children:r(`appTokens.modal.expiration1year`)}),(0,V.jsx)(`option`,{value:`never`,children:r(`appTokens.modal.expirationNever`)}),(0,V.jsx)(`option`,{value:`custom`,children:r(`appTokens.modal.expirationCustom`)})]}),c===`custom`&&(0,V.jsx)(h1,{type:`date`,value:u,onChange:e=>d(e.target.value),className:`mt-2`,min:new Date().toISOString().split(`T`)[0],required:!0,disabled:o})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:r(`appTokens.modal.permissions`)}),(0,V.jsx)(`div`,{className:`border border-gray-300 dark:border-gray-600 rounded-md p-3 space-y-3 max-h-48 overflow-y-auto`,children:Object.entries(m).map(([e,t])=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e}),(0,V.jsx)(`div`,{className:`space-y-1 ml-2`,children:t.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:i.permissions.includes(e.value),onChange:()=>p(e.value),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`}),(0,V.jsx)(`span`,{className:`ml-2 text-sm text-gray-600 dark:text-gray-400`,children:e.label})]},e.value))})]},e))})]}),(0,V.jsxs)(`div`,{className:`flex justify-end space-x-3 pt-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(U,{variant:`ghost`,onClick:t,disabled:o,children:r(`appTokens.modal.cancel`)}),(0,V.jsx)(U,{type:`submit`,onClick:f,disabled:o||!i.name,children:o?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),r(`appTokens.modal.creating`)]}):r(`appTokens.modal.createToken`)})]})]})})}function z1({token:e,isOpen:t,onClose:n}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)(!1);return(0,V.jsx)(b1,{isOpen:t&&!!e,onClose:n,title:r(`appTokens.tokenCreated.title`),size:`md`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-md p-4 mb-4`,children:(0,V.jsxs)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:[(0,V.jsx)(`strong`,{children:r(`common.note`)}),` `,r(`appTokens.tokenCreated.warning`)]})}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300`,children:r(`appTokens.tokenCreated.yourToken`)}),(0,V.jsxs)(`div`,{className:`flex`,children:[(0,V.jsx)(`input`,{type:`text`,value:e||``,readOnly:!0,className:`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-l-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white font-mono text-sm`}),(0,V.jsx)(U,{onClick:async()=>{e&&(await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3))},className:`rounded-l-none`,variant:i?`secondary`:`primary`,children:i?r(`appTokens.tokenCreated.copied`):(0,V.jsx)(lt,{className:`h-4 w-4`})})]})]}),(0,V.jsx)(`div`,{className:`flex justify-end pt-4 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(U,{onClick:n,children:r(`appTokens.tokenCreated.close`)})})]})})}function B1(){let{t:e}=H(`studio`),{hasPermission:t}=ci(),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)(new Set),m=t(fi.WRITE),h=t(fi.DELETE),g=async()=>{try{a(!0);let e=await W.get(`/tokens`);e.success&&e.data&&r(e.data)}catch(e){I1.error(`Failed to load tokens`,e)}finally{a(!1)}};(0,B.useEffect)(()=>{g()},[]);let _=async e=>{try{let t=await W.post(`/tokens`,e);if(t.success&&t.data)return l(t.data.token),await g(),{token:t.data.token};throw Error(`Failed to create token`)}catch(e){throw I1.error(`Failed to create token`,e),e}},v=async t=>{if(confirm(e(`appTokens.deleteConfirm`,{name:t.name})))try{(await W.delete(`/tokens/${t.id}`)).success&&await g()}catch(e){I1.error(`Failed to delete token`,e)}},y=e=>{p(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},b=e=>f.has(e.id)?`••••••••`:`••••••••••••••••••••••••••••••••`,x=n.filter(e=>e.name.toLowerCase().includes(u.toLowerCase())||e.description?.toLowerCase().includes(u.toLowerCase())),S=e=>e.isActive?e.expiresAt&&new Date(e.expiresAt)<new Date?`bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400`:`bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400`:`bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400`,C=t=>t.isActive?t.expiresAt&&new Date(t.expiresAt)<new Date?e(`appTokens.status.expired`):e(`appTokens.status.active`):e(`appTokens.status.inactive`);return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`appTokens.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`appTokens.subtitle`)})]}),m&&(0,V.jsxs)(U,{onClick:()=>s(!0),children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`appTokens.createToken`)]})]}),(0,V.jsx)(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:(0,V.jsx)(`div`,{className:`flex-1`,children:(0,V.jsx)(h1,{placeholder:e(`appTokens.searchPlaceholder`),value:u,onChange:e=>d(e.target.value)})})}),i?(0,V.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,V.jsx)(Ao,{})}):x.length===0?(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(te,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-2`,children:e(`appTokens.noTokensTitle`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:e(`appTokens.noTokensDesc`)}),m&&(0,V.jsxs)(U,{onClick:()=>s(!0),children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`appTokens.createToken`)]})]}):(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-200 dark:divide-gray-700`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`appTokens.tableHeaders.token`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`appTokens.tableHeaders.status`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`appTokens.tableHeaders.lastUsed`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`appTokens.tableHeaders.expires`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`appTokens.tableHeaders.actions`)})]})}),(0,V.jsx)(`tbody`,{className:`bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700`,children:x.map(t=>(0,V.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-gray-700`,children:[(0,V.jsx)(`td`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:t.name}),t.description&&(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t.description}),(0,V.jsxs)(`div`,{className:`text-xs text-gray-400 font-mono mt-1 flex items-center`,children:[(0,V.jsx)(`span`,{children:b(t)}),(0,V.jsx)(`button`,{onClick:()=>y(t.id),className:`ml-2 hover:text-gray-600 dark:hover:text-gray-300`,children:f.has(t.id)?(0,V.jsx)(le,{className:`h-3 w-3`}):(0,V.jsx)(ce,{className:`h-3 w-3`})})]})]})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap`,children:(0,V.jsx)(`span`,{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${S(t)}`,children:C(t)})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:t.lastUsedAt?new Date(t.lastUsedAt).toLocaleDateString():e(`appTokens.never`)}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:t.expiresAt?(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(re,{className:`h-4 w-4 mr-1`}),new Date(t.expiresAt).toLocaleDateString()]}):e(`appTokens.never`)}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-right text-sm font-medium`,children:h&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>v(t),className:`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,children:(0,V.jsx)(Be,{className:`h-4 w-4`})})})]},t.id))})]})})}),(0,V.jsx)(R1,{isOpen:o,onClose:()=>s(!1),onSave:_}),(0,V.jsx)(z1,{token:c,isOpen:!!c,onClose:()=>l(null)})]})}var V1=Fr(`WebhookManagement`),H1=[{value:`document.*`,labelKey:`webhooks.events.allDocuments`,group:`Documents`},{value:`document.created`,labelKey:`webhooks.events.documentCreated`,group:`Documents`},{value:`document.updated`,labelKey:`webhooks.events.documentUpdated`,group:`Documents`},{value:`document.deleted`,labelKey:`webhooks.events.documentDeleted`,group:`Documents`},{value:`document.published`,labelKey:`webhooks.events.documentPublished`,group:`Documents`},{value:`document.unpublished`,labelKey:`webhooks.events.documentUnpublished`,group:`Documents`},{value:`media.*`,labelKey:`webhooks.events.allMedia`,group:`Media`},{value:`media.uploaded`,labelKey:`webhooks.events.mediaUploaded`,group:`Media`},{value:`media.updated`,labelKey:`webhooks.events.mediaUpdated`,group:`Media`},{value:`media.deleted`,labelKey:`webhooks.events.mediaDeleted`,group:`Media`},{value:`user.*`,labelKey:`webhooks.events.allUsers`,group:`Users`},{value:`user.created`,labelKey:`webhooks.events.userCreated`,group:`Users`},{value:`user.updated`,labelKey:`webhooks.events.userUpdated`,group:`Users`},{value:`user.login`,labelKey:`webhooks.events.userLogin`,group:`Users`},{value:`system.*`,labelKey:`webhooks.events.allSystem`,group:`System`},{value:`system.startup`,labelKey:`webhooks.events.systemStartup`,group:`System`},{value:`system.error`,labelKey:`webhooks.events.systemError`,group:`System`}];function U1({isOpen:e,onClose:t,onSave:n,webhook:r}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)({name:``,url:``,events:[`document.created`,`document.updated`],secret:``,active:!0,headers:{},retryPolicy:{maxRetries:3,backoffType:`exponential`,baseDelay:1e3,maxDelay:3e4}}),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(``);(0,B.useEffect)(()=>{e&&(o(r?{name:r.name,url:r.url,events:r.events,secret:r.secret||``,active:r.active,headers:r.headers||{},retryPolicy:r.retryPolicy||{maxRetries:3,backoffType:`exponential`,baseDelay:1e3,maxDelay:3e4}}:{name:``,url:``,events:[`document.created`,`document.updated`],secret:``,active:!0,headers:{},retryPolicy:{maxRetries:3,backoffType:`exponential`,baseDelay:1e3,maxDelay:3e4}}),u(``),f(``))},[e,r]);let p=async e=>{e.preventDefault(),c(!0);try{await n(a),t()}catch(e){V1.error(`Failed to save webhook`,e)}finally{c(!1)}},m=e=>{o(t=>({...t,events:t.events.includes(e)?t.events.filter(t=>t!==e):[...t.events,e]}))},h=()=>{l.trim()&&d.trim()&&(o(e=>({...e,headers:{...e.headers,[l.trim()]:d.trim()}})),u(``),f(``))},g=e=>{o(t=>({...t,headers:Object.fromEntries(Object.entries(t.headers).filter(([t])=>t!==e))}))},_=()=>{let e=`wh_${Math.random().toString(36).substr(2,32)}`;o(t=>({...t,secret:e}))},v=H1.map(e=>({value:e.value,label:i(e.labelKey),group:e.group})).reduce((e,t)=>(e[t.group]||(e[t.group]=[]),e[t.group].push(t),e),{});return(0,V.jsx)(b1,{isOpen:e,onClose:t,title:i(r?`webhooks.modal.editTitle`:`webhooks.modal.createTitle`),size:`lg`,children:(0,V.jsxs)(`form`,{onSubmit:p,className:`space-y-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[i(`webhooks.modal.name`),` *`]}),(0,V.jsx)(h1,{type:`text`,value:a.name,onChange:e=>o(t=>({...t,name:e.target.value})),placeholder:i(`webhooks.modal.namePlaceholder`),required:!0,disabled:s})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:[i(`webhooks.modal.url`),` *`]}),(0,V.jsx)(h1,{type:`url`,value:a.url,onChange:e=>o(t=>({...t,url:e.target.value})),placeholder:i(`webhooks.modal.urlPlaceholder`),required:!0,disabled:s})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`webhooks.modal.events`)}),(0,V.jsx)(`div`,{className:`border border-gray-300 dark:border-gray-600 rounded-md p-3 space-y-3 max-h-48 overflow-y-auto`,children:Object.entries(v).map(([e,t])=>(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e}),(0,V.jsx)(`div`,{className:`space-y-1 ml-2`,children:t.map(e=>(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:a.events.includes(e.value),onChange:()=>m(e.value),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`}),(0,V.jsx)(`span`,{className:`ml-2 text-sm text-gray-600 dark:text-gray-400`,children:e.label})]},e.value))})]},e))})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`webhooks.modal.secret`)}),(0,V.jsxs)(`div`,{className:`flex`,children:[(0,V.jsx)(h1,{type:`text`,value:a.secret,onChange:e=>o(t=>({...t,secret:e.target.value})),placeholder:i(`webhooks.modal.secretPlaceholder`),disabled:s,className:`flex-1`}),(0,V.jsx)(U,{type:`button`,onClick:_,variant:`secondary`,className:`ml-2 whitespace-nowrap`,disabled:s,children:i(`common.generate`)})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-1`,children:i(`webhooks.modal.secretDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`webhooks.modal.headers`)}),Object.entries(a.headers).length>0&&(0,V.jsx)(`div`,{className:`mb-3 space-y-1`,children:Object.entries(a.headers).map(([e,t])=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between bg-gray-50 dark:bg-gray-700 p-2 rounded`,children:[(0,V.jsxs)(`span`,{className:`text-sm font-mono`,children:[e,`: `,t]}),(0,V.jsx)(U,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>g(e),className:`text-red-500 hover:text-red-700`,children:(0,V.jsx)(We,{className:`h-4 w-4`})})]},e))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(h1,{placeholder:i(`webhooks.modal.headerNamePlaceholder`),value:l,onChange:e=>u(e.target.value),disabled:s,className:`flex-1`}),(0,V.jsx)(h1,{placeholder:i(`webhooks.modal.headerValuePlaceholder`),value:d,onChange:e=>f(e.target.value),disabled:s,className:`flex-1`}),(0,V.jsx)(U,{type:`button`,onClick:h,variant:`secondary`,disabled:s||!l.trim()||!d.trim(),children:i(`common.add`)})]})]}),(0,V.jsxs)(`div`,{className:`grid grid-cols-2 gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`webhooks.modal.maxRetries`)}),(0,V.jsx)(h1,{type:`number`,min:0,max:10,value:a.retryPolicy.maxRetries,onChange:e=>o(t=>({...t,retryPolicy:{...t.retryPolicy,maxRetries:parseInt(e.target.value)||0}})),disabled:s})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:i(`webhooks.modal.backoffStrategy`)}),(0,V.jsxs)(`select`,{value:a.retryPolicy.backoffType,onChange:e=>o(t=>({...t,retryPolicy:{...t.retryPolicy,backoffType:e.target.value}})),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,disabled:s,children:[(0,V.jsx)(`option`,{value:`linear`,children:i(`webhooks.modal.linear`)}),(0,V.jsx)(`option`,{value:`exponential`,children:i(`webhooks.modal.exponential`)})]})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:`webhook-active`,checked:a.active,onChange:e=>o(t=>({...t,active:e.target.checked})),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded`,disabled:s}),(0,V.jsx)(`label`,{htmlFor:`webhook-active`,className:`ml-2 text-sm text-gray-700 dark:text-gray-300`,children:i(`webhooks.modal.active`)})]}),(0,V.jsxs)(`div`,{className:`flex justify-end space-x-3 pt-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(U,{variant:`ghost`,onClick:t,disabled:s,children:i(`common.cancel`)}),(0,V.jsx)(U,{type:`submit`,disabled:s||!a.name||!a.url||a.events.length===0,children:s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),i(r?`webhooks.modal.updating`:`webhooks.modal.creating`)]}):i(r?`webhooks.modal.update`:`webhooks.modal.create`)})]})]})})}function W1({webhook:e,isOpen:t,onClose:n}){let{t:r}=H(`studio`),[i,a]=(0,B.useState)([]),[o,s]=(0,B.useState)(!1);(0,B.useEffect)(()=>{t&&e&&c()},[t,e]);let c=async()=>{if(e)try{s(!0);let t=await W.get(`/webhooks/${e.id}/deliveries`);t.success&&t.data&&a(t.data.deliveries||[])}catch(e){V1.error(`Failed to load deliveries`,e)}finally{s(!1)}};return(0,V.jsx)(b1,{isOpen:t&&!!e,onClose:n,title:r(`webhooks.deliveryModal.title`,{name:e?.name}),size:`xl`,children:(0,V.jsx)(`div`,{className:`space-y-4`,children:o?(0,V.jsx)(`div`,{className:`flex justify-center py-8`,children:(0,V.jsx)(Ao,{})}):i.length===0?(0,V.jsxs)(`div`,{className:`text-center py-8`,children:[(0,V.jsx)(re,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:r(`webhooks.deliveryModal.noDeliveries`)})]}):(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-200 dark:divide-gray-700`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`webhooks.deliveryModal.status`)}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`webhooks.deliveryModal.response`)}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`webhooks.deliveryModal.timestamp`)}),(0,V.jsx)(`th`,{className:`px-4 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:r(`webhooks.deliveryModal.attempt`)})]})}),(0,V.jsx)(`tbody`,{className:`bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700`,children:i.map(e=>(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`td`,{className:`px-4 py-4 whitespace-nowrap`,children:(0,V.jsxs)(`span`,{className:`inline-flex items-center px-2 py-1 text-xs font-semibold rounded-full ${e.success?`bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400`:`bg-red-100 text-red-800 dark:bg-red-900/20 dark:text-red-400`}`,children:[e.success?(0,V.jsx)(Ae,{className:`h-3 w-3 mr-1`}):(0,V.jsx)(We,{className:`h-3 w-3 mr-1`}),e.success?r(`webhooks.deliveryModal.success`):r(`webhooks.deliveryModal.failed`)]})}),(0,V.jsx)(`td`,{className:`px-4 py-4 whitespace-nowrap text-sm`,children:(0,V.jsxs)(`div`,{children:[e.statusCode&&(0,V.jsx)(`span`,{className:`font-mono text-gray-900 dark:text-white`,children:e.statusCode}),(0,V.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[e.responseTime,`ms`]}),e.error&&(0,V.jsx)(`div`,{className:`text-xs text-red-500 max-w-xs truncate`,title:e.error,children:e.error})]})}),(0,V.jsx)(`td`,{className:`px-4 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:new Date(e.timestamp).toLocaleString()}),(0,V.jsxs)(`td`,{className:`px-4 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:[`#`,e.attempt]})]},e.deliveryId))})]})})})})}function G1(){let{t:e}=H(`studio`),{hasPermission:t}=ci(),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null),[m,h]=(0,B.useState)(``),[g,_]=(0,B.useState)(null),v=t(pi.WRITE),y=t(pi.WRITE),b=t(pi.DELETE),x=async()=>{try{a(!0);let e=await W.get(`/webhooks`);e.success&&e.data&&r(e.data.webhooks||[])}catch(e){V1.error(`Failed to load webhooks`,e)}finally{a(!1)}};(0,B.useEffect)(()=>{x()},[]);let S=async e=>{try{(await W.post(`/webhooks`,{webhookData:e})).success&&await x()}catch(e){throw V1.error(`Failed to create webhook`,e),e}},C=async e=>{if(c)try{(await W.put(`/webhooks/${c.id}`,{webhookData:e})).success&&(await x(),l(void 0))}catch(e){throw V1.error(`Failed to update webhook`,e),e}},w=async t=>{if(confirm(e(`webhooks.deleteConfirm`,{name:t.name})))try{(await W.delete(`/webhooks/${t.id}`)).success&&await x()}catch(e){V1.error(`Failed to delete webhook`,e)}},T=async e=>{try{_(e.id),(await W.post(`/webhooks/${e.id}/test`,{eventType:`system.test`})).success&&V1.info(`Test webhook sent successfully`)}catch(e){V1.error(`Failed to test webhook`,e)}finally{_(null)}},E=e=>{l(e),s(!0)},D=e=>{p(e),d(!0)},O=()=>{s(!1),l(void 0),d(!1),p(null)},k=n.filter(e=>e.name.toLowerCase().includes(m.toLowerCase())||e.url.toLowerCase().includes(m.toLowerCase())),A=e=>e.active?`bg-green-100 text-green-800 dark:bg-green-900/20 dark:text-green-400`:`bg-gray-100 text-gray-800 dark:bg-gray-900/20 dark:text-gray-400`,j=t=>t.active?e(`webhooks.status.active`):e(`webhooks.status.inactive`);return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between items-center`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`webhooks.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`webhooks.subtitle`)})]}),v&&(0,V.jsxs)(U,{onClick:()=>s(!0),children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`webhooks.createWebhook`)]})]}),(0,V.jsx)(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:(0,V.jsx)(`div`,{className:`flex-1`,children:(0,V.jsx)(h1,{placeholder:e(`webhooks.searchPlaceholder`),value:m,onChange:e=>h(e.target.value)})})}),i?(0,V.jsx)(`div`,{className:`flex justify-center py-12`,children:(0,V.jsx)(Ao,{})}):k.length===0?(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-8 text-center`,children:[(0,V.jsx)(I,{className:`h-12 w-12 text-gray-400 mx-auto mb-4`}),(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-2`,children:e(`webhooks.noWebhooksTitle`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:e(`webhooks.noWebhooksDesc`)}),v&&(0,V.jsxs)(U,{onClick:()=>s(!0),children:[(0,V.jsx)(Ne,{className:`h-4 w-4 mr-2`}),e(`webhooks.createWebhook`)]})]}):(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:(0,V.jsx)(`div`,{className:`overflow-x-auto`,children:(0,V.jsxs)(`table`,{className:`min-w-full divide-y divide-gray-200 dark:divide-gray-700`,children:[(0,V.jsx)(`thead`,{className:`bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`webhooks.tableHeaders.webhook`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`webhooks.tableHeaders.status`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`webhooks.tableHeaders.events`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-left text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`webhooks.tableHeaders.lastUpdated`)}),(0,V.jsx)(`th`,{className:`px-6 py-3 text-right text-xs font-medium text-gray-500 dark:text-gray-400 uppercase tracking-wider`,children:e(`webhooks.tableHeaders.actions`)})]})}),(0,V.jsx)(`tbody`,{className:`bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700`,children:k.map(t=>(0,V.jsxs)(`tr`,{className:`hover:bg-gray-50 dark:hover:bg-gray-700`,children:[(0,V.jsx)(`td`,{className:`px-6 py-4`,children:(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:t.name}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400 font-mono`,children:t.url})]})}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap`,children:(0,V.jsx)(`span`,{className:`inline-flex px-2 py-1 text-xs font-semibold rounded-full ${A(t)}`,children:j(t)})}),(0,V.jsxs)(`td`,{className:`px-6 py-4`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`webhooks.eventsCount`,{count:t.events.length})}),(0,V.jsxs)(`div`,{className:`text-xs text-gray-400 max-w-xs`,children:[t.events.slice(0,3).join(`, `),t.events.length>3&&` ${e(`webhooks.moreEvents`,{count:t.events.length-3})}`]})]}),(0,V.jsx)(`td`,{className:`px-6 py-4 whitespace-nowrap text-sm text-gray-500 dark:text-gray-400`,children:new Date(t.updatedAt).toLocaleDateString()}),(0,V.jsxs)(`td`,{className:`px-6 py-4 whitespace-nowrap text-right text-sm font-medium space-x-2`,children:[(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>T(t),disabled:g===t.id||!t.active,title:e(`webhooks.testWebhook`),children:g===t.id?(0,V.jsx)(ke,{className:`h-4 w-4 animate-spin`}):(0,V.jsx)(Se,{className:`h-4 w-4`})}),(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>D(t),title:e(`webhooks.viewDeliveryHistory`),children:(0,V.jsx)(ce,{className:`h-4 w-4`})}),y&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>E(t),title:e(`webhooks.editWebhook`),children:(0,V.jsx)(ct,{className:`h-4 w-4`})}),b&&(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:()=>w(t),className:`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,title:e(`webhooks.deleteWebhook`),children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]})]},t.id))})]})})}),(0,V.jsx)(U1,{isOpen:o,onClose:O,onSave:c?C:S,webhook:c}),(0,V.jsx)(W1,{webhook:f,isOpen:u,onClose:O})]})}function K1(){let{t:e}=H(`studio`);za({page:`users`,title:e(`users.title`),defaultVisible:!1,defaultPosition:`left`});let{hasPermission:t}=ci(),n=t(ui.READ),r=t(fi.READ),i=t(pi.READ),a=n||r||i,[o,s]=(0,B.useState)(`users`),[c,l]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{c||(n?s(`users`):r?s(`tokens`):i&&s(`webhooks`),l(!0))},[n,r,i,c]),a?(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`usersPage.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`usersPage.subtitle`)})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:[(0,V.jsx)(`div`,{className:`border-b border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`nav`,{className:`-mb-px flex`,children:[n&&(0,V.jsx)(`button`,{onClick:()=>s(`users`),className:`py-3 px-6 text-sm font-medium border-b-2 transition-colors ${o===`users`?`border-primary-500 text-primary-600 dark:text-primary-400`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300`}`,children:e(`usersPage.tabs.users`)}),r&&(0,V.jsx)(`button`,{onClick:()=>s(`tokens`),className:`py-3 px-6 text-sm font-medium border-b-2 transition-colors ${o===`tokens`?`border-primary-500 text-primary-600 dark:text-primary-400`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300`}`,children:e(`usersPage.tabs.tokens`)}),i&&(0,V.jsx)(`button`,{onClick:()=>s(`webhooks`),className:`py-3 px-6 text-sm font-medium border-b-2 transition-colors ${o===`webhooks`?`border-primary-500 text-primary-600 dark:text-primary-400`:`border-transparent text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-300`}`,children:e(`usersPage.tabs.webhooks`)})]})}),(0,V.jsxs)(`div`,{className:`p-6`,children:[o===`users`&&n&&(0,V.jsx)(F1,{}),o===`tokens`&&r&&(0,V.jsx)(B1,{}),o===`webhooks`&&i&&(0,V.jsx)(G1,{})]})]})]}):(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`usersPage.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`usersPage.subtitle`)})]}),(0,V.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-6 w-6 text-yellow-600 dark:text-yellow-400 mr-3`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:e(`usersPage.accessDenied`)}),(0,V.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:e(`usersPage.accessDeniedMessage`)})]})]})})]})}var q1=Fr(`config-service`),J1=class{client;cachedConfig=null;constructor(e){this.client=e}async fetchAndMergeConfig(){if(this.cachedConfig)return this.cachedConfig;try{let e=await this.client.get(`/config/studio`);if(e.success&&e.data&&e.data.studioConfig){let t=e.data.studioConfig,n=window.TROKKY_CONFIG||{},r={...n,branding:{...n.branding,...t.branding},...t.sessionConfig?{sessionConfig:t.sessionConfig}:{}};return window.TROKKY_CONFIG=r,this.cachedConfig=t,q1.debug(`Config updated from API`,{title:t.branding?.title,hasConfig:!!t}),t}}catch(e){q1.warn(`Failed to fetch config from API, falling back to window config`,e)}let e=window.TROKKY_CONFIG||{};return this.cachedConfig=e,e}async getBranding(){return(await this.fetchAndMergeConfig()).branding||{title:`Trokky Studio`}}clearCache(){this.cachedConfig=null}},Y1=null;function X1(e){return Y1||=new J1(e),Y1}function Z1(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)({title:`Trokky Studio`}),[i,a]=(0,B.useState)(!0);return(0,B.useEffect)(()=>{(async()=>{try{let e=X1(W),[n,i]=await Promise.all([e.fetchAndMergeConfig(),e.getBranding()]);t(n),r(i)}catch(e){console.warn(`[useStudioConfig] Failed to fetch config:`,e);let t=window.TROKKY_CONFIG;r(t?.branding||{title:`Trokky Studio`})}finally{a(!1)}})()},[W]),{config:e,branding:n,loading:i}}function Q1(){let{branding:e,loading:t}=Z1();return{branding:e,loading:t}}var $1=Fr(`SettingsPage`);function e0(){let{t:e}=H(`studio`),t=za({page:`settings`,title:e(`settings.title`)}),{hasPermission:n}=ci(),{branding:r}=Q1(),i=pa()?.utils?.showToast||((e,t)=>console.log(`Toast: ${t} - ${e}`)),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(``),[d,f]=(0,B.useState)(``),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(``),[_,v]=(0,B.useState)(`system`),[y,b]=(0,B.useState)(!0),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)(!1),[T,E]=(0,B.useState)([]),[D,O]=(0,B.useState)([`totp`,`email`]),k=n(di.READ),A=n(di.WRITE);if((0,B.useEffect)(()=>{t.configure({page:`settings`,title:e(`settings.title`),defaultVisible:!1})},[t.configure,e]),(0,B.useEffect)(()=>{k&&j()},[k]),!k)return(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`settings.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`settings.subtitle`)})]}),(0,V.jsx)(`div`,{className:`bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg p-6`,children:(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(de,{className:`h-6 w-6 text-yellow-600 dark:text-yellow-400 mr-3`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-yellow-800 dark:text-yellow-200`,children:e(`settings.accessDenied`)}),(0,V.jsx)(`p`,{className:`text-sm text-yellow-700 dark:text-yellow-300 mt-1`,children:e(`settings.accessDeniedMessage`)})]})]})})]});let j=async()=>{try{b(!0),$1.debug(`Loading settings from API`);let e=await W.get(`/config/settings`);if(e.success&&e.data?.settings){let t=e.data.settings;o(t.publicUrl||M()),c(t.studioTitle||`Trokky Studio`),u(t.organizationName||``),f(t.primaryColor||``),m(t.secondaryColor||``),g(t.logo||``),v(t.defaultTheme||`system`),w(t.mfaRequired||!1),E(t.mfaEnforcedRoles||[]),O(t.mfaAllowedMethods||[`totp`,`email`]),$1.info(`Settings loaded successfully`,{settings:t})}else o(M()),c(r?.title||`Trokky Studio`),u(``),f(``),m(``),g(``),v(`system`),w(!1),E([]),O([`totp`,`email`]),$1.warn(`No settings found, using defaults`)}catch(t){$1.error(`Failed to load settings`,t),o(M()),c(r?.title||`Trokky Studio`),u(``),f(``),m(``),g(``),v(`system`),w(!1),E([]),O([`totp`,`email`]),i(e(`settings.loadError`),`error`)}finally{b(!1)}},M=()=>{let e=window.location.origin;return window.location.pathname.includes(`/studio`),e};return y?(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`settings.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`settings.subtitle`)})]}),(0,V.jsx)(`div`,{className:`max-w-4xl`,children:(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(`div`,{className:`text-gray-500 dark:text-gray-400`,children:e(`settings.loading`)})})})})]}):(0,V.jsxs)(`div`,{className:`p-6`,children:[(0,V.jsxs)(`div`,{className:`mb-8`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`settings.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`settings.subtitle`)})]}),(0,V.jsxs)(`div`,{className:`max-w-4xl`,children:[(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-white mb-6`,children:e(`settings.generalSettings`)}),(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.studioTitle`)}),(0,V.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),disabled:!A,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`Trokky Studio`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.studioTitleDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.organizationName`)}),(0,V.jsx)(`input`,{type:`text`,value:l,onChange:e=>u(e.target.value),disabled:!A,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`Your Organization Name`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.organizationNameDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.primaryColor`)}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`color`,value:d||`#3B82F6`,onChange:e=>f(e.target.value),disabled:!A,className:`h-10 w-16 border border-gray-300 dark:border-gray-600 rounded-md disabled:opacity-50 disabled:cursor-not-allowed`}),(0,V.jsx)(`input`,{type:`text`,value:d,onChange:e=>f(e.target.value),disabled:!A,className:`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`#3B82F6`})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.primaryColorDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.secondaryColor`)}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(`input`,{type:`color`,value:p||`#6B7280`,onChange:e=>m(e.target.value),disabled:!A,className:`h-10 w-16 border border-gray-300 dark:border-gray-600 rounded-md disabled:opacity-50 disabled:cursor-not-allowed`}),(0,V.jsx)(`input`,{type:`text`,value:p,onChange:e=>m(e.target.value),disabled:!A,className:`flex-1 px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`#6B7280`})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.secondaryColorDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.logoUrl`)}),(0,V.jsx)(`input`,{type:`url`,value:h,onChange:e=>g(e.target.value),disabled:!A,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`https://yoursite.com/logo.png`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.logoUrlDescription`)}),h&&(0,V.jsxs)(`div`,{className:`mt-3 p-3 bg-gray-50 dark:bg-gray-900 rounded border border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-600 dark:text-gray-400 mb-2`,children:e(`settings.logoPreview`)}),(0,V.jsx)(`img`,{src:h,alt:`Logo preview`,className:`h-16 w-auto object-contain`})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.publicUrl`)}),(0,V.jsx)(`input`,{type:`url`,value:a,onChange:e=>o(e.target.value),disabled:!A,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,placeholder:`https://yourwebsite.com`}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.publicUrlDescription`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`settings.defaultTheme`)}),(0,V.jsxs)(`select`,{value:_,onChange:e=>v(e.target.value),disabled:!A,className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:outline-none focus:ring-2 focus:ring-primary-500 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,V.jsx)(`option`,{value:`system`,children:e(`theme.system`)}),(0,V.jsx)(`option`,{value:`light`,children:e(`theme.light`)}),(0,V.jsx)(`option`,{value:`dark`,children:e(`theme.dark`)})]}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-1`,children:e(`settings.defaultThemeDescription`)})]})]})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6 mt-6`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-gray-900 dark:text-white mb-6`,children:e(`settings.securitySettings`)}),(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-3`,children:e(`settings.mfa.title`)}),(0,V.jsxs)(`div`,{className:`flex items-center mb-4`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:`mfaRequired`,checked:C,onChange:e=>w(e.target.checked),disabled:!A,className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded disabled:opacity-50`}),(0,V.jsx)(`label`,{htmlFor:`mfaRequired`,className:`ml-2 text-sm text-gray-700 dark:text-gray-300`,children:e(`settings.mfa.requireAll`)})]}),(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-2`,children:e(`settings.mfa.requireRoles`)}),(0,V.jsx)(`div`,{className:`space-y-2 ml-4`,children:[`admin`,`editor`,`author`,`viewer`].map(e=>(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:`mfa-role-${e}`,checked:T.includes(e),onChange:t=>{t.target.checked?E([...T,e]):E(T.filter(t=>t!==e))},disabled:!A||C,className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded disabled:opacity-50`}),(0,V.jsx)(`label`,{htmlFor:`mfa-role-${e}`,className:`ml-2 text-sm text-gray-700 dark:text-gray-300 capitalize`,children:e})]},e))}),C&&(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2 ml-4`,children:e(`settings.mfa.roleDisabledNote`)})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white mb-3`,children:e(`settings.mfa.allowedMethods`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-2`,children:e(`settings.mfa.allowedMethodsDescription`)}),(0,V.jsxs)(`div`,{className:`space-y-2 ml-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:`mfa-method-totp`,checked:D.includes(`totp`),onChange:e=>{e.target.checked?O([...D,`totp`]):D.length>1&&O(D.filter(e=>e!==`totp`))},disabled:!A||D.length===1&&D.includes(`totp`),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded disabled:opacity-50`}),(0,V.jsx)(`label`,{htmlFor:`mfa-method-totp`,className:`ml-2 text-sm text-gray-700 dark:text-gray-300`,children:e(`settings.mfa.totp`)})]}),(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`input`,{type:`checkbox`,id:`mfa-method-email`,checked:D.includes(`email`),onChange:e=>{e.target.checked?O([...D,`email`]):D.length>1&&O(D.filter(e=>e!==`email`))},disabled:!A||D.length===1&&D.includes(`email`),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded disabled:opacity-50`}),(0,V.jsx)(`label`,{htmlFor:`mfa-method-email`,className:`ml-2 text-sm text-gray-700 dark:text-gray-300`,children:e(`settings.mfa.email`)})]})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mt-2 ml-4`,children:e(`settings.mfa.atLeastOne`)})]}),(0,V.jsx)(`div`,{className:`bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4`,children:(0,V.jsxs)(`p`,{className:`text-sm text-blue-800 dark:text-blue-200`,children:[(0,V.jsx)(`strong`,{children:e(`common.note`)}),` `,e(`settings.mfa.enforcementNote`)]})})]})]}),(0,V.jsxs)(`div`,{className:`mt-6 pt-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`button`,{onClick:async()=>{try{S(!0);let t=a.replace(/\/$/,``),n={publicUrl:t,studioTitle:s,organizationName:l,primaryColor:d,secondaryColor:p,logo:h,defaultTheme:_,mfaRequired:C,mfaEnforcedRoles:T,mfaAllowedMethods:D};$1.debug(`Saving settings via API`,n);let r=await W.put(`/config/settings`,{settings:n});if(r.success)o(t),window.dispatchEvent(new CustomEvent(`trokky:settings:updated`,{detail:{settings:n}})),$1.info(`Settings saved successfully`,{settings:n}),i(e(`settings.saveSuccess`),`success`);else throw Error(r.error?.message||`Failed to save settings`)}catch(t){$1.error(`Failed to save settings`,t);let n=t instanceof Error?t.message:`Unknown error`;i(e(`settings.saveError`,{error:n}),`error`)}finally{S(!1)}},disabled:x||!A,className:`px-4 py-2 bg-primary-600 text-white rounded-md hover:bg-primary-700 focus:outline-none focus:ring-2 focus:ring-primary-500 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:e(x?`settings.saving`:`settings.saveChanges`)}),!A&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mt-2`,children:e(`settings.readOnlyMessage`)})]})]})]})}function t0({mode:e=`login`,onError:t,disabled:n,className:r=``}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)(!1);return(0,V.jsxs)(U,{type:`button`,onClick:async()=>{o(!0);try{let n=await W.post(`/auth/oauth/google/init`,{mode:e});if(n.success&&n.data)sessionStorage.setItem(`oauth_state`,n.data.state),sessionStorage.setItem(`oauth_code_verifier`,n.data.codeVerifier),sessionStorage.setItem(`oauth_mode`,e),window.location.href=n.data.authUrl;else{let e=n.error?.message||i(`oauth.google.initFailed`);t?.(e)}}catch(e){let n=e instanceof Error?e.message:i(`oauth.google.initFailed`);t?.(n)}finally{o(!1)}},disabled:n||a,variant:`outline`,className:`w-full flex items-center justify-center gap-3 h-12 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${r}`,children:[a?(0,V.jsx)(Ao,{size:`sm`}):(0,V.jsx)(n0,{className:`w-5 h-5`}),(0,V.jsx)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:i(e===`link`?`oauth.google.linkAccount`:`oauth.google.signIn`)})]})}function n0({className:e}){return(0,V.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,V.jsx)(`path`,{fill:`#4285F4`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,V.jsx)(`path`,{fill:`#34A853`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,V.jsx)(`path`,{fill:`#FBBC05`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,V.jsx)(`path`,{fill:`#EA4335`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]})}function r0(){let{t:e}=H(`studio`),{user:t,refetch:n}=si(),[r,i]=(0,B.useState)(null),[a,o]=(0,B.useState)(!0),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),d=t?.oauthProviders||[];(0,B.useEffect)(()=>{f()},[]);let f=async()=>{try{let e=await W.get(`/auth/oauth/status`);e.success&&e.data&&i(e.data)}catch(e){console.error(`Failed to fetch OAuth status:`,e)}finally{o(!1)}},p=async t=>{c(t),u(null);try{let r=await W.delete(`/auth/oauth/${t}/unlink`);if(r.success)await n(),u({type:`success`,text:e(`oauth.unlinkSuccess`,{provider:g(t)})});else throw Error(r.error?.message||e(`oauth.unlinkFailed`))}catch(t){u({type:`error`,text:t instanceof Error?t.message:e(`oauth.unlinkFailed`)})}finally{c(null),setTimeout(()=>u(null),5e3)}},m=async()=>{u({type:`success`,text:e(`oauth.accountLinked`)}),await n()},h=e=>{u({type:`error`,text:e}),setTimeout(()=>u(null),5e3)},g=e=>({google:`Google`,github:`GitHub`,microsoft:`Microsoft`})[e]||e;return a?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(Ao,{size:`md`})}):r?.providers?.google?(0,V.jsxs)(`div`,{className:`space-y-4`,children:[l&&(0,V.jsx)(`div`,{className:`p-3 rounded-lg text-sm ${l.type===`success`?`bg-green-50 text-green-800 border border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800`:`bg-red-50 text-red-800 border border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800`}`,children:l.text}),r?.providers?.google&&(0,V.jsx)(i0,{provider:`google`,isLinked:(e=>d.some(t=>t.provider===e))(`google`),linkedData:(e=>d.find(t=>t.provider===e))(`google`),isUnlinking:s===`google`,onUnlink:()=>p(`google`),onLinkSuccess:m,onLinkError:h,getProviderIcon:e=>{switch(e){case`google`:return(0,V.jsx)(a0,{className:`w-5 h-5`});case`github`:return(0,V.jsx)(o0,{className:`w-5 h-5`});case`microsoft`:return(0,V.jsx)(s0,{className:`w-5 h-5`});default:return null}},getProviderName:g,formatDate:e=>new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`}),t:e})]}):null}function i0({provider:e,isLinked:t,linkedData:n,isUnlinking:r,onUnlink:i,onLinkSuccess:a,onLinkError:o,getProviderIcon:s,getProviderName:c,formatDate:l,t:u}){return(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-900/50 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:s(e)}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:c(e)}),t&&n?(0,V.jsxs)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:[n.email,` - `,u(`oauth.linked`,{date:l(n.linkedAt)})]}):(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:u(`oauth.notConnected`)})]})]}),(0,V.jsx)(`div`,{children:t?(0,V.jsx)(U,{variant:`outline`,size:`sm`,onClick:i,disabled:r,className:`text-red-600 dark:text-red-400 border-red-300 dark:border-red-700 hover:bg-red-50 dark:hover:bg-red-900/20`,children:r?(0,V.jsx)(Ao,{size:`sm`}):u(`oauth.unlink`)}):e===`google`?(0,V.jsx)(t0,{mode:`link`,onSuccess:a,onError:o,className:`!w-auto !h-auto py-1.5 px-3 text-sm`}):(0,V.jsx)(U,{variant:`outline`,size:`sm`,disabled:!0,children:u(`oauth.comingSoon`)})})]})}function a0({className:e}){return(0,V.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,V.jsx)(`path`,{fill:`#4285F4`,d:`M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92c-.26 1.37-1.04 2.53-2.21 3.31v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.09z`}),(0,V.jsx)(`path`,{fill:`#34A853`,d:`M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z`}),(0,V.jsx)(`path`,{fill:`#FBBC05`,d:`M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z`}),(0,V.jsx)(`path`,{fill:`#EA4335`,d:`M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z`})]})}function o0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,V.jsx)(`path`,{d:`M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z`})})}function s0({className:e}){return(0,V.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,children:[(0,V.jsx)(`path`,{fill:`#F25022`,d:`M1 1h10v10H1z`}),(0,V.jsx)(`path`,{fill:`#00A4EF`,d:`M1 13h10v10H1z`}),(0,V.jsx)(`path`,{fill:`#7FBA00`,d:`M13 1h10v10H13z`}),(0,V.jsx)(`path`,{fill:`#FFB900`,d:`M13 13h10v10H13z`})]})}function c0({totpSetupData:e,onCopy:t,onCancel:n,onNext:r}){let{t:i}=H(`studio`);return(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white mb-4`,children:i(`mfa.setup.authenticator`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:i(`mfa.setup.scanQrCode`)}),(0,V.jsx)(`div`,{className:`flex justify-center`,children:(0,V.jsx)(`img`,{src:e.qrCode,alt:`TOTP QR Code`,className:`w-48 h-48 bg-white p-2 rounded`})}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-2`,children:i(`mfa.setup.orEnterManually`)}),(0,V.jsxs)(`div`,{className:`inline-flex items-center gap-2 bg-gray-100 dark:bg-gray-700 px-3 py-2 rounded font-mono text-sm`,children:[e.manualEntryKey,(0,V.jsx)(`button`,{onClick:()=>t(e.manualEntryKey),className:`text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:(0,V.jsx)(oe,{className:`h-4 w-4`})})]})]}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:n,children:i(`mfa.cancel`)}),(0,V.jsx)(U,{onClick:r,children:i(`mfa.next`)})]})]})]})}function l0({verificationCode:e,onVerificationCodeChange:t,error:n,isProcessing:r,onCancel:i,onVerify:a}){let{t:o}=H(`studio`);return(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white mb-4`,children:o(`mfa.setup.verifyAuthenticatorCode`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:o(`mfa.setup.enterCodeToVerify`)}),n&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded text-sm text-red-600 dark:text-red-400`,children:n}),(0,V.jsx)(h1,{type:`text`,value:e,onChange:e=>t(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,className:`text-center text-2xl tracking-widest font-mono`,maxLength:6,autoFocus:!0}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:i,children:o(`mfa.cancel`)}),(0,V.jsxs)(U,{onClick:a,disabled:r||e.length!==6,children:[r?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,o(`mfa.verify`)]})]})]})]})}function u0({verificationCode:e,onVerificationCodeChange:t,error:n,isProcessing:r,onCancel:i,onVerify:a}){let{t:o}=H(`studio`);return(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white mb-4`,children:o(`mfa.setup.verifyEmailCode`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:o(`mfa.setup.enterEmailCode`)}),n&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded text-sm text-red-600 dark:text-red-400`,children:n}),(0,V.jsx)(h1,{type:`text`,value:e,onChange:e=>t(e.target.value.replace(/\D/g,``).slice(0,6)),placeholder:`000000`,className:`text-center text-2xl tracking-widest font-mono`,maxLength:6,autoFocus:!0}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:i,children:o(`mfa.cancel`)}),(0,V.jsxs)(U,{onClick:a,disabled:r||e.length!==6,children:[r?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,o(`mfa.verify`)]})]})]})]})}function d0({backupCodes:e,onCopy:t,onDone:n}){let{t:r}=H(`studio`);return(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white mb-4`,children:r(`mfa.setup.saveBackupCodes`)}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`p-4 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg border border-yellow-200 dark:border-yellow-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-yellow-800 dark:text-yellow-200`,children:r(`mfa.setup.backupCodesImportant`)})}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2 font-mono text-sm bg-gray-50 dark:bg-gray-900 p-4 rounded`,children:e.map((e,t)=>(0,V.jsx)(`div`,{className:`p-2 bg-white dark:bg-gray-800 rounded`,children:e},t))}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(U,{variant:`secondary`,onClick:()=>t(e.join(`
735
735
  `)),children:[(0,V.jsx)(oe,{className:`h-4 w-4 mr-2`}),r(`mfa.copyAll`)]}),(0,V.jsx)(U,{onClick:n,children:r(`mfa.done`)})]})]})]})}function f0({mfaStatus:e,totpMethod:t,emailMethod:n,isProcessing:r,showTrustedDevices:i,trustedDevices:a,isLoadingDevices:o,onSetupTOTP:s,onSetupEmailOTP:c,onDisableMethod:l,onRegenerateBackupCodes:u,onToggleTrustedDevices:d,onRevokeTrustedDevice:f,onRevokeAllTrustedDevices:p,onDisableAll:m}){let{t:h}=H(`studio`);return(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(L,{className:`h-8 w-8 text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white`,children:h(`mfa.authenticatorApp`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:h(`mfa.authenticatorAppDesc`)})]})]}),t?.enabled?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm text-green-600 dark:text-green-400`,children:h(`mfa.enabled`)}),(0,V.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>l(`totp`),children:h(`mfa.disableMethod`)})]}):(0,V.jsx)(U,{size:`sm`,onClick:s,disabled:r,children:h(`mfa.setUp`)})]})}),(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(ne,{className:`h-8 w-8 text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white`,children:h(`mfa.emailVerification`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:h(`mfa.emailVerificationDesc`)})]})]}),n?.enabled?(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-sm text-green-600 dark:text-green-400`,children:h(`mfa.enabled`)}),(0,V.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>l(`email`),children:h(`mfa.disableMethod`)})]}):(0,V.jsx)(U,{size:`sm`,onClick:c,disabled:r,children:h(`mfa.setUp`)})]})}),e?.enabled&&(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(te,{className:`h-8 w-8 text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white`,children:h(`mfa.backupCodes`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:h(`mfa.backupCodesRemaining`,{count:e.backupCodesRemaining})})]})]}),(0,V.jsxs)(U,{variant:`secondary`,size:`sm`,onClick:u,disabled:r,children:[(0,V.jsx)(ke,{className:`h-4 w-4 mr-1`}),h(`mfa.regenerate`)]})]})}),e?.enabled&&e.trustedDevicesCount>0&&(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(_e,{className:`h-8 w-8 text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`font-medium text-gray-900 dark:text-white`,children:h(`mfa.trustedDevices`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:h(`mfa.trustedDevicesCount`,{count:e.trustedDevicesCount})})]})]}),(0,V.jsx)(U,{variant:`secondary`,size:`sm`,onClick:d,children:h(i?`mfa.hide`:`mfa.manage`)})]}),i&&(0,V.jsx)(`div`,{className:`space-y-2 mt-4 pt-4 border-t border-gray-200 dark:border-gray-700`,children:o?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,V.jsx)(Ao,{size:`sm`})}):a.length>0?(0,V.jsxs)(V.Fragment,{children:[a.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-gray-50 dark:bg-gray-900 rounded`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:e.name}),(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400`,children:h(`mfa.trustedDevice.trusted`,{date:new Date(e.trustedAt).toLocaleDateString()})})]}),(0,V.jsx)(`button`,{onClick:()=>f(e.id),className:`p-1 text-gray-400 hover:text-red-500`,children:(0,V.jsx)(Be,{className:`h-4 w-4`})})]},e.id)),a.length>1&&(0,V.jsx)(U,{variant:`secondary`,size:`sm`,className:`w-full mt-2`,onClick:p,children:h(`mfa.revokeAll`)})]}):(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 text-center py-2`,children:h(`common.loading`)})})]}),e?.enabled&&(0,V.jsx)(`div`,{className:`mt-6 pt-6 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800 p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h4`,{className:`font-medium text-red-800 dark:text-red-200`,children:h(`mfa.disable.all`)}),(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h(`mfa.disable.allDesc`)})]}),(0,V.jsxs)(U,{variant:`danger`,size:`sm`,onClick:m,disabled:r,children:[(0,V.jsx)(We,{className:`h-4 w-4 mr-1`}),h(`mfa.disable.all`)]})]})})})]})}function p0({onToast:e}){let{t}=H(`studio`),[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(`idle`),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(``),[f,p]=(0,B.useState)([]),[m,h]=(0,B.useState)(!1),[g,_]=(0,B.useState)([]),[v,y]=(0,B.useState)(!1),[b,x]=(0,B.useState)(!1),[S,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(null),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)(``),[A,j]=(0,B.useState)(!1),[M,N]=(0,B.useState)(``),[P,F]=(0,B.useState)(!1),[I,L]=(0,B.useState)(null),ee=e||((e,t)=>console.log(`${t}: ${e}`));(0,B.useEffect)(()=>{R()},[]);let R=async()=>{try{a(!0);let e=await W.get(`/auth/mfa/status`);e.success&&e.data&&r(e.data.data||e.data)}catch(e){console.error(`Failed to load MFA status:`,e),ee(t(`mfa.toast.loadFailed`),`error`)}finally{a(!1)}},te=async()=>{try{x(!0);let e=await W.get(`/auth/mfa/trusted-devices`);if(e.success&&e.data){let t=e.data,n=t.data?.devices||t.devices||[];_(n)}}catch(e){console.error(`Failed to load trusted devices:`,e)}finally{x(!1)}},ne=async()=>{try{F(!0),L(null);let e=await W.post(`/auth/mfa/setup/totp`,{});if(e.success&&e.data)l(e.data.data||e.data),s(`totp-qr`);else throw Error(e.error?.message||`Failed to initialize TOTP setup`)}catch(e){L(e instanceof Error?e.message:t(`mfa.toast.totpInitFailed`)),ee(t(`mfa.toast.totpInitFailed`),`error`)}finally{F(!1)}},re=async()=>{if(!u.trim()){L(t(`mfa.enterCode`));return}try{F(!0),L(null);let e=await W.post(`/auth/mfa/setup/totp/verify`,{code:u.trim()});if(e.success){let n=e.data;n.backupCodes?(p(n.backupCodes),s(`backup-codes`)):(s(`idle`),await R()),ee(t(`mfa.toast.totpEnabled`),`success`)}else throw Error(e.error?.message||`Invalid verification code`)}catch(e){L(e instanceof Error?e.message:t(`mfa.verifying`))}finally{F(!1),d(``)}},ie=async()=>{try{F(!0),L(null);let e=await W.post(`/auth/mfa/setup/email`,{});if(e.success)s(`email-verify`),ee(t(`mfa.toast.emailCodeSent`),`success`);else throw Error(e.error?.message||t(`mfa.toast.emailSendFailed`))}catch(e){L(e instanceof Error?e.message:t(`mfa.toast.emailSendFailed`)),ee(t(`mfa.toast.emailSendFailed`),`error`)}finally{F(!1)}},ae=async()=>{if(!u.trim()){L(t(`mfa.enterCode`));return}try{F(!0),L(null);let e=await W.post(`/auth/mfa/setup/email/verify`,{code:u.trim()});if(e.success){let n=e.data;n.backupCodes?(p(n.backupCodes),s(`backup-codes`)):(s(`idle`),await R()),ee(t(`mfa.toast.emailEnabled`),`success`)}else throw Error(e.error?.message||`Invalid verification code`)}catch(e){L(e instanceof Error?e.message:t(`mfa.verifying`))}finally{F(!1),d(``)}},z=async e=>{if(!S){L(t(`mfa.errors.passwordRequired`));return}try{F(!0),L(null);let n=await W.post(`/auth/mfa/disable`,{method:e,password:S});if(n.success)T(null),C(``),await R(),ee(t(e===`totp`?`mfa.toast.authenticatorDisabled`:`mfa.toast.emailDisabled`),`success`);else throw Error(n.error?.message||`Failed to disable MFA`)}catch(e){L(e instanceof Error?e.message:`Failed to disable MFA`)}finally{F(!1)}},se=async()=>{if(!M){L(t(`mfa.errors.passwordRequired`));return}try{F(!0),L(null);let e=await W.post(`/auth/mfa/disable-all`,{password:M});if(e.success)j(!1),N(``),await R(),ee(t(`mfa.toast.allDisabled`),`success`);else throw Error(e.error?.message||`Failed to disable MFA`)}catch(e){L(e instanceof Error?e.message:`Failed to disable MFA`)}finally{F(!1)}},ce=async()=>{if(!O){L(t(`mfa.errors.passwordRequired`));return}try{F(!0),L(null);let e=await W.post(`/auth/mfa/backup-codes/regenerate`,{password:O});if(e.success&&e.data){let n=e.data;p(n.backupCodes||[]),h(!0),D(!1),k(``),await R(),ee(t(`mfa.toast.backupCodesRegenerated`),`success`)}else throw Error(e.error?.message||`Failed to regenerate backup codes`)}catch(e){L(e instanceof Error?e.message:`Failed to regenerate backup codes`)}finally{F(!1)}},le=async e=>{try{(await W.delete(`/auth/mfa/trusted-devices/${e}`)).success&&(_(t=>t.filter(t=>t.id!==e)),await R(),ee(t(`mfa.toast.deviceRevoked`),`success`))}catch{ee(t(`mfa.toast.deviceRevokeFailed`),`error`)}},ue=async()=>{if(confirm(t(`mfa.trustedDevice.confirmRevokeAll`)))try{(await W.delete(`/auth/mfa/trusted-devices`)).success&&(_([]),await R(),ee(t(`mfa.toast.allDevicesRevoked`),`success`))}catch{ee(t(`mfa.toast.allDevicesRevokeFailed`),`error`)}},fe=e=>{navigator.clipboard.writeText(e),ee(t(`mfa.copiedToClipboard`),`info`)},pe=()=>{s(`idle`),l(null),d(``),L(null)},me=()=>{s(`idle`),p([]),R()};if(i)return(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,V.jsx)(Ao,{size:`lg`})});let he=n?.methods.find(e=>e.type===`totp`),ge=n?.methods.find(e=>e.type===`email`);return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(He,{className:`h-6 w-6 text-primary-500`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-white`,children:t(`mfa.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t(`mfa.subtitle`)})]})]}),(0,V.jsx)(`div`,{className:`flex items-center gap-2`,children:n?.enabled?(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-400`,children:[(0,V.jsx)(Ae,{className:`h-4 w-4`}),t(`mfa.enabled`)]}):(0,V.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-400`,children:[(0,V.jsx)(de,{className:`h-4 w-4`}),t(`mfa.notEnabled`)]})}),o===`totp-qr`&&c&&(0,V.jsx)(c0,{totpSetupData:c,onCopy:fe,onCancel:pe,onNext:()=>s(`totp-verify`)}),o===`totp-verify`&&(0,V.jsx)(l0,{verificationCode:u,onVerificationCodeChange:d,error:I,isProcessing:P,onCancel:pe,onVerify:re}),o===`email-verify`&&(0,V.jsx)(u0,{verificationCode:u,onVerificationCodeChange:d,error:I,isProcessing:P,onCancel:pe,onVerify:ae}),o===`backup-codes`&&f.length>0&&(0,V.jsx)(d0,{backupCodes:f,onCopy:fe,onDone:me}),o===`idle`&&(0,V.jsx)(f0,{mfaStatus:n,totpMethod:he,emailMethod:ge,isProcessing:P,showTrustedDevices:v,trustedDevices:g,isLoadingDevices:b,onSetupTOTP:ne,onSetupEmailOTP:ie,onDisableMethod:T,onRegenerateBackupCodes:()=>D(!0),onToggleTrustedDevices:()=>{y(!v),v||te()},onRevokeTrustedDevice:le,onRevokeAllTrustedDevices:ue,onDisableAll:()=>j(!0)}),w&&(0,V.jsx)(ia,{open:!0,onClose:()=>{T(null),C(``),L(null)},variant:`center`,size:`sm`,title:t(w===`totp`?`mfa.disableDialog.authenticator`:`mfa.disableDialog.email`),children:(0,V.jsxs)(ia.Body,{children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:t(`mfa.disableDialog.enterPassword`)}),I&&(0,V.jsx)(`div`,{className:`p-3 mb-4 bg-red-50 dark:bg-red-900/20 rounded text-sm text-red-600 dark:text-red-400`,children:I}),(0,V.jsx)(h1,{type:`password`,value:S,onChange:e=>C(e.target.value),placeholder:`Password`,className:`mb-4`}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:()=>{T(null),C(``),L(null)},children:t(`mfa.cancel`)}),(0,V.jsxs)(U,{variant:`danger`,onClick:()=>z(w),disabled:P||!S,children:[P?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,t(`mfa.disableMethod`)]})]})]})}),E&&(0,V.jsx)(ia,{open:!0,onClose:()=>{D(!1),k(``),L(null)},variant:`center`,size:`sm`,title:t(`mfa.regenerateBackupCodes.title`),children:(0,V.jsxs)(ia.Body,{children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:t(`mfa.regenerateBackupCodes.description`)}),I&&(0,V.jsx)(`div`,{className:`p-3 mb-4 bg-red-50 dark:bg-red-900/20 rounded text-sm text-red-600 dark:text-red-400`,children:I}),(0,V.jsx)(h1,{type:`password`,value:O,onChange:e=>k(e.target.value),placeholder:`Password`,className:`mb-4`}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:()=>{D(!1),k(``),L(null)},children:t(`mfa.cancel`)}),(0,V.jsxs)(U,{onClick:ce,disabled:P||!O,children:[P?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,t(`mfa.regenerate`)]})]})]})}),m&&f.length>0&&(0,V.jsx)(ia,{open:!0,onClose:()=>{h(!1),p([])},variant:`center`,size:`md`,title:t(`mfa.setup.newBackupCodes`),children:(0,V.jsx)(ia.Body,{children:(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`p-4 bg-yellow-50 dark:bg-yellow-900/20 rounded-lg border border-yellow-200 dark:border-yellow-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-yellow-800 dark:text-yellow-200`,children:t(`mfa.setup.newBackupCodesImportant`)})}),(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2 font-mono text-sm bg-gray-50 dark:bg-gray-900 p-4 rounded`,children:f.map((e,t)=>(0,V.jsx)(`div`,{className:`p-2 bg-white dark:bg-gray-800 rounded text-center`,children:e},t))}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsxs)(U,{variant:`secondary`,onClick:()=>fe(f.join(`
736
736
  `)),children:[(0,V.jsx)(oe,{className:`h-4 w-4 mr-2`}),t(`mfa.copyAll`)]}),(0,V.jsx)(U,{onClick:()=>{h(!1),p([])},children:t(`mfa.done`)})]})]})})}),A&&(0,V.jsxs)(ia,{open:!0,onClose:()=>{j(!1),N(``),L(null)},variant:`center`,size:`sm`,ariaLabel:t(`mfa.disableDialog.all`),children:[(0,V.jsx)(ia.Header,{children:(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-red-600 dark:text-red-400`,children:t(`mfa.disableDialog.all`)})}),(0,V.jsxs)(ia.Body,{children:[(0,V.jsx)(`div`,{className:`p-4 mb-4 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-800 dark:text-red-200`,children:t(`mfa.disableDialog.allWarning`)})}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:t(`mfa.disableDialog.confirmPassword`)}),I&&(0,V.jsx)(`div`,{className:`p-3 mb-4 bg-red-50 dark:bg-red-900/20 rounded text-sm text-red-600 dark:text-red-400`,children:I}),(0,V.jsx)(h1,{type:`password`,value:M,onChange:e=>N(e.target.value),placeholder:`Password`,className:`mb-4`}),(0,V.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,V.jsx)(U,{variant:`secondary`,onClick:()=>{j(!1),N(``),L(null)},children:t(`mfa.cancel`)}),(0,V.jsxs)(U,{variant:`danger`,onClick:se,disabled:P||!M,children:[P?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,t(`mfa.disableDialog.all`)]})]})]})]})]})}function m0(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function h0(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return a}function g0(){return _0.stubThis(globalThis?.PublicKeyCredential!==void 0&&typeof globalThis.PublicKeyCredential==`function`)}var _0={stubThis:e=>e};function v0(e){let{id:t}=e;return{...e,id:h0(t),transports:e.transports}}function y0(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var b0=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function x0({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new b0({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new b0({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new b0({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new b0({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new b0({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new b0({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new b0({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new b0({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!y0(t))return new b0({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new b0({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new b0({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new b0({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var S0=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},C0=[`cross-platform`,`platform`];function w0(e){if(e&&!(C0.indexOf(e)<0))return e}async function T0(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!g0())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:h0(t.challenge),user:{...t.user,id:h0(t.user.id)},excludeCredentials:t.excludeCredentials?.map(v0)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=S0.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw x0({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){E0(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=m0(e))}catch(e){E0(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=m0(c.getAuthenticatorData())}catch(e){E0(`getAuthenticatorData()`,e)}return{id:o,rawId:m0(s),response:{attestationObject:m0(c.attestationObject),clientDataJSON:m0(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:w0(a.authenticatorAttachment)}}function E0(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function D0(){if(!g0())return O0.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?O0.stubThis(new Promise(e=>e(!1))):O0.stubThis(e.isConditionalMediationAvailable())}var O0={stubThis:e=>e};function k0({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new b0({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new b0({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!y0(t))return new b0({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new b0({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new b0({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function A0(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!g0())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(v0));let a={...t,challenge:h0(t.challenge),allowCredentials:i},o={};if(n){if(!await D0())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No <input> with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=S0.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw k0({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=m0(u.userHandle)),{id:c,rawId:m0(l),response:{authenticatorData:m0(u.authenticatorData),clientDataJSON:m0(u.clientDataJSON),signature:m0(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:w0(s.authenticatorAttachment)}}var j0=Fr(`PasskeyRegistration`);function M0({onSuccess:e,onError:t,disabled:n,className:r=``}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(``),[l,u]=(0,B.useState)(!1);return l?(0,V.jsxs)(`div`,{className:`space-y-3 ${r}`,children:[(0,V.jsx)(`input`,{type:`text`,value:s,onChange:e=>c(e.target.value),placeholder:i(`passkey.register.namePlaceholder`,`e.g., MacBook Pro Touch ID`),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md bg-white dark:bg-gray-800 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:ring-2 focus:ring-blue-500 focus:border-transparent`,disabled:a}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsx)(U,{type:`button`,onClick:async()=>{o(!0);try{j0.debug(`Requesting passkey registration options`);let n=await W.post(`/auth/passkey/register/options`,{friendlyName:s||void 0});if(!n.success||!n.data){let e=n.error?.message||i(`passkey.register.optionsFailed`,`Failed to start passkey registration`);j0.error(`Failed to get registration options`,{error:e}),t?.(e);return}let{sessionId:r,...a}=n.data;j0.debug(`Received registration options`,{sessionId:r.substring(0,8)});let o;try{o=await T0({optionsJSON:a}),j0.debug(`Browser registration completed`)}catch(e){e.name===`NotAllowedError`?(j0.info(`User cancelled passkey registration`),t?.(i(`passkey.register.cancelled`,`Registration was cancelled`))):e.name===`InvalidStateError`?(j0.warn(`Passkey already registered`),t?.(i(`passkey.register.alreadyRegistered`,`This passkey is already registered`))):e.name===`NotSupportedError`?(j0.warn(`Passkeys not supported in this browser`),t?.(i(`passkey.register.notSupported`,`Passkeys are not supported in this browser`))):(j0.error(`Browser registration failed`,{error:e.message}),t?.(e.message||i(`passkey.register.failed`,`Passkey registration failed`)));return}j0.debug(`Verifying registration with server`);let l=await W.post(`/auth/passkey/register/verify`,{sessionId:r,credential:o,friendlyName:s||void 0});if(!l.success||!l.data){let e=l.error?.message||i(`passkey.register.verifyFailed`,`Passkey registration verification failed`);j0.error(`Registration verification failed`,{error:e}),t?.(e);return}j0.info(`Passkey registered successfully`,{credentialId:l.data.credential.id.substring(0,8)}),c(``),u(!1),e?.(l.data.credential)}catch(e){let n=e instanceof Error?e.message:i(`passkey.register.failed`,`Passkey registration failed`);j0.error(`Passkey registration error`,{error:n}),t?.(n)}finally{o(!1)}},disabled:n||a,variant:`primary`,className:`flex-1`,children:a?(0,V.jsx)(Ao,{size:`sm`}):i(`passkey.register.continue`,`Continue`)}),(0,V.jsx)(U,{type:`button`,onClick:()=>{u(!1),c(``)},disabled:a,variant:`outline`,children:i(`common.cancel`,`Cancel`)})]})]}):(0,V.jsxs)(U,{type:`button`,onClick:()=>u(!0),disabled:n||a,variant:`outline`,className:`flex items-center gap-2 ${r}`,children:[(0,V.jsx)(N0,{className:`w-4 h-4`}),i(`passkey.register.addPasskey`,`Add Passkey`)]})}function N0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,xmlns:`http://www.w3.org/2000/svg`,children:(0,V.jsx)(`path`,{fillRule:`evenodd`,d:`M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z`,clipRule:`evenodd`})})}var P0=Fr(`PasskeyManager`);function F0({className:e=``}){let{t}=H(`studio`),[n,r]=(0,B.useState)([]),[i,a]=(0,B.useState)(!0),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(null),[f,p]=(0,B.useState)(``),[m,h]=(0,B.useState)(null),g=(0,B.useCallback)(async()=>{try{let e=await W.get(`/auth/passkey/status`);return e.success&&e.data?(s(e.data.enabled),e.data.enabled):(s(!1),!1)}catch(e){return P0.warn(`Failed to check passkey status`,{error:e}),s(!1),!1}},[]),_=(0,B.useCallback)(async()=>{a(!0),l(null);try{let e=await W.get(`/auth/passkey/credentials`);e.success&&e.data?(r(e.data.credentials),P0.debug(`Loaded passkey credentials`,{count:e.data.credentials.length})):l(e.error?.message||t(`passkey.manager.loadFailed`,`Failed to load passkeys`))}catch(e){let n=e instanceof Error?e.message:t(`passkey.manager.loadFailed`,`Failed to load passkeys`);P0.error(`Failed to load credentials`,{error:n}),l(n)}finally{a(!1)}},[t]);(0,B.useEffect)(()=>{(async()=>{await g()?await _():a(!1)})()},[g,_]);let v=async e=>{if(!f.trim()){d(null);return}try{let n=await W.patch(`/auth/passkey/credentials/${e}`,{friendlyName:f.trim()});n.success?(P0.info(`Renamed passkey credential`),r(t=>t.map(t=>t.id===e?{...t,friendlyName:f.trim()}:t)),d(null),p(``)):(P0.error(`Failed to rename credential`,{error:n.error?.message}),l(n.error?.message||t(`passkey.manager.renameFailed`,`Failed to rename passkey`)))}catch(e){let n=e instanceof Error?e.message:t(`passkey.manager.renameFailed`,`Failed to rename passkey`);P0.error(`Rename error`,{error:n}),l(n)}},y=async e=>{try{h(e);let n=await W.delete(`/auth/passkey/credentials/${e}`);n.success?(P0.info(`Deleted passkey credential`),r(t=>t.filter(t=>t.id!==e))):(P0.error(`Failed to delete credential`,{error:n.error?.message}),l(n.error?.message||t(`passkey.manager.deleteFailed`,`Failed to delete passkey`)))}catch(e){let n=e instanceof Error?e.message:t(`passkey.manager.deleteFailed`,`Failed to delete passkey`);P0.error(`Delete error`,{error:n}),l(n)}finally{h(null)}},b=e=>{r(t=>[...t,e]),l(null)},x=e=>{l(e)},S=e=>{try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return e}},C=(e,t)=>t?(0,V.jsx)(L0,{className:`w-5 h-5 text-blue-500`}):(0,V.jsx)(I0,{className:`w-5 h-5 text-gray-500 dark:text-gray-400`});return i?(0,V.jsx)(`div`,{className:`flex items-center justify-center py-8 ${e}`,children:(0,V.jsx)(Ao,{})}):o===!1?(0,V.jsx)(`div`,{className:`space-y-4 ${e}`,children:(0,V.jsxs)(`div`,{className:`text-center py-6`,children:[(0,V.jsx)(I0,{className:`w-12 h-12 mx-auto text-gray-400 dark:text-gray-500 mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-2`,children:t(`passkey.manager.notConfigured`,`Passkey authentication is not enabled`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500`,children:t(`passkey.manager.notConfiguredDescription`,`Passkey authentication needs to be configured by an administrator in the server settings.`)})]})}):(0,V.jsxs)(`div`,{className:`space-y-4 ${e}`,children:[c&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-md`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-700 dark:text-red-300`,children:c})}),n.length===0?(0,V.jsxs)(`div`,{className:`text-center py-6`,children:[(0,V.jsx)(I0,{className:`w-12 h-12 mx-auto text-gray-400 dark:text-gray-500 mb-3`}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-4`,children:t(`passkey.manager.noPasskeys`,`You haven't set up any passkeys yet.`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-500 mb-4`,children:t(`passkey.manager.description`,`Passkeys let you sign in without a password using your fingerprint, face, or security key.`)})]}):(0,V.jsx)(`ul`,{className:`space-y-3`,children:n.map(e=>(0,V.jsxs)(`li`,{className:`flex items-center justify-between p-4 bg-gray-50 dark:bg-gray-800/50 rounded-lg border border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[C(e.deviceType,e.backedUp),(0,V.jsxs)(`div`,{children:[u===e.id?(0,V.jsx)(`input`,{type:`text`,value:f,onChange:e=>p(e.target.value),onBlur:()=>v(e.id),onKeyDown:t=>{t.key===`Enter`&&v(e.id),t.key===`Escape`&&(d(null),p(``))},className:`px-2 py-1 text-sm border border-gray-300 dark:border-gray-600 rounded bg-white dark:bg-gray-800 text-gray-900 dark:text-white`,autoFocus:!0}):(0,V.jsx)(`p`,{className:`font-medium text-gray-900 dark:text-white`,children:e.friendlyName||t(`passkey.manager.unnamed`,`Passkey`)}),(0,V.jsxs)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:[t(`passkey.manager.added`,`Added`),` `,S(e.createdAt),e.lastUsedAt&&(0,V.jsxs)(V.Fragment,{children:[` · `,t(`passkey.manager.lastUsed`,`Last used`),` `,S(e.lastUsedAt)]})]}),(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:e.backedUp?t(`passkey.manager.synced`,`Synced across devices`):t(`passkey.manager.deviceOnly`,`This device only`)})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u!==e.id&&(0,V.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>{d(e.id),p(e.friendlyName||``)},children:(0,V.jsx)(R0,{className:`w-4 h-4`})}),(0,V.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>y(e.id),disabled:m===e.id,className:`text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,children:m===e.id?(0,V.jsx)(Ao,{size:`sm`}):(0,V.jsx)(z0,{className:`w-4 h-4`})})]})]},e.id))}),(0,V.jsx)(`div`,{className:`pt-4 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(M0,{onSuccess:b,onError:x})})]})}function I0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,V.jsx)(`path`,{d:`M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4`})})}function L0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,V.jsx)(`path`,{d:`M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96z`})})}function R0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,V.jsx)(`path`,{d:`M13.586 3.586a2 2 0 112.828 2.828l-.793.793-2.828-2.828.793-.793zM11.379 5.793L3 14.172V17h2.828l8.38-8.379-2.83-2.828z`})})}function z0({className:e}){return(0,V.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,V.jsx)(`path`,{fillRule:`evenodd`,d:`M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z`,clipRule:`evenodd`})})}var B0=Fr(`UserPreferences`);function V0(){let{user:e}=ri(),{t}=H(`studio`),{locale:n,setLocale:r,locales:i,getLocaleName:a}=xr(),o=za({page:`user-preferences`,title:t(`preferences.title`)}),s=pa()?.utils?.showToast||((e,t)=>console.log(`Toast: ${t} - ${e}`)),[c,l]=(0,B.useState)({theme:`system`,language:n,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,emailNotifications:!0,pushNotifications:!1}),[u,d]=(0,B.useState)(!1),[f,p]=(0,B.useState)(null);return(0,B.useEffect)(()=>{o.configure({page:`user-preferences`,title:t(`preferences.title`),defaultVisible:!1})},[o.configure,t]),(0,B.useEffect)(()=>{e&&l(t=>({...t,...e.preferences}))},[e]),(0,V.jsx)(`div`,{className:`p-6`,children:(0,V.jsxs)(`div`,{className:`max-w-2xl space-y-8`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:t(`preferences.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:t(`preferences.subtitle`)})]}),f&&(0,V.jsx)(`div`,{className:`p-4 rounded-lg ${f.type===`success`?`bg-green-50 text-green-800 border border-green-200 dark:bg-green-900/20 dark:text-green-400 dark:border-green-800`:`bg-red-50 text-red-800 border border-red-200 dark:bg-red-900/20 dark:text-red-400 dark:border-red-800`}`,children:f.text}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-3 mb-6`,children:[(0,V.jsx)(Te,{className:`h-6 w-6 text-gray-600 dark:text-gray-400`}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:t(`preferences.appearance`)})]}),(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:t(`preferences.theme`)}),(0,V.jsxs)(`select`,{value:c.theme,onChange:e=>l(t=>({...t,theme:e.target.value})),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:`system`,children:t(`preferences.themeSystem`)}),(0,V.jsx)(`option`,{value:`light`,children:t(`preferences.themeLight`)}),(0,V.jsx)(`option`,{value:`dark`,children:t(`preferences.themeDark`)})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:t(`language.title`)}),(0,V.jsx)(`select`,{value:c.language,onChange:e=>l(t=>({...t,language:e.target.value})),className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-md shadow-sm bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:i.map(e=>(0,V.jsx)(`option`,{value:e,children:a(e)},e))}),(0,V.jsxs)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-400`,children:[t(`language.current`),`: `,a(n)]})]})]})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-3 mb-6`,children:[(0,V.jsx)(Le,{className:`h-6 w-6 text-gray-600 dark:text-gray-400`}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:t(`preferences.notifications`)})]}),(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:t(`preferences.emailNotifications`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t(`preferences.emailNotificationsDescription`)})]}),(0,V.jsx)(`input`,{type:`checkbox`,checked:c.emailNotifications,onChange:e=>l(t=>({...t,emailNotifications:e.target.checked})),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-900 dark:text-white`,children:t(`preferences.pushNotifications`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t(`preferences.pushNotificationsDescription`)})]}),(0,V.jsx)(`input`,{type:`checkbox`,checked:c.pushNotifications,onChange:e=>l(t=>({...t,pushNotifications:e.target.checked})),className:`h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 rounded`})]})]})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-3 mb-6`,children:[(0,V.jsx)(he,{className:`h-6 w-6 text-gray-600 dark:text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:t(`preferences.connectedAccounts`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t(`preferences.connectedAccountsDescription`)})]})]}),(0,V.jsx)(r0,{})]}),(0,V.jsxs)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 p-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center space-x-3 mb-6`,children:[(0,V.jsx)(He,{className:`h-6 w-6 text-gray-600 dark:text-gray-400`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:t(`preferences.security`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:t(`preferences.securityDescription`)})]})]}),(0,V.jsx)(p0,{onToast:s}),(0,V.jsxs)(`div`,{className:`mt-6 pt-6 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(`h3`,{className:`text-lg font-medium text-gray-900 dark:text-white mb-2`,children:t(`preferences.passkeys`,`Passkeys`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mb-4`,children:t(`preferences.passkeysDescription`,`Sign in securely without a password using your fingerprint, face, or security key.`)}),(0,V.jsx)(F0,{})]})]}),(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsxs)(U,{onClick:async()=>{d(!0),p(null);try{c.theme&&(c.theme===`system`?document.documentElement.classList.remove(`light`,`dark`):(document.documentElement.classList.remove(`light`,`dark`),document.documentElement.classList.add(c.theme)),localStorage.setItem(`trokky_theme`,c.theme)),c.language&&c.language!==n&&r(c.language),p({type:`success`,text:t(`preferences.saveSuccess`)})}catch(e){B0.error(`Failed to update preferences`,e),p({type:`error`,text:t(`preferences.saveError`)})}finally{d(!1),setTimeout(()=>p(null),3e3)}},disabled:u,children:[u?(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}):null,t(`preferences.savePreferences`)]})})]})})}var H0=Fr(`AuditLogsPage`),U0=25;function W0(){let{t:e}=H(`studio`);za({page:`audit-logs`,title:e(`auditLogs.title`),defaultVisible:!1,defaultPosition:`left`});let[t,n]=(0,B.useState)([]),[r,i]=(0,B.useState)(!0),[a,o]=(0,B.useState)(null),[s,l]=(0,B.useState)(new Set),[u,d]=(0,B.useState)(1),[f,p]=(0,B.useState)(0),[m,h]=(0,B.useState)([]),[g,_]=(0,B.useState)([]),[v,y]=(0,B.useState)(``),[b,x]=(0,B.useState)(``),[S,C]=(0,B.useState)(``),[w,T]=(0,B.useState)(``),[E,D]=(0,B.useState)(!1),[O,k]=(0,B.useState)({});(0,B.useEffect)(()=>{A(),j()},[]),(0,B.useEffect)(()=>{(m.length>0||v)&&N()},[u,v,b,S,m.length]);let A=async()=>{try{let e=await W.get(`/config/structure`);if(e.success&&e.data?.structure){let t=e.data.structure,n=t.items||t,r=e=>{let t=[];for(let n of e)n.schemaType&&t.push(n.schemaType),n.items&&Array.isArray(n.items)&&t.push(...r(n.items));return t};Array.isArray(n)&&h([...new Set(r(n))].sort())}}catch(e){H0.warn(`Failed to load collections`,e)}},j=async()=>{try{let e=await W.get(`/users`);e.success&&e.data?.users&&_(e.data.users)}catch(e){H0.warn(`Failed to load users`,e)}},M=async e=>{if(O[e])return O[e];if(e===`system`)return`System`;try{let t=await W.get(`/users/${e}`);if(t.success&&t.data?.user){let n=t.data.user,r=n.username||n.name||n.email||`User`;return k(t=>({...t,[e]:r})),r}}catch{}return e.startsWith(`user-`)?`User`:e},N=async()=>{i(!0),o(null);try{let e=(u-1)*U0,t=[];if(v){let e=await W.get(`/audit-logs/collections/${v}`,{limit:200,offset:0});e.success&&e.data?.auditLogs&&(t=e.data.auditLogs)}else for(let e of m)try{let n=await W.get(`/audit-logs/collections/${e}`,{limit:100,offset:0});n.success&&n.data?.auditLogs&&t.push(...n.data.auditLogs)}catch{}let r=t;if(b&&(r=r.filter(e=>e.actorId===b)),S&&(r=r.filter(e=>e.operation===S)),w.trim()){let e=w.toLowerCase();r=r.filter(t=>{let n=t.changes?.after,r=t.changes?.before;return(n?.title||n?.name||r?.title||r?.name||``).toLowerCase().includes(e)||t.documentId.toLowerCase().includes(e)||t.collection.toLowerCase().includes(e)})}r.sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),p(r.length);let i=r.slice(e,e+U0),a=[...new Set(i.map(e=>e.actorId).filter(Boolean))];for(let e of a)await M(e);let o=i.map(e=>({...e,actorUsername:O[e.actorId]||e.actorUsername}));n(o),H0.info(`Audit logs loaded`,{count:o.length,total:r.length})}catch(e){H0.error(`Failed to load audit logs`,e),o(`Failed to load audit logs`)}finally{i(!1)}},P=(0,B.useCallback)(()=>{d(1),N()},[w]),F=e=>{e.key===`Enter`&&P()},I=()=>{y(``),x(``),C(``),T(``),d(1)},L=e=>{let t=new Set(s);t.has(e)?t.delete(e):t.add(e),l(t)},R=t=>{switch(t){case`create`:return{icon:Ne,text:e(`auditLogs.operations.create`),color:`text-green-600 dark:text-green-400`,bgColor:`bg-green-100 dark:bg-green-900/30`};case`update`:return{icon:ct,text:e(`auditLogs.operations.update`),color:`text-blue-600 dark:text-blue-400`,bgColor:`bg-blue-100 dark:bg-blue-900/30`};case`delete`:return{icon:Be,text:e(`auditLogs.operations.delete`),color:`text-red-600 dark:text-red-400`,bgColor:`bg-red-100 dark:bg-red-900/30`};case`publish`:return{icon:ce,text:e(`auditLogs.operations.publish`),color:`text-purple-600 dark:text-purple-400`,bgColor:`bg-purple-100 dark:bg-purple-900/30`};case`unpublish`:return{icon:ce,text:e(`auditLogs.operations.unpublish`),color:`text-orange-600 dark:text-orange-400`,bgColor:`bg-orange-100 dark:bg-orange-900/30`};case`restore`:return{icon:re,text:e(`auditLogs.operations.restore`),color:`text-indigo-600 dark:text-indigo-400`,bgColor:`bg-indigo-100 dark:bg-indigo-900/30`};default:return{icon:ct,text:t,color:`text-gray-600 dark:text-gray-400`,bgColor:`bg-gray-100 dark:bg-gray-700`}}},te=e=>{try{let t=new Date(e);return{relative:ko(t,{addSuffix:!0}),full:t.toLocaleString()}}catch{return{relative:`Unknown`,full:e}}},ne=e=>{let t=e.changes?.after,n=e.changes?.before;return t?.title||t?.name||n?.title||n?.name||e.documentId},ie=t=>{if(!t.changes?.fields||t.changes.fields.length===0)return null;let n=t.changes.fields;return n.length===1?e(`auditLogs.changedField`,{field:n[0]}):e(`auditLogs.changedFields`,{count:n.length})},ae=Math.ceil(f/U0),oe=v||b||S||w;return(0,V.jsxs)(`div`,{className:`p-6 max-w-7xl mx-auto`,children:[(0,V.jsx)(`div`,{className:`mb-6`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white flex items-center`,children:[(0,V.jsx)(re,{className:`h-7 w-7 mr-3 text-gray-500`}),e(`auditLogs.title`)]}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mt-1`,children:e(`auditLogs.subtitle`)})]}),(0,V.jsxs)(`button`,{onClick:()=>N(),disabled:r,className:`flex items-center px-4 py-2 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50`,children:[(0,V.jsx)(ke,{className:`h-4 w-4 mr-2 ${r?`animate-spin`:``}`}),e(`auditLogs.refresh`)]})]})}),(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 mb-6`,children:(0,V.jsxs)(`div`,{className:`p-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex-1 relative`,children:[(0,V.jsx)(ee,{className:`absolute left-3 top-1/2 -translate-y-1/2 h-5 w-5 text-gray-400`}),(0,V.jsx)(`input`,{type:`text`,placeholder:e(`auditLogs.searchPlaceholder`),value:w,onChange:e=>T(e.target.value),onKeyPress:F,className:`w-full pl-10 pr-4 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 focus:ring-2 focus:ring-primary-500 focus:border-transparent`})]}),(0,V.jsx)(`button`,{onClick:P,className:`px-4 py-2 bg-primary-600 text-white rounded-lg hover:bg-primary-700 font-medium`,children:e(`auditLogs.search`)}),(0,V.jsxs)(`button`,{onClick:()=>D(!E),className:`flex items-center px-4 py-2 border rounded-lg font-medium ${E||oe?`border-primary-500 text-primary-600 dark:text-primary-400 bg-primary-50 dark:bg-primary-900/20`:`border-gray-300 dark:border-gray-600 text-gray-700 dark:text-gray-200 hover:bg-gray-50 dark:hover:bg-gray-700`}`,children:[(0,V.jsx)(Re,{className:`h-4 w-4 mr-2`}),e(`auditLogs.filters`),oe&&(0,V.jsx)(`span`,{className:`ml-2 px-1.5 py-0.5 text-xs bg-primary-600 text-white rounded-full`,children:[v,b,S].filter(Boolean).length})]})]}),E&&(0,V.jsxs)(`div`,{className:`mt-4 pt-4 border-t border-gray-200 dark:border-gray-700`,children:[(0,V.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-3 gap-4`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e(`auditLogs.collection`)}),(0,V.jsxs)(`select`,{value:v,onChange:e=>{y(e.target.value),d(1)},className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:``,children:e(`auditLogs.allCollections`)}),m.map(e=>(0,V.jsx)(`option`,{value:e,children:e},e))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e(`auditLogs.user`)}),(0,V.jsxs)(`select`,{value:b,onChange:e=>{x(e.target.value),d(1)},className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:``,children:e(`auditLogs.allUsers`)}),g.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.username},e.id))]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1`,children:e(`auditLogs.operation`)}),(0,V.jsxs)(`select`,{value:S,onChange:e=>{C(e.target.value),d(1)},className:`w-full px-3 py-2 border border-gray-300 dark:border-gray-600 rounded-lg bg-white dark:bg-gray-700 text-gray-900 dark:text-white`,children:[(0,V.jsx)(`option`,{value:``,children:e(`auditLogs.allOperations`)}),(0,V.jsx)(`option`,{value:`create`,children:e(`auditLogs.operations.create`)}),(0,V.jsx)(`option`,{value:`update`,children:e(`auditLogs.operations.update`)}),(0,V.jsx)(`option`,{value:`delete`,children:e(`auditLogs.operations.delete`)}),(0,V.jsx)(`option`,{value:`publish`,children:e(`auditLogs.operations.publish`)}),(0,V.jsx)(`option`,{value:`unpublish`,children:e(`auditLogs.operations.unpublish`)})]})]})]}),oe&&(0,V.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,V.jsxs)(`button`,{onClick:I,className:`flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white`,children:[(0,V.jsx)(tt,{className:`h-4 w-4 mr-1`}),e(`auditLogs.clearFilters`)]})})]})]})}),(0,V.jsx)(`div`,{className:`mb-4 text-sm text-gray-600 dark:text-gray-400`,children:f>0?(0,V.jsx)(V.Fragment,{children:e(`auditLogs.showingResults`,{start:(u-1)*U0+1,end:Math.min(u*U0,f),total:f})}):e(r?`auditLogs.loading`:`auditLogs.noResults`)}),(0,V.jsx)(`div`,{className:`bg-white dark:bg-gray-800 rounded-lg border border-gray-200 dark:border-gray-700 overflow-hidden`,children:r&&t.length===0?(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-12`,children:[(0,V.jsx)(Ao,{}),(0,V.jsx)(`span`,{className:`ml-3 text-gray-500 dark:text-gray-400`,children:e(`auditLogs.loading`)})]}):a?(0,V.jsxs)(`div`,{className:`p-6 text-center`,children:[(0,V.jsx)(`p`,{className:`text-red-600 dark:text-red-400`,children:a}),(0,V.jsx)(`button`,{onClick:()=>N(),className:`mt-4 text-primary-600 dark:text-primary-400 hover:underline`,children:e(`auditLogs.tryAgain`)})]}):t.length===0?(0,V.jsxs)(`div`,{className:`p-12 text-center`,children:[(0,V.jsx)(re,{className:`h-12 w-12 mx-auto text-gray-300 dark:text-gray-600 mb-4`}),(0,V.jsx)(`p`,{className:`text-gray-500 dark:text-gray-400`,children:e(`auditLogs.noLogs`)}),oe&&(0,V.jsx)(`button`,{onClick:I,className:`mt-4 text-primary-600 dark:text-primary-400 hover:underline`,children:e(`auditLogs.clearFilters`)})]}):(0,V.jsx)(`div`,{className:`divide-y divide-gray-200 dark:divide-gray-700`,children:t.map(t=>{let n=R(t.operation),r=n.icon,i=te(t.timestamp),a=s.has(t.id),o=ie(t);return(0,V.jsxs)(`div`,{className:`hover:bg-gray-50 dark:hover:bg-gray-750`,children:[(0,V.jsx)(`div`,{className:`p-4`,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-4`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0 w-10 h-10 rounded-full flex items-center justify-center ${n.bgColor}`,children:(0,V.jsx)(r,{className:`h-5 w-5 ${n.color}`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,V.jsx)(`span`,{className:`font-medium ${n.color}`,children:n.text}),(0,V.jsx)(c,{to:`/content/${t.collection}/${t.documentId}`,className:`font-medium text-gray-900 dark:text-white hover:text-primary-600 dark:hover:text-primary-400 truncate`,children:ne(t)}),(0,V.jsx)(`span`,{className:`text-xs px-2 py-0.5 bg-gray-100 dark:bg-gray-700 text-gray-600 dark:text-gray-400 rounded`,children:t.collection})]}),(0,V.jsxs)(`div`,{className:`mt-1 flex items-center gap-4 text-sm text-gray-500 dark:text-gray-400`,children:[(0,V.jsxs)(`span`,{className:`flex items-center`,children:[(0,V.jsx)(Ke,{className:`h-4 w-4 mr-1`}),O[t.actorId]||t.actorUsername||t.actorId]}),(0,V.jsx)(`span`,{title:i.full,children:i.relative}),o&&(0,V.jsx)(`span`,{className:`text-gray-400 dark:text-gray-500`,children:o})]})]}),t.changes&&(t.changes.before||t.changes.after)&&(0,V.jsx)(`button`,{onClick:()=>L(t.id),className:`flex-shrink-0 p-2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 rounded-lg hover:bg-gray-100 dark:hover:bg-gray-700`,title:e(a?`auditLogs.hideDetails`:`auditLogs.showDetails`),children:a?(0,V.jsx)(ye,{className:`h-5 w-5`}):(0,V.jsx)(z,{className:`h-5 w-5`})})]})}),a&&t.changes&&(0,V.jsx)(`div`,{className:`px-4 pb-4 ml-14`,children:(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-900 rounded-lg p-4 border border-gray-200 dark:border-gray-700`,children:[(0,V.jsx)(w$,{before:t.changes.before,after:t.changes.after,operation:t.operation}),(0,V.jsx)(`div`,{className:`mt-4 pt-4 border-t border-gray-200 dark:border-gray-700`,children:(0,V.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-4 gap-4 text-xs text-gray-500 dark:text-gray-400`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e(`auditLogs.technical.revision`)}),` `,t.revision]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e(`auditLogs.technical.documentId`)}),` `,t.documentId]}),t.ipAddress&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e(`auditLogs.technical.ip`)}),` `,t.ipAddress]}),t.actorType&&(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`span`,{className:`font-medium`,children:e(`auditLogs.technical.actorType`)}),` `,t.actorType]})]})})]})})]},t.id)})})}),ae>1&&(0,V.jsxs)(`div`,{className:`mt-6 flex items-center justify-between`,children:[(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:e(`auditLogs.page`,{current:u,total:ae})}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsxs)(`button`,{onClick:()=>d(e=>Math.max(1,e-1)),disabled:u===1,className:`flex items-center px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:[(0,V.jsx)(be,{className:`h-4 w-4 mr-1`}),e(`auditLogs.previous`)]}),(0,V.jsxs)(`button`,{onClick:()=>d(e=>Math.min(ae,e+1)),disabled:u===ae,className:`flex items-center px-3 py-2 text-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-gray-800 border border-gray-300 dark:border-gray-600 rounded-lg hover:bg-gray-50 dark:hover:bg-gray-700 disabled:opacity-50 disabled:cursor-not-allowed`,children:[e(`auditLogs.next`),(0,V.jsx)(z,{className:`h-4 w-4 ml-1`})]})]})]})]})}function G0(){let{t:e}=H(`studio`);return(0,V.jsx)(`div`,{className:`min-h-full flex items-center justify-center p-6`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`text-6xl font-bold text-gray-300 dark:text-gray-600 mb-4`,children:`404`}),(0,V.jsx)(`h1`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-2`,children:e(`notFound.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 mb-6`,children:e(`notFound.message`)}),(0,V.jsx)(U,{asChild:!0,children:(0,V.jsxs)(c,{to:`/`,children:[(0,V.jsx)(ze,{className:`h-4 w-4 mr-2`}),e(`notFound.goToDashboard`)]})})]})})}function K0(){return window.TROKKY_CONFIG?.basePath||``}function q0(e){return`${K0()}${e.startsWith(`/`)?e:`/${e}`}`}function J0(e){window.location.href=q0(e)}var Y0=3e4,X0=class extends Error{constructor(){super(`OAuth callback timed out`),this.name=`OAuthCallbackTimeoutError`}},Z0=!1;function Q0(){if(Z0)return;Z0=!0;let e={en:{auth:{oauth:{notCompleted:`Sign-in could not be completed. Please try again.`}}},fr:{auth:{oauth:{notCompleted:`La connexion n'a pas pu aboutir. Veuillez réessayer.`}}}},t=yr();for(let n of ur){let r=e[n];r&&t.addResourceBundle(n,`studio`,r,!0,!1)}}function $0({onLoginSuccess:e}){Q0();let{t}=H(`studio`),[n,r]=(0,B.useState)(`processing`),[i,a]=(0,B.useState)(null),[o,s]=(0,B.useState)(null),c=(0,B.useRef)(!1);(0,B.useEffect)(()=>{if(!c.current)try{if(!sessionStorage.getItem(`oauth_state`)){if(Ar.getToken()){c.current=!0,r(`success`),s(t(`auth.oauth.loginSuccess`)),setTimeout(()=>{e()},100);return}c.current=!0,r(`error`),a(t(`auth.oauth.notCompleted`));return}c.current=!0,l()}catch{c.current=!0,r(`error`),a(t(`auth.oauth.notCompleted`))}},[]);let l=async()=>{let n=new AbortController,i,o=!1,c=new Promise((e,t)=>{i=setTimeout(()=>{t(new X0),n.abort()},Y0)});try{let i=new URLSearchParams(window.location.search),a=i.get(`code`),l=i.get(`state`);if(i.get(`error`)){let e=i.get(`error_description`)||`Authentication was denied`;throw Error(e)}if(!a||!l)throw Error(`Missing authorization code or state parameter`);let u=sessionStorage.getItem(`oauth_state`),d=sessionStorage.getItem(`oauth_code_verifier`),f=sessionStorage.getItem(`oauth_mode`)||`login`;if(l!==u)throw Error(`Invalid state parameter. This may be a security issue.`);if(!d)throw Error(`Missing code verifier. Please try again.`);let p=e2(),m=await Promise.race([W.post(`/auth/oauth/google/callback`,{code:a,state:l,codeVerifier:d,mode:f,deviceId:p},{signal:n.signal}),c]);if(o=!0,sessionStorage.removeItem(`oauth_state`),sessionStorage.removeItem(`oauth_code_verifier`),sessionStorage.removeItem(`oauth_mode`),m.success&&m.data){if(f===`login`){if(m.data.requiresMFA&&m.data.mfaToken){sessionStorage.setItem(`oauth_mfa_token`,m.data.mfaToken),sessionStorage.setItem(`oauth_mfa_methods`,JSON.stringify(m.data.methods||[])),r(`success`),s(t(`auth.oauth.mfaRequired`)),setTimeout(()=>{window.location.href=K0()+`/?mfa=verify`},500);return}if(m.data.requiresMFASetup&&m.data.setupToken){sessionStorage.setItem(`oauth_mfa_setup_token`,m.data.setupToken),sessionStorage.setItem(`oauth_mfa_allowed_methods`,JSON.stringify(m.data.allowedMethods||[])),sessionStorage.setItem(`oauth_mfa_message`,m.data.message||`MFA setup required`),r(`success`),s(t(`auth.oauth.mfaSetupRequired`)),setTimeout(()=>{window.location.href=K0()+`/?mfa=setup`},500);return}let{token:n,refreshToken:i,user:a}=m.data;if(n&&a)Ar.persist(n,i),r(`success`),s(t(`auth.oauth.loginSuccess`)),setTimeout(()=>{e()},500);else throw Error(t(`auth.oauth.invalidResponse`))}else r(`success`),s(m.data.message||`${t(`auth.oauth.accountLinked`)} (${m.data.provider?.email})`),setTimeout(()=>{window.location.href=K0()+`/user/preferences`},2e3)}else throw Error(m.error?.message||`OAuth callback failed`)}catch(e){if(o)return;o=!0,console.error(`OAuth callback error:`,e);let n=e instanceof X0;r(`error`),a(n?t(`auth.oauth.notCompleted`):e instanceof Error?e.message:`An unexpected error occurred`),sessionStorage.removeItem(`oauth_state`),sessionStorage.removeItem(`oauth_code_verifier`),sessionStorage.removeItem(`oauth_mode`)}finally{clearTimeout(i),c.catch(()=>void 0)}};return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsx)(`div`,{className:`w-full max-w-sm`,children:(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl text-center`,children:[n===`processing`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`lg`,className:`mx-auto mb-4`}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white mb-2`,children:t(`auth.oauth.processing`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:t(`auth.oauth.completingAuth`)})]}),n===`success`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 rounded-full bg-green-100 dark:bg-green-900/30 flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-green-600 dark:text-green-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M5 13l4 4L19 7`})})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white mb-2`,children:t(`auth.oauth.success`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400`,children:o})]}),n===`error`&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 rounded-full bg-red-100 dark:bg-red-900/30 flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-red-600 dark:text-red-400`,fill:`none`,stroke:`currentColor`,viewBox:`0 0 24 24`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white mb-2`,children:t(`auth.oauth.failed`)}),(0,V.jsx)(`p`,{className:`text-red-600 dark:text-red-400 mb-4`,children:i}),(0,V.jsx)(`button`,{onClick:()=>{window.location.href=K0()+`/`},className:`px-6 py-2 bg-gray-900 dark:bg-white text-white dark:text-gray-900 rounded-lg font-medium hover:bg-gray-800 dark:hover:bg-gray-100 transition-colors`,children:t(`auth.oauth.returnToLogin`)})]})]})})})}function e2(){let e=localStorage.getItem(`trokky_device_id`);if(e)return e;let t=crypto.randomUUID();return localStorage.setItem(`trokky_device_id`,t),t}function t2(){let{t:e}=H(`studio`),[t]=p(),n=r(),i=t.get(`code`),[a,o]=(0,B.useState)(`loading`),[s,c]=(0,B.useState)(null),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1);(0,B.useEffect)(()=>{if(!i){o(`error`),u(e(`auth.device.noCode`));return}m()},[i]);let m=async()=>{try{let t=await W.get(`/auth/device/verify?code=${i}`);if(t.success&&t.data)c(t.data),o(`pending`);else{o(`error`);let n=typeof t.error==`string`?t.error:t.error?.message||e(`auth.device.fetchError`);u(n)}}catch(t){o(`error`);let n=t?.message||e(`auth.device.connectError`);u(n)}},h=async()=>{if(i){f(!0);try{let t=await W.post(`/auth/device/verify`,{user_code:i,action:`authorize`});if(t.success)o(`authorized`);else{let n=typeof t.error==`string`?t.error:t.error?.message||e(`auth.device.authError`);u(n),o(`error`)}}catch(t){let n=t?.message||e(`auth.device.authError`);u(n),o(`error`)}finally{f(!1)}}},g=async()=>{if(i){f(!0);try{let t=await W.post(`/auth/device/verify`,{user_code:i,action:`deny`});if(t.success)o(`denied`);else{let n=typeof t.error==`string`?t.error:t.error?.message||e(`auth.device.denyError`);u(n),o(`error`)}}catch(t){let n=t?.message||e(`auth.device.denyError`);u(n),o(`error`)}finally{f(!1)}}},_=t=>t.split(` `).filter(Boolean).map(t=>{switch(t){case`openid`:return e(`auth.device.scopes.openid`);case`profile`:return e(`auth.device.scopes.profile`);case`content:read`:return e(`auth.device.scopes.contentRead`);case`content:write`:return e(`auth.device.scopes.contentWrite`);case`content:delete`:return e(`auth.device.scopes.contentDelete`);case`media:read`:return e(`auth.device.scopes.mediaRead`);case`media:write`:return e(`auth.device.scopes.mediaWrite`);case`offline_access`:return e(`auth.device.scopes.offlineAccess`);default:return t}});return(0,V.jsx)(`div`,{className:`min-h-screen bg-gray-100 dark:bg-gray-900 flex items-center justify-center p-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md bg-white dark:bg-gray-800 rounded-xl shadow-lg p-8`,children:[(0,V.jsx)(`div`,{className:`text-center mb-6`,children:(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`auth.device.pageTitle`)})}),(()=>{switch(a){case`loading`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`p`,{className:`mt-4 text-gray-600 dark:text-gray-400`,children:e(`auth.device.loading`)})]});case`pending`:return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(_e,{className:`w-8 h-8 text-blue-600 dark:text-blue-400`})})}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.device.authorizeDevice`)}),(0,V.jsxs)(`p`,{className:`mt-2 text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(`span`,{className:`font-mono font-bold text-lg text-blue-600 dark:text-blue-400`,children:s?.clientName||s?.clientId||`Trokky CLI`}),` `,e(`auth.device.requestingAccess`)]})]}),(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 rounded-lg p-4`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:e(`auth.device.deviceCode`)}),(0,V.jsx)(`p`,{className:`font-mono text-2xl font-bold text-center text-gray-900 dark:text-white tracking-wider`,children:i})]}),s?.scopes&&s.scopes.length>0&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 rounded-lg p-4`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:e(`auth.device.allowApplication`)}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:_(s.scopes.join(` `)).map((e,t)=>(0,V.jsxs)(`li`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(Ae,{className:`w-4 h-4 mr-2 text-green-500`}),e]},t))})]}),(0,V.jsxs)(`div`,{className:`flex gap-3`,children:[(0,V.jsx)(U,{variant:`secondary`,className:`flex-1`,onClick:g,disabled:d,children:e(`auth.device.deny`)}),(0,V.jsx)(U,{variant:`primary`,className:`flex-1`,onClick:h,disabled:d,children:d?(0,V.jsx)(Ao,{size:`sm`}):e(`auth.device.authorize`)})]})]});case`authorized`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 bg-green-100 dark:bg-green-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(Ae,{className:`w-10 h-10 text-green-600 dark:text-green-400`})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.device.authorized`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:e(`auth.device.authorizedMessage`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:()=>window.close(),children:e(`auth.device.closeWindow`)})]});case`denied`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(We,{className:`w-10 h-10 text-red-600 dark:text-red-400`})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.device.denied`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:e(`auth.device.deniedMessage`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:()=>window.close(),children:e(`auth.device.closeWindow`)})]});case`expired`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 bg-yellow-100 dark:bg-yellow-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(We,{className:`w-10 h-10 text-yellow-600 dark:text-yellow-400`})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.device.expired`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:e(`auth.device.expiredMessage`)})]});case`error`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(We,{className:`w-10 h-10 text-red-600 dark:text-red-400`})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.device.error`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:l||e(`common.error`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:()=>n(`/`),children:e(`auth.device.returnToStudio`)})]})}})()]})})}function n2(){let{t:e}=H(`studio`),[t]=p(),n=r(),[i,a]=(0,B.useState)(`loading`),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(!1),f=t.get(`client_id`),m=t.get(`redirect_uri`),h=t.get(`response_type`),g=t.get(`scope`),_=t.get(`state`),v=t.get(`code_challenge`),y=t.get(`code_challenge_method`);(0,B.useEffect)(()=>{if(!f||!m||!h||!_||!v){a(`error`),l(e(`auth.authorize.missingParams`));return}b()},[f,m,h,g,_,v]);let b=async()=>{try{let t=new URLSearchParams;t.set(`response_type`,h||``),t.set(`client_id`,f||``),t.set(`redirect_uri`,m||``),g&&t.set(`scope`,g),t.set(`state`,_||``),t.set(`code_challenge`,v||``),t.set(`code_challenge_method`,y||`S256`);let n=await W.get(`/auth/authorize?${t.toString()}`);if(n.success&&n.data)s(n.data),n.data.hasExistingConsent?await x(n.data):a(`pending`);else{a(`error`);let t=typeof n.error==`string`?n.error:n.error?.message||e(`auth.authorize.invalidRequest`);l(t)}}catch(t){a(`error`);let n=t?.message||e(`auth.authorize.validateError`);l(n)}},x=async e=>{try{let t=await W.post(`/auth/authorize`,{action:`approve`,client_id:e.client.id,redirect_uri:e.redirectUri,scopes:e.scopes,state:e.state,code_challenge:e.codeChallenge});t.success&&t.data?.redirectUrl?window.location.href=t.data.redirectUrl:a(`pending`)}catch{a(`pending`)}},S=async()=>{if(o){d(!0);try{let t=await W.post(`/auth/authorize`,{action:`approve`,client_id:o.client.id,redirect_uri:o.redirectUri,scopes:o.scopes,state:o.state,code_challenge:o.codeChallenge});if(t.success&&t.data?.redirectUrl)a(`redirecting`),window.location.href=t.data.redirectUrl;else{let n=typeof t.error==`string`?t.error:t.error?.message||e(`auth.authorize.authFailed`);l(n),a(`error`)}}catch(t){let n=t?.message||e(`auth.authorize.authFailed`);l(n),a(`error`)}finally{d(!1)}}},C=async()=>{if(o){d(!0);try{let t=await W.post(`/auth/authorize`,{action:`deny`,client_id:o.client.id,redirect_uri:o.redirectUri,scopes:o.scopes,state:o.state,code_challenge:o.codeChallenge});if(t.success&&t.data?.redirectUrl)a(`redirecting`),window.location.href=t.data.redirectUrl;else{let n=typeof t.error==`string`?t.error:t.error?.message||e(`auth.authorize.denyFailed`);l(n),a(`error`)}}catch(t){let n=t?.message||e(`auth.authorize.denyFailed`);l(n),a(`error`)}finally{d(!1)}}},w=t=>{switch(t){case`openid`:return e(`auth.device.scopes.openid`);case`profile`:return e(`auth.device.scopes.profile`);case`content:read`:return e(`auth.device.scopes.contentRead`);case`content:write`:return e(`auth.device.scopes.contentWrite`);case`content:delete`:return e(`auth.device.scopes.contentDelete`);case`media:read`:return e(`auth.device.scopes.mediaRead`);case`media:write`:return e(`auth.device.scopes.mediaWrite`);case`offline_access`:return e(`auth.device.scopes.offlineAccess`);default:return t}};return(0,V.jsx)(`div`,{className:`min-h-screen bg-gray-100 dark:bg-gray-900 flex items-center justify-center p-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md bg-white dark:bg-gray-800 rounded-xl shadow-lg p-8`,children:[(0,V.jsx)(`div`,{className:`text-center mb-6`,children:(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-gray-900 dark:text-white`,children:e(`auth.authorize.pageTitle`)})}),(()=>{switch(i){case`loading`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`p`,{className:`mt-4 text-gray-600 dark:text-gray-400`,children:e(`auth.authorize.validating`)})]});case`pending`:return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,V.jsx)(`div`,{className:`w-16 h-16 bg-blue-100 dark:bg-blue-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(He,{className:`w-8 h-8 text-blue-600 dark:text-blue-400`})})}),(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.authorize.authorizeApp`)}),(0,V.jsxs)(`p`,{className:`mt-2 text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(`span`,{className:`font-semibold text-blue-600 dark:text-blue-400`,children:o?.client.name}),` `,e(`auth.authorize.wantsAccess`)]}),o?.client.description&&(0,V.jsx)(`p`,{className:`mt-1 text-sm text-gray-500 dark:text-gray-500`,children:o.client.description})]}),o?.scopes&&o.scopes.length>0&&(0,V.jsxs)(`div`,{className:`bg-gray-50 dark:bg-gray-800 rounded-lg p-4`,children:[(0,V.jsx)(`p`,{className:`text-sm font-medium text-gray-700 dark:text-gray-300 mb-3`,children:e(`auth.authorize.allowApplication`)}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:o.scopes.map((e,t)=>(0,V.jsxs)(`li`,{className:`flex items-center text-sm text-gray-600 dark:text-gray-400`,children:[(0,V.jsx)(Ae,{className:`w-4 h-4 mr-2 text-green-500 flex-shrink-0`}),w(e)]},t))})]}),o?.client.homepageUrl&&(0,V.jsx)(`div`,{className:`text-center text-sm`,children:(0,V.jsx)(`a`,{href:o.client.homepageUrl,target:`_blank`,rel:`noopener noreferrer`,className:`text-blue-600 dark:text-blue-400 hover:underline`,children:e(`auth.authorize.visitWebsite`)})}),(0,V.jsxs)(`div`,{className:`flex gap-3`,children:[(0,V.jsx)(U,{variant:`secondary`,className:`flex-1`,onClick:C,disabled:u,children:e(`auth.authorize.deny`)}),(0,V.jsx)(U,{variant:`primary`,className:`flex-1`,onClick:S,disabled:u,children:u?(0,V.jsx)(Ao,{size:`sm`}):e(`auth.authorize.authorize`)})]}),(0,V.jsx)(`p`,{className:`text-xs text-center text-gray-500 dark:text-gray-500`,children:e(`auth.authorize.consentNote`)})]});case`redirecting`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.authorize.redirecting`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:e(`auth.authorize.redirectingMessage`)})]});case`error`:return(0,V.jsxs)(`div`,{className:`flex flex-col items-center justify-center py-12 space-y-4`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 bg-red-100 dark:bg-red-900/30 rounded-full flex items-center justify-center`,children:(0,V.jsx)(We,{className:`w-10 h-10 text-red-600 dark:text-red-400`})}),(0,V.jsx)(`h2`,{className:`text-xl font-semibold text-gray-900 dark:text-white`,children:e(`auth.authorize.error`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-400 text-center`,children:c||e(`common.error`)}),(0,V.jsx)(U,{variant:`secondary`,onClick:()=>n(`/`),children:e(`auth.authorize.returnToStudio`)})]})}})()]})})}var r2=()=>window.TROKKY_CONFIG?.basePath||``,i2=n([{path:`/oauth/callback`,element:(0,V.jsx)(Wa,{children:(0,V.jsx)($0,{onLoginSuccess:()=>window.location.href=r2()+`/`})})},{path:`/auth/device`,element:(0,V.jsx)(Wa,{children:(0,V.jsx)(t2,{})})},{path:`/auth/authorize`,element:(0,V.jsx)(Wa,{children:(0,V.jsx)(n2,{})})},{path:`/`,element:(0,V.jsx)(Wa,{children:(0,V.jsx)(Ha,{})}),errorElement:(0,V.jsx)(Wa,{children:(0,V.jsx)(`div`,{children:`Error occurred`})}),children:[{index:!0,element:(0,V.jsx)(Ro,{})},{path:`content`,element:(0,V.jsx)(Q$,{})},{path:`content/:schemaName`,element:(0,V.jsx)(Q$,{})},{path:`content/:schemaName/:documentId`,element:(0,V.jsx)(Q$,{})},{path:`media`,element:(0,V.jsx)(w1,{})},{path:`users`,element:(0,V.jsx)(K1,{})},{path:`users/:userId`,element:(0,V.jsx)(K1,{})},{path:`settings`,element:(0,V.jsx)(e0,{})},{path:`settings/:section`,element:(0,V.jsx)(e0,{})},{path:`user/preferences`,element:(0,V.jsx)(V0,{})},{path:`audit-logs`,element:(0,V.jsx)(W0,{})},{path:`*`,element:(0,V.jsx)(G0,{})}]}],{basename:r2()});function a2(){return(0,V.jsx)(f,{router:i2})}function o2(e){return e=e.replace(/^#/,``),e.length===3&&(e=e.split(``).map(e=>e+e).join(``)),e.length===6?`${parseInt(e.substring(0,2),16)} ${parseInt(e.substring(2,4),16)} ${parseInt(e.substring(4,6),16)}`:null}function s2(e){let t=document.documentElement;if(e.primaryColor){let n=o2(e.primaryColor);n&&(t.style.setProperty(`--color-primary-500`,n),t.style.setProperty(`--color-primary-600`,n),t.style.setProperty(`--color-primary-700`,n))}if(e.secondaryColor){let n=o2(e.secondaryColor);n&&(t.style.setProperty(`--color-secondary-500`,n),t.style.setProperty(`--color-secondary-600`,n),t.style.setProperty(`--color-secondary-700`,n))}}async function c2(){try{let e=await W.get(`/config/studio`);if(e.success&&e.data?.studioConfig?.branding)return e.data.studioConfig.branding}catch(e){console.error(`Failed to fetch branding:`,e)}return window.TROKKY_CONFIG?.branding||{title:`Trokky Studio`}}var l2=Fr(`PasskeyLoginButton`);function u2({onSuccess:e,onMFARequired:t,onMFASetupRequired:n,onError:r,disabled:i,className:a=``}){let{t:o}=H(`studio`),[s,c]=(0,B.useState)(!1);return(0,V.jsxs)(U,{type:`button`,onClick:async()=>{c(!0);try{l2.debug(`Requesting passkey authentication options`);let i=await W.post(`/auth/passkey/login/options`,{});if(!i.success||!i.data){let e=i.error?.message||o(`passkey.optionsFailed`,`Failed to start passkey authentication`);l2.error(`Failed to get passkey options`,{error:e}),r?.(e);return}let{sessionId:a,...s}=i.data;l2.debug(`Received passkey options`,{sessionId:a.substring(0,8)});let c;try{c=await A0({optionsJSON:s}),l2.debug(`Browser authentication completed`)}catch(e){e.name===`NotAllowedError`?(l2.info(`User cancelled passkey authentication`),r?.(o(`passkey.cancelled`,`Authentication was cancelled`))):e.name===`NotSupportedError`?(l2.warn(`Passkeys not supported in this browser`),r?.(o(`passkey.notSupported`,`Passkeys are not supported in this browser`))):(l2.error(`Browser authentication failed`,{error:e.message}),r?.(e.message||o(`passkey.authFailed`,`Passkey authentication failed`)));return}l2.debug(`Verifying passkey with server`);let l=await W.post(`/auth/passkey/login/verify`,{sessionId:a,credential:c,deviceId:d2()});if(!l.success||!l.data){let e=l.error?.message||o(`passkey.verifyFailed`,`Passkey verification failed`);l2.error(`Passkey verification failed`,{error:e}),r?.(e);return}let u=l.data;u.requiresMFA&&u.mfaToken?(l2.info(`MFA required after passkey authentication`),t?.({mfaToken:u.mfaToken,methods:u.methods||[],expiresIn:u.expiresIn||300})):u.requiresMFASetup&&u.setupToken?(l2.info(`MFA setup required after passkey authentication`),n?.({setupToken:u.setupToken,allowedMethods:u.allowedMethods||[],message:u.message||``,expiresIn:u.expiresIn||900})):u.token&&u.refreshToken&&u.user?(l2.info(`Passkey authentication successful`,{userId:u.user.id}),e?.({token:u.token,refreshToken:u.refreshToken,user:u.user,expiresAt:u.expiresAt||``})):(l2.error(`Unexpected response from passkey verification`),r?.(o(`passkey.unexpectedResponse`,`Unexpected response from server`)))}catch(e){let t=e instanceof Error?e.message:o(`passkey.authFailed`,`Passkey authentication failed`);l2.error(`Passkey authentication error`,{error:t}),r?.(t)}finally{c(!1)}},disabled:i||s,variant:`outline`,className:`w-full flex items-center justify-center gap-3 h-12 border-gray-300 dark:border-gray-600 hover:bg-gray-50 dark:hover:bg-gray-700/50 transition-colors ${a}`,children:[s?(0,V.jsx)(Ao,{size:`sm`}):(0,V.jsx)(f2,{className:`w-5 h-5`}),(0,V.jsx)(`span`,{className:`text-gray-700 dark:text-gray-300`,children:o(`passkey.signIn`,`Sign in with Passkey`)})]})}function d2(){let e=`trokky_device_id`,t=localStorage.getItem(e);if(!t){let n=new Uint8Array(16);crypto.getRandomValues(n),t=Array.from(n,e=>e.toString(16).padStart(2,`0`)).join(``),localStorage.setItem(e,t)}return t}function f2({className:e}){return(0,V.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,V.jsx)(`path`,{d:`M12 2C8.13 2 5 5.13 5 9c0 2.38 1.19 4.47 3 5.74V17a1 1 0 001 1h1v1a1 1 0 001 1h1v1a1 1 0 001 1h2a1 1 0 001-1v-4.26c1.81-1.27 3-3.36 3-5.74 0-3.87-3.13-7-7-7z`,className:`fill-current text-gray-600 dark:text-gray-300`}),(0,V.jsx)(`circle`,{cx:`12`,cy:`9`,r:`2`,className:`fill-current text-white dark:text-gray-800`})]})}function p2({mfaToken:e,methods:t,onSuccess:n,onBack:r}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(t.includes(`totp`)?`totp`:t[0]),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!1),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(!1),y=(0,B.useRef)(null);(0,B.useEffect)(()=>{y.current?.focus()},[s]),(0,B.useEffect)(()=>{s===`email`&&!_&&b()},[s]);let b=async()=>{f(!0),g(null);try{let t=await W.post(`/auth/mfa/send-code`,{mfaToken:e});t.success?v(!0):g(t.error?.message||`Failed to send code`)}catch(e){g(e instanceof Error?e.message:`Failed to send code`)}finally{f(!1)}},x=async t=>{if(t.preventDefault(),!a.trim()){g(i(`mfa.enterCode`));return}u(!0),g(null);try{let t=p?m2():void 0,r=p?h2():void 0,i=s===`backup`?`/auth/mfa/verify-backup`:`/auth/mfa/verify`,c=await W.post(i,{mfaToken:e,code:a.trim(),method:s===`backup`?void 0:s,trustDevice:p,deviceId:t,deviceName:r});c.success&&c.data?(c.data.token&&await W.storeTokens(c.data.token,c.data.refreshToken),c.data.warning&&console.warn(`MFA Warning:`,c.data.warning),n(c.data.token,c.data.user)):(g(c.error?.message||`Verification failed`),o(``))}catch(e){g(e instanceof Error?e.message:`Verification failed`),o(``)}finally{u(!1)}},S=e=>{let t=s===`backup`?e.target.value.replace(/[^A-Za-z0-9-]/g,``).toUpperCase():e.target.value.replace(/[^0-9]/g,``);o(t)},C=e=>{switch(e){case`totp`:return(0,V.jsx)(L,{className:`h-5 w-5`});case`email`:return(0,V.jsx)(ne,{className:`h-5 w-5`});case`backup`:return(0,V.jsx)(te,{className:`h-5 w-5`})}},w=e=>{switch(e){case`totp`:return i(`mfa.authenticatorApp`);case`email`:return i(`mfa.emailCode`);case`backup`:return i(`mfa.backupCode`)}},T=e=>{switch(e){case`totp`:return i(`mfa.totpDescription`);case`email`:return i(_?`mfa.emailDescriptionSent`:`mfa.emailDescriptionPending`);case`backup`:return i(`mfa.backupDescription`)}},E=[...t,`backup`];return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:r,className:`p-2 -ml-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors`,children:(0,V.jsx)(Me,{className:`h-5 w-5`})}),(0,V.jsx)(`h2`,{className:`ml-2 text-xl font-semibold text-gray-900 dark:text-gray-100`,children:i(`mfa.title`)})]}),E.length>1&&(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:E.map(e=>(0,V.jsxs)(`button`,{type:`button`,onClick:()=>{c(e),o(``),g(null),e===`email`&&v(!1)},className:`flex items-center gap-2 px-3 py-2 rounded-lg text-sm font-medium transition-colors ${s===e?`bg-primary-100 dark:bg-primary-900/30 text-primary-700 dark:text-primary-300 border border-primary-300 dark:border-primary-700`:`bg-gray-100 dark:bg-gray-700 text-gray-700 dark:text-gray-300 border border-transparent hover:bg-gray-200 dark:hover:bg-gray-600`}`,children:[C(e),w(e)]},e))}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:T(s)}),h&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:h})}),(0,V.jsxs)(`form`,{onSubmit:x,className:`space-y-4`,children:[(0,V.jsx)(`div`,{className:`relative`,children:(0,V.jsx)(h1,{ref:y,type:`text`,value:a,onChange:S,placeholder:s===`backup`?`XXXX-XXXX`:`000000`,required:!0,disabled:l||s===`email`&&d,autoComplete:`one-time-code`,inputMode:`numeric`,pattern:s===`backup`?`[A-Z0-9]{4}-[A-Z0-9]{4}`:`[0-9]{6}`,maxLength:s===`backup`?9:6,className:`w-full text-center text-2xl tracking-widest font-mono bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 focus:border-primary-500 focus:ring-0 transition-colors`})}),(0,V.jsxs)(`div`,{className:`flex items-center`,children:[(0,V.jsx)(V$,{id:`trust-device`,checked:p,onChange:m,className:`mr-2`}),(0,V.jsx)(`label`,{htmlFor:`trust-device`,className:`text-sm text-gray-600 dark:text-gray-400 cursor-pointer`,children:i(`mfa.trustDevice`)})]}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:l||!a.trim(),children:l?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),i(`mfa.verifying`)]}):i(`mfa.verify`)}),s===`email`&&_&&(0,V.jsx)(`button`,{type:`button`,onClick:b,disabled:d,className:`w-full text-sm text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:i(d?`mfa.sendingCode`:`mfa.resendCode`)})]})]})}function m2(){let e=localStorage.getItem(`trokky_device_id`);if(e)return e;let t=crypto.randomUUID();return localStorage.setItem(`trokky_device_id`,t),t}function h2(){let e=navigator.userAgent,t=`Browser`,n=`Unknown`;return e.includes(`Firefox`)?t=`Firefox`:e.includes(`Edge`)?t=`Edge`:e.includes(`Chrome`)?t=`Chrome`:e.includes(`Safari`)&&(t=`Safari`),e.includes(`Windows`)?n=`Windows`:e.includes(`Mac`)?n=`macOS`:e.includes(`Linux`)?n=`Linux`:e.includes(`Android`)?n=`Android`:(e.includes(`iPhone`)||e.includes(`iPad`))&&(n=`iOS`),`${t} on ${n}`}var g2={turnstile:`https://challenges.cloudflare.com/turnstile/v0/api.js`,recaptcha:`https://www.google.com/recaptcha/api.js`},_2={turnstile:`script[src*="challenges.cloudflare.com/turnstile"]`,recaptcha:`script[src*="google.com/recaptcha/api.js"]`};function v2({provider:e,siteKey:t,options:n={},onVerify:r,onError:i,onExpire:a,className:o=``}){let{t:s}=H(`studio`),c=(0,B.useRef)(null),l=(0,B.useRef)(null),u=(0,B.useRef)({onVerify:r,onError:i,onExpire:a}),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(null);return(0,B.useEffect)(()=>{u.current={onVerify:r,onError:i,onExpire:a}},[r,i,a]),(0,B.useEffect)(()=>{if(e===`hcaptcha`){m(s(`captcha.errors.hcaptchaNotSupported`));return}let t=g2[e],n=_2[e];if(!t){m(s(`captcha.errors.providerNotSupported`,{provider:e}));return}if(e===`turnstile`&&window.turnstile){f(!0);return}if(e===`recaptcha`&&window.grecaptcha){f(!0);return}let r=document.querySelector(n);if(r){let t=()=>{e===`recaptcha`&&window.grecaptcha?window.grecaptcha.ready(()=>f(!0)):f(!0)},n=()=>m(s(`captcha.errors.scriptLoadFailed`));return r.addEventListener(`load`,t),r.addEventListener(`error`,n),()=>{r.removeEventListener(`load`,t),r.removeEventListener(`error`,n)}}let i=document.createElement(`script`);i.src=t,i.async=!0,i.onload=()=>{e===`recaptcha`&&window.grecaptcha?window.grecaptcha.ready(()=>f(!0)):f(!0)},i.onerror=()=>{m(s(`captcha.errors.scriptLoadFailed`))},document.head.appendChild(i)},[e]),(0,B.useEffect)(()=>{if(!d||!c.current||e!==`turnstile`)return;if(!window.turnstile){m(s(`captcha.errors.notAvailable`,{provider:`Turnstile`}));return}if(l.current!==null)return;let r=setTimeout(()=>{if(c.current&&l.current===null)try{l.current=window.turnstile.render(c.current,{sitekey:t,callback:e=>u.current.onVerify(e),"error-callback":e=>u.current.onError?.(e),"expired-callback":()=>u.current.onExpire?.(),theme:n.theme||`auto`,size:n.size||`normal`,language:n.language})}catch(e){console.error(`Failed to render Turnstile widget:`,e),m(s(`captcha.errors.renderFailed`))}},100);return()=>{if(clearTimeout(r),l.current!==null&&window.turnstile){try{window.turnstile.remove(l.current)}catch{}l.current=null}}},[d,e,t,n.theme,n.size]),(0,B.useEffect)(()=>{if(!d||!c.current||e!==`recaptcha`)return;if(!window.grecaptcha){m(s(`captcha.errors.notAvailable`,{provider:`reCAPTCHA`}));return}if(l.current!==null)return;let r=setTimeout(()=>{if(c.current&&l.current===null)try{let e=n.theme===`auto`?`light`:n.theme||`light`,r=n.size===`invisible`?`normal`:n.size||`normal`;l.current=window.grecaptcha.render(c.current,{sitekey:t,callback:e=>u.current.onVerify(e),"error-callback":()=>u.current.onError?.(`reCAPTCHA error`),"expired-callback":()=>u.current.onExpire?.(),theme:e,size:r})}catch(e){console.error(`Failed to render reCAPTCHA widget:`,e),m(s(`captcha.errors.renderFailed`))}},100);return()=>{if(clearTimeout(r),l.current!==null&&window.grecaptcha){try{window.grecaptcha.reset(l.current)}catch{}l.current=null}}},[d,e,t,n.theme,n.size]),p?(0,V.jsx)(`div`,{className:`captcha-widget captcha-error ${o}`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600`,children:p})}):d?(0,V.jsx)(`div`,{ref:c,className:`captcha-widget ${o}`,"data-provider":e}):(0,V.jsx)(`div`,{className:`captcha-widget captcha-loading ${o}`,children:(0,V.jsxs)(`div`,{className:`flex items-center justify-center py-4`,children:[(0,V.jsx)(`div`,{className:`w-5 h-5 border-2 border-gray-300 border-t-blue-600 rounded-full animate-spin`}),(0,V.jsx)(`span`,{className:`ml-2 text-sm text-gray-500`,children:s(`captcha.loading`)})]})})}function y2({endpoint:e}){let[t,n]=(0,B.useState)({isLoading:!0,config:null,isRequired:!1,token:null,error:null});(0,B.useEffect)(()=>{(async()=>{try{let t=await W.get(`/auth/captcha/status`);if(t.success&&t.data){let{enabled:r,config:i,protectedEndpoints:a}=t.data;n(t=>({...t,isLoading:!1,config:r&&i?i:null,isRequired:r&&a[e]}))}else n(e=>({...e,isLoading:!1,isRequired:!1}))}catch(e){console.warn(`Failed to fetch CAPTCHA status:`,e),n(e=>({...e,isLoading:!1,isRequired:!1}))}})()},[e]);let r=(0,B.useCallback)(e=>{n(t=>({...t,token:e,error:null}))},[]),i=(0,B.useCallback)(e=>{n(t=>({...t,token:null,error:e}))},[]),a=(0,B.useCallback)(()=>{n(e=>({...e,token:null}))},[]),o=(0,B.useCallback)(()=>{n(e=>({...e,token:null,error:null}))},[]);return{...t,onVerify:r,onError:i,onExpire:a,reset:o}}function b2({onLoginSuccess:e,onMFASetupRequired:t}){let{t:n}=H(`auth`),[r,i]=(0,B.useState)({username:``,password:``}),[a,o]=(0,B.useState)(!1),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(``),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(!1),[C,w]=(0,B.useState)({required:!1,setupRequired:!1}),[T,E]=(0,B.useState)({step:`select`,verificationCode:``,isLoading:!1}),D=y2({endpoint:`login`}),O=async()=>{if(C.setupToken){E(e=>({...e,isLoading:!0,error:void 0}));try{let e=await W.post(`/auth/mfa/setup/totp`,{},{headers:{"X-MFA-Setup-Token":C.setupToken}});if(e.success&&e.data){let t=e.data;E(e=>({...e,step:`totp-setup`,selectedMethod:`totp`,totpSecret:t.secret,totpQrCode:t.qrCode,isLoading:!1}))}else throw Error(e.error?.message||`Failed to initialize TOTP setup`)}catch(e){E(t=>({...t,isLoading:!1,error:e instanceof Error?e.message:`Setup failed`}))}}},k=async()=>{if(C.setupToken){E(e=>({...e,isLoading:!0,error:void 0}));try{let e=await W.post(`/auth/mfa/setup/email`,{},{headers:{"X-MFA-Setup-Token":C.setupToken}});if(e.success)E(e=>({...e,step:`email-setup`,selectedMethod:`email`,isLoading:!1}));else throw Error(e.error?.message||`Failed to send verification email`)}catch(e){E(t=>({...t,isLoading:!1,error:e instanceof Error?e.message:`Setup failed`}))}}},A=()=>{T.pendingToken&&T.pendingUser&&(Ar.persist(T.pendingToken,T.pendingRefreshToken),e(T.pendingToken,T.pendingUser))},j=()=>{if(T.backupCodes){let e=T.backupCodes.join(`
737
- `);navigator.clipboard.writeText(e)}},M=async()=>{if(C.setupToken&&T.verificationCode){E(e=>({...e,isLoading:!0,error:void 0}));try{let t=T.selectedMethod===`totp`?`/auth/mfa/setup/totp/verify`:`/auth/mfa/setup/email/verify`,n=await W.post(t,{code:T.verificationCode},{headers:{"X-MFA-Setup-Token":C.setupToken}});if(n.success&&n.data){let t=n.data;t.backupCodes&&t.backupCodes.length>0?E(e=>({...e,step:`backup-codes`,backupCodes:t.backupCodes,pendingToken:t.token,pendingRefreshToken:t.refreshToken,pendingUser:t.user,isLoading:!1})):t.token&&t.user?(Ar.persist(t.token,t.refreshToken),e(t.token,t.user)):E(e=>({...e,step:`verify`,isLoading:!1}))}else throw Error(n.error?.message||`Verification failed`)}catch(e){E(t=>({...t,isLoading:!1,error:e instanceof Error?e.message:`Verification failed`}))}}};(0,B.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)};e(),(async()=>{let e=await c2();g(e),s2(e)})(),(async()=>{try{let e=await W.get(`/auth/oauth/status`);e.success&&e.data?.providers?.google&&b(!0)}catch(e){console.debug(`OAuth status check failed:`,e)}})(),(async()=>{try{if(!window.PublicKeyCredential){console.debug(`WebAuthn not supported in this browser`);return}let e=await W.get(`/auth/passkey/status`);e.success&&e.data?.enabled&&S(!0)}catch(e){console.debug(`Passkey status check failed:`,e)}})();let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{localStorage.getItem(`theme`)||e()};t.addEventListener(`change`,n);let r=window.TROKKY_CONFIG?.backendUrl;if(r)m(r||void 0);else{let e=Rr.get(Lr.BACKEND_URL);if(e)m(e);else{let e=`${window.location.origin}/api`;m(e)}}return()=>{t.removeEventListener(`change`,n)}},[]),(0,B.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`mfa`);if(e===`verify`){let e=sessionStorage.getItem(`oauth_mfa_token`),t=sessionStorage.getItem(`oauth_mfa_methods`);if(e&&t){let n=JSON.parse(t);sessionStorage.removeItem(`oauth_mfa_token`),sessionStorage.removeItem(`oauth_mfa_methods`),w({required:!0,setupRequired:!1,mfaToken:e,methods:n}),window.history.replaceState({},``,window.location.pathname)}}else if(e===`setup`){let e=sessionStorage.getItem(`oauth_mfa_setup_token`),t=sessionStorage.getItem(`oauth_mfa_allowed_methods`),n=sessionStorage.getItem(`oauth_mfa_message`);if(e&&t){let r=JSON.parse(t);sessionStorage.removeItem(`oauth_mfa_setup_token`),sessionStorage.removeItem(`oauth_mfa_allowed_methods`),sessionStorage.removeItem(`oauth_mfa_message`),w({required:!1,setupRequired:!0,setupToken:e,allowedMethods:r,message:n||`Your organization requires MFA. Please set up multi-factor authentication.`}),window.history.replaceState({},``,window.location.pathname)}}},[]);let N=async i=>{if(i.preventDefault(),c(!0),u(null),D.isRequired&&!D.token){u(n(`errors.captchaRequired`)),c(!1);return}try{let n=window.TROKKY_CONFIG?.backendUrl;p&&!n&&(Rr.set(Lr.BACKEND_URL,p),W.setBackendUrl(p));let i=x2(),o=await W.login(r.username,r.password,a,i,D.token||void 0);if(o.success&&o.data){let n=o.data;if(n.requiresMFA&&n.mfaToken){w({required:!0,setupRequired:!1,mfaToken:n.mfaToken,methods:n.methods||[`totp`]});return}if(n.requiresMFASetup&&n.setupToken){w({required:!1,setupRequired:!0,setupToken:n.setupToken,allowedMethods:n.allowedMethods||[`totp`,`email`],message:n.message}),t&&t(n.setupToken,n.allowedMethods||[`totp`,`email`]);return}n.token&&n.user?e(n.token,n.user):u(`Invalid login response`)}else u(o.error?.message||`Login failed`)}catch(e){u(e instanceof Error?e.message:`Login failed`)}finally{c(!1)}},P=(t,n)=>{e(t,n)},F=()=>{w({required:!1,setupRequired:!1}),i({username:r.username,password:``})},I=e=>t=>{i(n=>({...n,[e]:t.target.value}))},L=h||{title:`Trokky Studio`};return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[!C.required&&(0,V.jsx)(`div`,{className:`mb-8 text-center`,children:L.logo?(0,V.jsx)(`div`,{className:`flex justify-center`,children:(0,V.jsx)(`img`,{src:L.logo,alt:L.organizationName||L.title,className:`h-20 w-auto object-contain`})}):(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-primary-600 dark:text-primary-400`,children:L.organizationName||L.title})}),C.required&&C.mfaToken&&C.methods&&(0,V.jsx)(p2,{mfaToken:C.mfaToken,methods:C.methods,onSuccess:P,onBack:F,onError:u}),C.setupRequired&&(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`text-center mb-4 p-4 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-amber-800 dark:text-amber-200 mb-2`,children:n(`mfa.required`)}),(0,V.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-300`,children:C.message||n(`mfa.setupRequired`)})]}),T.error&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T.error})}),T.step===`select`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 text-center`,children:n(`mfa.chooseMethod`)}),C.allowedMethods?.includes(`totp`)&&(0,V.jsx)(`button`,{onClick:O,disabled:T.isLoading,className:`w-full p-4 border-2 border-gray-200 dark:border-gray-700 rounded-lg hover:border-primary-500 dark:hover:border-primary-500 transition-colors text-left disabled:opacity-50`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 bg-primary-100 dark:bg-primary-900 rounded-lg flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-6 h-6 text-primary-600 dark:text-primary-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z`})})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-white`,children:n(`mfa.authenticatorApp`)}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`mfa.authenticatorAppDesc`)})]})]})}),C.allowedMethods?.includes(`email`)&&(0,V.jsx)(`button`,{onClick:k,disabled:T.isLoading,className:`w-full p-4 border-2 border-gray-200 dark:border-gray-700 rounded-lg hover:border-primary-500 dark:hover:border-primary-500 transition-colors text-left disabled:opacity-50`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 bg-blue-100 dark:bg-blue-900 rounded-lg flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-6 h-6 text-blue-600 dark:text-blue-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`})})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-white`,children:n(`mfa.emailCode`)}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`mfa.emailCodeDesc`)})]})]})}),T.isLoading&&(0,V.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,V.jsx)(Ao,{size:`md`})})]}),T.step===`totp-setup`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:n(`mfa.scanQR`)}),T.totpQrCode&&(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(`img`,{src:T.totpQrCode,alt:`TOTP QR Code`,className:`w-48 h-48 bg-white p-2 rounded-lg`})}),T.totpSecret&&(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:n(`mfa.manualEntry`)}),(0,V.jsx)(`code`,{className:`text-sm bg-gray-100 dark:bg-gray-800 px-3 py-1 rounded font-mono`,children:T.totpSecret})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:n(`mfa.enterCode`)}),(0,V.jsx)(h1,{type:`text`,value:T.verificationCode,onChange:e=>E(t=>({...t,verificationCode:e.target.value.replace(/\D/g,``).slice(0,6)})),placeholder:`000000`,maxLength:6,className:`text-center text-2xl tracking-widest font-mono`,autoFocus:!0})]}),(0,V.jsx)(U,{onClick:M,disabled:T.isLoading||T.verificationCode.length!==6,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium disabled:opacity-50`,children:T.isLoading?(0,V.jsx)(Ao,{size:`sm`}):n(`mfa.verifyComplete`)}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>E(e=>({...e,step:`select`,verificationCode:``,error:void 0})),className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`mfa.chooseDifferent`)})]}),T.step===`email-setup`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 bg-blue-100 dark:bg-blue-900 rounded-full flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-blue-600 dark:text-blue-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`})})}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`mfa.emailSent`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:n(`mfa.enterEmailCode`)}),(0,V.jsx)(h1,{type:`text`,value:T.verificationCode,onChange:e=>E(t=>({...t,verificationCode:e.target.value.replace(/\D/g,``).slice(0,6)})),placeholder:`000000`,maxLength:6,className:`text-center text-2xl tracking-widest font-mono`,autoFocus:!0})]}),(0,V.jsx)(U,{onClick:M,disabled:T.isLoading||T.verificationCode.length!==6,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium disabled:opacity-50`,children:T.isLoading?(0,V.jsx)(Ao,{size:`sm`}):n(`mfa.verifyComplete`)}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>E(e=>({...e,step:`select`,verificationCode:``,error:void 0})),className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`mfa.chooseDifferent`)})]}),T.step===`backup-codes`&&T.backupCodes&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-green-600 dark:text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})})}),(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-white mb-2`,children:n(`mfa.backupCodes.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`mfa.backupCodes.description`)})]}),(0,V.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2 font-mono text-sm`,children:T.backupCodes.map((e,t)=>(0,V.jsx)(`div`,{className:`text-center py-1 px-2 bg-white dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-600`,children:e},t))})}),(0,V.jsx)(`div`,{className:`flex gap-2`,children:(0,V.jsxs)(U,{onClick:j,variant:`outline`,className:`flex-1 h-10`,children:[(0,V.jsx)(`svg`,{className:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})}),n(`mfa.backupCodes.copy`)]})}),(0,V.jsx)(`div`,{className:`p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800`,children:(0,V.jsxs)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:[(0,V.jsxs)(`strong`,{children:[n(`mfa.backupCodes.warning`).split(`:`)[0],`:`]}),` `,n(`mfa.backupCodes.warning`).split(`:`).slice(1).join(`:`)]})}),(0,V.jsx)(U,{onClick:A,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium`,children:n(`mfa.backupCodes.continue`)})]}),T.step!==`backup-codes`&&(0,V.jsx)(`button`,{type:`button`,onClick:F,className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`login.backToLogin`)})]}),!C.required&&!C.setupRequired&&(0,V.jsxs)(V.Fragment,{children:[l&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:l})}),(0,V.jsxs)(`form`,{onSubmit:N,className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(h1,{type:`text`,value:r.username,onChange:I(`username`),placeholder:n(`login.emailOrUsername`),required:!0,disabled:s,autoComplete:`username`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`})}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:_?`text`:`password`,value:r.password,onChange:I(`password`),placeholder:n(`login.password`),required:!0,disabled:s,autoComplete:`current-password`,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>v(!_),className:`absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 transition-colors`,tabIndex:-1,"aria-label":_?`Hide password`:`Show password`,children:_?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(V$,{id:`remember-me`,checked:a,onChange:o,className:`mr-2`}),(0,V.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:n(`login.rememberMe`)})]}),(0,V.jsx)(`a`,{href:q0(`/forgot-password`),className:`text-sm text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:n(`login.forgotPassword`)})]}),!window.TROKKY_CONFIG?.backendUrl&&(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`flex items-center text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors`,children:[d?(0,V.jsx)(ye,{className:`h-3 w-3 mr-1`}):(0,V.jsx)(z,{className:`h-3 w-3 mr-1`}),n(`advanced.title`)]})}),!window.TROKKY_CONFIG?.backendUrl&&d&&(0,V.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50/50 dark:bg-gray-900/30 rounded-lg border border-gray-200/30 dark:border-gray-700/30`,children:[(0,V.jsx)(h1,{type:`url`,value:p,onChange:e=>m(e.target.value),placeholder:n(`advanced.backendUrl`),disabled:s,className:`text-sm bg-transparent border-gray-300 dark:border-gray-600 px-4 py-2`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:n(`advanced.customEndpoint`)})]}),D.isRequired&&D.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:D.config.provider,siteKey:D.config.siteKey,options:D.config.options,onVerify:D.onVerify,onError:D.onError,onExpire:D.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:s||!r.username||!r.password||D.isRequired&&!D.token,children:s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),n(`login.signingIn`)]}):n(`login.signIn`)}),(x||y)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative my-6`,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,V.jsx)(`div`,{className:`w-full border-t border-gray-300 dark:border-gray-600`})}),(0,V.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,V.jsx)(`span`,{className:`px-4 bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400`,children:n(`login.orContinueWith`)})})]}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[x&&(0,V.jsx)(u2,{onSuccess:t=>{Rr.set(Lr.AUTH_TOKEN,t.token),Rr.set(Lr.REFRESH_TOKEN,t.refreshToken),e(t.token,t.user)},onMFARequired:e=>{w({required:!0,setupRequired:!1,mfaToken:e.mfaToken,methods:e.methods})},onMFASetupRequired:e=>{w({required:!1,setupRequired:!0,setupToken:e.setupToken,allowedMethods:e.allowedMethods,message:e.message})},onError:e=>u(e),disabled:s}),y&&(0,V.jsx)(t0,{mode:`login`,onError:e=>u(e),disabled:s})]})]})]})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:L.title})})]})})}function x2(){let e=localStorage.getItem(`trokky_device_id`);if(e)return e;let t=crypto.randomUUID();return localStorage.setItem(`trokky_device_id`,t),t}function S2(){let{t:e}=H(`studio`),[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),d=y2({endpoint:`passwordResetRequest`});(0,B.useEffect)(()=>{let e=localStorage.getItem(`theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`),(async()=>{let e=await c2();u(e),s2(e)})()},[]);let f=async n=>{if(n.preventDefault(),i(!0),o(null),d.isRequired&&!d.token){o(e(`auth.forgotPassword.captchaRequired`)),i(!1);return}try{let n=await W.post(`/auth/request-reset`,{email:t,captchaToken:d.token||void 0});n.success?c(!0):o(n.error?.message||e(`auth.forgotPassword.sendError`))}catch(t){o(t instanceof Error?t.message:e(`auth.forgotPassword.sendError`))}finally{i(!1)}},p=l||{title:`Trokky Studio`};return s?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(Ae,{className:`h-16 w-16 text-green-500 dark:text-green-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-primary-600 dark:text-primary-400 mb-3`,children:e(`auth.forgotPassword.checkEmail`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-6`,dangerouslySetInnerHTML:{__html:e(`auth.forgotPassword.emailSentMessage`,{email:t})}}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mb-8`,children:e(`auth.forgotPassword.linkExpires`)}),(0,V.jsx)(U,{onClick:()=>J0(`/`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.forgotPassword.backToSignIn`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:p.title})})]})}):(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[(0,V.jsx)(`div`,{className:`mb-6`,children:(0,V.jsxs)(`a`,{href:q0(`/`),className:`inline-flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors`,children:[(0,V.jsx)(Me,{className:`h-4 w-4 mr-2`}),e(`auth.forgotPassword.backToSignIn`)]})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-primary-600 dark:text-primary-400 mb-2`,children:e(`auth.forgotPassword.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-8`,children:e(`auth.forgotPassword.subtitle`)}),a&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a})}),(0,V.jsxs)(`form`,{onSubmit:f,className:`space-y-6`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(h1,{type:`email`,value:t,onChange:e=>n(e.target.value),placeholder:`your@email.com`,required:!0,disabled:r,autoComplete:`email`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`})}),d.isRequired&&d.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:d.config.provider,siteKey:d.config.siteKey,options:d.config.options,onVerify:d.onVerify,onError:d.onError,onExpire:d.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:r||!t||d.isRequired&&!d.token,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),e(`auth.forgotPassword.sending`)]}):e(`auth.forgotPassword.sendResetLink`)})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:p.title})})]})})}function C2(){let{t:e}=H(`studio`),[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!0),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),C=y2({endpoint:`passwordResetVerify`});(0,B.useEffect)(()=>{let e=localStorage.getItem(`trokky_theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||e===`system`&&t||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)},[]),(0,B.useEffect)(()=>{let t=new URLSearchParams(window.location.search).get(`token`);if(!t){v(e(`auth.resetPassword.noToken`)),m(!1);return}n(t),(async()=>{try{let n=await W.post(`/auth/verify-reset-token`,{token:t});n.success&&n.data?.valid?(g(!0),S(n.data.expiresIn??null)):v(n.data?.message||e(`auth.resetPassword.tokenInvalid`))}catch{v(e(`auth.resetPassword.tokenVerifyError`))}finally{m(!1)}})()},[]);let w=async n=>{if(n.preventDefault(),v(null),r.length<8){v(e(`auth.resetPassword.passwordMinLength`));return}if(r!==a){v(e(`auth.resetPassword.passwordMismatch`));return}if(C.isRequired&&!C.token){v(e(`auth.resetPassword.captchaRequired`));return}f(!0);try{let n=await W.post(`/auth/reset-password`,{token:t,newPassword:r,captchaToken:C.token||void 0});n.success?b(!0):v(n.error?.message||e(`auth.resetPassword.resetError`))}catch(t){v(t instanceof Error?t.message:e(`auth.resetPassword.resetError`))}finally{f(!1)}},T=r?(t=>t.length<8?e(`auth.resetPassword.strengthTooShort`):t.length<12?e(`auth.resetPassword.strengthWeak`):t.length<16&&/[A-Z]/.test(t)&&/[0-9]/.test(t)?e(`auth.resetPassword.strengthGood`):t.length>=16&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)?e(`auth.resetPassword.strengthStrong`):e(`auth.resetPassword.strengthMedium`))(r):null,E=window.TROKKY_CONFIG?.branding||{title:`Trokky Studio`};return p?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`p`,{className:`mt-4 text-gray-600 dark:text-gray-400`,children:e(`auth.resetPassword.verifying`)})]})}):y?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(Ae,{className:`h-16 w-16 text-green-500 dark:text-green-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-3`,children:e(`auth.resetPassword.success`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-8`,children:e(`auth.resetPassword.successMessage`)}),(0,V.jsx)(U,{onClick:()=>J0(`/`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.resetPassword.signIn`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})}):h?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-2`,children:e(`auth.resetPassword.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-6`,children:e(`auth.resetPassword.subtitle`)}),x&&x<10&&(0,V.jsx)(`div`,{className:`mb-4 p-3 bg-yellow-50/80 dark:bg-yellow-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-yellow-800 dark:text-yellow-200`,children:e(`auth.resetPassword.linkExpiresIn`,{minutes:x,count:x})})}),_&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_})}),(0,V.jsxs)(`form`,{onSubmit:w,className:`space-y-6`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:s?`text`:`password`,value:r,onChange:e=>i(e.target.value),placeholder:e(`auth.resetPassword.newPassword`),required:!0,disabled:d,autoComplete:`new-password`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:s?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]}),r&&(0,V.jsxs)(`p`,{className:`mt-2 text-xs ${T===e(`auth.resetPassword.strengthStrong`)?`text-green-600 dark:text-green-400`:T===e(`auth.resetPassword.strengthGood`)?`text-blue-600 dark:text-blue-400`:T===e(`auth.resetPassword.strengthMedium`)?`text-yellow-600 dark:text-yellow-400`:`text-red-600 dark:text-red-400`}`,children:[e(`auth.resetPassword.strength`),`: `,T]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:l?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:e(`auth.resetPassword.confirmPassword`),required:!0,disabled:d,autoComplete:`new-password`,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>u(!l),className:`absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:l?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]}),a&&a!==r&&(0,V.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:e(`auth.resetPassword.passwordMismatch`)})]}),(0,V.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400 space-y-1`,children:[(0,V.jsx)(`p`,{children:e(`auth.resetPassword.requirements`)}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 ml-2`,children:[(0,V.jsx)(`li`,{className:r.length>=8?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireLength`)}),(0,V.jsx)(`li`,{className:/[A-Z]/.test(r)?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireUppercase`)}),(0,V.jsx)(`li`,{className:/[0-9]/.test(r)?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireNumber`)})]})]}),C.isRequired&&C.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:C.config.provider,siteKey:C.config.siteKey,options:C.config.options,onVerify:C.onVerify,onError:C.onError,onExpire:C.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:d||!r||!a||r!==a||C.isRequired&&!C.token,children:d?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),e(`auth.resetPassword.resetting`)]}):e(`auth.resetPassword.resetButton`)})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})}):(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(We,{className:`h-16 w-16 text-red-500 dark:text-red-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-3`,children:e(`auth.resetPassword.invalidLink`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-2`,children:_||e(`auth.resetPassword.invalidLinkMessage`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mb-8`,children:e(`auth.resetPassword.linkExpireNote`)}),(0,V.jsx)(U,{onClick:()=>J0(`/forgot-password`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.resetPassword.requestNewLink`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})})}function w2({show:e,onDismiss:t,onRefresh:n,expiresAt:r}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)(``);return(0,B.useEffect)(()=>{if(!e||!r)return;let t=()=>{let e=new Date,t=r.getTime()-e.getTime();if(t<=0){o(`Session expired`);return}let n=Math.floor(t/6e4),i=Math.floor(t%6e4/1e3);o(n>0?`${n} minute${n>1?`s`:``}`:`${i} second${i>1?`s`:``}`)};t();let n=setInterval(t,1e3);return()=>clearInterval(n)},[e,r]),e?(0,V.jsx)(`div`,{className:`fixed top-4 right-4 z-toast max-w-sm`,children:(0,V.jsx)(`div`,{className:`bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4 shadow-lg`,children:(0,V.jsxs)(`div`,{className:`flex items-start`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:(0,V.jsx)(de,{className:`h-5 w-5 text-amber-400`})}),(0,V.jsxs)(`div`,{className:`ml-3 flex-1`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:i(`sessionTimeout.title`)}),(0,V.jsx)(`div`,{className:`mt-1 text-sm text-amber-700 dark:text-amber-300`,children:(0,V.jsx)(`p`,{children:i(`sessionTimeout.expireIn`,{time:a})})}),(0,V.jsxs)(`div`,{className:`mt-3 flex space-x-2`,children:[(0,V.jsx)(U,{size:`sm`,onClick:()=>{console.log(`Extend Session button clicked!`),n()},className:`bg-amber-600 hover:bg-amber-700 text-white`,children:i(`sessionTimeout.stayLoggedIn`)}),(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:t,className:`text-amber-800 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-800/20`,children:i(`common.dismiss`)})]})]}),(0,V.jsx)(`div`,{className:`ml-auto flex-shrink-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex rounded-md text-amber-400 hover:text-amber-500 focus:outline-none focus:ring-2 focus:ring-amber-500 focus:ring-offset-2 focus:ring-offset-amber-50`,onClick:t,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:i(`common.close`)}),(0,V.jsx)(tt,{className:`h-5 w-5`})]})})]})})}):null}function T2(){let{showTimeoutWarning:e,sessionExpiresAt:t,dismissTimeoutWarning:n,refreshSession:r}=ri();return(0,V.jsx)(w2,{show:e,expiresAt:t,onDismiss:n,onRefresh:r})}var E2=({toast:e,onRemove:t})=>{let{t:n}=H(`studio`),{id:r,message:i,type:a,duration:o=3e3}=e;return(0,B.useEffect)(()=>{let e=setTimeout(()=>{t(r)},o);return()=>{clearTimeout(e)}},[r,o,t]),(0,V.jsxs)(`div`,{className:`
737
+ `);navigator.clipboard.writeText(e)}},M=async()=>{if(C.setupToken&&T.verificationCode){E(e=>({...e,isLoading:!0,error:void 0}));try{let t=T.selectedMethod===`totp`?`/auth/mfa/setup/totp/verify`:`/auth/mfa/setup/email/verify`,n=await W.post(t,{code:T.verificationCode},{headers:{"X-MFA-Setup-Token":C.setupToken}});if(n.success&&n.data){let t=n.data;t.backupCodes&&t.backupCodes.length>0?E(e=>({...e,step:`backup-codes`,backupCodes:t.backupCodes,pendingToken:t.token,pendingRefreshToken:t.refreshToken,pendingUser:t.user,isLoading:!1})):t.token&&t.user?(Ar.persist(t.token,t.refreshToken),e(t.token,t.user)):E(e=>({...e,step:`verify`,isLoading:!1}))}else throw Error(n.error?.message||`Verification failed`)}catch(e){E(t=>({...t,isLoading:!1,error:e instanceof Error?e.message:`Verification failed`}))}}};(0,B.useEffect)(()=>{let e=()=>{let e=localStorage.getItem(`theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)};e(),(async()=>{let e=await c2();g(e),s2(e)})(),(async()=>{try{let e=await W.get(`/auth/oauth/status`);e.success&&e.data?.providers?.google&&b(!0)}catch(e){console.debug(`OAuth status check failed:`,e)}})(),(async()=>{try{if(!window.PublicKeyCredential){console.debug(`WebAuthn not supported in this browser`);return}let e=await W.get(`/auth/passkey/status`);e.success&&e.data?.enabled&&S(!0)}catch(e){console.debug(`Passkey status check failed:`,e)}})();let t=window.matchMedia(`(prefers-color-scheme: dark)`),n=()=>{localStorage.getItem(`theme`)||e()};t.addEventListener(`change`,n);let r=window.TROKKY_CONFIG?.backendUrl;if(r)m(r||void 0);else{let e=Rr.get(Lr.BACKEND_URL);if(e)m(e);else{let e=`${window.location.origin}/api`;m(e)}}return()=>{t.removeEventListener(`change`,n)}},[]),(0,B.useEffect)(()=>{let e=new URLSearchParams(window.location.search).get(`mfa`);if(e===`verify`){let e=sessionStorage.getItem(`oauth_mfa_token`),t=sessionStorage.getItem(`oauth_mfa_methods`);if(e&&t){let n=JSON.parse(t);sessionStorage.removeItem(`oauth_mfa_token`),sessionStorage.removeItem(`oauth_mfa_methods`),w({required:!0,setupRequired:!1,mfaToken:e,methods:n}),window.history.replaceState({},``,window.location.pathname)}}else if(e===`setup`){let e=sessionStorage.getItem(`oauth_mfa_setup_token`),t=sessionStorage.getItem(`oauth_mfa_allowed_methods`),n=sessionStorage.getItem(`oauth_mfa_message`);if(e&&t){let r=JSON.parse(t);sessionStorage.removeItem(`oauth_mfa_setup_token`),sessionStorage.removeItem(`oauth_mfa_allowed_methods`),sessionStorage.removeItem(`oauth_mfa_message`),w({required:!1,setupRequired:!0,setupToken:e,allowedMethods:r,message:n||`Your organization requires MFA. Please set up multi-factor authentication.`}),window.history.replaceState({},``,window.location.pathname)}}},[]);let N=async i=>{if(i.preventDefault(),c(!0),u(null),D.isRequired&&!D.token){u(n(`errors.captchaRequired`)),c(!1);return}try{let n=window.TROKKY_CONFIG?.backendUrl;p&&!n&&(Rr.set(Lr.BACKEND_URL,p),W.setBackendUrl(p));let i=x2(),o=await W.login(r.username,r.password,a,i,D.token||void 0);if(o.success&&o.data){let n=o.data;if(n.requiresMFA&&n.mfaToken){w({required:!0,setupRequired:!1,mfaToken:n.mfaToken,methods:n.methods||[`totp`]});return}if(n.requiresMFASetup&&n.setupToken){w({required:!1,setupRequired:!0,setupToken:n.setupToken,allowedMethods:n.allowedMethods||[`totp`,`email`],message:n.message}),t&&t(n.setupToken,n.allowedMethods||[`totp`,`email`]);return}n.token&&n.user?e(n.token,n.user):u(`Invalid login response`)}else u(o.error?.message||`Login failed`)}catch(e){u(e instanceof Error?e.message:`Login failed`)}finally{c(!1)}},P=(t,n)=>{e(t,n)},F=()=>{w({required:!1,setupRequired:!1}),i({username:r.username,password:``})},I=e=>t=>{i(n=>({...n,[e]:t.target.value}))},L=h||{title:`Trokky Studio`};return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-sm`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[!C.required&&(0,V.jsx)(`div`,{className:`mb-8 text-center`,children:L.logo?(0,V.jsx)(`div`,{className:`flex justify-center`,children:(0,V.jsx)(`img`,{src:L.logo,alt:L.organizationName||L.title,className:`h-20 w-auto object-contain`})}):(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-primary-600 dark:text-primary-400`,children:L.organizationName||L.title})}),C.required&&C.mfaToken&&C.methods&&(0,V.jsx)(p2,{mfaToken:C.mfaToken,methods:C.methods,onSuccess:P,onBack:F,onError:u}),C.setupRequired&&(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`text-center mb-4 p-4 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800`,children:[(0,V.jsx)(`h2`,{className:`text-lg font-semibold text-amber-800 dark:text-amber-200 mb-2`,children:n(`mfa.required`)}),(0,V.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-300`,children:C.message||n(`mfa.setupRequired`)})]}),T.error&&(0,V.jsx)(`div`,{className:`p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:T.error})}),T.step===`select`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 text-center`,children:n(`mfa.chooseMethod`)}),C.allowedMethods?.includes(`totp`)&&(0,V.jsx)(`button`,{onClick:O,disabled:T.isLoading,className:`w-full p-4 border-2 border-gray-200 dark:border-gray-700 rounded-lg hover:border-primary-500 dark:hover:border-primary-500 transition-colors text-left disabled:opacity-50`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 bg-primary-100 dark:bg-primary-900 rounded-lg flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-6 h-6 text-primary-600 dark:text-primary-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M12 18h.01M8 21h8a2 2 0 002-2V5a2 2 0 00-2-2H8a2 2 0 00-2 2v14a2 2 0 002 2z`})})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-white`,children:n(`mfa.authenticatorApp`)}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`mfa.authenticatorAppDesc`)})]})]})}),C.allowedMethods?.includes(`email`)&&(0,V.jsx)(`button`,{onClick:k,disabled:T.isLoading,className:`w-full p-4 border-2 border-gray-200 dark:border-gray-700 rounded-lg hover:border-primary-500 dark:hover:border-primary-500 transition-colors text-left disabled:opacity-50`,children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 bg-blue-100 dark:bg-blue-900 rounded-lg flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-6 h-6 text-blue-600 dark:text-blue-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`})})}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`font-medium text-gray-900 dark:text-white`,children:n(`mfa.emailCode`)}),(0,V.jsx)(`div`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n(`mfa.emailCodeDesc`)})]})]})}),T.isLoading&&(0,V.jsx)(`div`,{className:`flex justify-center py-4`,children:(0,V.jsx)(Ao,{size:`md`})})]}),T.step===`totp-setup`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400 mb-4`,children:n(`mfa.scanQR`)}),T.totpQrCode&&(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(`img`,{src:T.totpQrCode,alt:`TOTP QR Code`,className:`w-48 h-48 bg-white p-2 rounded-lg`})}),T.totpSecret&&(0,V.jsxs)(`div`,{className:`mb-4`,children:[(0,V.jsx)(`p`,{className:`text-xs text-gray-500 dark:text-gray-400 mb-1`,children:n(`mfa.manualEntry`)}),(0,V.jsx)(`code`,{className:`text-sm bg-gray-100 dark:bg-gray-800 px-3 py-1 rounded font-mono`,children:T.totpSecret})]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:n(`mfa.enterCode`)}),(0,V.jsx)(h1,{type:`text`,value:T.verificationCode,onChange:e=>E(t=>({...t,verificationCode:e.target.value.replace(/\D/g,``).slice(0,6)})),placeholder:`000000`,maxLength:6,className:`text-center text-2xl tracking-widest font-mono`,autoFocus:!0})]}),(0,V.jsx)(U,{onClick:M,disabled:T.isLoading||T.verificationCode.length!==6,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium disabled:opacity-50`,children:T.isLoading?(0,V.jsx)(Ao,{size:`sm`}):n(`mfa.verifyComplete`)}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>E(e=>({...e,step:`select`,verificationCode:``,error:void 0})),className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`mfa.chooseDifferent`)})]}),T.step===`email-setup`&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 bg-blue-100 dark:bg-blue-900 rounded-full flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-blue-600 dark:text-blue-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z`})})}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`mfa.emailSent`)})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`label`,{className:`block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2`,children:n(`mfa.enterEmailCode`)}),(0,V.jsx)(h1,{type:`text`,value:T.verificationCode,onChange:e=>E(t=>({...t,verificationCode:e.target.value.replace(/\D/g,``).slice(0,6)})),placeholder:`000000`,maxLength:6,className:`text-center text-2xl tracking-widest font-mono`,autoFocus:!0})]}),(0,V.jsx)(U,{onClick:M,disabled:T.isLoading||T.verificationCode.length!==6,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium disabled:opacity-50`,children:T.isLoading?(0,V.jsx)(Ao,{size:`sm`}):n(`mfa.verifyComplete`)}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>E(e=>({...e,step:`select`,verificationCode:``,error:void 0})),className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`mfa.chooseDifferent`)})]}),T.step===`backup-codes`&&T.backupCodes&&(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`w-16 h-16 mx-auto mb-4 bg-green-100 dark:bg-green-900 rounded-full flex items-center justify-center`,children:(0,V.jsx)(`svg`,{className:`w-8 h-8 text-green-600 dark:text-green-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M9 12l2 2 4-4m5.618-4.016A11.955 11.955 0 0112 2.944a11.955 11.955 0 01-8.618 3.04A12.02 12.02 0 003 9c0 5.591 3.824 10.29 9 11.622 5.176-1.332 9-6.03 9-11.622 0-1.042-.133-2.052-.382-3.016z`})})}),(0,V.jsx)(`h3`,{className:`text-lg font-semibold text-gray-900 dark:text-white mb-2`,children:n(`mfa.backupCodes.title`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-600 dark:text-gray-400`,children:n(`mfa.backupCodes.description`)})]}),(0,V.jsx)(`div`,{className:`p-4 bg-gray-50 dark:bg-gray-900 rounded-lg border border-gray-200 dark:border-gray-700`,children:(0,V.jsx)(`div`,{className:`grid grid-cols-2 gap-2 font-mono text-sm`,children:T.backupCodes.map((e,t)=>(0,V.jsx)(`div`,{className:`text-center py-1 px-2 bg-white dark:bg-gray-800 rounded border border-gray-200 dark:border-gray-600`,children:e},t))})}),(0,V.jsx)(`div`,{className:`flex gap-2`,children:(0,V.jsxs)(U,{onClick:j,variant:`outline`,className:`flex-1 h-10`,children:[(0,V.jsx)(`svg`,{className:`w-4 h-4 mr-2`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:(0,V.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z`})}),n(`mfa.backupCodes.copy`)]})}),(0,V.jsx)(`div`,{className:`p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800`,children:(0,V.jsxs)(`p`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:[(0,V.jsxs)(`strong`,{children:[n(`mfa.backupCodes.warning`).split(`:`)[0],`:`]}),` `,n(`mfa.backupCodes.warning`).split(`:`).slice(1).join(`:`)]})}),(0,V.jsx)(U,{onClick:A,className:`w-full h-12 bg-primary-600 hover:bg-primary-700 text-white rounded-lg font-medium`,children:n(`mfa.backupCodes.continue`)})]}),T.step!==`backup-codes`&&(0,V.jsx)(`button`,{type:`button`,onClick:F,className:`w-full text-sm text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200`,children:n(`login.backToLogin`)})]}),!C.required&&!C.setupRequired&&(0,V.jsxs)(V.Fragment,{children:[l&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:l})}),(0,V.jsxs)(`form`,{onSubmit:N,className:`space-y-6`,children:[(0,V.jsxs)(`div`,{className:`space-y-4`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(h1,{type:`text`,value:r.username,onChange:I(`username`),placeholder:n(`login.emailOrUsername`),required:!0,disabled:s,autoComplete:`username`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`})}),(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:_?`text`:`password`,value:r.password,onChange:I(`password`),placeholder:n(`login.password`),required:!0,disabled:s,autoComplete:`current-password`,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>v(!_),className:`absolute right-2 top-1/2 -translate-y-1/2 p-2 text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300 transition-colors`,tabIndex:-1,"aria-label":_?`Hide password`:`Show password`,children:_?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]})]}),(0,V.jsxs)(`div`,{className:`flex items-center justify-between text-sm`,children:[(0,V.jsxs)(`label`,{className:`flex items-center`,children:[(0,V.jsx)(V$,{id:`remember-me`,checked:a,onChange:o,className:`mr-2`}),(0,V.jsx)(`span`,{className:`text-gray-600 dark:text-gray-400`,children:n(`login.rememberMe`)})]}),(0,V.jsx)(`a`,{href:q0(`/forgot-password`),className:`text-sm text-primary-600 dark:text-primary-400 hover:text-primary-700 dark:hover:text-primary-300 transition-colors`,children:n(`login.forgotPassword`)})]}),!window.TROKKY_CONFIG?.backendUrl&&(0,V.jsx)(`div`,{className:`flex justify-end`,children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>f(!d),className:`flex items-center text-xs text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-300 transition-colors`,children:[d?(0,V.jsx)(ye,{className:`h-3 w-3 mr-1`}):(0,V.jsx)(z,{className:`h-3 w-3 mr-1`}),n(`advanced.title`)]})}),!window.TROKKY_CONFIG?.backendUrl&&d&&(0,V.jsxs)(`div`,{className:`mt-4 p-4 bg-gray-50/50 dark:bg-gray-900/30 rounded-lg border border-gray-200/30 dark:border-gray-700/30`,children:[(0,V.jsx)(h1,{type:`url`,value:p,onChange:e=>m(e.target.value),placeholder:n(`advanced.backendUrl`),disabled:s,className:`text-sm bg-transparent border-gray-300 dark:border-gray-600 px-4 py-2`}),(0,V.jsx)(`p`,{className:`mt-2 text-xs text-gray-500 dark:text-gray-400`,children:n(`advanced.customEndpoint`)})]}),D.isRequired&&D.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:D.config.provider,siteKey:D.config.siteKey,options:D.config.options,onVerify:D.onVerify,onError:D.onError,onExpire:D.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:s||!r.username||!r.password||D.isRequired&&!D.token,children:s?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),n(`login.signingIn`)]}):n(`login.signIn`)}),(x||y)&&(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{className:`relative my-6`,children:[(0,V.jsx)(`div`,{className:`absolute inset-0 flex items-center`,children:(0,V.jsx)(`div`,{className:`w-full border-t border-gray-300 dark:border-gray-600`})}),(0,V.jsx)(`div`,{className:`relative flex justify-center text-sm`,children:(0,V.jsx)(`span`,{className:`px-4 bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400`,children:n(`login.orContinueWith`)})})]}),(0,V.jsxs)(`div`,{className:`space-y-3`,children:[x&&(0,V.jsx)(u2,{onSuccess:t=>{Rr.set(Lr.AUTH_TOKEN,t.token),Rr.set(Lr.REFRESH_TOKEN,t.refreshToken),e(t.token,t.user)},onMFARequired:e=>{w({required:!0,setupRequired:!1,mfaToken:e.mfaToken,methods:e.methods})},onMFASetupRequired:e=>{w({required:!1,setupRequired:!0,setupToken:e.setupToken,allowedMethods:e.allowedMethods,message:e.message})},onError:e=>u(e),disabled:s}),y&&(0,V.jsx)(t0,{mode:`login`,onError:e=>u(e),disabled:s})]})]})]})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:L.title})})]})})}function x2(){let e=localStorage.getItem(`trokky_device_id`);if(e)return e;let t=crypto.randomUUID();return localStorage.setItem(`trokky_device_id`,t),t}function S2({secretRequired:e,onLoginSuccess:t,onClaimedWithoutSession:n}){let{t:r}=H(`auth`),[i,a]=(0,B.useState)({username:``,email:``,password:``,confirmPassword:``,secret:``}),[o,s]=(0,B.useState)(null),[c,l]=(0,B.useState)(!1),u=e=>t=>a(n=>({...n,[e]:t.target.value}));return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsx)(`div`,{className:`w-full max-w-sm`,children:(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[(0,V.jsxs)(`div`,{className:`mb-6 text-center`,children:[(0,V.jsx)(`h1`,{className:`text-2xl font-bold text-primary-600 dark:text-primary-400`,children:r(`claim.title`)}),(0,V.jsx)(`p`,{className:`mt-2 text-sm text-gray-600 dark:text-gray-300`,children:r(`claim.subtitle`)})]}),!e&&(0,V.jsx)(`div`,{role:`note`,className:`mb-6 p-3 bg-amber-50 dark:bg-amber-900/20 rounded-lg border border-amber-200 dark:border-amber-800 text-sm text-amber-800 dark:text-amber-200`,children:r(`claim.openWarning`)}),o&&(0,V.jsx)(`div`,{role:`alert`,className:`mb-4 p-3 bg-red-50 dark:bg-red-900/20 rounded-lg border border-red-200 dark:border-red-800`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:o})}),(0,V.jsxs)(`form`,{onSubmit:async a=>{if(a.preventDefault(),s(null),i.password!==i.confirmPassword){s(r(`claim.passwordMismatch`));return}l(!0);try{let a=await W.claimInstance({username:i.username.trim(),email:i.email.trim(),password:i.password,secret:e?i.secret:void 0});if(!a.success||!a.data?.claimed){s(a.error?.message||r(`claim.failed`));return}if(a.data.token&&a.data.user){Ar.persist(a.data.token,a.data.refreshToken),t(a.data.token,a.data.user);return}n?.()}catch(e){s(e instanceof Error?e.message:r(`claim.failed`))}finally{l(!1)}},className:`space-y-4`,children:[(0,V.jsx)(h1,{label:r(`claim.username`),name:`username`,autoComplete:`username`,required:!0,value:i.username,onChange:u(`username`)}),(0,V.jsx)(h1,{label:r(`claim.email`),name:`email`,type:`email`,autoComplete:`email`,required:!0,value:i.email,onChange:u(`email`)}),(0,V.jsx)(h1,{label:r(`claim.password`),name:`password`,type:`password`,autoComplete:`new-password`,required:!0,value:i.password,onChange:u(`password`)}),(0,V.jsx)(h1,{label:r(`claim.confirmPassword`),name:`confirmPassword`,type:`password`,autoComplete:`new-password`,required:!0,value:i.confirmPassword,onChange:u(`confirmPassword`)}),e&&(0,V.jsx)(h1,{label:r(`claim.secret`),name:`secret`,type:`password`,autoComplete:`off`,required:!0,helperText:r(`claim.secretHelp`),value:i.secret,onChange:u(`secret`)}),(0,V.jsx)(U,{type:`submit`,className:`w-full`,loading:c,disabled:c,children:r(c?`claim.claiming`:`claim.claim`)})]})]})})})}function C2(){let{t:e}=H(`studio`),[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)(!1),[a,o]=(0,B.useState)(null),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(null),d=y2({endpoint:`passwordResetRequest`});(0,B.useEffect)(()=>{let e=localStorage.getItem(`theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`),(async()=>{let e=await c2();u(e),s2(e)})()},[]);let f=async n=>{if(n.preventDefault(),i(!0),o(null),d.isRequired&&!d.token){o(e(`auth.forgotPassword.captchaRequired`)),i(!1);return}try{let n=await W.post(`/auth/request-reset`,{email:t,captchaToken:d.token||void 0});n.success?c(!0):o(n.error?.message||e(`auth.forgotPassword.sendError`))}catch(t){o(t instanceof Error?t.message:e(`auth.forgotPassword.sendError`))}finally{i(!1)}},p=l||{title:`Trokky Studio`};return s?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(Ae,{className:`h-16 w-16 text-green-500 dark:text-green-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-primary-600 dark:text-primary-400 mb-3`,children:e(`auth.forgotPassword.checkEmail`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-6`,dangerouslySetInnerHTML:{__html:e(`auth.forgotPassword.emailSentMessage`,{email:t})}}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mb-8`,children:e(`auth.forgotPassword.linkExpires`)}),(0,V.jsx)(U,{onClick:()=>J0(`/`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.forgotPassword.backToSignIn`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:p.title})})]})}):(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[(0,V.jsx)(`div`,{className:`mb-6`,children:(0,V.jsxs)(`a`,{href:q0(`/`),className:`inline-flex items-center text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-white transition-colors`,children:[(0,V.jsx)(Me,{className:`h-4 w-4 mr-2`}),e(`auth.forgotPassword.backToSignIn`)]})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-primary-600 dark:text-primary-400 mb-2`,children:e(`auth.forgotPassword.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-8`,children:e(`auth.forgotPassword.subtitle`)}),a&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a})}),(0,V.jsxs)(`form`,{onSubmit:f,className:`space-y-6`,children:[(0,V.jsx)(`div`,{children:(0,V.jsx)(h1,{type:`email`,value:t,onChange:e=>n(e.target.value),placeholder:`your@email.com`,required:!0,disabled:r,autoComplete:`email`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`})}),d.isRequired&&d.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:d.config.provider,siteKey:d.config.siteKey,options:d.config.options,onVerify:d.onVerify,onError:d.onError,onExpire:d.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:r||!t||d.isRequired&&!d.token,children:r?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),e(`auth.forgotPassword.sending`)]}):e(`auth.forgotPassword.sendResetLink`)})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:p.title})})]})})}function w2(){let{t:e}=H(`studio`),[t,n]=(0,B.useState)(``),[r,i]=(0,B.useState)(``),[a,o]=(0,B.useState)(``),[s,c]=(0,B.useState)(!1),[l,u]=(0,B.useState)(!1),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(!0),[h,g]=(0,B.useState)(!1),[_,v]=(0,B.useState)(null),[y,b]=(0,B.useState)(!1),[x,S]=(0,B.useState)(null),C=y2({endpoint:`passwordResetVerify`});(0,B.useEffect)(()=>{let e=localStorage.getItem(`trokky_theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||e===`system`&&t||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)},[]),(0,B.useEffect)(()=>{let t=new URLSearchParams(window.location.search).get(`token`);if(!t){v(e(`auth.resetPassword.noToken`)),m(!1);return}n(t),(async()=>{try{let n=await W.post(`/auth/verify-reset-token`,{token:t});n.success&&n.data?.valid?(g(!0),S(n.data.expiresIn??null)):v(n.data?.message||e(`auth.resetPassword.tokenInvalid`))}catch{v(e(`auth.resetPassword.tokenVerifyError`))}finally{m(!1)}})()},[]);let w=async n=>{if(n.preventDefault(),v(null),r.length<8){v(e(`auth.resetPassword.passwordMinLength`));return}if(r!==a){v(e(`auth.resetPassword.passwordMismatch`));return}if(C.isRequired&&!C.token){v(e(`auth.resetPassword.captchaRequired`));return}f(!0);try{let n=await W.post(`/auth/reset-password`,{token:t,newPassword:r,captchaToken:C.token||void 0});n.success?b(!0):v(n.error?.message||e(`auth.resetPassword.resetError`))}catch(t){v(t instanceof Error?t.message:e(`auth.resetPassword.resetError`))}finally{f(!1)}},T=r?(t=>t.length<8?e(`auth.resetPassword.strengthTooShort`):t.length<12?e(`auth.resetPassword.strengthWeak`):t.length<16&&/[A-Z]/.test(t)&&/[0-9]/.test(t)?e(`auth.resetPassword.strengthGood`):t.length>=16&&/[A-Z]/.test(t)&&/[0-9]/.test(t)&&/[^A-Za-z0-9]/.test(t)?e(`auth.resetPassword.strengthStrong`):e(`auth.resetPassword.strengthMedium`))(r):null,E=window.TROKKY_CONFIG?.branding||{title:`Trokky Studio`};return p?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`p`,{className:`mt-4 text-gray-600 dark:text-gray-400`,children:e(`auth.resetPassword.verifying`)})]})}):y?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(Ae,{className:`h-16 w-16 text-green-500 dark:text-green-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-3`,children:e(`auth.resetPassword.success`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-8`,children:e(`auth.resetPassword.successMessage`)}),(0,V.jsx)(U,{onClick:()=>J0(`/`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.resetPassword.signIn`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})}):h?(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsxs)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-2`,children:e(`auth.resetPassword.title`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-6`,children:e(`auth.resetPassword.subtitle`)}),x&&x<10&&(0,V.jsx)(`div`,{className:`mb-4 p-3 bg-yellow-50/80 dark:bg-yellow-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-yellow-800 dark:text-yellow-200`,children:e(`auth.resetPassword.linkExpiresIn`,{minutes:x,count:x})})}),_&&(0,V.jsx)(`div`,{className:`mb-6 p-3 bg-red-50/80 dark:bg-red-900/20 rounded-lg`,children:(0,V.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:_})}),(0,V.jsxs)(`form`,{onSubmit:w,className:`space-y-6`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:s?`text`:`password`,value:r,onChange:e=>i(e.target.value),placeholder:e(`auth.resetPassword.newPassword`),required:!0,disabled:d,autoComplete:`new-password`,autoFocus:!0,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>c(!s),className:`absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:s?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]}),r&&(0,V.jsxs)(`p`,{className:`mt-2 text-xs ${T===e(`auth.resetPassword.strengthStrong`)?`text-green-600 dark:text-green-400`:T===e(`auth.resetPassword.strengthGood`)?`text-blue-600 dark:text-blue-400`:T===e(`auth.resetPassword.strengthMedium`)?`text-yellow-600 dark:text-yellow-400`:`text-red-600 dark:text-red-400`}`,children:[e(`auth.resetPassword.strength`),`: `,T]})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsxs)(`div`,{className:`relative`,children:[(0,V.jsx)(h1,{type:l?`text`:`password`,value:a,onChange:e=>o(e.target.value),placeholder:e(`auth.resetPassword.confirmPassword`),required:!0,disabled:d,autoComplete:`new-password`,className:`w-full bg-transparent border-0 border-b-2 border-gray-200 dark:border-gray-600 rounded-none px-4 py-3 pr-12 text-base placeholder-gray-400 dark:placeholder-gray-500 focus:border-primary-500 focus:ring-0 transition-colors`}),(0,V.jsx)(`button`,{type:`button`,onClick:()=>u(!l),className:`absolute right-4 top-1/2 -translate-y-1/2 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,children:l?(0,V.jsx)(le,{className:`h-5 w-5`}):(0,V.jsx)(ce,{className:`h-5 w-5`})})]}),a&&a!==r&&(0,V.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:e(`auth.resetPassword.passwordMismatch`)})]}),(0,V.jsxs)(`div`,{className:`text-sm text-gray-600 dark:text-gray-400 space-y-1`,children:[(0,V.jsx)(`p`,{children:e(`auth.resetPassword.requirements`)}),(0,V.jsxs)(`ul`,{className:`list-disc list-inside space-y-1 ml-2`,children:[(0,V.jsx)(`li`,{className:r.length>=8?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireLength`)}),(0,V.jsx)(`li`,{className:/[A-Z]/.test(r)?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireUppercase`)}),(0,V.jsx)(`li`,{className:/[0-9]/.test(r)?`text-green-600 dark:text-green-400`:``,children:e(`auth.resetPassword.requireNumber`)})]})]}),C.isRequired&&C.config&&(0,V.jsx)(`div`,{className:`flex justify-center my-4`,children:(0,V.jsx)(v2,{provider:C.config.provider,siteKey:C.config.siteKey,options:C.config.options,onVerify:C.onVerify,onError:C.onError,onExpire:C.onExpire})}),(0,V.jsx)(U,{type:`submit`,className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium text-base transition-colors`,disabled:d||!r||!a||r!==a||C.isRequired&&!C.token,children:d?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(Ao,{size:`sm`,className:`mr-2`}),e(`auth.resetPassword.resetting`)]}):e(`auth.resetPassword.resetButton`)})]})]}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})}):(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gradient-to-br from-gray-50 to-gray-100 dark:from-gray-900 dark:to-gray-800 px-4`,children:(0,V.jsxs)(`div`,{className:`w-full max-w-md`,children:[(0,V.jsx)(`div`,{className:`bg-white/60 dark:bg-gray-800/60 backdrop-blur-sm rounded-2xl border border-white/20 dark:border-gray-700/20 p-8 shadow-xl`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,V.jsx)(We,{className:`h-16 w-16 text-red-500 dark:text-red-400`})}),(0,V.jsx)(`h2`,{className:`text-2xl font-semibold text-gray-900 dark:text-white mb-3`,children:e(`auth.resetPassword.invalidLink`)}),(0,V.jsx)(`p`,{className:`text-gray-600 dark:text-gray-300 mb-2`,children:_||e(`auth.resetPassword.invalidLinkMessage`)}),(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400 mb-8`,children:e(`auth.resetPassword.linkExpireNote`)}),(0,V.jsx)(U,{onClick:()=>J0(`/forgot-password`),className:`w-full h-12 bg-gray-900 dark:bg-white text-white dark:text-gray-900 hover:bg-gray-800 dark:hover:bg-gray-100 rounded-lg font-medium transition-colors`,children:e(`auth.resetPassword.requestNewLink`)})]})}),(0,V.jsx)(`div`,{className:`mt-8 text-center`,children:(0,V.jsx)(`p`,{className:`text-xs text-gray-400 dark:text-gray-500`,children:E.title})})]})})}function T2({show:e,onDismiss:t,onRefresh:n,expiresAt:r}){let{t:i}=H(`studio`),[a,o]=(0,B.useState)(``);return(0,B.useEffect)(()=>{if(!e||!r)return;let t=()=>{let e=new Date,t=r.getTime()-e.getTime();if(t<=0){o(`Session expired`);return}let n=Math.floor(t/6e4),i=Math.floor(t%6e4/1e3);o(n>0?`${n} minute${n>1?`s`:``}`:`${i} second${i>1?`s`:``}`)};t();let n=setInterval(t,1e3);return()=>clearInterval(n)},[e,r]),e?(0,V.jsx)(`div`,{className:`fixed top-4 right-4 z-toast max-w-sm`,children:(0,V.jsx)(`div`,{className:`bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 rounded-lg p-4 shadow-lg`,children:(0,V.jsxs)(`div`,{className:`flex items-start`,children:[(0,V.jsx)(`div`,{className:`flex-shrink-0`,children:(0,V.jsx)(de,{className:`h-5 w-5 text-amber-400`})}),(0,V.jsxs)(`div`,{className:`ml-3 flex-1`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:i(`sessionTimeout.title`)}),(0,V.jsx)(`div`,{className:`mt-1 text-sm text-amber-700 dark:text-amber-300`,children:(0,V.jsx)(`p`,{children:i(`sessionTimeout.expireIn`,{time:a})})}),(0,V.jsxs)(`div`,{className:`mt-3 flex space-x-2`,children:[(0,V.jsx)(U,{size:`sm`,onClick:()=>{console.log(`Extend Session button clicked!`),n()},className:`bg-amber-600 hover:bg-amber-700 text-white`,children:i(`sessionTimeout.stayLoggedIn`)}),(0,V.jsx)(U,{size:`sm`,variant:`ghost`,onClick:t,className:`text-amber-800 dark:text-amber-200 hover:bg-amber-100 dark:hover:bg-amber-800/20`,children:i(`common.dismiss`)})]})]}),(0,V.jsx)(`div`,{className:`ml-auto flex-shrink-0`,children:(0,V.jsxs)(`button`,{type:`button`,className:`inline-flex rounded-md text-amber-400 hover:text-amber-500 focus:outline-none focus:ring-2 focus:ring-amber-500 focus:ring-offset-2 focus:ring-offset-amber-50`,onClick:t,children:[(0,V.jsx)(`span`,{className:`sr-only`,children:i(`common.close`)}),(0,V.jsx)(tt,{className:`h-5 w-5`})]})})]})})}):null}function E2(){let{showTimeoutWarning:e,sessionExpiresAt:t,dismissTimeoutWarning:n,refreshSession:r}=ri();return(0,V.jsx)(T2,{show:e,expiresAt:t,onDismiss:n,onRefresh:r})}var D2=({toast:e,onRemove:t})=>{let{t:n}=H(`studio`),{id:r,message:i,type:a,duration:o=3e3}=e;return(0,B.useEffect)(()=>{let e=setTimeout(()=>{t(r)},o);return()=>{clearTimeout(e)}},[r,o,t]),(0,V.jsxs)(`div`,{className:`
738
738
  flex items-center px-3 py-2 rounded-lg border shadow-lg backdrop-blur-sm
739
739
  transition-all duration-300 ease-in-out transform animate-in slide-in-from-top-2
740
740
  ${(()=>{switch(a){case`success`:return`bg-white dark:bg-gray-800 border-green-200 dark:border-green-800 text-gray-800 dark:text-gray-200`;case`error`:return`bg-white dark:bg-gray-800 border-red-200 dark:border-red-800 text-gray-800 dark:text-gray-200`;case`warning`:return`bg-white dark:bg-gray-800 border-amber-200 dark:border-amber-800 text-gray-800 dark:text-gray-200`;default:return`bg-white dark:bg-gray-800 border-blue-200 dark:border-blue-800 text-gray-800 dark:text-gray-200`}})()}
741
- `,role:`alert`,children:[(()=>{switch(a){case`success`:return(0,V.jsx)(F,{className:`w-4 h-4 text-green-500`});case`error`:return(0,V.jsx)(tt,{className:`w-4 h-4 text-red-500`});case`warning`:return(0,V.jsx)(de,{className:`w-4 h-4 text-amber-500`});default:return(0,V.jsx)(ue,{className:`w-4 h-4 text-blue-500`})}})(),(0,V.jsx)(`div`,{className:`ml-2 flex-1`,children:(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:i})}),(0,V.jsx)(`button`,{onClick:()=>t(r),className:`ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors opacity-60 hover:opacity-100`,"aria-label":n(`toast.closeNotification`),children:(0,V.jsx)(tt,{className:`w-3 h-3`})})]})},D2=()=>{let{t:e}=H(`studio`),[t,n]=(0,B.useState)([]);(0,B.useEffect)(()=>{let e=e=>{let{message:t,type:r}=e.detail,i={id:`toast-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,message:t,type:r,duration:r===`error`?4e3:3e3};n(e=>[...e,i].slice(-3))};return window.addEventListener(`studio:toast`,e),()=>{window.removeEventListener(`studio:toast`,e)}},[]);let r=(0,B.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return t.length===0?null:(0,V.jsx)(`div`,{className:`fixed bottom-4 right-4 z-toast space-y-2 max-w-xs w-full pointer-events-none`,"aria-live":`polite`,"aria-label":e(`toast.notifications`),children:t.map(e=>(0,V.jsx)(`div`,{className:`pointer-events-auto`,children:(0,V.jsx)(E2,{toast:e,onRemove:r})},e.id))})},O2=({isOpen:e,title:t,message:n,confirmText:r,cancelText:i,variant:a=`default`,onConfirm:o,onCancel:s})=>{let{t:c}=H(`studio`),l=r||c(`confirmDialog.defaultConfirm`),u=i||c(`confirmDialog.defaultCancel`),d=a===`danger`?{icon:(0,V.jsx)(de,{className:`h-6 w-6 text-red-600`}),iconBg:`bg-red-100 dark:bg-red-900/20`,confirmButton:`bg-red-600 hover:bg-red-700 focus:ring-red-500 text-white`}:{icon:(0,V.jsx)(de,{className:`h-6 w-6 text-amber-600`}),iconBg:`bg-amber-100 dark:bg-amber-900/20`,confirmButton:`bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 text-white`};return(0,V.jsx)(ia,{open:e,onClose:s,variant:`center`,size:`md`,ariaLabel:t||n,children:(0,V.jsxs)(ia.Body,{padded:!1,className:`px-4 pb-4 pt-5 sm:p-6`,children:[(0,V.jsx)(`button`,{onClick:s,className:`absolute right-4 top-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,"aria-label":u,children:(0,V.jsx)(tt,{className:`h-5 w-5`})}),(0,V.jsxs)(`div`,{className:`sm:flex sm:items-start`,children:[(0,V.jsx)(`div`,{className:`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${d.iconBg} sm:mx-0 sm:h-10 sm:w-10`,children:d.icon}),(0,V.jsxs)(`div`,{className:`mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left`,children:[t&&(0,V.jsx)(`h3`,{className:`text-base font-semibold leading-6 text-gray-900 dark:text-white`,children:t}),(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n})})]})]}),(0,V.jsxs)(`div`,{className:`mt-5 sm:mt-4 sm:flex sm:flex-row-reverse gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold shadow-sm sm:w-auto ${d.confirmButton} focus:outline-none focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-800`,children:l}),(0,V.jsx)(`button`,{type:`button`,onClick:s,className:`mt-3 inline-flex w-full justify-center rounded-md bg-white dark:bg-gray-700 px-3 py-2 text-sm font-semibold text-gray-900 dark:text-gray-200 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 sm:mt-0 sm:w-auto focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800`,children:u})]})]})})},k2=()=>{let[e,t]=(0,B.useState)({isOpen:!1,message:``});(0,B.useEffect)(()=>{let e=e=>{let{message:n,title:r,confirmText:i,cancelText:a,variant:o,resolve:s}=e.detail;t({isOpen:!0,message:n,title:r,confirmText:i,cancelText:a,variant:o,resolve:s})};return window.addEventListener(`studio:confirm`,e),()=>{window.removeEventListener(`studio:confirm`,e)}},[]);let n=(0,B.useCallback)(()=>{e.resolve?.(!0),t(e=>({...e,isOpen:!1}))},[e.resolve]),r=(0,B.useCallback)(()=>{e.resolve?.(!1),t(e=>({...e,isOpen:!1}))},[e.resolve]);return(0,V.jsx)(O2,{isOpen:e.isOpen,title:e.title,message:e.message,confirmText:e.confirmText,cancelText:e.cancelText,variant:e.variant,onConfirm:n,onCancel:r})},A2=Fr(`useDocumentTitle`);function j2(e=!1){let t=async()=>{try{let e=await W.get(`/config/studio`);if(e.success&&e.data?.studioConfig?.branding){let t=e.data.studioConfig.branding;if(t.title){document.title=t.title,A2.debug(`Document title updated from branding`,{title:t.title});return}}}catch(e){A2.warn(`Failed to load studio config for document title`,e)}document.title=`Trokky Studio`,A2.debug(`Document title updated from default`,{title:`Trokky Studio`})};(0,B.useEffect)(()=>{t();let e=()=>{A2.debug(`Settings changed, updating document title`),t()};return window.addEventListener(`trokky:settings:updated`,e),()=>{window.removeEventListener(`trokky:settings:updated`,e)}},[e])}var M2=Fr(`Debug`);typeof window<`u`&&(window.TrokkyDebug={clearStructureCache(){try{Xr().clearCache(),M2.info(`✅ Structure cache cleared`);try{localStorage.removeItem(`trokky_structure_cache`),sessionStorage.removeItem(`trokky_structure_cache`),M2.info(`✅ Browser structure cache cleared`)}catch(e){M2.warn(`⚠️ Could not clear browser cache:`,e)}}catch(e){M2.error(`❌ Failed to clear structure cache:`,e)}},async refreshStructure(){try{let e=await Xr().refreshFromEndpoint();e?M2.info(`✅ Structure refreshed from endpoint:`,{title:e.title,itemsCount:e.items?.length||0}):M2.warn(`⚠️ No structure returned from endpoint, falling back to defaults`)}catch(e){M2.error(`❌ Failed to refresh structure:`,e)}},async getStructureInfo(){try{let e=Xr(),t=await e.getStructure(),n={cached:e.isCached(),title:t.title,itemsCount:t.items?.length||0,metadata:t.metadata,items:t.items?.map(e=>({type:e.type,title:e.title,schemaType:e.schemaType,hasChildren:!!e.items?.length}))};return M2.info(`📊 Current structure info:`,n),n}catch(e){return M2.error(`❌ Failed to get structure info:`,e),{error:e instanceof Error?e.message:String(e)}}},clearAllCache(){try{this.clearStructureCache(),Ar.clear(),[`trokky_user_data`,`trokky_theme`,`trokky_sidebar_collapsed`,`trokky_studio_config`].forEach(e=>{try{localStorage.removeItem(e),sessionStorage.removeItem(e)}catch{}}),M2.info(`✅ All browser cache cleared`)}catch(e){M2.error(`❌ Failed to clear all cache:`,e)}},enableDebugLogging(){try{localStorage.setItem(`trokky_debug_enabled`,`true`),window.TrokkyLogger?.setLevel&&window.TrokkyLogger.setLevel(`debug`),M2.info(`✅ Debug logging enabled`)}catch(e){M2.error(`❌ Failed to enable debug logging:`,e)}},disableDebugLogging(){try{localStorage.removeItem(`trokky_debug_enabled`),window.TrokkyLogger?.setLevel&&window.TrokkyLogger.setLevel(`info`),M2.info(`✅ Debug logging disabled`)}catch(e){M2.error(`❌ Failed to disable debug logging:`,e)}}});function N2(){let e=window.TROKKY_CONFIG?.i18n;return{defaultLocale:e?.defaultLocale||`en`,supportedLocales:e?.supportedLocales||[`en`,`fr`],fallbackLocale:e?.fallbackLocale||`en`,detectBrowserLanguage:e?.detectBrowserLanguage??!0,debug:e?.debug??!1}}W.initialize();var P2=new ht({defaultOptions:{queries:{retry:2,staleTime:3e5}}});function F2(){let{t:e}=H(`common`),{isAuthenticated:t,isLoading:n,checkAuth:r}=ri(),i=Fr(`AppContent`),a=(0,B.useRef)({});j2(t),(0,B.useEffect)(()=>{let e={isAuthenticated:t,isLoading:n},r=a.current;(r.isAuthenticated!==t||r.isLoading!==n)&&(i.debug(`Auth state changed`,e),a.current=e)},[t,n,i]);let o=()=>{i.info(`Login successful, rechecking auth state`);let e=sessionStorage.getItem(`trokky_oauth_redirect`);if(e){sessionStorage.removeItem(`trokky_oauth_redirect`),i.info(`Redirecting to OAuth flow`,{url:e}),window.location.href=e;return}r()};if(n)return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-gray-900 dark:text-white`,children:e(`app.loadingStudio`)})]})});if(!t){let e=window.location.pathname,t=window.TROKKY_CONFIG?.basePath||``,n=e.replace(t,``);if(n===`/forgot-password`)return(0,V.jsx)(S2,{});if(n===`/reset-password`)return(0,V.jsx)(C2,{});if(n===`/oauth/callback`)return(0,V.jsx)($0,{onLoginSuccess:o});if(n===`/auth/authorize`||n===`/auth/device`){let e=window.location.href;return sessionStorage.setItem(`trokky_oauth_redirect`,e),(0,V.jsx)(b2,{onLoginSuccess:o})}return(0,V.jsx)(b2,{onLoginSuccess:o})}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(a2,{}),(0,V.jsx)(T2,{}),(0,Ht.createPortal)((0,V.jsxs)(`div`,{"data-dialog-exempt":``,children:[(0,V.jsx)(D2,{}),(0,V.jsx)(k2,{})]}),document.body)]})}function I2(){let[e,t]=(0,B.useState)(null),n=(0,B.useMemo)(()=>N2(),[]);return(0,B.useEffect)(()=>{Fr(`App`).info(`Trokky Studio started`),(async()=>{let e=await c2();t(e),s2(e),e.title&&(document.title=e.title)})();let e=async e=>{let n=e.detail?.settings;if(n){let e={title:n.studioTitle,organizationName:n.organizationName,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,logo:n.logo};t(e),s2(e),e.title&&(document.title=e.title)}};return window.addEventListener(`trokky:settings:updated`,e),()=>{window.removeEventListener(`trokky:settings:updated`,e)}},[]),(0,V.jsx)(br,{config:n,children:(0,V.jsx)(N,{client:P2,children:(0,V.jsx)(ni,{children:(0,V.jsx)(fa,{branding:e,children:(0,V.jsx)(`div`,{className:`App`,children:(0,V.jsx)(F2,{})})})})})})}(()=>{try{let e=localStorage.getItem(`trokky_theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||e===`system`&&t||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)}catch(e){console.warn(`Failed to initialize theme:`,e)}})(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{let t=localStorage.getItem(`trokky_theme`);(!t||t===`system`)&&(e.matches?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`))}),Ut.createRoot(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(I2,{})}));
742
- //# sourceMappingURL=index-Da-xtsMB.js.map
741
+ `,role:`alert`,children:[(()=>{switch(a){case`success`:return(0,V.jsx)(F,{className:`w-4 h-4 text-green-500`});case`error`:return(0,V.jsx)(tt,{className:`w-4 h-4 text-red-500`});case`warning`:return(0,V.jsx)(de,{className:`w-4 h-4 text-amber-500`});default:return(0,V.jsx)(ue,{className:`w-4 h-4 text-blue-500`})}})(),(0,V.jsx)(`div`,{className:`ml-2 flex-1`,children:(0,V.jsx)(`p`,{className:`text-sm font-medium`,children:i})}),(0,V.jsx)(`button`,{onClick:()=>t(r),className:`ml-3 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors opacity-60 hover:opacity-100`,"aria-label":n(`toast.closeNotification`),children:(0,V.jsx)(tt,{className:`w-3 h-3`})})]})},O2=()=>{let{t:e}=H(`studio`),[t,n]=(0,B.useState)([]);(0,B.useEffect)(()=>{let e=e=>{let{message:t,type:r}=e.detail,i={id:`toast-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,message:t,type:r,duration:r===`error`?4e3:3e3};n(e=>[...e,i].slice(-3))};return window.addEventListener(`studio:toast`,e),()=>{window.removeEventListener(`studio:toast`,e)}},[]);let r=(0,B.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return t.length===0?null:(0,V.jsx)(`div`,{className:`fixed bottom-4 right-4 z-toast space-y-2 max-w-xs w-full pointer-events-none`,"aria-live":`polite`,"aria-label":e(`toast.notifications`),children:t.map(e=>(0,V.jsx)(`div`,{className:`pointer-events-auto`,children:(0,V.jsx)(D2,{toast:e,onRemove:r})},e.id))})},k2=({isOpen:e,title:t,message:n,confirmText:r,cancelText:i,variant:a=`default`,onConfirm:o,onCancel:s})=>{let{t:c}=H(`studio`),l=r||c(`confirmDialog.defaultConfirm`),u=i||c(`confirmDialog.defaultCancel`),d=a===`danger`?{icon:(0,V.jsx)(de,{className:`h-6 w-6 text-red-600`}),iconBg:`bg-red-100 dark:bg-red-900/20`,confirmButton:`bg-red-600 hover:bg-red-700 focus:ring-red-500 text-white`}:{icon:(0,V.jsx)(de,{className:`h-6 w-6 text-amber-600`}),iconBg:`bg-amber-100 dark:bg-amber-900/20`,confirmButton:`bg-blue-600 hover:bg-blue-700 focus:ring-blue-500 text-white`};return(0,V.jsx)(ia,{open:e,onClose:s,variant:`center`,size:`md`,ariaLabel:t||n,children:(0,V.jsxs)(ia.Body,{padded:!1,className:`px-4 pb-4 pt-5 sm:p-6`,children:[(0,V.jsx)(`button`,{onClick:s,className:`absolute right-4 top-4 text-gray-400 hover:text-gray-600 dark:hover:text-gray-300`,"aria-label":u,children:(0,V.jsx)(tt,{className:`h-5 w-5`})}),(0,V.jsxs)(`div`,{className:`sm:flex sm:items-start`,children:[(0,V.jsx)(`div`,{className:`mx-auto flex h-12 w-12 flex-shrink-0 items-center justify-center rounded-full ${d.iconBg} sm:mx-0 sm:h-10 sm:w-10`,children:d.icon}),(0,V.jsxs)(`div`,{className:`mt-3 text-center sm:ml-4 sm:mt-0 sm:text-left`,children:[t&&(0,V.jsx)(`h3`,{className:`text-base font-semibold leading-6 text-gray-900 dark:text-white`,children:t}),(0,V.jsx)(`div`,{className:`mt-2`,children:(0,V.jsx)(`p`,{className:`text-sm text-gray-500 dark:text-gray-400`,children:n})})]})]}),(0,V.jsxs)(`div`,{className:`mt-5 sm:mt-4 sm:flex sm:flex-row-reverse gap-3`,children:[(0,V.jsx)(`button`,{type:`button`,onClick:o,className:`inline-flex w-full justify-center rounded-md px-3 py-2 text-sm font-semibold shadow-sm sm:w-auto ${d.confirmButton} focus:outline-none focus:ring-2 focus:ring-offset-2 dark:focus:ring-offset-gray-800`,children:l}),(0,V.jsx)(`button`,{type:`button`,onClick:s,className:`mt-3 inline-flex w-full justify-center rounded-md bg-white dark:bg-gray-700 px-3 py-2 text-sm font-semibold text-gray-900 dark:text-gray-200 shadow-sm ring-1 ring-inset ring-gray-300 dark:ring-gray-600 hover:bg-gray-50 dark:hover:bg-gray-600 sm:mt-0 sm:w-auto focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 dark:focus:ring-offset-gray-800`,children:u})]})]})})},A2=()=>{let[e,t]=(0,B.useState)({isOpen:!1,message:``});(0,B.useEffect)(()=>{let e=e=>{let{message:n,title:r,confirmText:i,cancelText:a,variant:o,resolve:s}=e.detail;t({isOpen:!0,message:n,title:r,confirmText:i,cancelText:a,variant:o,resolve:s})};return window.addEventListener(`studio:confirm`,e),()=>{window.removeEventListener(`studio:confirm`,e)}},[]);let n=(0,B.useCallback)(()=>{e.resolve?.(!0),t(e=>({...e,isOpen:!1}))},[e.resolve]),r=(0,B.useCallback)(()=>{e.resolve?.(!1),t(e=>({...e,isOpen:!1}))},[e.resolve]);return(0,V.jsx)(k2,{isOpen:e.isOpen,title:e.title,message:e.message,confirmText:e.confirmText,cancelText:e.cancelText,variant:e.variant,onConfirm:n,onCancel:r})},j2=Fr(`useDocumentTitle`);function M2(e=!1){let t=async()=>{try{let e=await W.get(`/config/studio`);if(e.success&&e.data?.studioConfig?.branding){let t=e.data.studioConfig.branding;if(t.title){document.title=t.title,j2.debug(`Document title updated from branding`,{title:t.title});return}}}catch(e){j2.warn(`Failed to load studio config for document title`,e)}document.title=`Trokky Studio`,j2.debug(`Document title updated from default`,{title:`Trokky Studio`})};(0,B.useEffect)(()=>{t();let e=()=>{j2.debug(`Settings changed, updating document title`),t()};return window.addEventListener(`trokky:settings:updated`,e),()=>{window.removeEventListener(`trokky:settings:updated`,e)}},[e])}var N2=Fr(`Debug`);typeof window<`u`&&(window.TrokkyDebug={clearStructureCache(){try{Xr().clearCache(),N2.info(`✅ Structure cache cleared`);try{localStorage.removeItem(`trokky_structure_cache`),sessionStorage.removeItem(`trokky_structure_cache`),N2.info(`✅ Browser structure cache cleared`)}catch(e){N2.warn(`⚠️ Could not clear browser cache:`,e)}}catch(e){N2.error(`❌ Failed to clear structure cache:`,e)}},async refreshStructure(){try{let e=await Xr().refreshFromEndpoint();e?N2.info(`✅ Structure refreshed from endpoint:`,{title:e.title,itemsCount:e.items?.length||0}):N2.warn(`⚠️ No structure returned from endpoint, falling back to defaults`)}catch(e){N2.error(`❌ Failed to refresh structure:`,e)}},async getStructureInfo(){try{let e=Xr(),t=await e.getStructure(),n={cached:e.isCached(),title:t.title,itemsCount:t.items?.length||0,metadata:t.metadata,items:t.items?.map(e=>({type:e.type,title:e.title,schemaType:e.schemaType,hasChildren:!!e.items?.length}))};return N2.info(`📊 Current structure info:`,n),n}catch(e){return N2.error(`❌ Failed to get structure info:`,e),{error:e instanceof Error?e.message:String(e)}}},clearAllCache(){try{this.clearStructureCache(),Ar.clear(),[`trokky_user_data`,`trokky_theme`,`trokky_sidebar_collapsed`,`trokky_studio_config`].forEach(e=>{try{localStorage.removeItem(e),sessionStorage.removeItem(e)}catch{}}),N2.info(`✅ All browser cache cleared`)}catch(e){N2.error(`❌ Failed to clear all cache:`,e)}},enableDebugLogging(){try{localStorage.setItem(`trokky_debug_enabled`,`true`),window.TrokkyLogger?.setLevel&&window.TrokkyLogger.setLevel(`debug`),N2.info(`✅ Debug logging enabled`)}catch(e){N2.error(`❌ Failed to enable debug logging:`,e)}},disableDebugLogging(){try{localStorage.removeItem(`trokky_debug_enabled`),window.TrokkyLogger?.setLevel&&window.TrokkyLogger.setLevel(`info`),N2.info(`✅ Debug logging disabled`)}catch(e){N2.error(`❌ Failed to disable debug logging:`,e)}}});function P2(){let e=window.TROKKY_CONFIG?.i18n;return{defaultLocale:e?.defaultLocale||`en`,supportedLocales:e?.supportedLocales||[`en`,`fr`],fallbackLocale:e?.fallbackLocale||`en`,detectBrowserLanguage:e?.detectBrowserLanguage??!0,debug:e?.debug??!1}}W.initialize();var F2=new ht({defaultOptions:{queries:{retry:2,staleTime:3e5}}});function I2(){let{t:e}=H(`common`),{isAuthenticated:t,isLoading:n,checkAuth:r}=ri(),i=Fr(`AppContent`),a=(0,B.useRef)({}),[o,s]=(0,B.useState)({checked:!1,claimable:!1,secretRequired:!1});(0,B.useEffect)(()=>{if(n||t||o.checked)return;let e=!1;return W.getClaimStatus().then(t=>{if(e)return;let n=t.success?t.data:void 0;s({checked:!0,claimable:!!n?.claimable,secretRequired:!!n?.secretRequired})}).catch(()=>{e||s({checked:!0,claimable:!1,secretRequired:!1})}),()=>{e=!0}},[n,t,o.checked]),M2(t),(0,B.useEffect)(()=>{let e={isAuthenticated:t,isLoading:n},r=a.current;(r.isAuthenticated!==t||r.isLoading!==n)&&(i.debug(`Auth state changed`,e),a.current=e)},[t,n,i]);let c=()=>{i.info(`Login successful, rechecking auth state`);let e=sessionStorage.getItem(`trokky_oauth_redirect`);if(e){sessionStorage.removeItem(`trokky_oauth_redirect`),i.info(`Redirecting to OAuth flow`,{url:e}),window.location.href=e;return}r()};if(n)return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900`,children:(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(Ao,{size:`lg`}),(0,V.jsx)(`h2`,{className:`mt-4 text-lg font-semibold text-gray-900 dark:text-white`,children:e(`app.loadingStudio`)})]})});if(!t){let e=window.location.pathname,t=window.TROKKY_CONFIG?.basePath||``,n=e.replace(t,``);if(n===`/forgot-password`)return(0,V.jsx)(C2,{});if(n===`/reset-password`)return(0,V.jsx)(w2,{});if(n===`/oauth/callback`)return(0,V.jsx)($0,{onLoginSuccess:c});if(!o.checked)return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center bg-gray-50 dark:bg-gray-900`,children:(0,V.jsx)(Ao,{size:`lg`})});if(o.claimable)return(0,V.jsx)(S2,{secretRequired:o.secretRequired,onLoginSuccess:c,onClaimedWithoutSession:()=>s(e=>({...e,claimable:!1}))});if(n===`/auth/authorize`||n===`/auth/device`){let e=window.location.href;return sessionStorage.setItem(`trokky_oauth_redirect`,e),(0,V.jsx)(b2,{onLoginSuccess:c})}return(0,V.jsx)(b2,{onLoginSuccess:c})}return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(a2,{}),(0,V.jsx)(E2,{}),(0,Ht.createPortal)((0,V.jsxs)(`div`,{"data-dialog-exempt":``,children:[(0,V.jsx)(O2,{}),(0,V.jsx)(A2,{})]}),document.body)]})}function L2(){let[e,t]=(0,B.useState)(null),n=(0,B.useMemo)(()=>P2(),[]);return(0,B.useEffect)(()=>{Fr(`App`).info(`Trokky Studio started`),(async()=>{let e=await c2();t(e),s2(e),e.title&&(document.title=e.title)})();let e=async e=>{let n=e.detail?.settings;if(n){let e={title:n.studioTitle,organizationName:n.organizationName,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,logo:n.logo};t(e),s2(e),e.title&&(document.title=e.title)}};return window.addEventListener(`trokky:settings:updated`,e),()=>{window.removeEventListener(`trokky:settings:updated`,e)}},[]),(0,V.jsx)(br,{config:n,children:(0,V.jsx)(N,{client:F2,children:(0,V.jsx)(ni,{children:(0,V.jsx)(fa,{branding:e,children:(0,V.jsx)(`div`,{className:`App`,children:(0,V.jsx)(I2,{})})})})})})}(()=>{try{let e=localStorage.getItem(`trokky_theme`),t=window.matchMedia(`(prefers-color-scheme: dark)`).matches;e===`dark`||e===`system`&&t||!e&&t?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`)}catch(e){console.warn(`Failed to initialize theme:`,e)}})(),window.matchMedia(`(prefers-color-scheme: dark)`).addEventListener(`change`,e=>{let t=localStorage.getItem(`trokky_theme`);(!t||t===`system`)&&(e.matches?document.documentElement.classList.add(`dark`):document.documentElement.classList.remove(`dark`))}),Ut.createRoot(document.getElementById(`root`)).render((0,V.jsx)(B.StrictMode,{children:(0,V.jsx)(L2,{})}));
742
+ //# sourceMappingURL=index-CMHu7Of4.js.map