@lax-wp/design-system 0.11.48 → 0.11.49

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.
@@ -73,6 +73,12 @@ export type TCheckboxUtilities = {
73
73
  selectionDisabledRowIds?: TId[];
74
74
  checkboxMetadata?: Record<string, unknown>;
75
75
  };
76
+ export type TExpandedRowState = {
77
+ isOpen: boolean;
78
+ /** Nested row data when the row is expanded (tree / cascading tables). */
79
+ data?: unknown[];
80
+ level?: number;
81
+ };
76
82
  export interface ITableProps {
77
83
  tableKey: TTableKey;
78
84
  modelName?: string;
@@ -81,7 +87,7 @@ export interface ITableProps {
81
87
  data: any[];
82
88
  rawData?: Record<string, unknown>;
83
89
  inlineEditColumns?: string[];
84
- expandedRows?: Record<string, boolean>;
90
+ expandedRows?: Record<string, TExpandedRowState>;
85
91
  maxLevel?: number;
86
92
  totalItems?: number;
87
93
  showRecordCount?: boolean;
@@ -177,7 +183,7 @@ export interface ITableProps {
177
183
  cascadingTableConfig?: Record<string, unknown>;
178
184
  originalsOnly?: boolean;
179
185
  getInnerRowData?: (...args: any[]) => unknown;
180
- setExpandedRows?: (rows: Record<string, boolean>) => void;
186
+ setExpandedRows?: (rows: Record<string, TExpandedRowState>) => void;
181
187
  tooltiptext?: string | ReactNode;
182
188
  checkboxUtilities?: TCheckboxUtilities | null;
183
189
  emptyMessage?: string | ReactNode;
package/dist/index.cjs.js CHANGED
@@ -78,7 +78,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
78
78
  monaco.config({ paths: { vs: '...' } })
79
79
 
80
80
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
81
- `},Qx=aR(AR)(SS),uR={config:oR},cR=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(i){return r.reduceRight(function(a,s){return s(a)},i)}};function ES(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],ES(t[r],e[r]))}),qx(qx({},t),e)}var dR={type:"cancelation",msg:"operation is manually canceled"};function $c(t){var e=!1,r=new Promise(function(n,i){t.then(function(a){return e?i(dR):n(a)}),t.catch(i)});return r.cancel=function(){return e=!0},r}var fR=nR.create({config:iR,isInitialized:!1,resolve:null,reject:null,monaco:null}),kS=HD(fR,2),sl=kS[0],$u=kS[1];function pR(t){var e=uR.config(t),r=e.monaco,n=jD(e,["monaco"]);$u(function(i){return{config:ES(i.config,n),monaco:r}})}function hR(){var t=sl(function(e){var r=e.monaco,n=e.isInitialized,i=e.resolve;return{monaco:r,isInitialized:n,resolve:i}});if(!t.isInitialized){if($u({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),$c(Jc);if(window.monaco&&window.monaco.editor)return wS(window.monaco),t.resolve(window.monaco),$c(Jc);cR(mR,bR)(xR)}return $c(Jc)}function mR(t){return document.body.appendChild(t)}function gR(t){var e=document.createElement("script");return t&&(e.src=t),e}function bR(t){var e=sl(function(n){var i=n.config,a=n.reject;return{config:i,reject:a}}),r=gR("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function xR(){var t=sl(function(r){var n=r.config,i=r.resolve,a=r.reject;return{config:n,resolve:i,reject:a}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){wS(r),t.resolve(r)},function(r){t.reject(r)})}function wS(t){sl().monaco||$u({monaco:t})}function _R(){return sl(function(t){var e=t.monaco;return e})}var Jc=new Promise(function(t,e){return $u({resolve:t,reject:e})}),JA={config:pR,init:hR,__getMonacoInstance:_R},yR={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ed=yR,vR={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},SR=vR;function ER({children:t}){return h.createElement("div",{style:SR.container},t)}var kR=ER,wR=kR;function TR({width:t,height:e,isEditorReady:r,loading:n,_ref:i,className:a,wrapperProps:s}){return h.createElement("section",{style:{...ed.wrapper,width:t,height:e},...s},!r&&h.createElement(wR,null,n),h.createElement("div",{ref:i,style:{...ed.fullWidth,...!r&&ed.hide},className:a}))}var OR=TR,TS=h.memo(OR);function CR(t){h.useEffect(t,[])}var OS=CR;function NR(t,e,r=!0){let n=h.useRef(!0);h.useEffect(n.current||!r?()=>{n.current=!1}:t,e)}var Wr=NR;function ao(){}function za(t,e,r,n){return DR(t,n)||RR(t,e,r,n)}function DR(t,e){return t.editor.getModel(CS(t,e))}function RR(t,e,r,n){return t.editor.createModel(e,r,n?CS(t,n):void 0)}function CS(t,e){return t.Uri.parse(e)}function PR({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:s,keepCurrentOriginalModel:o=!1,keepCurrentModifiedModel:A=!1,theme:u="light",loading:c="Loading...",options:d={},height:f="100%",width:p="100%",className:m,wrapperProps:g={},beforeMount:y=ao,onMount:b=ao}){let[_,v]=h.useState(!1),[S,k]=h.useState(!0),E=h.useRef(null),w=h.useRef(null),T=h.useRef(null),O=h.useRef(b),C=h.useRef(y),N=h.useRef(!1);OS(()=>{let D=JA.init();return D.then(H=>(w.current=H)&&k(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>E.current?R():D.cancel()}),Wr(()=>{if(E.current&&w.current){let D=E.current.getOriginalEditor(),H=za(w.current,t||"",n||r||"text",a||"");H!==D.getModel()&&D.setModel(H)}},[a],_),Wr(()=>{if(E.current&&w.current){let D=E.current.getModifiedEditor(),H=za(w.current,e||"",i||r||"text",s||"");H!==D.getModel()&&D.setModel(H)}},[s],_),Wr(()=>{let D=E.current.getModifiedEditor();D.getOption(w.current.editor.EditorOption.readOnly)?D.setValue(e||""):e!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[e],_),Wr(()=>{E.current?.getModel()?.original.setValue(t||"")},[t],_),Wr(()=>{let{original:D,modified:H}=E.current.getModel();w.current.editor.setModelLanguage(D,n||r||"text"),w.current.editor.setModelLanguage(H,i||r||"text")},[r,n,i],_),Wr(()=>{w.current?.editor.setTheme(u)},[u],_),Wr(()=>{E.current?.updateOptions(d)},[d],_);let P=h.useCallback(()=>{if(!w.current)return;C.current(w.current);let D=za(w.current,t||"",n||r||"text",a||""),H=za(w.current,e||"",i||r||"text",s||"");E.current?.setModel({original:D,modified:H})},[r,e,i,t,n,a,s]),L=h.useCallback(()=>{!N.current&&T.current&&(E.current=w.current.editor.createDiffEditor(T.current,{automaticLayout:!0,...d}),P(),w.current?.editor.setTheme(u),v(!0),N.current=!0)},[d,u,P]);h.useEffect(()=>{_&&O.current(E.current,w.current)},[_]),h.useEffect(()=>{!S&&!_&&L()},[S,_,L]);function R(){let D=E.current?.getModel();o||D?.original?.dispose(),A||D?.modified?.dispose(),E.current?.dispose()}return h.createElement(TS,{width:p,height:f,isEditorReady:_,loading:c,_ref:T,className:m,wrapperProps:g})}var LR=PR;h.memo(LR);function IR(t){let e=h.useRef();return h.useEffect(()=>{e.current=t},[t]),e.current}var MR=IR,ql=new Map;function jR({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:i,path:a,theme:s="light",line:o,loading:A="Loading...",options:u={},overrideServices:c={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p="100%",height:m="100%",className:g,wrapperProps:y={},beforeMount:b=ao,onMount:_=ao,onChange:v,onValidate:S=ao}){let[k,E]=h.useState(!1),[w,T]=h.useState(!0),O=h.useRef(null),C=h.useRef(null),N=h.useRef(null),P=h.useRef(_),L=h.useRef(b),R=h.useRef(),D=h.useRef(n),H=MR(a),I=h.useRef(!1),M=h.useRef(!1);OS(()=>{let X=JA.init();return X.then(ee=>(O.current=ee)&&T(!1)).catch(ee=>ee?.type!=="cancelation"&&console.error("Monaco initialization: error:",ee)),()=>C.current?V():X.cancel()}),Wr(()=>{let X=za(O.current,t||n||"",e||i||"",a||r||"");X!==C.current?.getModel()&&(d&&ql.set(H,C.current?.saveViewState()),C.current?.setModel(X),d&&C.current?.restoreViewState(ql.get(a)))},[a],k),Wr(()=>{C.current?.updateOptions(u)},[u],k),Wr(()=>{!C.current||n===void 0||(C.current.getOption(O.current.editor.EditorOption.readOnly)?C.current.setValue(n):n!==C.current.getValue()&&(M.current=!0,C.current.executeEdits("",[{range:C.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),C.current.pushUndoStop(),M.current=!1))},[n],k),Wr(()=>{let X=C.current?.getModel();X&&i&&O.current?.editor.setModelLanguage(X,i)},[i],k),Wr(()=>{o!==void 0&&C.current?.revealLine(o)},[o],k),Wr(()=>{O.current?.editor.setTheme(s)},[s],k);let z=h.useCallback(()=>{if(!(!N.current||!O.current)&&!I.current){L.current(O.current);let X=a||r,ee=za(O.current,n||t||"",e||i||"",X||"");C.current=O.current?.editor.create(N.current,{model:ee,automaticLayout:!0,...u},c),d&&C.current.restoreViewState(ql.get(X)),O.current.editor.setTheme(s),o!==void 0&&C.current.revealLine(o),E(!0),I.current=!0}},[t,e,r,n,i,a,u,c,d,s,o]);h.useEffect(()=>{k&&P.current(C.current,O.current)},[k]),h.useEffect(()=>{!w&&!k&&z()},[w,k,z]),D.current=n,h.useEffect(()=>{k&&v&&(R.current?.dispose(),R.current=C.current?.onDidChangeModelContent(X=>{M.current||v(C.current.getValue(),X)}))},[k,v]),h.useEffect(()=>{if(k){let X=O.current.editor.onDidChangeMarkers(ee=>{let W=C.current.getModel()?.uri;if(W&&ee.find(B=>B.path===W.path)){let B=O.current.editor.getModelMarkers({resource:W});S?.(B)}});return()=>{X?.dispose()}}return()=>{}},[k,S]);function V(){R.current?.dispose(),f?d&&ql.set(a,C.current.saveViewState()):C.current.getModel()?.dispose(),C.current.dispose()}return h.createElement(TS,{width:p,height:m,isEditorReady:k,loading:A,_ref:N,className:g,wrapperProps:y})}var HR=jR,FR=h.memo(HR),UR=FR;class Ba{static instance;monaco=null;initialized=!1;initializationPromise=null;static getInstance(){return Ba.instance||(Ba.instance=new Ba),Ba.instance}configure(e){this.initialized&&console.warn("monacoManager.configure() called after initialization — config may not take effect"),JA.config(e)}async initialize(){return this.initialized&&this.monaco?this.monaco:this.initializationPromise?this.initializationPromise:(this.initializationPromise=this.performInitialization(),this.initializationPromise)}async performInitialization(){try{return this.monaco=await JA.init(),this.initialized=!0,this.initializationPromise=null,this.monaco}catch(e){throw this.initializationPromise=null,console.error("Failed to initialize Monaco Editor:",e),new Error(`Monaco Editor initialization failed: ${e instanceof Error?e.message:"Unknown error"}`)}}getMonaco(){return this.monaco}isInitialized(){return this.initialized}getEditorInstance(e=0){if(!this.monaco)return console.warn("Monaco Editor not initialized"),null;const r=this.monaco.editor.getEditors();return r.length<=e?(console.warn(`No editor found at index ${e}. Available editors: ${r.length}`),null):r[e]}getFirstEditorInstance(){return this.getEditorInstance(0)}static safeDispose(e){e.forEach(r=>{try{r&&typeof r.dispose=="function"&&r.dispose()}catch(n){console.warn("Error disposing Monaco resource:",n)}})}}const Q1=Ba.getInstance(),NS=()=>{const[t,e]=h.useState(Q1.getMonaco());return h.useEffect(()=>{if(t)return;let r=!1;return Q1.initialize().then(n=>{r||e(n)}),()=>{r=!0}},[t]),t},Ht={createSuccess:function(t){return`${t} created successfully.`},createFailure:function(t){return`${t} creation failed. Please retry.`},updateSuccess:function(t){return`${t} updated successfully.`},updateFailure:function(t){return`${t} update failed. Please retry.`},copySuccess:function(t){return`${t} copied successfully.`},copyFailure:function(t){return`${t} copy failed. Please retry.`},copyToClipboard:function(t){return`${t} copied to clipboard.`},moveSuccess:function(t){return`${t} moved successfully.`},moveFailure:function(t){return`${t} move failed. Please retry.`},restoreSuccess:function(t){return`${t} restored successfully.`},resetSuccess:function(t){return`${t} reset successfully.`},resetFailure:function(t){return`${t} reset failed. Please retry.`},restoreFailure:function(t){return`${t} restore failed. Please retry.`},deleteSuccess:function(t){return`${t} deleted successfully.`},deleteFailure:function(t){return`${t} delete failed. Please retry.`},addSuccess:function(t){return`${t} added successfully.`},addFailure:function(t){return`${t} add failed. Please retry.`},removeSuccess:function(t){return`${t} removed successfully.`},removeFailure:function(t){return`${t} remove failed. Please retry.`},importSuccess:function(t){return`${t} imported successfully.`},importFailure:function(t){return`${t} import failed. Please retry.`},exportSuccess:function(t){return`${t} exported successfully.`},exportFailure:function(t){return`${t} export failed. Please retry.`},installSuccess:function(t){return`${t} installed successfully.`},duplicateSuccess:function(t){return`${t} duplicated successfully.`},installFailure:function(t){return`${t} install failed. Please retry.`},uninstallSuccess:function(t){return`${t} uninstalled successfully.`},uninstallFailure:function(t){return`${t} uninstall failed. Please retry.`},approveSuccess:function(t){return`${t} approved successfully.`},approveFailure:function(t){return`${t} approve failed. Please retry.`},rejectSuccess:function(t){return`${t} rejected successfully.`},rejectFailure:function(t){return`${t} reject failed. Please retry.`},archiveSuccess:function(t){return`${t} archived successfully.`},archiveFailure:function(t){return`${t} archive failed. Please retry.`},activateSuccess:function(t){return`${t} activated successfully.`},activateFailure:function(t){return`${t} activation failed. Please retry.`},deactivateSuccess:function(t){return`${t} deactivated successfully.`},deactivateFailure:function(t){return`${t} deactivation failed. Please retry.`},fetchFailure:function(t){return`An error occurred while fetching ${t}. Please retry.`},requiredField:function(t){return`${t} is required.`},existsError:function(t){return`${t} already exists.`},shouldNotContainOnlySpaces:function(t){return`${t} shouldn't contain only spaces.`},notAllowed:function(t){return`${t} not allowed.`},allowed:function(t){return`${t} allowed.`},multipleNotAllowed:function(t){return`Multiple ${t} not allowed.`},notFound:function(t){return`${t} not found.`},sendForApproval:function(t){return`${t} sent for approval.`},invalidError:function(t){return`Invalid ${t}.`},success:function(t){return`${t} successful.`},initializationError:function(t){return`Please initialize the ${t}.`},selectError:function(t){return`Please select ${t}.`},importStarted:function(t){return`${t} import has started.`},initiationSuccess:function(t){return`${t} initiated successfully.`},initiationFailure:function(t){return`${t} initiation failed. Please retry.`},transferSuccess:function(t){return`${t} has been successfully transferred.`},transferFailure:function(t){return`${t} transfer has failed, Please retry.`},terminatedSuccess:function(t){return`${t} terminated successfully.`},terminatedFailure:function(t){return`${t} termination failed, Please retry.`},markedAs:function(t){return`Marked as ${t}.`},bulkStatusChangeSuccess:function(t){return`Status changed to ${t?"locked":"unlocked"} successfully.`},bulkStatusChangeFailure:function(t){return`Status change to ${t?"locked":"unlocked"} failed, Please retry.`},downloading:function(t){return`Downloading ${t}...`},downloadFailure:function(t){return`Download ${t} failed. Please retry.`},bulkStatusChangeInfo:"Status change default info",bulkStatusChangeDefault:"Unknown response type",bulkDeleteUsersSuccess:"Users deleted successfully.",bulkDeleteUsersFailure:"Bulk user delete failed, Please retry.",errorMessage:"Something went wrong.",requiredFieldError:"Please fill out all mandatory fields.",resetPasswordSuccess:"Password reset successfully.",noItemSelected:"No item selected.",fieldAlreadyExist:"Field has already been added to this step.",fetchingError:"An error occurred while fetching configuration details.",secondaryOwnerLimitExceed:"Can't add more than 3 users to 'Secondary Owner'.",saveChangesAlert:"Please save the changes before switching tabs.",visibleColumnError:"There must be at least one visible column.",sessionExpired:"Session expired. Please login.",invalidFileType:"Non acceptable file type.",triggerNodeError:"Trigger is required!",formatFailed:"Failed to format.",memberRemoveSuccess:"Team member removed successfully.",memberRemoveInfo:"Team member removed default info.",memberRemoveError:"Unable to remove team member.",memberRemoveWarning:"Unable to remove team member.",memberRemoveDefault:"Unknown response type."},DS=({monacoEditor:t,currentEditorModel:e,code:r,setCode:n,enable:i,checkSyntaxAPI:a,formatCodeAPI:s})=>{const[o,A]=h.useState(null),[u,c]=h.useState(!1);function d(g){const y={};let b=0;return{result:g.replace(/{{(.*?)}}/g,(v,S,k,E)=>{const w=E.slice(0,k),T=E.slice(k+v.length),O=w.endsWith('"')&&T.startsWith('"'),C=w.endsWith("'")&&T.startsWith("'");return O||C?v:(y[`__dynamic_value_${b}`]=v,`"__dynamic_value_${b++}"`)}),originalValues:y}}function f(g,y){return g.replace(/"__dynamic_value_\d+"/g,b=>{const _=b.slice(1,-1);return y[_]||b})}const p=async()=>{if(!t||!e||!a){console.warn("Monaco editor, model, or syntax check API not available");return}c(!0);try{const{result:g}=d(r),b=(await a(g))?.data?.error;if(b?.message){A(b);const _=[{startLineNumber:b.line||1,endLineNumber:b.line||1,startColumn:b.column||1,endColumn:b.column||1,message:b.message,severity:t.MarkerSeverity?.Error||8}];try{t.editor.setModelMarkers(e,"owner",_)}catch(v){console.warn("Failed to set error markers:",v)}}else{A(null);try{t.editor.setModelMarkers(e,"owner",[])}catch(_){console.warn("Failed to clear error markers:",_)}}}catch(g){if(console.warn("Syntax check failed:",g),A(null),t&&e)try{t.editor.setModelMarkers(e,"owner",[])}catch(y){console.warn("Failed to clear error markers after error:",y)}}finally{c(!1)}},m=async()=>{if(!t||!e||!s){console.warn("Monaco editor, model, or format API not available");return}c(!0);try{const{result:g,originalValues:y}=d(r),b=await s(g);if(b?.data?.formatted_code){const _=f(b.data.formatted_code,y);n(_)}else console.warn("No formatted code received from service")}catch(g){const y=g?.message||Ht.formatFailed;console.warn("Code formatting failed:",y),Dt.toast.error(y,{toastId:y})}finally{c(!1)}};return h.useEffect(()=>{if(t&&i&&a){const g=xb.debounce(p,500);return g(),()=>{g.cancel()}}},[r,t]),{pythonError:o,pythonLoading:u,handleCheckSyntax:p,handleFormatCode:m}},RS=["US","GB","IN","DE","FR","CN","JP","BR","CA","AU","IT","ES","RU","KR","ZA","MX","TR","ID","SA","AR","NL","CH","SE","BE","PL","EG","SG","TH","UA","PK","BD","PH","VN","MY","CO","CL","NO","DK","FI","IE","AT","GR","PT","HU","CZ","RO","NZ","AE","GH","EU","MA","NG","TW","HK","KE","IR","PE","QA","KW","LK","NP"];function Tb(t){return{US:"United States",GB:"United Kingdom",IN:"India",DE:"Germany",FR:"France",CN:"China",JP:"Japan",BR:"Brazil",CA:"Canada",AU:"Australia",IT:"Italy",ES:"Spain",RU:"Russia",KR:"South Korea",ZA:"South Africa",MX:"Mexico",TR:"Turkey",ID:"Indonesia",SA:"Saudi Arabia",AR:"Argentina",NL:"Netherlands",CH:"Switzerland",SE:"Sweden",BE:"Belgium",PL:"Poland",EG:"Egypt",SG:"Singapore",TH:"Thailand",UA:"Ukraine",PK:"Pakistan",BD:"Bangladesh",PH:"Philippines",VN:"Vietnam",MY:"Malaysia",CO:"Colombia",CL:"Chile",NO:"Norway",DK:"Denmark",FI:"Finland",IE:"Ireland",AT:"Austria",GR:"Greece",PT:"Portugal",HU:"Hungary",CZ:"Czech Republic",RO:"Romania",NZ:"New Zealand",AE:"United Arab Emirates",GH:"Ghana",EU:"European Union",MA:"Morocco",NG:"Nigeria",TW:"Taiwan",HK:"Hong Kong",KE:"Kenya",IR:"Iran",PE:"Peru",QA:"Qatar",KW:"Kuwait",LK:"Sri Lanka",NP:"Nepal"}[t]||t}const PS=h.createContext(null),LS=PS.Provider,bs=()=>{const t=h.useContext(PS);if(!t)throw new Error("useJsonGridViewerContext must be used within a JsonGridViewerContextProvider");return t},Ie={STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",OBJECT:"object",ARRAY:"array"},IS={[Ie.ARRAY]:"text-purple-600 bg-purple-100",[Ie.OBJECT]:"text-warning-600 bg-warning-100",[Ie.STRING]:"text-success-600 bg-success-100",[Ie.NUMBER]:"text-blue-600 bg-blue-100",[Ie.BOOLEAN]:"text-purple-600 bg-purple-100",[Ie.NULL]:"text-neutral-600 bg-neutral-100"},OA=[{label:"String",value:Ie.STRING},{label:"Number",value:Ie.NUMBER},{label:"Boolean",value:Ie.BOOLEAN},{label:"Null",value:Ie.NULL},{label:"Object",value:Ie.OBJECT},{label:"Array",value:Ie.ARRAY}],Ob=t=>t===null?Ie.NULL:Array.isArray(t)?Ie.ARRAY:typeof t=="object"?Ie.OBJECT:typeof t,MS=t=>{const e=[...t].sort((n,i)=>n.length-i.length),r=[];for(const n of e)r.some(a=>n!==a&&n.startsWith(a+"."))||r.push(n);return r},jS=t=>!t||t.trim()===""?{}:JSON.parse(t),HS=(t,e)=>{const r=h.useCallback((a,s)=>{const o=[],A=(u,c)=>{Array.isArray(u)?u.forEach((d,f)=>{const p=`${c}.${f}`;o.push(p),typeof d=="object"&&d!==null&&A(d,p)}):u&&typeof u=="object"&&Object.entries(u).forEach(([d,f])=>{const p=`${c}.${d}`;o.push(p),typeof f=="object"&&f!==null&&A(f,p)})};return A(s,a),o},[]),n=h.useCallback((a,s,o,A)=>{if(s){const u=[a];if(A){const c=r(a,o);u.push(...c)}e(Array.from(new Set([...t,...u])))}else{const u=[a];if(A){const c=r(a,o);u.push(...c)}e(t?.filter(c=>!u.includes(c))||[])}},[t,e,r]),i=h.useCallback(a=>t?.includes(a)||!1,[t]);return{handleCheckboxChange:n,isPathSelected:i,getAllChildPaths:r}},FS=({value:t,path:e,onChange:r,isDarkMode:n=!1})=>{const[i,a]=h.useState(""),s=Ob(t),{selectedPathForEdit:o,setSelectedPathForEdit:A}=bs();h.useEffect(()=>{s===Ie.STRING?a(t):s===Ie.NUMBER||s===Ie.BOOLEAN?a(String(t)):s===Ie.NULL&&a("null")},[t,s]);const u=d=>{a(d.target.value)},c=()=>{try{let d;if(s===Ie.NUMBER){if(d=Number(i),i.trim()==="")throw new Error("Empty number");if(d=Number(i),Number.isNaN(d))throw new Error("Invalid number")}else if(s===Ie.BOOLEAN)if(i.toLowerCase()==="true")d=!0;else if(i.toLowerCase()==="false")d=!1;else throw new Error("Invalid boolean value");else if(s===Ie.NULL)if(i.toLowerCase()==="null")d=null;else throw new Error("Invalid null value");else d=i;r(e,d),A(null)}catch{s===Ie.STRING?a(t):s===Ie.NUMBER||s===Ie.BOOLEAN?a(String(t)):s===Ie.NULL&&a("null")}};return s===Ie.BOOLEAN?l.jsx(Zn,{isChecked:t,onChange:d=>r(e,d)}):s===Ie.NULL?l.jsx("span",{className:n?"text-neutral-400 italic":"text-neutral-500 italic",children:"null"}):o===e&&s===Ie.NUMBER?l.jsx(Hi,{value:i,onChange:d=>{const p=d.replace(/\.(?=.*\.)/g,"").replace(/[^\d.-]/g,"");a(p)},className:"w-full",onBlur:c}):o===e&&s===Ie.STRING?l.jsx("div",{className:"w-full min-w-36",children:l.jsx("textarea",{value:i,onChange:u,onBlur:c,className:`w-full min-w-36 rounded-lg px-2 py-1 text-sm focus:outline-none focus:border-blue-500 border resize-none hover:resize-y ${n?"bg-black-800 text-white":"bg-white text-black"}`,rows:1})}):l.jsx("span",{className:F(n?"text-neutral-400":"text-neutral-900","text-sm font-medium"),children:t})},zR=({isExpanded:t})=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:F(t?"rotate-90":"rotate-0","transition-transform duration-200"),children:l.jsx("path",{d:"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"})}),BR=()=>l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),qR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-neutral-500 dark:text-neutral-400",children:l.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})}),Cb=({data:t,path:e,onChange:r})=>{const n=Array.isArray(t),[i,a]=h.useState([]),{allExpanded:s,isDarkMode:o,selectedPaths:A,setSelectedPaths:u,setSelectedPathModification:c,isEditMode:d,handleCopy:f}=bs(),{handleCheckboxChange:p,isPathSelected:m}=HS(A,u),g=()=>{const S=[],k=(E,w)=>{Array.isArray(E)?E.forEach((T,O)=>{const C=`${w}.${O}`;typeof T=="object"&&T!==null&&(S.push(C),k(T,C))}):E&&typeof E=="object"&&Object.entries(E).forEach(([T,O])=>{const C=`${w}.${T}`;typeof O=="object"&&O!==null&&(S.push(C),k(O,C))})};return k(t,e),S};h.useEffect(()=>{t&&a(s?g():[])},[s,t,e]);const y=S=>{a(k=>k.includes(S)?k.filter(E=>E!==S):[...k,S])},b=(S,k)=>{r(S,k)},_=e==="",v=(S,k,E,w,T)=>{const O=Ob(k),C=O===Ie.OBJECT||O===Ie.ARRAY,N=`${E}.${S}`,P=i.includes(N);return l.jsxs("tr",{className:F("border-neutral-300 dark:border-neutral-700",_?"border-b":T?"border-b-0":"border-b"),children:[l.jsx("td",{className:F("px-3 py-4 align-top border-r text-sm font-medium w-1/4",o?"text-neutral-200 bg-black-700":"bg-neutral-100 text-[#101828]",w&&!_&&"rounded-tl-xl",T&&!_&&"rounded-bl-xl"),children:l.jsxs("div",{className:"flex items-center",children:[d&&l.jsx(oS,{id:`checkbox-${N}`,label:"",isChecked:m(N),onChange:L=>p(N,L.target.checked,k,C)}),l.jsx("span",{className:"text-neutral-500 dark:text-neutral-400 whitespace-nowrap",children:S})]})}),l.jsx("td",{className:"!w-[120px] py-4 px-3 align-top bg-white dark:bg-black-800",children:l.jsx("div",{className:"flex items-start justify-center h-full",children:l.jsx("span",{className:`${IS[O]} px-2 py-1 rounded-xl text-xs`,children:O?.toUpperCase()})})}),l.jsx("td",{className:F("border-l border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black-800",!d&&w&&!_&&"rounded-tr-xl",!d&&T&&!_&&"rounded-br-xl","!min-w-36"),children:l.jsx("div",{className:"py-2 px-3 flex items-center justify-start h-full",children:C?l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{type:"button",onClick:()=>y(N),className:`mr-1 p-0.5 flex items-center justify-center rounded ${o?"hover:bg-black-700 text-neutral-200":"hover:bg-neutral-300 text-neutral-600"}`,children:l.jsx(zR,{isExpanded:P})}),l.jsx("span",{className:F(o?"text-neutral-400":"text-neutral-900","text-sm font-medium"),children:P?O===Ie.ARRAY?`[${k.length} items]`:`{${Object.keys(k).length} items}`:O===Ie.ARRAY?`[${k.length} items]`:"{...}"}),!d&&l.jsx("button",{type:"button",className:"ml-2",onClick:()=>f([N]),children:l.jsx(BR,{})})]}),P&&(Array.isArray(k)&&k?.length>0||Object.keys(k).length>0)&&l.jsx("div",{className:"ml-1.5 mt-3",children:l.jsx(Cb,{data:k,path:N,onChange:b})})]}):l.jsx(FS,{value:k,path:N,onChange:b,isDarkMode:o})})}),d&&l.jsx("td",{className:F("w-6 py-3.5 align-top bg-white dark:bg-black-800",w&&!_&&"rounded-tr-xl",T&&!_&&"rounded-br-xl"),children:l.jsx("button",{type:"button",onClick:()=>c(N),className:"p-1 rounded hover:bg-neutral-100 dark:hover:bg-black-700",children:l.jsx(qR,{})})})]},N)};return t?l.jsx("div",{className:_?"border-none":"border border-neutral-300 dark:border-neutral-700 rounded-xl",children:l.jsx("table",{className:F("w-full"),children:l.jsx("tbody",{children:n?t.map((S,k)=>v(k,S,e,k===0,k===t.length-1)):Object.entries(t).map(([S,k],E)=>v(S,k,e,E===0,E===Object.keys(t).length-1))})})}):null},US=({onChange:t,style:e})=>{const{isDarkMode:r,error:n,jsonData:i,setJsonData:a}=bs();if(!i)return null;const s=(o,A)=>{if(!o||o===".")return;const u=o.split(".");u.shift();const c=structuredClone(i);let d=c;for(let p=0;p<u.length-1;p++){const m=u[p];if(Array.isArray(d)){const g=parseInt(m,10);d=d[g]}else d=d[m]}const f=u[u.length-1];if(Array.isArray(d)){const p=parseInt(f,10);d[p]=A}else d[f]=A;a(c),t?.(JSON.stringify(c,null,2))};return n?l.jsx("div",{className:r?"p-4 bg-red-900 text-red-300 border border-red-800 rounded":"p-4 bg-red-50 text-red-600 border border-red-300 rounded",children:n}):l.jsx("div",{className:F(r?"shadow-sm overflow-auto":"bg-white dark:bg-black-800 shadow-sm overflow-auto"),style:e,id:"json-grid-core-container",children:l.jsx("div",{className:"p-0 overflow-auto",children:l.jsx(Cb,{data:i,path:"",onChange:s})})})},zS=({visible:t,onClose:e,content:r,title:n,onConfirm:i,isLoading:a,variant:s,cancelText:o="Cancel",confirmText:A})=>{const u=h.useMemo(()=>l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx(bt,{id:"btn-confirmation-modal-cancel",onClick:e,disabled:a,status:"secondary-neutral",children:o}),l.jsx(bt,{id:`btn-confirmation-modal-${s==="destructive"?"Delete":"Confirm"}`,onClick:i,isLoading:a,status:s==="destructive"?"error":"primary",autoFocus:!0,type:"submit",children:A||(s==="destructive"?"Delete":"Confirm")})]}),[e,i,a,s,o,A]);return t?l.jsx(pn,{title:n,open:t,footer:u,onCancel:e,zIndex:9999,children:l.jsx("div",{className:"my-5",children:l.jsx("div",{className:"text-neutral-400 font-inter text-base",children:r})})}):null},VR=({size:t=24,fill:e="currentColor",className:r})=>l.jsx("svg",{className:r,width:t,height:t,viewBox:"0 0 20 20",fill:e,xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M10.0002 11.1666L5.91683 15.2499C5.76405 15.4027 5.56961 15.4791 5.3335 15.4791C5.09739 15.4791 4.90294 15.4027 4.75016 15.2499C4.59738 15.0971 4.521 14.9027 4.521 14.6666C4.521 14.4305 4.59738 14.236 4.75016 14.0833L8.8335 9.99992L4.75016 5.91659C4.59738 5.76381 4.521 5.56936 4.521 5.33325C4.521 5.09714 4.59738 4.9027 4.75016 4.74992C4.90294 4.59714 5.09739 4.52075 5.3335 4.52075C5.56961 4.52075 5.76405 4.59714 5.91683 4.74992L10.0002 8.83325L14.0835 4.74992C14.2363 4.59714 14.4307 4.52075 14.6668 4.52075C14.9029 4.52075 15.0974 4.59714 15.2502 4.74992C15.4029 4.9027 15.4793 5.09714 15.4793 5.33325C15.4793 5.56936 15.4029 5.76381 15.2502 5.91659L11.1668 9.99992L15.2502 14.0833C15.4029 14.236 15.4793 14.4305 15.4793 14.6666C15.4793 14.9027 15.4029 15.0971 15.2502 15.2499C15.0974 15.4027 14.9029 15.4791 14.6668 15.4791C14.4307 15.4791 14.2363 15.4027 14.0835 15.2499L10.0002 11.1666Z"})}),WR=({fill:t="#cccccc",className:e})=>l.jsx("svg",{height:"20",width:"20",viewBox:"0 0 20 20",focusable:"false",className:e,children:l.jsx("path",{fill:t,d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"})}),XR=({size:t=24,fill:e="currentColor",className:r,onClick:n})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:e,xmlns:"http://www.w3.org/2000/svg",className:r,onClick:n,children:l.jsx("g",{mask:"url(#mask0_6454_18843)",children:l.jsx("path",{d:"M5.8335 17.5C5.37516 17.5 4.9828 17.3368 4.65641 17.0104C4.33002 16.684 4.16683 16.2917 4.16683 15.8333V5C3.93072 5 3.7328 4.92014 3.57308 4.76042C3.41336 4.60069 3.3335 4.40278 3.3335 4.16667C3.3335 3.93056 3.41336 3.73264 3.57308 3.57292C3.7328 3.41319 3.93072 3.33333 4.16683 3.33333H7.50016C7.50016 3.09722 7.58002 2.89931 7.73975 2.73958C7.89947 2.57986 8.09738 2.5 8.3335 2.5H11.6668C11.9029 2.5 12.1009 2.57986 12.2606 2.73958C12.4203 2.89931 12.5002 3.09722 12.5002 3.33333H15.8335C16.0696 3.33333 16.2675 3.41319 16.4272 3.57292C16.587 3.73264 16.6668 3.93056 16.6668 4.16667C16.6668 4.40278 16.587 4.60069 16.4272 4.76042C16.2675 4.92014 16.0696 5 15.8335 5V15.8333C15.8335 16.2917 15.6703 16.684 15.3439 17.0104C15.0175 17.3368 14.6252 17.5 14.1668 17.5H5.8335ZM5.8335 5V15.8333H14.1668V5H5.8335ZM7.50016 13.3333C7.50016 13.5694 7.58002 13.7674 7.73975 13.9271C7.89947 14.0868 8.09738 14.1667 8.3335 14.1667C8.56961 14.1667 8.76752 14.0868 8.92725 13.9271C9.08697 13.7674 9.16683 13.5694 9.16683 13.3333V7.5C9.16683 7.26389 9.08697 7.06597 8.92725 6.90625C8.76752 6.74653 8.56961 6.66667 8.3335 6.66667C8.09738 6.66667 7.89947 6.74653 7.73975 6.90625C7.58002 7.06597 7.50016 7.26389 7.50016 7.5V13.3333ZM10.8335 13.3333C10.8335 13.5694 10.9134 13.7674 11.0731 13.9271C11.2328 14.0868 11.4307 14.1667 11.6668 14.1667C11.9029 14.1667 12.1009 14.0868 12.2606 13.9271C12.4203 13.7674 12.5002 13.5694 12.5002 13.3333V7.5C12.5002 7.26389 12.4203 7.06597 12.2606 6.90625C12.1009 6.74653 11.9029 6.66667 11.6668 6.66667C11.4307 6.66667 11.2328 6.74653 11.0731 6.90625C10.9134 7.06597 10.8335 7.26389 10.8335 7.5V13.3333Z"})})}),Ju=t=>{const{show:e,isFlowDashboard:r,onClose:n,actionItems:i,selectedItemsCount:a,deleteConfig:s,showActionBg:o}=t,{t:A}=Xt.useTranslation(),[u,c]=h.useState(!1),[d,f]=h.useState(!0),p=h.useRef(null),m=h.useRef(null);h.useEffect(()=>{const b=new ResizeObserver(()=>{if(p.current&&m.current){const _=p.current.scrollWidth-100;i.length*180+100>_?f(!1):f(!0)}});return p.current&&b.observe(p.current),()=>{p.current&&b.unobserve(p.current)}});const g={label:A("Delete"),icon:l.jsx(XR,{size:16,className:"text-error-500"}),onClick:s?.onClick,...s},y=i.filter(b=>b.visible!==!1).map((b,_)=>({key:_,label:l.jsx(Er,{icon:b.dropdownIcon,text:b?.label||"",onClick:b.onClick,className:"font-inter text-[14px] font-medium text-black-900 dark:text-black-200 gap-1.5"}),children:b.dropdownItems,disabled:!1}));return e?l.jsx(Ve.motion.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1],opacity:{duration:.15}},ref:p,className:F("h-[40px]",r?"ml-60 w-1/2":"w-full"),children:l.jsxs("div",{className:F("h-[40px] border py-1.5 px-2 text-white bg-primary-800 dark:bg-black-700 flex justify-between items-center"),children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(or,{tooltip:"Close",variant:"ghost",onClick:n,className:"hover:bg-primary-100 !p-0",children:l.jsx(VR,{size:20})}),l.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[l.jsx("span",{className:"text-primary-600 dark:text-black-100 bg-primary-50 dark:bg-black-800 border-primary-200 dark:border-black-800 text-xs leading-4 font-normal border rounded-full pr-2 pl-2",children:a||0}),l.jsx(ne,{size:"extra-small",appearance:"custom",className:"text-white",children:A("Selected")})]})]}),l.jsx("div",{ref:m,className:F("h-[36px] flex items-center rounded-full font-inter",o?"bg-primary-900 dark:bg-black-800 px-[10px] rounded-[43px]":""),children:d?l.jsxs(Ve.motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"flex bg-primary-800 dark:bg-black-800 px-4 rounded-full",children:[i.map((b,_)=>b.visible!==!1&&l.jsx("div",{children:b.type==="dropdown"?l.jsx(Ze.Dropdown,{menu:{items:b.dropdownItems},trigger:[b.dropdownTrigger||"click"],overlayClassName:"!min-w-[148px]",placement:"bottomRight",getPopupContainer:v=>v.parentElement,open:u,onOpenChange:c,children:l.jsxs("button",{id:`btn-floating-bar-${b.label}`,onClick:b.onClick,disabled:b.disabled,className:F(b?.label?"flex items-center mx-1 gap-1.5 py-1 pr-3 pl-2 rounded-md text-white hover:text-primary-50 transition-all duration-300 bg-transparent":"bg-transparent p-1.5 hover:bg-primary-800 rounded-xl",b?.hideLabel&&"!p-1.5",(b.label==="Delete"||b.label==="Remove")&&"!text-error-500"),children:[l.jsx(Te,{hideTooltip:!b.tooltip,title:b.tooltip,className:"flex items-center",children:b.icon}),!b?.hideLabel&&b.label&&l.jsx(ne,{size:"small",variant:"medium",className:"text-inherit",appearance:"custom",children:b.label})]},_)}):l.jsxs("button",{id:`btn-floating-bar-${b.label}`,onClick:b.onClick,disabled:b.disabled,className:F(b?.label?"flex items-center mx-1 gap-1.5 py-1 pr-3 pl-2 rounded-md text-white hover:text-primary-50 transition-all duration-300 bg-transparent":"bg-transparent p-1.5 hover:bg-primary-800 rounded-xl",b?.hideLabel&&"!p-1.5",(b.label==="Delete"||b.label==="Remove")&&"!text-error-500"),children:[l.jsx(Te,{hideTooltip:!b.tooltip,title:b.tooltip,className:"flex items-center",children:b.icon}),!b?.hideLabel&&b.label&&l.jsx(ne,{size:"small",variant:"medium",className:"text-inherit",appearance:"custom",children:b.label})]})},_)),s?l.jsxs("button",{id:`btn-floating-bar-${g.label}`,onClick:g.onClick,disabled:!1,className:"flex items-center gap-1.5 py-1 pr-3 pl-2 rounded-md",children:[g.icon,l.jsx(ne,{size:"small",variant:"medium",className:"text-error-500",appearance:"custom",children:g.label})]}):null]}):l.jsxs(Ve.motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"minw-[150px] p-1.5 flex items-center",children:[l.jsx(Ze.Dropdown,{menu:{items:y},trigger:["click"],overlayClassName:"!min-w-[148px]",placement:"bottomRight",getPopupContainer:b=>b.parentElement,open:u,onOpenChange:c,children:l.jsxs("button",{id:"btn-floating-bar-actions",disabled:!1,className:"flex items-center gap-1.5 px-2 py-1 w-22 h-7 rounded-full bg-primary-700",type:"button",children:[l.jsx(ne,{size:"small",variant:"medium",className:"text-white",children:A("Actions")}),l.jsx(WR,{fill:"#FFFFFF",className:"w-[16px] h-[16px]"})]})}),s?l.jsxs("button",{id:`btn-floating-bar-${g.label}`,onClick:g.onClick,disabled:!1,className:"flex items-center gap-1.5 py-1 pr-3 pl-2 rounded-md",type:"button",children:[g.icon,l.jsx(ne,{size:"small",variant:"medium",className:"text-error-500",appearance:"custom",children:g.label})]}):null]})})]})}):null};Ju.displayName="FloatingBar";const QR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-white",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),GR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-white",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"})}),YR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-[#F04438]",children:l.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})}),BS=()=>{const{selectedTopLevelPaths:t,setSelectedPaths:e,handleDelete:r,handleDuplicate:n,handleCopy:i}=bs(),[a,s]=h.useState(!1),o=[{id:"copy",icon:l.jsx(QR,{}),tooltip:"Copy",label:"Copy",hideLabel:!0,onClick:()=>i(t)},{id:"duplicate",icon:l.jsx(GR,{}),tooltip:"Duplicate",label:"Duplicate",hideLabel:!0,onClick:()=>n(t)},{id:"delete",icon:l.jsx(YR,{}),tooltip:"Delete",label:"Delete",hideLabel:!0,onClick:()=>s(!0)}];return l.jsxs(l.Fragment,{children:[l.jsx(zS,{title:"Delete Keys",content:"Are you sure you want to delete the selected keys?",visible:a,variant:"destructive",onClose:()=>s(!1),onConfirm:()=>{r(t),e([]),s(!1)}}),l.jsx(Ju,{show:t.length>0,onClose:()=>e([]),actionItems:o,showActionBg:!0,selectedItemsCount:t.length})]})},KR=t=>{if(t===Ie.BOOLEAN)return!1;if(t===Ie.STRING)return"";if(t===Ie.NUMBER)return 0;if(t===Ie.NULL)return null;if(t===Ie.ARRAY)return[];if(t===Ie.OBJECT)return{}},qS=({isVisible:t,onClose:e,parentContainer:r})=>{const[n,i]=h.useState(""),[a,s]=h.useState(OA[0]),[o,A]=h.useState(null),[u,c]=h.useState(""),[d,f]=h.useState(null),{handleAddKey:p,selectedPathModification:m}=bs();h.useEffect(()=>{a.value===Ie.BOOLEAN?A(!1):a.value===Ie.STRING?A(""):a.value===Ie.NUMBER?A(0):a.value===Ie.NULL?A(null):a.value===Ie.ARRAY?(A([]),c("")):a.value===Ie.OBJECT&&(A({}),c(""))},[a]);const g=()=>{i(""),s(OA[0]),A(null),c(""),e(),f(null)};h.useEffect(()=>{if(a.value===Ie.ARRAY||a.value===Ie.OBJECT){if(u.trim()===""){f(null);return}try{const b=JSON.parse(u);a.value===Ie.ARRAY&&!Array.isArray(b)?f("Enter a valid JSON array."):a.value===Ie.OBJECT&&(typeof b!="object"||b===null||Array.isArray(b))?f("Enter a valid JSON object."):f(null)}catch{f("Enter valid JSON.")}}},[u,a]);const y=()=>o===null&&a.value===Ie.NULL?null:!o&&o!==0&&o!==!1?KR(a.value):a.value===Ie.NUMBER?Number(o):o;return l.jsx(pn,{open:t,onCancel:g,title:"New Key",parentContainer:r,width:351,asForm:!0,footer:l.jsx("div",{className:"flex justify-end mt-5 gap-4",children:l.jsx(bt,{id:"btn-add-key-modal-add",status:"primary",onClick:async()=>{await p(m||"",n,y()),g()},disabled:!n||o===null&&a.value!==Ie.NULL||!!d,children:"Add"})}),children:l.jsxs("div",{className:"flex flex-col gap-4",children:[l.jsx(Hi,{required:!0,label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Key"}),value:n,onChange:b=>i(b),placeholder:"Enter key"}),l.jsx(al,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Type"}),options:OA,value:a,onChange:b=>s(b)}),(()=>{switch(a.value){case Ie.NULL:return null;case Ie.BOOLEAN:return l.jsx(Zn,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Value"}),isChecked:!!o,onChange:b=>A(b),statusText:o?"true":"false"});case Ie.OBJECT:case Ie.ARRAY:return l.jsx(Eb,{placeholder:a.value===Ie.ARRAY?"e.g. [1, 2, 3]":'e.g. {"key_1" : 1, "key_2":2}',onChange:b=>{const _=b;if(c(_),_.trim()==="")A(a.value===Ie.ARRAY?[]:{});else try{const v=JSON.parse(_);A(v)}catch{}}});default:return l.jsx(Hi,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Value"}),className:"w-full",value:o,onChange:b=>{if(a.value===Ie.NUMBER){const v=b.replace(/\.(?=.*\.)/g,"").replace(/[^\d.-]/g,"");A(v)}else A(b)},placeholder:"Enter value"})}})()]})})},ec=({isFullScreen:t,allExpanded:e,toggleAll:r,isEditMode:n,isDarkMode:i,style:a,value:s,onChange:o,setIsAddKeyModalOpen:A,isAddKeyModalOpen:u})=>{const[c,d]=h.useState({}),[f,p]=h.useState(null),[m,g]=h.useState([]),[y,b]=h.useState([]),[_,v]=h.useState(null),[S,k]=h.useState(null);h.useEffect(()=>{b(MS(m))},[m]),h.useEffect(()=>{try{const C=jS(s);d(C),p(null)}catch(C){p("Invalid JSON: "+C.message)}},[s]);const E=C=>{if(!C.length)return;const N=Gc.produce(c,P=>{C.forEach(L=>{if(!L||L===".")return;const R=L.split(".");if(R.shift(),R.length===0)return;let D=P;for(let I=0;I<R.length-1;I++)if(D=D[R[I]],D===void 0)return;const H=R[R.length-1];if(Array.isArray(D)){const I=Number(H);!isNaN(I)&&I>=0&&I<D.length&&D.splice(I,1)}else D&&typeof D=="object"&&delete D[H]})});o?.(JSON.stringify(N,null,2))},w=C=>{if(!C.length)return;const N=Gc.produce(c,P=>{C.forEach(L=>{const R=L.split(".");R[0]===""&&R.shift();let D=P;for(let I=0;I<R.length-1;I++)if(D=D[R[I]],D===void 0)return;const H=R[R.length-1];if(Array.isArray(D)){const I=Number(H);if(!isNaN(I)&&I>=0&&I<D.length){const M=JSON.parse(JSON.stringify(D[I]));D.splice(I+1,0,M)}}else if(D&&typeof D=="object"&&Object.hasOwn(D,H)){let I=H+"_copy",M=2;for(;Object.hasOwn(D,I);)I=`${H}_copy_${M++}`;D[I]=JSON.parse(JSON.stringify(D[H]))}})});o?.(JSON.stringify(N,null,2))},T=async C=>{if(!C.length)return!1;if(C.length===1){const N=C[0].split(".");N[0]===""&&N.shift();let P=c;for(const R of N){if(P==null)return!1;P=P[R]}if(P===void 0)return!1;let L;typeof P=="object"?L=JSON.stringify(P,null,2):L=String(P);try{return await navigator.clipboard.writeText(L),!0}catch{return!1}}else{const N={};for(const P of C){const L=P.split(".");L[0]===""&&L.shift();let R=c;for(const D of L)R!=null&&(R=R[D]);if(R!==void 0){const D=L[L.length-1]||"root";N[D]=R}}try{return await navigator.clipboard.writeText(JSON.stringify(N,null,2)),!0}catch{return!1}}},O=async(C,N,P)=>{const L=C.split(".");L[0]===""&&L.shift();const R=Gc.produce(c,D=>{let H=D;if(L.length===0){if(Object.hasOwn(H,N)){let I=N,M=2;for(;Object.hasOwn(H,I);)I=`${N}_${M++}`;H[I]=P}else H[N]=P;return}for(let I=0;I<L.length;I++)if(H=H[L[I]],H===void 0)return;if(Object.hasOwn(H,N)){let I=N,M=2;for(;Object.hasOwn(H,I);)I=`${N}_${M++}`;H[I]=P}else H[N]=P});v(null),o?.(JSON.stringify(R,null,2))};return l.jsx(LS,{value:{allExpanded:e,toggleAll:r,isEditMode:n,isDarkMode:i,selectedPaths:m,setSelectedPaths:g,selectedTopLevelPaths:y,setSelectedTopLevelPaths:b,selectedPathModification:_,setSelectedPathModification:v,selectedPathForEdit:S,setSelectedPathForEdit:k,jsonData:c,setJsonData:d,error:f,setError:p,handleDelete:E,handleDuplicate:w,handleCopy:T,handleAddKey:O,setIsAddKeyModalOpen:A,isAddKeyModalOpen:u},children:l.jsxs("div",{className:"bg-white dark:bg-black-800 rounded-b-lg",children:[n&&l.jsx(BS,{}),l.jsx(US,{onChange:o,style:a}),n&&l.jsx(qS,{parentContainer:t?"json-grid-core-container":"full-screen-container",isVisible:u,onClose:()=>A(!1)})]})})},Qi=F("text-neutral-600 cursor-pointer hover:text-neutral-800","dark:text-neutral-300 dark:hover:text-neutral-50"),ZR=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})}),$R=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"})}),JR=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M9.5 2c-1.82 0-3.53.5-5 1.35 2.99 1.73 5 4.95 5 8.65s-2.01 6.92-5 8.65c1.47.85 3.18 1.35 5 1.35 5.52 0 10-4.48 10-10S15.02 2 9.5 2z"})}),eP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-5 5-5-5h3V4h4v7h3z"})}),tP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),rP=({fontSize:t})=>l.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:[l.jsx("path",{d:"M18 6.41 16.59 5 12 9.58 7.41 5 6 6.41l6 6z"}),l.jsx("path",{d:"m18 13-1.41-1.41L12 16.17l-4.59-4.58L6 13l6 6z"})]}),nP=({fontSize:t})=>l.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:[l.jsx("path",{d:"M6 17.59 7.41 19 12 14.42 16.59 19 18 17.59l-6-6z"}),l.jsx("path",{d:"m6 11 1.41 1.41L12 7.83l4.59 4.58L18 11l-6-6z"})]}),iP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M12 9c1.65 0 3 1.35 3 3s-1.35 3-3 3-3-1.35-3-3 1.35-3 3-3m0-2c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41l-1.06-1.06zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z"})}),aP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"})}),VS=({value:t,onChange:e=()=>!1,withFullScreen:r=!0,withTheme:n=!0,isEditMode:i=!1,height:a="55vh",language:s="json",monacoEditor:o,isShowCopy:A=!0,isShowDownload:u=!0,setIsDisableSave:c,withJsonGrid:d=!0,editorTheme:f,setEditorTheme:p,theme:m,className:g,enableAutoFormatting:y=!0,renderToolbarActions:b,onBlockClick:_,focusBlock:v,focusBlockTopLevelOnly:S=!1})=>{const k=h.useRef(null),[E,w]=h.useState("vs"),[T,O]=h.useState("light"),C=f??E,N=m??T,P=p??(Q=>{w(Q),O(Q==="vs-dark"?"dark":"light")}),[L,R]=h.useState(!1),[D,H]=h.useState(null),I=NS(),M=o||I,{handleFormatCode:z,pythonError:V,pythonLoading:X}=DS({code:t,setCode:e,currentEditorModel:D,monacoEditor:M,enable:i===!0&&s==="python"}),ee=GA.useFullScreenHandle(),[W,B]=h.useState("JSON"),[Y,re]=h.useState(!1),G=s==="json",K=()=>{ee?.active?ee.exit():ee.enter()},te=h.useRef(_);te.current=_;const $=h.useCallback(async(Q,se,ke)=>{if(!te.current)return;const Ue=Q.getModel();if(!Ue)return;const Ge=(Fe,we)=>Ue.getValueInRange({startLineNumber:Fe,startColumn:1,endLineNumber:we,endColumn:Ue.getLineMaxColumn(we)}),Je=(Fe,we,Pe,ge,De)=>{te.current({startLine:Fe,endLine:we,text:Pe,kind:ge,cursorLine:se,cursorColumn:ke,parentBlock:De})};try{const Fe=Q.getContribution("editor.contrib.folding");if(Fe){const Le=await Fe.getFoldingModel();if(Le?.regions){const Ye=Le.regions,lt=Ue.getLineCount(),nt=[];for(let et=0;et<Ye.length;et++){const Xe=Ye.getStartLineNumber(et),mt=Ye.getEndLineNumber(et),je=Math.min(mt+1,lt),Qe=je-Xe;if(se>=Xe&&se<=je){const Ke=Ye.getType(et),Et=Ke===1?"comment":Ke===2?"imports":Ke===3?"region":void 0;nt.push({start:Xe,end:je,size:Qe,kind:Et})}}if(nt.length>0){nt.sort((Qe,Ke)=>Qe.size-Ke.size);const et=nt[0],Xe=Ge(et.start,et.end);let mt;for(let Qe=nt.length-1;Qe>0;Qe--){const Ke=nt[Qe];if(!(Ke.start<=1&&Ke.end>=lt)){mt=Ke;break}}const je=mt&&mt!==et?{startLine:mt.start,endLine:mt.end,text:Ge(mt.start,mt.end),kind:mt.kind}:void 0;Je(et.start,et.end,Xe,et.kind,je);return}}}const we={lineNumber:se,column:ke},Pe=Ue.bracketPairs?.findEnclosingBrackets?.(we);if(Pe&&Pe.length===2){const[Le,Ye]=Pe,lt=Le.startLineNumber,nt=Ye.endLineNumber,et=Ge(lt,nt);Je(lt,nt,et);return}const ge=Ue.getLineCount(),De=Ue.getValue();Je(1,ge,De)}catch{}},[]);h.useEffect(()=>{if(!v||!k.current)return;const Q=k.current,se=Q.getModel();if(!se)return;const ke=se.findMatches(v,!0,!1,!0,null,!1);if(ke.length===0)return;let Ue=ke[0];if(S&&ke.length>1){let we=1/0;for(const Pe of ke){const ge=se.getLineContent(Pe.range.startLineNumber),De=ge.length-ge.trimStart().length;De<we&&(we=De,Ue=Pe)}}const Ge=Ue.range.startLineNumber,Je=Ue.range.startColumn;Q.setPosition({lineNumber:Ge,column:Je}),Q.revealLineInCenter(Ge,1);const Fe=async()=>{try{const we=Q.getContribution("editor.contrib.folding");if(we){const De=await we.getFoldingModel();if(De?.regions){const Le=De.regions;let Ye=-1,lt=-1,nt=1/0;for(let et=0;et<Le.length;et++){const Xe=Le.getStartLineNumber(et),mt=Le.getEndLineNumber(et),je=Math.min(mt+1,se.getLineCount()),Qe=je-Xe;Ge>=Xe&&Ge<=je&&Qe<nt&&(Ye=Xe,lt=je,nt=Qe)}if(Ye!==-1){Q.setSelection({startLineNumber:Ye,startColumn:1,endLineNumber:lt,endColumn:se.getLineMaxColumn(lt)}),Q.revealRangeInCenter({startLineNumber:Ye,startColumn:1,endLineNumber:lt,endColumn:se.getLineMaxColumn(lt)},1);return}}}const Pe={lineNumber:Ge,column:Je},ge=se.bracketPairs?.findEnclosingBrackets?.(Pe);if(ge&&ge.length===2){const[De,Le]=ge;Q.setSelection({startLineNumber:De.startLineNumber,startColumn:1,endLineNumber:Le.endLineNumber,endColumn:se.getLineMaxColumn(Le.endLineNumber)}),Q.revealRangeInCenter({startLineNumber:De.startLineNumber,startColumn:1,endLineNumber:Le.endLineNumber,endColumn:se.getLineMaxColumn(Le.endLineNumber)},1);return}Q.setSelection(Ue.range)}catch{Q.setSelection(Ue.range)}};requestAnimationFrame(()=>{Fe()})},[v,S]);const oe=Q=>{k.current=Q;const se=()=>{try{if(s==="python"){const ke=Q.getModel();ke&&H(ke)}s==="json"&&y&&requestAnimationFrame(()=>{ye()})}catch(ke){console.warn("Failed to initialize editor:",ke)}};if(Q.getModel())se();else{const ke=Q.onDidChangeModel(()=>{se(),ke.dispose()})}te.current&&Q.onMouseDown(()=>{requestAnimationFrame(()=>{const ke=Q.getPosition();ke&&$(Q,ke.lineNumber,ke.column)})})},Me=()=>{try{const Q=JSON.parse(t),se=JSON.stringify(Q,null,4);e(se),D&&M&&M.editor.setModelMarkers(D,"json",[])}catch(Q){if(D&&M){const se=Q instanceof Error?Q.message:"Invalid JSON";try{M.editor.setModelMarkers(D,"json",[{startLineNumber:1,startColumn:1,endLineNumber:1,endColumn:1,message:`Cannot format: ${se}`,severity:M.MarkerSeverity.Error}])}catch(ke){console.warn("Failed to set JSON error markers:",ke)}}}},ye=()=>{if(s==="python"){z();return}if(s==="json"){Me();return}if(k.current)try{const Q=k.current.getAction("editor.action.formatDocument");Q&&Q.run()}catch(Q){console.warn("Failed to format document:",Q)}},me=Q=>{typeof Q=="string"&&e(Q)};if(h.useEffect(()=>{c&&c(V||X)},[V,X,c]),!o&&!I)return l.jsx("div",{className:"flex items-center justify-center p-8 border border-neutral-200 dark:border-neutral-700 rounded-lg",children:l.jsx("div",{className:"text-neutral-600 dark:text-neutral-400",children:"Loading editor..."})});const fe=F("hover:bg-neutral-300 hover:dark:bg-neutral-700 p-0.5 rounded-md flex items-center justify-center"),pe=()=>{if(s==="python")try{let Q=t;Q&&(Q=Q.replace(/\r\n/g,`
81
+ `},Qx=aR(AR)(SS),uR={config:oR},cR=function(){for(var e=arguments.length,r=new Array(e),n=0;n<e;n++)r[n]=arguments[n];return function(i){return r.reduceRight(function(a,s){return s(a)},i)}};function ES(t,e){return Object.keys(e).forEach(function(r){e[r]instanceof Object&&t[r]&&Object.assign(e[r],ES(t[r],e[r]))}),qx(qx({},t),e)}var dR={type:"cancelation",msg:"operation is manually canceled"};function $c(t){var e=!1,r=new Promise(function(n,i){t.then(function(a){return e?i(dR):n(a)}),t.catch(i)});return r.cancel=function(){return e=!0},r}var fR=nR.create({config:iR,isInitialized:!1,resolve:null,reject:null,monaco:null}),kS=HD(fR,2),sl=kS[0],$u=kS[1];function pR(t){var e=uR.config(t),r=e.monaco,n=jD(e,["monaco"]);$u(function(i){return{config:ES(i.config,n),monaco:r}})}function hR(){var t=sl(function(e){var r=e.monaco,n=e.isInitialized,i=e.resolve;return{monaco:r,isInitialized:n,resolve:i}});if(!t.isInitialized){if($u({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),$c(Jc);if(window.monaco&&window.monaco.editor)return wS(window.monaco),t.resolve(window.monaco),$c(Jc);cR(mR,bR)(xR)}return $c(Jc)}function mR(t){return document.body.appendChild(t)}function gR(t){var e=document.createElement("script");return t&&(e.src=t),e}function bR(t){var e=sl(function(n){var i=n.config,a=n.reject;return{config:i,reject:a}}),r=gR("".concat(e.config.paths.vs,"/loader.js"));return r.onload=function(){return t()},r.onerror=e.reject,r}function xR(){var t=sl(function(r){var n=r.config,i=r.resolve,a=r.reject;return{config:n,resolve:i,reject:a}}),e=window.require;e.config(t.config),e(["vs/editor/editor.main"],function(r){wS(r),t.resolve(r)},function(r){t.reject(r)})}function wS(t){sl().monaco||$u({monaco:t})}function _R(){return sl(function(t){var e=t.monaco;return e})}var Jc=new Promise(function(t,e){return $u({resolve:t,reject:e})}),JA={config:pR,init:hR,__getMonacoInstance:_R},yR={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ed=yR,vR={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},SR=vR;function ER({children:t}){return h.createElement("div",{style:SR.container},t)}var kR=ER,wR=kR;function TR({width:t,height:e,isEditorReady:r,loading:n,_ref:i,className:a,wrapperProps:s}){return h.createElement("section",{style:{...ed.wrapper,width:t,height:e},...s},!r&&h.createElement(wR,null,n),h.createElement("div",{ref:i,style:{...ed.fullWidth,...!r&&ed.hide},className:a}))}var OR=TR,TS=h.memo(OR);function CR(t){h.useEffect(t,[])}var OS=CR;function NR(t,e,r=!0){let n=h.useRef(!0);h.useEffect(n.current||!r?()=>{n.current=!1}:t,e)}var Wr=NR;function ao(){}function za(t,e,r,n){return DR(t,n)||RR(t,e,r,n)}function DR(t,e){return t.editor.getModel(CS(t,e))}function RR(t,e,r,n){return t.editor.createModel(e,r,n?CS(t,n):void 0)}function CS(t,e){return t.Uri.parse(e)}function PR({original:t,modified:e,language:r,originalLanguage:n,modifiedLanguage:i,originalModelPath:a,modifiedModelPath:s,keepCurrentOriginalModel:o=!1,keepCurrentModifiedModel:A=!1,theme:u="light",loading:c="Loading...",options:d={},height:f="100%",width:p="100%",className:m,wrapperProps:g={},beforeMount:y=ao,onMount:b=ao}){let[_,v]=h.useState(!1),[S,k]=h.useState(!0),E=h.useRef(null),w=h.useRef(null),T=h.useRef(null),O=h.useRef(b),C=h.useRef(y),N=h.useRef(!1);OS(()=>{let D=JA.init();return D.then(H=>(w.current=H)&&k(!1)).catch(H=>H?.type!=="cancelation"&&console.error("Monaco initialization: error:",H)),()=>E.current?R():D.cancel()}),Wr(()=>{if(E.current&&w.current){let D=E.current.getOriginalEditor(),H=za(w.current,t||"",n||r||"text",a||"");H!==D.getModel()&&D.setModel(H)}},[a],_),Wr(()=>{if(E.current&&w.current){let D=E.current.getModifiedEditor(),H=za(w.current,e||"",i||r||"text",s||"");H!==D.getModel()&&D.setModel(H)}},[s],_),Wr(()=>{let D=E.current.getModifiedEditor();D.getOption(w.current.editor.EditorOption.readOnly)?D.setValue(e||""):e!==D.getValue()&&(D.executeEdits("",[{range:D.getModel().getFullModelRange(),text:e||"",forceMoveMarkers:!0}]),D.pushUndoStop())},[e],_),Wr(()=>{E.current?.getModel()?.original.setValue(t||"")},[t],_),Wr(()=>{let{original:D,modified:H}=E.current.getModel();w.current.editor.setModelLanguage(D,n||r||"text"),w.current.editor.setModelLanguage(H,i||r||"text")},[r,n,i],_),Wr(()=>{w.current?.editor.setTheme(u)},[u],_),Wr(()=>{E.current?.updateOptions(d)},[d],_);let P=h.useCallback(()=>{if(!w.current)return;C.current(w.current);let D=za(w.current,t||"",n||r||"text",a||""),H=za(w.current,e||"",i||r||"text",s||"");E.current?.setModel({original:D,modified:H})},[r,e,i,t,n,a,s]),L=h.useCallback(()=>{!N.current&&T.current&&(E.current=w.current.editor.createDiffEditor(T.current,{automaticLayout:!0,...d}),P(),w.current?.editor.setTheme(u),v(!0),N.current=!0)},[d,u,P]);h.useEffect(()=>{_&&O.current(E.current,w.current)},[_]),h.useEffect(()=>{!S&&!_&&L()},[S,_,L]);function R(){let D=E.current?.getModel();o||D?.original?.dispose(),A||D?.modified?.dispose(),E.current?.dispose()}return h.createElement(TS,{width:p,height:f,isEditorReady:_,loading:c,_ref:T,className:m,wrapperProps:g})}var LR=PR;h.memo(LR);function IR(t){let e=h.useRef();return h.useEffect(()=>{e.current=t},[t]),e.current}var MR=IR,ql=new Map;function jR({defaultValue:t,defaultLanguage:e,defaultPath:r,value:n,language:i,path:a,theme:s="light",line:o,loading:A="Loading...",options:u={},overrideServices:c={},saveViewState:d=!0,keepCurrentModel:f=!1,width:p="100%",height:m="100%",className:g,wrapperProps:y={},beforeMount:b=ao,onMount:_=ao,onChange:v,onValidate:S=ao}){let[k,E]=h.useState(!1),[w,T]=h.useState(!0),O=h.useRef(null),C=h.useRef(null),N=h.useRef(null),P=h.useRef(_),L=h.useRef(b),R=h.useRef(),D=h.useRef(n),H=MR(a),I=h.useRef(!1),M=h.useRef(!1);OS(()=>{let X=JA.init();return X.then(ee=>(O.current=ee)&&T(!1)).catch(ee=>ee?.type!=="cancelation"&&console.error("Monaco initialization: error:",ee)),()=>C.current?V():X.cancel()}),Wr(()=>{let X=za(O.current,t||n||"",e||i||"",a||r||"");X!==C.current?.getModel()&&(d&&ql.set(H,C.current?.saveViewState()),C.current?.setModel(X),d&&C.current?.restoreViewState(ql.get(a)))},[a],k),Wr(()=>{C.current?.updateOptions(u)},[u],k),Wr(()=>{!C.current||n===void 0||(C.current.getOption(O.current.editor.EditorOption.readOnly)?C.current.setValue(n):n!==C.current.getValue()&&(M.current=!0,C.current.executeEdits("",[{range:C.current.getModel().getFullModelRange(),text:n,forceMoveMarkers:!0}]),C.current.pushUndoStop(),M.current=!1))},[n],k),Wr(()=>{let X=C.current?.getModel();X&&i&&O.current?.editor.setModelLanguage(X,i)},[i],k),Wr(()=>{o!==void 0&&C.current?.revealLine(o)},[o],k),Wr(()=>{O.current?.editor.setTheme(s)},[s],k);let z=h.useCallback(()=>{if(!(!N.current||!O.current)&&!I.current){L.current(O.current);let X=a||r,ee=za(O.current,n||t||"",e||i||"",X||"");C.current=O.current?.editor.create(N.current,{model:ee,automaticLayout:!0,...u},c),d&&C.current.restoreViewState(ql.get(X)),O.current.editor.setTheme(s),o!==void 0&&C.current.revealLine(o),E(!0),I.current=!0}},[t,e,r,n,i,a,u,c,d,s,o]);h.useEffect(()=>{k&&P.current(C.current,O.current)},[k]),h.useEffect(()=>{!w&&!k&&z()},[w,k,z]),D.current=n,h.useEffect(()=>{k&&v&&(R.current?.dispose(),R.current=C.current?.onDidChangeModelContent(X=>{M.current||v(C.current.getValue(),X)}))},[k,v]),h.useEffect(()=>{if(k){let X=O.current.editor.onDidChangeMarkers(ee=>{let W=C.current.getModel()?.uri;if(W&&ee.find(B=>B.path===W.path)){let B=O.current.editor.getModelMarkers({resource:W});S?.(B)}});return()=>{X?.dispose()}}return()=>{}},[k,S]);function V(){R.current?.dispose(),f?d&&ql.set(a,C.current.saveViewState()):C.current.getModel()?.dispose(),C.current.dispose()}return h.createElement(TS,{width:p,height:m,isEditorReady:k,loading:A,_ref:N,className:g,wrapperProps:y})}var HR=jR,FR=h.memo(HR),UR=FR;class Ba{static instance;monaco=null;initialized=!1;initializationPromise=null;static getInstance(){return Ba.instance||(Ba.instance=new Ba),Ba.instance}configure(e){this.initialized&&console.warn("monacoManager.configure() called after initialization — config may not take effect"),JA.config(e)}async initialize(){return this.initialized&&this.monaco?this.monaco:this.initializationPromise?this.initializationPromise:(this.initializationPromise=this.performInitialization(),this.initializationPromise)}async performInitialization(){try{return this.monaco=await JA.init(),this.initialized=!0,this.initializationPromise=null,this.monaco}catch(e){throw this.initializationPromise=null,console.error("Failed to initialize Monaco Editor:",e),new Error(`Monaco Editor initialization failed: ${e instanceof Error?e.message:"Unknown error"}`)}}getMonaco(){return this.monaco}isInitialized(){return this.initialized}getEditorInstance(e=0){if(!this.monaco)return console.warn("Monaco Editor not initialized"),null;const r=this.monaco.editor.getEditors();return r.length<=e?(console.warn(`No editor found at index ${e}. Available editors: ${r.length}`),null):r[e]}getFirstEditorInstance(){return this.getEditorInstance(0)}static safeDispose(e){e.forEach(r=>{try{r&&typeof r.dispose=="function"&&r.dispose()}catch(n){console.warn("Error disposing Monaco resource:",n)}})}}const Q1=Ba.getInstance(),NS=()=>{const[t,e]=h.useState(Q1.getMonaco());return h.useEffect(()=>{if(t)return;let r=!1;return Q1.initialize().then(n=>{r||e(n)}),()=>{r=!0}},[t]),t},Ht={createSuccess:function(t){return`${t} created successfully.`},createFailure:function(t){return`${t} creation failed. Please retry.`},updateSuccess:function(t){return`${t} updated successfully.`},updateFailure:function(t){return`${t} update failed. Please retry.`},copySuccess:function(t){return`${t} copied successfully.`},copyFailure:function(t){return`${t} copy failed. Please retry.`},copyToClipboard:function(t){return`${t} copied to clipboard.`},moveSuccess:function(t){return`${t} moved successfully.`},moveFailure:function(t){return`${t} move failed. Please retry.`},restoreSuccess:function(t){return`${t} restored successfully.`},resetSuccess:function(t){return`${t} reset successfully.`},resetFailure:function(t){return`${t} reset failed. Please retry.`},restoreFailure:function(t){return`${t} restore failed. Please retry.`},deleteSuccess:function(t){return`${t} deleted successfully.`},deleteFailure:function(t){return`${t} delete failed. Please retry.`},addSuccess:function(t){return`${t} added successfully.`},addFailure:function(t){return`${t} add failed. Please retry.`},removeSuccess:function(t){return`${t} removed successfully.`},removeFailure:function(t){return`${t} remove failed. Please retry.`},importSuccess:function(t){return`${t} imported successfully.`},importFailure:function(t){return`${t} import failed. Please retry.`},exportSuccess:function(t){return`${t} exported successfully.`},exportFailure:function(t){return`${t} export failed. Please retry.`},installSuccess:function(t){return`${t} installed successfully.`},duplicateSuccess:function(t){return`${t} duplicated successfully.`},installFailure:function(t){return`${t} install failed. Please retry.`},uninstallSuccess:function(t){return`${t} uninstalled successfully.`},uninstallFailure:function(t){return`${t} uninstall failed. Please retry.`},approveSuccess:function(t){return`${t} approved successfully.`},approveFailure:function(t){return`${t} approve failed. Please retry.`},rejectSuccess:function(t){return`${t} rejected successfully.`},rejectFailure:function(t){return`${t} reject failed. Please retry.`},archiveSuccess:function(t){return`${t} archived successfully.`},archiveFailure:function(t){return`${t} archive failed. Please retry.`},activateSuccess:function(t){return`${t} activated successfully.`},activateFailure:function(t){return`${t} activation failed. Please retry.`},deactivateSuccess:function(t){return`${t} deactivated successfully.`},deactivateFailure:function(t){return`${t} deactivation failed. Please retry.`},fetchFailure:function(t){return`An error occurred while fetching ${t}. Please retry.`},requiredField:function(t){return`${t} is required.`},existsError:function(t){return`${t} already exists.`},shouldNotContainOnlySpaces:function(t){return`${t} shouldn't contain only spaces.`},notAllowed:function(t){return`${t} not allowed.`},allowed:function(t){return`${t} allowed.`},multipleNotAllowed:function(t){return`Multiple ${t} not allowed.`},notFound:function(t){return`${t} not found.`},sendForApproval:function(t){return`${t} sent for approval.`},invalidError:function(t){return`Invalid ${t}.`},success:function(t){return`${t} successful.`},initializationError:function(t){return`Please initialize the ${t}.`},selectError:function(t){return`Please select ${t}.`},importStarted:function(t){return`${t} import has started.`},initiationSuccess:function(t){return`${t} initiated successfully.`},initiationFailure:function(t){return`${t} initiation failed. Please retry.`},transferSuccess:function(t){return`${t} has been successfully transferred.`},transferFailure:function(t){return`${t} transfer has failed, Please retry.`},terminatedSuccess:function(t){return`${t} terminated successfully.`},terminatedFailure:function(t){return`${t} termination failed, Please retry.`},markedAs:function(t){return`Marked as ${t}.`},bulkStatusChangeSuccess:function(t){return`Status changed to ${t?"locked":"unlocked"} successfully.`},bulkStatusChangeFailure:function(t){return`Status change to ${t?"locked":"unlocked"} failed, Please retry.`},downloading:function(t){return`Downloading ${t}...`},downloadFailure:function(t){return`Download ${t} failed. Please retry.`},bulkStatusChangeInfo:"Status change default info",bulkStatusChangeDefault:"Unknown response type",bulkDeleteUsersSuccess:"Users deleted successfully.",bulkDeleteUsersFailure:"Bulk user delete failed, Please retry.",errorMessage:"Something went wrong.",requiredFieldError:"Please fill out all mandatory fields.",resetPasswordSuccess:"Password reset successfully.",noItemSelected:"No item selected.",fieldAlreadyExist:"Field has already been added to this step.",fetchingError:"An error occurred while fetching configuration details.",secondaryOwnerLimitExceed:"Can't add more than 3 users to 'Secondary Owner'.",saveChangesAlert:"Please save the changes before switching tabs.",visibleColumnError:"There must be at least one visible column.",sessionExpired:"Session expired. Please login.",invalidFileType:"Non acceptable file type.",triggerNodeError:"Trigger is required!",formatFailed:"Failed to format.",memberRemoveSuccess:"Team member removed successfully.",memberRemoveInfo:"Team member removed default info.",memberRemoveError:"Unable to remove team member.",memberRemoveWarning:"Unable to remove team member.",memberRemoveDefault:"Unknown response type."},DS=({monacoEditor:t,currentEditorModel:e,code:r,setCode:n,enable:i,checkSyntaxAPI:a,formatCodeAPI:s})=>{const[o,A]=h.useState(null),[u,c]=h.useState(!1);function d(g){const y={};let b=0;return{result:g.replace(/{{(.*?)}}/g,(v,S,k,E)=>{const w=E.slice(0,k),T=E.slice(k+v.length),O=w.endsWith('"')&&T.startsWith('"'),C=w.endsWith("'")&&T.startsWith("'");return O||C?v:(y[`__dynamic_value_${b}`]=v,`"__dynamic_value_${b++}"`)}),originalValues:y}}function f(g,y){return g.replace(/"__dynamic_value_\d+"/g,b=>{const _=b.slice(1,-1);return y[_]||b})}const p=async()=>{if(!t||!e||!a){console.warn("Monaco editor, model, or syntax check API not available");return}c(!0);try{const{result:g}=d(r),b=(await a(g))?.data?.error;if(b?.message){A(b);const _=[{startLineNumber:b.line||1,endLineNumber:b.line||1,startColumn:b.column||1,endColumn:b.column||1,message:b.message,severity:t.MarkerSeverity?.Error||8}];try{t.editor.setModelMarkers(e,"owner",_)}catch(v){console.warn("Failed to set error markers:",v)}}else{A(null);try{t.editor.setModelMarkers(e,"owner",[])}catch(_){console.warn("Failed to clear error markers:",_)}}}catch(g){if(console.warn("Syntax check failed:",g),A(null),t&&e)try{t.editor.setModelMarkers(e,"owner",[])}catch(y){console.warn("Failed to clear error markers after error:",y)}}finally{c(!1)}},m=async()=>{if(!t||!e||!s){console.warn("Monaco editor, model, or format API not available");return}c(!0);try{const{result:g,originalValues:y}=d(r),b=await s(g);if(b?.data?.formatted_code){const _=f(b.data.formatted_code,y);n(_)}else console.warn("No formatted code received from service")}catch(g){const y=g?.message||Ht.formatFailed;console.warn("Code formatting failed:",y),Dt.toast.error(y,{toastId:y})}finally{c(!1)}};return h.useEffect(()=>{if(t&&i&&a){const g=xb.debounce(p,500);return g(),()=>{g.cancel()}}},[r,t]),{pythonError:o,pythonLoading:u,handleCheckSyntax:p,handleFormatCode:m}},RS=["US","GB","IN","DE","FR","CN","JP","BR","CA","AU","IT","ES","RU","KR","ZA","MX","TR","ID","SA","AR","NL","CH","SE","BE","PL","EG","SG","TH","UA","PK","BD","PH","VN","MY","CO","CL","NO","DK","FI","IE","AT","GR","PT","HU","CZ","RO","NZ","AE","GH","EU","MA","NG","TW","HK","KE","IR","PE","QA","KW","LK","NP"];function Tb(t){return{US:"United States",GB:"United Kingdom",IN:"India",DE:"Germany",FR:"France",CN:"China",JP:"Japan",BR:"Brazil",CA:"Canada",AU:"Australia",IT:"Italy",ES:"Spain",RU:"Russia",KR:"South Korea",ZA:"South Africa",MX:"Mexico",TR:"Turkey",ID:"Indonesia",SA:"Saudi Arabia",AR:"Argentina",NL:"Netherlands",CH:"Switzerland",SE:"Sweden",BE:"Belgium",PL:"Poland",EG:"Egypt",SG:"Singapore",TH:"Thailand",UA:"Ukraine",PK:"Pakistan",BD:"Bangladesh",PH:"Philippines",VN:"Vietnam",MY:"Malaysia",CO:"Colombia",CL:"Chile",NO:"Norway",DK:"Denmark",FI:"Finland",IE:"Ireland",AT:"Austria",GR:"Greece",PT:"Portugal",HU:"Hungary",CZ:"Czech Republic",RO:"Romania",NZ:"New Zealand",AE:"United Arab Emirates",GH:"Ghana",EU:"European Union",MA:"Morocco",NG:"Nigeria",TW:"Taiwan",HK:"Hong Kong",KE:"Kenya",IR:"Iran",PE:"Peru",QA:"Qatar",KW:"Kuwait",LK:"Sri Lanka",NP:"Nepal"}[t]||t}const PS=h.createContext(null),LS=PS.Provider,bs=()=>{const t=h.useContext(PS);if(!t)throw new Error("useJsonGridViewerContext must be used within a JsonGridViewerContextProvider");return t},Ie={STRING:"string",NUMBER:"number",BOOLEAN:"boolean",NULL:"null",OBJECT:"object",ARRAY:"array"},IS={[Ie.ARRAY]:"text-purple-600 bg-purple-100",[Ie.OBJECT]:"text-warning-600 bg-warning-100",[Ie.STRING]:"text-success-600 bg-success-100",[Ie.NUMBER]:"text-blue-600 bg-blue-100",[Ie.BOOLEAN]:"text-purple-600 bg-purple-100",[Ie.NULL]:"text-neutral-600 bg-neutral-100"},OA=[{label:"String",value:Ie.STRING},{label:"Number",value:Ie.NUMBER},{label:"Boolean",value:Ie.BOOLEAN},{label:"Null",value:Ie.NULL},{label:"Object",value:Ie.OBJECT},{label:"Array",value:Ie.ARRAY}],Ob=t=>t===null?Ie.NULL:Array.isArray(t)?Ie.ARRAY:typeof t=="object"?Ie.OBJECT:typeof t,MS=t=>{const e=[...t].sort((n,i)=>n.length-i.length),r=[];for(const n of e)r.some(a=>n!==a&&n.startsWith(a+"."))||r.push(n);return r},jS=t=>!t||t.trim()===""?{}:JSON.parse(t),HS=(t,e)=>{const r=h.useCallback((a,s)=>{const o=[],A=(u,c)=>{Array.isArray(u)?u.forEach((d,f)=>{const p=`${c}.${f}`;o.push(p),typeof d=="object"&&d!==null&&A(d,p)}):u&&typeof u=="object"&&Object.entries(u).forEach(([d,f])=>{const p=`${c}.${d}`;o.push(p),typeof f=="object"&&f!==null&&A(f,p)})};return A(s,a),o},[]),n=h.useCallback((a,s,o,A)=>{if(s){const u=[a];if(A){const c=r(a,o);u.push(...c)}e(Array.from(new Set([...t,...u])))}else{const u=[a];if(A){const c=r(a,o);u.push(...c)}e(t?.filter(c=>!u.includes(c))||[])}},[t,e,r]),i=h.useCallback(a=>t?.includes(a)||!1,[t]);return{handleCheckboxChange:n,isPathSelected:i,getAllChildPaths:r}},FS=({value:t,path:e,onChange:r,isDarkMode:n=!1})=>{const[i,a]=h.useState(""),s=Ob(t),{selectedPathForEdit:o,setSelectedPathForEdit:A}=bs();h.useEffect(()=>{s===Ie.STRING?a(t):s===Ie.NUMBER||s===Ie.BOOLEAN?a(String(t)):s===Ie.NULL&&a("null")},[t,s]);const u=d=>{a(d.target.value)},c=()=>{try{let d;if(s===Ie.NUMBER){if(d=Number(i),i.trim()==="")throw new Error("Empty number");if(d=Number(i),Number.isNaN(d))throw new Error("Invalid number")}else if(s===Ie.BOOLEAN)if(i.toLowerCase()==="true")d=!0;else if(i.toLowerCase()==="false")d=!1;else throw new Error("Invalid boolean value");else if(s===Ie.NULL)if(i.toLowerCase()==="null")d=null;else throw new Error("Invalid null value");else d=i;r(e,d),A(null)}catch{s===Ie.STRING?a(t):s===Ie.NUMBER||s===Ie.BOOLEAN?a(String(t)):s===Ie.NULL&&a("null")}};return s===Ie.BOOLEAN?l.jsx(Zn,{isChecked:t,onChange:d=>r(e,d)}):s===Ie.NULL?l.jsx("span",{className:n?"text-neutral-400 italic":"text-neutral-500 italic",children:"null"}):o===e&&s===Ie.NUMBER?l.jsx(Hi,{value:i,onChange:d=>{const p=d.replace(/\.(?=.*\.)/g,"").replace(/[^\d.-]/g,"");a(p)},className:"w-full",onBlur:c}):o===e&&s===Ie.STRING?l.jsx("div",{className:"w-full min-w-36",children:l.jsx("textarea",{value:i,onChange:u,onBlur:c,className:`w-full min-w-36 rounded-lg px-2 py-1 text-sm focus:outline-none focus:border-blue-500 border resize-none hover:resize-y ${n?"bg-black-800 text-white":"bg-white text-black"}`,rows:1})}):l.jsx("span",{className:F(n?"text-neutral-400":"text-neutral-900","text-sm font-medium"),children:t})},zR=({isExpanded:t})=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:F(t?"rotate-90":"rotate-0","transition-transform duration-200"),children:l.jsx("path",{d:"M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z"})}),BR=()=>l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),qR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-neutral-500 dark:text-neutral-400",children:l.jsx("path",{d:"M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"})}),Cb=({data:t,path:e,onChange:r})=>{const n=Array.isArray(t),[i,a]=h.useState([]),{allExpanded:s,isDarkMode:o,selectedPaths:A,setSelectedPaths:u,setSelectedPathModification:c,isEditMode:d,handleCopy:f}=bs(),{handleCheckboxChange:p,isPathSelected:m}=HS(A,u),g=()=>{const S=[],k=(E,w)=>{Array.isArray(E)?E.forEach((T,O)=>{const C=`${w}.${O}`;typeof T=="object"&&T!==null&&(S.push(C),k(T,C))}):E&&typeof E=="object"&&Object.entries(E).forEach(([T,O])=>{const C=`${w}.${T}`;typeof O=="object"&&O!==null&&(S.push(C),k(O,C))})};return k(t,e),S};h.useEffect(()=>{t&&a(s?g():[])},[s,t,e]);const y=S=>{a(k=>k.includes(S)?k.filter(E=>E!==S):[...k,S])},b=(S,k)=>{r(S,k)},_=e==="",v=(S,k,E,w,T)=>{const O=Ob(k),C=O===Ie.OBJECT||O===Ie.ARRAY,N=`${E}.${S}`,P=i.includes(N);return l.jsxs("tr",{className:F("border-neutral-300 dark:border-neutral-700",_?"border-b":T?"border-b-0":"border-b"),children:[l.jsx("td",{className:F("px-3 py-4 align-top border-r text-sm font-medium w-1/4",o?"text-neutral-200 bg-black-700":"bg-neutral-100 text-[#101828]",w&&!_&&"rounded-tl-xl",T&&!_&&"rounded-bl-xl"),children:l.jsxs("div",{className:"flex items-center",children:[d&&l.jsx(oS,{id:`checkbox-${N}`,label:"",isChecked:m(N),onChange:L=>p(N,L.target.checked,k,C)}),l.jsx("span",{className:"text-neutral-500 dark:text-neutral-400 whitespace-nowrap",children:S})]})}),l.jsx("td",{className:"!w-[120px] py-4 px-3 align-top bg-white dark:bg-black-800",children:l.jsx("div",{className:"flex items-start justify-center h-full",children:l.jsx("span",{className:`${IS[O]} px-2 py-1 rounded-xl text-xs`,children:O?.toUpperCase()})})}),l.jsx("td",{className:F("border-l border-neutral-300 dark:border-neutral-700 bg-white dark:bg-black-800",!d&&w&&!_&&"rounded-tr-xl",!d&&T&&!_&&"rounded-br-xl","!min-w-36"),children:l.jsx("div",{className:"py-2 px-3 flex items-center justify-start h-full",children:C?l.jsxs("div",{children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("button",{type:"button",onClick:()=>y(N),className:`mr-1 p-0.5 flex items-center justify-center rounded ${o?"hover:bg-black-700 text-neutral-200":"hover:bg-neutral-300 text-neutral-600"}`,children:l.jsx(zR,{isExpanded:P})}),l.jsx("span",{className:F(o?"text-neutral-400":"text-neutral-900","text-sm font-medium"),children:P?O===Ie.ARRAY?`[${k.length} items]`:`{${Object.keys(k).length} items}`:O===Ie.ARRAY?`[${k.length} items]`:"{...}"}),!d&&l.jsx("button",{type:"button",className:"ml-2",onClick:()=>f([N]),children:l.jsx(BR,{})})]}),P&&(Array.isArray(k)&&k?.length>0||Object.keys(k).length>0)&&l.jsx("div",{className:"ml-1.5 mt-3",children:l.jsx(Cb,{data:k,path:N,onChange:b})})]}):l.jsx(FS,{value:k,path:N,onChange:b,isDarkMode:o})})}),d&&l.jsx("td",{className:F("w-6 py-3.5 align-top bg-white dark:bg-black-800",w&&!_&&"rounded-tr-xl",T&&!_&&"rounded-br-xl"),children:l.jsx("button",{type:"button",onClick:()=>c(N),className:"p-1 rounded hover:bg-neutral-100 dark:hover:bg-black-700",children:l.jsx(qR,{})})})]},N)};return t?l.jsx("div",{className:_?"border-none":"border border-neutral-300 dark:border-neutral-700 rounded-xl",children:l.jsx("table",{className:F("w-full"),children:l.jsx("tbody",{children:n?t.map((S,k)=>v(k,S,e,k===0,k===t.length-1)):Object.entries(t).map(([S,k],E)=>v(S,k,e,E===0,E===Object.keys(t).length-1))})})}):null},US=({onChange:t,style:e})=>{const{isDarkMode:r,error:n,jsonData:i,setJsonData:a}=bs();if(!i)return null;const s=(o,A)=>{if(!o||o===".")return;const u=o.split(".");u.shift();const c=structuredClone(i);let d=c;for(let p=0;p<u.length-1;p++){const m=u[p];if(Array.isArray(d)){const g=parseInt(m,10);d=d[g]}else d=d[m]}const f=u[u.length-1];if(Array.isArray(d)){const p=parseInt(f,10);d[p]=A}else d[f]=A;a(c),t?.(JSON.stringify(c,null,2))};return n?l.jsx("div",{className:r?"p-4 bg-red-900 text-red-300 border border-red-800 rounded":"p-4 bg-red-50 text-red-600 border border-red-300 rounded",children:n}):l.jsx("div",{className:F(r?"shadow-sm overflow-auto":"bg-white dark:bg-black-800 shadow-sm overflow-auto"),style:e,id:"json-grid-core-container",children:l.jsx("div",{className:"p-0 overflow-auto",children:l.jsx(Cb,{data:i,path:"",onChange:s})})})},zS=({visible:t,onClose:e,content:r,title:n,onConfirm:i,isLoading:a,variant:s,cancelText:o="Cancel",confirmText:A})=>{const u=h.useMemo(()=>l.jsxs("div",{className:"flex justify-end gap-3",children:[l.jsx(bt,{id:"btn-confirmation-modal-cancel",onClick:e,disabled:a,status:"secondary-neutral",children:o}),l.jsx(bt,{id:`btn-confirmation-modal-${s==="destructive"?"Delete":"Confirm"}`,onClick:i,isLoading:a,status:s==="destructive"?"error":"primary",autoFocus:!0,type:"submit",children:A||(s==="destructive"?"Delete":"Confirm")})]}),[e,i,a,s,o,A]);return t?l.jsx(pn,{title:n,open:t,footer:u,onCancel:e,zIndex:9999,children:l.jsx("div",{className:"my-5",children:l.jsx("div",{className:"text-neutral-400 font-inter text-base",children:r})})}):null},VR=({size:t=24,fill:e="currentColor",className:r})=>l.jsx("svg",{className:r,width:t,height:t,viewBox:"0 0 20 20",fill:e,xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{d:"M10.0002 11.1666L5.91683 15.2499C5.76405 15.4027 5.56961 15.4791 5.3335 15.4791C5.09739 15.4791 4.90294 15.4027 4.75016 15.2499C4.59738 15.0971 4.521 14.9027 4.521 14.6666C4.521 14.4305 4.59738 14.236 4.75016 14.0833L8.8335 9.99992L4.75016 5.91659C4.59738 5.76381 4.521 5.56936 4.521 5.33325C4.521 5.09714 4.59738 4.9027 4.75016 4.74992C4.90294 4.59714 5.09739 4.52075 5.3335 4.52075C5.56961 4.52075 5.76405 4.59714 5.91683 4.74992L10.0002 8.83325L14.0835 4.74992C14.2363 4.59714 14.4307 4.52075 14.6668 4.52075C14.9029 4.52075 15.0974 4.59714 15.2502 4.74992C15.4029 4.9027 15.4793 5.09714 15.4793 5.33325C15.4793 5.56936 15.4029 5.76381 15.2502 5.91659L11.1668 9.99992L15.2502 14.0833C15.4029 14.236 15.4793 14.4305 15.4793 14.6666C15.4793 14.9027 15.4029 15.0971 15.2502 15.2499C15.0974 15.4027 14.9029 15.4791 14.6668 15.4791C14.4307 15.4791 14.2363 15.4027 14.0835 15.2499L10.0002 11.1666Z"})}),WR=({fill:t="#cccccc",className:e})=>l.jsx("svg",{height:"20",width:"20",viewBox:"0 0 20 20",focusable:"false",className:e,children:l.jsx("path",{fill:t,d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"})}),XR=({size:t=24,fill:e="currentColor",className:r,onClick:n})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 20 20",fill:e,xmlns:"http://www.w3.org/2000/svg",className:r,onClick:n,children:l.jsx("g",{mask:"url(#mask0_6454_18843)",children:l.jsx("path",{d:"M5.8335 17.5C5.37516 17.5 4.9828 17.3368 4.65641 17.0104C4.33002 16.684 4.16683 16.2917 4.16683 15.8333V5C3.93072 5 3.7328 4.92014 3.57308 4.76042C3.41336 4.60069 3.3335 4.40278 3.3335 4.16667C3.3335 3.93056 3.41336 3.73264 3.57308 3.57292C3.7328 3.41319 3.93072 3.33333 4.16683 3.33333H7.50016C7.50016 3.09722 7.58002 2.89931 7.73975 2.73958C7.89947 2.57986 8.09738 2.5 8.3335 2.5H11.6668C11.9029 2.5 12.1009 2.57986 12.2606 2.73958C12.4203 2.89931 12.5002 3.09722 12.5002 3.33333H15.8335C16.0696 3.33333 16.2675 3.41319 16.4272 3.57292C16.587 3.73264 16.6668 3.93056 16.6668 4.16667C16.6668 4.40278 16.587 4.60069 16.4272 4.76042C16.2675 4.92014 16.0696 5 15.8335 5V15.8333C15.8335 16.2917 15.6703 16.684 15.3439 17.0104C15.0175 17.3368 14.6252 17.5 14.1668 17.5H5.8335ZM5.8335 5V15.8333H14.1668V5H5.8335ZM7.50016 13.3333C7.50016 13.5694 7.58002 13.7674 7.73975 13.9271C7.89947 14.0868 8.09738 14.1667 8.3335 14.1667C8.56961 14.1667 8.76752 14.0868 8.92725 13.9271C9.08697 13.7674 9.16683 13.5694 9.16683 13.3333V7.5C9.16683 7.26389 9.08697 7.06597 8.92725 6.90625C8.76752 6.74653 8.56961 6.66667 8.3335 6.66667C8.09738 6.66667 7.89947 6.74653 7.73975 6.90625C7.58002 7.06597 7.50016 7.26389 7.50016 7.5V13.3333ZM10.8335 13.3333C10.8335 13.5694 10.9134 13.7674 11.0731 13.9271C11.2328 14.0868 11.4307 14.1667 11.6668 14.1667C11.9029 14.1667 12.1009 14.0868 12.2606 13.9271C12.4203 13.7674 12.5002 13.5694 12.5002 13.3333V7.5C12.5002 7.26389 12.4203 7.06597 12.2606 6.90625C12.1009 6.74653 11.9029 6.66667 11.6668 6.66667C11.4307 6.66667 11.2328 6.74653 11.0731 6.90625C10.9134 7.06597 10.8335 7.26389 10.8335 7.5V13.3333Z"})})}),Ju=t=>{const{show:e,isFlowDashboard:r,onClose:n,actionItems:i,selectedItemsCount:a,deleteConfig:s,showActionBg:o}=t,{t:A}=Xt.useTranslation(),[u,c]=h.useState(!1),[d,f]=h.useState(!0),p=h.useRef(null),m=h.useRef(null);h.useEffect(()=>{const b=new ResizeObserver(()=>{if(p.current&&m.current){const _=p.current.scrollWidth-100;i.length*180+100>_?f(!1):f(!0)}});return p.current&&b.observe(p.current),()=>{p.current&&b.unobserve(p.current)}});const g={label:A("Delete"),icon:l.jsx(XR,{size:16,className:"text-error-500"}),onClick:s?.onClick,...s},y=i.filter(b=>b.visible!==!1).map((b,_)=>({key:_,label:l.jsx(Er,{icon:b.dropdownIcon,text:b?.label||"",onClick:b.onClick,className:"font-inter text-[14px] font-medium text-black-900 dark:text-black-200 gap-1.5"}),children:b.dropdownItems,disabled:!1}));return e?l.jsx(Ve.motion.div,{initial:{y:20,opacity:0},animate:{y:0,opacity:1},exit:{y:20,opacity:0},transition:{duration:.2,ease:[.4,0,.2,1],opacity:{duration:.15}},ref:p,className:F("h-[40px]",r?"ml-60 w-1/2":"w-full"),children:l.jsxs("div",{className:F("h-[40px] border py-1.5 px-2 text-white bg-primary-800 dark:bg-black-700 flex justify-between items-center"),children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx(or,{tooltip:"Close",variant:"ghost",onClick:n,className:"hover:bg-primary-100 !p-0",children:l.jsx(VR,{size:20})}),l.jsxs("div",{className:"flex items-center gap-1.5 ml-2",children:[l.jsx("span",{className:"text-primary-600 dark:text-black-100 bg-primary-50 dark:bg-black-800 border-primary-200 dark:border-black-800 text-xs leading-4 font-normal border rounded-full pr-2 pl-2",children:a||0}),l.jsx(ne,{size:"extra-small",appearance:"custom",className:"text-white",children:A("Selected")})]})]}),l.jsx("div",{ref:m,className:F("h-[36px] flex items-center rounded-full font-inter",o?"bg-primary-900 dark:bg-black-800 px-[10px] rounded-[43px]":""),children:d?l.jsxs(Ve.motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"flex bg-primary-800 dark:bg-black-800 px-4 rounded-full",children:[i.map((b,_)=>b.visible!==!1&&l.jsx("div",{children:b.type==="dropdown"?l.jsx(Ze.Dropdown,{menu:{items:b.dropdownItems},trigger:[b.dropdownTrigger||"click"],overlayClassName:"!min-w-[148px]",placement:"bottomRight",getPopupContainer:v=>v.parentElement,open:u,onOpenChange:c,children:l.jsx("button",{id:`btn-floating-bar-${b.label}`,onClick:b.onClick,disabled:b.disabled,className:F(b?.label?"flex items-center mx-1 gap-1.5 py-1 pr-3 pl-2 rounded-md text-white hover:text-primary-50 transition-all duration-300 bg-transparent":"bg-transparent p-1.5 hover:bg-primary-800 rounded-xl",b?.hideLabel&&"!p-1.5",(b.label==="Delete"||b.label==="Remove"||b.label==="Move to trash"||b.label==="Permanent delete")&&"!text-error-500",b.disabled&&"opacity-70"),children:l.jsxs(Te,{hideTooltip:!b.tooltip,title:b.tooltip,className:"flex items-center",children:[b.icon,!b?.hideLabel&&b.label&&l.jsx(ne,{size:"small",variant:"medium",className:"text-inherit",appearance:"custom",children:b.label})]})},_)}):l.jsx("button",{id:`btn-floating-bar-${b.label}`,onClick:b.onClick,disabled:b.disabled,className:F(b?.label?"flex items-center mx-1 gap-1.5 py-1 pr-3 pl-2 rounded-md text-white hover:text-primary-50 transition-all duration-300 bg-transparent":"bg-transparent p-1.5 hover:bg-primary-800 rounded-xl",b?.hideLabel&&"!p-1.5",(b.label==="Delete"||b.label==="Remove"||b.label==="Move to trash"||b.label==="Permanent delete")&&"!text-error-500",b.disabled&&"opacity-70"),children:l.jsxs(Te,{hideTooltip:!b.tooltip,title:b.tooltip,className:"flex items-center",children:[b.icon,!b?.hideLabel&&b.label&&l.jsx(ne,{size:"small",variant:"medium",className:"text-inherit",appearance:"custom",children:b.label})]})})},_)),s?l.jsxs("button",{id:`btn-floating-bar-${g.label}`,onClick:g.onClick,disabled:g.disabled,className:F("flex items-center gap-1.5 py-1 pr-3 pl-2 rounded-md",g.disabled&&"opacity-70"),children:[g.icon,l.jsx(ne,{size:"small",variant:"medium",className:"text-error-500",appearance:"custom",children:g.label})]}):null]}):l.jsxs(Ve.motion.div,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.2},className:"minw-[150px] p-1.5 flex items-center",children:[l.jsx(Ze.Dropdown,{menu:{items:y},trigger:["click"],overlayClassName:"!min-w-[148px]",placement:"bottomRight",getPopupContainer:b=>b.parentElement,open:u,onOpenChange:c,children:l.jsxs("button",{id:"btn-floating-bar-actions",disabled:!1,className:"flex items-center gap-1.5 px-2 py-1 w-22 h-7 rounded-full bg-primary-700",type:"button",children:[l.jsx(ne,{size:"small",variant:"medium",className:"text-white",children:A("Actions")}),l.jsx(WR,{fill:"#FFFFFF",className:"w-[16px] h-[16px]"})]})}),s?l.jsxs("button",{id:`btn-floating-bar-${g.label}`,onClick:g.onClick,disabled:g.disabled,className:F("flex items-center gap-1.5 py-1 pr-3 pl-2 rounded-md",g.disabled&&"opacity-70"),type:"button",children:[g.icon,l.jsx(ne,{size:"small",variant:"medium",className:"text-error-500",appearance:"custom",children:g.label})]}):null]})})]})}):null};Ju.displayName="FloatingBar";const QR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-white",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"})}),GR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-white",children:l.jsx("path",{d:"M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm-1 4l6 6v10c0 1.1-.9 2-2 2H7.99C6.89 23 6 22.1 6 21l.01-14c0-1.1.89-2 1.99-2h7zm-1 7h5.5L14 6.5V12z"})}),YR=()=>l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",className:"text-[#F04438]",children:l.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"})}),BS=()=>{const{selectedTopLevelPaths:t,setSelectedPaths:e,handleDelete:r,handleDuplicate:n,handleCopy:i}=bs(),[a,s]=h.useState(!1),o=[{id:"copy",icon:l.jsx(QR,{}),tooltip:"Copy",label:"Copy",hideLabel:!0,onClick:()=>i(t)},{id:"duplicate",icon:l.jsx(GR,{}),tooltip:"Duplicate",label:"Duplicate",hideLabel:!0,onClick:()=>n(t)},{id:"delete",icon:l.jsx(YR,{}),tooltip:"Delete",label:"Delete",hideLabel:!0,onClick:()=>s(!0)}];return l.jsxs(l.Fragment,{children:[l.jsx(zS,{title:"Delete Keys",content:"Are you sure you want to delete the selected keys?",visible:a,variant:"destructive",onClose:()=>s(!1),onConfirm:()=>{r(t),e([]),s(!1)}}),l.jsx(Ju,{show:t.length>0,onClose:()=>e([]),actionItems:o,showActionBg:!0,selectedItemsCount:t.length})]})},KR=t=>{if(t===Ie.BOOLEAN)return!1;if(t===Ie.STRING)return"";if(t===Ie.NUMBER)return 0;if(t===Ie.NULL)return null;if(t===Ie.ARRAY)return[];if(t===Ie.OBJECT)return{}},qS=({isVisible:t,onClose:e,parentContainer:r})=>{const[n,i]=h.useState(""),[a,s]=h.useState(OA[0]),[o,A]=h.useState(null),[u,c]=h.useState(""),[d,f]=h.useState(null),{handleAddKey:p,selectedPathModification:m}=bs();h.useEffect(()=>{a.value===Ie.BOOLEAN?A(!1):a.value===Ie.STRING?A(""):a.value===Ie.NUMBER?A(0):a.value===Ie.NULL?A(null):a.value===Ie.ARRAY?(A([]),c("")):a.value===Ie.OBJECT&&(A({}),c(""))},[a]);const g=()=>{i(""),s(OA[0]),A(null),c(""),e(),f(null)};h.useEffect(()=>{if(a.value===Ie.ARRAY||a.value===Ie.OBJECT){if(u.trim()===""){f(null);return}try{const b=JSON.parse(u);a.value===Ie.ARRAY&&!Array.isArray(b)?f("Enter a valid JSON array."):a.value===Ie.OBJECT&&(typeof b!="object"||b===null||Array.isArray(b))?f("Enter a valid JSON object."):f(null)}catch{f("Enter valid JSON.")}}},[u,a]);const y=()=>o===null&&a.value===Ie.NULL?null:!o&&o!==0&&o!==!1?KR(a.value):a.value===Ie.NUMBER?Number(o):o;return l.jsx(pn,{open:t,onCancel:g,title:"New Key",parentContainer:r,width:351,asForm:!0,footer:l.jsx("div",{className:"flex justify-end mt-5 gap-4",children:l.jsx(bt,{id:"btn-add-key-modal-add",status:"primary",onClick:async()=>{await p(m||"",n,y()),g()},disabled:!n||o===null&&a.value!==Ie.NULL||!!d,children:"Add"})}),children:l.jsxs("div",{className:"flex flex-col gap-4",children:[l.jsx(Hi,{required:!0,label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Key"}),value:n,onChange:b=>i(b),placeholder:"Enter key"}),l.jsx(al,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Type"}),options:OA,value:a,onChange:b=>s(b)}),(()=>{switch(a.value){case Ie.NULL:return null;case Ie.BOOLEAN:return l.jsx(Zn,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Value"}),isChecked:!!o,onChange:b=>A(b),statusText:o?"true":"false"});case Ie.OBJECT:case Ie.ARRAY:return l.jsx(Eb,{placeholder:a.value===Ie.ARRAY?"e.g. [1, 2, 3]":'e.g. {"key_1" : 1, "key_2":2}',onChange:b=>{const _=b;if(c(_),_.trim()==="")A(a.value===Ie.ARRAY?[]:{});else try{const v=JSON.parse(_);A(v)}catch{}}});default:return l.jsx(Hi,{label:l.jsx("span",{className:"text-neutral-600 dark:text-white text-xs font-medium",children:"Value"}),className:"w-full",value:o,onChange:b=>{if(a.value===Ie.NUMBER){const v=b.replace(/\.(?=.*\.)/g,"").replace(/[^\d.-]/g,"");A(v)}else A(b)},placeholder:"Enter value"})}})()]})})},ec=({isFullScreen:t,allExpanded:e,toggleAll:r,isEditMode:n,isDarkMode:i,style:a,value:s,onChange:o,setIsAddKeyModalOpen:A,isAddKeyModalOpen:u})=>{const[c,d]=h.useState({}),[f,p]=h.useState(null),[m,g]=h.useState([]),[y,b]=h.useState([]),[_,v]=h.useState(null),[S,k]=h.useState(null);h.useEffect(()=>{b(MS(m))},[m]),h.useEffect(()=>{try{const C=jS(s);d(C),p(null)}catch(C){p("Invalid JSON: "+C.message)}},[s]);const E=C=>{if(!C.length)return;const N=Gc.produce(c,P=>{C.forEach(L=>{if(!L||L===".")return;const R=L.split(".");if(R.shift(),R.length===0)return;let D=P;for(let I=0;I<R.length-1;I++)if(D=D[R[I]],D===void 0)return;const H=R[R.length-1];if(Array.isArray(D)){const I=Number(H);!isNaN(I)&&I>=0&&I<D.length&&D.splice(I,1)}else D&&typeof D=="object"&&delete D[H]})});o?.(JSON.stringify(N,null,2))},w=C=>{if(!C.length)return;const N=Gc.produce(c,P=>{C.forEach(L=>{const R=L.split(".");R[0]===""&&R.shift();let D=P;for(let I=0;I<R.length-1;I++)if(D=D[R[I]],D===void 0)return;const H=R[R.length-1];if(Array.isArray(D)){const I=Number(H);if(!isNaN(I)&&I>=0&&I<D.length){const M=JSON.parse(JSON.stringify(D[I]));D.splice(I+1,0,M)}}else if(D&&typeof D=="object"&&Object.hasOwn(D,H)){let I=H+"_copy",M=2;for(;Object.hasOwn(D,I);)I=`${H}_copy_${M++}`;D[I]=JSON.parse(JSON.stringify(D[H]))}})});o?.(JSON.stringify(N,null,2))},T=async C=>{if(!C.length)return!1;if(C.length===1){const N=C[0].split(".");N[0]===""&&N.shift();let P=c;for(const R of N){if(P==null)return!1;P=P[R]}if(P===void 0)return!1;let L;typeof P=="object"?L=JSON.stringify(P,null,2):L=String(P);try{return await navigator.clipboard.writeText(L),!0}catch{return!1}}else{const N={};for(const P of C){const L=P.split(".");L[0]===""&&L.shift();let R=c;for(const D of L)R!=null&&(R=R[D]);if(R!==void 0){const D=L[L.length-1]||"root";N[D]=R}}try{return await navigator.clipboard.writeText(JSON.stringify(N,null,2)),!0}catch{return!1}}},O=async(C,N,P)=>{const L=C.split(".");L[0]===""&&L.shift();const R=Gc.produce(c,D=>{let H=D;if(L.length===0){if(Object.hasOwn(H,N)){let I=N,M=2;for(;Object.hasOwn(H,I);)I=`${N}_${M++}`;H[I]=P}else H[N]=P;return}for(let I=0;I<L.length;I++)if(H=H[L[I]],H===void 0)return;if(Object.hasOwn(H,N)){let I=N,M=2;for(;Object.hasOwn(H,I);)I=`${N}_${M++}`;H[I]=P}else H[N]=P});v(null),o?.(JSON.stringify(R,null,2))};return l.jsx(LS,{value:{allExpanded:e,toggleAll:r,isEditMode:n,isDarkMode:i,selectedPaths:m,setSelectedPaths:g,selectedTopLevelPaths:y,setSelectedTopLevelPaths:b,selectedPathModification:_,setSelectedPathModification:v,selectedPathForEdit:S,setSelectedPathForEdit:k,jsonData:c,setJsonData:d,error:f,setError:p,handleDelete:E,handleDuplicate:w,handleCopy:T,handleAddKey:O,setIsAddKeyModalOpen:A,isAddKeyModalOpen:u},children:l.jsxs("div",{className:"bg-white dark:bg-black-800 rounded-b-lg",children:[n&&l.jsx(BS,{}),l.jsx(US,{onChange:o,style:a}),n&&l.jsx(qS,{parentContainer:t?"json-grid-core-container":"full-screen-container",isVisible:u,onClose:()=>A(!1)})]})})},Qi=F("text-neutral-600 cursor-pointer hover:text-neutral-800","dark:text-neutral-300 dark:hover:text-neutral-50"),ZR=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",children:l.jsx("path",{d:"M19 13h-6v6h-2v-6H5v-2h6V5h2v6h6v2z"})}),$R=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M19 2h-4.18C14.4.84 13.3 0 12 0S9.6.84 9.18 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z"})}),JR=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M9.5 2c-1.82 0-3.53.5-5 1.35 2.99 1.73 5 4.95 5 8.65s-2.01 6.92-5 8.65c1.47.85 3.18 1.35 5 1.35 5.52 0 10-4.48 10-10S15.02 2 9.5 2z"})}),eP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zm-1-4-5 5-5-5h3V4h4v7h3z"})}),tP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z"})}),rP=({fontSize:t})=>l.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:[l.jsx("path",{d:"M18 6.41 16.59 5 12 9.58 7.41 5 6 6.41l6 6z"}),l.jsx("path",{d:"m18 13-1.41-1.41L12 16.17l-4.59-4.58L6 13l6 6z"})]}),nP=({fontSize:t})=>l.jsxs("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:[l.jsx("path",{d:"M6 17.59 7.41 19 12 14.42 16.59 19 18 17.59l-6-6z"}),l.jsx("path",{d:"m6 11 1.41 1.41L12 7.83l4.59 4.58L18 11l-6-6z"})]}),iP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M12 9c1.65 0 3 1.35 3 3s-1.35 3-3 3-3-1.35-3-3 1.35-3 3-3m0-2c-2.76 0-5 2.24-5 5s2.24 5 5 5 5-2.24 5-5-2.24-5-5-5zM2 13h2c.55 0 1-.45 1-1s-.45-1-1-1H2c-.55 0-1 .45-1 1s.45 1 1 1zm18 0h2c.55 0 1-.45 1-1s-.45-1-1-1h-2c-.55 0-1 .45-1 1s.45 1 1 1zM11 2v2c0 .55.45 1 1 1s1-.45 1-1V2c0-.55-.45-1-1-1s-1 .45-1 1zm0 18v2c0 .55.45 1 1 1s1-.45 1-1v-2c0-.55-.45-1-1-1s-1 .45-1 1zM5.99 4.58c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0s.39-1.03 0-1.41L5.99 4.58zm12.37 12.37c-.39-.39-1.03-.39-1.41 0-.39.39-.39 1.03 0 1.41l1.06 1.06c.39.39 1.03.39 1.41 0 .39-.39.39-1.03 0-1.41l-1.06-1.06zm1.06-10.96c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06zM7.05 18.36c.39-.39.39-1.03 0-1.41-.39-.39-1.03-.39-1.41 0l-1.06 1.06c-.39.39-.39 1.03 0 1.41s1.03.39 1.41 0l1.06-1.06z"})}),aP=({fontSize:t})=>l.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"currentColor",className:Qi,children:l.jsx("path",{d:"M14 17H4v2h10v-2zm6-8H4v2h16V9zM4 15h16v-2H4v2zM4 5v2h16V5H4z"})}),VS=({value:t,onChange:e=()=>!1,withFullScreen:r=!0,withTheme:n=!0,isEditMode:i=!1,height:a="55vh",language:s="json",monacoEditor:o,isShowCopy:A=!0,isShowDownload:u=!0,setIsDisableSave:c,withJsonGrid:d=!0,editorTheme:f,setEditorTheme:p,theme:m,className:g,enableAutoFormatting:y=!0,renderToolbarActions:b,onBlockClick:_,focusBlock:v,focusBlockTopLevelOnly:S=!1})=>{const k=h.useRef(null),[E,w]=h.useState("vs"),[T,O]=h.useState("light"),C=f??E,N=m??T,P=p??(Q=>{w(Q),O(Q==="vs-dark"?"dark":"light")}),[L,R]=h.useState(!1),[D,H]=h.useState(null),I=NS(),M=o||I,{handleFormatCode:z,pythonError:V,pythonLoading:X}=DS({code:t,setCode:e,currentEditorModel:D,monacoEditor:M,enable:i===!0&&s==="python"}),ee=GA.useFullScreenHandle(),[W,B]=h.useState("JSON"),[Y,re]=h.useState(!1),G=s==="json",K=()=>{ee?.active?ee.exit():ee.enter()},te=h.useRef(_);te.current=_;const $=h.useCallback(async(Q,se,ke)=>{if(!te.current)return;const Ue=Q.getModel();if(!Ue)return;const Ge=(Fe,we)=>Ue.getValueInRange({startLineNumber:Fe,startColumn:1,endLineNumber:we,endColumn:Ue.getLineMaxColumn(we)}),Je=(Fe,we,Pe,ge,De)=>{te.current({startLine:Fe,endLine:we,text:Pe,kind:ge,cursorLine:se,cursorColumn:ke,parentBlock:De})};try{const Fe=Q.getContribution("editor.contrib.folding");if(Fe){const Le=await Fe.getFoldingModel();if(Le?.regions){const Ye=Le.regions,lt=Ue.getLineCount(),nt=[];for(let et=0;et<Ye.length;et++){const Xe=Ye.getStartLineNumber(et),mt=Ye.getEndLineNumber(et),je=Math.min(mt+1,lt),Qe=je-Xe;if(se>=Xe&&se<=je){const Ke=Ye.getType(et),Et=Ke===1?"comment":Ke===2?"imports":Ke===3?"region":void 0;nt.push({start:Xe,end:je,size:Qe,kind:Et})}}if(nt.length>0){nt.sort((Qe,Ke)=>Qe.size-Ke.size);const et=nt[0],Xe=Ge(et.start,et.end);let mt;for(let Qe=nt.length-1;Qe>0;Qe--){const Ke=nt[Qe];if(!(Ke.start<=1&&Ke.end>=lt)){mt=Ke;break}}const je=mt&&mt!==et?{startLine:mt.start,endLine:mt.end,text:Ge(mt.start,mt.end),kind:mt.kind}:void 0;Je(et.start,et.end,Xe,et.kind,je);return}}}const we={lineNumber:se,column:ke},Pe=Ue.bracketPairs?.findEnclosingBrackets?.(we);if(Pe&&Pe.length===2){const[Le,Ye]=Pe,lt=Le.startLineNumber,nt=Ye.endLineNumber,et=Ge(lt,nt);Je(lt,nt,et);return}const ge=Ue.getLineCount(),De=Ue.getValue();Je(1,ge,De)}catch{}},[]);h.useEffect(()=>{if(!v||!k.current)return;const Q=k.current,se=Q.getModel();if(!se)return;const ke=se.findMatches(v,!0,!1,!0,null,!1);if(ke.length===0)return;let Ue=ke[0];if(S&&ke.length>1){let we=1/0;for(const Pe of ke){const ge=se.getLineContent(Pe.range.startLineNumber),De=ge.length-ge.trimStart().length;De<we&&(we=De,Ue=Pe)}}const Ge=Ue.range.startLineNumber,Je=Ue.range.startColumn;Q.setPosition({lineNumber:Ge,column:Je}),Q.revealLineInCenter(Ge,1);const Fe=async()=>{try{const we=Q.getContribution("editor.contrib.folding");if(we){const De=await we.getFoldingModel();if(De?.regions){const Le=De.regions;let Ye=-1,lt=-1,nt=1/0;for(let et=0;et<Le.length;et++){const Xe=Le.getStartLineNumber(et),mt=Le.getEndLineNumber(et),je=Math.min(mt+1,se.getLineCount()),Qe=je-Xe;Ge>=Xe&&Ge<=je&&Qe<nt&&(Ye=Xe,lt=je,nt=Qe)}if(Ye!==-1){Q.setSelection({startLineNumber:Ye,startColumn:1,endLineNumber:lt,endColumn:se.getLineMaxColumn(lt)}),Q.revealRangeInCenter({startLineNumber:Ye,startColumn:1,endLineNumber:lt,endColumn:se.getLineMaxColumn(lt)},1);return}}}const Pe={lineNumber:Ge,column:Je},ge=se.bracketPairs?.findEnclosingBrackets?.(Pe);if(ge&&ge.length===2){const[De,Le]=ge;Q.setSelection({startLineNumber:De.startLineNumber,startColumn:1,endLineNumber:Le.endLineNumber,endColumn:se.getLineMaxColumn(Le.endLineNumber)}),Q.revealRangeInCenter({startLineNumber:De.startLineNumber,startColumn:1,endLineNumber:Le.endLineNumber,endColumn:se.getLineMaxColumn(Le.endLineNumber)},1);return}Q.setSelection(Ue.range)}catch{Q.setSelection(Ue.range)}};requestAnimationFrame(()=>{Fe()})},[v,S]);const oe=Q=>{k.current=Q;const se=()=>{try{if(s==="python"){const ke=Q.getModel();ke&&H(ke)}s==="json"&&y&&requestAnimationFrame(()=>{ye()})}catch(ke){console.warn("Failed to initialize editor:",ke)}};if(Q.getModel())se();else{const ke=Q.onDidChangeModel(()=>{se(),ke.dispose()})}te.current&&Q.onMouseDown(()=>{requestAnimationFrame(()=>{const ke=Q.getPosition();ke&&$(Q,ke.lineNumber,ke.column)})})},Me=()=>{try{const Q=JSON.parse(t),se=JSON.stringify(Q,null,4);e(se),D&&M&&M.editor.setModelMarkers(D,"json",[])}catch(Q){if(D&&M){const se=Q instanceof Error?Q.message:"Invalid JSON";try{M.editor.setModelMarkers(D,"json",[{startLineNumber:1,startColumn:1,endLineNumber:1,endColumn:1,message:`Cannot format: ${se}`,severity:M.MarkerSeverity.Error}])}catch(ke){console.warn("Failed to set JSON error markers:",ke)}}}},ye=()=>{if(s==="python"){z();return}if(s==="json"){Me();return}if(k.current)try{const Q=k.current.getAction("editor.action.formatDocument");Q&&Q.run()}catch(Q){console.warn("Failed to format document:",Q)}},me=Q=>{typeof Q=="string"&&e(Q)};if(h.useEffect(()=>{c&&c(V||X)},[V,X,c]),!o&&!I)return l.jsx("div",{className:"flex items-center justify-center p-8 border border-neutral-200 dark:border-neutral-700 rounded-lg",children:l.jsx("div",{className:"text-neutral-600 dark:text-neutral-400",children:"Loading editor..."})});const fe=F("hover:bg-neutral-300 hover:dark:bg-neutral-700 p-0.5 rounded-md flex items-center justify-center"),pe=()=>{if(s==="python")try{let Q=t;Q&&(Q=Q.replace(/\r\n/g,`
82
82
  `).replace(/\r/g,`
83
83
  `),Q=Q.split(`
84
84
  `).map(se=>se.trimEnd()).join(`