@gisce/react-ooui 1.4.14 → 1.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-ooui.es.js +19 -9
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +2 -2
- package/dist/react-ooui.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/iconMapper.ts +1 -2
- package/src/stories/dashboard/DashboardGrid.stories.tsx +13 -0
- package/src/widgets/views/Graph/GraphIndicator.tsx +3 -3
package/dist/react-ooui.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(U,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("antd"),require("@gisce/ooui"),require("@ant-design/icons"),require("interweave"),require("react/jsx-runtime"),require("@tabler/icons-react"),require("antd/lib/input/TextArea"),require("styled-components"),require("react-measure"),require("antd/lib/typography/Title"),require("@ant-design/plots"),require("use-deep-compare-effect"),require("@gisce/react-formiga-table"),require("file-type-buffer-browser"),require("antd/lib/_util/colors"),require("@gisce/fiber-diagram"),require("@gisce/react-formiga-components"),require("validator/lib/isURL"),require("validator/lib/isEmail"),require("react-hotkeys-hook"),require("react-markdown"),require("@monaco-editor/react"),require("md5"),require("react-grid-layout"),require("react-grid-layout/css/styles.css"),require("uuid")):typeof define=="function"&&define.amd?define(["exports","react","antd","@gisce/ooui","@ant-design/icons","interweave","react/jsx-runtime","@tabler/icons-react","antd/lib/input/TextArea","styled-components","react-measure","antd/lib/typography/Title","@ant-design/plots","use-deep-compare-effect","@gisce/react-formiga-table","file-type-buffer-browser","antd/lib/_util/colors","@gisce/fiber-diagram","@gisce/react-formiga-components","validator/lib/isURL","validator/lib/isEmail","react-hotkeys-hook","react-markdown","@monaco-editor/react","md5","react-grid-layout","react-grid-layout/css/styles.css","uuid"],l):(U=typeof globalThis<"u"?globalThis:U||self,l(U["react-ooui"]={},U.React,U.antd,U.ooui,U.AntIcons,U.interweave,U.jsxRuntime,U.TablerIcons,U.TextArea$1,U.styled,U.Measure,U.Title$3,U.plots,U.useDeepCompareEffect,U.reactFormigaTable,U.fileTypeBufferBrowser,U.colors,U.fiberDiagram,U.reactFormigaComponents,U.isURL,U.isEmail,U.reactHotkeysHook,U.ReactMarkdown,U.Editor,U.md5,U.reactGridLayout,null,U.uuid))})(this,function(U,l,p,se,H,Ht,e,fo,ho,po,go,mo,Kt,yo,vo,wo,gr,Co,mr,So,bo,xo,To,Fo,Oo,yr,Uc,vr){"use strict";const Ue=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function wr(t){if(t&&t.__esModule)return t;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const Be=Ue(l),Cr=wr(H),Sr=Ue(H),br=wr(fo),_o=Ue(ho),mt=Ue(po),Yt=Ue(go),Wt=Ue(mo),et=Ue(yo),Do=Ue(So),ko=Ue(bo),Mo=Ue(To),Vo=Ue(Fo),Eo=Ue(Oo),{Text:Io,Title:$o}=p.Typography,{useToken:Ao}=p.theme,Lo={left:"justify-start",center:"justify-center",right:"justify-end"},yt=t=>{const{ooui:r,align:n,responsiveBehaviour:s}=t,{label:o,tooltip:i,fieldForLabel:a,labelSize:c,labelType:h}=r,f=a!==null&&o.length>1?o+" :":o,g=n||(a?s?"left":"right":"left"),{token:w}=Ao(),y=c===void 0?Io:$o;return e.jsxs("div",{className:`flex flex-row items-center pb-1 pt-1 ${Lo[g]}`,children:[i&&e.jsx(p.Tooltip,{title:i,children:e.jsx(H.QuestionCircleOutlined,{className:"pr-1 text-xs",style:{color:w.colorPrimary}})}),e.jsx("span",{className:"pr-2",children:e.jsx(y,{level:c,type:h,children:e.jsx(Ht.Interweave,{content:f})})})]})},No={ca_ES:{true:"S\xED",false:"No",simple_search:"B\xFAsqueda simple",advanced_search:"B\xFAsqueda avan\xE7ada",search:"Buscar",parameters:"Par\xE0metres",limit:"Limit",first:"Primer",no_results:"No hi ha resultats",summary:"Mostrant resultats des de {from} fins {to} d'un total de {total} registres",welcome:"Benvingut",attachments:"Adjunts",addNewAttachment:"Afegir nou adjunt",listAllAttachments:"Veure tots els adjunts",viewAs:"Veure com",confirmRemoveItem:"Est\xE0s segur de volguer eliminar aquest item?",save:"Desar",delete:"Eliminar",refresh:"Refrescar",previous:"Anterior",next:"Seg\xFCent",actions:"Accions",reports:"Informes",related:"Relacionat",new:"Nou",fillRequiredField:"Siusplau, omple aquest camp obligatori",fillRequiredFields:"Siusplau, omple tots els camps obligatoris",generatingReport:"Generant informe...",confirmation:"Confirmaci\xF3",ok:"D'acord",cancel:"Cancel\xB7lar",formHasErrors:"El formulari t\xE9 errors",unsavedChanges:"Hi ha canvis sense guardar",confirmRefreshWithoutSave:"Est\xE0s segur de volguer refrescar la p\xE0gina sense guardar els canvis?",discardAndRefresh:"Descarta els canvis i refresca",removeItems:"Elimina el registre/s",confirmRemove:"Est\xE0s segur de volguer eliminar els registre/s seleccionats?",yesConfirmRemove:"S\xED, elimina",unlinkItems:"Desenlla\xE7a registre/s",confirmUnlink:"Est\xE0s segur de volguer desenlla\xE7ar els registre/s seleccionats?",yesConfirmUnlink:"S\xED, desenlla\xE7a",confirmCloseWithoutSave:"Est\xE0s segur de volguer tancar aquesta finestra sense guardar?",closeWithoutSaving:"Tancar sense guardar",action:"Acci\xF3",report:"Informe",selectAction:"Selecciona una acci\xF3",download:"Descarrega",clear:"Neteja",open:"Obre",uploadNewImage:"Puja una nova imatge",noCurrentEntries:"No hi ha registres",duplicate:"Duplicar",downloadingAttachment:"Descarregant adjunt...",tree:"llista",form:"formulari",favorites:"Els meus favorits",edit_favorites:"Edita els favorits",no_favorites:"No tens favorits guardats",register:"Registre",of:"de",editingDocument:"Editant document",showLogs:"Veure logs",createdBy:"Creat per l'usuari",creationDate:"Data creaci\xF3",lastUpdatedBy:"\xDAltima modificaci\xF3 per",lastUpdatedDate:"Data \xFAltima modificaci\xF3",goToResourceId:"V\xE9s al recurs amb ID",searchId:"ID de cerca:",idNotFound:"No es troba aquesta id de recurs per l'objecte",selectedRegisters:"registres seleccionats",translate:"Tradu\xEFr",enterTextBeforeTranslate:"Introdueix algun text al camp abans d'afegir traduccions",saveBeforeTranslate:"Heu de desar el registre abans d'afegir les traduccions",configDashboard:"Configurar panell",moveDashboard:"Moure items del panell",openAttachment:"Veure detall de l'adjunt",openAttachmentLink:"Obrir enlla\xE7 de l'adjunt",uninformed:"Sense informar",totalRegisters:"Registres totals:",export:"Exportar",selectAtLeastOneField:"Selecciona almenys un camp per a l'exportaci\xF3",printScreen:"Imprimir pantalla",advancedExport:"Exportaci\xF3 avan\xE7ada",savedRegisters:"Registre guardat correctament",errorWhileSavingForm:"Error en guardar el formulari",autor:"Autor"},en_US:{true:"Yes",false:"No",simple_search:"Simple search",advanced_search:"Advanced search",search:"Search",parameters:"Parameters",limit:"Limit",first:"First",no_results:"No results",summary:"Showing registers from {from} to {to} of {total} registers",welcome:"Welcome",attachments:"Attachments",addNewAttachment:"Add new attachment",listAllAttachments:"View all the attachments",viewAs:"View as",confirmRemoveItem:"Are you sure to remove this item?",save:"Save",delete:"Delete",refresh:"Refresh",previous:"Previous",next:"Next",actions:"Actions",reports:"Reports",related:"Related",new:"New",fillRequiredField:"Please fill this required field",fillRequiredFields:"Please fill all the required fields",generatingReport:"Generating report...",confirmation:"Confirmation",ok:"OK",cancel:"Cancel",formHasErrors:"Form has errors",unsavedChanges:"There are unsaved changes",confirmRefreshWithoutSave:"Do you really want to refresh this window without saving?",discardAndRefresh:"Discard changes and refresh",removeItems:"Remove item/s",confirmRemove:"Are you sure you want to remove the selected item/s?",yesConfirmRemove:"Yes, remove",unlinkItems:"Unlink item/s",confirmUnlink:"Are you sure you want to unlink the selected item/s?",yesConfirmUnlink:"Yes, unlink",confirmCloseWithoutSave:"Do you really want to close this window without saving?",closeWithoutSaving:"Close without saving",action:"Action",report:"Report",selectAction:"Select an action",download:"Download",clear:"Clear",open:"Open",uploadNewImage:"Upload new image",noCurrentEntries:"No current entries",duplicate:"Duplicate",downloadingAttachment:"Downloading attachment...",tree:"list",form:"form",favorites:"My shortcuts",edit_favorites:"Edit shortcuts",no_favorites:"You don't have any shortcuts saved yet",register:"Register",of:"of",editingDocument:"Editing document",showLogs:"Show logs",createdBy:"Created by user",creationDate:"Creation date",lastUpdatedBy:"Last modified by",lastUpdatedDate:"Date of last modification",goToResourceId:"Go to resource ID",searchId:"Search ID:",idNotFound:"Resource ID does not exist for this object!",selectedRegisters:"selected registers",translate:"Translate",enterTextBeforeTranslate:"Enter some text to the related field before adding translations",saveBeforeTranslate:"You must save the record before adding translations",configDashboard:"Setup dashboard",moveDashboard:"Move dashboard items",openAttachment:"Open attachment detail",openAttachmentLink:"Open attachment link",uninformed:"Uninformed",totalRegisters:"Total registers:",export:"Export",selectAtLeastOneField:"Select at least one field for the export",printScreen:"Print screen",advancedExport:"Advanced export",savedRegisters:"Record successfully saved",errorWhileSavingForm:"Error while saving form",author:"Author"},es_ES:{true:"S\xED",false:"No",simple_search:"B\xFAsqueda simple",advanced_search:"B\xFAsqueda avanzada",search:"Buscar",parameters:"Parametros",limit:"L\xEDmite",first:"Primero",no_results:"No hay resultados",summary:"Mostrando resultado desde {from} hasta {to} de un total de {total} registros",welcome:"Bienvenido",attachments:"Adjuntos",addNewAttachment:"A\xF1adir nuevo adjunto",listAllAttachments:"Ver todos los adjuntos",viewAs:"Ver c\xF3mo",confirmRemoveItem:"Est\xE1s seguro de querer eliminar \xE9ste registro?",save:"Guardar",delete:"Eliminar",refresh:"Refrescar",previous:"Anterior",next:"Siguiente",actions:"Acciones",reports:"Informes",related:"Relacionado",new:"Nuevo",fillRequiredField:"Por favor, rellena \xE9ste campo obligatorio",fillRequiredFields:"Por favor, rellena todos los campos obligatorios",generatingReport:"Generando informe...",confirmation:"Confirmaci\xF3m",ok:"De acuerdo",cancel:"Cancelar",formHasErrors:"El formulario tiene errores",unsavedChanges:"Hay cambios sin guardar",confirmRefreshWithoutSave:"Est\xE1s seguro de querer refrescar la p\xE1gina sin guardar los cambios?",discardAndRefresh:"Descarta los cambios y refresca",removeItems:"Eliminar el registro/s",confirmRemove:"Est\xE1s seguro de querer eliminar los registro/s seleccionados?",yesConfirmRemove:"S\xED, elimina",unlinkItems:"Desenlaza registro/s",confirmUnlink:"Est\xE1s seguro de querer desenlazar los registro/s seleccionados?",yesConfirmUnlink:"S\xED, desenlaza",confirmCloseWithoutSave:"Est\xE1s seguro de querer cerrar \xE9sta ventana sin cerrar?",closeWithoutSaving:"Cerrar sin guardar",action:"Acci\xF3n",report:"Informe",selectAction:"Selecciona una acci\xF3n",download:"Descarga",clear:"Limpiar",open:"Abrir",uploadNewImage:"Subir una nueva im\xE1gen",noCurrentEntries:"No hay registros",duplicate:"Duplicar",downloadingAttachment:"Descargando adjunto...",tree:"lista",form:"formulario",favorites:"Mis favoritos",edit_favorites:"Edita los favoritos",no_favorites:"No tienes favoritos guardados",register:"Registro",of:"de",editingDocument:"Editando documento",showLogs:"Ver logs",createdBy:"Creado por el usuario",creationDate:"Fecha creaci\xF3n",lastUpdatedBy:"\xDAltima modificaci\xF3n por",lastUpdatedDate:"Fecha \xFAltima modificaci\xF3n",goToResourceId:"Ir al recurso con ID",searchId:"ID de b\xFAsqueda:",idNotFound:"No se encuentra \xE9sta ID de recursos para el objeto",selectedRegisters:"registros seleccionados",translate:"Traducir",enterTextBeforeTranslate:"Introduce algun texto en el campo antes de a\xF1adir traducciones",saveBeforeTranslate:"Tienes que guardar el registro antes de a\xF1adir las traducciones",configDashboard:"Configurar panel",moveDashboard:"Mover items del panel",openAttachment:"Ver detalle del adjunto",openAttachmentLink:"Abrir enlace del adjunto",uninformed:"Sin informar",totalRegisters:"Registros totales:",export:"Exportar",selectAtLeastOneField:"Selecciona al menos un campo para la exportaci\xF3n",printScreen:"Imprimir pantalla",advancedExport:"Exportaci\xF3n avanzada",savedRegisters:"Registro guardado correctamente",errorWhileSavingForm:"Error al guardar el formulario",author:"Autor"}},ge=Be.default.createContext(null),Po=t=>{const{children:r,lang:n}=t;function s(o){return be(o,n)}return e.jsx(ge.Provider,{value:{lang:n,t:s},children:r})},be=(t,r)=>{var s;return((s=No[r])==null?void 0:s[t])||t};function me({ooui:t,children:r,layout:n="horizontal",valuePropName:s,showLabel:o=!1,alignLabel:i="left",required:a=!1,type:c,validator:h}){const{id:d,label:f,tooltip:u}=t,{t:g}=l.useContext(ge),w=a?[{required:!0,message:g("fillRequiredField"),type:c,validator:h}]:void 0,y=()=>e.jsx(p.Form.Item,{className:"mb-0",name:d,valuePropName:s,rules:w,children:r});if(!o)return y();const m=e.jsx(yt,{ooui:new se.Label({name:d+"_label",string:f,help:u,fieldForLabel:d}),align:i});return n==="horizontal"?(()=>e.jsxs(p.Row,{align:"middle",className:"pb-1 pt-1",children:[e.jsx(p.Col,{className:"ml-2",flex:"7rem",children:e.jsx("div",{className:"flex flex-col items-end",children:m})}),e.jsx(p.Col,{flex:"auto",children:y()})]}))():(()=>e.jsxs(e.Fragment,{children:[m,y()]}))()}const{confirm:Bo}=p.Modal,ot=({onOk:t,confirmMessage:r,lang:n})=>{Bo({title:be("confirmation",n),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:r,okText:be("ok",n),cancelText:be("cancel",n),onOk:t})},Ve=Be.default.createContext(null),Ho=t=>{const{children:r,activeId:n,activeModel:s,setFieldValue:o,getFieldValue:i,executeButtonAction:a,getContext:c,getValues:h,getPlainValues:d,domain:f,submitForm:u,fetchValues:g,formHasChanges:w,elementHasLostFocus:y,getFields:m}=t;return e.jsx(Ve.Provider,{value:{domain:f,getValues:h,getPlainValues:d,getFields:m,activeId:n,activeModel:s,setFieldValue:o,getFieldValue:i,executeButtonAction:a,getContext:c,submitForm:u,fetchValues:g,formHasChanges:w,elementHasLostFocus:y},children:r})},xr={"terp-purchase":"ShoppingCart","terp-graph":"PieChart","terp-crm":"Contacts","terp-hr":"Friends","terp-account":"BuildingBank","terp-project":"Checklist","terp-administration":"Adjustments","terp-partner":"Team","terp-mrp":"Build","terp-product":"Shopping",STOCK_JUSTIFY_FILL:"UnorderedList",STOCK_INDENT:"IndentIncrease",STOCK_HELP:"Question",STOCK_GO_UP:"ArrowUp",STOCK_SORT_DESCENDING:"SortDescending",STOCK_ADD:"Plus",STOCK_GOTO_LAST:"FastForward",STOCK_FIND:"Search",STOCK_PROPERTIES:"Control",STOCK_DIALOG_INFO:"Info",STOCK_FLOPPY:"Usb",STOCK_JUSTIFY_CENTER:"AlignCenter",STOCK_GO_BACK:"ArrowLeft",STOCK_UNDERLINE:"Underline",STOCK_BOLD:"Bold",STOCK_APPLY:"Check",STOCK_ZOOM_OUT:"ZoomOut",STOCK_STRIKETHROUGH:"Strikethrough",STOCK_MEDIA_REWIND:"Backward",STOCK_PRINT:"Printer",STOCK_NO:"Close",STOCK_GOTO_FIRST:"FastBackward",STOCK_CLOSE:"Close",STOCK_REMOVE:"Minus",STOCK_CUT:"Scissor",STOCK_DIALOG_AUTHENTICATION:"Safety",STOCK_ZOOM_FIT:"Expand",STOCK_JUMP_TO:"Select",STOCK_HARDDISK:"Hdd",STOCK_SAVE_AS:"Save",STOCK_UNDO:"Undo",STOCK_JUSTIFY_RIGHT:"AlignRight",STOCK_DIALOG_ERROR:"CloseCircle",STOCK_INDEX:"Profile",STOCK_GOTO_BOTTOM:"VerticalAlignBottom",STOCK_MEDIA_NEXT:"StepForward",STOCK_REDO:"Redo",STOCK_COPY:"Copy",STOCK_MEDIA_PAUSE:"Pause",STOCK_GO_FORWARD:"ArrowRight",STOCK_UNDELETE:"Undo",STOCK_EXECUTE:"Setting",STOCK_SAVE:"Save",STOCK_DIALOG_QUESTION:"QuestionCircle",STOCK_SORT_ASCENDING:"SortAscending",STOCK_REFRESH:"Reload",STOCK_MEDIA_FORWARD:"Forward",STOCK_STOP:"Border",STOCK_PRINT_PREVIEW:"Printer",STOCK_HOME:"Home",STOCK_PASTE:"CarryOut",STOCK_ZOOM_100:"ZoomIn",STOCK_FIND_AND_REPLACE:"FileSearch",STOCK_DIALOG_WARNING:"Warning",STOCK_ZOOM_IN:"ZoomIn",STOCK_CONVERT:"Export",STOCK_ITALIC:"Italic",STOCK_YES:"Check",STOCK_MEDIA_PLAY:"PlayCircle",STOCK_MEDIA_RECORD:"VideoCamera",STOCK_MEDIA_PREVIOUS:"StepBackward",STOCK_NEW:"FileAdd",STOCK_CANCEL:"Close",STOCK_DISCONNECT:"Api",STOCK_JUSTIFY_LEFT:"AlignLeft",STOCK_FILE:"File",STOCK_QUIT:"Logout",STOCK_EDIT:"Edit",STOCK_CONNECT:"Api",STOCK_GO_DOWN:"CaretDown",STOCK_NETWORK:"Apartment",STOCK_OK:"Check",STOCK_GOTO_TOP:"VerticalAlignTop",STOCK_ABOUT:"Star",STOCK_COLOR_PICKER:"Aim",STOCK_SELECT_FONT:"FontSize",STOCK_DELETE:"Delete",STOCK_DND:"FileText",STOCK_CLEAR:"CloseSquare",STOCK_UNINDENT:"AlignLeft",STOCK_PREFERENCES:"Setting"},Ge=(t,r)=>(t.indexOf("gtk-")!==-1&&(t=`STOCK_${t.replace("gtk-","").replace(/\-/g,"_").toUpperCase()}`),xr.hasOwnProperty(t)?Tr(xr[t],r):Tr(t,r));function Ko(t){return`${t.split("-").map(r=>r.replace(/\w\S*/g,n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase())).join("")}`}function Tr(t,r){let n=t.charAt(0).toUpperCase()+t.slice(1);n.indexOf("-")!==-1&&(n=Ko(n));const s=`${n}Outlined`;if(Cr[s])return()=>Be.default.createElement(Cr[s],{...r});const o=`Icon${n}`;if(br[o]){const i=()=>Be.default.createElement(br[o],{fill:"transparent",height:17,width:17});return()=>Be.default.createElement(Sr.default,{component:i,...r})}}const qt=t=>{const{ooui:r}=t,{id:n,label:s,activated:o,buttonType:i,confirmMessage:a,icon:c,context:h,readOnly:d}=r,f=l.useContext(Ve),{executeButtonAction:u}=f||{},[g,w]=l.useState(!1),{lang:y}=l.useContext(ge);async function m(){w(!0),await u({type:i,action:n,context:h}),w(!1)}function v(){if(a){ot({confirmMessage:a,lang:y,onOk:()=>{m()}});return}m()}function C(){if(g)return e.jsx(H.LoadingOutlined,{});if(c){const F=Ge(c);return F&&e.jsx(F,{})}}return e.jsx(me,{ooui:r,children:e.jsx(p.Button,{block:!0,disabled:!o||d,onClick:v,icon:C(),type:r.primary?"primary":"default",danger:r.danger,style:{whiteSpace:"normal",height:"auto"},children:s})})},Fr=t=>{const{ooui:r}=t,{defaultButton:n,secondaryButtons:s}=r,{id:o,caption:i,activated:a,buttonType:c,confirmMessage:h,icon:d,primary:f,danger:u,context:g,readOnly:w}=n||{},y=l.useContext(Ve),{executeButtonAction:m}=y||{},[v,C]=l.useState(!1),{lang:F}=l.useContext(ge);function E(){if(v)return e.jsx(H.LoadingOutlined,{});if(d){const k=Ge(d);return k&&e.jsx(k,{})}}async function S(){c&&o&&(C(!0),await m({type:c,action:o,context:g}),C(!1))}function V(){if(h){ot({confirmMessage:h,lang:F,onOk:()=>{S()}});return}S()}if(r.buttons.length===0)return null;if(r.buttons.length>1)return e.jsx(me,{ooui:new se.Field({ooui:r}),children:e.jsxs(p.Dropdown.Button,{disabled:!a||w,onClick:V,icon:e.jsx(H.DownOutlined,{}),type:f?"primary":void 0,overlay:e.jsx(Yo,{ooui:s,executeButtonAction:m,lang:F}),children:[E(),i]})});if(n)return e.jsx(qt,{ooui:n})},Yo=t=>{const{ooui:r,executeButtonAction:n,lang:s}=t;if(!r)return null;const o=r.map(i=>{const{id:a,caption:c,activated:h,buttonType:d,confirmMessage:f,icon:u,context:g,readOnly:w,danger:y}=i,[m,v]=l.useState(!1);async function C(){v(!0),await n({type:d,action:a,context:g}),v(!1)}function F(){if(f){ot({confirmMessage:f,lang:s,onOk:()=>{C()}});return}C()}function E(){if(m)return e.jsx(H.LoadingOutlined,{});if(u){const S=Ge(u);return S&&e.jsx(S,{})}}return e.jsx(p.Menu.Item,{disabled:!h||w,onClick:F,icon:E(),danger:y,children:c})});return e.jsx(p.Menu,{children:o})},Wo=.7;function Or(){const{innerWidth:t,innerHeight:r}=window;return{width:t,height:r}}function Ot(){const[t,r]=l.useState(Or());return l.useEffect(()=>{function n(){r(Or())}return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{modalWidth:t.width*Wo,modalHeight:t.height,width:t.width,height:t.height}}class K{static init(r){K.handler=r}static getHandler(){if(!K.handler)throw"Must call init() first with a valid ConnectionProvider instance";return K.handler}}const _r=t=>{let r,n,s;if(typeof t=="string"&&t.indexOf(" -- ")!==-1&&t.indexOf(`
|
|
1
|
+
(function(U,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react"),require("antd"),require("@gisce/ooui"),require("@ant-design/icons"),require("interweave"),require("react/jsx-runtime"),require("@tabler/icons-react"),require("antd/lib/input/TextArea"),require("styled-components"),require("react-measure"),require("antd/lib/typography/Title"),require("@ant-design/plots"),require("use-deep-compare-effect"),require("@gisce/react-formiga-table"),require("file-type-buffer-browser"),require("antd/lib/_util/colors"),require("@gisce/fiber-diagram"),require("@gisce/react-formiga-components"),require("validator/lib/isURL"),require("validator/lib/isEmail"),require("react-hotkeys-hook"),require("react-markdown"),require("@monaco-editor/react"),require("md5"),require("react-grid-layout"),require("react-grid-layout/css/styles.css"),require("uuid")):typeof define=="function"&&define.amd?define(["exports","react","antd","@gisce/ooui","@ant-design/icons","interweave","react/jsx-runtime","@tabler/icons-react","antd/lib/input/TextArea","styled-components","react-measure","antd/lib/typography/Title","@ant-design/plots","use-deep-compare-effect","@gisce/react-formiga-table","file-type-buffer-browser","antd/lib/_util/colors","@gisce/fiber-diagram","@gisce/react-formiga-components","validator/lib/isURL","validator/lib/isEmail","react-hotkeys-hook","react-markdown","@monaco-editor/react","md5","react-grid-layout","react-grid-layout/css/styles.css","uuid"],l):(U=typeof globalThis<"u"?globalThis:U||self,l(U["react-ooui"]={},U.React,U.antd,U.ooui,U.AntIcons,U.interweave,U.jsxRuntime,U.TablerIcons,U.TextArea$1,U.styled,U.Measure,U.Title$3,U.plots,U.useDeepCompareEffect,U.reactFormigaTable,U.fileTypeBufferBrowser,U.colors,U.fiberDiagram,U.reactFormigaComponents,U.isURL,U.isEmail,U.reactHotkeysHook,U.ReactMarkdown,U.Editor,U.md5,U.reactGridLayout,null,U.uuid))})(this,function(U,l,p,se,H,Ht,e,fo,ho,po,go,mo,Kt,yo,vo,wo,gr,Co,mr,So,bo,xo,To,Fo,Oo,yr,Uc,vr){"use strict";const Ue=t=>t&&typeof t=="object"&&"default"in t?t:{default:t};function wr(t){if(t&&t.__esModule)return t;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const Be=Ue(l),Cr=wr(H),Sr=Ue(H),br=wr(fo),_o=Ue(ho),mt=Ue(po),Yt=Ue(go),Wt=Ue(mo),et=Ue(yo),Do=Ue(So),ko=Ue(bo),Mo=Ue(To),Vo=Ue(Fo),Eo=Ue(Oo),{Text:Io,Title:$o}=p.Typography,{useToken:Ao}=p.theme,Lo={left:"justify-start",center:"justify-center",right:"justify-end"},yt=t=>{const{ooui:r,align:n,responsiveBehaviour:s}=t,{label:o,tooltip:i,fieldForLabel:a,labelSize:c,labelType:h}=r,f=a!==null&&o.length>1?o+" :":o,g=n||(a?s?"left":"right":"left"),{token:w}=Ao(),y=c===void 0?Io:$o;return e.jsxs("div",{className:`flex flex-row items-center pb-1 pt-1 ${Lo[g]}`,children:[i&&e.jsx(p.Tooltip,{title:i,children:e.jsx(H.QuestionCircleOutlined,{className:"pr-1 text-xs",style:{color:w.colorPrimary}})}),e.jsx("span",{className:"pr-2",children:e.jsx(y,{level:c,type:h,children:e.jsx(Ht.Interweave,{content:f})})})]})},No={ca_ES:{true:"S\xED",false:"No",simple_search:"B\xFAsqueda simple",advanced_search:"B\xFAsqueda avan\xE7ada",search:"Buscar",parameters:"Par\xE0metres",limit:"Limit",first:"Primer",no_results:"No hi ha resultats",summary:"Mostrant resultats des de {from} fins {to} d'un total de {total} registres",welcome:"Benvingut",attachments:"Adjunts",addNewAttachment:"Afegir nou adjunt",listAllAttachments:"Veure tots els adjunts",viewAs:"Veure com",confirmRemoveItem:"Est\xE0s segur de volguer eliminar aquest item?",save:"Desar",delete:"Eliminar",refresh:"Refrescar",previous:"Anterior",next:"Seg\xFCent",actions:"Accions",reports:"Informes",related:"Relacionat",new:"Nou",fillRequiredField:"Siusplau, omple aquest camp obligatori",fillRequiredFields:"Siusplau, omple tots els camps obligatoris",generatingReport:"Generant informe...",confirmation:"Confirmaci\xF3",ok:"D'acord",cancel:"Cancel\xB7lar",formHasErrors:"El formulari t\xE9 errors",unsavedChanges:"Hi ha canvis sense guardar",confirmRefreshWithoutSave:"Est\xE0s segur de volguer refrescar la p\xE0gina sense guardar els canvis?",discardAndRefresh:"Descarta els canvis i refresca",removeItems:"Elimina el registre/s",confirmRemove:"Est\xE0s segur de volguer eliminar els registre/s seleccionats?",yesConfirmRemove:"S\xED, elimina",unlinkItems:"Desenlla\xE7a registre/s",confirmUnlink:"Est\xE0s segur de volguer desenlla\xE7ar els registre/s seleccionats?",yesConfirmUnlink:"S\xED, desenlla\xE7a",confirmCloseWithoutSave:"Est\xE0s segur de volguer tancar aquesta finestra sense guardar?",closeWithoutSaving:"Tancar sense guardar",action:"Acci\xF3",report:"Informe",selectAction:"Selecciona una acci\xF3",download:"Descarrega",clear:"Neteja",open:"Obre",uploadNewImage:"Puja una nova imatge",noCurrentEntries:"No hi ha registres",duplicate:"Duplicar",downloadingAttachment:"Descarregant adjunt...",tree:"llista",form:"formulari",favorites:"Els meus favorits",edit_favorites:"Edita els favorits",no_favorites:"No tens favorits guardats",register:"Registre",of:"de",editingDocument:"Editant document",showLogs:"Veure logs",createdBy:"Creat per l'usuari",creationDate:"Data creaci\xF3",lastUpdatedBy:"\xDAltima modificaci\xF3 per",lastUpdatedDate:"Data \xFAltima modificaci\xF3",goToResourceId:"V\xE9s al recurs amb ID",searchId:"ID de cerca:",idNotFound:"No es troba aquesta id de recurs per l'objecte",selectedRegisters:"registres seleccionats",translate:"Tradu\xEFr",enterTextBeforeTranslate:"Introdueix algun text al camp abans d'afegir traduccions",saveBeforeTranslate:"Heu de desar el registre abans d'afegir les traduccions",configDashboard:"Configurar panell",moveDashboard:"Moure items del panell",openAttachment:"Veure detall de l'adjunt",openAttachmentLink:"Obrir enlla\xE7 de l'adjunt",uninformed:"Sense informar",totalRegisters:"Registres totals:",export:"Exportar",selectAtLeastOneField:"Selecciona almenys un camp per a l'exportaci\xF3",printScreen:"Imprimir pantalla",advancedExport:"Exportaci\xF3 avan\xE7ada",savedRegisters:"Registre guardat correctament",errorWhileSavingForm:"Error en guardar el formulari",autor:"Autor"},en_US:{true:"Yes",false:"No",simple_search:"Simple search",advanced_search:"Advanced search",search:"Search",parameters:"Parameters",limit:"Limit",first:"First",no_results:"No results",summary:"Showing registers from {from} to {to} of {total} registers",welcome:"Welcome",attachments:"Attachments",addNewAttachment:"Add new attachment",listAllAttachments:"View all the attachments",viewAs:"View as",confirmRemoveItem:"Are you sure to remove this item?",save:"Save",delete:"Delete",refresh:"Refresh",previous:"Previous",next:"Next",actions:"Actions",reports:"Reports",related:"Related",new:"New",fillRequiredField:"Please fill this required field",fillRequiredFields:"Please fill all the required fields",generatingReport:"Generating report...",confirmation:"Confirmation",ok:"OK",cancel:"Cancel",formHasErrors:"Form has errors",unsavedChanges:"There are unsaved changes",confirmRefreshWithoutSave:"Do you really want to refresh this window without saving?",discardAndRefresh:"Discard changes and refresh",removeItems:"Remove item/s",confirmRemove:"Are you sure you want to remove the selected item/s?",yesConfirmRemove:"Yes, remove",unlinkItems:"Unlink item/s",confirmUnlink:"Are you sure you want to unlink the selected item/s?",yesConfirmUnlink:"Yes, unlink",confirmCloseWithoutSave:"Do you really want to close this window without saving?",closeWithoutSaving:"Close without saving",action:"Action",report:"Report",selectAction:"Select an action",download:"Download",clear:"Clear",open:"Open",uploadNewImage:"Upload new image",noCurrentEntries:"No current entries",duplicate:"Duplicate",downloadingAttachment:"Downloading attachment...",tree:"list",form:"form",favorites:"My shortcuts",edit_favorites:"Edit shortcuts",no_favorites:"You don't have any shortcuts saved yet",register:"Register",of:"of",editingDocument:"Editing document",showLogs:"Show logs",createdBy:"Created by user",creationDate:"Creation date",lastUpdatedBy:"Last modified by",lastUpdatedDate:"Date of last modification",goToResourceId:"Go to resource ID",searchId:"Search ID:",idNotFound:"Resource ID does not exist for this object!",selectedRegisters:"selected registers",translate:"Translate",enterTextBeforeTranslate:"Enter some text to the related field before adding translations",saveBeforeTranslate:"You must save the record before adding translations",configDashboard:"Setup dashboard",moveDashboard:"Move dashboard items",openAttachment:"Open attachment detail",openAttachmentLink:"Open attachment link",uninformed:"Uninformed",totalRegisters:"Total registers:",export:"Export",selectAtLeastOneField:"Select at least one field for the export",printScreen:"Print screen",advancedExport:"Advanced export",savedRegisters:"Record successfully saved",errorWhileSavingForm:"Error while saving form",author:"Author"},es_ES:{true:"S\xED",false:"No",simple_search:"B\xFAsqueda simple",advanced_search:"B\xFAsqueda avanzada",search:"Buscar",parameters:"Parametros",limit:"L\xEDmite",first:"Primero",no_results:"No hay resultados",summary:"Mostrando resultado desde {from} hasta {to} de un total de {total} registros",welcome:"Bienvenido",attachments:"Adjuntos",addNewAttachment:"A\xF1adir nuevo adjunto",listAllAttachments:"Ver todos los adjuntos",viewAs:"Ver c\xF3mo",confirmRemoveItem:"Est\xE1s seguro de querer eliminar \xE9ste registro?",save:"Guardar",delete:"Eliminar",refresh:"Refrescar",previous:"Anterior",next:"Siguiente",actions:"Acciones",reports:"Informes",related:"Relacionado",new:"Nuevo",fillRequiredField:"Por favor, rellena \xE9ste campo obligatorio",fillRequiredFields:"Por favor, rellena todos los campos obligatorios",generatingReport:"Generando informe...",confirmation:"Confirmaci\xF3m",ok:"De acuerdo",cancel:"Cancelar",formHasErrors:"El formulario tiene errores",unsavedChanges:"Hay cambios sin guardar",confirmRefreshWithoutSave:"Est\xE1s seguro de querer refrescar la p\xE1gina sin guardar los cambios?",discardAndRefresh:"Descarta los cambios y refresca",removeItems:"Eliminar el registro/s",confirmRemove:"Est\xE1s seguro de querer eliminar los registro/s seleccionados?",yesConfirmRemove:"S\xED, elimina",unlinkItems:"Desenlaza registro/s",confirmUnlink:"Est\xE1s seguro de querer desenlazar los registro/s seleccionados?",yesConfirmUnlink:"S\xED, desenlaza",confirmCloseWithoutSave:"Est\xE1s seguro de querer cerrar \xE9sta ventana sin cerrar?",closeWithoutSaving:"Cerrar sin guardar",action:"Acci\xF3n",report:"Informe",selectAction:"Selecciona una acci\xF3n",download:"Descarga",clear:"Limpiar",open:"Abrir",uploadNewImage:"Subir una nueva im\xE1gen",noCurrentEntries:"No hay registros",duplicate:"Duplicar",downloadingAttachment:"Descargando adjunto...",tree:"lista",form:"formulario",favorites:"Mis favoritos",edit_favorites:"Edita los favoritos",no_favorites:"No tienes favoritos guardados",register:"Registro",of:"de",editingDocument:"Editando documento",showLogs:"Ver logs",createdBy:"Creado por el usuario",creationDate:"Fecha creaci\xF3n",lastUpdatedBy:"\xDAltima modificaci\xF3n por",lastUpdatedDate:"Fecha \xFAltima modificaci\xF3n",goToResourceId:"Ir al recurso con ID",searchId:"ID de b\xFAsqueda:",idNotFound:"No se encuentra \xE9sta ID de recursos para el objeto",selectedRegisters:"registros seleccionados",translate:"Traducir",enterTextBeforeTranslate:"Introduce algun texto en el campo antes de a\xF1adir traducciones",saveBeforeTranslate:"Tienes que guardar el registro antes de a\xF1adir las traducciones",configDashboard:"Configurar panel",moveDashboard:"Mover items del panel",openAttachment:"Ver detalle del adjunto",openAttachmentLink:"Abrir enlace del adjunto",uninformed:"Sin informar",totalRegisters:"Registros totales:",export:"Exportar",selectAtLeastOneField:"Selecciona al menos un campo para la exportaci\xF3n",printScreen:"Imprimir pantalla",advancedExport:"Exportaci\xF3n avanzada",savedRegisters:"Registro guardado correctamente",errorWhileSavingForm:"Error al guardar el formulario",author:"Autor"}},ge=Be.default.createContext(null),Po=t=>{const{children:r,lang:n}=t;function s(o){return be(o,n)}return e.jsx(ge.Provider,{value:{lang:n,t:s},children:r})},be=(t,r)=>{var s;return((s=No[r])==null?void 0:s[t])||t};function me({ooui:t,children:r,layout:n="horizontal",valuePropName:s,showLabel:o=!1,alignLabel:i="left",required:a=!1,type:c,validator:h}){const{id:d,label:f,tooltip:u}=t,{t:g}=l.useContext(ge),w=a?[{required:!0,message:g("fillRequiredField"),type:c,validator:h}]:void 0,y=()=>e.jsx(p.Form.Item,{className:"mb-0",name:d,valuePropName:s,rules:w,children:r});if(!o)return y();const m=e.jsx(yt,{ooui:new se.Label({name:d+"_label",string:f,help:u,fieldForLabel:d}),align:i});return n==="horizontal"?(()=>e.jsxs(p.Row,{align:"middle",className:"pb-1 pt-1",children:[e.jsx(p.Col,{className:"ml-2",flex:"7rem",children:e.jsx("div",{className:"flex flex-col items-end",children:m})}),e.jsx(p.Col,{flex:"auto",children:y()})]}))():(()=>e.jsxs(e.Fragment,{children:[m,y()]}))()}const{confirm:Bo}=p.Modal,ot=({onOk:t,confirmMessage:r,lang:n})=>{Bo({title:be("confirmation",n),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:r,okText:be("ok",n),cancelText:be("cancel",n),onOk:t})},Ve=Be.default.createContext(null),Ho=t=>{const{children:r,activeId:n,activeModel:s,setFieldValue:o,getFieldValue:i,executeButtonAction:a,getContext:c,getValues:h,getPlainValues:d,domain:f,submitForm:u,fetchValues:g,formHasChanges:w,elementHasLostFocus:y,getFields:m}=t;return e.jsx(Ve.Provider,{value:{domain:f,getValues:h,getPlainValues:d,getFields:m,activeId:n,activeModel:s,setFieldValue:o,getFieldValue:i,executeButtonAction:a,getContext:c,submitForm:u,fetchValues:g,formHasChanges:w,elementHasLostFocus:y},children:r})},xr={"terp-purchase":"ShoppingCart","terp-graph":"PieChart","terp-crm":"Contacts","terp-hr":"Friends","terp-account":"BuildingBank","terp-project":"Checklist","terp-administration":"Adjustments","terp-partner":"Team","terp-mrp":"Build","terp-product":"Shopping",STOCK_JUSTIFY_FILL:"UnorderedList",STOCK_INDENT:"IndentIncrease",STOCK_HELP:"Question",STOCK_GO_UP:"ArrowUp",STOCK_SORT_DESCENDING:"SortDescending",STOCK_ADD:"Plus",STOCK_GOTO_LAST:"FastForward",STOCK_FIND:"Search",STOCK_PROPERTIES:"Control",STOCK_DIALOG_INFO:"Info",STOCK_FLOPPY:"Usb",STOCK_JUSTIFY_CENTER:"AlignCenter",STOCK_GO_BACK:"ArrowLeft",STOCK_UNDERLINE:"Underline",STOCK_BOLD:"Bold",STOCK_APPLY:"Check",STOCK_ZOOM_OUT:"ZoomOut",STOCK_STRIKETHROUGH:"Strikethrough",STOCK_MEDIA_REWIND:"Backward",STOCK_PRINT:"Printer",STOCK_NO:"Close",STOCK_GOTO_FIRST:"FastBackward",STOCK_CLOSE:"Close",STOCK_REMOVE:"Minus",STOCK_CUT:"Scissor",STOCK_DIALOG_AUTHENTICATION:"Safety",STOCK_ZOOM_FIT:"Expand",STOCK_JUMP_TO:"Select",STOCK_HARDDISK:"Hdd",STOCK_SAVE_AS:"Save",STOCK_UNDO:"Undo",STOCK_JUSTIFY_RIGHT:"AlignRight",STOCK_DIALOG_ERROR:"CloseCircle",STOCK_INDEX:"Profile",STOCK_GOTO_BOTTOM:"VerticalAlignBottom",STOCK_MEDIA_NEXT:"StepForward",STOCK_REDO:"Redo",STOCK_COPY:"Copy",STOCK_MEDIA_PAUSE:"Pause",STOCK_GO_FORWARD:"ArrowRight",STOCK_UNDELETE:"Undo",STOCK_EXECUTE:"Setting",STOCK_SAVE:"Save",STOCK_DIALOG_QUESTION:"QuestionCircle",STOCK_SORT_ASCENDING:"SortAscending",STOCK_REFRESH:"Reload",STOCK_MEDIA_FORWARD:"Forward",STOCK_STOP:"Border",STOCK_PRINT_PREVIEW:"Printer",STOCK_HOME:"Home",STOCK_PASTE:"CarryOut",STOCK_ZOOM_100:"ZoomIn",STOCK_FIND_AND_REPLACE:"FileSearch",STOCK_DIALOG_WARNING:"Warning",STOCK_ZOOM_IN:"ZoomIn",STOCK_CONVERT:"Export",STOCK_ITALIC:"Italic",STOCK_YES:"Check",STOCK_MEDIA_PLAY:"PlayCircle",STOCK_MEDIA_RECORD:"VideoCamera",STOCK_MEDIA_PREVIOUS:"StepBackward",STOCK_NEW:"FileAdd",STOCK_CANCEL:"Close",STOCK_DISCONNECT:"Api",STOCK_JUSTIFY_LEFT:"AlignLeft",STOCK_FILE:"File",STOCK_QUIT:"Logout",STOCK_EDIT:"Edit",STOCK_CONNECT:"Api",STOCK_GO_DOWN:"CaretDown",STOCK_NETWORK:"Apartment",STOCK_OK:"Check",STOCK_GOTO_TOP:"VerticalAlignTop",STOCK_ABOUT:"Star",STOCK_COLOR_PICKER:"Aim",STOCK_SELECT_FONT:"FontSize",STOCK_DELETE:"Delete",STOCK_DND:"FileText",STOCK_CLEAR:"CloseSquare",STOCK_UNINDENT:"AlignLeft",STOCK_PREFERENCES:"Setting"},Ge=(t,r)=>(t.indexOf("gtk-")!==-1&&(t=`STOCK_${t.replace("gtk-","").replace(/\-/g,"_").toUpperCase()}`),xr.hasOwnProperty(t)?Tr(xr[t],r):Tr(t,r));function Ko(t){return`${t.split("-").map(r=>r.replace(/\w\S*/g,n=>n.charAt(0).toUpperCase()+n.slice(1).toLowerCase())).join("")}`}function Tr(t,r){let n=t.charAt(0).toUpperCase()+t.slice(1);n.indexOf("-")!==-1&&(n=Ko(n));const s=`${n}Outlined`;if(Cr[s])return()=>Be.default.createElement(Cr[s],{...r});const o=`Icon${n}`;if(br[o]){const i=()=>{var c;return Be.default.createElement(br[o],{fill:"transparent",size:((c=r==null?void 0:r.style)==null?void 0:c.fontSize)||17})};return()=>Be.default.createElement(Sr.default,{component:i,...r})}}const qt=t=>{const{ooui:r}=t,{id:n,label:s,activated:o,buttonType:i,confirmMessage:a,icon:c,context:h,readOnly:d}=r,f=l.useContext(Ve),{executeButtonAction:u}=f||{},[g,w]=l.useState(!1),{lang:y}=l.useContext(ge);async function m(){w(!0),await u({type:i,action:n,context:h}),w(!1)}function v(){if(a){ot({confirmMessage:a,lang:y,onOk:()=>{m()}});return}m()}function C(){if(g)return e.jsx(H.LoadingOutlined,{});if(c){const F=Ge(c);return F&&e.jsx(F,{})}}return e.jsx(me,{ooui:r,children:e.jsx(p.Button,{block:!0,disabled:!o||d,onClick:v,icon:C(),type:r.primary?"primary":"default",danger:r.danger,style:{whiteSpace:"normal",height:"auto"},children:s})})},Fr=t=>{const{ooui:r}=t,{defaultButton:n,secondaryButtons:s}=r,{id:o,caption:i,activated:a,buttonType:c,confirmMessage:h,icon:d,primary:f,danger:u,context:g,readOnly:w}=n||{},y=l.useContext(Ve),{executeButtonAction:m}=y||{},[v,C]=l.useState(!1),{lang:F}=l.useContext(ge);function E(){if(v)return e.jsx(H.LoadingOutlined,{});if(d){const k=Ge(d);return k&&e.jsx(k,{})}}async function S(){c&&o&&(C(!0),await m({type:c,action:o,context:g}),C(!1))}function V(){if(h){ot({confirmMessage:h,lang:F,onOk:()=>{S()}});return}S()}if(r.buttons.length===0)return null;if(r.buttons.length>1)return e.jsx(me,{ooui:new se.Field({ooui:r}),children:e.jsxs(p.Dropdown.Button,{disabled:!a||w,onClick:V,icon:e.jsx(H.DownOutlined,{}),type:f?"primary":void 0,overlay:e.jsx(Yo,{ooui:s,executeButtonAction:m,lang:F}),children:[E(),i]})});if(n)return e.jsx(qt,{ooui:n})},Yo=t=>{const{ooui:r,executeButtonAction:n,lang:s}=t;if(!r)return null;const o=r.map(i=>{const{id:a,caption:c,activated:h,buttonType:d,confirmMessage:f,icon:u,context:g,readOnly:w,danger:y}=i,[m,v]=l.useState(!1);async function C(){v(!0),await n({type:d,action:a,context:g}),v(!1)}function F(){if(f){ot({confirmMessage:f,lang:s,onOk:()=>{C()}});return}C()}function E(){if(m)return e.jsx(H.LoadingOutlined,{});if(u){const S=Ge(u);return S&&e.jsx(S,{})}}return e.jsx(p.Menu.Item,{disabled:!h||w,onClick:F,icon:E(),danger:y,children:c})});return e.jsx(p.Menu,{children:o})},Wo=.7;function Or(){const{innerWidth:t,innerHeight:r}=window;return{width:t,height:r}}function Ot(){const[t,r]=l.useState(Or());return l.useEffect(()=>{function n(){r(Or())}return window.addEventListener("resize",n),()=>window.removeEventListener("resize",n)},[]),{modalWidth:t.width*Wo,modalHeight:t.height,width:t.width,height:t.height}}class K{static init(r){K.handler=r}static getHandler(){if(!K.handler)throw"Must call init() first with a valid ConnectionProvider instance";return K.handler}}const _r=t=>{let r,n,s;if(typeof t=="string"&&t.indexOf(" -- ")!==-1&&t.indexOf(`
|
|
2
2
|
|
|
3
3
|
`)!==-1){const o=t.split(`
|
|
4
4
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
.ant-input {
|
|
33
33
|
background-color: ${yn.colorPrimaryBg};
|
|
34
34
|
}
|
|
35
|
-
`,Cn=Be.default.createContext(null),Ha=({children:t,initialView:r})=>{const[n,s]=l.useState(r),[o,i]=l.useState(0),[a,c]=l.useState(!1);return e.jsx(Cn.Provider,{value:{currentView:n,setCurrentView:s,itemIndex:o,setItemIndex:i,manualTriggerChange:a,setManualTriggerChange:c},children:t})},{getValueForOperator:Sn}=se.graphProcessor,Et=.7,It=30,bn=t=>{const{model:r,domain:n,context:s,colorCondition:o,totalDomain:i,showPercent:a=!1,icon:c,suffix:h,field:d,operator:f,manualIds:u}=t,[g,w]=l.useState(!1),[y,m]=l.useState(),[v,C]=l.useState(),[F,E]=l.useState(),[S,V]=l.useState(0),[k,L]=l.useState(0),[x,T]=l.useState(),[b,_]=l.useState(),[N,A]=l.useState();l.useEffect(()=>{$()},[r,o]);async function O({domain:M,isTotal:B}){if(B)return await I({domain:M});if(d&&f){const D=u||await K.getHandler().searchAllIds({params:M,model:r,context:s}),W=await K.getHandler().readObjects({model:r,ids:D,fieldsToRetrieve:[d],context:s});return Sn({values:W.map(J=>J[d]),operator:f})}else return u?u.length:await K.getHandler().searchCount({model:r,params:M,context:s})}async function I({domain:M}){if(d&&f){const B=await K.getHandler().searchAllIds({params:M,model:r,context:s}),D=await K.getHandler().readObjects({model:r,ids:B,fieldsToRetrieve:[d],context:s});return Sn({values:D.map(W=>W[d]),operator:f})}else return await K.getHandler().searchCount({model:r,params:M,context:s})}async function $(){w(!0);let M,B;try{const D=await O({domain:n,isTotal:!1});if(m(D),i){const W=await K.getHandler().evalDomain({domain:i,values:{},context:s});M=await O({domain:W,isTotal:!0}),E(M)}if(M?(B=Math.round(D/M*100*100)/100,C(B)):C(0),o){const W=await K.getHandler().parseCondition({condition:o,values:{value:D,percent:B},context:s});T(W)}if(c)if(c.indexOf(":")!==-1){const W=await K.getHandler().parseCondition({condition:c,values:{value:D,percent:B},context:s});_(W)}else _(c)}catch(D){A(JSON.stringify(D))}w(!1)}return N?e.jsx(p.Alert,{className:"mt-10",message:N,type:"error",banner:!0}):g?e.jsx("div",{style:{padding:"1rem"},children:e.jsx(H.LoadingOutlined,{style:{height:"12px"}})}):e.jsx(Yt.default,{bounds:!0,onResize:M=>{var B,D;V((B=M.bounds)==null?void 0:B.height),L((D=M.bounds)==null?void 0:D.width)},children:({measureRef:M})=>a?e.jsx(Ya,{value:y,total:F,percent:v,measureRef:M,height:S,width:k,color:x,icon:b,suffix:h}):e.jsx(Ka,{value:y,total:F,measureRef:M,height:S,width:k,color:x,icon:b,suffix:h})})};function xn(t,r){const s=document.createElement("canvas").getContext("2d");return s.font=r||getComputedStyle(document.body).font,s.measureText(t).width}function Ka({measureRef:t,width:r,height:n,total:s,value:o,color:i,icon:a,suffix:c}){let h=n*Et<It?It:n*Et;const d=o==null?void 0:o.toLocaleString("es-ES",{useGrouping:!0});let f=s?`${d}/${s}`:`${d}`;c&&(f+=" "+c);let u=xn(f,`bold ${Math.floor(h*1.03)}px sans-serif`);a&&(u=u*2),u>=r*.85&&(h=r*.85/u*h);const g=a&&Ge(a);return e.jsx("div",{ref:t,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:e.jsxs(Wt.default,{style:{fontSize:h,margin:0,color:i},children:[g&&e.jsx(g,{style:{fontSize:h*.7}}),g?` ${f}`:f]})})}function Ya({measureRef:t,height:r,width:n,percent:s,total:o,value:i,color:a,icon:c,suffix:h}){const d=r*.65;let f=d*Et<It?It:d*Et;const u=i==null?void 0:i.toLocaleString("es-ES",{useGrouping:!0});let g=o?`${u}/${o==null?void 0:o.toLocaleString("es-ES",{useGrouping:!0})}`:`${u}`;h&&(g+=" "+h);const w=`${s==null?void 0:s.toLocaleString("es-ES",{useGrouping:!0})}%`;let y=xn(w,`bold ${Math.floor(f*1.03)}px sans-serif`);c&&(y=y*1.5);const m=c&&Ge(c);return(y>=n*.85||f*2<d)&&(f=n*.85/y*f),e.jsx("div",{ref:t,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",flexDirection:"column",padding:"0.2rem"},children:e.jsxs(p.Row,{align:"middle",children:[m&&e.jsx(p.Col,{style:{fontSize:f*1,color:a,paddingRight:"10px"},children:e.jsx(m,{})}),e.jsxs(p.Col,{children:[e.jsx(Wt.default,{style:{fontSize:f*.8,margin:0,color:a},children:m?` ${s}%`:`${s}%`}),e.jsx(Wt.default,{style:{fontSize:f*.4,margin:0,color:a,textAlign:"center"},children:g})]})]})})}const rr=t=>r=>{const n=r.value.toLocaleString("es-ES",{useGrouping:!0});return{name:t==="pie"?r.x:r.type,value:n}},$t=t=>{if(typeof t=="string"&&Wa(t))return parseFloat(t).toLocaleString("es-ES",{useGrouping:!0});if(qa(t))return t.toLocaleString("es-ES",{useGrouping:!0});if(Ua(t)){const r=Ga(t);return r===null?t:je(t,At.input[r]).format(At.output[r])}else return t},Wa=t=>/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/.test(t),qa=t=>typeof t=="number"&&!isNaN(t),Tn={default:{padding:"auto",xAxis:{tickCount:5,label:{formatter:$t}},yAxis:{label:{formatter:$t}},legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("default")}},pie:{appendPadding:10,radius:.9,label:{type:"inner",offset:"-30%",content:({percent:t})=>`${(t*100).toFixed(0)}%`,style:{fontSize:14,textAlign:"center"}},legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("pie")},interactions:[{type:"element-active"}]},barGrouped:{isGroup:!0,legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("barGrouped")},xAxis:{label:{formatter:$t}},yAxis:{label:{formatter:$t}},label:{position:"middle",layout:[{type:"interval-adjust-position"},{type:"interval-hide-overlap"},{type:"adjust-color"}]}}};function Ua(t){return typeof t!="string"||t===void 0?!1:new Date(t).toString()!=="Invalid Date"}const At={input:{hours:"YYYY-MM-DD HH:mm",days:"YYYY-MM-DD",weeks:"YYYY-[W]WW",months:"YYYY-MM",years:"YYYY"},output:{hours:"DD/MM/YYYY HH:mm",days:"DD/MM/YYYY",weeks:"[W]WW/YYYY",months:"MM/YYYY",years:"YYYY"}};function Ga(t){for(const r in At.input)if(je(t,At.input[r],!0).isValid())return r;return null}const{processGraphData:ja}=se.graphProcessor,{getFieldsToRetrieve:za}=se.graphFieldUtils,Ja=t=>{const{model:r,domain:n=[],context:s={},xml:o,limit:i,uninformedString:a,manualIds:c}=t,[h,d]=l.useState(!1),[f,u]=l.useState(),[g,w]=l.useState(),[y,m]=l.useState(),[v,C]=l.useState("line");return et.default(()=>{(async()=>{d(!0),u(void 0);const F=se.parseGraph(o);C(F.type||"line");const E=za({ooui:F});let S,V;try{({values:S,fields:V}=await Xa({model:r,domain:n,context:s,limit:i,order:F.timerange?F.x.name:null,fields:E,manualIds:c}))}catch(k){u("Error fetching graph data values: "+JSON.stringify(k)),d(!1);return}try{if(!S||!V){u("No values or fields returned"),d(!1);return}m(S);const k=ja({ooui:F,values:S,fields:V,options:{uninformedString:a}});w(k)}catch(k){u("Error processing graph data: "+k),d(!1);return}d(!1)})()},[o,r,i,s,n]),{loading:h,error:f,type:v,values:g,evaluatedEntries:y}};async function Za({model:t,context:r,fields:n}){return await K.getHandler().getFields({model:t,context:r,fields:n})}async function Xa({fields:t,model:r,domain:n,context:s,order:o,limit:i,manualIds:a}){const c=await Za({model:r,context:s,fields:t});if(a){let d=await K.getHandler().readObjects({model:r,ids:a,fieldsToRetrieve:t,context:s});return o&&(d=[...d].sort((f,u)=>f[o]-u[o])),{values:d,fields:c}}return{values:await K.getHandler().search({model:r,params:n,fields:t,context:s,limit:i,order:o}),fields:c}}const Qa={line:Kt.Line,bar:Kt.Column,pie:Kt.Pie},Ra=t=>{var C;const{model:r,domain:n,context:s,xml:o,limit:i,manualIds:a}=t,{t:c}=l.useContext(ge),{error:h,loading:d,values:f,type:u,evaluatedEntries:g}=Ja({model:r,xml:o,limit:i,domain:n,context:s,uninformedString:c("uninformed"),manualIds:a});if(h)return e.jsx(p.Alert,{message:h,type:"error",banner:!0});if(d)return e.jsx(p.Spin,{});if(!f)return e.jsx(p.Alert,{message:"No data to display",type:"info"});const{data:w,isGroup:y,isStack:m}=f,v=Qa[u];return v?e.jsxs("div",{style:{padding:"1rem"},children:[e.jsx("p",{style:{textAlign:"right"},children:`${c("totalRegisters")} ${(C=g==null?void 0:g.length)==null?void 0:C.toLocaleString("es-ES",{useGrouping:!0})}`}),e.jsx(v,{...el({type:u,data:w,isGroup:y,isStack:m})})]}):e.jsx(e.Fragment,{children:`Unknown graph type: ${u}`})};function el(t){const{type:r,data:n,isGroup:s,isStack:o}=t;let i=Tn[r];return i||(i=Tn.default),i.data=n,r==="pie"?(i.colorField="x",i.angleField="value"):(i.xField="x",i.yField="value",i.seriesField="type",i.isGroup=s,o&&(i.isStack=!0,i.groupField="stacked")),i}const tl=(t,r)=>{const{view_id:n,model:s,context:o,domain:i,limit:a,manualIds:c}=t,[h,d]=l.useState(!1),[f,u]=l.useState(),[g,w]=l.useState(),y=l.useContext(We),{setGraphIsLoading:m=void 0}=y||{};l.useImperativeHandle(r,()=>({refresh:()=>{v()}})),l.useEffect(()=>{v()},[n]);async function v(){d(!0),m==null||m(!0);try{const C=await K.getHandler().getView({model:s,id:n,type:"graph",context:o});w(C.arch);const F=se.parseGraph(C.arch);u(F)}catch(C){return console.error(C),e.jsx(e.Fragment,{children:JSON.stringify(C)})}d(!1),m==null||m(!1)}if(h)return e.jsx("div",{style:{width:"100%",display:"flex",height:"20%",justifyContent:"center",alignContent:"center",padding:"1rem"},children:e.jsx(H.LoadingOutlined,{style:{height:"12px"}})});if(!f)return null;switch(f.type){case"indicatorField":case"indicator":{const C=f,F=C.type==="indicatorField"?{field:C.field,operator:C.operator}:{};return e.jsx(bn,{showPercent:C.showPercent,totalDomain:C.totalDomain,colorCondition:C.color,model:s,context:o,domain:i,icon:C.icon,suffix:C.suffix,manualIds:c,...F})}case"line":case"bar":case"pie":return e.jsx(Ra,{model:s,context:o,domain:i,xml:g,limit:a,manualIds:c});default:return e.jsx(e.Fragment,{children:`Graph ${f.type} not implemented`})}},Lt=l.forwardRef(tl),{confirm:rl}=p.Modal,nl=({onOk:t,lang:r})=>{rl({title:be("removeItems",r),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmRemove",r),okText:be("yesConfirmRemove",r),onOk:t,cancelText:be("cancel",r)})},{confirm:ol}=p.Modal,sl=({onOk:t,lang:r})=>{ol({title:be("unlinkItems",r),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmUnlink",r),okText:be("yesConfirmUnlink",r),onOk:t,cancelText:be("cancel",r)})},{useToken:il}=p.theme,al=t=>{const{title:r,readOnly:n,onCreateItem:s,onToggleViewMode:o,mode:i,onDelete:a,totalItems:c,currentItemIndex:h,onPreviousItem:d,onNextItem:f,isMany2Many:u,onSearchItem:g,selectedRowKeys:w,showCreateButton:y,showToggleButton:m}=t,{token:v}=il();function C(){return e.jsx("div",{className:"inline-block w-3"})}function F(){return e.jsx("div",{className:"flex flex-grow h-8 text-white",style:{borderRadius:v.borderRadius,backgroundColor:v.colorPrimaryActive},children:e.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:e.jsx("span",{className:"pl-2 font-bold",children:r})})})}function E(){return e.jsx(He,{tooltip:u?"Unlink":"Delete",icon:u?e.jsx(H.ApiOutlined,{}):e.jsx(H.DeleteOutlined,{}),onClick:a,disabled:c===0||n||i!=="form"&&w.length===0})}function S(){let k="_";return c===0?k="_":k=(h+1).toString(),e.jsxs("span",{className:"pl-1 pr-1",children:["(",k,"/",c,")"]})}function V(){return e.jsxs(e.Fragment,{children:[C(),e.jsx(He,{tooltip:"Previous item",icon:e.jsx(H.LeftOutlined,{}),onClick:d}),S(),e.jsx(He,{tooltip:"Next item",icon:e.jsx(H.RightOutlined,{}),onClick:f})]})}return e.jsxs("div",{className:"flex mb-2",children:[F(),e.jsxs("div",{className:"flex-none h-8 pl-2",children:[i!=="graph"&&y&&e.jsx(He,{tooltip:"Create new item",icon:e.jsx(H.FileAddOutlined,{}),disabled:n,onClick:s}),u&&y&&e.jsx(He,{tooltip:"Search existing item",icon:e.jsx(H.SearchOutlined,{}),disabled:n,onClick:g}),i!=="graph"&&C(),i!=="graph"&&E(),i==="form"&&V(),C(),m&&e.jsx(He,{tooltip:"Toggle view mode",icon:e.jsx(H.AlignLeftOutlined,{}),onClick:o})]})]})},ll={form:se.Form,tree:se.Tree,graph:Lt};function cl(t){const r=t.map(s=>s.id);return t.filter((s,o)=>{const{id:i}=s;return!r.includes(i,o+1)})}const dl=t=>{var Ae;const{value:r,onChange:n,ooui:s,views:o}=t,{items:i=[]}=r||{},{currentView:a,setCurrentView:c,itemIndex:h,setItemIndex:d}=l.useContext(Cn),f=l.useContext(Ve),{activeId:u,getFields:g,getValues:w,getContext:y,domain:m}=f||{},{lang:v,t:C}=l.useContext(ge),[F,E]=l.useState(!1),[S,V]=l.useState(!1),[k,L]=l.useState(),[x,T]=l.useState(!1),[b,_]=l.useState(!1),[N,A]=l.useState(),[O,I]=l.useState([]),[$,M]=l.useState(!1),B=l.useRef([]),[D,W]=l.useState(),J=l.useRef(),[j,X]=l.useState(void 0),{readOnly:G,relation:P,context:Y,domain:re}=s,Q=s.type==="many2many",{id:le}=s,R=i.filter(ee=>(ee.values||ee.treeValues)&&ee.operation!=="pendingRemove"),Z=l.useRef();l.useEffect(()=>{if(Z.current!==a){Z.current=a,he();return}he()},[i,a]);const he=l.useCallback(()=>{(a==="form"&&i.some(ee=>!ee.values)||a==="tree"&&i.some(ee=>!ee.treeValues))&&Ee()},[i,a]);l.useEffect(()=>{Ie()},[m]);const we=ee=>{var ae,Ce;n==null||n({fields:((ae=o.get("form"))==null?void 0:ae.fields)||((Ce=o.get("tree"))==null?void 0:Ce.fields),items:cl(ee)})},Ee=async()=>{await Oe(),h>R.length-1&&h!==0&&d(0)},Oe=async ee=>{var ae,Ce,ye;V(!0),E(!1),L(void 0);try{const[Se,xe]=await zt({treeView:{arch:(ae=o.get("tree"))==null?void 0:ae.arch,fields:(Ce=o.get("tree"))==null?void 0:Ce.fields},formView:{fields:((ye=o.get("form"))==null?void 0:ye.fields)||{}},model:P,items:i,context:{...y==null?void 0:y(),...Y},currentView:ee||a});return J.current||(J.current=Se.map(Te=>Te.id)),(a||ee)==="tree"&&xe&&X(xe),we(Se),Se}catch(Se){L(Se)}finally{V(!1)}};async function Ie(){re&&(B.current=await K.getHandler().evalDomain({domain:re,values:ct({fields:g(),values:w()}),fields:g(),context:y()})),m&&m.length>0&&(B.current=B.current.concat(se.transformDomainForChildWidget({domain:m,widgetFieldName:le})))}const Ne=()=>{const ee=Array.from(o.keys()),ae=ee[(ee.indexOf(a)+1)%ee.length];a==="form"?ve(()=>{c(ae)}):c(ae)},ie=()=>{h>0&&(a==="form"?ve(()=>{d(h-1)}):d(h-1))},de=()=>{const ee=R.length;h<ee-1&&(a==="form"?ve(()=>{d(h+1)}):d(h+1))},$e=async()=>{const ee=R[h].id,ae=(await K.getHandler().readObjects({model:P,ids:[ee],fields:o.get("form").fields,context:{...y==null?void 0:y(),...Y}}))[0],Ce=(await K.getHandler().readObjects({model:P,ids:[ee],fields:o.get("tree").fields,context:{...y==null?void 0:y(),...Y}}))[0],ye=i.map(Se=>Se.id===ee?{...Se,operation:"original",values:ae,treeValues:Ce}:Se);we(ye)},ve=ee=>{F?wt({lang:v,onOk:()=>{$e(),ee(),E(!1)}}):ee()},De=()=>{if(Q){sl({lang:v,onOk:()=>{a==="form"?Fe():_e()}});return}nl({lang:v,onOk:()=>{a==="form"?Fe():_e()}})},Ye=async()=>{const{inv_field:ee}=s;let ae;ee&&u&&(ae={[ee]:u}),a==="form"?ve(()=>{M(!0),A({defaultValues:ae}),T(!0)}):(M(!0),A({defaultValues:ae}),T(!0))},te=async()=>{a==="form"?ve(()=>{_(!0)}):_(!0)},Fe=async()=>{V(!0),E(!1),L(void 0);try{if(R[h].id>0){const ee=i.map(ae=>ae.id===R[h].id?{...ae,operation:"pendingRemove"}:ae);we(ee)}else we(i.filter(ee=>ee.id!==R[h].id))}catch(ee){L(ee)}d(0),V(!1)},_e=async()=>{const ee=R.filter(ae=>O.includes(ae.id));V(!0),E(!1),L(void 0);try{const ae=ee.map(ye=>ye.id),Ce=i.filter(ye=>!(ae.includes(ye.id)&&ye.id<0)).map(ye=>ae.includes(ye.id)?{...ye,operation:"pendingRemove"}:ye);we(Ce)}catch(ae){L(ae)}d(0),V(!1)},ke=(ee,ae,Ce,ye=!1)=>{let Se;if(ye)Se=i.concat({id:ee,operation:"pendingLink",values:{...Ce,id:ee},treeValues:{...Ce,id:ee}});else if(ee)Se=i.map(xe=>xe.id===ee?{id:ee,operation:ee>0?"pendingUpdate":"pendingCreate",values:{...Ce,id:ee},treeValues:{...Ce,id:ee}}:xe);else{const xe=ci(i);Se=i.concat({id:xe,operation:"pendingCreate",values:{...Ce,id:xe},treeValues:{...Ce,id:xe}})}we(Se),$||T(!1)},ce=async ee=>{const{id:ae}=ee;let Ce=i;const ye=i.find(Se=>Se.id===ae);(ye==null?void 0:ye.values)===void 0&&(Ce=await Oe("form")),A(Ce.find(Se=>Se.id===ae)),M(!1),T(!0)},fe=async ee=>{V(!0);let ae=i;const Ce=ee.filter(ye=>!i.find(Se=>Se.id===ye));try{for(const ye of Ce){const Se=(await K.getHandler().readObjects({model:P,ids:[ye],fields:o.get("form").fields,context:{...y==null?void 0:y(),...Y}}))[0],xe=(await K.getHandler().readObjects({model:P,ids:[ye],fields:o.get("tree").fields,context:{...y==null?void 0:y(),...Y}}))[0];ae.push({id:ye,operation:"pendingLink",values:Se,treeValues:xe})}we(ae)}catch(ye){L(ye)}finally{V(!1)}};function Pe(){const ee=ll[a];if(a==="graph")return se.parseGraph(o.get("graph").arch).string;{const ae=new ee(o.get(a).fields);return ae.parse(o.get(a).arch),ae.string}}const ue=()=>{var ae,Ce,ye,Se;if(a==="form")return R.length===0?C("noCurrentEntries"):a!==Z.current&&i.some(xe=>!xe.values)?e.jsx(p.Spin,{}):e.jsx(ut,{formView:o.get("form"),values:(ae=R[h])==null?void 0:ae.values,parentContext:{...y==null?void 0:y(),...Y},model:P,id:(Ce=R[h])==null?void 0:Ce.id,submitMode:"values",onFieldsChange:xe=>{var Ze;const Te=(Ze=R[h])==null?void 0:Ze.id,Me=i.map(rt=>rt.id===Te?{...rt,operation:rt.operation==="original"?"pendingUpdate":rt.operation,values:{...xe,id:Te},treeValues:{...xe,id:Te}}:rt);we(Me),E(!0)},readOnly:G});let ee=[];if(R.some(xe=>xe.treeValues)&&(ee=D?at({resultsToSort:R.map(xe=>xe.treeValues),sorter:D,fields:{...o.get("tree").fields,...((ye=o.get("form"))==null?void 0:ye.fields)||{}}}):R.map(xe=>xe.treeValues)),a==="tree")return e.jsx(bt,{total:R.length,limit:R.length,treeView:o.get("tree"),results:ee,loading:S,onRowClicked:((Se=o.get("form"))==null?void 0:Se.fields)!==void 0?ce:void 0,showPagination:!1,rowSelection:{selectedRowKeys:O,onChange:I},sorter:D,onChangeSort:W,context:{...y==null?void 0:y(),...Y},colorsForResults:j,readonly:G});if(a==="graph"){const xe=[[`${s.inv_field}`,"=",u]];return e.jsx(Lt,{view_id:o.get("graph").view_id,model:s.relation,domain:xe,context:{...y==null?void 0:y(),...Y},limit:0})}};if(k)return e.jsx(p.Alert,{className:"mt-10",message:k,type:"error",banner:!0});const Je=$;return S?e.jsx(p.Spin,{}):e.jsxs(e.Fragment,{children:[e.jsx(al,{mode:a,title:Pe(),readOnly:G,isMany2Many:Q,formHasChanges:F,totalItems:R.length,currentItemIndex:h,onDelete:De,onCreateItem:Ye,onToggleViewMode:Ne,onPreviousItem:ie,onNextItem:de,onSearchItem:te,selectedRowKeys:O,showCreateButton:((Ae=o.get("form"))==null?void 0:Ae.fields)!==void 0,showToggleButton:o.size>1}),ue(),e.jsx(ft,{formView:o.get("form"),model:P,id:N==null?void 0:N.id,submitMode:"2many",values:N==null?void 0:N.values,defaultValues:N==null?void 0:N.defaultValues,visible:x,onSubmitSucceed:ke,parentContext:{...y==null?void 0:y(),...Y},onCancel:()=>{M(!1),T(!1)},readOnly:G,mustClearAfterSave:Je}),e.jsx(tr,{domain:B.current,model:P,context:{...y==null?void 0:y(),...Y},visible:b,onSelectValues:async ee=>{_(!1),fe(ee)},onCloseModal:()=>{_(!1)}})]})},Fn=t=>{const{ooui:r}=t,{mode:n,relation:s,views:o,required:i,context:a}=r;let c;const[h,d]=l.useState(!0),[f,u]=l.useState(),[g,w]=l.useState(new Map),y=l.useContext(Ve),{getContext:m}=y||{};et.default(()=>{C()},[r]);const v=async E=>o&&o[E]?o[E]:await K.getHandler().getView({model:s,type:E,context:{...m==null?void 0:m(),...a}}),C=async()=>{d(!0),u(void 0);try{if(n&&n.length>0){for(const E of n){const S=await v(E);g.set(E,S)}w(g)}else{const E=await v("form"),S=await v("tree");g.set("form",E),g.set("tree",S),w(g)}}catch(E){u(JSON.stringify(E))}finally{d(!1)}};if(n&&n.length>0?c=n[0]:c="tree",h)return e.jsx(p.Spin,{});if(f)return e.jsx(p.Alert,{className:"mt-10",message:f,type:"error",banner:!0});const F=async(E,S)=>{if(!S)throw new Error;if(!S.items)throw new Error;if(!Array.isArray(S.items))throw new Error;if(S.items.length===0)throw new Error};return e.jsx(Ha,{initialView:c,children:e.jsx(me,{required:i,type:"array",validator:F,...t,children:e.jsx(dl,{ooui:r,views:g})})})},{useToken:ul}=p.theme,On=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"number",...t,children:e.jsx(fl,{ooui:r})})},fl=t=>{const{ooui:r,value:n,onChange:s}=t,{id:o,readOnly:i,required:a}=r,{token:c}=ul(),h=a&&!i?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useRef(),[f,u]=l.useState(),g=l.useContext(Ve),{elementHasLostFocus:w}=g||{};l.useEffect(()=>{u(an(n))},[n]);const y=C=>{s==null||s(C)};function m(C){d.current=C.target.value,u(C.target.value)}async function v(){y(pa(f)),await new Promise(C=>setTimeout(C,300)),w==null||w()}return e.jsx(p.Input,{value:f,disabled:i,className:"w-full",style:h,id:o,placeholder:"00:00",onChange:m,onBlur:v})};function nr(t){const{ooui:r,showLabel:n=!0,responsiveBehaviour:s}=t,o=Ge(r.icon||"");return e.jsx(e.Fragment,{children:(r.label||o)&&n?e.jsx(mr.FieldSet,{label:r.label,icon:o,children:e.jsx(Zt,{container:r.container,responsiveBehaviour:s})}):e.jsx(Zt,{container:r.container,responsiveBehaviour:s})})}const{TabPane:hl}=p.Tabs;function _n(t){const{ooui:r,responsiveBehaviour:n}=t,s=r.pages;function o(i){if(i){const a=Ge(i);return a&&e.jsx(a,{})}}return e.jsx(p.Tabs,{defaultActiveKey:"1",tabPosition:r.tabPosition,children:s.filter(i=>!i.invisible).map(i=>e.jsx(hl,{tab:e.jsxs(e.Fragment,{children:[o(i.icon)," ",i.label]}),children:e.jsx(nr,{ooui:i,showLabel:!1,responsiveBehaviour:n})},i.label))})}const{useToken:pl}=p.theme,{TextArea:or}=p.Input,Dn=t=>{const{ooui:r}=t,{id:n,readOnly:s,required:o,height:i,translatable:a}=r,{token:c}=pl(),h=o&&!s?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useContext(Ve),{elementHasLostFocus:f}=d||{};return e.jsx(me,{required:o,...t,children:a?e.jsx(gl,{field:n,height:i,requiredStyle:h}):e.jsx(or,{disabled:s||a,style:{minHeight:i?i+"px":"100%",...h},rows:4,onBlur:f})})},gl=({value:t,field:r,requiredStyle:n,onChange:s,height:o})=>{const i=l.useContext(Ve),{activeId:a,activeModel:c,fetchValues:h,formHasChanges:d,elementHasLostFocus:f}=i||{},[u,g]=l.useState(!1),{t:w}=l.useContext(ge);return a?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>{if(d!=null&&d()){Xe(w("saveBeforeTranslate"));return}u||g(!0)},children:e.jsx(or,{value:t,onChange:y=>{s==null||s(y.target.value)},style:{height:o?o+"px":"100%",cursor:"pointer",pointerEvents:"none",...n},id:r,disabled:!0,rows:4,onBlur:f})}),e.jsx(Dr,{id:a,model:c,field:r,visible:u,onCloseModal:()=>{g(!1)},onSubmitSucceed:()=>{g(!1),h==null||h()}})]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Row,{gutter:8,wrap:!1,children:e.jsx(or,{value:t,onChange:y=>{s==null||s(y.target.value)},style:{height:o?o+"px":"100%",...n},id:r,rows:4,onBlur:f})}),e.jsx(p.Row,{justify:"end",style:{paddingTop:5},children:e.jsx(He,{tooltip:w("translate"),icon:e.jsx(H.TranslationOutlined,{}),onClick:async()=>{d!=null&&d()?Xe(w("saveBeforeTranslate")):Xe(w("enterTextBeforeTranslate"))},children:w("translate")})})]})},kn=t=>{const{ooui:r}=t,{label:n,icon:s}=r,o=Ge(s||"");return e.jsx(p.Divider,{orientation:"left",className:"text-sm",children:(o||n)&&e.jsxs(p.Space,{children:[o?e.jsx(o,{}):null,n]})})},ml=({model:t,context:r,locale:n,selectedRegistersToExport:s,domain:o,limit:i,onClose:a})=>{const c=l.useRef({}),h=l.useRef(new Map),d=l.useCallback(async v=>{if(v.selectedKeys===void 0||v.selectedKeys.length===0){Xe(be("selectAtLeastOneField",n));return}let C=o;v.registersAmount==="selected"&&(s==null?void 0:s.length)!==0&&(C=[["id","in",s==null?void 0:s.map(S=>S.id)]]);const{datas:F}=await K.getHandler().exportData({model:t,fields:bl({keys:v.selectedKeys,fields:c.current}),domain:C,limit:v.registersAmount==="all"?0:i,context:r,format:v.exportType});a(),await new Promise(S=>setTimeout(S,200));const E=await st(F);_t(F,E.mime)},[n,t,o,i,r,a]),f=l.useCallback(async()=>{const v=await K.getHandler().getFields({model:t,context:r,fields:[]});return c.current["/"]=v,Mn({fields:v})},[t,r,c]),u=l.useCallback(async v=>{const F=ir(v,c.current)[sr(v)],E=F.relation,S=await K.getHandler().getFields({model:E,context:r,fields:[]});for(const[V,k]of Object.entries(S))S[V].string=vl({parentTitle:F.string,title:k.string});return c.current[v]=S,Mn({fields:S,parentKey:v})},[c.current,t,r]),g=l.useCallback(async()=>{const v=await wl({model:t,context:r}),C=await Sl({predefinedExports:v,fields:c.current,onGetFieldChilds:u});return{predefinedExports:v.map(E=>({...E,fields:E.fields.map(S=>{const V=sr(S.key),L=ir(S.key,c.current)[V];return{key:S.key,title:L.string}})})),keysWithChilds:C}},[c.current]),w=l.useCallback(async v=>{const C=await m("ir.exports"),F=await m("ir.exports.line"),E=await K.getHandler().create({model:"ir.exports",values:{name:v.name,resource:t},fields:C,context:r});return await Promise.all(v.fields.map(async S=>await K.getHandler().create({model:"ir.exports.line",values:{name:S.key,export_id:E},fields:F,context:r}))),{...v,id:E}},[]),y=l.useCallback(async v=>{await K.getHandler().delete({model:"ir.exports",ids:[v.id]})},[]),m=l.useCallback(async v=>{if(h.current.has(v))return h.current.get(v);const C=K.getHandler().getFields({model:v,context:r,fields:[]});h.current.set(v,C)},[h,r]);return{onGetFields:f,onGetFieldChilds:u,onExport:d,onGetPredefinedExports:g,onSavePredefinedExport:w,onRemovePredefinedExport:y}},Mn=({fields:t,parentKey:r})=>{const n=[];for(const s of Object.keys(t)){const o=t[s];if(o.relation&&o.is_function===!0)continue;const i=Vn(o);n.push({key:yl({key:s,parentKey:r}),title:o.string,tooltip:o.help,required:o.required,isLeaf:!i})}return n},Vn=t=>t.type==="many2one"||t.type==="one2many"||t.type==="many2many",yl=({parentKey:t,key:r})=>`${t?t+"/":""}${r}`,xt=t=>t.indexOf("/")===-1?t:t.split("/").slice(0,-1).join("/"),sr=t=>{if(t.indexOf("/")===-1)return t;const r=t.split("/");return r[r.length-1]},ir=(t,r)=>t.indexOf("/")===-1?r["/"]:r[xt(t)],vl=({title:t,parentTitle:r})=>`${r?r+" \u2192 ":""}${t}`,wl=async({model:t,context:r})=>{const n=await K.getHandler().search({model:"ir.exports",params:[["resource","=",t]],context:r}),s=n.flatMap(i=>i.export_fields),o=await K.getHandler().readObjects({model:"ir.exports.line",ids:s,context:r});return n.map(i=>({id:i.id,name:i.name,fields:i.export_fields.map(a=>({key:o.find(h=>h.id===a).name}))}))},Cl=({fields:t,keys:r})=>xl([...new Set(r.filter(n=>{var s,o,i;if(n.indexOf("/")===-1)return!((s=t["/"])!=null&&s[n]);{const a=xt(n);console.log({key:n,parentKey:a,fields:t});const c=(o=t==null?void 0:t[xt(n)])==null?void 0:o[n];return console.log({exists:c}),!((i=t==null?void 0:t[xt(n)])!=null&&i[n])}}).map(n=>xt(n)))]),Sl=async({predefinedExports:t,fields:r,onGetFieldChilds:n})=>{const s=t.flatMap(a=>a.fields.map(c=>c.key)),o=Cl({fields:r,keys:s}),i=[];for(const a of o)i.push({key:a,childs:await n(a)});return i},bl=({keys:t,fields:r})=>t.map(n=>{const s=sr(n),i=ir(n,r)[s];return Vn(i)?`${n}/id`:n}),xl=t=>{const r=new Map,n=[];for(const s of t){const o=s.split("/");let i="";for(const a of o){const c=i?`${i}/${a}`:a;r.has(c)||(n.push(c),r.set(c,!0)),i=c}}return n.sort((s,o)=>{const i=s.split("/").length,a=o.split("/").length;return i-a}),n},En=t=>{const{visible:r,locale:n,onClose:s,model:o,context:i,selectedRegistersToExport:a,totalRegisters:c,domain:h,limit:d,visibleRegisters:f}=t,{onExport:u,onGetFieldChilds:g,onGetFields:w,onGetPredefinedExports:y,onSavePredefinedExport:m,onRemovePredefinedExport:v}=ml({model:o,context:i,domain:h,limit:d,selectedRegistersToExport:a,onClose:s,locale:n});return e.jsx(mr.ExportModal,{visible:r,locale:n,onSucceed:u,onCancel:s,selectedRegistersToExport:a&&a.length&&a.length>0?a.length:void 0,totalRegisters:c,onGetFieldChilds:g,onGetFields:w,visibleRegisters:f,onGetPredefinedExports:y,onSavePredefinedExport:m,onRemovePredefinedExport:v})},In=t=>{const{ooui:r}=t;return e.jsx(pn,{ooui:r})},$n=t=>{const{ooui:r}=t;return e.jsx(pn,{ooui:r,showTime:!0})};var An={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(Qe,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},s=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,o=/\d\d/,i=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,c={},h=function(m){return(m=+m)+(m>68?1900:2e3)},d=function(m){return function(v){this[m]=+v}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(m){(this.zone||(this.zone={})).offset=function(v){if(!v||v==="Z")return 0;var C=v.match(/([+-]|\d\d)/g),F=60*C[1]+(+C[2]||0);return F===0?0:C[0]==="+"?-F:F}(m)}],u=function(m){var v=c[m];return v&&(v.indexOf?v:v.s.concat(v.f))},g=function(m,v){var C,F=c.meridiem;if(F){for(var E=1;E<=24;E+=1)if(m.indexOf(F(E,0,v))>-1){C=E>12;break}}else C=m===(v?"pm":"PM");return C},w={A:[a,function(m){this.afternoon=g(m,!1)}],a:[a,function(m){this.afternoon=g(m,!0)}],S:[/\d/,function(m){this.milliseconds=100*+m}],SS:[o,function(m){this.milliseconds=10*+m}],SSS:[/\d{3}/,function(m){this.milliseconds=+m}],s:[i,d("seconds")],ss:[i,d("seconds")],m:[i,d("minutes")],mm:[i,d("minutes")],H:[i,d("hours")],h:[i,d("hours")],HH:[i,d("hours")],hh:[i,d("hours")],D:[i,d("day")],DD:[o,d("day")],Do:[a,function(m){var v=c.ordinal,C=m.match(/\d+/);if(this.day=C[0],v)for(var F=1;F<=31;F+=1)v(F).replace(/\[|\]/g,"")===m&&(this.day=F)}],M:[i,d("month")],MM:[o,d("month")],MMM:[a,function(m){var v=u("months"),C=(u("monthsShort")||v.map(function(F){return F.slice(0,3)})).indexOf(m)+1;if(C<1)throw new Error;this.month=C%12||C}],MMMM:[a,function(m){var v=u("months").indexOf(m)+1;if(v<1)throw new Error;this.month=v%12||v}],Y:[/[+-]?\d+/,d("year")],YY:[o,function(m){this.year=h(m)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function y(m){var v,C;v=m,C=c&&c.formats;for(var F=(m=v.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(T,b,_){var N=_&&_.toUpperCase();return b||C[_]||n[_]||C[N].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(A,O,I){return O||I.slice(1)})})).match(s),E=F.length,S=0;S<E;S+=1){var V=F[S],k=w[V],L=k&&k[0],x=k&&k[1];F[S]=x?{regex:L,parser:x}:V.replace(/^\[|\]$/g,"")}return function(T){for(var b={},_=0,N=0;_<E;_+=1){var A=F[_];if(typeof A=="string")N+=A.length;else{var O=A.regex,I=A.parser,$=T.slice(N),M=O.exec($)[0];I.call(b,M),T=T.replace(M,"")}}return function(B){var D=B.afternoon;if(D!==void 0){var W=B.hours;D?W<12&&(B.hours+=12):W===12&&(B.hours=0),delete B.afternoon}}(b),b}}return function(m,v,C){C.p.customParseFormat=!0,m&&m.parseTwoDigitYear&&(h=m.parseTwoDigitYear);var F=v.prototype,E=F.parse;F.parse=function(S){var V=S.date,k=S.utc,L=S.args;this.$u=k;var x=L[1];if(typeof x=="string"){var T=L[2]===!0,b=L[3]===!0,_=T||b,N=L[2];b&&(N=L[2]),c=this.$locale(),!T&&N&&(c=C.Ls[N]),this.$d=function($,M,B){try{if(["x","X"].indexOf(M)>-1)return new Date((M==="X"?1e3:1)*$);var D=y(M)($),W=D.year,J=D.month,j=D.day,X=D.hours,G=D.minutes,P=D.seconds,Y=D.milliseconds,re=D.zone,Q=new Date,le=j||(W||J?1:Q.getDate()),R=W||Q.getFullYear(),Z=0;W&&!J||(Z=J>0?J-1:Q.getMonth());var he=X||0,we=G||0,Ee=P||0,Oe=Y||0;return re?new Date(Date.UTC(R,Z,le,he,we,Ee,Oe+60*re.offset*1e3)):B?new Date(Date.UTC(R,Z,le,he,we,Ee,Oe)):new Date(R,Z,le,he,we,Ee,Oe)}catch{return new Date("")}}(V,x,k),this.init(),N&&N!==!0&&(this.$L=this.locale(N).$L),_&&V!=this.format(x)&&(this.$d=new Date("")),c={}}else if(x instanceof Array)for(var A=x.length,O=1;O<=A;O+=1){L[1]=x[O-1];var I=C.apply(this,L);if(I.isValid()){this.$d=I.$d,this.$L=I.$L,this.init();break}O===A&&(this.$d=new Date(""))}else E.call(this,S)}}})})(An);const Tl=An.exports;je.extend(Tl);const Ln=t=>{const{ooui:r}=t;return e.jsx(me,{...t,children:e.jsx(Fl,{ooui:r})})},Fl=t=>{const r=(n,s)=>{t.onChange&&t.onChange(s)};return e.jsx(p.TimePicker,{onChange:r,value:t.value?je(t.value,"HH:mm:ss"):void 0})},Nn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Ol,{ooui:r})})},Ol=t=>{const{value:r,onChange:n,ooui:s}=t,{required:o,selectionValues:i,readOnly:a}=s,c=r==null?void 0:r.split(","),[h,d]=l.useState([]),[f,u]=l.useState();return l.useEffect(()=>{if(!r){u(void 0),d([]);return}const g=r&&c&&c[0],w=r&&c&&c[1]&&parseInt(c[1]);d([w,void 0]),u(g)},[r]),e.jsxs(p.Row,{gutter:8,wrap:!1,children:[e.jsx(p.Col,{flex:"1",children:e.jsx(kr,{ooui:new se.Selection({name:"model_selection",selection:i,readonly:a,required:o}),onChange:g=>{u(g);let w=h[0]||0;g!==f&&(d([]),w=0);const y=`${g},${w}`;y!==r&&(n==null||n(y))},value:f})}),e.jsx(p.Col,{flex:"3",children:e.jsx(wn,{ooui:new se.Many2one({name:"object_value",relation:f,readonly:a,required:o}),value:h,onChange:g=>{d(g);const w=`${f},${g[0]||0}`;w!==r&&(n==null||n(w))}})})]})},{useToken:_l}=p.theme,Pn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Dl,{ooui:r})})},Dl=t=>{const{ooui:r,value:n,onChange:s}=t,{readOnly:o,required:i,filenameField:a}=r,{token:c}=_l(),h=i&&!o?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useRef(null),{setFieldValue:f,getFieldValue:u}=l.useContext(Ve)||{},{t:g}=l.useContext(ge),w=n?ni(n):"",y=E=>{s==null||s(E)};async function m(){const E=await st(n),S=`data:${E==null?void 0:E.mime};base64,${n}`,V=document.createElement("a"),k=u(a),L=u("name");V.href=S,V.download=k||L,V.click()}async function v(){const E=await st(n);_t(n,E.mime)}async function C(E){E.stopPropagation(),E.preventDefault();const S=E.target.files[0],V=await Yr(S);y(V),a&&f(a,S.name)}function F(){f(a,void 0),y(void 0)}return e.jsxs(p.Row,{gutter:8,children:[e.jsxs(p.Col,{style:{paddingBottom:5},children:[e.jsx("input",{type:"file",id:"file",ref:d,style:{display:"none"},onChange:C}),e.jsx(p.Input,{type:"text",disabled:!0,style:h,value:w})]}),e.jsx(p.Col,{children:e.jsxs(p.Space,{children:[e.jsx(p.Button,{icon:e.jsx(H.FolderOpenOutlined,{}),disabled:o,onClick:()=>{d.current.click()},children:"Select"}),e.jsx(p.Button,{icon:e.jsx(H.EyeOutlined,{}),disabled:!n,onClick:v,children:g("open")}),e.jsx(He,{tooltip:g("download"),disabled:!n,onClick:m,icon:e.jsx(H.DownloadOutlined,{})}),e.jsx(He,{tooltip:g("clear"),disabled:o||!n,onClick:F,icon:e.jsx(H.ClearOutlined,{})})]})})]})},ar={tree:e.jsx(H.TableOutlined,{}),form:e.jsx(H.FormOutlined,{}),graph:e.jsx(H.AreaChartOutlined,{}),calendar:e.jsx(H.CalendarOutlined,{})};function Bn(t){return t?(ar==null?void 0:ar[t.type])||e.jsx(H.FormOutlined,{}):e.jsx(H.FormOutlined,{})}function lr(t){const{currentView:r,availableViews:n,onChangeView:s,disabled:o=!1,formHasChanges:i=!1,previousView:a}=t,{t:c,lang:h}=l.useContext(ge);function d(){const g=n.map((w,y)=>e.jsx(p.Menu.Item,{children:e.jsxs(p.Row,{wrap:!1,children:[e.jsx(p.Col,{flex:"none",style:{paddingRight:20},children:Bn(w)}),e.jsx(p.Col,{flex:"auto",style:{paddingRight:20},children:w.type.charAt(0).toUpperCase()+w.type.slice(1)}),e.jsx(p.Col,{flex:"none",children:e.jsx(H.CheckOutlined,{style:{opacity:r.view_id===w.view_id?1:0}})})]})},w.view_id||y));return e.jsx(p.Menu,{onClick:u,children:e.jsx(p.Menu.ItemGroup,{title:c("viewAs"),children:g})})}function f(g){if(i){wt({lang:h,onOk:()=>{g()}});return}g()}function u(g){f(()=>{const w=n.find(y=>y.view_id===parseInt(g.key));s(w)})}return e.jsxs("div",{style:{display:"flex"},children:[e.jsx(He,{tooltip:a?c("viewAs")+" "+c(a.type):"",icon:Bn(a),style:{width:50,borderTopRightRadius:0,borderBottomRightRadius:0},onClick:()=>{u({key:a==null?void 0:a.view_id})},disabled:o||n.length===1}),e.jsx(p.Dropdown,{overlay:d(),disabled:o||n.length===1,children:e.jsx(p.Button,{style:{width:25,borderTopLeftRadius:0,borderBottomLeftRadius:0},icon:e.jsx(H.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:g=>g.preventDefault()})})]})}function ht(t){const{icon:r,tooltip:n,items:s=[],onItemClick:o,label:i,disabled:a=!1}=t;function c(){const d=s==null?void 0:s.map((f,u)=>f.name==="divider"?e.jsx(p.Menu.Divider,{},"divider"+u):e.jsx(p.Menu.Item,{children:f.name},f.id));return e.jsx(p.Menu,{onClick:h,children:e.jsx(p.Menu.ItemGroup,{title:n,children:d})})}function h(d){const f=s.find(u=>isNaN(d.key)?u.id===d.key:u.id===parseInt(d.key));o(f)}return e.jsx(p.Dropdown,{overlay:c(),disabled:a||!s||s.length===0,children:e.jsxs(p.Button,{children:[r," ",i," ",e.jsx(H.DownOutlined,{})]})})}function Ke(t){const{onClick:r,disabled:n=!1,loading:s=!1,tooltip:o,icon:i,label:a,type:c="default"}=t,h=s?e.jsx(H.LoadingOutlined,{}):i;return e.jsxs(He,{type:c,tooltip:o,onClick:r,disabled:n,children:[h,a]})}function Hn(t){const{disabled:r=!1}=t,{formHasChanges:n,onNewClicked:s}=l.useContext(We),{t:o,lang:i}=l.useContext(ge),a=()=>{if(n){wt({lang:i,onOk:()=>{s()}});return}s()};return e.jsx(Ke,{icon:e.jsx(H.FileAddOutlined,{}),tooltip:o("new"),onClick:a,disabled:r})}const{confirm:kl}=p.Modal,Ml=({onOk:t,onCancel:r,lang:n})=>{kl({title:be("unsavedChanges",n),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmRefreshWithoutSave",n),okText:be("discardAndRefresh",n),cancelText:be("cancel",n),onOk:t,onCancel:r})};async function Kn(t,r,n){const s=(await K.getHandler().getLogInfo({model:t,ids:[r]}))[0],{create_date:o,create_uid:i,id:a,write_date:c,write_uid:h}=s;Xe(e.jsxs("div",{children:["ID: "+a," ",e.jsx("br",{}),n("createdBy")+": "+i[1]," ",e.jsx("br",{}),n("creationDate")+": "+o," ",e.jsx("br",{}),n("lastUpdatedBy")+": "+h[1]," ",e.jsx("br",{}),n("lastUpdatedDate")+": "+c]}))}const Vl=t=>{const{numberOfAttachments:r,disabled:n}=t,{t:s,lang:o}=l.useContext(ge),[i,a]=l.useState(!1),c=e.jsxs(p.Button,{disabled:n,children:[e.jsx(H.LinkOutlined,{}),`(${r})`,e.jsx(H.DownOutlined,{style:{fontSize:12}})]});return n?c:e.jsx(p.Popover,{onVisibleChange:h=>a(h),visible:i,placement:"bottom",content:El(t,a,o),title:s("attachments"),arrowContent:null,children:c})},El=(t,r,n)=>{const{attachments:s=[],loading:o,onAddNewAttachment:i,onopenAttachmentLink:a,onOpenAttachmentDetail:c,onListAllAttachments:h}=t;return o?e.jsx(p.Spin,{style:{padding:20}}):e.jsxs(e.Fragment,{children:[e.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{r(!1),h()},children:[e.jsx(H.TableOutlined,{})," ",be("listAllAttachments",n)]}),e.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{r(!1),i()},children:[e.jsx(H.FileAddOutlined,{})," ",be("addNewAttachment",n)]}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"ant-dropdown-menu-item-divider"}),s.map(d=>{const f=d.link?H.LinkOutlined:H.DownloadOutlined;return e.jsxs(p.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[e.jsx(p.Col,{flex:"auto",children:d.name}),e.jsx(p.Col,{flex:"25px",style:{textAlign:"center"},children:(d.datas_fname||d.link)&&e.jsx(p.Tooltip,{title:d.link?be("openAttachmentLink",n):be("download",n),children:e.jsx(f,{style:{cursor:"pointer"},onClick:()=>{r(!1),a(d)}})})}),e.jsx(p.Col,{flex:"25px",style:{textAlign:"center"},children:e.jsx(p.Tooltip,{title:be("openAttachment",n),children:e.jsx(H.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{r(!1),c(d)}})})})]},d.id)})]})]})};function Il(t){const{attachments:r,disabled:n=!1,onAddNewAttachment:s,onListAllAttachments:o,onViewAttachmentDetails:i}=t,{formRef:a}=l.useContext(We),[c,h]=l.useState(!1),[d,f]=l.useState([]),[u,g]=l.useState(!1),{t:w}=l.useContext(ge),y=l.useCallback(async()=>{h(!0);try{const C=await K.getHandler().readObjects({model:"ir.attachment",ids:r.map(F=>F.id),fieldsToRetrieve:["name","datas_fname","link"],context:a.current.getContext()});f(C.map(F=>({id:F.id,name:F.name,datas_fname:F.datas_fname,link:F.link})))}catch(C){Le(C)}h(!1)},r),m=l.useCallback(async C=>{if(C.link){window.open(C.link);return}g(!0);let F;try{F=(await K.getHandler().readObjects({model:"ir.attachment",ids:[C.id],context:a.current.getContext()}))[0]}catch(E){Le(E)}if(g(!1),!!F)if(F.datas){const E=await st(F.datas);_t(F.datas,E.mime)}else i(F)},[]),v=l.useCallback(async C=>{i(C)},[]);return l.useEffect(()=>{y()},[y]),e.jsxs(e.Fragment,{children:[e.jsx(Vl,{numberOfAttachments:r.length,attachments:d,disabled:n,loading:c,onAddNewAttachment:s,onListAllAttachments:o,onopenAttachmentLink:m,onOpenAttachmentDetail:v}),e.jsx(p.Modal,{title:w("downloadingAttachment"),open:u,footer:null,closable:!1,centered:!0,maskClosable:!1,children:e.jsx(p.Spin,{})})]})}function Yn({toolbar:t}){const{availableViews:r,currentView:n,setCurrentView:s,onFormSave:o,formHasChanges:i,formIsSaving:a,currentId:c,results:h,setCurrentItemIndex:d,currentItemIndex:f,setCurrentId:u,currentModel:g,setRemovingItem:w,removingItem:y,duplicatingItem:m,setDuplicatingItem:v,setResults:C,formIsLoading:F,attachments:E,formRef:S,setFormHasChanges:V,previousView:k,setPreviousView:L,goToResourceId:x}=l.useContext(We),{t:T,lang:b}=l.useContext(ge),_=l.useContext(dt),{processAction:N}=_||{},A=l.useContext(ze),{openRelate:O,openDefaultActionForModel:I}=A||{};function $(P){if(i){Ml({lang:b,onOk:()=>{P()}});return}P()}function M(P){if(i){wt({lang:b,onOk:()=>{P()}});return}P()}function B(){h&&h.length>f+1?(d==null||d(f+1),u==null||u(h[f+1].id)):h&&f+1===h.length&&(d==null||d(0),u==null||u(h[0].id))}function D(){h&&f>0?(d==null||d(f-1),u==null||u(h[f-1].id)):h&&f===0&&(d==null||d(h.length-1),u==null||u(h[h.length-1].id))}function W(){ot({confirmMessage:T("confirmRemoveItem"),lang:b,onOk:()=>{J()}})}async function J(){try{w==null||w(!0),await K.getHandler().delete({model:g,ids:[c]});const P=h==null?void 0:h.filter(re=>re.id!==c);C==null||C(P);let Y=0;f>0&&f<=h.length-1&&(Y=f-1),P!=null&&P[Y]?(u==null||u(P==null?void 0:P[Y].id),d==null||d(Y)):(u==null||u(void 0),d==null||d(void 0))}catch(P){Vt(JSON.stringify(P))}finally{w==null||w(!1)}}async function j(){try{v==null||v(!0);const P=await K.getHandler().duplicate({id:c,model:g,context:S.current.getContext()});P&&await(x==null?void 0:x(P))}catch(P){Vt(JSON.stringify(P))}finally{v==null||v(!1)}}const X=a||y||F||m;function G(P){N==null||N({actionData:P,values:S.current.getValues(),fields:S.current.getFields(),context:S.current.getContext(),onRefreshParentValues:()=>{S.current.fetchValues()}})}return n?e.jsxs(p.Space,{wrap:!0,children:[F&&e.jsxs(e.Fragment,{children:[e.jsx(p.Spin,{}),pt(),pt()]}),e.jsx(Hn,{disabled:a||F||y||m}),e.jsx(Ke,{icon:e.jsx(H.SaveOutlined,{}),tooltip:T("save"),disabled:!i||X,loading:a,onClick:o}),e.jsx(Ke,{icon:e.jsx(H.CopyOutlined,{}),tooltip:T("duplicate"),disabled:i||a||c===void 0||m||F,loading:m,onClick:j}),e.jsx(Ke,{icon:e.jsx(H.DeleteOutlined,{}),tooltip:T("delete"),disabled:a||c===void 0||y||m||F,loading:y,onClick:W}),pt(),e.jsx(Ke,{icon:e.jsx(H.InfoCircleOutlined,{}),tooltip:T("showLogs"),disabled:a||c===void 0||y||m||F,loading:!1,onClick:()=>{Kn(g,c,T)}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:T("refresh"),disabled:a||c===void 0||y||m||F,loading:!1,onClick:()=>{$(()=>{S.current.fetchValues()})}}),pt(),e.jsx(lr,{currentView:n,previousView:k,availableViews:r,onChangeView:P=>{L==null||L(n),V==null||V(!1),s==null||s(P)},disabled:X,formHasChanges:i}),pt(),e.jsxs(p.Space,{children:[e.jsx(Ke,{icon:e.jsx(H.LeftOutlined,{}),tooltip:T("previous"),disabled:X,loading:!1,onClick:()=>{M(D)}}),e.jsx(Ke,{icon:e.jsx(H.RightOutlined,{}),tooltip:T("next"),disabled:X,loading:!1,onClick:()=>{M(B)}})]}),pt(),e.jsx(ht,{icon:e.jsx(H.ThunderboltOutlined,{}),disabled:X,tooltip:T("actions"),items:t==null?void 0:t.action,onItemClick:async P=>{!P||!(await gt({onFormSave:o})).succeed||G(P)}}),e.jsx(ht,{icon:e.jsx(H.PrinterOutlined,{}),disabled:X,tooltip:T("reports"),items:t==null?void 0:t.print,onItemClick:async P=>{if(!P)return;const Y=await gt({onFormSave:o});!Y.succeed||G({...P,datas:{...P.datas||{},ids:[Y.currentId]}})}}),e.jsx(ht,{icon:e.jsx(H.EnterOutlined,{}),disabled:X,tooltip:T("related"),items:t==null?void 0:t.relate,onItemClick:async P=>{!P||!(await gt({onFormSave:o})).succeed||O({relateData:P,values:S.current.getValues(),fields:S.current.getFields(),action_id:P.id,action_type:P.type})}}),e.jsx(Il,{disabled:X,attachments:E,onAddNewAttachment:async()=>{const P=await gt({onFormSave:o});if(!P.succeed)return;const Y=P.currentId,re=g;I({model:"ir.attachment",values:{selection_associated_object:`${re},${Y}`},forced_values:{res_model:re,res_id:Y},initialViewType:"form"})},onListAllAttachments:async()=>{const P=await gt({onFormSave:o});if(!P.succeed)return;const Y=P.currentId;I({model:"ir.attachment",domain:[["res_model","=",`${g}`],["res_id","=",`${Y}`]],initialViewType:"tree"})},onViewAttachmentDetails:async P=>{!(await gt({onFormSave:o})).succeed||I({model:"ir.attachment",res_id:P.id,initialViewType:"form"})}})]}):null}function pt(){return e.jsx("div",{className:"inline-block w-2"})}async function gt({onFormSave:t}){const r=await(t==null?void 0:t());return r!=null&&r.succeed?{succeed:!0,currentId:r.id}:{succeed:!1,currentId:void 0}}const{useToken:$l}=p.theme,Wn=t=>{const{ooui:r,value:n,onChange:s,valueValidator:o,linkPrefix:i=""}=t,{id:a,readOnly:c,required:h}=r,{token:d}=$l(),f=h&&!c?{backgroundColor:d.colorPrimaryBg}:void 0,u=l.useContext(Ve),{elementHasLostFocus:g}=u||{},[w,y]=l.useState(!1),[m,v]=l.useState(!1);l.useEffect(()=>{c&&!w&&v(!1),!n&&!c&&(y(!0),v(!0))},[w,c]);const C=F=>{s==null||s(F.target.value)};return e.jsxs(p.Row,{gutter:8,wrap:!1,align:"middle",children:[c?null:e.jsx(p.Col,{flex:"32px",children:w?e.jsx(p.Button,{icon:e.jsx(H.CheckOutlined,{}),onClick:()=>{o(n)&&(y(!1),v(!1))},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1}):e.jsx(p.Button,{icon:e.jsx(H.EditOutlined,{}),onClick:()=>{y(!0),v(!0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1})}),e.jsx(p.Col,{flex:"auto",children:m?e.jsx(p.Input,{style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,...f},id:a,onChange:C,value:n,onBlur:()=>{o(n)&&(y(!1),v(!1),g==null||g())}}):e.jsx("a",{href:`${i}${n}`,style:{color:d.colorPrimary,paddingRight:15},target:"_blank",children:n})})]})},qn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Wn,{ooui:r,valueValidator:s=>s?Do.default(s):!1})})},Un=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Wn,{ooui:r,linkPrefix:"mailto:",valueValidator:s=>s?ko.default(s):!1})})},Al=t=>{const{visible:r,onIdSubmitted:n,onCancel:s,isSearching:o}=t,{t:i}=l.useContext(ge),a=l.useRef();function c(h){n(h.id)}return e.jsx(p.Modal,{title:i("goToResourceId"),centered:!0,open:r,footer:null,destroyOnClose:!0,onCancel:s,maskClosable:!1,afterOpenChange:h=>{var d;return h&&((d=a.current)==null?void 0:d.focus())},children:e.jsxs(p.Form,{layout:"vertical",onFinish:c,autoComplete:"off",children:[e.jsx(p.Form.Item,{name:"id",label:i("searchId"),rules:[{required:!0,type:"number"}],children:e.jsx(p.InputNumber,{style:{width:"100%"},autoFocus:!0,ref:a})}),e.jsx(p.Row,{align:"middle",justify:"end",children:e.jsx(p.Col,{children:e.jsxs(p.Space,{children:[e.jsx(p.Button,{icon:e.jsx(H.CloseOutlined,{}),htmlType:"button",onClick:s,disabled:o,children:i("cancel")}),e.jsx(p.Button,{loading:o,style:{marginLeft:15},icon:e.jsx(H.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:o,children:i("ok")})]})})})]})})},{useToken:Ll}=p.theme;function Gn(t){const{badgeNumber:r=0,...n}=t,{token:s}=Ll();return e.jsxs("div",{style:{position:"relative"},children:[r>0&&e.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:e.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:s.colorPrimaryHover,color:s.colorPrimaryBg},children:r})}),e.jsx(He,{...n,style:{width:46,zIndex:0}})]})}function Nl({refreshGraph:t}){const{t:r}=l.useContext(ge),{availableViews:n,currentView:s,setCurrentView:o,searchParams:i,searchVisible:a,setSearchVisible:c,graphIsLoading:h,previousView:d,setPreviousView:f}=l.useContext(We);return e.jsxs(p.Space,{wrap:!0,children:[e.jsx(Gn,{icon:e.jsx(H.FilterOutlined,{style:{color:a?"white":void 0}}),tooltip:r("advanced_search"),type:a?"primary":"default",onClick:()=>{c==null||c(!a)},disabled:h,badgeNumber:i==null?void 0:i.length}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:r("refresh"),disabled:h,loading:!1,onClick:()=>{t()}}),e.jsx(lr,{currentView:s,availableViews:n,onChangeView:u=>{f==null||f(s),o==null||o(u)},disabled:!1,previousView:d})]})}const{useToken:Pl}=p.theme,{Title:Bl,Text:Nt}=p.Typography;function Pt(t){const{title:r,children:n}=t,{title:s,currentView:o,currentId:i,currentItemIndex:a,results:c,totalItems:h,selectedRowItems:d}=l.useContext(We),{t:f}=l.useContext(ge),{token:u}=Pl();function g(){if((o==null?void 0:o.type)==="form")return i?h===0?e.jsxs(e.Fragment,{children:[f("editingDocument")," (id:"," ",e.jsx(Nt,{copyable:{icon:e.jsx(H.CopyOutlined,{style:{color:"red"}})},children:i}),")"]}):e.jsxs(e.Fragment,{children:[f("register")," ",a===void 0?1:a+1," /"," ",c.length," ",f("of")," ",h," - ",f("editingDocument")," (id:"," ",e.jsx(Nt,{copyable:!0,children:i}),")"]}):"";if((o==null?void 0:o.type)==="tree"&&d){if(d.length===1)return e.jsxs(e.Fragment,{children:["1 ",f("selectedRegisters")," - (id:"," ",e.jsx(Nt,{copyable:!0,children:d[0].id}),")"]});if(d.length>1)return e.jsxs(e.Fragment,{children:[d.length," ",f("selectedRegisters"),e.jsx(Nt,{copyable:{text:d.map(w=>w.id).join(", ")}})]})}return null}return e.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[e.jsxs(p.Row,{className:"shadow-md",style:{padding:"1em",borderRadius:u.borderRadius,backgroundColor:u.colorPrimaryBg},align:"middle",children:[e.jsxs(p.Col,{flex:2,children:[e.jsx(Bl,{level:3,style:{marginBottom:0},children:r||s}),g()]}),e.jsx(p.Col,{flex:3,children:e.jsx(p.Row,{justify:"end",children:n})})]}),e.jsx("div",{className:"pb-5"})]})}const Hl=t=>{const{viewData:r,visible:n,model:s,context:o,domain:i,formView:a,treeView:c}=t,h=l.useRef(),d=l.useContext(We),{setResults:f=void 0,setCurrentItemIndex:u=void 0,currentId:g=void 0,results:w=void 0,setSelectedRowItems:y=void 0,setSearchParams:m=void 0,searchVisible:v=!0,setSearchVisible:C=void 0,sorter:F=void 0,setSorter:E=void 0,setTotalItems:S=void 0,setSearchTreeNameSearch:V=void 0,setTreeIsLoading:k=void 0,limit:L,setLimit:x,searchParams:T,searchValues:b,setSearchValues:_,currentView:N}=d||{},[A,O]=l.useState(!0);l.useEffect(()=>{var W;(W=h.current)==null||W.refresh()},[T]),l.useEffect(()=>{r.view_id!==N.view_id&&O(!0)},[N]);const{clear:I,searchFilterLoading:$,searchError:M,offset:B,tableRefreshing:D}=rn({model:s,setSearchTreeNameSearch:V,setSelectedRowItems:y,searchParams:T,setSearchValues:_,setSearchParams:m,setSearchVisible:C,setTreeIsLoading:k,context:o,formView:a,treeView:c,sorter:F,setSorter:E,setCurrentItemIndex:u,setResultsActionView:f,resultsActionView:w,domain:i,currentId:g,setActionViewTotalItems:S,limit:L,setLimit:x});return!n||!r?null:e.jsxs(e.Fragment,{children:[e.jsx(Pt,{title:r.name,children:e.jsx(Nl,{refreshGraph:()=>{h.current.refresh()}})}),e.jsx(Qt,{fields:{...c.fields,...a.fields},searchFields:jr([a.search_fields,c.search_fields]),limit:L,onClear:I,offset:B,isSearching:$,onSubmit:W=>{O(!1),m==null||m(W.params),C==null||C(!1)},searchError:M,searchVisible:v,searchValues:b,showLimitOptions:!1}),D?e.jsx(p.Spin,{}):e.jsx(Lt,{ref:h,view_id:r.view_id,model:s,context:o,domain:Mt(T||[],i),limit:A?L:void 0,manualIds:A?w==null?void 0:w.map(W=>W.id):void 0})]})},Kl=t=>{const{visible:r,formRef:n,model:s,currentId:o,domain:i,formView:a,context:c,defaultValues:h,forcedValues:d,results:f,setResults:u,setCurrentItemIndex:g}=t;return r?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{children:e.jsx(Yn,{toolbar:a==null?void 0:a.toolbar})}),e.jsx(ut,{rootForm:!0,ref:n,model:s,defaultValues:h,forcedValues:d,formView:a,actionDomain:i,id:o,parentContext:c,onSubmitSucceed:(w,y)=>{f.findIndex(v=>v.id===w)===-1&&(f.push(y),u(f),g(f.length-1))}})]}):null};function Yl(t){const{onSearch:r,disabled:n=!1,searchText:s}=t,{t:o}=l.useContext(ge),[i]=p.Form.useForm(),[a,c]=l.useState(!1);function h(f){r(f.search)}l.useEffect(()=>{i.setFieldsValue({search:s})},[s]);function d(){c(!1),i.setFieldsValue({search:void 0}),r(void 0)}return e.jsx(p.Form,{form:i,onFinish:h,autoComplete:"off",children:e.jsxs(p.Row,{align:"middle",justify:"end",children:[e.jsx(p.Col,{children:e.jsx(p.Form.Item,{name:"search",noStyle:!0,children:e.jsx(p.Input,{autoFocus:!0,disabled:n,onChange:f=>{c(f.target.value.length>0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},suffix:(a||s&&s.length>0)&&e.jsx(p.Tooltip,{title:o("clear"),children:e.jsx(H.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:d})})})})}),e.jsx(p.Col,{children:e.jsx(p.Button,{htmlType:"submit",disabled:n,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},children:o("search")})})]})})}const jn=Be.default.createContext({previewFeatures:!1});function Wl(t){var X;const{availableViews:r,currentView:n,setCurrentView:s,selectedRowItems:o,setRemovingItem:i,removingItem:a,duplicatingItem:c,setDuplicatingItem:h,currentModel:d,searchTreeRef:f,setCurrentId:u,setCurrentItemIndex:g,searchParams:w,searchVisible:y,setSearchVisible:m,setSearchTreeNameSearch:v,searchTreeNameSearch:C,treeIsLoading:F,setPreviousView:E,previousView:S,results:V,limit:k,totalItems:L}=l.useContext(We),{parentContext:x={},treeExpandable:T,toolbar:b}=t,{previewFeatures:_}=l.useContext(jn),{t:N,lang:A}=l.useContext(ge),O=l.useContext(dt),{processAction:I}=O||{},[$,M]=l.useState(!1),B=C!==void 0&&C.trim().length>0;function D(){ot({confirmMessage:N("confirmRemove"),lang:A,onOk:()=>{W()}})}async function W(){var G;try{i==null||i(!0),await K.getHandler().delete({model:d,ids:o.map(P=>P.id)}),u==null||u(void 0),g==null||g(void 0),(G=f==null?void 0:f.current)==null||G.refreshResults()}catch(P){Le(P)}finally{i==null||i(!1)}}async function J(){var G;try{h==null||h(!0);const P=o[0].id;await K.getHandler().duplicate({id:P,model:d,context:{...x}})&&((G=f==null?void 0:f.current)==null||G.refreshResults())}catch(P){Le(P)}finally{h==null||h(!1)}}function j(G){I==null||I({actionData:G,values:{active_id:o==null?void 0:o.map(P=>P.id)[0],active_ids:o==null?void 0:o.map(P=>P.id)},fields:{},context:{...x,active_id:o==null?void 0:o.map(P=>P.id)[0],active_ids:o==null?void 0:o.map(P=>P.id)},onRefreshParentValues:()=>{var P;(P=f==null?void 0:f.current)==null||P.refreshResults()}})}return e.jsxs(p.Space,{wrap:!0,children:[F&&e.jsxs(e.Fragment,{children:[e.jsx(p.Spin,{}),tt(),tt()]}),T?null:e.jsxs(e.Fragment,{children:[e.jsx(Yl,{disabled:c||a||F,searchText:C,onSearch:G=>{G&&G.trim().length>0?v==null||v(G):v==null||v(void 0)}}),!T&&e.jsx(Gn,{icon:e.jsx(H.FilterOutlined,{style:{color:y?"white":void 0}}),tooltip:N("advanced_search"),type:y?"primary":"default",onClick:()=>{m==null||m(!y)},disabled:c||a||F,badgeNumber:w==null?void 0:w.length}),tt(),e.jsx(Hn,{disabled:F}),e.jsx(Ke,{icon:e.jsx(H.CopyOutlined,{}),tooltip:N("duplicate"),disabled:!o||(o==null?void 0:o.length)!==1||c||F,loading:c,onClick:J}),e.jsx(Ke,{icon:e.jsx(H.DeleteOutlined,{}),tooltip:N("delete"),disabled:!(o&&(o==null?void 0:o.length)>0)||F,loading:a,onClick:D}),tt()]}),e.jsx(Ke,{icon:e.jsx(H.InfoCircleOutlined,{}),tooltip:N("showLogs"),disabled:!(o&&(o==null?void 0:o.length)>0)||F,loading:!1,onClick:()=>{Kn(d,o[0].id,N)}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:N("refresh"),disabled:c||a||F,loading:!1,onClick:()=>{var G;(G=f==null?void 0:f.current)==null||G.refreshResults()}}),!T&&e.jsxs(e.Fragment,{children:[tt(),e.jsx(lr,{currentView:n,availableViews:r,onChangeView:G=>{E==null||E(n),s==null||s(G)},previousView:S,disabled:F})]}),tt(),e.jsx(ht,{icon:e.jsx(H.ThunderboltOutlined,{}),disabled:!(o&&(o==null?void 0:o.length)>0)||F,tooltip:N("actions"),items:b==null?void 0:b.action,onItemClick:G=>{!G||j(G)}}),e.jsx(ht,{icon:e.jsx(H.PrinterOutlined,{}),disabled:!(o&&(o==null?void 0:o.length)>0)||F,tooltip:N("reports"),items:b==null?void 0:b.print,onItemClick:G=>{!G||j({...G,datas:{...G.datas||{},ids:o.map(P=>P.id)}})}}),_&&e.jsxs(e.Fragment,{children:[tt(),e.jsx(ht,{icon:e.jsx(Sr.default,{component:()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24",strokeWidth:"1.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),e.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),e.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:N("export"),items:[{id:"print_screen",name:N("printScreen")},{id:"export",name:N("advancedExport")}],onItemClick:G=>{if(G.id==="print_screen"){let P=(o==null?void 0:o.map(Y=>Y.id))||[];P.length===0&&(P=(V==null?void 0:V.map(Y=>Y.id))||[]),j({id:-1,model:d,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:d,ids:P}});return}M(!0)},disabled:c||a||F||B}),e.jsx(En,{visible:$,locale:A,onClose:()=>M(!1),model:d,domain:Mt(((X=f==null?void 0:f.current)==null?void 0:X.getDomain())||[],w||[]),limit:k,totalRegisters:L||0,selectedRegistersToExport:o,visibleRegisters:(V==null?void 0:V.length)||0,context:x})]})]})}function tt(){return e.jsx("div",{className:"inline-block w-2"})}const ql=t=>{const{visible:r,searchTreeRef:n,model:s,context:o,formView:i,treeView:a,domain:c,setCurrentItemIndex:h,results:d,setCurrentId:f,setCurrentView:u,availableViews:g,searchTreeNameSearch:w}=t,{currentView:y,setPreviousView:m}=l.useContext(We);return r?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{children:e.jsx(Wl,{toolbar:a==null?void 0:a.toolbar,parentContext:o,treeExpandable:(a==null?void 0:a.isExpandable)||!1})}),e.jsx(er,{ref:n,rootTree:!0,model:s,parentContext:o,nameSearch:w,formView:i,treeView:a,domain:c,onRowClicked:v=>{const{id:C}=v;f(C);const F=d.findIndex(S=>S.id===C);m==null||m(y),h(F);const E=g.find(S=>S.type==="form");u(E)}})]}):null},cr=Be.default.createContext(null),Ul=t=>{const[r,n]=l.useState(!1),[s,o]=l.useState(!1),{children:i,dashboardRef:a,openAction:c}=t;return e.jsx(cr.Provider,{value:{isLoading:r,setIsLoading:n,dashboardRef:a,openAction:c,moveItemsEnabled:s,setMoveItemsEnabled:o},children:i})};function Gl(){const{isLoading:t,dashboardRef:r,moveItemsEnabled:n,setMoveItemsEnabled:s}=l.useContext(cr),{t:o}=l.useContext(ge);return e.jsxs(p.Space,{wrap:!0,children:[e.jsx(Ke,{icon:e.jsx(H.BorderOuterOutlined,{style:{color:n?"white":void 0}}),type:n?"primary":"default",tooltip:o("moveDashboard"),disabled:t,loading:!1,onClick:()=>{s(!n)}}),jl(),e.jsx(Ke,{icon:e.jsx(H.SettingOutlined,{}),tooltip:o("configDashboard"),disabled:t,loading:!1,onClick:()=>{r==null||r.current.configDashboard()}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:o("refresh"),disabled:t,loading:!1,onClick:()=>{r==null||r.current.refresh()}})]})}function jl(){return e.jsx("div",{className:"inline-block w-2"})}const zl=t=>{const{dashboardData:r}=t,n=l.useRef(),s=l.useContext(ze),{openShortcut:o}=s||{};return r?e.jsxs(Ul,{dashboardRef:n,openAction:i=>{o(i)},children:[e.jsx(Pt,{children:e.jsx(Gl,{})}),e.jsx(Xn,{ref:n,model:r.model,id:r.id,context:r==null?void 0:r.context,configAction:r==null?void 0:r.configAction})]}):null};async function Jl(t){const r=await Promise.all(t.map(async s=>{try{return await s.promise}catch(o){return console.error(`Error for ${s.viewTuple}:`,o),null}}));return t.map((s,o)=>({...s,info:r[o]})).filter(s=>s.info!==null)}function Zl(t,r){const{domain:n,model:s,context:o,views:i,title:a,setCanWeClose:c,tabKey:h,initialView:d,formDefaultValues:f,formForcedValues:u={},res_id:g=!1,action_id:w,action_type:y,treeExpandable:m=!1,limit:v}=t,[C,F]=l.useState(),[E,S]=l.useState([]),[V,k]=l.useState(!0),L=g||void 0,[x,T]=l.useState(L),[b,_]=l.useState([]),[N,A]=l.useState(),[O,I]=l.useState([]),[$,M]=l.useState(),[B,D]=l.useState(0),[W,J]=l.useState(!1),[j,X]=l.useState(!1),[G,P]=l.useState(),{t:Y}=l.useContext(ge),re=l.useRef(),Q=l.useRef(),le=l.useContext(ze),{setCurrentView:R,setCurrentId:Z,tabs:he,activeKey:we,openAction:Ee,onRemoveTab:Oe}=le||{};xo.useHotkeys("ctrl+g,command+g",te=>{te.preventDefault(),$e()},[we,he,C,N,O]);function Ie(te){T(te),Z==null||Z(te)}function Ne(te){F(te),R==null||R(te)}l.useImperativeHandle(r,()=>({canWeClose:de}));const ie=async()=>{k(!0);const te=[],Fe=[];for(const ce of i){const[fe,Pe]=ce;Pe!=="dashboard"?Fe.push({viewTuple:ce,promise:K.getHandler().getView({model:s,type:Pe,id:fe,context:o})}):Fe.push({viewTuple:ce})}const _e=await Jl(Fe);for(const ce of _e){if(!ce)continue;const[,fe]=ce.viewTuple;let Pe=ce.info;switch(fe){case"dashboard":{const ue=i.find(Ae=>{const[,ee]=Ae;return ee==="form"});let Je;ue&&(Je={action_id:w,action_type:y,name:a,res_id:o.active_id,res_model:s,view_id:ue[0],view_type:ue[1]}),te.push({type:"dashboard",id:o.active_id,model:s,context:o,configAction:Je});break}case"form":{te.push({...Pe,type:fe});break}case"tree":{te.push({...Pe,isExpandable:m,type:fe});break}case"graph":{te.push({...Pe,type:fe});break}}}let ke;!d&&te.find(ce=>ce.type==="tree")?ke=te.find(fe=>fe.type==="tree"):d?ke=te.find(fe=>d.id?fe.type===d.type&&fe.view_id===d.id:fe.type===d.type):ke=te.find(fe=>fe.type==="form"),ke||(Le(`Error determining the first view to show for model ${s}.
|
|
35
|
+
`,Cn=Be.default.createContext(null),Ha=({children:t,initialView:r})=>{const[n,s]=l.useState(r),[o,i]=l.useState(0),[a,c]=l.useState(!1);return e.jsx(Cn.Provider,{value:{currentView:n,setCurrentView:s,itemIndex:o,setItemIndex:i,manualTriggerChange:a,setManualTriggerChange:c},children:t})},{getValueForOperator:Sn}=se.graphProcessor,Et=.7,It=30,bn=t=>{const{model:r,domain:n,context:s,colorCondition:o,totalDomain:i,showPercent:a=!1,icon:c,suffix:h,field:d,operator:f,manualIds:u}=t,[g,w]=l.useState(!1),[y,m]=l.useState(),[v,C]=l.useState(),[F,E]=l.useState(),[S,V]=l.useState(0),[k,L]=l.useState(0),[x,T]=l.useState(),[b,_]=l.useState(),[N,A]=l.useState();l.useEffect(()=>{$()},[r,o]);async function O({domain:M,isTotal:B}){if(B)return await I({domain:M});if(d&&f){const D=u||await K.getHandler().searchAllIds({params:M,model:r,context:s}),W=await K.getHandler().readObjects({model:r,ids:D,fieldsToRetrieve:[d],context:s});return Sn({values:W.map(J=>J[d]),operator:f})}else return u?u.length:await K.getHandler().searchCount({model:r,params:M,context:s})}async function I({domain:M}){if(d&&f){const B=await K.getHandler().searchAllIds({params:M,model:r,context:s}),D=await K.getHandler().readObjects({model:r,ids:B,fieldsToRetrieve:[d],context:s});return Sn({values:D.map(W=>W[d]),operator:f})}else return await K.getHandler().searchCount({model:r,params:M,context:s})}async function $(){w(!0);let M,B;try{const D=await O({domain:n,isTotal:!1});if(m(D),i){const W=await K.getHandler().evalDomain({domain:i,values:{},context:s});M=await O({domain:W,isTotal:!0}),E(M)}if(M?(B=Math.round(D/M*100*100)/100,C(B)):C(0),o){const W=await K.getHandler().parseCondition({condition:o,values:{value:D,percent:B},context:s});T(W)}if(c)if(c.indexOf(":")!==-1){const W=await K.getHandler().parseCondition({condition:c,values:{value:D,percent:B},context:s});_(W)}else _(c)}catch(D){A(JSON.stringify(D))}w(!1)}return N?e.jsx(p.Alert,{className:"mt-10",message:N,type:"error",banner:!0}):g?e.jsx("div",{style:{padding:"1rem"},children:e.jsx(H.LoadingOutlined,{style:{height:"12px"}})}):e.jsx(Yt.default,{bounds:!0,onResize:M=>{var B,D;V((B=M.bounds)==null?void 0:B.height),L((D=M.bounds)==null?void 0:D.width)},children:({measureRef:M})=>a?e.jsx(Ya,{value:y,total:F,percent:v,measureRef:M,height:S,width:k,color:x,icon:b,suffix:h}):e.jsx(Ka,{value:y,total:F,measureRef:M,height:S,width:k,color:x,icon:b,suffix:h})})};function xn(t,r){const s=document.createElement("canvas").getContext("2d");return s.font=r||getComputedStyle(document.body).font,s.measureText(t).width}function Ka({measureRef:t,width:r,height:n,total:s,value:o,color:i,icon:a,suffix:c}){let h=n*Et<It?It:n*Et;const d=o==null?void 0:o.toLocaleString("es-ES",{useGrouping:!0});let f=s?`${d}/${s}`:`${d}`;c&&(f+=" "+c);let u=xn(f,`bold ${Math.floor(h*1.03)}px sans-serif`);a&&(u=u*2),u>=r*.85&&(h=r*.85/u*h);const g=a&&Ge(a,{style:{fontSize:h*.7}});return e.jsx("div",{ref:t,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:e.jsxs(Wt.default,{style:{fontSize:h,margin:0,color:i},children:[g&&e.jsx(g,{style:{fontSize:h*.7}}),g?` ${f}`:f]})})}function Ya({measureRef:t,height:r,width:n,percent:s,total:o,value:i,color:a,icon:c,suffix:h}){const d=r*.65;let f=d*Et<It?It:d*Et;const u=i==null?void 0:i.toLocaleString("es-ES",{useGrouping:!0});let g=o?`${u}/${o==null?void 0:o.toLocaleString("es-ES",{useGrouping:!0})}`:`${u}`;h&&(g+=" "+h);const w=`${s==null?void 0:s.toLocaleString("es-ES",{useGrouping:!0})}%`;let y=xn(w,`bold ${Math.floor(f*1.03)}px sans-serif`);c&&(y=y*1.5),(y>=n*.85||f*2<d)&&(f=n*.85/y*f);const m=c&&Ge(c,{style:{fontSize:f}});return e.jsx("div",{ref:t,style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",flexDirection:"column",padding:"0.2rem"},children:e.jsxs(p.Row,{align:"middle",children:[m&&e.jsx(p.Col,{style:{fontSize:f*1,color:a,paddingRight:"10px"},children:e.jsx(m,{})}),e.jsxs(p.Col,{children:[e.jsx(Wt.default,{style:{fontSize:f*.8,margin:0,color:a},children:m?` ${s}%`:`${s}%`}),e.jsx(Wt.default,{style:{fontSize:f*.4,margin:0,color:a,textAlign:"center"},children:g})]})]})})}const rr=t=>r=>{const n=r.value.toLocaleString("es-ES",{useGrouping:!0});return{name:t==="pie"?r.x:r.type,value:n}},$t=t=>{if(typeof t=="string"&&Wa(t))return parseFloat(t).toLocaleString("es-ES",{useGrouping:!0});if(qa(t))return t.toLocaleString("es-ES",{useGrouping:!0});if(Ua(t)){const r=Ga(t);return r===null?t:je(t,At.input[r]).format(At.output[r])}else return t},Wa=t=>/^[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?$/.test(t),qa=t=>typeof t=="number"&&!isNaN(t),Tn={default:{padding:"auto",xAxis:{tickCount:5,label:{formatter:$t}},yAxis:{label:{formatter:$t}},legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("default")}},pie:{appendPadding:10,radius:.9,label:{type:"inner",offset:"-30%",content:({percent:t})=>`${(t*100).toFixed(0)}%`,style:{fontSize:14,textAlign:"center"}},legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("pie")},interactions:[{type:"element-active"}]},barGrouped:{isGroup:!0,legend:{maxWidthRatio:.5,maxItemWidth:1e3},tooltip:{formatter:rr("barGrouped")},xAxis:{label:{formatter:$t}},yAxis:{label:{formatter:$t}},label:{position:"middle",layout:[{type:"interval-adjust-position"},{type:"interval-hide-overlap"},{type:"adjust-color"}]}}};function Ua(t){return typeof t!="string"||t===void 0?!1:new Date(t).toString()!=="Invalid Date"}const At={input:{hours:"YYYY-MM-DD HH:mm",days:"YYYY-MM-DD",weeks:"YYYY-[W]WW",months:"YYYY-MM",years:"YYYY"},output:{hours:"DD/MM/YYYY HH:mm",days:"DD/MM/YYYY",weeks:"[W]WW/YYYY",months:"MM/YYYY",years:"YYYY"}};function Ga(t){for(const r in At.input)if(je(t,At.input[r],!0).isValid())return r;return null}const{processGraphData:ja}=se.graphProcessor,{getFieldsToRetrieve:za}=se.graphFieldUtils,Ja=t=>{const{model:r,domain:n=[],context:s={},xml:o,limit:i,uninformedString:a,manualIds:c}=t,[h,d]=l.useState(!1),[f,u]=l.useState(),[g,w]=l.useState(),[y,m]=l.useState(),[v,C]=l.useState("line");return et.default(()=>{(async()=>{d(!0),u(void 0);const F=se.parseGraph(o);C(F.type||"line");const E=za({ooui:F});let S,V;try{({values:S,fields:V}=await Xa({model:r,domain:n,context:s,limit:i,order:F.timerange?F.x.name:null,fields:E,manualIds:c}))}catch(k){u("Error fetching graph data values: "+JSON.stringify(k)),d(!1);return}try{if(!S||!V){u("No values or fields returned"),d(!1);return}m(S);const k=ja({ooui:F,values:S,fields:V,options:{uninformedString:a}});w(k)}catch(k){u("Error processing graph data: "+k),d(!1);return}d(!1)})()},[o,r,i,s,n]),{loading:h,error:f,type:v,values:g,evaluatedEntries:y}};async function Za({model:t,context:r,fields:n}){return await K.getHandler().getFields({model:t,context:r,fields:n})}async function Xa({fields:t,model:r,domain:n,context:s,order:o,limit:i,manualIds:a}){const c=await Za({model:r,context:s,fields:t});if(a){let d=await K.getHandler().readObjects({model:r,ids:a,fieldsToRetrieve:t,context:s});return o&&(d=[...d].sort((f,u)=>f[o]-u[o])),{values:d,fields:c}}return{values:await K.getHandler().search({model:r,params:n,fields:t,context:s,limit:i,order:o}),fields:c}}const Qa={line:Kt.Line,bar:Kt.Column,pie:Kt.Pie},Ra=t=>{var C;const{model:r,domain:n,context:s,xml:o,limit:i,manualIds:a}=t,{t:c}=l.useContext(ge),{error:h,loading:d,values:f,type:u,evaluatedEntries:g}=Ja({model:r,xml:o,limit:i,domain:n,context:s,uninformedString:c("uninformed"),manualIds:a});if(h)return e.jsx(p.Alert,{message:h,type:"error",banner:!0});if(d)return e.jsx(p.Spin,{});if(!f)return e.jsx(p.Alert,{message:"No data to display",type:"info"});const{data:w,isGroup:y,isStack:m}=f,v=Qa[u];return v?e.jsxs("div",{style:{padding:"1rem"},children:[e.jsx("p",{style:{textAlign:"right"},children:`${c("totalRegisters")} ${(C=g==null?void 0:g.length)==null?void 0:C.toLocaleString("es-ES",{useGrouping:!0})}`}),e.jsx(v,{...el({type:u,data:w,isGroup:y,isStack:m})})]}):e.jsx(e.Fragment,{children:`Unknown graph type: ${u}`})};function el(t){const{type:r,data:n,isGroup:s,isStack:o}=t;let i=Tn[r];return i||(i=Tn.default),i.data=n,r==="pie"?(i.colorField="x",i.angleField="value"):(i.xField="x",i.yField="value",i.seriesField="type",i.isGroup=s,o&&(i.isStack=!0,i.groupField="stacked")),i}const tl=(t,r)=>{const{view_id:n,model:s,context:o,domain:i,limit:a,manualIds:c}=t,[h,d]=l.useState(!1),[f,u]=l.useState(),[g,w]=l.useState(),y=l.useContext(We),{setGraphIsLoading:m=void 0}=y||{};l.useImperativeHandle(r,()=>({refresh:()=>{v()}})),l.useEffect(()=>{v()},[n]);async function v(){d(!0),m==null||m(!0);try{const C=await K.getHandler().getView({model:s,id:n,type:"graph",context:o});w(C.arch);const F=se.parseGraph(C.arch);u(F)}catch(C){return console.error(C),e.jsx(e.Fragment,{children:JSON.stringify(C)})}d(!1),m==null||m(!1)}if(h)return e.jsx("div",{style:{width:"100%",display:"flex",height:"20%",justifyContent:"center",alignContent:"center",padding:"1rem"},children:e.jsx(H.LoadingOutlined,{style:{height:"12px"}})});if(!f)return null;switch(f.type){case"indicatorField":case"indicator":{const C=f,F=C.type==="indicatorField"?{field:C.field,operator:C.operator}:{};return e.jsx(bn,{showPercent:C.showPercent,totalDomain:C.totalDomain,colorCondition:C.color,model:s,context:o,domain:i,icon:C.icon,suffix:C.suffix,manualIds:c,...F})}case"line":case"bar":case"pie":return e.jsx(Ra,{model:s,context:o,domain:i,xml:g,limit:a,manualIds:c});default:return e.jsx(e.Fragment,{children:`Graph ${f.type} not implemented`})}},Lt=l.forwardRef(tl),{confirm:rl}=p.Modal,nl=({onOk:t,lang:r})=>{rl({title:be("removeItems",r),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmRemove",r),okText:be("yesConfirmRemove",r),onOk:t,cancelText:be("cancel",r)})},{confirm:ol}=p.Modal,sl=({onOk:t,lang:r})=>{ol({title:be("unlinkItems",r),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmUnlink",r),okText:be("yesConfirmUnlink",r),onOk:t,cancelText:be("cancel",r)})},{useToken:il}=p.theme,al=t=>{const{title:r,readOnly:n,onCreateItem:s,onToggleViewMode:o,mode:i,onDelete:a,totalItems:c,currentItemIndex:h,onPreviousItem:d,onNextItem:f,isMany2Many:u,onSearchItem:g,selectedRowKeys:w,showCreateButton:y,showToggleButton:m}=t,{token:v}=il();function C(){return e.jsx("div",{className:"inline-block w-3"})}function F(){return e.jsx("div",{className:"flex flex-grow h-8 text-white",style:{borderRadius:v.borderRadius,backgroundColor:v.colorPrimaryActive},children:e.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:e.jsx("span",{className:"pl-2 font-bold",children:r})})})}function E(){return e.jsx(He,{tooltip:u?"Unlink":"Delete",icon:u?e.jsx(H.ApiOutlined,{}):e.jsx(H.DeleteOutlined,{}),onClick:a,disabled:c===0||n||i!=="form"&&w.length===0})}function S(){let k="_";return c===0?k="_":k=(h+1).toString(),e.jsxs("span",{className:"pl-1 pr-1",children:["(",k,"/",c,")"]})}function V(){return e.jsxs(e.Fragment,{children:[C(),e.jsx(He,{tooltip:"Previous item",icon:e.jsx(H.LeftOutlined,{}),onClick:d}),S(),e.jsx(He,{tooltip:"Next item",icon:e.jsx(H.RightOutlined,{}),onClick:f})]})}return e.jsxs("div",{className:"flex mb-2",children:[F(),e.jsxs("div",{className:"flex-none h-8 pl-2",children:[i!=="graph"&&y&&e.jsx(He,{tooltip:"Create new item",icon:e.jsx(H.FileAddOutlined,{}),disabled:n,onClick:s}),u&&y&&e.jsx(He,{tooltip:"Search existing item",icon:e.jsx(H.SearchOutlined,{}),disabled:n,onClick:g}),i!=="graph"&&C(),i!=="graph"&&E(),i==="form"&&V(),C(),m&&e.jsx(He,{tooltip:"Toggle view mode",icon:e.jsx(H.AlignLeftOutlined,{}),onClick:o})]})]})},ll={form:se.Form,tree:se.Tree,graph:Lt};function cl(t){const r=t.map(s=>s.id);return t.filter((s,o)=>{const{id:i}=s;return!r.includes(i,o+1)})}const dl=t=>{var Ae;const{value:r,onChange:n,ooui:s,views:o}=t,{items:i=[]}=r||{},{currentView:a,setCurrentView:c,itemIndex:h,setItemIndex:d}=l.useContext(Cn),f=l.useContext(Ve),{activeId:u,getFields:g,getValues:w,getContext:y,domain:m}=f||{},{lang:v,t:C}=l.useContext(ge),[F,E]=l.useState(!1),[S,V]=l.useState(!1),[k,L]=l.useState(),[x,T]=l.useState(!1),[b,_]=l.useState(!1),[N,A]=l.useState(),[O,I]=l.useState([]),[$,M]=l.useState(!1),B=l.useRef([]),[D,W]=l.useState(),J=l.useRef(),[j,X]=l.useState(void 0),{readOnly:G,relation:P,context:Y,domain:re}=s,Q=s.type==="many2many",{id:le}=s,R=i.filter(ee=>(ee.values||ee.treeValues)&&ee.operation!=="pendingRemove"),Z=l.useRef();l.useEffect(()=>{if(Z.current!==a){Z.current=a,he();return}he()},[i,a]);const he=l.useCallback(()=>{(a==="form"&&i.some(ee=>!ee.values)||a==="tree"&&i.some(ee=>!ee.treeValues))&&Ee()},[i,a]);l.useEffect(()=>{Ie()},[m]);const we=ee=>{var ae,Ce;n==null||n({fields:((ae=o.get("form"))==null?void 0:ae.fields)||((Ce=o.get("tree"))==null?void 0:Ce.fields),items:cl(ee)})},Ee=async()=>{await Oe(),h>R.length-1&&h!==0&&d(0)},Oe=async ee=>{var ae,Ce,ye;V(!0),E(!1),L(void 0);try{const[Se,xe]=await zt({treeView:{arch:(ae=o.get("tree"))==null?void 0:ae.arch,fields:(Ce=o.get("tree"))==null?void 0:Ce.fields},formView:{fields:((ye=o.get("form"))==null?void 0:ye.fields)||{}},model:P,items:i,context:{...y==null?void 0:y(),...Y},currentView:ee||a});return J.current||(J.current=Se.map(Te=>Te.id)),(a||ee)==="tree"&&xe&&X(xe),we(Se),Se}catch(Se){L(Se)}finally{V(!1)}};async function Ie(){re&&(B.current=await K.getHandler().evalDomain({domain:re,values:ct({fields:g(),values:w()}),fields:g(),context:y()})),m&&m.length>0&&(B.current=B.current.concat(se.transformDomainForChildWidget({domain:m,widgetFieldName:le})))}const Ne=()=>{const ee=Array.from(o.keys()),ae=ee[(ee.indexOf(a)+1)%ee.length];a==="form"?ve(()=>{c(ae)}):c(ae)},ie=()=>{h>0&&(a==="form"?ve(()=>{d(h-1)}):d(h-1))},de=()=>{const ee=R.length;h<ee-1&&(a==="form"?ve(()=>{d(h+1)}):d(h+1))},$e=async()=>{const ee=R[h].id,ae=(await K.getHandler().readObjects({model:P,ids:[ee],fields:o.get("form").fields,context:{...y==null?void 0:y(),...Y}}))[0],Ce=(await K.getHandler().readObjects({model:P,ids:[ee],fields:o.get("tree").fields,context:{...y==null?void 0:y(),...Y}}))[0],ye=i.map(Se=>Se.id===ee?{...Se,operation:"original",values:ae,treeValues:Ce}:Se);we(ye)},ve=ee=>{F?wt({lang:v,onOk:()=>{$e(),ee(),E(!1)}}):ee()},De=()=>{if(Q){sl({lang:v,onOk:()=>{a==="form"?Fe():_e()}});return}nl({lang:v,onOk:()=>{a==="form"?Fe():_e()}})},Ye=async()=>{const{inv_field:ee}=s;let ae;ee&&u&&(ae={[ee]:u}),a==="form"?ve(()=>{M(!0),A({defaultValues:ae}),T(!0)}):(M(!0),A({defaultValues:ae}),T(!0))},te=async()=>{a==="form"?ve(()=>{_(!0)}):_(!0)},Fe=async()=>{V(!0),E(!1),L(void 0);try{if(R[h].id>0){const ee=i.map(ae=>ae.id===R[h].id?{...ae,operation:"pendingRemove"}:ae);we(ee)}else we(i.filter(ee=>ee.id!==R[h].id))}catch(ee){L(ee)}d(0),V(!1)},_e=async()=>{const ee=R.filter(ae=>O.includes(ae.id));V(!0),E(!1),L(void 0);try{const ae=ee.map(ye=>ye.id),Ce=i.filter(ye=>!(ae.includes(ye.id)&&ye.id<0)).map(ye=>ae.includes(ye.id)?{...ye,operation:"pendingRemove"}:ye);we(Ce)}catch(ae){L(ae)}d(0),V(!1)},ke=(ee,ae,Ce,ye=!1)=>{let Se;if(ye)Se=i.concat({id:ee,operation:"pendingLink",values:{...Ce,id:ee},treeValues:{...Ce,id:ee}});else if(ee)Se=i.map(xe=>xe.id===ee?{id:ee,operation:ee>0?"pendingUpdate":"pendingCreate",values:{...Ce,id:ee},treeValues:{...Ce,id:ee}}:xe);else{const xe=ci(i);Se=i.concat({id:xe,operation:"pendingCreate",values:{...Ce,id:xe},treeValues:{...Ce,id:xe}})}we(Se),$||T(!1)},ce=async ee=>{const{id:ae}=ee;let Ce=i;const ye=i.find(Se=>Se.id===ae);(ye==null?void 0:ye.values)===void 0&&(Ce=await Oe("form")),A(Ce.find(Se=>Se.id===ae)),M(!1),T(!0)},fe=async ee=>{V(!0);let ae=i;const Ce=ee.filter(ye=>!i.find(Se=>Se.id===ye));try{for(const ye of Ce){const Se=(await K.getHandler().readObjects({model:P,ids:[ye],fields:o.get("form").fields,context:{...y==null?void 0:y(),...Y}}))[0],xe=(await K.getHandler().readObjects({model:P,ids:[ye],fields:o.get("tree").fields,context:{...y==null?void 0:y(),...Y}}))[0];ae.push({id:ye,operation:"pendingLink",values:Se,treeValues:xe})}we(ae)}catch(ye){L(ye)}finally{V(!1)}};function Pe(){const ee=ll[a];if(a==="graph")return se.parseGraph(o.get("graph").arch).string;{const ae=new ee(o.get(a).fields);return ae.parse(o.get(a).arch),ae.string}}const ue=()=>{var ae,Ce,ye,Se;if(a==="form")return R.length===0?C("noCurrentEntries"):a!==Z.current&&i.some(xe=>!xe.values)?e.jsx(p.Spin,{}):e.jsx(ut,{formView:o.get("form"),values:(ae=R[h])==null?void 0:ae.values,parentContext:{...y==null?void 0:y(),...Y},model:P,id:(Ce=R[h])==null?void 0:Ce.id,submitMode:"values",onFieldsChange:xe=>{var Ze;const Te=(Ze=R[h])==null?void 0:Ze.id,Me=i.map(rt=>rt.id===Te?{...rt,operation:rt.operation==="original"?"pendingUpdate":rt.operation,values:{...xe,id:Te},treeValues:{...xe,id:Te}}:rt);we(Me),E(!0)},readOnly:G});let ee=[];if(R.some(xe=>xe.treeValues)&&(ee=D?at({resultsToSort:R.map(xe=>xe.treeValues),sorter:D,fields:{...o.get("tree").fields,...((ye=o.get("form"))==null?void 0:ye.fields)||{}}}):R.map(xe=>xe.treeValues)),a==="tree")return e.jsx(bt,{total:R.length,limit:R.length,treeView:o.get("tree"),results:ee,loading:S,onRowClicked:((Se=o.get("form"))==null?void 0:Se.fields)!==void 0?ce:void 0,showPagination:!1,rowSelection:{selectedRowKeys:O,onChange:I},sorter:D,onChangeSort:W,context:{...y==null?void 0:y(),...Y},colorsForResults:j,readonly:G});if(a==="graph"){const xe=[[`${s.inv_field}`,"=",u]];return e.jsx(Lt,{view_id:o.get("graph").view_id,model:s.relation,domain:xe,context:{...y==null?void 0:y(),...Y},limit:0})}};if(k)return e.jsx(p.Alert,{className:"mt-10",message:k,type:"error",banner:!0});const Je=$;return S?e.jsx(p.Spin,{}):e.jsxs(e.Fragment,{children:[e.jsx(al,{mode:a,title:Pe(),readOnly:G,isMany2Many:Q,formHasChanges:F,totalItems:R.length,currentItemIndex:h,onDelete:De,onCreateItem:Ye,onToggleViewMode:Ne,onPreviousItem:ie,onNextItem:de,onSearchItem:te,selectedRowKeys:O,showCreateButton:((Ae=o.get("form"))==null?void 0:Ae.fields)!==void 0,showToggleButton:o.size>1}),ue(),e.jsx(ft,{formView:o.get("form"),model:P,id:N==null?void 0:N.id,submitMode:"2many",values:N==null?void 0:N.values,defaultValues:N==null?void 0:N.defaultValues,visible:x,onSubmitSucceed:ke,parentContext:{...y==null?void 0:y(),...Y},onCancel:()=>{M(!1),T(!1)},readOnly:G,mustClearAfterSave:Je}),e.jsx(tr,{domain:B.current,model:P,context:{...y==null?void 0:y(),...Y},visible:b,onSelectValues:async ee=>{_(!1),fe(ee)},onCloseModal:()=>{_(!1)}})]})},Fn=t=>{const{ooui:r}=t,{mode:n,relation:s,views:o,required:i,context:a}=r;let c;const[h,d]=l.useState(!0),[f,u]=l.useState(),[g,w]=l.useState(new Map),y=l.useContext(Ve),{getContext:m}=y||{};et.default(()=>{C()},[r]);const v=async E=>o&&o[E]?o[E]:await K.getHandler().getView({model:s,type:E,context:{...m==null?void 0:m(),...a}}),C=async()=>{d(!0),u(void 0);try{if(n&&n.length>0){for(const E of n){const S=await v(E);g.set(E,S)}w(g)}else{const E=await v("form"),S=await v("tree");g.set("form",E),g.set("tree",S),w(g)}}catch(E){u(JSON.stringify(E))}finally{d(!1)}};if(n&&n.length>0?c=n[0]:c="tree",h)return e.jsx(p.Spin,{});if(f)return e.jsx(p.Alert,{className:"mt-10",message:f,type:"error",banner:!0});const F=async(E,S)=>{if(!S)throw new Error;if(!S.items)throw new Error;if(!Array.isArray(S.items))throw new Error;if(S.items.length===0)throw new Error};return e.jsx(Ha,{initialView:c,children:e.jsx(me,{required:i,type:"array",validator:F,...t,children:e.jsx(dl,{ooui:r,views:g})})})},{useToken:ul}=p.theme,On=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"number",...t,children:e.jsx(fl,{ooui:r})})},fl=t=>{const{ooui:r,value:n,onChange:s}=t,{id:o,readOnly:i,required:a}=r,{token:c}=ul(),h=a&&!i?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useRef(),[f,u]=l.useState(),g=l.useContext(Ve),{elementHasLostFocus:w}=g||{};l.useEffect(()=>{u(an(n))},[n]);const y=C=>{s==null||s(C)};function m(C){d.current=C.target.value,u(C.target.value)}async function v(){y(pa(f)),await new Promise(C=>setTimeout(C,300)),w==null||w()}return e.jsx(p.Input,{value:f,disabled:i,className:"w-full",style:h,id:o,placeholder:"00:00",onChange:m,onBlur:v})};function nr(t){const{ooui:r,showLabel:n=!0,responsiveBehaviour:s}=t,o=Ge(r.icon||"");return e.jsx(e.Fragment,{children:(r.label||o)&&n?e.jsx(mr.FieldSet,{label:r.label,icon:o,children:e.jsx(Zt,{container:r.container,responsiveBehaviour:s})}):e.jsx(Zt,{container:r.container,responsiveBehaviour:s})})}const{TabPane:hl}=p.Tabs;function _n(t){const{ooui:r,responsiveBehaviour:n}=t,s=r.pages;function o(i){if(i){const a=Ge(i);return a&&e.jsx(a,{})}}return e.jsx(p.Tabs,{defaultActiveKey:"1",tabPosition:r.tabPosition,children:s.filter(i=>!i.invisible).map(i=>e.jsx(hl,{tab:e.jsxs(e.Fragment,{children:[o(i.icon)," ",i.label]}),children:e.jsx(nr,{ooui:i,showLabel:!1,responsiveBehaviour:n})},i.label))})}const{useToken:pl}=p.theme,{TextArea:or}=p.Input,Dn=t=>{const{ooui:r}=t,{id:n,readOnly:s,required:o,height:i,translatable:a}=r,{token:c}=pl(),h=o&&!s?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useContext(Ve),{elementHasLostFocus:f}=d||{};return e.jsx(me,{required:o,...t,children:a?e.jsx(gl,{field:n,height:i,requiredStyle:h}):e.jsx(or,{disabled:s||a,style:{minHeight:i?i+"px":"100%",...h},rows:4,onBlur:f})})},gl=({value:t,field:r,requiredStyle:n,onChange:s,height:o})=>{const i=l.useContext(Ve),{activeId:a,activeModel:c,fetchValues:h,formHasChanges:d,elementHasLostFocus:f}=i||{},[u,g]=l.useState(!1),{t:w}=l.useContext(ge);return a?e.jsxs(e.Fragment,{children:[e.jsx("div",{onClick:()=>{if(d!=null&&d()){Xe(w("saveBeforeTranslate"));return}u||g(!0)},children:e.jsx(or,{value:t,onChange:y=>{s==null||s(y.target.value)},style:{height:o?o+"px":"100%",cursor:"pointer",pointerEvents:"none",...n},id:r,disabled:!0,rows:4,onBlur:f})}),e.jsx(Dr,{id:a,model:c,field:r,visible:u,onCloseModal:()=>{g(!1)},onSubmitSucceed:()=>{g(!1),h==null||h()}})]}):e.jsxs(e.Fragment,{children:[e.jsx(p.Row,{gutter:8,wrap:!1,children:e.jsx(or,{value:t,onChange:y=>{s==null||s(y.target.value)},style:{height:o?o+"px":"100%",...n},id:r,rows:4,onBlur:f})}),e.jsx(p.Row,{justify:"end",style:{paddingTop:5},children:e.jsx(He,{tooltip:w("translate"),icon:e.jsx(H.TranslationOutlined,{}),onClick:async()=>{d!=null&&d()?Xe(w("saveBeforeTranslate")):Xe(w("enterTextBeforeTranslate"))},children:w("translate")})})]})},kn=t=>{const{ooui:r}=t,{label:n,icon:s}=r,o=Ge(s||"");return e.jsx(p.Divider,{orientation:"left",className:"text-sm",children:(o||n)&&e.jsxs(p.Space,{children:[o?e.jsx(o,{}):null,n]})})},ml=({model:t,context:r,locale:n,selectedRegistersToExport:s,domain:o,limit:i,onClose:a})=>{const c=l.useRef({}),h=l.useRef(new Map),d=l.useCallback(async v=>{if(v.selectedKeys===void 0||v.selectedKeys.length===0){Xe(be("selectAtLeastOneField",n));return}let C=o;v.registersAmount==="selected"&&(s==null?void 0:s.length)!==0&&(C=[["id","in",s==null?void 0:s.map(S=>S.id)]]);const{datas:F}=await K.getHandler().exportData({model:t,fields:bl({keys:v.selectedKeys,fields:c.current}),domain:C,limit:v.registersAmount==="all"?0:i,context:r,format:v.exportType});a(),await new Promise(S=>setTimeout(S,200));const E=await st(F);_t(F,E.mime)},[n,t,o,i,r,a]),f=l.useCallback(async()=>{const v=await K.getHandler().getFields({model:t,context:r,fields:[]});return c.current["/"]=v,Mn({fields:v})},[t,r,c]),u=l.useCallback(async v=>{const F=ir(v,c.current)[sr(v)],E=F.relation,S=await K.getHandler().getFields({model:E,context:r,fields:[]});for(const[V,k]of Object.entries(S))S[V].string=vl({parentTitle:F.string,title:k.string});return c.current[v]=S,Mn({fields:S,parentKey:v})},[c.current,t,r]),g=l.useCallback(async()=>{const v=await wl({model:t,context:r}),C=await Sl({predefinedExports:v,fields:c.current,onGetFieldChilds:u});return{predefinedExports:v.map(E=>({...E,fields:E.fields.map(S=>{const V=sr(S.key),L=ir(S.key,c.current)[V];return{key:S.key,title:L.string}})})),keysWithChilds:C}},[c.current]),w=l.useCallback(async v=>{const C=await m("ir.exports"),F=await m("ir.exports.line"),E=await K.getHandler().create({model:"ir.exports",values:{name:v.name,resource:t},fields:C,context:r});return await Promise.all(v.fields.map(async S=>await K.getHandler().create({model:"ir.exports.line",values:{name:S.key,export_id:E},fields:F,context:r}))),{...v,id:E}},[]),y=l.useCallback(async v=>{await K.getHandler().delete({model:"ir.exports",ids:[v.id]})},[]),m=l.useCallback(async v=>{if(h.current.has(v))return h.current.get(v);const C=K.getHandler().getFields({model:v,context:r,fields:[]});h.current.set(v,C)},[h,r]);return{onGetFields:f,onGetFieldChilds:u,onExport:d,onGetPredefinedExports:g,onSavePredefinedExport:w,onRemovePredefinedExport:y}},Mn=({fields:t,parentKey:r})=>{const n=[];for(const s of Object.keys(t)){const o=t[s];if(o.relation&&o.is_function===!0)continue;const i=Vn(o);n.push({key:yl({key:s,parentKey:r}),title:o.string,tooltip:o.help,required:o.required,isLeaf:!i})}return n},Vn=t=>t.type==="many2one"||t.type==="one2many"||t.type==="many2many",yl=({parentKey:t,key:r})=>`${t?t+"/":""}${r}`,xt=t=>t.indexOf("/")===-1?t:t.split("/").slice(0,-1).join("/"),sr=t=>{if(t.indexOf("/")===-1)return t;const r=t.split("/");return r[r.length-1]},ir=(t,r)=>t.indexOf("/")===-1?r["/"]:r[xt(t)],vl=({title:t,parentTitle:r})=>`${r?r+" \u2192 ":""}${t}`,wl=async({model:t,context:r})=>{const n=await K.getHandler().search({model:"ir.exports",params:[["resource","=",t]],context:r}),s=n.flatMap(i=>i.export_fields),o=await K.getHandler().readObjects({model:"ir.exports.line",ids:s,context:r});return n.map(i=>({id:i.id,name:i.name,fields:i.export_fields.map(a=>({key:o.find(h=>h.id===a).name}))}))},Cl=({fields:t,keys:r})=>xl([...new Set(r.filter(n=>{var s,o,i;if(n.indexOf("/")===-1)return!((s=t["/"])!=null&&s[n]);{const a=xt(n);console.log({key:n,parentKey:a,fields:t});const c=(o=t==null?void 0:t[xt(n)])==null?void 0:o[n];return console.log({exists:c}),!((i=t==null?void 0:t[xt(n)])!=null&&i[n])}}).map(n=>xt(n)))]),Sl=async({predefinedExports:t,fields:r,onGetFieldChilds:n})=>{const s=t.flatMap(a=>a.fields.map(c=>c.key)),o=Cl({fields:r,keys:s}),i=[];for(const a of o)i.push({key:a,childs:await n(a)});return i},bl=({keys:t,fields:r})=>t.map(n=>{const s=sr(n),i=ir(n,r)[s];return Vn(i)?`${n}/id`:n}),xl=t=>{const r=new Map,n=[];for(const s of t){const o=s.split("/");let i="";for(const a of o){const c=i?`${i}/${a}`:a;r.has(c)||(n.push(c),r.set(c,!0)),i=c}}return n.sort((s,o)=>{const i=s.split("/").length,a=o.split("/").length;return i-a}),n},En=t=>{const{visible:r,locale:n,onClose:s,model:o,context:i,selectedRegistersToExport:a,totalRegisters:c,domain:h,limit:d,visibleRegisters:f}=t,{onExport:u,onGetFieldChilds:g,onGetFields:w,onGetPredefinedExports:y,onSavePredefinedExport:m,onRemovePredefinedExport:v}=ml({model:o,context:i,domain:h,limit:d,selectedRegistersToExport:a,onClose:s,locale:n});return e.jsx(mr.ExportModal,{visible:r,locale:n,onSucceed:u,onCancel:s,selectedRegistersToExport:a&&a.length&&a.length>0?a.length:void 0,totalRegisters:c,onGetFieldChilds:g,onGetFields:w,visibleRegisters:f,onGetPredefinedExports:y,onSavePredefinedExport:m,onRemovePredefinedExport:v})},In=t=>{const{ooui:r}=t;return e.jsx(pn,{ooui:r})},$n=t=>{const{ooui:r}=t;return e.jsx(pn,{ooui:r,showTime:!0})};var An={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(Qe,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},s=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,o=/\d\d/,i=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,c={},h=function(m){return(m=+m)+(m>68?1900:2e3)},d=function(m){return function(v){this[m]=+v}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(m){(this.zone||(this.zone={})).offset=function(v){if(!v||v==="Z")return 0;var C=v.match(/([+-]|\d\d)/g),F=60*C[1]+(+C[2]||0);return F===0?0:C[0]==="+"?-F:F}(m)}],u=function(m){var v=c[m];return v&&(v.indexOf?v:v.s.concat(v.f))},g=function(m,v){var C,F=c.meridiem;if(F){for(var E=1;E<=24;E+=1)if(m.indexOf(F(E,0,v))>-1){C=E>12;break}}else C=m===(v?"pm":"PM");return C},w={A:[a,function(m){this.afternoon=g(m,!1)}],a:[a,function(m){this.afternoon=g(m,!0)}],S:[/\d/,function(m){this.milliseconds=100*+m}],SS:[o,function(m){this.milliseconds=10*+m}],SSS:[/\d{3}/,function(m){this.milliseconds=+m}],s:[i,d("seconds")],ss:[i,d("seconds")],m:[i,d("minutes")],mm:[i,d("minutes")],H:[i,d("hours")],h:[i,d("hours")],HH:[i,d("hours")],hh:[i,d("hours")],D:[i,d("day")],DD:[o,d("day")],Do:[a,function(m){var v=c.ordinal,C=m.match(/\d+/);if(this.day=C[0],v)for(var F=1;F<=31;F+=1)v(F).replace(/\[|\]/g,"")===m&&(this.day=F)}],M:[i,d("month")],MM:[o,d("month")],MMM:[a,function(m){var v=u("months"),C=(u("monthsShort")||v.map(function(F){return F.slice(0,3)})).indexOf(m)+1;if(C<1)throw new Error;this.month=C%12||C}],MMMM:[a,function(m){var v=u("months").indexOf(m)+1;if(v<1)throw new Error;this.month=v%12||v}],Y:[/[+-]?\d+/,d("year")],YY:[o,function(m){this.year=h(m)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function y(m){var v,C;v=m,C=c&&c.formats;for(var F=(m=v.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(T,b,_){var N=_&&_.toUpperCase();return b||C[_]||n[_]||C[N].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(A,O,I){return O||I.slice(1)})})).match(s),E=F.length,S=0;S<E;S+=1){var V=F[S],k=w[V],L=k&&k[0],x=k&&k[1];F[S]=x?{regex:L,parser:x}:V.replace(/^\[|\]$/g,"")}return function(T){for(var b={},_=0,N=0;_<E;_+=1){var A=F[_];if(typeof A=="string")N+=A.length;else{var O=A.regex,I=A.parser,$=T.slice(N),M=O.exec($)[0];I.call(b,M),T=T.replace(M,"")}}return function(B){var D=B.afternoon;if(D!==void 0){var W=B.hours;D?W<12&&(B.hours+=12):W===12&&(B.hours=0),delete B.afternoon}}(b),b}}return function(m,v,C){C.p.customParseFormat=!0,m&&m.parseTwoDigitYear&&(h=m.parseTwoDigitYear);var F=v.prototype,E=F.parse;F.parse=function(S){var V=S.date,k=S.utc,L=S.args;this.$u=k;var x=L[1];if(typeof x=="string"){var T=L[2]===!0,b=L[3]===!0,_=T||b,N=L[2];b&&(N=L[2]),c=this.$locale(),!T&&N&&(c=C.Ls[N]),this.$d=function($,M,B){try{if(["x","X"].indexOf(M)>-1)return new Date((M==="X"?1e3:1)*$);var D=y(M)($),W=D.year,J=D.month,j=D.day,X=D.hours,G=D.minutes,P=D.seconds,Y=D.milliseconds,re=D.zone,Q=new Date,le=j||(W||J?1:Q.getDate()),R=W||Q.getFullYear(),Z=0;W&&!J||(Z=J>0?J-1:Q.getMonth());var he=X||0,we=G||0,Ee=P||0,Oe=Y||0;return re?new Date(Date.UTC(R,Z,le,he,we,Ee,Oe+60*re.offset*1e3)):B?new Date(Date.UTC(R,Z,le,he,we,Ee,Oe)):new Date(R,Z,le,he,we,Ee,Oe)}catch{return new Date("")}}(V,x,k),this.init(),N&&N!==!0&&(this.$L=this.locale(N).$L),_&&V!=this.format(x)&&(this.$d=new Date("")),c={}}else if(x instanceof Array)for(var A=x.length,O=1;O<=A;O+=1){L[1]=x[O-1];var I=C.apply(this,L);if(I.isValid()){this.$d=I.$d,this.$L=I.$L,this.init();break}O===A&&(this.$d=new Date(""))}else E.call(this,S)}}})})(An);const Tl=An.exports;je.extend(Tl);const Ln=t=>{const{ooui:r}=t;return e.jsx(me,{...t,children:e.jsx(Fl,{ooui:r})})},Fl=t=>{const r=(n,s)=>{t.onChange&&t.onChange(s)};return e.jsx(p.TimePicker,{onChange:r,value:t.value?je(t.value,"HH:mm:ss"):void 0})},Nn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Ol,{ooui:r})})},Ol=t=>{const{value:r,onChange:n,ooui:s}=t,{required:o,selectionValues:i,readOnly:a}=s,c=r==null?void 0:r.split(","),[h,d]=l.useState([]),[f,u]=l.useState();return l.useEffect(()=>{if(!r){u(void 0),d([]);return}const g=r&&c&&c[0],w=r&&c&&c[1]&&parseInt(c[1]);d([w,void 0]),u(g)},[r]),e.jsxs(p.Row,{gutter:8,wrap:!1,children:[e.jsx(p.Col,{flex:"1",children:e.jsx(kr,{ooui:new se.Selection({name:"model_selection",selection:i,readonly:a,required:o}),onChange:g=>{u(g);let w=h[0]||0;g!==f&&(d([]),w=0);const y=`${g},${w}`;y!==r&&(n==null||n(y))},value:f})}),e.jsx(p.Col,{flex:"3",children:e.jsx(wn,{ooui:new se.Many2one({name:"object_value",relation:f,readonly:a,required:o}),value:h,onChange:g=>{d(g);const w=`${f},${g[0]||0}`;w!==r&&(n==null||n(w))}})})]})},{useToken:_l}=p.theme,Pn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Dl,{ooui:r})})},Dl=t=>{const{ooui:r,value:n,onChange:s}=t,{readOnly:o,required:i,filenameField:a}=r,{token:c}=_l(),h=i&&!o?{backgroundColor:c.colorPrimaryBg}:void 0,d=l.useRef(null),{setFieldValue:f,getFieldValue:u}=l.useContext(Ve)||{},{t:g}=l.useContext(ge),w=n?ni(n):"",y=E=>{s==null||s(E)};async function m(){const E=await st(n),S=`data:${E==null?void 0:E.mime};base64,${n}`,V=document.createElement("a"),k=u(a),L=u("name");V.href=S,V.download=k||L,V.click()}async function v(){const E=await st(n);_t(n,E.mime)}async function C(E){E.stopPropagation(),E.preventDefault();const S=E.target.files[0],V=await Yr(S);y(V),a&&f(a,S.name)}function F(){f(a,void 0),y(void 0)}return e.jsxs(p.Row,{gutter:8,children:[e.jsxs(p.Col,{style:{paddingBottom:5},children:[e.jsx("input",{type:"file",id:"file",ref:d,style:{display:"none"},onChange:C}),e.jsx(p.Input,{type:"text",disabled:!0,style:h,value:w})]}),e.jsx(p.Col,{children:e.jsxs(p.Space,{children:[e.jsx(p.Button,{icon:e.jsx(H.FolderOpenOutlined,{}),disabled:o,onClick:()=>{d.current.click()},children:"Select"}),e.jsx(p.Button,{icon:e.jsx(H.EyeOutlined,{}),disabled:!n,onClick:v,children:g("open")}),e.jsx(He,{tooltip:g("download"),disabled:!n,onClick:m,icon:e.jsx(H.DownloadOutlined,{})}),e.jsx(He,{tooltip:g("clear"),disabled:o||!n,onClick:F,icon:e.jsx(H.ClearOutlined,{})})]})})]})},ar={tree:e.jsx(H.TableOutlined,{}),form:e.jsx(H.FormOutlined,{}),graph:e.jsx(H.AreaChartOutlined,{}),calendar:e.jsx(H.CalendarOutlined,{})};function Bn(t){return t?(ar==null?void 0:ar[t.type])||e.jsx(H.FormOutlined,{}):e.jsx(H.FormOutlined,{})}function lr(t){const{currentView:r,availableViews:n,onChangeView:s,disabled:o=!1,formHasChanges:i=!1,previousView:a}=t,{t:c,lang:h}=l.useContext(ge);function d(){const g=n.map((w,y)=>e.jsx(p.Menu.Item,{children:e.jsxs(p.Row,{wrap:!1,children:[e.jsx(p.Col,{flex:"none",style:{paddingRight:20},children:Bn(w)}),e.jsx(p.Col,{flex:"auto",style:{paddingRight:20},children:w.type.charAt(0).toUpperCase()+w.type.slice(1)}),e.jsx(p.Col,{flex:"none",children:e.jsx(H.CheckOutlined,{style:{opacity:r.view_id===w.view_id?1:0}})})]})},w.view_id||y));return e.jsx(p.Menu,{onClick:u,children:e.jsx(p.Menu.ItemGroup,{title:c("viewAs"),children:g})})}function f(g){if(i){wt({lang:h,onOk:()=>{g()}});return}g()}function u(g){f(()=>{const w=n.find(y=>y.view_id===parseInt(g.key));s(w)})}return e.jsxs("div",{style:{display:"flex"},children:[e.jsx(He,{tooltip:a?c("viewAs")+" "+c(a.type):"",icon:Bn(a),style:{width:50,borderTopRightRadius:0,borderBottomRightRadius:0},onClick:()=>{u({key:a==null?void 0:a.view_id})},disabled:o||n.length===1}),e.jsx(p.Dropdown,{overlay:d(),disabled:o||n.length===1,children:e.jsx(p.Button,{style:{width:25,borderTopLeftRadius:0,borderBottomLeftRadius:0},icon:e.jsx(H.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:g=>g.preventDefault()})})]})}function ht(t){const{icon:r,tooltip:n,items:s=[],onItemClick:o,label:i,disabled:a=!1}=t;function c(){const d=s==null?void 0:s.map((f,u)=>f.name==="divider"?e.jsx(p.Menu.Divider,{},"divider"+u):e.jsx(p.Menu.Item,{children:f.name},f.id));return e.jsx(p.Menu,{onClick:h,children:e.jsx(p.Menu.ItemGroup,{title:n,children:d})})}function h(d){const f=s.find(u=>isNaN(d.key)?u.id===d.key:u.id===parseInt(d.key));o(f)}return e.jsx(p.Dropdown,{overlay:c(),disabled:a||!s||s.length===0,children:e.jsxs(p.Button,{children:[r," ",i," ",e.jsx(H.DownOutlined,{})]})})}function Ke(t){const{onClick:r,disabled:n=!1,loading:s=!1,tooltip:o,icon:i,label:a,type:c="default"}=t,h=s?e.jsx(H.LoadingOutlined,{}):i;return e.jsxs(He,{type:c,tooltip:o,onClick:r,disabled:n,children:[h,a]})}function Hn(t){const{disabled:r=!1}=t,{formHasChanges:n,onNewClicked:s}=l.useContext(We),{t:o,lang:i}=l.useContext(ge),a=()=>{if(n){wt({lang:i,onOk:()=>{s()}});return}s()};return e.jsx(Ke,{icon:e.jsx(H.FileAddOutlined,{}),tooltip:o("new"),onClick:a,disabled:r})}const{confirm:kl}=p.Modal,Ml=({onOk:t,onCancel:r,lang:n})=>{kl({title:be("unsavedChanges",n),icon:e.jsx(H.ExclamationCircleOutlined,{}),centered:!0,content:be("confirmRefreshWithoutSave",n),okText:be("discardAndRefresh",n),cancelText:be("cancel",n),onOk:t,onCancel:r})};async function Kn(t,r,n){const s=(await K.getHandler().getLogInfo({model:t,ids:[r]}))[0],{create_date:o,create_uid:i,id:a,write_date:c,write_uid:h}=s;Xe(e.jsxs("div",{children:["ID: "+a," ",e.jsx("br",{}),n("createdBy")+": "+i[1]," ",e.jsx("br",{}),n("creationDate")+": "+o," ",e.jsx("br",{}),n("lastUpdatedBy")+": "+h[1]," ",e.jsx("br",{}),n("lastUpdatedDate")+": "+c]}))}const Vl=t=>{const{numberOfAttachments:r,disabled:n}=t,{t:s,lang:o}=l.useContext(ge),[i,a]=l.useState(!1),c=e.jsxs(p.Button,{disabled:n,children:[e.jsx(H.LinkOutlined,{}),`(${r})`,e.jsx(H.DownOutlined,{style:{fontSize:12}})]});return n?c:e.jsx(p.Popover,{onVisibleChange:h=>a(h),visible:i,placement:"bottom",content:El(t,a,o),title:s("attachments"),arrowContent:null,children:c})},El=(t,r,n)=>{const{attachments:s=[],loading:o,onAddNewAttachment:i,onopenAttachmentLink:a,onOpenAttachmentDetail:c,onListAllAttachments:h}=t;return o?e.jsx(p.Spin,{style:{padding:20}}):e.jsxs(e.Fragment,{children:[e.jsxs("a",{style:{display:"block",paddingBottom:5},href:"#",onClick:()=>{r(!1),h()},children:[e.jsx(H.TableOutlined,{})," ",be("listAllAttachments",n)]}),e.jsxs("a",{style:{display:"block"},href:"#",onClick:()=>{r(!1),i()},children:[e.jsx(H.FileAddOutlined,{})," ",be("addNewAttachment",n)]}),s.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("li",{className:"ant-dropdown-menu-item-divider"}),s.map(d=>{const f=d.link?H.LinkOutlined:H.DownloadOutlined;return e.jsxs(p.Row,{style:{paddingTop:4,paddingBottom:4},wrap:!1,align:"middle",children:[e.jsx(p.Col,{flex:"auto",children:d.name}),e.jsx(p.Col,{flex:"25px",style:{textAlign:"center"},children:(d.datas_fname||d.link)&&e.jsx(p.Tooltip,{title:d.link?be("openAttachmentLink",n):be("download",n),children:e.jsx(f,{style:{cursor:"pointer"},onClick:()=>{r(!1),a(d)}})})}),e.jsx(p.Col,{flex:"25px",style:{textAlign:"center"},children:e.jsx(p.Tooltip,{title:be("openAttachment",n),children:e.jsx(H.FormOutlined,{style:{cursor:"pointer"},onClick:()=>{r(!1),c(d)}})})})]},d.id)})]})]})};function Il(t){const{attachments:r,disabled:n=!1,onAddNewAttachment:s,onListAllAttachments:o,onViewAttachmentDetails:i}=t,{formRef:a}=l.useContext(We),[c,h]=l.useState(!1),[d,f]=l.useState([]),[u,g]=l.useState(!1),{t:w}=l.useContext(ge),y=l.useCallback(async()=>{h(!0);try{const C=await K.getHandler().readObjects({model:"ir.attachment",ids:r.map(F=>F.id),fieldsToRetrieve:["name","datas_fname","link"],context:a.current.getContext()});f(C.map(F=>({id:F.id,name:F.name,datas_fname:F.datas_fname,link:F.link})))}catch(C){Le(C)}h(!1)},r),m=l.useCallback(async C=>{if(C.link){window.open(C.link);return}g(!0);let F;try{F=(await K.getHandler().readObjects({model:"ir.attachment",ids:[C.id],context:a.current.getContext()}))[0]}catch(E){Le(E)}if(g(!1),!!F)if(F.datas){const E=await st(F.datas);_t(F.datas,E.mime)}else i(F)},[]),v=l.useCallback(async C=>{i(C)},[]);return l.useEffect(()=>{y()},[y]),e.jsxs(e.Fragment,{children:[e.jsx(Vl,{numberOfAttachments:r.length,attachments:d,disabled:n,loading:c,onAddNewAttachment:s,onListAllAttachments:o,onopenAttachmentLink:m,onOpenAttachmentDetail:v}),e.jsx(p.Modal,{title:w("downloadingAttachment"),open:u,footer:null,closable:!1,centered:!0,maskClosable:!1,children:e.jsx(p.Spin,{})})]})}function Yn({toolbar:t}){const{availableViews:r,currentView:n,setCurrentView:s,onFormSave:o,formHasChanges:i,formIsSaving:a,currentId:c,results:h,setCurrentItemIndex:d,currentItemIndex:f,setCurrentId:u,currentModel:g,setRemovingItem:w,removingItem:y,duplicatingItem:m,setDuplicatingItem:v,setResults:C,formIsLoading:F,attachments:E,formRef:S,setFormHasChanges:V,previousView:k,setPreviousView:L,goToResourceId:x}=l.useContext(We),{t:T,lang:b}=l.useContext(ge),_=l.useContext(dt),{processAction:N}=_||{},A=l.useContext(ze),{openRelate:O,openDefaultActionForModel:I}=A||{};function $(P){if(i){Ml({lang:b,onOk:()=>{P()}});return}P()}function M(P){if(i){wt({lang:b,onOk:()=>{P()}});return}P()}function B(){h&&h.length>f+1?(d==null||d(f+1),u==null||u(h[f+1].id)):h&&f+1===h.length&&(d==null||d(0),u==null||u(h[0].id))}function D(){h&&f>0?(d==null||d(f-1),u==null||u(h[f-1].id)):h&&f===0&&(d==null||d(h.length-1),u==null||u(h[h.length-1].id))}function W(){ot({confirmMessage:T("confirmRemoveItem"),lang:b,onOk:()=>{J()}})}async function J(){try{w==null||w(!0),await K.getHandler().delete({model:g,ids:[c]});const P=h==null?void 0:h.filter(re=>re.id!==c);C==null||C(P);let Y=0;f>0&&f<=h.length-1&&(Y=f-1),P!=null&&P[Y]?(u==null||u(P==null?void 0:P[Y].id),d==null||d(Y)):(u==null||u(void 0),d==null||d(void 0))}catch(P){Vt(JSON.stringify(P))}finally{w==null||w(!1)}}async function j(){try{v==null||v(!0);const P=await K.getHandler().duplicate({id:c,model:g,context:S.current.getContext()});P&&await(x==null?void 0:x(P))}catch(P){Vt(JSON.stringify(P))}finally{v==null||v(!1)}}const X=a||y||F||m;function G(P){N==null||N({actionData:P,values:S.current.getValues(),fields:S.current.getFields(),context:S.current.getContext(),onRefreshParentValues:()=>{S.current.fetchValues()}})}return n?e.jsxs(p.Space,{wrap:!0,children:[F&&e.jsxs(e.Fragment,{children:[e.jsx(p.Spin,{}),pt(),pt()]}),e.jsx(Hn,{disabled:a||F||y||m}),e.jsx(Ke,{icon:e.jsx(H.SaveOutlined,{}),tooltip:T("save"),disabled:!i||X,loading:a,onClick:o}),e.jsx(Ke,{icon:e.jsx(H.CopyOutlined,{}),tooltip:T("duplicate"),disabled:i||a||c===void 0||m||F,loading:m,onClick:j}),e.jsx(Ke,{icon:e.jsx(H.DeleteOutlined,{}),tooltip:T("delete"),disabled:a||c===void 0||y||m||F,loading:y,onClick:W}),pt(),e.jsx(Ke,{icon:e.jsx(H.InfoCircleOutlined,{}),tooltip:T("showLogs"),disabled:a||c===void 0||y||m||F,loading:!1,onClick:()=>{Kn(g,c,T)}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:T("refresh"),disabled:a||c===void 0||y||m||F,loading:!1,onClick:()=>{$(()=>{S.current.fetchValues()})}}),pt(),e.jsx(lr,{currentView:n,previousView:k,availableViews:r,onChangeView:P=>{L==null||L(n),V==null||V(!1),s==null||s(P)},disabled:X,formHasChanges:i}),pt(),e.jsxs(p.Space,{children:[e.jsx(Ke,{icon:e.jsx(H.LeftOutlined,{}),tooltip:T("previous"),disabled:X,loading:!1,onClick:()=>{M(D)}}),e.jsx(Ke,{icon:e.jsx(H.RightOutlined,{}),tooltip:T("next"),disabled:X,loading:!1,onClick:()=>{M(B)}})]}),pt(),e.jsx(ht,{icon:e.jsx(H.ThunderboltOutlined,{}),disabled:X,tooltip:T("actions"),items:t==null?void 0:t.action,onItemClick:async P=>{!P||!(await gt({onFormSave:o})).succeed||G(P)}}),e.jsx(ht,{icon:e.jsx(H.PrinterOutlined,{}),disabled:X,tooltip:T("reports"),items:t==null?void 0:t.print,onItemClick:async P=>{if(!P)return;const Y=await gt({onFormSave:o});!Y.succeed||G({...P,datas:{...P.datas||{},ids:[Y.currentId]}})}}),e.jsx(ht,{icon:e.jsx(H.EnterOutlined,{}),disabled:X,tooltip:T("related"),items:t==null?void 0:t.relate,onItemClick:async P=>{!P||!(await gt({onFormSave:o})).succeed||O({relateData:P,values:S.current.getValues(),fields:S.current.getFields(),action_id:P.id,action_type:P.type})}}),e.jsx(Il,{disabled:X,attachments:E,onAddNewAttachment:async()=>{const P=await gt({onFormSave:o});if(!P.succeed)return;const Y=P.currentId,re=g;I({model:"ir.attachment",values:{selection_associated_object:`${re},${Y}`},forced_values:{res_model:re,res_id:Y},initialViewType:"form"})},onListAllAttachments:async()=>{const P=await gt({onFormSave:o});if(!P.succeed)return;const Y=P.currentId;I({model:"ir.attachment",domain:[["res_model","=",`${g}`],["res_id","=",`${Y}`]],initialViewType:"tree"})},onViewAttachmentDetails:async P=>{!(await gt({onFormSave:o})).succeed||I({model:"ir.attachment",res_id:P.id,initialViewType:"form"})}})]}):null}function pt(){return e.jsx("div",{className:"inline-block w-2"})}async function gt({onFormSave:t}){const r=await(t==null?void 0:t());return r!=null&&r.succeed?{succeed:!0,currentId:r.id}:{succeed:!1,currentId:void 0}}const{useToken:$l}=p.theme,Wn=t=>{const{ooui:r,value:n,onChange:s,valueValidator:o,linkPrefix:i=""}=t,{id:a,readOnly:c,required:h}=r,{token:d}=$l(),f=h&&!c?{backgroundColor:d.colorPrimaryBg}:void 0,u=l.useContext(Ve),{elementHasLostFocus:g}=u||{},[w,y]=l.useState(!1),[m,v]=l.useState(!1);l.useEffect(()=>{c&&!w&&v(!1),!n&&!c&&(y(!0),v(!0))},[w,c]);const C=F=>{s==null||s(F.target.value)};return e.jsxs(p.Row,{gutter:8,wrap:!1,align:"middle",children:[c?null:e.jsx(p.Col,{flex:"32px",children:w?e.jsx(p.Button,{icon:e.jsx(H.CheckOutlined,{}),onClick:()=>{o(n)&&(y(!1),v(!1))},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1}):e.jsx(p.Button,{icon:e.jsx(H.EditOutlined,{}),onClick:()=>{y(!0),v(!0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},tabIndex:-1})}),e.jsx(p.Col,{flex:"auto",children:m?e.jsx(p.Input,{style:{borderTopLeftRadius:0,borderBottomLeftRadius:0,...f},id:a,onChange:C,value:n,onBlur:()=>{o(n)&&(y(!1),v(!1),g==null||g())}}):e.jsx("a",{href:`${i}${n}`,style:{color:d.colorPrimary,paddingRight:15},target:"_blank",children:n})})]})},qn=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Wn,{ooui:r,valueValidator:s=>s?Do.default(s):!1})})},Un=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,...t,children:e.jsx(Wn,{ooui:r,linkPrefix:"mailto:",valueValidator:s=>s?ko.default(s):!1})})},Al=t=>{const{visible:r,onIdSubmitted:n,onCancel:s,isSearching:o}=t,{t:i}=l.useContext(ge),a=l.useRef();function c(h){n(h.id)}return e.jsx(p.Modal,{title:i("goToResourceId"),centered:!0,open:r,footer:null,destroyOnClose:!0,onCancel:s,maskClosable:!1,afterOpenChange:h=>{var d;return h&&((d=a.current)==null?void 0:d.focus())},children:e.jsxs(p.Form,{layout:"vertical",onFinish:c,autoComplete:"off",children:[e.jsx(p.Form.Item,{name:"id",label:i("searchId"),rules:[{required:!0,type:"number"}],children:e.jsx(p.InputNumber,{style:{width:"100%"},autoFocus:!0,ref:a})}),e.jsx(p.Row,{align:"middle",justify:"end",children:e.jsx(p.Col,{children:e.jsxs(p.Space,{children:[e.jsx(p.Button,{icon:e.jsx(H.CloseOutlined,{}),htmlType:"button",onClick:s,disabled:o,children:i("cancel")}),e.jsx(p.Button,{loading:o,style:{marginLeft:15},icon:e.jsx(H.CheckOutlined,{}),htmlType:"submit",type:"primary",disabled:o,children:i("ok")})]})})})]})})},{useToken:Ll}=p.theme;function Gn(t){const{badgeNumber:r=0,...n}=t,{token:s}=Ll();return e.jsxs("div",{style:{position:"relative"},children:[r>0&&e.jsx("div",{style:{position:"absolute",left:-10,top:-10,zIndex:2},children:e.jsx("span",{style:{display:"inline-block",minWidth:"22px",padding:"2px",borderRadius:"50%",fontSize:"12px",textAlign:"center",background:s.colorPrimaryHover,color:s.colorPrimaryBg},children:r})}),e.jsx(He,{...n,style:{width:46,zIndex:0}})]})}function Nl({refreshGraph:t}){const{t:r}=l.useContext(ge),{availableViews:n,currentView:s,setCurrentView:o,searchParams:i,searchVisible:a,setSearchVisible:c,graphIsLoading:h,previousView:d,setPreviousView:f}=l.useContext(We);return e.jsxs(p.Space,{wrap:!0,children:[e.jsx(Gn,{icon:e.jsx(H.FilterOutlined,{style:{color:a?"white":void 0}}),tooltip:r("advanced_search"),type:a?"primary":"default",onClick:()=>{c==null||c(!a)},disabled:h,badgeNumber:i==null?void 0:i.length}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:r("refresh"),disabled:h,loading:!1,onClick:()=>{t()}}),e.jsx(lr,{currentView:s,availableViews:n,onChangeView:u=>{f==null||f(s),o==null||o(u)},disabled:!1,previousView:d})]})}const{useToken:Pl}=p.theme,{Title:Bl,Text:Nt}=p.Typography;function Pt(t){const{title:r,children:n}=t,{title:s,currentView:o,currentId:i,currentItemIndex:a,results:c,totalItems:h,selectedRowItems:d}=l.useContext(We),{t:f}=l.useContext(ge),{token:u}=Pl();function g(){if((o==null?void 0:o.type)==="form")return i?h===0?e.jsxs(e.Fragment,{children:[f("editingDocument")," (id:"," ",e.jsx(Nt,{copyable:{icon:e.jsx(H.CopyOutlined,{style:{color:"red"}})},children:i}),")"]}):e.jsxs(e.Fragment,{children:[f("register")," ",a===void 0?1:a+1," /"," ",c.length," ",f("of")," ",h," - ",f("editingDocument")," (id:"," ",e.jsx(Nt,{copyable:!0,children:i}),")"]}):"";if((o==null?void 0:o.type)==="tree"&&d){if(d.length===1)return e.jsxs(e.Fragment,{children:["1 ",f("selectedRegisters")," - (id:"," ",e.jsx(Nt,{copyable:!0,children:d[0].id}),")"]});if(d.length>1)return e.jsxs(e.Fragment,{children:[d.length," ",f("selectedRegisters"),e.jsx(Nt,{copyable:{text:d.map(w=>w.id).join(", ")}})]})}return null}return e.jsxs("div",{style:{position:"sticky",top:80,zIndex:3},children:[e.jsxs(p.Row,{className:"shadow-md",style:{padding:"1em",borderRadius:u.borderRadius,backgroundColor:u.colorPrimaryBg},align:"middle",children:[e.jsxs(p.Col,{flex:2,children:[e.jsx(Bl,{level:3,style:{marginBottom:0},children:r||s}),g()]}),e.jsx(p.Col,{flex:3,children:e.jsx(p.Row,{justify:"end",children:n})})]}),e.jsx("div",{className:"pb-5"})]})}const Hl=t=>{const{viewData:r,visible:n,model:s,context:o,domain:i,formView:a,treeView:c}=t,h=l.useRef(),d=l.useContext(We),{setResults:f=void 0,setCurrentItemIndex:u=void 0,currentId:g=void 0,results:w=void 0,setSelectedRowItems:y=void 0,setSearchParams:m=void 0,searchVisible:v=!0,setSearchVisible:C=void 0,sorter:F=void 0,setSorter:E=void 0,setTotalItems:S=void 0,setSearchTreeNameSearch:V=void 0,setTreeIsLoading:k=void 0,limit:L,setLimit:x,searchParams:T,searchValues:b,setSearchValues:_,currentView:N}=d||{},[A,O]=l.useState(!0);l.useEffect(()=>{var W;(W=h.current)==null||W.refresh()},[T]),l.useEffect(()=>{r.view_id!==N.view_id&&O(!0)},[N]);const{clear:I,searchFilterLoading:$,searchError:M,offset:B,tableRefreshing:D}=rn({model:s,setSearchTreeNameSearch:V,setSelectedRowItems:y,searchParams:T,setSearchValues:_,setSearchParams:m,setSearchVisible:C,setTreeIsLoading:k,context:o,formView:a,treeView:c,sorter:F,setSorter:E,setCurrentItemIndex:u,setResultsActionView:f,resultsActionView:w,domain:i,currentId:g,setActionViewTotalItems:S,limit:L,setLimit:x});return!n||!r?null:e.jsxs(e.Fragment,{children:[e.jsx(Pt,{title:r.name,children:e.jsx(Nl,{refreshGraph:()=>{h.current.refresh()}})}),e.jsx(Qt,{fields:{...c.fields,...a.fields},searchFields:jr([a.search_fields,c.search_fields]),limit:L,onClear:I,offset:B,isSearching:$,onSubmit:W=>{O(!1),m==null||m(W.params),C==null||C(!1)},searchError:M,searchVisible:v,searchValues:b,showLimitOptions:!1}),D?e.jsx(p.Spin,{}):e.jsx(Lt,{ref:h,view_id:r.view_id,model:s,context:o,domain:Mt(T||[],i),limit:A?L:void 0,manualIds:A?w==null?void 0:w.map(W=>W.id):void 0})]})},Kl=t=>{const{visible:r,formRef:n,model:s,currentId:o,domain:i,formView:a,context:c,defaultValues:h,forcedValues:d,results:f,setResults:u,setCurrentItemIndex:g}=t;return r?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{children:e.jsx(Yn,{toolbar:a==null?void 0:a.toolbar})}),e.jsx(ut,{rootForm:!0,ref:n,model:s,defaultValues:h,forcedValues:d,formView:a,actionDomain:i,id:o,parentContext:c,onSubmitSucceed:(w,y)=>{f.findIndex(v=>v.id===w)===-1&&(f.push(y),u(f),g(f.length-1))}})]}):null};function Yl(t){const{onSearch:r,disabled:n=!1,searchText:s}=t,{t:o}=l.useContext(ge),[i]=p.Form.useForm(),[a,c]=l.useState(!1);function h(f){r(f.search)}l.useEffect(()=>{i.setFieldsValue({search:s})},[s]);function d(){c(!1),i.setFieldsValue({search:void 0}),r(void 0)}return e.jsx(p.Form,{form:i,onFinish:h,autoComplete:"off",children:e.jsxs(p.Row,{align:"middle",justify:"end",children:[e.jsx(p.Col,{children:e.jsx(p.Form.Item,{name:"search",noStyle:!0,children:e.jsx(p.Input,{autoFocus:!0,disabled:n,onChange:f=>{c(f.target.value.length>0)},style:{borderTopRightRadius:0,borderBottomRightRadius:0},suffix:(a||s&&s.length>0)&&e.jsx(p.Tooltip,{title:o("clear"),children:e.jsx(H.CloseCircleFilled,{style:{color:"rgba(0,0,0,.45)"},onClick:d})})})})}),e.jsx(p.Col,{children:e.jsx(p.Button,{htmlType:"submit",disabled:n,style:{borderTopLeftRadius:0,borderBottomLeftRadius:0},children:o("search")})})]})})}const jn=Be.default.createContext({previewFeatures:!1});function Wl(t){var X;const{availableViews:r,currentView:n,setCurrentView:s,selectedRowItems:o,setRemovingItem:i,removingItem:a,duplicatingItem:c,setDuplicatingItem:h,currentModel:d,searchTreeRef:f,setCurrentId:u,setCurrentItemIndex:g,searchParams:w,searchVisible:y,setSearchVisible:m,setSearchTreeNameSearch:v,searchTreeNameSearch:C,treeIsLoading:F,setPreviousView:E,previousView:S,results:V,limit:k,totalItems:L}=l.useContext(We),{parentContext:x={},treeExpandable:T,toolbar:b}=t,{previewFeatures:_}=l.useContext(jn),{t:N,lang:A}=l.useContext(ge),O=l.useContext(dt),{processAction:I}=O||{},[$,M]=l.useState(!1),B=C!==void 0&&C.trim().length>0;function D(){ot({confirmMessage:N("confirmRemove"),lang:A,onOk:()=>{W()}})}async function W(){var G;try{i==null||i(!0),await K.getHandler().delete({model:d,ids:o.map(P=>P.id)}),u==null||u(void 0),g==null||g(void 0),(G=f==null?void 0:f.current)==null||G.refreshResults()}catch(P){Le(P)}finally{i==null||i(!1)}}async function J(){var G;try{h==null||h(!0);const P=o[0].id;await K.getHandler().duplicate({id:P,model:d,context:{...x}})&&((G=f==null?void 0:f.current)==null||G.refreshResults())}catch(P){Le(P)}finally{h==null||h(!1)}}function j(G){I==null||I({actionData:G,values:{active_id:o==null?void 0:o.map(P=>P.id)[0],active_ids:o==null?void 0:o.map(P=>P.id)},fields:{},context:{...x,active_id:o==null?void 0:o.map(P=>P.id)[0],active_ids:o==null?void 0:o.map(P=>P.id)},onRefreshParentValues:()=>{var P;(P=f==null?void 0:f.current)==null||P.refreshResults()}})}return e.jsxs(p.Space,{wrap:!0,children:[F&&e.jsxs(e.Fragment,{children:[e.jsx(p.Spin,{}),tt(),tt()]}),T?null:e.jsxs(e.Fragment,{children:[e.jsx(Yl,{disabled:c||a||F,searchText:C,onSearch:G=>{G&&G.trim().length>0?v==null||v(G):v==null||v(void 0)}}),!T&&e.jsx(Gn,{icon:e.jsx(H.FilterOutlined,{style:{color:y?"white":void 0}}),tooltip:N("advanced_search"),type:y?"primary":"default",onClick:()=>{m==null||m(!y)},disabled:c||a||F,badgeNumber:w==null?void 0:w.length}),tt(),e.jsx(Hn,{disabled:F}),e.jsx(Ke,{icon:e.jsx(H.CopyOutlined,{}),tooltip:N("duplicate"),disabled:!o||(o==null?void 0:o.length)!==1||c||F,loading:c,onClick:J}),e.jsx(Ke,{icon:e.jsx(H.DeleteOutlined,{}),tooltip:N("delete"),disabled:!(o&&(o==null?void 0:o.length)>0)||F,loading:a,onClick:D}),tt()]}),e.jsx(Ke,{icon:e.jsx(H.InfoCircleOutlined,{}),tooltip:N("showLogs"),disabled:!(o&&(o==null?void 0:o.length)>0)||F,loading:!1,onClick:()=>{Kn(d,o[0].id,N)}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:N("refresh"),disabled:c||a||F,loading:!1,onClick:()=>{var G;(G=f==null?void 0:f.current)==null||G.refreshResults()}}),!T&&e.jsxs(e.Fragment,{children:[tt(),e.jsx(lr,{currentView:n,availableViews:r,onChangeView:G=>{E==null||E(n),s==null||s(G)},previousView:S,disabled:F})]}),tt(),e.jsx(ht,{icon:e.jsx(H.ThunderboltOutlined,{}),disabled:!(o&&(o==null?void 0:o.length)>0)||F,tooltip:N("actions"),items:b==null?void 0:b.action,onItemClick:G=>{!G||j(G)}}),e.jsx(ht,{icon:e.jsx(H.PrinterOutlined,{}),disabled:!(o&&(o==null?void 0:o.length)>0)||F,tooltip:N("reports"),items:b==null?void 0:b.print,onItemClick:G=>{!G||j({...G,datas:{...G.datas||{},ids:o.map(P=>P.id)}})}}),_&&e.jsxs(e.Fragment,{children:[tt(),e.jsx(ht,{icon:e.jsx(Sr.default,{component:()=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-database-export",width:"1em",height:"1em",viewBox:"0 0 24 24",strokeWidth:"1.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),e.jsx("ellipse",{cx:"12",cy:"6",rx:"8",ry:"3"}),e.jsx("path",{d:"M4 6v6c0 1.657 3.582 3 8 3a19.84 19.84 0 0 0 3.302 -.267m4.698 -2.733v-6"}),e.jsx("path",{d:"M4 12v6c0 1.599 3.335 2.905 7.538 2.995m8.462 -6.995v-2m-6 7h7m-3 -3l3 3l-3 3"})]})}),tooltip:N("export"),items:[{id:"print_screen",name:N("printScreen")},{id:"export",name:N("advancedExport")}],onItemClick:G=>{if(G.id==="print_screen"){let P=(o==null?void 0:o.map(Y=>Y.id))||[];P.length===0&&(P=(V==null?void 0:V.map(Y=>Y.id))||[]),j({id:-1,model:d,report_name:"printscreen.list",type:"ir.actions.report.xml",datas:{model:d,ids:P}});return}M(!0)},disabled:c||a||F||B}),e.jsx(En,{visible:$,locale:A,onClose:()=>M(!1),model:d,domain:Mt(((X=f==null?void 0:f.current)==null?void 0:X.getDomain())||[],w||[]),limit:k,totalRegisters:L||0,selectedRegistersToExport:o,visibleRegisters:(V==null?void 0:V.length)||0,context:x})]})]})}function tt(){return e.jsx("div",{className:"inline-block w-2"})}const ql=t=>{const{visible:r,searchTreeRef:n,model:s,context:o,formView:i,treeView:a,domain:c,setCurrentItemIndex:h,results:d,setCurrentId:f,setCurrentView:u,availableViews:g,searchTreeNameSearch:w}=t,{currentView:y,setPreviousView:m}=l.useContext(We);return r?e.jsxs(e.Fragment,{children:[e.jsx(Pt,{children:e.jsx(Wl,{toolbar:a==null?void 0:a.toolbar,parentContext:o,treeExpandable:(a==null?void 0:a.isExpandable)||!1})}),e.jsx(er,{ref:n,rootTree:!0,model:s,parentContext:o,nameSearch:w,formView:i,treeView:a,domain:c,onRowClicked:v=>{const{id:C}=v;f(C);const F=d.findIndex(S=>S.id===C);m==null||m(y),h(F);const E=g.find(S=>S.type==="form");u(E)}})]}):null},cr=Be.default.createContext(null),Ul=t=>{const[r,n]=l.useState(!1),[s,o]=l.useState(!1),{children:i,dashboardRef:a,openAction:c}=t;return e.jsx(cr.Provider,{value:{isLoading:r,setIsLoading:n,dashboardRef:a,openAction:c,moveItemsEnabled:s,setMoveItemsEnabled:o},children:i})};function Gl(){const{isLoading:t,dashboardRef:r,moveItemsEnabled:n,setMoveItemsEnabled:s}=l.useContext(cr),{t:o}=l.useContext(ge);return e.jsxs(p.Space,{wrap:!0,children:[e.jsx(Ke,{icon:e.jsx(H.BorderOuterOutlined,{style:{color:n?"white":void 0}}),type:n?"primary":"default",tooltip:o("moveDashboard"),disabled:t,loading:!1,onClick:()=>{s(!n)}}),jl(),e.jsx(Ke,{icon:e.jsx(H.SettingOutlined,{}),tooltip:o("configDashboard"),disabled:t,loading:!1,onClick:()=>{r==null||r.current.configDashboard()}}),e.jsx(Ke,{icon:e.jsx(H.ReloadOutlined,{}),tooltip:o("refresh"),disabled:t,loading:!1,onClick:()=>{r==null||r.current.refresh()}})]})}function jl(){return e.jsx("div",{className:"inline-block w-2"})}const zl=t=>{const{dashboardData:r}=t,n=l.useRef(),s=l.useContext(ze),{openShortcut:o}=s||{};return r?e.jsxs(Ul,{dashboardRef:n,openAction:i=>{o(i)},children:[e.jsx(Pt,{children:e.jsx(Gl,{})}),e.jsx(Xn,{ref:n,model:r.model,id:r.id,context:r==null?void 0:r.context,configAction:r==null?void 0:r.configAction})]}):null};async function Jl(t){const r=await Promise.all(t.map(async s=>{try{return await s.promise}catch(o){return console.error(`Error for ${s.viewTuple}:`,o),null}}));return t.map((s,o)=>({...s,info:r[o]})).filter(s=>s.info!==null)}function Zl(t,r){const{domain:n,model:s,context:o,views:i,title:a,setCanWeClose:c,tabKey:h,initialView:d,formDefaultValues:f,formForcedValues:u={},res_id:g=!1,action_id:w,action_type:y,treeExpandable:m=!1,limit:v}=t,[C,F]=l.useState(),[E,S]=l.useState([]),[V,k]=l.useState(!0),L=g||void 0,[x,T]=l.useState(L),[b,_]=l.useState([]),[N,A]=l.useState(),[O,I]=l.useState([]),[$,M]=l.useState(),[B,D]=l.useState(0),[W,J]=l.useState(!1),[j,X]=l.useState(!1),[G,P]=l.useState(),{t:Y}=l.useContext(ge),re=l.useRef(),Q=l.useRef(),le=l.useContext(ze),{setCurrentView:R,setCurrentId:Z,tabs:he,activeKey:we,openAction:Ee,onRemoveTab:Oe}=le||{};xo.useHotkeys("ctrl+g,command+g",te=>{te.preventDefault(),$e()},[we,he,C,N,O]);function Ie(te){T(te),Z==null||Z(te)}function Ne(te){F(te),R==null||R(te)}l.useImperativeHandle(r,()=>({canWeClose:de}));const ie=async()=>{k(!0);const te=[],Fe=[];for(const ce of i){const[fe,Pe]=ce;Pe!=="dashboard"?Fe.push({viewTuple:ce,promise:K.getHandler().getView({model:s,type:Pe,id:fe,context:o})}):Fe.push({viewTuple:ce})}const _e=await Jl(Fe);for(const ce of _e){if(!ce)continue;const[,fe]=ce.viewTuple;let Pe=ce.info;switch(fe){case"dashboard":{const ue=i.find(Ae=>{const[,ee]=Ae;return ee==="form"});let Je;ue&&(Je={action_id:w,action_type:y,name:a,res_id:o.active_id,res_model:s,view_id:ue[0],view_type:ue[1]}),te.push({type:"dashboard",id:o.active_id,model:s,context:o,configAction:Je});break}case"form":{te.push({...Pe,type:fe});break}case"tree":{te.push({...Pe,isExpandable:m,type:fe});break}case"graph":{te.push({...Pe,type:fe});break}}}let ke;!d&&te.find(ce=>ce.type==="tree")?ke=te.find(fe=>fe.type==="tree"):d?ke=te.find(fe=>d.id?fe.type===d.type&&fe.view_id===d.id:fe.type===d.type):ke=te.find(fe=>fe.type==="form"),ke||(Le(`Error determining the first view to show for model ${s}.
|
|
36
36
|
Please, make sure the view ids on the fields_view_get responses are the same as the ones defined in the action`),Oe==null||Oe(h)),Ne(ke),S(te),k(!1)};c({tabKey:h,canWeClose:de}),l.useEffect(()=>{const te=E.find(_e=>_e.type==="tree"),Fe=E.find(_e=>d.id?_e.type===d.type&&_e.view_id===d.id:_e.type===d.type);Ne(Fe||te),g?Z==null||Z(L):(Ie(void 0),A(void 0)),ie()},[s,i,g]),l.useEffect(()=>{we===h&&(Z==null||Z(x),R==null||R(C))},[he,we]);async function de(){return C&&C.type==="form"?await re.current.cancelUnsavedChanges():!0}async function $e(){we===h&&(C.type==="form"&&!await re.current.cancelUnsavedChanges()||J(!0))}async function ve(te){var ce;X(!0);const Fe=O.findIndex(fe=>fe.id===te);let _e;if(Fe===-1){try{_e=(ce=await K.getHandler().readObjects({model:s,ids:[te],context:o}))==null?void 0:ce[0]}catch{}if(!_e){X(!1),J(!1),Xe(Y("idNotFound"));return}}else _e=O[Fe];X(!1),J(!1);const ke=i.find(fe=>fe[1]==="form");Ee({domain:[],context:o,model:s,views:i,title:a,target:"current",initialView:{id:ke==null?void 0:ke[0],type:"form"},action_id:w,action_type:y,res_id:te})}function De(){return E.map(te=>{switch(te.type){case"form":return e.jsx(Kl,{formRef:re,currentId:x,visible:C.type===te.type&&C.view_id===te.view_id,formView:te,model:s,context:o,domain:n,defaultValues:f,forcedValues:u,results:O,setResults:I,setCurrentItemIndex:A},`${te.type}-${te.view_id}`);case"tree":return e.jsx(ql,{visible:C.type===te.type&&C.view_id===te.view_id,limit:v,model:s,context:o,domain:n,formView:E.find(Fe=>Fe.type==="form"),treeView:te,searchTreeRef:Q,searchTreeNameSearch:G,availableViews:E,results:O,setCurrentItemIndex:A,setCurrentId:Ie,setCurrentView:Ne},`${te.type}-${te.view_id}`);case"graph":return e.jsx(Hl,{visible:C.type===te.type&&C.view_id===te.view_id,viewData:te,model:s,context:o,domain:n,treeView:E.find(Fe=>Fe.type==="tree"),formView:E.find(Fe=>Fe.type==="form")},`${te.type}-${te.view_id}`);case"dashboard":return e.jsx(zl,{dashboardData:te},`${te.type}-${te.view_id}`)}})}function Ye(){if(x===void 0&&C.type==="form")re.current.clearAndReload();else{Ie(void 0);const te=E.find(Fe=>Fe.type==="form");Ne(te)}}return V?e.jsx(p.Spin,{}):C?e.jsxs(qi,{title:a,currentView:C,setCurrentView:Ne,availableViews:E,formRef:re,searchTreeRef:Q,onNewClicked:Ye,currentId:x,setCurrentId:Ie,setCurrentItemIndex:A,currentItemIndex:N,results:O,setResults:I,currentModel:s,sorter:$,setSorter:M,totalItems:B,setTotalItems:D,selectedRowItems:b,setSelectedRowItems:_,setSearchTreeNameSearch:P,searchTreeNameSearch:G,goToResourceId:ve,limit:v,children:[De(),e.jsx(Al,{visible:W,onIdSubmitted:ve,isSearching:j,onCancel:()=>{J(!1)}})]}):null}const zn=l.forwardRef(Zl);async function Xl({actionId:t,rootContext:r={},globalValues:n={}}){const s="ir.actions.act_window",o=`${s},${t}`,i=await K.getHandler().getActionData({action:o,context:r}),a=se.parseContext({context:i.context,values:n,fields:{}}),c=i.domain?await K.getHandler().evalDomain({domain:i.domain,values:n,context:{...r,...a}}):[],{res_model:h,views:d,name:f,limit:u,view_type:g}=i,w=g==="tree",y=[];for(const F of d){const[E,S]=F;if(E)y.push(F);else{const{view_id:V}=await K.getHandler().getView({model:h,type:S,id:E,context:{...r,...a}});y.push([V,S])}}const[m,v]=y[0],C={id:m,type:v};return{title:f,actionId:t,actionType:s,key:vr.v4(),views:d,model:h,context:{...r,...a},domain:c,initialView:C,limit:u,treeExpandable:w}}const Jc="",Ql=yr.WidthProvider(yr.Responsive),Jn=t=>{const{children:r=[],onPositionItemsChanged:n}=t,s=Be.default.Children.map(r,o=>{const{parms:i,id:a}=o.props;return e.jsx("div",{"data-grid":i,children:o},a)});return e.jsx(Ql,{className:"layout",cols:{lg:12,md:10,sm:6,xs:4,xxs:2},draggableHandle:".draggable-head",rowHeight:30,onLayoutChange:o=>{n==null||n(o.map(i=>({id:parseInt(i.i.replace(".$",""),10),x:i.x,y:i.y,w:i.w,h:i.h})))},children:s})},{useToken:Rl}=p.theme,{Text:ec}=p.Typography,Zn=t=>{const{title:r,children:n,action:s,openAction:o}=t,{token:i}=Rl();return e.jsxs("div",{className:"shadow-md",style:{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #eee",backgroundColor:"white",borderRadius:i.borderRadius},children:[e.jsxs(p.Row,{align:"middle",style:{borderBottom:"1px solid #ddd",backgroundColor:i.colorPrimaryBg},wrap:!1,children:[e.jsx(p.Col,{flex:"auto",className:"draggable-head",style:{fontWeight:"bold",padding:"0.5rem",cursor:"grab",overflow:"hidden"},children:e.jsx(ec,{ellipsis:!0,children:r})}),s&&e.jsx(p.Col,{flex:"25px",style:{padding:"0.5rem"},children:e.jsx(p.Row,{justify:"end",align:"middle",children:e.jsx(H.ExportOutlined,{style:{cursor:"pointer"},onClick:()=>{o==null||o(s)}})})})]}),n]})},tc=80;function rc(t){const{action:r,model:n,view_id:s,onRowClicked:o,domain:i=[],visible:a=!0,parentContext:c={}}=t,[h,d]=l.useState(!1),[f,u]=l.useState(!1),[g,w]=l.useState(),[y,m]=l.useState(),[v,C]=l.useState(),[F,E]=l.useState(1),[S,V]=l.useState(0),k=l.useRef(tc),L=l.useRef([]),[x,T]=l.useState(0),[b,_]=l.useState([]),[N,A]=l.useState(void 0),[O,I]=l.useState(),[$,M]=l.useState(),[B,D]=l.useState(),[W,J]=l.useState(!1),j=l.useRef([]),X=Z=>{J(!0),E(Z),V((Z-1)*k.current)},G=async()=>{const Z=j.current.length>0?j.current:i,he=Mt(L.current,Z),{colors:we}=it(y),{totalItems:Ee,results:Oe,attrsEvaluated:Ie}=await K.getHandler().searchForTree({params:he,limit:k.current,offset:S,model:g,fields:y.fields,context:c,attrs:we&&{colors:we}});A(Dt(Ie));const Ne=at({resultsToSort:Oe,sorter:O,fields:{...y.fields,...v.fields}});J(!1),_(Ne);const ie=await Ee;T(ie)},P=async()=>{try{J(!0),await G()}catch(Z){M(JSON.stringify(Z))}};l.useEffect(()=>{!f||a&&P()},[F,S,f,a]);const Y=async Z=>{u(!1),d(!0),D(void 0);try{Z==="action"?await re():await Q(),u(!0)}catch(he){D(he)}finally{d(!1)}},re=async()=>{const Z=await K.getHandler().getViewsForAction({action:r,context:c});j.current=Z.domain,C(Z.views.get("form")),m(Z.views.get("tree")),w(Z.model),k.current=Z.limit},Q=async()=>{w(n);const Z=await K.getHandler().getView({model:n,type:"form",context:c});C(Z);const he=await K.getHandler().getView({model:n,type:"tree",id:s,context:c});m(he)};l.useEffect(()=>{r?Y("action"):n&&Y("model")},[r,n]);const le=Z=>{const{id:he}=Z;o({id:he,model:g,treeView:y})},R=()=>!y||!v?null:e.jsxs("div",{style:{overflowY:"scroll"},children:[$&&e.jsx(p.Alert,{className:"mt-10",message:$,type:"error",banner:!0}),e.jsx(bt,{showPagination:!1,total:x,limit:k.current,page:F,treeView:y,results:b,onRequestPageChange:X,loading:W,onRowClicked:le,colorsForResults:N,sorter:O,onChangeSort:Z=>{I==null||I(Z);const he=at({resultsToSort:b,sorter:Z,fields:{...y.fields,...v.fields}});_(he)},context:c})]});return B?e.jsx(p.Alert,{className:"mt-10",message:B,type:"error",banner:!0}):h?e.jsx(p.Spin,{style:{padding:"2rem"}}):R()}const nc=t=>{const{model:r}=t,[n,s]=l.useState();l.useEffect(()=>{o()},[r]);async function o(){const i=await K.getHandler().search({params:[],model:r,limit:1});i.length>0&&s(i[0].id)}return e.jsx("div",{style:{padding:"0.5rem",overflowY:"scroll"},children:e.jsx(ut,{...t,model:r,id:n,readOnly:!0})})},dr="line_ids";function oc(t,r){const{model:n,context:s={},id:o,configAction:i}=t,[a,c]=l.useState([]),[h,d]=l.useState(!1),[f,u]=l.useState(),{setIsLoading:g,openAction:w,moveItemsEnabled:y}=l.useContext(cr),m=l.useRef(),v=l.useRef();l.useEffect(()=>{C()},[n,o,s]),l.useImperativeHandle(r,()=>({refresh:()=>{C()},configDashboard:L}));async function C(){d(!0),g(!0),u(void 0);try{const x=await F(),T=await S(x),b=x.fields[dr].relation,_=T[dr].items;v.current=x.fields;const N=await E({items:_,model:b,context:s}),A=await V(N);c(A),d(!1),g(!1)}catch(x){u(JSON.stringify(x))}}async function F(){return await K.getHandler().getView({model:n,type:"form",context:s})}async function E({items:x,model:T,context:b}){m.current=(await K.getHandler().getView({model:T,type:"form",context:b})).fields;const[_]=await zt({treeView:{fields:m.current},formView:{fields:m.current},model:T,items:x,context:b,currentView:"form"});return _}async function S(x){return(await K.getHandler().readObjects({model:n,ids:[o],fields:x.fields,context:s}))[0]}async function V(x){const T=[];for(const b of x){const{values:_}=b;if(_.action_id&&_.action_id.length>0){const N=parseInt(_.action_id[0],10),A=await Xl({actionId:N,rootContext:s});T.push({...b,actionData:A})}}return T}async function k(x){if(!y)return;const T=x.filter(A=>{const O=a.find($=>$.id===A.id);if(!O)return!1;if(!O.position)return!0;const I={...JSON.parse(O.position.replace(/'/g,'"')),id:O.id};return JSON.stringify(A)!==JSON.stringify(I)});if(T.length===0)return;const _=a.filter(A=>T.map(O=>O.id).includes(A.id)).map(A=>{const O={...T.find(I=>I.id===A.id)};return delete O.id,{...A},{...A,operation:"pendingUpdate",values:{...A.values,position:JSON.stringify(O).replace(/"/g,"'")}}}),N={fields:m.current,items:_};await K.getHandler().update({model:n,id:o,values:{[dr]:N},fields:v.current,context:s})}async function L(){w(i)}return f?(console.log(f),e.jsx(p.Alert,{className:"mt-10 mb-20",message:f,type:"error",banner:!0})):h?e.jsx(H.LoadingOutlined,{}):e.jsx(Jn,{onPositionItemsChanged:k,children:a.map((x,T)=>{const{actionData:b,values:_}=x,{position:N,id:A}=_,{actionId:O,actionType:I,key:$,title:M,views:B,model:D,context:W,domain:J,initialView:j,limit:X}=b;let G={};try{G=JSON.parse(N.replace(/'/g,'"'))}catch{G={x:T*2,y:0,w:2,h:3}}let P=null;if((j==null?void 0:j.type)==="graph")P=e.jsx(Lt,{view_id:B.filter(Q=>Q[1]==="graph")[0][0],model:D,context:W,domain:J,limit:X});else if((j==null?void 0:j.type)==="form")P=e.jsx(nc,{model:D,actionDomain:J});else if((j==null?void 0:j.type)==="tree")P=e.jsx(rc,{model:D,domain:J,view_id:B.filter(Q=>Q[1]==="tree")[0][0],onRowClicked:Q=>{const le=B.find(R=>{const[,Z]=R;return Z==="form"});if(le){const[R,Z]=le,{actionId:he,actionType:we,title:Ee,model:Oe}=b,Ie={action_id:he,action_type:we,name:Ee,res_id:Q.id,res_model:Oe,view_id:R,view_type:Z};w(Ie)}}});else if(j!==void 0){const Q=j&&Array.isArray(j.id)?{...j,id:j.id[0]}:j;P=e.jsx(zn,{action_id:O,action_type:I,tabKey:$,title:M,views:B,model:D,context:W,domain:J,setCanWeClose:()=>{},initialView:Q,limit:X})}let Y;const re=B.find(Q=>{const[,le]=Q;return le==="tree"});if(re){const[Q,le]=re,{actionId:R,actionType:Z,title:he,model:we}=b;Y={action_id:R,action_type:Z,name:he,res_id:!1,res_model:we,view_id:Q,view_type:le}}return e.jsx(Zn,{id:A,title:M,parms:G,action:Y,openAction:w,children:P},A)})})}const Xn=l.forwardRef(oc),Qn=t=>{const{ooui:r}=t;return e.jsx(me,{type:"array",...t,children:e.jsx(sc,{ooui:r})})},sc=t=>{const{value:r,ooui:n,onChange:s}=t,{items:o=[]}=r||{},i=o.filter(x=>x.operation!=="pendingRemove").map(x=>x.id),[a,c]=l.useState([]),[h,d]=l.useState(),[f,u]=l.useState(!1),{relation:g,context:w,readOnly:y,field:m,columns:v}=n,C=l.useContext(Ve),{getContext:F}=C||{};et.default(()=>{S()},[o]);const E=x=>{s==null||s({items:x})};async function S(){u(!0);let x=[];if(n.domain){const T=await K.getHandler().evalDomain({domain:n.domain,values:ct({fields:C==null?void 0:C.getFields(),values:C.getPlainValues()}),fields:C==null?void 0:C.getFields(),context:C.getContext()});x=[...x,...T]}try{const b=(await K.getHandler().search({model:g,params:x,fields:[m],context:{...F==null?void 0:F(),...w}})).map(_=>{const N=_[m];let A=N;return Array.isArray(N)&&(A=N[1]),{label:A,value:_.id}});c(b)}catch(T){d(T)}finally{u(!1)}if(h)return e.jsx(p.Alert,{className:"mt-10",message:h,type:"error",banner:!0})}const V=()=>{L(a.map(x=>x.value))},k=()=>{L([])},L=x=>{const T=o.map(_=>x.includes(_.id)?_.operation=="pendingRemove"?{..._,operation:"original"}:_:{id:_.id,operation:"pendingRemove"}),b=T.map(_=>_.id);x.filter(_=>!b.includes(_)).map(_=>{T.push({id:_,operation:"pendingLink"})}),E(T)};return f&&a.length===0?e.jsx(p.Spin,{}):e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex flex-row",children:[e.jsx(p.Checkbox.Group,{value:a.length?i:[],disabled:y,onChange:L,style:{width:"100%"},children:e.jsx(p.Row,{children:a.map(x=>e.jsx(p.Col,{span:Math.floor(24/v),children:e.jsx(p.Checkbox,{value:x.value,children:x.label})}))})}),!y&&e.jsxs(p.Space,{children:[e.jsx(p.Button,{onClick:V,disabled:i.length==a.length,children:"Check all"}),e.jsx(p.Button,{onClick:k,disabled:i.length===0,children:"Uncheck all"})]})]})})},Rn=t=>e.jsx(me,{...t,children:e.jsx(ic,{...t})}),ic=t=>{const{value:r,ooui:n}=t;return e.jsx("div",{style:{height:n.height?n.height+"px":"100%",overflow:"auto"},children:e.jsx(Mo.default,{children:r,className:"ant-typography"})})},eo=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"any",...t,children:e.jsx(ac,{...t})})},ac=t=>{const{ooui:r,onChange:n,value:s}=t,{selectionValues:o,readOnly:i,direction:a}=r,c=Array.from(o.entries()),h=c&&c.length&&c.map(d=>{const[f,u]=d;return e.jsx(p.Radio,{value:f,children:u},f)});return e.jsx(p.Radio.Group,{disabled:i,onChange:n,value:s,children:e.jsx(p.Space,{direction:a,children:h})})},to=t=>{const{ooui:r}=t,{id:n,readOnly:s,required:o}=r;return e.jsx(me,{...t,valuePropName:"checked",children:e.jsx(lc,{id:n,readOnly:s,required:o})})},lc=t=>{const{required:r,readOnly:n,...s}=t;return e.jsx("div",{className:"flex flex-row",children:e.jsx(p.Switch,{disabled:n,...s})})},ro=t=>{const{ooui:r}=t,{required:n}=r;return e.jsx(me,{required:n,type:"any",...t,children:e.jsx(cc,{...t})})},cc=t=>{const{ooui:r,value:n}=t,{selectionValues:s,errorField:o}=r,i=l.useContext(Ve),a=Array.from(s.entries()),c=a.map(f=>f[0]).indexOf(n);let h="process",d="";return o&&(d=i.getFieldValue(o),d&&(h="error")),e.jsx(p.Steps,{current:c,status:h,children:a.map((f,u)=>e.jsx(p.Steps.Step,{title:f[1],description:u===c&&h==="error"?d:null}))})},no=t=>{const{ooui:r}=t,{lang:n,height:s}=r,o=l.useContext(Ve),{elementHasLostFocus:i}=o||{},a=c=>{c.onDidBlurEditorWidget(i)};return e.jsx(me,{...t,children:e.jsx(Vo.default,{defaultLanguage:n||"",height:s||300,onMount:a})})};var oo={exports:{}};(function(t,r){(function(n,s){t.exports=s()})(Qe,function(){return function(n,s,o){n=n||{};var i=s.prototype,a={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function c(d,f,u,g){return i.fromToBase(d,f,u,g)}o.en.relativeTime=a,i.fromToBase=function(d,f,u,g,w){for(var y,m,v,C=u.$locale().relativeTime||a,F=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],E=F.length,S=0;S<E;S+=1){var V=F[S];V.d&&(y=g?o(d).diff(u,V.d,!0):u.diff(d,V.d,!0));var k=(n.rounding||Math.round)(Math.abs(y));if(v=y>0,k<=V.r||!V.r){k<=1&&S>0&&(V=F[S-1]);var L=C[V.l];w&&(k=w(""+k)),m=typeof L=="string"?L.replace("%d",k):L(k,f,V.l,v);break}}if(f)return m;var x=v?C.future:C.past;return typeof x=="function"?x(m):x.replace("%s",m)},i.to=function(d,f){return c(d,f,this,!0)},i.from=function(d,f){return c(d,f,this)};var h=function(d){return d.$u?o.utc():o()};i.toNow=function(d){return this.to(h(this),d)},i.fromNow=function(d){return this.from(h(this),d)}}})})(oo);const dc=oo.exports,{Meta:uc}=p.Card,{Text:fc}=p.Typography;je.extend(dc);const hc=({email:t,size:r=40,theme:n=""})=>{const s=`https://www.gravatar.com/avatar/${Eo.default(t)}?s=${r}&d=${n}`;return e.jsx(p.Avatar,{src:s,size:r})};function pc({text:t}){const r=t.split(`
|
|
37
37
|
`);return e.jsx("div",{children:r.map((n,s)=>e.jsxs(Be.default.Fragment,{children:[n,s!==r.length-1&&e.jsx("br",{})]},s))})}const gc=t=>{const{data:r,style:n}=t,{t:s}=l.useContext(ge);return e.jsxs(p.Card,{style:{...n,textAlign:"start"},children:[e.jsx(uc,{avatar:e.jsx(hc,{email:r.email,theme:"mp"}),title:r.author,description:e.jsxs(p.Space,{direction:"horizontal",children:[e.jsx("span",{title:r.date,children:je(r.date).fromNow()}),r.isAuthor&&e.jsx(p.Tag,{color:"blue",children:s("author")})]}),style:{marginBottom:"5px"}}),e.jsx(fc,{children:e.jsx(pc,{text:r.text})})]},r.id)},mc=t=>{const{value:r}=t,n=(r||[]).map(s=>{if(s.type==="action")return{children:`${s.event.date} - ${s.event.action}`};if(s.type==="comment")return{color:"gray",position:s.event.isSender?"left":"right",label:s.event.date,children:e.jsx(gc,{data:s.event})}});return e.jsx(p.Timeline,{mode:"alternate",items:n})},so=t=>e.jsx(me,{...t,children:e.jsx(mc,{})}),{Content:yc}=p.Layout,{Title:vc}=p.Typography;function wc(){const{t}=l.useContext(ge);return e.jsx(yc,{className:"m-5 select-none",children:e.jsx(vc,{level:5,children:t("welcome")})})}function Cc(t,r){const{children:n,globalValues:s={},rootContext:o={},lang:i}=t,[a,c]=l.useState("welcome"),[h,d]=l.useState([{title:be("welcome",i),key:"welcome",closable:!0,content:e.jsx(wc,{})}]),f=l.useRef(new Map),u=l.useRef();l.useImperativeHandle(r,()=>({retrieveAndOpenAction:y,openShortcut:C}));function g(S){if(S===a){const V=h.findIndex(k=>k.key===S);h[V-1]&&c(h[V-1].key),h[V+1]&&c(h[V+1].key)}d(h.filter(V=>V.key!==S)),f.current.delete(S)}function w({tabKey:S,canWeClose:V}){f.current.set(S,V)}async function y({action:S,values:V,forced_values:k,initialViewType:L,res_id:x,domain:T=[]}){const b=await K.getHandler().getActionData({action:S,context:o});if(b.type==="ir.actions.wizard"){Le("Action type not supported");return}const[_,N]=S.split(","),A=parseInt(N),O=se.parseContext({context:b.context,values:s,fields:{}}),I=b.domain?await K.getHandler().evalDomain({domain:b.domain,values:s,context:{...o,...O}}):[],{res_model:$,views:M,name:B,target:D,view_type:W,limit:J}=b,j=W==="tree",X=[];for(const P of M){const[Y,re]=P;if(Y)X.push(P);else if(re==="dashboard")X.push([void 0,"dashboard"]);else{const{view_id:Q}=await K.getHandler().getView({model:$,type:re,id:Y,context:{...o,...O}});X.push([Q,re])}}let G;if(L){const[P,Y]=X.find(([re,Q])=>Q===L);G={id:P,type:Y}}else{const[P,Y]=X[0];G={id:P,type:Y}}E({domain:[...I,...T],context:{...o,...O},model:$,views:X,title:B,target:D,initialView:G,action_type:_,action_id:A,values:V,forced_values:k,res_id:x,treeExpandable:j,limit:J})}function m({title:S,content:V,key:k,action:L}){let x=[...h];h.length===1&&h[0].key==="welcome"&&(x=[...h.filter(T=>T.key!=="welcome")]),d([...x,{title:S,key:k,closable:!0,content:V,action:L}]),c(k)}async function v({relateData:S,fields:V,values:k,action_id:L,action_type:x}){const{res_model:T,context:b,domain:_,views:N,target:A,string:O,limit:I}=S,[$,M]=N[0],B={id:$,type:M},D=se.parseContext({context:b,values:{...k,...s},fields:V}),W=_?await K.getHandler().evalDomain({domain:_,values:ct({fields:V,values:{...k,...s}}),fields:V,context:{...o,...D}}):[];E({model:T,target:A,views:N,context:{...o,...D},domain:W,title:O,initialView:B,action_id:L,action_type:x,limit:I})}async function C(S){const{action_id:V,action_type:k,res_id:L,view_id:x}=S,T=`${k},${V}`,b=await K.getHandler().getActionData({action:T,context:o}),_=se.parseContext({context:b.context,values:s,fields:{}}),N=b.domain?await K.getHandler().evalDomain({domain:b.domain,values:s,context:{...o,..._}}):[],{res_model:A,views:O,name:I,target:$,view_type:M,limit:B}=b,D=M==="tree",W=[];for(const G of O){const[P,Y]=G;if(P)W.push(G);else if(Y==="dashboard")W.push([void 0,"dashboard"]);else{const{view_id:re}=await K.getHandler().getView({model:A,type:Y,id:P,context:{...o,..._}});W.push([re,Y])}}let J,j;if(x==null){const G=W.find(P=>P[0]===void 0);J=void 0,j=G[1]}else[J,j]=W.find(G=>G[0]===void 0?!1:G[0]===x);const X={id:J,type:j};E({domain:N,context:{...o,..._},model:A,views:W,title:I,target:$,initialView:X,action_id:V,action_type:k,res_id:L,treeExpandable:D,limit:B})}async function F({model:S,values:V,forced_values:k,initialViewType:L,res_id:x,domain:T}){const b=await K.getHandler().getActionStringForModel(S);await y({action:b,values:V,forced_values:k,initialViewType:L,res_id:x,domain:T})}async function E({domain:S,context:V,model:k,views:L,title:x,target:T,initialView:b,action_id:_,action_type:N,res_id:A,values:O,forced_values:I,treeExpandable:$=!1,limit:M}){const B=vr.v4();if(T!=="current"){const D=await K.getHandler().getView({model:k,type:"form",id:b.type==="form"?b.id:void 0,context:{...o,...V}});u.current.openActionModal({domain:S,model:k,formView:D,context:{...o,...V},actionData:{action_id:_,action_type:N,res_id:A,view_id:D.view_id}})}else{const D=b&&Array.isArray(b.id)?{...b,id:b.id[0]}:b;m({title:x,action:{id:_,type:N},content:e.jsx(zn,{action_id:_,action_type:N,tabKey:B,title:x,views:L,model:k,context:{...o,...V},domain:S,setCanWeClose:w,initialView:D,res_id:A,formDefaultValues:O,formForcedValues:I,treeExpandable:$,limit:M}),key:B})}}return e.jsx(Po,{lang:i,children:e.jsx(Ui,{openShortcut:C,openAction:E,openRelate:v,openDefaultActionForModel:F,tabs:h,activeKey:a,onRemoveTab:async S=>{const V=f.current.get(S);(await(V==null?void 0:V())||a==="welcome")&&g(S)},onChangeTab:S=>{c(S)},children:e.jsx(on,{ref:u,globalValues:s,children:n})})})}const Sc=l.forwardRef(Cc),{useToken:bc}=p.theme;function xc(t){const{label:r,onClose:n,tabKey:s,isActive:o,onSelected:i}=t,{token:a}=bc(),c=o?a.colorBgContainer:a.colorPrimaryBg;return e.jsxs("div",{onClick:()=>{!o&&i(s)},style:{cursor:"pointer",height:40,paddingTop:7,paddingBottom:5,paddingLeft:10,paddingRight:10,backgroundColor:c,display:"inline-flex",flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",borderTopLeftRadius:a.borderRadius,borderTopRightRadius:a.borderRadius,marginLeft:2},children:[e.jsx("div",{style:{color:a.colorPrimaryActive,userSelect:"none",height:40,display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:5,paddingRight:5,marginBottom:2,fontWeight:o?500:"normal"},children:r}),e.jsx("div",{style:{paddingLeft:5,height:40,display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(H.CloseOutlined,{style:{color:a.colorPrimaryActive},onClick:h=>{h.stopPropagation(),n(s)}})})]})}function Tc(){const t=l.useContext(ze),{activeKey:r,tabs:n,onRemoveTab:s,onChangeTab:o}=t||{};return e.jsx(e.Fragment,{children:n.map(i=>e.jsx(xc,{tabKey:i.key,label:i.title,onClose:s,isActive:r===i.key,onSelected:o},i.key))})}function Fc(t){const{tab:r}=t,n=l.useContext(ze),{activeKey:s}=n||{},o={display:"none"};return e.jsx("div",{style:r.key!==s?o:void 0,children:r.content})}const Oc=Be.default.memo(Fc,()=>!0);function _c(){const t=l.useContext(ze),{tabs:r}=t||{},n=(r==null?void 0:r.map(s=>e.jsx(Oc,{tab:s},s.key)))||null;return e.jsx(e.Fragment,{children:n})}const{useToken:Dc}=p.theme,kc=t=>{const{onRetrieveShortcuts:r,onCheckIsFavourite:n,onAddFavourite:s,onRemoveFavourite:o}=t,[i,a]=l.useState(!1),[c,h]=l.useState(!1),[d,f]=l.useState([]),[u,g]=l.useState(!0),[w,y]=l.useState(),{t:m}=l.useContext(ge)||{},{token:v}=Dc(),C=l.useContext(ze),{openShortcut:F,tabs:E,activeKey:S,currentView:V,currentId:k,openDefaultActionForModel:L}=C||{};l.useEffect(()=>{x()},[]),l.useEffect(()=>{_()},[E,S,V,k]);async function x(){try{g(!0);const $=await r();f($)}catch($){Le($)}finally{g(!1)}}function T($){const{key:M}=$,B=d.find(D=>D.id===Number(M));(B==null?void 0:B.action_type)!=="ir.actions.wizard"&&(B&&F(B),h(!1))}function b($){$&&x(),h($)}async function _(){if(!V)return;const $=E.find(j=>j.key===S),{id:M,type:B}=($==null?void 0:$.action)||{};if(!M||!B){a(!1);return}const D=V.view_id;let W=!1;V.type==="form"&&(W=k||!1);const J=await n({action_id:M,action_type:B,view_id:D,res_id:W});J!==!1&&y(J),a(J!==!1)}async function N(){h(!1),L==null||L({model:"ir.ui.view_sc"})}const A=e.jsxs(p.Menu,{onClick:T,children:[e.jsxs("div",{style:{width:300,padding:5,display:"flex"},children:[e.jsx("div",{style:{paddingLeft:15,color:"#ccc"},children:m==null?void 0:m("favorites").toUpperCase()}),e.jsx("div",{style:{flexGrow:1,paddingLeft:10},children:e.jsx(p.Tooltip,{title:m==null?void 0:m("edit_favorites"),children:e.jsx(H.EditOutlined,{style:{color:v.colorPrimary,cursor:"pointer"},onClick:N})})})]}),e.jsx(p.Menu.Divider,{}),u?e.jsx(p.Spin,{style:{padding:"1rem"}}):d.length>0?e.jsx(e.Fragment,{children:d.map($=>e.jsx(p.Menu.Item,{children:e.jsx(O,{title:$.name,type:$.view_type})},$.id))}):e.jsx("div",{style:{width:300,padding:5,paddingLeft:15},children:m==null?void 0:m("no_favorites")})]});function O({title:$,type:M}){const B=M==="tree"?e.jsx(H.TableOutlined,{}):e.jsx(H.FormOutlined,{});return e.jsxs(p.Row,{wrap:!1,children:[e.jsx(p.Col,{flex:"none",style:{paddingRight:20},children:B}),e.jsx(p.Col,{flex:"auto",children:$})]})}async function I(){if(i&&w)await o(w);else{if(!V)return;const $=E.find(J=>J.key===S),{id:M,type:B}=($==null?void 0:$.action)||{},D=V.view_id;let W=!1;if(!M||!B){a(!1);return}V.type==="form"&&(W=k||!1),await s({action_id:M,action_type:B,view_id:D,res_id:W})}await x(),a(!i)}return e.jsxs(e.Fragment,{children:[e.jsx(p.Button,{type:i?"primary":"default",icon:i?e.jsx(H.StarFilled,{style:{color:"white"}}):e.jsx(H.StarOutlined,{}),style:{width:50,borderTopRightRadius:0,borderBottomRightRadius:0},onClick:I}),e.jsx(p.Dropdown,{overlay:A,onVisibleChange:b,open:c,children:e.jsx(p.Button,{style:{width:25,borderTopLeftRadius:0,borderBottomLeftRadius:0},icon:e.jsx(H.DownOutlined,{style:{fontSize:"0.5em"}}),onClick:$=>$.preventDefault()})})]})};U.ActionBar=Yn,U.Binary=Pn,U.Boolean=Vr,U.Button=qt,U.ButtonGroup=Fr,U.Char=Ut,U.CodeEditor=no,U.CommentsTimelineField=so,U.ConfigContext=jn,U.ConnectionProvider=K,U.ContentRootProvider=on,U.CurrentTabContent=_c,U.Dashboard=Xn,U.DashboardGrid=Jn,U.DashboardGridItem=Zn,U.Date=In,U.DateTime=$n,U.Email=Un,U.ExportModal=En,U.FavouriteButton=kc,U.Float=Xt,U.FloatTime=On,U.Form=ut,U.FormModal=ft,U.GraphIndicator=bn,U.Group=nr,U.Image=Wr,U.Integer=St,U.Label=yt,U.Many2one=vn,U.Markdown=Rn,U.MultiCheckbox=Qn,U.Notebook=_n,U.One2many=Fn,U.ProgressBar=ln,U.Radio=eo,U.Reference=Nn,U.RootView=Sc,U.SearchFilter=Qt,U.SearchModal=tr,U.SearchTree=er,U.Selection=Gt,U.Separator=kn,U.Steps=ro,U.Switch=to,U.TabSelector=Tc,U.Tag=Jr,U.Tags=Qr,U.Text=Dn,U.Time=Ln,U.Tree=bt,U.Url=qn,U.iconMapper=Ge,U.showConfirmDialog=ot,Object.defineProperties(U,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
38
38
|
//# sourceMappingURL=react-ooui.umd.js.map
|